xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_tdls.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2024 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 __HDD_TDLS_H
21 #define __HDD_TDLS_H
22 /**
23  * DOC: wlan_hdd_tdls.h
24  * WLAN Host Device Driver TDLS include file
25  */
26 
27 #include "qca_vendor.h"
28 
29 struct hdd_context;
30 
31 #ifdef FEATURE_WLAN_TDLS
32 
33 extern const struct nla_policy
34 	wlan_hdd_tdls_mode_configuration_policy
35 	[QCA_WLAN_VENDOR_ATTR_TDLS_CONFIG_MAX + 1];
36 
37 extern const struct nla_policy
38 	wlan_hdd_tdls_disc_rsp_policy
39 	[QCA_WLAN_VENDOR_ATTR_TDLS_DISC_RSP_EXT_MAX + 1];
40 
41 #define FEATURE_TDLS_VENDOR_COMMANDS                                    \
42 {                                                                       \
43 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
44 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_CONFIGURE_TDLS,        \
45 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
46 			 WIPHY_VENDOR_CMD_NEED_NETDEV |                 \
47 			 WIPHY_VENDOR_CMD_NEED_RUNNING,                 \
48 	.doit = wlan_hdd_cfg80211_configure_tdls_mode,                  \
49 	vendor_command_policy(wlan_hdd_tdls_mode_configuration_policy,  \
50 			      QCA_WLAN_VENDOR_ATTR_TDLS_CONFIG_MAX)     \
51 },                                                                     \
52 {                                                                      \
53 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                       \
54 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,          \
55 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                          \
56 		 WIPHY_VENDOR_CMD_NEED_NETDEV |                        \
57 		 WIPHY_VENDOR_CMD_NEED_RUNNING,                        \
58 	.doit = wlan_hdd_cfg80211_exttdls_enable,                      \
59 	vendor_command_policy(VENDOR_CMD_RAW_DATA, 0)                  \
60 },                                                                     \
61 {                                                                      \
62 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                       \
63 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,         \
64 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                          \
65 		 WIPHY_VENDOR_CMD_NEED_NETDEV |                        \
66 		 WIPHY_VENDOR_CMD_NEED_RUNNING,                        \
67 	.doit = wlan_hdd_cfg80211_exttdls_disable,                     \
68 	vendor_command_policy(VENDOR_CMD_RAW_DATA, 0)                  \
69 },                                                                     \
70 {                                                                      \
71 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                       \
72 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,      \
73 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                          \
74 		 WIPHY_VENDOR_CMD_NEED_NETDEV,                         \
75 	.doit = wlan_hdd_cfg80211_exttdls_get_status,                  \
76 	vendor_command_policy(VENDOR_CMD_RAW_DATA, 0)                  \
77 },                                                                     \
78 {                                                                      \
79 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                       \
80 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISC_RSP_EXT,    \
81 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                          \
82 		 WIPHY_VENDOR_CMD_NEED_NETDEV,                         \
83 	.doit = wlan_hdd_cfg80211_exttdls_set_link_id,                 \
84 	vendor_command_policy(wlan_hdd_tdls_disc_rsp_policy,           \
85 			      QCA_WLAN_VENDOR_ATTR_TDLS_DISC_RSP_EXT_TX_LINK) \
86 },
87 
88 /* Bit mask flag for tdls_option to FW */
89 #define ENA_TDLS_OFFCHAN      (1 << 0)  /* TDLS Off Channel support */
90 #define ENA_TDLS_BUFFER_STA   (1 << 1)  /* TDLS Buffer STA support */
91 #define ENA_TDLS_SLEEP_STA    (1 << 2)  /* TDLS Sleep STA support */
92 
93 int wlan_hdd_tdls_get_all_peers(struct hdd_adapter *adapter, char *buf,
94 				int buflen);
95 
96 int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
97 				     struct wireless_dev *wdev,
98 				     const void *data,
99 				     int data_len);
100 
101 int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
102 				      struct wireless_dev *wdev,
103 				      const void *data,
104 				      int data_len);
105 
106 int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
107 					 struct wireless_dev *wdev,
108 					 const void *data,
109 					 int data_len);
110 
111 /**
112  * wlan_hdd_cfg80211_exttdls_set_link_id() - set link id
113  * @wiphy:   pointer to wireless wiphy structure.
114  * @wdev:    pointer to wireless_dev structure.
115  * @data:    Pointer to the data to be passed via vendor interface
116  * @data_len:Length of the data to be passed
117  *
118  * Return:   Return the Success or Failure code.
119  */
120 int
121 wlan_hdd_cfg80211_exttdls_set_link_id(struct wiphy *wiphy,
122 				      struct wireless_dev *wdev,
123 				      const void *data,
124 				      int data_len);
125 
126 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
127 int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy,
128 				struct net_device *dev,
129 				const uint8_t *peer,
130 				enum nl80211_tdls_operation oper);
131 #else
132 int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy,
133 				struct net_device *dev,
134 				uint8_t *peer,
135 				enum nl80211_tdls_operation oper);
136 #endif
137 
138 #ifdef TDLS_MGMT_VERSION5
139 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
140 				struct net_device *dev, const uint8_t *peer,
141 				uint8_t action_code, uint8_t dialog_token,
142 				uint16_t status_code, uint32_t peer_capability,
143 				bool initiator, const uint8_t *buf,
144 				size_t len, int link_id);
145 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0))
146 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
147 				struct net_device *dev, const u8 *peer,
148 				int link_id, u8 action_code,
149 				u8 dialog_token, u16 status_code,
150 				u32 peer_capability, bool initiator,
151 				const u8 *buf, size_t len);
152 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
153 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
154 				struct net_device *dev, const uint8_t *peer,
155 				uint8_t action_code, uint8_t dialog_token,
156 				uint16_t status_code, uint32_t peer_capability,
157 				bool initiator, const uint8_t *buf,
158 				size_t len);
159 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0))
160 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
161 				struct net_device *dev, const uint8_t *peer,
162 				uint8_t action_code, uint8_t dialog_token,
163 				uint16_t status_code, uint32_t peer_capability,
164 				const uint8_t *buf, size_t len);
165 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) || defined(TDLS_MGMT_VERSION2)
166 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
167 				struct net_device *dev, uint8_t *peer,
168 				uint8_t action_code, uint8_t dialog_token,
169 				uint16_t status_code, uint32_t peer_capability,
170 				const uint8_t *buf, size_t len);
171 #else
172 int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy,
173 				struct net_device *dev, uint8_t *peer,
174 				uint8_t action_code, uint8_t dialog_token,
175 				uint16_t status_code, const uint8_t *buf,
176 				size_t len);
177 #endif
178 
179 /**
180  * hdd_set_tdls_offchannel() - set tdls off-channel number
181  * @hdd_ctx:     Pointer to the HDD context
182  * @adapter: Pointer to the HDD adapter
183  * @offchannel: tdls off-channel number
184  *
185  * This function sets tdls off-channel number
186  *
187  * Return: 0 on success; negative errno otherwise
188  */
189 int hdd_set_tdls_offchannel(struct hdd_context *hdd_ctx,
190 			    struct hdd_adapter *adapter,
191 			    int offchannel);
192 
193 /**
194  * hdd_get_tdls_connected_peer_count() - Gets connected TDLS peer count.
195  * @link_info: Pointer to link_info in hdd adapter
196  *
197  * This function return number of connected peer.
198  *
199  * Return: void
200  */
201 uint16_t
202 hdd_get_tdls_connected_peer_count(struct wlan_hdd_link_info *link_info);
203 
204 /**
205  * hdd_check_and_set_tdls_conn_params() - Sets and Overwrite netdev params if
206  *                               stations is connected in 11A, 11B and 11G mode.
207  * @vdev: Pointer to vdev objmgr
208  *
209  * This function updates the netdev params such as enabling checksum/tso
210  * if the feature "disable checksum/tso for 11abg connections" is enabled via
211  * INI. if INI is enabled then 11abg sta link will be created by disabling
212  * checksum/tso which are needed to be enabled for better throughput
213  * for TDLS connected in 11AX, 11AC, 11N mode
214  *
215  * Return: void
216  */
217 void hdd_check_and_set_tdls_conn_params(struct wlan_objmgr_vdev *vdev);
218 
219 /**
220  * hdd_check_and_set_tdls_disconn_params() - Overwrite netdev params if BSS
221  *                                           STA link is 11A, 11B and 11G mode
222  *                                           when TDLS is disconnected
223  * @vdev: Pointer to vdev objmgr
224  *
225  * During TDLS connection if STA-BSS link is in 11a, 11b, 11g mode, then
226  * legacy netdev features such as checksum/tso are enabled. This function will
227  * take care of disabling them during TDLS disconnection if the feature
228  * "disable checksum/tso for 11abg connections" is enabled via INI.
229  *
230  * Return: void
231  */
232 void hdd_check_and_set_tdls_disconn_params(struct wlan_objmgr_vdev *vdev);
233 
234 /**
235  * hdd_set_tdls_secoffchanneloffset() - set secondary tdls off-channel offset
236  * @hdd_ctx:     Pointer to the HDD context
237  * @adapter: Pointer to the HDD adapter
238  * @offchanoffset: tdls off-channel offset
239  *
240  * This function sets secondary tdls off-channel offset
241  *
242  * Return: 0 on success; negative errno otherwise
243  */
244 int hdd_set_tdls_secoffchanneloffset(struct hdd_context *hdd_ctx,
245 				     struct hdd_adapter *adapter,
246 				     int offchanoffset);
247 
248 /**
249  * hdd_set_tdls_offchannelmode() - set tdls off-channel mode
250  * @hdd_ctx:     Pointer to the HDD context
251  * @adapter: Pointer to the HDD adapter
252  * @offchanmode: tdls off-channel mode
253  * 1-Enable Channel Switch
254  * 2-Disable Channel Switch
255  *
256  * This function sets tdls off-channel mode
257  *
258  * Return: 0 on success; negative errno otherwise
259  */
260 int hdd_set_tdls_offchannelmode(struct hdd_context *hdd_ctx,
261 				struct hdd_adapter *adapter,
262 				int offchanmode);
263 int hdd_set_tdls_scan_type(struct hdd_context *hdd_ctx, int val);
264 
265 /**
266  * wlan_hdd_tdls_antenna_switch() - Dynamic TDLS antenna  switch 1x1 <-> 2x2
267  * antenna mode in standalone station
268  * @link_info: Pointer to link_info in hdd adapter
269  * @mode: enum antenna_mode
270  *
271  * Return: 0 if success else non zero
272  */
273 int wlan_hdd_tdls_antenna_switch(struct wlan_hdd_link_info *link_info,
274 				 uint32_t mode);
275 
276 /**
277  * wlan_hdd_cfg80211_configure_tdls_mode() - configure tdls mode
278  * @wiphy:   pointer to wireless wiphy structure.
279  * @wdev:    pointer to wireless_dev structure.
280  * @data:    Pointer to the data to be passed via vendor interface
281  * @data_len:Length of the data to be passed
282  *
283  * Return:   Return the Success or Failure code.
284  */
285 int wlan_hdd_cfg80211_configure_tdls_mode(struct wiphy *wiphy,
286 					struct wireless_dev *wdev,
287 					const void *data,
288 					int data_len);
289 
290 QDF_STATUS hdd_tdls_register_peer(void *userdata, uint32_t vdev_id,
291 				  const uint8_t *mac, uint8_t qos);
292 
293 /**
294  * hdd_init_tdls_config() - initialize tdls config
295  * @tdls_cfg: pointer to tdls_start_params structure
296  *
297  * Return: none
298  */
299 void hdd_init_tdls_config(struct tdls_start_params *tdls_cfg);
300 
301 /**
302  * hdd_config_tdls_with_band_switch() - configure tdls when band changes
303  *                                      Disable tdls offchmode if only one of
304  *                                      bands is supported
305  *                                      Enable tdls offchmode if all band enable
306  * @hdd_ctx:     Pointer to the HDD context
307  *
308  * Return: none
309  */
310 void hdd_config_tdls_with_band_switch(struct hdd_context *hdd_ctx);
311 #else
312 
313 #define FEATURE_TDLS_VENDOR_COMMANDS
314 
315 static inline int
wlan_hdd_tdls_antenna_switch(struct wlan_hdd_link_info * link_info,uint32_t mode)316 wlan_hdd_tdls_antenna_switch(struct wlan_hdd_link_info *link_info,
317 			     uint32_t mode)
318 {
319 	return 0;
320 }
321 
wlan_hdd_cfg80211_configure_tdls_mode(struct wiphy * wiphy,struct wireless_dev * wdev,const void * data,int data_len)322 static inline int wlan_hdd_cfg80211_configure_tdls_mode(struct wiphy *wiphy,
323 					struct wireless_dev *wdev,
324 					const void *data,
325 					int data_len)
326 {
327 	return 0;
328 }
329 
330 static inline
hdd_tdls_register_peer(void * userdata,uint32_t vdev_id,const uint8_t * mac,uint8_t qos)331 QDF_STATUS hdd_tdls_register_peer(void *userdata, uint32_t vdev_id,
332 				  const uint8_t *mac, uint8_t qos)
333 {
334 	return QDF_STATUS_SUCCESS;
335 }
336 
hdd_init_tdls_config(struct tdls_start_params * tdls_cfg)337 static inline void hdd_init_tdls_config(struct tdls_start_params *tdls_cfg)
338 {
339 }
340 
hdd_config_tdls_with_band_switch(struct hdd_context * hdd_ctx)341 static inline void hdd_config_tdls_with_band_switch(struct hdd_context *hdd_ctx)
342 {
343 }
344 
345 static inline uint16_t
hdd_get_tdls_connected_peer_count(struct wlan_hdd_link_info * link_info)346 hdd_get_tdls_connected_peer_count(struct wlan_hdd_link_info *link_info)
347 {
348 	return 0;
349 }
350 
351 static inline void
hdd_check_and_set_tdls_conn_params(struct wlan_objmgr_vdev * vdev)352 hdd_check_and_set_tdls_conn_params(struct wlan_objmgr_vdev *vdev)
353 {
354 }
355 
356 static inline void
hdd_check_and_set_tdls_disconn_params(struct wlan_objmgr_vdev * vdev)357 hdd_check_and_set_tdls_disconn_params(struct wlan_objmgr_vdev *vdev)
358 {
359 }
360 #endif /* End of FEATURE_WLAN_TDLS */
361 #endif /* __HDD_TDLS_H */
362