xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_wext.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 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 #ifndef __WEXT_IW_H__
21 #define __WEXT_IW_H__
22 
23 #include <linux/version.h>
24 #include <linux/module.h>
25 #include <linux/netdevice.h>
26 #include <linux/wireless.h>
27 #include <net/iw_handler.h>
28 #include <linux/timer.h>
29 #include "qdf_event.h"
30 
31 struct hdd_context;
32 struct sap_config;
33 
34 /*
35  * order of parameters in addTs private ioctl
36  */
37 #define HDD_WLAN_WMM_PARAM_HANDLE                       0
38 #define HDD_WLAN_WMM_PARAM_TID                          1
39 #define HDD_WLAN_WMM_PARAM_DIRECTION                    2
40 #define HDD_WLAN_WMM_PARAM_APSD                         3
41 #define HDD_WLAN_WMM_PARAM_USER_PRIORITY                4
42 #define HDD_WLAN_WMM_PARAM_NOMINAL_MSDU_SIZE            5
43 #define HDD_WLAN_WMM_PARAM_MAXIMUM_MSDU_SIZE            6
44 #define HDD_WLAN_WMM_PARAM_MINIMUM_DATA_RATE            7
45 #define HDD_WLAN_WMM_PARAM_MEAN_DATA_RATE               8
46 #define HDD_WLAN_WMM_PARAM_PEAK_DATA_RATE               9
47 #define HDD_WLAN_WMM_PARAM_MAX_BURST_SIZE              10
48 #define HDD_WLAN_WMM_PARAM_MINIMUM_PHY_RATE            11
49 #define HDD_WLAN_WMM_PARAM_SURPLUS_BANDWIDTH_ALLOWANCE 12
50 #define HDD_WLAN_WMM_PARAM_SERVICE_INTERVAL            13
51 #define HDD_WLAN_WMM_PARAM_SUSPENSION_INTERVAL         14
52 #define HDD_WLAN_WMM_PARAM_BURST_SIZE_DEFN             15
53 #define HDD_WLAN_WMM_PARAM_ACK_POLICY                  16
54 #define HDD_WLAN_WMM_PARAM_INACTIVITY_INTERVAL         17
55 #define HDD_WLAN_WMM_PARAM_MAX_SERVICE_INTERVAL        18
56 #define HDD_WLAN_WMM_PARAM_COUNT                       19
57 
58 #define MHZ 6
59 
60 #define WE_MAX_STR_LEN                                 IW_PRIV_SIZE_MASK
61 #define WLAN_HDD_UI_BAND_AUTO                          0
62 #define WLAN_HDD_UI_BAND_5_GHZ                         1
63 #define WLAN_HDD_UI_BAND_2_4_GHZ                       2
64 
65 enum hdd_wlan_wmm_direction {
66 	HDD_WLAN_WMM_DIRECTION_UPSTREAM = 0,
67 	HDD_WLAN_WMM_DIRECTION_DOWNSTREAM = 1,
68 	HDD_WLAN_WMM_DIRECTION_BIDIRECTIONAL = 2,
69 };
70 
71 enum hdd_wlan_wmm_power_save {
72 	HDD_WLAN_WMM_POWER_SAVE_LEGACY = 0,
73 	HDD_WLAN_WMM_POWER_SAVE_UAPSD = 1,
74 };
75 
76 typedef enum {
77 	/* TSPEC/re-assoc done, async */
78 	HDD_WLAN_WMM_STATUS_SETUP_SUCCESS = 0,
79 	/* no need to setup TSPEC since ACM=0 and no UAPSD desired,
80 	 * sync + async
81 	 */
82 	HDD_WLAN_WMM_STATUS_SETUP_SUCCESS_NO_ACM_NO_UAPSD = 1,
83 	/* no need to setup TSPEC since ACM=0 and UAPSD already exists,
84 	 * sync + async
85 	 */
86 	HDD_WLAN_WMM_STATUS_SETUP_SUCCESS_NO_ACM_UAPSD_EXISTING = 2,
87 	/* TSPEC result pending, sync */
88 	HDD_WLAN_WMM_STATUS_SETUP_PENDING = 3,
89 	/* TSPEC/re-assoc failed, sync + async */
90 	HDD_WLAN_WMM_STATUS_SETUP_FAILED = 4,
91 	/* Request rejected due to invalid params, sync + async */
92 	HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM = 5,
93 	/* TSPEC request rejected since AP!=QAP, sync */
94 	HDD_WLAN_WMM_STATUS_SETUP_FAILED_NO_WMM = 6,
95 
96 	/* TSPEC modification/re-assoc successful, async */
97 	HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS = 7,
98 	/* TSPEC modification a no-op since ACM=0 and
99 	 * no change in UAPSD, sync + async
100 	 */
101 	HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS_NO_ACM_NO_UAPSD = 8,
102 	/* TSPEC modification a no-op since ACM=0 and
103 	 * requested U-APSD already exists, sync + async
104 	 */
105 	HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS_NO_ACM_UAPSD_EXISTING = 9,
106 	/* TSPEC result pending, sync */
107 	HDD_WLAN_WMM_STATUS_MODIFY_PENDING = 10,
108 	/* TSPEC modification failed, prev TSPEC in effect, sync + async */
109 	HDD_WLAN_WMM_STATUS_MODIFY_FAILED = 11,
110 	/* TSPEC modification request rejected due to invalid params,
111 	 * sync + async
112 	 */
113 	HDD_WLAN_WMM_STATUS_MODIFY_FAILED_BAD_PARAM = 12,
114 
115 	/* TSPEC release successful, sync and also async */
116 	HDD_WLAN_WMM_STATUS_RELEASE_SUCCESS = 13,
117 	/* TSPEC release pending, sync */
118 	HDD_WLAN_WMM_STATUS_RELEASE_PENDING = 14,
119 	/* TSPEC release failed, sync + async */
120 	HDD_WLAN_WMM_STATUS_RELEASE_FAILED = 15,
121 	/* TSPEC release rejected due to invalid params, sync */
122 	HDD_WLAN_WMM_STATUS_RELEASE_FAILED_BAD_PARAM = 16,
123 	/* TSPEC modified due to the mux'ing of requests on ACs, async */
124 
125 	HDD_WLAN_WMM_STATUS_MODIFIED = 17,
126 	/* TSPEC revoked by AP, async */
127 	HDD_WLAN_WMM_STATUS_LOST = 18,
128 	/* some internal failure like memory allocation failure, etc, sync */
129 	HDD_WLAN_WMM_STATUS_INTERNAL_FAILURE = 19,
130 
131 	/* U-APSD failed during setup but OTA setup (whether TSPEC exchange or
132 	 * re-assoc) was done so app should release this QoS, async
133 	 */
134 	HDD_WLAN_WMM_STATUS_SETUP_UAPSD_SET_FAILED = 20,
135 	/* U-APSD failed during modify, but OTA setup (whether TSPEC exchange or
136 	 * re-assoc) was done so app should release this QoS, async
137 	 */
138 	HDD_WLAN_WMM_STATUS_MODIFY_UAPSD_SET_FAILED = 21
139 } hdd_wlan_wmm_status_e;
140 
141 /** Enable 11d */
142 #define ENABLE_11D  1
143 
144 /** Disable 11d */
145 #define DISABLE_11D 0
146 
147 #define HDD_RTSCTS_EN_MASK                  0xF
148 #define HDD_RTSCTS_ENABLE                   1
149 #define HDD_CTS_ENABLE                      2
150 
151 #define HDD_AUTO_RATE_SGI    0x8
152 
153 /* Packet Types. */
154 #define WLAN_KEEP_ALIVE_UNSOLICIT_ARP_RSP     2
155 #define WLAN_KEEP_ALIVE_NULL_PKT              1
156 
157 /*
158  * Defines for fw_test command
159  */
160 #define HDD_FWTEST_PARAMS 3
161 #define HDD_FWTEST_SU_PARAM_ID 53
162 #define HDD_FWTEST_MU_PARAM_ID 2
163 #define HDD_FWTEST_SU_DEFAULT_VALUE 100
164 #define HDD_FWTEST_MU_DEFAULT_VALUE 40
165 #define HDD_FWTEST_MAX_VALUE 500
166 
167 #ifdef WLAN_WEXT_SUPPORT_ENABLE
168 /**
169  * hdd_register_wext() - register wext context
170  * @dev: net device handle
171  *
172  * Registers wext interface context for a given net device
173  *
174  * Returns: None
175  */
176 void hdd_register_wext(struct net_device *dev);
177 
178 /**
179  * hdd_wext_unregister() - unregister wext context with rtnl lock dependency
180  * @dev: net device from which wireless extensions are being unregistered
181  * @rtnl_held: flag which indicates if caller is holding the rtnl_lock
182  *
183  * Unregisters wext context for a given net device. This behaves the
184  * same as hdd_unregister_wext() except it does not take the rtnl_lock
185  * if the caller is already holding it.
186  *
187  * Returns: None
188  */
189 void hdd_wext_unregister(struct net_device *dev,
190 			 bool rtnl_held);
191 
192 static inline
hdd_wext_send_event(struct net_device * dev,unsigned int cmd,union iwreq_data * wrqu,const char * extra)193 void hdd_wext_send_event(struct net_device *dev, unsigned int cmd,
194 			 union iwreq_data *wrqu, const char *extra)
195 {
196 	wireless_send_event(dev, cmd, wrqu, extra);
197 }
198 
199 /**
200  * hdd_wlan_get_stats() - Get txrx stats in SAP mode
201  * @link_info: Link info pointer in HDD adapter
202  * @length:   Size of the data copied
203  * @buffer:   Pointer to char buffer.
204  * @buf_len:  Length of the char buffer.
205  *
206  * This function called when the "iwpriv wlan0 get_stats" command is given.
207  * It used to collect the txrx stats when the device is configured in SAP mode.
208  *
209  * Return - none
210  */
211 void hdd_wlan_get_stats(struct wlan_hdd_link_info *link_info, uint16_t *length,
212 			char *buffer, uint16_t buf_len);
213 
214 void hdd_wlan_list_fw_profile(uint16_t *length,
215 			      char *buffer, uint16_t buf_len);
216 
217 int iw_set_var_ints_getnone(struct net_device *dev,
218 			   struct iw_request_info *info,
219 			   union iwreq_data *wrqu, char *extra);
220 
221 int iw_set_three_ints_getnone(struct net_device *dev,
222 			     struct iw_request_info *info,
223 			     union iwreq_data *wrqu, char *extra);
224 
225 int hdd_priv_get_data(struct iw_point *p_priv_data,
226 		     union iwreq_data *wrqu);
227 
228 void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len);
229 
230 /**
231  * hdd_we_set_short_gi() - Set adapter Short GI
232  * @link_info: Link info pointer in HDD adapter
233  * @sgi: new sgi value
234  *
235  * Return: 0 on success, negative errno on failure
236  */
237 int hdd_we_set_short_gi(struct wlan_hdd_link_info *link_info, int sgi);
238 
239 /**
240  * hdd_assemble_rate_code() - assemble rate code to be sent to FW
241  * @preamble: rate preamble
242  * @nss: number of streams
243  * @rate: rate index
244  *
245  * Rate code assembling is different for targets which are 11ax capable.
246  * Check for the target support and assemble the rate code accordingly.
247  *
248  * Return: assembled rate code
249  */
250 int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate);
251 
252 /**
253  * hdd_set_11ax_rate() - set 11ax rate
254  * @adapter: adapter being modified
255  * @value: new 11ax rate code
256  * @sap_config: pointer to SAP config to check HW mode
257  *              this will be NULL for call from STA persona
258  *
259  * Return: 0 on success, negative errno on failure
260  */
261 int hdd_set_11ax_rate(struct hdd_adapter *adapter, int value,
262 		      struct sap_config *sap_config);
263 
264 /**
265  * hdd_we_update_phymode() - handle change in PHY mode
266  * @link_info: Link info pointer in HDD adapter.
267  * @new_phymode: new PHY mode for the device
268  *
269  * This function is called when the device is set to a new PHY mode.
270  * It takes a holistic look at the desired PHY mode along with the
271  * configured capabilities of the driver and the reported capabilities
272  * of the hardware in order to correctly configure all PHY-related
273  * parameters.
274  *
275  * Return: 0 on success, negative errno value on error
276  */
277 int hdd_we_update_phymode(struct wlan_hdd_link_info *link_info,
278 			  int new_phymode);
279 
280 /**
281  * wlan_hdd_set_btcoex_mode() - set BTCoex Mode
282  * @link_info: Link info pointer in HDD adapter
283  * @value: new BTCoex mode for the adapter
284  *
285  * This function is called to set a BTCoex Operation Mode
286  *
287  * Return: 0 on success, negative errno value on error
288  */
289 int wlan_hdd_set_btcoex_mode(struct wlan_hdd_link_info *link_info, int value);
290 
291 /**
292  * wlan_hdd_set_btcoex_rssi_threshold() - set RSSI threshold
293  * @link_info: Link info pointer in HDD adapter
294  * @value: new RSSI Threshold for the adapter
295  *
296  * This function is called to set a new RSSI threshold for
297  * change of Coex operating mode from TDD to FDD
298  *
299  * Return: 0 on success, negative errno value on error
300  */
301 int wlan_hdd_set_btcoex_rssi_threshold(struct wlan_hdd_link_info *link_info,
302 				       int value);
303 
304 struct iw_request_info;
305 
306 /**
307  * hdd_check_private_wext_control() - Check to see if private
308  *      wireless extensions ioctls are allowed
309  * @hdd_ctx: Global HDD context
310  * @info: Wireless extensions ioctl information passed by the kernel
311  *
312  * This function will examine the "private_wext_control" configuration
313  * item to determine whether or not private wireless extensions ioctls
314  * are allowed.
315  *
316  * Return: 0 if the ioctl is allowed to be processed, -ENOTSUPP if the
317  * ioctls have been disabled. Note that in addition to returning
318  * status, this function will log a message if the ioctls are disabled
319  * or deprecated.
320  */
321 int hdd_check_private_wext_control(struct hdd_context *hdd_ctx,
322 				   struct iw_request_info *info);
323 
324 #ifdef CONFIG_DP_TRACE
325 void hdd_set_dump_dp_trace(uint16_t cmd_type, uint16_t count);
326 #else
327 static inline
hdd_set_dump_dp_trace(uint16_t cmd_type,uint16_t count)328 void hdd_set_dump_dp_trace(uint16_t cmd_type, uint16_t count) {}
329 #endif
330 #else /* WLAN_WEXT_SUPPORT_ENABLE */
hdd_register_wext(struct net_device * dev)331 static inline void hdd_register_wext(struct net_device *dev)
332 {
333 }
334 
hdd_wext_unregister(struct net_device * dev,bool rtnl_locked)335 static inline void hdd_wext_unregister(struct net_device *dev,
336 				       bool rtnl_locked)
337 {
338 }
339 
340 static inline
hdd_wext_send_event(struct net_device * dev,unsigned int cmd,union iwreq_data * wrqu,const char * extra)341 void hdd_wext_send_event(struct net_device *dev, unsigned int cmd,
342 			 union iwreq_data *wrqu, const char *extra)
343 {
344 }
345 #endif /* WLAN_WEXT_SUPPORT_ENABLE */
346 
347 #if defined(WLAN_WEXT_SUPPORT_ENABLE) && defined(HASTINGS_BT_WAR)
348 int hdd_hastings_bt_war_enable_fw(struct hdd_context *hdd_ctx);
349 int hdd_hastings_bt_war_disable_fw(struct hdd_context *hdd_ctx);
350 #else
351 static inline
hdd_hastings_bt_war_enable_fw(struct hdd_context * hdd_ctx)352 int hdd_hastings_bt_war_enable_fw(struct hdd_context *hdd_ctx)
353 {
354 	return -ENOTSUPP;
355 }
356 
357 static inline
hdd_hastings_bt_war_disable_fw(struct hdd_context * hdd_ctx)358 int hdd_hastings_bt_war_disable_fw(struct hdd_context *hdd_ctx)
359 {
360 	return -ENOTSUPP;
361 }
362 
363 #endif
364 
365 #endif /* __WEXT_IW_H__ */
366