wlan_nlink_common.h 9.6 KB

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