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