wlan_nlink_common.h 9.1 KB

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