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