wlan_nlink_common.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /*===========================================================================
  19. \file wlan_nlink_common.h
  20. Exports and types for the Netlink Service interface. This header file contains
  21. message types and definitions that is shared between the user space service
  22. (e.g. logging service) and WLAN kernel module.
  23. ===========================================================================*/
  24. #ifndef WLAN_NLINK_COMMON_H__
  25. #define WLAN_NLINK_COMMON_H__
  26. #include <linux/netlink.h>
  27. #ifdef __KERNEL__
  28. #include <linux/if.h>
  29. #else
  30. #include <net/if.h>
  31. #endif
  32. /*---------------------------------------------------------------------------
  33. * External Functions
  34. *-------------------------------------------------------------------------*/
  35. /*---------------------------------------------------------------------------
  36. * Preprocessor Definitions and Constants
  37. *-------------------------------------------------------------------------*/
  38. #define WLAN_NL_MAX_PAYLOAD 5120 /* maximum size for netlink message */
  39. #define WLAN_NLINK_PROTO_FAMILY NETLINK_USERSOCK
  40. #define WLAN_NLINK_MCAST_GRP_ID 0x01
  41. /*---------------------------------------------------------------------------
  42. * Type Declarations
  43. *-------------------------------------------------------------------------*/
  44. /*
  45. * The following enum defines the target service within WLAN driver for which the
  46. * message is intended for. Each service along with its counterpart
  47. * in the user space, define a set of messages they recognize.
  48. * Each of this message will have an header of type tAniMsgHdr defined below.
  49. * Each Netlink message to/from a kernel module will contain only one
  50. * message which is preceded by a tAniMsgHdr. The maximun size (in bytes) of
  51. * a netlink message is assumed to be MAX_PAYLOAD bytes.
  52. *
  53. * +------------+-------+----------+----------+
  54. * |Netlink hdr | Align |tAniMsgHdr| msg body |
  55. * +------------+-------+----------|----------+
  56. */
  57. /* Message Types */
  58. #define WLAN_SVC_FW_CRASHED_IND 0x100
  59. #define WLAN_SVC_LTE_COEX_IND 0x101
  60. #define WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND 0x102
  61. #define WLAN_SVC_DFS_CAC_START_IND 0x103
  62. #define WLAN_SVC_DFS_CAC_END_IND 0x104
  63. #define WLAN_SVC_DFS_RADAR_DETECT_IND 0x105
  64. #define WLAN_SVC_WLAN_STATUS_IND 0x106
  65. #define WLAN_SVC_WLAN_VERSION_IND 0x107
  66. #define WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND 0x108
  67. #define WLAN_SVC_WLAN_TP_IND 0x109
  68. #define WLAN_SVC_RPS_ENABLE_IND 0x10A
  69. #define WLAN_SVC_WLAN_TP_TX_IND 0x10B
  70. #define WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND 0x10C
  71. #define WLAN_SVC_WLAN_RADIO_INDEX 0x10D
  72. #define WLAN_SVC_FW_SHUTDOWN_IND 0x10E
  73. #define WLAN_SVC_CORE_MINFREQ 0x10F
  74. #define WLAN_SVC_MAX_SSID_LEN 32
  75. #define WLAN_SVC_MAX_BSSID_LEN 6
  76. #define WLAN_SVC_MAX_STR_LEN 16
  77. #define WLAN_SVC_MAX_NUM_CHAN 128
  78. #define WLAN_SVC_COUNTRY_CODE_LEN 3
  79. #define ANI_NL_MSG_BASE 0x10 /* Some arbitrary base */
  80. typedef enum eAniNlModuleTypes {
  81. ANI_NL_MSG_PUMAC = ANI_NL_MSG_BASE + 0x01, /* PTT Socket App */
  82. ANI_NL_MSG_PTT = ANI_NL_MSG_BASE + 0x07, /* Quarky GUI */
  83. WLAN_NL_MSG_OEM = ANI_NL_MSG_BASE + 0x09,
  84. WLAN_NL_MSG_SVC,
  85. WLAN_NL_MSG_CNSS_DIAG = ANI_NL_MSG_BASE + 0x0B, /* Value needs to be 27 */
  86. ANI_NL_MSG_LOG,
  87. WLAN_NL_MSG_SPECTRAL_SCAN,
  88. ANI_NL_MSG_MAX
  89. } tAniNlModTypes, tWlanNlModTypes;
  90. #define WLAN_NL_MSG_BASE ANI_NL_MSG_BASE
  91. #define WLAN_NL_MSG_MAX ANI_NL_MSG_MAX
  92. /* All Netlink messages must contain this header */
  93. typedef struct sAniHdr {
  94. unsigned short type;
  95. unsigned short length;
  96. } tAniHdr, tAniMsgHdr;
  97. typedef struct sAniNlMsg {
  98. struct nlmsghdr nlh; /* Netlink Header */
  99. int radio; /* unit number of the radio */
  100. tAniHdr wmsg; /* Airgo Message Header */
  101. } tAniNlHdr;
  102. struct radio_index_tlv {
  103. unsigned short type;
  104. unsigned short length;
  105. int radio;
  106. };
  107. /**
  108. * struct svc_channel_info - Channel information
  109. * @chan_id: Channel ID
  110. * @reserved0: Reserved for padding and future use
  111. * @mhz: Primary 20 MHz channel frequency in MHz
  112. * @band_center_freq1: Center frequency 1 in MHz
  113. * @band_center_freq2: Center frequency 2 in MHz
  114. * @info: Channel info
  115. * @reg_info_1: Regulatory information field 1 which contains
  116. * MIN power, MAX power, reg power and reg class ID
  117. * @reg_info_2: Regulatory information field 2 which contains antennamax
  118. */
  119. struct svc_channel_info {
  120. uint32_t chan_id;
  121. uint32_t reserved0;
  122. uint32_t mhz;
  123. uint32_t band_center_freq1;
  124. uint32_t band_center_freq2;
  125. uint32_t info;
  126. uint32_t reg_info_1;
  127. uint32_t reg_info_2;
  128. };
  129. struct wlan_status_data {
  130. uint8_t lpss_support;
  131. uint8_t is_on;
  132. uint8_t vdev_id;
  133. uint8_t is_connected;
  134. int8_t rssi;
  135. uint8_t ssid_len;
  136. uint8_t country_code[WLAN_SVC_COUNTRY_CODE_LEN];
  137. uint32_t vdev_mode;
  138. uint32_t freq;
  139. uint32_t numChannels;
  140. uint8_t channel_list[WLAN_SVC_MAX_NUM_CHAN];
  141. uint8_t ssid[WLAN_SVC_MAX_SSID_LEN];
  142. uint8_t bssid[WLAN_SVC_MAX_BSSID_LEN];
  143. struct svc_channel_info channel_info[WLAN_SVC_MAX_NUM_CHAN];
  144. };
  145. struct wlan_version_data {
  146. uint32_t chip_id;
  147. char chip_name[WLAN_SVC_MAX_STR_LEN];
  148. char chip_from[WLAN_SVC_MAX_STR_LEN];
  149. char host_version[WLAN_SVC_MAX_STR_LEN];
  150. char fw_version[WLAN_SVC_MAX_STR_LEN];
  151. };
  152. struct wlan_dfs_info {
  153. uint16_t channel;
  154. uint8_t country_code[WLAN_SVC_COUNTRY_CODE_LEN];
  155. };
  156. /*
  157. * Maximim number of queues supported by WLAN driver. Setting an upper
  158. * limit. Actual number of queues may be smaller than this value.
  159. */
  160. #define WLAN_SVC_IFACE_NUM_QUEUES 6
  161. /**
  162. * struct wlan_rps_data - structure to send RPS info to cnss-daemon
  163. * @ifname: interface name for which the RPS data belongs to
  164. * @num_queues: number of rx queues for which RPS data is being sent
  165. * @cpu_map_list: array of cpu maps for different rx queues supported by
  166. * the wlan driver
  167. *
  168. * The structure specifies the format of data exchanged between wlan
  169. * driver and cnss-daemon. On receipt of the data, cnss-daemon is expected
  170. * to apply the 'cpu_map' for each rx queue belonging to the interface 'ifname'
  171. */
  172. struct wlan_rps_data {
  173. char ifname[IFNAMSIZ];
  174. uint16_t num_queues;
  175. uint16_t cpu_map_list[WLAN_SVC_IFACE_NUM_QUEUES];
  176. };
  177. /**
  178. * enum wlan_tp_level - indicates wlan throughput level
  179. * @WLAN_SVC_TP_NONE: used for initialization
  180. * @WLAN_SVC_TP_LOW: used to identify low throughput level
  181. * @WLAN_SVC_TP_MEDIUM: used to identify medium throughput level
  182. * @WLAN_SVC_TP_HIGH: used to identify high throughput level
  183. *
  184. * The different throughput levels are determined on the basis of # of tx and
  185. * rx packets and other threshold values. For example, if the # of total
  186. * packets sent or received by the driver is greater than 500 in the last 100ms
  187. * , the driver has a high throughput requirement. The driver may tweak certain
  188. * system parameters based on the throughput level.
  189. */
  190. enum wlan_tp_level {
  191. WLAN_SVC_TP_NONE,
  192. WLAN_SVC_TP_LOW,
  193. WLAN_SVC_TP_MEDIUM,
  194. WLAN_SVC_TP_HIGH,
  195. };
  196. /**
  197. * struct wlan_core_minfreq - msg to [re]set the min freq of a set of cores
  198. * @magic: signature token: 0xBABA
  199. * @reserved: unused for now
  200. * @coremask: bitmap of cores (16 bits) bit0=CORE0, bit1=CORE1, ...
  201. * coremask is ONLY valid for set command
  202. * valid values: 0xf0, or 0x0f
  203. * @freq: frequency in KH
  204. * > 0: "set to the given frequency"
  205. * == 0: "free; remove the lock"
  206. *
  207. * Msg structure passed by the driver to cnss-daemon.
  208. *
  209. * Semantical Alert:
  210. * There can be only one outstanding lock, even for different masks.
  211. */
  212. #define WLAN_CORE_MINFREQ_MAGIC 0xBABA
  213. struct wlan_core_minfreq {
  214. uint16_t magic;
  215. uint16_t reserved;
  216. uint16_t coremask;
  217. uint16_t freq;
  218. };
  219. /* Indication to enable TCP delayed ack in TPUT indication */
  220. #define TCP_DEL_ACK_IND (1 << 0)
  221. #define TCP_DEL_ACK_IND_MASK 0x1
  222. /* Indication to enable TCP advance window scaling in TPUT indication */
  223. #define TCP_ADV_WIN_SCL (1 << 1)
  224. #define TCP_ADV_WIN_SCL_MASK 0x2
  225. /* TCP limit output bytes for low and high TPUT */
  226. #define TCP_LIMIT_OUTPUT_BYTES_LOW 506072
  227. #define TCP_LIMIT_OUTPUT_BYTES_HI 4048579
  228. /* TCP window scale for low and high TPUT */
  229. #define WIN_SCALE_LOW 2
  230. #define WIN_SCALE_HI 1
  231. /* TCP DEL ACK value for low and high TPUT */
  232. #define TCP_DEL_ACK_LOW 0
  233. #define TCP_DEL_ACK_HI 20
  234. /**
  235. * struct wlan_rx_tp_data - msg to TCP delayed ack and advance window scaling
  236. * @level: Throughput level.
  237. * @rx_tp_flags: Bit map of flags, for which this indcation will take
  238. * effect, bit map for TCP_ADV_WIN_SCL and TCP_DEL_ACK_IND.
  239. */
  240. struct wlan_rx_tp_data {
  241. enum wlan_tp_level level;
  242. uint16_t rx_tp_flags;
  243. };
  244. /**
  245. * struct wlan_tx_tp_data - msg to TCP for Tx Dir
  246. * @level: Throughput level.
  247. * @tcp_limit_output: Tcp limit output flag.
  248. *
  249. */
  250. struct wlan_tx_tp_data {
  251. enum wlan_tp_level level;
  252. bool tcp_limit_output;
  253. };
  254. #endif /* WLAN_NLINK_COMMON_H__ */