xref: /wlan-driver/qcacld-3.0/components/tdls/dispatcher/src/wlan_tdls_ucfg_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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 /**
21  * DOC: wlan_tdls_ucfg_api.c
22  *
23  * TDLS north bound interface definitions
24  */
25 
26 #include <wlan_tdls_ucfg_api.h>
27 #include <wlan_tdls_tgt_api.h>
28 #include "../../core/src/wlan_tdls_main.h"
29 #include "../../core/src/wlan_tdls_cmds_process.h"
30 #include "../../core/src/wlan_tdls_ct.h"
31 #include "../../core/src/wlan_tdls_mgmt.h"
32 #include <wlan_objmgr_global_obj.h>
33 #include <wlan_objmgr_cmn.h>
34 #include "wlan_policy_mgr_api.h"
35 #include "wlan_scan_ucfg_api.h"
36 #include "cfg_tdls.h"
37 #include "wlan_mlo_mgr_sta.h"
38 #include "cfg_ucfg_api.h"
39 #include "wlan_tdls_api.h"
40 
ucfg_tdls_init(void)41 QDF_STATUS ucfg_tdls_init(void)
42 {
43 	QDF_STATUS status;
44 
45 	tdls_notice("tdls module dispatcher init");
46 	status = wlan_objmgr_register_psoc_create_handler(WLAN_UMAC_COMP_TDLS,
47 		tdls_psoc_obj_create_notification, NULL);
48 
49 	if (QDF_IS_STATUS_ERROR(status)) {
50 		tdls_err("Failed to register psoc create handler for tdls");
51 		return status;
52 	}
53 
54 	status = wlan_objmgr_register_psoc_destroy_handler(WLAN_UMAC_COMP_TDLS,
55 		tdls_psoc_obj_destroy_notification, NULL);
56 
57 	if (QDF_IS_STATUS_ERROR(status)) {
58 		tdls_err("Failed to register psoc delete handler for tdls");
59 		goto fail_delete_psoc;
60 	}
61 
62 	status = wlan_objmgr_register_vdev_create_handler(WLAN_UMAC_COMP_TDLS,
63 		tdls_vdev_obj_create_notification, NULL);
64 
65 	if (QDF_IS_STATUS_ERROR(status)) {
66 		tdls_err("Failed to register vdev create handler for tdls");
67 		goto fail_create_vdev;
68 	}
69 
70 	status = wlan_objmgr_register_vdev_destroy_handler(WLAN_UMAC_COMP_TDLS,
71 		tdls_vdev_obj_destroy_notification, NULL);
72 
73 	if (QDF_IS_STATUS_ERROR(status)) {
74 		tdls_err("Failed to register vdev create handler for tdls");
75 		goto fail_delete_vdev;
76 	}
77 	tdls_notice("tdls module dispatcher init done");
78 
79 	return status;
80 fail_delete_vdev:
81 	wlan_objmgr_unregister_vdev_create_handler(WLAN_UMAC_COMP_TDLS,
82 		tdls_vdev_obj_create_notification, NULL);
83 
84 fail_create_vdev:
85 	wlan_objmgr_unregister_psoc_destroy_handler(WLAN_UMAC_COMP_TDLS,
86 		tdls_psoc_obj_destroy_notification, NULL);
87 
88 fail_delete_psoc:
89 	wlan_objmgr_unregister_psoc_create_handler(WLAN_UMAC_COMP_TDLS,
90 		tdls_psoc_obj_create_notification, NULL);
91 
92 	return status;
93 }
94 
ucfg_tdls_deinit(void)95 QDF_STATUS ucfg_tdls_deinit(void)
96 {
97 	QDF_STATUS ret;
98 
99 	tdls_notice("tdls module dispatcher deinit");
100 	ret = wlan_objmgr_unregister_psoc_create_handler(WLAN_UMAC_COMP_TDLS,
101 				tdls_psoc_obj_create_notification, NULL);
102 	if (QDF_IS_STATUS_ERROR(ret))
103 		tdls_err("Failed to unregister psoc create handler");
104 
105 	ret = wlan_objmgr_unregister_psoc_destroy_handler(WLAN_UMAC_COMP_TDLS,
106 				tdls_psoc_obj_destroy_notification, NULL);
107 	if (QDF_IS_STATUS_ERROR(ret))
108 		tdls_err("Failed to unregister psoc delete handler");
109 
110 	ret = wlan_objmgr_unregister_vdev_create_handler(WLAN_UMAC_COMP_TDLS,
111 				tdls_vdev_obj_create_notification, NULL);
112 	if (QDF_IS_STATUS_ERROR(ret))
113 		tdls_err("Failed to unregister vdev create handler");
114 
115 	ret = wlan_objmgr_unregister_vdev_destroy_handler(WLAN_UMAC_COMP_TDLS,
116 				tdls_vdev_obj_destroy_notification, NULL);
117 
118 	if (QDF_IS_STATUS_ERROR(ret))
119 		tdls_err("Failed to unregister vdev delete handler");
120 
121 	return ret;
122 }
123 
124 /**
125  * tdls_update_feature_flag() - update tdls feature flag
126  * @tdls_soc_obj:   pointer to tdls psoc object
127  *
128  * This function updates tdls feature flag
129  */
130 static void
tdls_update_feature_flag(struct tdls_soc_priv_obj * tdls_soc_obj)131 tdls_update_feature_flag(struct tdls_soc_priv_obj *tdls_soc_obj)
132 {
133 	tdls_soc_obj->tdls_configs.tdls_feature_flags =
134 		((tdls_soc_obj->tdls_configs.tdls_off_chan_enable ?
135 		  1 << TDLS_FEATURE_OFF_CHANNEL : 0) |
136 		 (tdls_soc_obj->tdls_configs.tdls_wmm_mode_enable ?
137 		  1 << TDLS_FEATURE_WMM : 0) |
138 		 (tdls_soc_obj->tdls_configs.tdls_buffer_sta_enable ?
139 		  1 << TDLS_FEATURE_BUFFER_STA : 0) |
140 		 (tdls_soc_obj->tdls_configs.tdls_sleep_sta_enable ?
141 		  1 << TDLS_FEATURE_SLEEP_STA : 0) |
142 		 (tdls_soc_obj->tdls_configs.tdls_scan_enable ?
143 		  1 << TDLS_FEATURE_SCAN : 0) |
144 		 (tdls_soc_obj->tdls_configs.tdls_support_enable ?
145 		  1 << TDLS_FEATURE_ENABLE : 0) |
146 		 (tdls_soc_obj->tdls_configs.tdls_implicit_trigger_enable ?
147 		  1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) |
148 		 (tdls_soc_obj->tdls_configs.tdls_external_control &
149 		  TDLS_STRICT_EXTERNAL_CONTROL ?
150 		  1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0) |
151 		 (tdls_soc_obj->tdls_configs.tdls_external_control &
152 		  TDLS_LIBERAL_EXTERNAL_CONTROL ?
153 		  1 << TDLS_FEATURE_LIBERAL_EXTERNAL_CONTROL : 0));
154 }
155 
156 /**
157  * tdls_object_init_params() - init parameters for tdls object
158  * @tdls_soc_obj: pointer to tdls psoc object
159  *
160  * This function init parameters for tdls object
161  */
tdls_object_init_params(struct tdls_soc_priv_obj * tdls_soc_obj)162 static QDF_STATUS tdls_object_init_params(
163 	struct tdls_soc_priv_obj *tdls_soc_obj)
164 {
165 	struct wlan_objmgr_psoc *psoc;
166 
167 	if (!tdls_soc_obj) {
168 		tdls_err("invalid param");
169 		return QDF_STATUS_E_INVAL;
170 	}
171 
172 	psoc = tdls_soc_obj->soc;
173 	if (!psoc) {
174 		tdls_err("invalid psoc object");
175 		return QDF_STATUS_E_INVAL;
176 	}
177 
178 	tdls_soc_obj->tdls_configs.tdls_tx_states_period =
179 			cfg_get(psoc, CFG_TDLS_TX_STATS_PERIOD);
180 	tdls_soc_obj->tdls_configs.tdls_tx_pkt_threshold =
181 			cfg_get(psoc, CFG_TDLS_TX_PACKET_THRESHOLD);
182 	tdls_soc_obj->tdls_configs.tdls_rx_pkt_threshold =
183 			cfg_get(psoc, CFG_TDLS_RX_FRAME_THRESHOLD);
184 	tdls_soc_obj->tdls_configs.tdls_max_discovery_attempt =
185 			cfg_get(psoc, CFG_TDLS_MAX_DISCOVERY_ATTEMPT);
186 	tdls_soc_obj->tdls_configs.tdls_idle_timeout =
187 			cfg_get(psoc, CFG_TDLS_IDLE_TIMEOUT);
188 	tdls_soc_obj->tdls_configs.tdls_idle_pkt_threshold =
189 			cfg_get(psoc, CFG_TDLS_IDLE_PACKET_THRESHOLD);
190 	tdls_soc_obj->tdls_configs.tdls_rssi_trigger_threshold =
191 			cfg_get(psoc, CFG_TDLS_RSSI_TRIGGER_THRESHOLD);
192 	tdls_soc_obj->tdls_configs.tdls_rssi_teardown_threshold =
193 			cfg_get(psoc, CFG_TDLS_RSSI_TEARDOWN_THRESHOLD);
194 	tdls_soc_obj->tdls_configs.tdls_rssi_delta =
195 			cfg_get(psoc, CFG_TDLS_RSSI_DELTA);
196 	tdls_soc_obj->tdls_configs.tdls_uapsd_mask =
197 			cfg_get(psoc, CFG_TDLS_QOS_WMM_UAPSD_MASK);
198 	tdls_soc_obj->tdls_configs.tdls_uapsd_inactivity_time =
199 			cfg_get(psoc, CFG_TDLS_PUAPSD_INACT_TIME);
200 	tdls_soc_obj->tdls_configs.tdls_uapsd_pti_window =
201 			cfg_get(psoc, CFG_TDLS_PUAPSD_PEER_TRAFFIC_IND_WINDOW);
202 	tdls_soc_obj->tdls_configs.tdls_uapsd_ptr_timeout =
203 			cfg_get(psoc, CFG_TDLS_PUAPSD_PEER_TRAFFIC_RSP_TIMEOUT);
204 	tdls_soc_obj->tdls_configs.tdls_pre_off_chan_num =
205 			cfg_get(psoc, CFG_TDLS_PREFERRED_OFF_CHANNEL_NUM);
206 	tdls_soc_obj->tdls_configs.tdls_pre_off_chan_freq_6g =
207 			cfg_get(psoc, CFG_TDLS_PREFERRED_OFF_CHANNEL_FREQ_6G);
208 	tdls_soc_obj->tdls_configs.tdls_pre_off_chan_bw =
209 			cfg_get(psoc, CFG_TDLS_PREFERRED_OFF_CHANNEL_BW);
210 	tdls_soc_obj->tdls_configs.tdls_peer_kickout_threshold =
211 			cfg_get(psoc, CFG_TDLS_PEER_KICKOUT_THRESHOLD);
212 	tdls_soc_obj->tdls_configs.tdls_discovery_wake_timeout =
213 			cfg_get(psoc, CFG_TDLS_DISCOVERY_WAKE_TIMEOUT);
214 	tdls_soc_obj->tdls_configs.delayed_trig_framint =
215 			cfg_get(psoc, CFG_TL_DELAYED_TRGR_FRM_INTERVAL);
216 	tdls_soc_obj->tdls_configs.tdls_wmm_mode_enable =
217 			cfg_get(psoc,  CFG_TDLS_WMM_MODE_ENABLE);
218 	tdls_soc_obj->tdls_configs.tdls_off_chan_enable =
219 			cfg_get(psoc, CFG_TDLS_OFF_CHANNEL_ENABLED);
220 	tdls_soc_obj->tdls_configs.tdls_buffer_sta_enable =
221 			cfg_get(psoc, CFG_TDLS_BUF_STA_ENABLED);
222 	tdls_soc_obj->tdls_configs.tdls_scan_enable =
223 			cfg_get(psoc, CFG_TDLS_SCAN_ENABLE);
224 	tdls_soc_obj->tdls_configs.tdls_support_enable =
225 			cfg_get(psoc, CFG_TDLS_SUPPORT_ENABLE);
226 	tdls_soc_obj->tdls_configs.tdls_implicit_trigger_enable =
227 			cfg_get(psoc, CFG_TDLS_IMPLICIT_TRIGGER);
228 	tdls_soc_obj->tdls_configs.tdls_external_control =
229 			cfg_get(psoc, CFG_TDLS_EXTERNAL_CONTROL);
230 	tdls_soc_obj->max_num_tdls_sta =
231 			cfg_get(psoc, CFG_TDLS_MAX_PEER_COUNT);
232 
233 	tdls_update_feature_flag(tdls_soc_obj);
234 
235 	return QDF_STATUS_SUCCESS;
236 }
237 
238 #ifdef TDLS_WOW_ENABLED
239 /**
240  * tdls_wow_init() - Create/init wake lock for TDLS
241  * @soc_obj: TDLS private soc object
242  *
243  * Create/init wake lock for TDLS if DVR isn't supported
244  *
245  * Return None
246  */
tdls_wow_init(struct tdls_soc_priv_obj * soc_obj)247 static void tdls_wow_init(struct tdls_soc_priv_obj *soc_obj)
248 {
249 	soc_obj->is_prevent_suspend = false;
250 	soc_obj->is_drv_supported = qdf_is_drv_supported();
251 	if (!soc_obj->is_drv_supported) {
252 		qdf_wake_lock_create(&soc_obj->wake_lock, "wlan_tdls");
253 		qdf_runtime_lock_init(&soc_obj->runtime_lock);
254 	}
255 }
256 
257 /**
258  * tdls_wow_deinit() - Destroy/deinit wake lock for TDLS
259  * @soc_obj: TDLS private soc object
260  *
261  * Destroy/deinit wake lock for TDLS if DVR isn't supported
262  *
263  * Return None
264  */
tdls_wow_deinit(struct tdls_soc_priv_obj * soc_obj)265 static void tdls_wow_deinit(struct tdls_soc_priv_obj *soc_obj)
266 {
267 	if (!soc_obj->is_drv_supported) {
268 		qdf_runtime_lock_deinit(&soc_obj->runtime_lock);
269 		qdf_wake_lock_destroy(&soc_obj->wake_lock);
270 	}
271 }
272 #else
tdls_wow_init(struct tdls_soc_priv_obj * soc_obj)273 static void tdls_wow_init(struct tdls_soc_priv_obj *soc_obj)
274 {
275 }
276 
tdls_wow_deinit(struct tdls_soc_priv_obj * soc_obj)277 static void tdls_wow_deinit(struct tdls_soc_priv_obj *soc_obj)
278 {
279 }
280 #endif
281 
tdls_global_init(struct tdls_soc_priv_obj * soc_obj)282 static QDF_STATUS tdls_global_init(struct tdls_soc_priv_obj *soc_obj)
283 {
284 	tdls_object_init_params(soc_obj);
285 	soc_obj->connected_peer_count = 0;
286 	soc_obj->tdls_nss_switch_in_progress = false;
287 	soc_obj->tdls_teardown_peers_cnt = 0;
288 	soc_obj->tdls_nss_teardown_complete = false;
289 	soc_obj->tdls_nss_transition_mode = TDLS_NSS_TRANSITION_S_UNKNOWN;
290 	soc_obj->enable_tdls_connection_tracker = false;
291 	soc_obj->tdls_external_peer_count = 0;
292 	soc_obj->is_user_tdls_enable = true;
293 
294 	qdf_spinlock_create(&soc_obj->tdls_ct_spinlock);
295 	tdls_wow_init(soc_obj);
296 
297 	return QDF_STATUS_SUCCESS;
298 }
299 
tdls_global_deinit(struct tdls_soc_priv_obj * soc_obj)300 static QDF_STATUS tdls_global_deinit(struct tdls_soc_priv_obj *soc_obj)
301 {
302 	tdls_wow_deinit(soc_obj);
303 	qdf_spinlock_destroy(&soc_obj->tdls_ct_spinlock);
304 
305 	return QDF_STATUS_SUCCESS;
306 }
307 
ucfg_tdls_psoc_open(struct wlan_objmgr_psoc * psoc)308 QDF_STATUS ucfg_tdls_psoc_open(struct wlan_objmgr_psoc *psoc)
309 {
310 	QDF_STATUS status;
311 	struct tdls_soc_priv_obj *soc_obj;
312 
313 	tdls_debug("tdls psoc open");
314 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
315 							WLAN_UMAC_COMP_TDLS);
316 	if (!soc_obj) {
317 		tdls_err("Failed to get tdls psoc component");
318 		return QDF_STATUS_E_FAILURE;
319 	}
320 
321 	status = tdls_global_init(soc_obj);
322 
323 	return status;
324 }
325 
ucfg_tdls_update_fw_wideband_capability(struct wlan_objmgr_psoc * psoc,bool is_fw_tdls_wideband_capable)326 void ucfg_tdls_update_fw_wideband_capability(struct wlan_objmgr_psoc *psoc,
327 					     bool is_fw_tdls_wideband_capable)
328 {
329 	struct tdls_soc_priv_obj *soc_obj;
330 
331 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
332 							WLAN_UMAC_COMP_TDLS);
333 	if (!soc_obj) {
334 		tdls_err("Failed to get tdls psoc component");
335 		return;
336 	}
337 
338 	soc_obj->fw_tdls_wideband_capability = is_fw_tdls_wideband_capable;
339 }
340 
ucfg_tdls_is_fw_wideband_capable(struct wlan_objmgr_psoc * psoc)341 bool ucfg_tdls_is_fw_wideband_capable(struct wlan_objmgr_psoc *psoc)
342 {
343 	struct tdls_soc_priv_obj *soc_obj;
344 
345 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
346 							WLAN_UMAC_COMP_TDLS);
347 	if (!soc_obj) {
348 		tdls_err("Failed to get tdls psoc component");
349 		return false;
350 	}
351 
352 	tdls_debug("FW wideband capability %d",
353 		   soc_obj->fw_tdls_wideband_capability);
354 
355 	return soc_obj->fw_tdls_wideband_capability;
356 }
357 
358 #ifdef WLAN_FEATURE_11BE
ucfg_tdls_update_fw_mlo_capability(struct wlan_objmgr_psoc * psoc,bool is_fw_tdls_mlo_capable)359 void ucfg_tdls_update_fw_mlo_capability(struct wlan_objmgr_psoc *psoc,
360 					bool is_fw_tdls_mlo_capable)
361 {
362 	struct tdls_soc_priv_obj *soc_obj;
363 
364 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
365 							WLAN_UMAC_COMP_TDLS);
366 	if (!soc_obj) {
367 		tdls_err("Failed to get tdls psoc component");
368 		return;
369 	}
370 
371 	soc_obj->fw_tdls_mlo_capable = is_fw_tdls_mlo_capable;
372 }
373 #endif
374 
375 #ifdef WLAN_FEATURE_11AX
ucfg_tdls_update_fw_11ax_capability(struct wlan_objmgr_psoc * psoc,bool is_fw_tdls_11ax_capable)376 void ucfg_tdls_update_fw_11ax_capability(struct wlan_objmgr_psoc *psoc,
377 					 bool is_fw_tdls_11ax_capable)
378 {
379 	struct tdls_soc_priv_obj *soc_obj;
380 
381 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
382 							WLAN_UMAC_COMP_TDLS);
383 	if (!soc_obj) {
384 		tdls_err("Failed to get tdls psoc component");
385 		return;
386 	}
387 
388 	soc_obj->fw_tdls_11ax_capability = is_fw_tdls_11ax_capable;
389 }
390 
ucfg_update_fw_tdls_6g_capability(struct wlan_objmgr_psoc * psoc,bool is_fw_tdls_6g_capable)391 void ucfg_update_fw_tdls_6g_capability(struct wlan_objmgr_psoc *psoc,
392 				       bool is_fw_tdls_6g_capable)
393 {
394 	struct tdls_soc_priv_obj *soc_obj;
395 
396 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
397 							WLAN_UMAC_COMP_TDLS);
398 	if (!soc_obj) {
399 		tdls_err("Failed to get tdls psoc component");
400 		return;
401 	}
402 
403 	soc_obj->fw_tdls_6g_capability = is_fw_tdls_6g_capable;
404 }
405 
ucfg_tdls_is_fw_11ax_capable(struct wlan_objmgr_psoc * psoc)406 bool  ucfg_tdls_is_fw_11ax_capable(struct wlan_objmgr_psoc *psoc)
407 {
408 	struct tdls_soc_priv_obj *soc_obj;
409 
410 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
411 							WLAN_UMAC_COMP_TDLS);
412 	if (!soc_obj) {
413 		tdls_err("Failed to get tdls psoc component");
414 		return false;
415 	}
416 	tdls_debug("FW 11AX capability %d", soc_obj->fw_tdls_11ax_capability);
417 
418 	return soc_obj->fw_tdls_11ax_capability;
419 }
420 
ucfg_tdls_is_fw_6g_capable(struct wlan_objmgr_psoc * psoc)421 bool  ucfg_tdls_is_fw_6g_capable(struct wlan_objmgr_psoc *psoc)
422 {
423 	struct tdls_soc_priv_obj *soc_obj;
424 
425 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
426 							WLAN_UMAC_COMP_TDLS);
427 	if (!soc_obj) {
428 		tdls_err("Failed to get tdls psoc component");
429 		return false;
430 	}
431 	tdls_debug("FW 6g capability %d", soc_obj->fw_tdls_6g_capability);
432 
433 	return soc_obj->fw_tdls_6g_capability;
434 }
435 #endif
436 
ucfg_tdls_update_config(struct wlan_objmgr_psoc * psoc,struct tdls_start_params * req)437 QDF_STATUS ucfg_tdls_update_config(struct wlan_objmgr_psoc *psoc,
438 				   struct tdls_start_params *req)
439 {
440 	struct tdls_soc_priv_obj *soc_obj;
441 	uint32_t tdls_feature_flags;
442 	struct policy_mgr_tdls_cbacks tdls_pm_call_backs;
443 	uint8_t sta_idx;
444 
445 	tdls_debug("tdls update config ");
446 	if (!psoc || !req) {
447 		tdls_err("psoc: 0x%pK, req: 0x%pK", psoc, req);
448 		return QDF_STATUS_E_FAILURE;
449 	}
450 
451 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
452 							WLAN_UMAC_COMP_TDLS);
453 	if (!soc_obj) {
454 		tdls_err("Failed to get tdls psoc component");
455 		return QDF_STATUS_E_FAILURE;
456 	}
457 
458 	soc_obj->tdls_rx_cb = req->tdls_rx_cb;
459 	soc_obj->tdls_rx_cb_data = req->tdls_rx_cb_data;
460 
461 	soc_obj->tdls_wmm_cb = req->tdls_wmm_cb;
462 	soc_obj->tdls_wmm_cb_data = req->tdls_wmm_cb_data;
463 
464 	soc_obj->tdls_event_cb = req->tdls_event_cb;
465 	soc_obj->tdls_evt_cb_data = req->tdls_evt_cb_data;
466 
467 	/* Save callbacks to register/deregister TDLS sta with datapath */
468 	soc_obj->tdls_reg_peer = req->tdls_reg_peer;
469 	soc_obj->tdls_peer_context = req->tdls_peer_context;
470 
471 	/* Save legacy PE/WMA commands in TDLS soc object */
472 	soc_obj->tdls_send_mgmt_req = req->tdls_send_mgmt_req;
473 	soc_obj->tdls_add_sta_req = req->tdls_add_sta_req;
474 	soc_obj->tdls_del_sta_req = req->tdls_del_sta_req;
475 	soc_obj->tdls_update_peer_state = req->tdls_update_peer_state;
476 	soc_obj->tdls_del_all_peers = req->tdls_del_all_peers;
477 	soc_obj->tdls_update_dp_vdev_flags = req->tdls_update_dp_vdev_flags;
478 	soc_obj->tdls_dp_vdev_update = req->tdls_dp_vdev_update;
479 	soc_obj->tdls_osif_init_cb = req->tdls_osif_init_cb;
480 	soc_obj->tdls_osif_deinit_cb = req->tdls_osif_deinit_cb;
481 	soc_obj->tdls_osif_update_cb.tdls_osif_conn_update =
482 	       req->tdls_osif_update_cb.tdls_osif_conn_update;
483 	soc_obj->tdls_osif_update_cb.tdls_osif_disconn_update =
484 	       req->tdls_osif_update_cb.tdls_osif_disconn_update;
485 	tdls_pm_call_backs.tdls_notify_increment_session =
486 			tdls_notify_increment_session;
487 
488 	tdls_pm_call_backs.tdls_notify_decrement_session =
489 			tdls_notify_decrement_session;
490 	if (QDF_STATUS_SUCCESS != policy_mgr_register_tdls_cb(
491 		psoc, &tdls_pm_call_backs)) {
492 		tdls_err("policy manager callback registration failed ");
493 		return QDF_STATUS_E_FAILURE;
494 	}
495 
496 	tdls_update_feature_flag(soc_obj);
497 	tdls_feature_flags = soc_obj->tdls_configs.tdls_feature_flags;
498 
499 	if (!TDLS_IS_IMPLICIT_TRIG_ENABLED(tdls_feature_flags))
500 		soc_obj->tdls_current_mode = TDLS_SUPPORT_EXP_TRIG_ONLY;
501 	else if (TDLS_IS_EXTERNAL_CONTROL_ENABLED(tdls_feature_flags))
502 		soc_obj->tdls_current_mode = TDLS_SUPPORT_EXT_CONTROL;
503 	else
504 		soc_obj->tdls_current_mode = TDLS_SUPPORT_IMP_MODE;
505 
506 	soc_obj->tdls_last_mode = soc_obj->tdls_current_mode;
507 	if (TDLS_IS_BUFFER_STA_ENABLED(tdls_feature_flags) ||
508 	    TDLS_IS_SLEEP_STA_ENABLED(tdls_feature_flags))
509 		soc_obj->max_num_tdls_sta =
510 			WLAN_TDLS_STA_P_UAPSD_OFFCHAN_MAX_NUM;
511 
512 	for (sta_idx = 0; sta_idx < soc_obj->max_num_tdls_sta; sta_idx++) {
513 		soc_obj->tdls_conn_info[sta_idx].valid_entry = false;
514 		soc_obj->tdls_conn_info[sta_idx].index =
515 						INVALID_TDLS_PEER_INDEX;
516 		soc_obj->tdls_conn_info[sta_idx].session_id = 255;
517 		qdf_mem_zero(&soc_obj->tdls_conn_info[sta_idx].peer_mac,
518 			     QDF_MAC_ADDR_SIZE);
519 	}
520 	return QDF_STATUS_SUCCESS;
521 }
522 
ucfg_tdls_link_vdev_is_matching(struct wlan_objmgr_vdev * vdev)523 bool ucfg_tdls_link_vdev_is_matching(struct wlan_objmgr_vdev *vdev)
524 {
525 	struct wlan_objmgr_vdev *tdls_link_vdev;
526 
527 	tdls_link_vdev = tdls_mlo_get_tdls_link_vdev(vdev);
528 	if (!tdls_link_vdev) {
529 		wlan_vdev_mlme_feat_ext2_cap_set(vdev,
530 						 WLAN_VDEV_FEXT2_MLO_STA_TDLS);
531 		tdls_set_remain_links_unforce(vdev);
532 		return true;
533 	}
534 
535 	if (tdls_link_vdev && tdls_link_vdev != vdev) {
536 		tdls_debug("tdls vdev has been created on vdev %d",
537 			   wlan_vdev_get_id(tdls_link_vdev));
538 		return false;
539 	}
540 
541 	return true;
542 }
543 
544 struct wlan_objmgr_vdev *
ucfg_tdls_get_tdls_link_vdev(struct wlan_objmgr_vdev * vdev,wlan_objmgr_ref_dbgid dbg_id)545 ucfg_tdls_get_tdls_link_vdev(struct wlan_objmgr_vdev *vdev,
546 			     wlan_objmgr_ref_dbgid dbg_id)
547 {
548 	struct wlan_objmgr_vdev *link_vdev;
549 
550 	link_vdev = tdls_mlo_get_tdls_link_vdev(vdev);
551 	if (!link_vdev)
552 		return NULL;
553 
554 	if (wlan_objmgr_vdev_try_get_ref(link_vdev, dbg_id) !=
555 	    QDF_STATUS_SUCCESS)
556 		return NULL;
557 
558 	return link_vdev;
559 }
560 
ucfg_tdls_put_tdls_link_vdev(struct wlan_objmgr_vdev * vdev,wlan_objmgr_ref_dbgid dbg_id)561 void ucfg_tdls_put_tdls_link_vdev(struct wlan_objmgr_vdev *vdev,
562 				  wlan_objmgr_ref_dbgid dbg_id)
563 {
564 	wlan_objmgr_vdev_release_ref(vdev, dbg_id);
565 }
566 
ucfg_tdls_psoc_enable(struct wlan_objmgr_psoc * psoc)567 QDF_STATUS ucfg_tdls_psoc_enable(struct wlan_objmgr_psoc *psoc)
568 {
569 	QDF_STATUS status;
570 
571 	tdls_debug("psoc tdls enable: 0x%pK", psoc);
572 	if (!psoc) {
573 		tdls_err("NULL psoc");
574 		return QDF_STATUS_E_FAILURE;
575 	}
576 
577 	status = tgt_tdls_register_ev_handler(psoc);
578 
579 	if (status != QDF_STATUS_SUCCESS)
580 		return status;
581 
582 	status = wlan_serialization_register_comp_info_cb(psoc,
583 					WLAN_UMAC_COMP_TDLS,
584 					WLAN_SER_CMD_SCAN,
585 					tdls_scan_serialization_comp_info_cb);
586 	if (QDF_STATUS_SUCCESS != status) {
587 		tdls_err("Serialize scan cmd register failed ");
588 		return status;
589 	}
590 
591 	/* register callbacks with tx/rx mgmt */
592 	status = tdls_mgmt_rx_ops(psoc, true);
593 	if (status != QDF_STATUS_SUCCESS)
594 		tdls_err("Failed to register mgmt rx callback, status:%d",
595 			status);
596 	return status;
597 }
598 
ucfg_tdls_psoc_disable(struct wlan_objmgr_psoc * psoc)599 QDF_STATUS ucfg_tdls_psoc_disable(struct wlan_objmgr_psoc *psoc)
600 {
601 	QDF_STATUS status;
602 	struct tdls_soc_priv_obj *soc_obj = NULL;
603 
604 	tdls_debug("psoc tdls disable: 0x%pK", psoc);
605 	if (!psoc) {
606 		tdls_err("NULL psoc");
607 		return QDF_STATUS_E_FAILURE;
608 	}
609 
610 	status = tgt_tdls_unregister_ev_handler(psoc);
611 	if (QDF_IS_STATUS_ERROR(status))
612 		tdls_err("Failed to unregister tdls event handler");
613 
614 	status = tdls_mgmt_rx_ops(psoc, false);
615 	if (QDF_IS_STATUS_ERROR(status))
616 		tdls_err("Failed to unregister mgmt rx callback");
617 
618 	soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
619 							WLAN_UMAC_COMP_TDLS);
620 	if (!soc_obj) {
621 		tdls_err("Failed to get tdls psoc component");
622 		return QDF_STATUS_E_FAILURE;
623 	}
624 
625 	soc_obj->tdls_event_cb = NULL;
626 	soc_obj->tdls_evt_cb_data = NULL;
627 
628 	return status;
629 }
630 
ucfg_tdls_psoc_close(struct wlan_objmgr_psoc * psoc)631 QDF_STATUS ucfg_tdls_psoc_close(struct wlan_objmgr_psoc *psoc)
632 {
633 	QDF_STATUS status = QDF_STATUS_SUCCESS;
634 	struct tdls_soc_priv_obj *tdls_soc;
635 
636 	tdls_debug("tdls psoc close");
637 	tdls_soc = wlan_objmgr_psoc_get_comp_private_obj(psoc,
638 							WLAN_UMAC_COMP_TDLS);
639 	if (!tdls_soc) {
640 		tdls_err("Failed to get tdls psoc component");
641 		return QDF_STATUS_E_FAILURE;
642 	}
643 
644 	status = tdls_global_deinit(tdls_soc);
645 
646 	return status;
647 }
648 
ucfg_tdls_post_msg_flush_cb(struct scheduler_msg * msg)649 static QDF_STATUS ucfg_tdls_post_msg_flush_cb(struct scheduler_msg *msg)
650 {
651 	void *ptr = msg->bodyptr;
652 	struct wlan_objmgr_vdev *vdev = NULL;
653 
654 	switch (msg->type) {
655 	case TDLS_NOTIFY_RESET_ADAPTERS:
656 		ptr = NULL;
657 		break;
658 	case TDLS_CMD_SET_TDLS_MODE:
659 		vdev = ((struct tdls_set_mode_params *)ptr)->vdev;
660 		break;
661 	case TDLS_CMD_TX_ACTION:
662 	case TDLS_CMD_SET_RESPONDER:
663 		break;
664 	case TDLS_CMD_ADD_STA:
665 		vdev = ((struct tdls_add_peer_request *)ptr)->vdev;
666 		break;
667 	case TDLS_CMD_CHANGE_STA:
668 		vdev = ((struct tdls_update_peer_request *)ptr)->vdev;
669 		break;
670 	case TDLS_CMD_ENABLE_LINK:
671 	case TDLS_CMD_DISABLE_LINK:
672 	case TDLS_CMD_REMOVE_FORCE_PEER:
673 	case TDLS_CMD_CONFIG_FORCE_PEER:
674 		vdev = ((struct tdls_oper_request *)ptr)->vdev;
675 		break;
676 	case TDLS_CMD_SET_OFFCHANNEL:
677 		vdev = ((struct tdls_set_offchannel *)ptr)->vdev;
678 		break;
679 	case TDLS_CMD_SET_OFFCHANMODE:
680 		vdev = ((struct tdls_set_offchanmode *)ptr)->vdev;
681 		break;
682 	case TDLS_CMD_SET_SECOFFCHANOFFSET:
683 		vdev = ((struct tdls_set_secoffchanneloffset *)ptr)->vdev;
684 		break;
685 	}
686 
687 	if (vdev)
688 		wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
689 
690 	if (ptr)
691 		qdf_mem_free(ptr);
692 
693 	msg->bodyptr = NULL;
694 
695 	return QDF_STATUS_SUCCESS;
696 }
697 
ucfg_tdls_add_peer(struct wlan_objmgr_vdev * vdev,struct tdls_add_peer_params * add_peer_req)698 QDF_STATUS ucfg_tdls_add_peer(struct wlan_objmgr_vdev *vdev,
699 			      struct tdls_add_peer_params *add_peer_req)
700 {
701 	struct scheduler_msg msg = {0, };
702 	struct tdls_add_peer_request *req;
703 	QDF_STATUS status;
704 
705 	if (!vdev || !add_peer_req) {
706 		tdls_err("vdev: %pK, req %pK", vdev, add_peer_req);
707 		return QDF_STATUS_E_NULL_VALUE;
708 	}
709 	tdls_debug("vdevid: %d, peertype: %d",
710 		   add_peer_req->vdev_id, add_peer_req->peer_type);
711 
712 	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_TDLS_NB_ID);
713 	if (QDF_IS_STATUS_ERROR(status)) {
714 		tdls_err("can't get vdev");
715 		return status;
716 	}
717 
718 	req = qdf_mem_malloc(sizeof(*req));
719 	if (!req) {
720 		status = QDF_STATUS_E_NOMEM;
721 		goto dec_ref;
722 	}
723 
724 	qdf_mem_copy(&req->add_peer_req, add_peer_req, sizeof(*add_peer_req));
725 	req->vdev = vdev;
726 
727 	msg.bodyptr = req;
728 	msg.callback = tdls_process_cmd;
729 	msg.type = TDLS_CMD_ADD_STA;
730 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
731 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
732 					QDF_MODULE_ID_TDLS,
733 					QDF_MODULE_ID_OS_IF, &msg);
734 	if (QDF_IS_STATUS_ERROR(status)) {
735 		tdls_err("post add peer msg fail");
736 		qdf_mem_free(req);
737 		goto dec_ref;
738 	}
739 
740 	return status;
741 dec_ref:
742 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
743 	return status;
744 }
745 
ucfg_tdls_update_peer(struct wlan_objmgr_vdev * vdev,struct tdls_update_peer_params * update_peer)746 QDF_STATUS ucfg_tdls_update_peer(struct wlan_objmgr_vdev *vdev,
747 				 struct tdls_update_peer_params *update_peer)
748 {
749 	struct scheduler_msg msg = {0,};
750 	struct tdls_update_peer_request *req;
751 	QDF_STATUS status;
752 
753 	if (!vdev || !update_peer) {
754 		tdls_err("vdev: %pK, update_peer: %pK", vdev, update_peer);
755 		return QDF_STATUS_E_NULL_VALUE;
756 	}
757 
758 	tdls_debug("vdev_id: %d, peertype: %d",
759 		   update_peer->vdev_id, update_peer->peer_type);
760 	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_TDLS_NB_ID);
761 	if (QDF_IS_STATUS_ERROR(status)) {
762 		tdls_err("can't get vdev");
763 		return status;
764 	}
765 	req = qdf_mem_malloc(sizeof(*req));
766 	if (!req) {
767 		status = QDF_STATUS_E_NOMEM;
768 		goto dec_ref;
769 	}
770 	qdf_mem_copy(&req->update_peer_req, update_peer, sizeof(*update_peer));
771 	req->vdev = vdev;
772 
773 	msg.bodyptr = req;
774 	msg.callback = tdls_process_cmd;
775 	msg.type = TDLS_CMD_CHANGE_STA;
776 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
777 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
778 					QDF_MODULE_ID_TDLS,
779 					QDF_MODULE_ID_OS_IF, &msg);
780 	if (QDF_IS_STATUS_ERROR(status)) {
781 		tdls_err("post update peer msg fail");
782 		qdf_mem_free(req);
783 		goto dec_ref;
784 	}
785 
786 	return status;
787 dec_ref:
788 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
789 	return status;
790 }
791 
tdls_get_oper_str(enum tdls_command_type cmd_type)792 static char *tdls_get_oper_str(enum tdls_command_type cmd_type)
793 {
794 	switch (cmd_type) {
795 	case TDLS_CMD_ENABLE_LINK:
796 		return "Enable_TDLS_LINK";
797 	case TDLS_CMD_DISABLE_LINK:
798 		return "DISABLE_TDLS_LINK";
799 	case TDLS_CMD_REMOVE_FORCE_PEER:
800 		return "REMOVE_FORCE_PEER";
801 	case TDLS_CMD_CONFIG_FORCE_PEER:
802 		return "CONFIG_FORCE_PEER";
803 	default:
804 		return "ERR:UNKNOWN OPER";
805 	}
806 }
807 
ucfg_tdls_oper(struct wlan_objmgr_vdev * vdev,const uint8_t * macaddr,enum tdls_command_type cmd)808 QDF_STATUS ucfg_tdls_oper(struct wlan_objmgr_vdev *vdev,
809 			  const uint8_t *macaddr, enum tdls_command_type cmd)
810 {
811 	struct scheduler_msg msg = {0,};
812 	struct tdls_oper_request *req;
813 	QDF_STATUS status;
814 
815 	if (!vdev || !macaddr) {
816 		tdls_err("vdev: %pK, mac %pK", vdev, macaddr);
817 		return QDF_STATUS_E_NULL_VALUE;
818 	}
819 
820 	tdls_debug("%s for peer " QDF_MAC_ADDR_FMT,
821 		   tdls_get_oper_str(cmd),
822 		   QDF_MAC_ADDR_REF(macaddr));
823 
824 	req = qdf_mem_malloc(sizeof(*req));
825 	if (!req)
826 		return QDF_STATUS_E_NOMEM;
827 
828 	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_TDLS_NB_ID);
829 	if (QDF_IS_STATUS_ERROR(status)) {
830 		tdls_err("can't get vdev");
831 		goto error;
832 	}
833 
834 	qdf_mem_copy(req->peer_addr, macaddr, QDF_MAC_ADDR_SIZE);
835 	req->vdev = vdev;
836 
837 	msg.bodyptr = req;
838 	msg.callback = tdls_process_cmd;
839 	msg.type = cmd;
840 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
841 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
842 					QDF_MODULE_ID_TDLS,
843 					QDF_MODULE_ID_OS_IF, &msg);
844 	if (QDF_IS_STATUS_ERROR(status)) {
845 		tdls_err("post msg for %s fail", tdls_get_oper_str(cmd));
846 		goto dec_ref;
847 	}
848 
849 	return status;
850 dec_ref:
851 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
852 error:
853 	qdf_mem_free(req);
854 	return status;
855 }
856 
ucfg_tdls_get_all_peers(struct wlan_objmgr_vdev * vdev,char * buf,int buflen)857 QDF_STATUS ucfg_tdls_get_all_peers(struct wlan_objmgr_vdev *vdev,
858 				   char *buf, int buflen)
859 {
860 	struct scheduler_msg msg = {0, };
861 	struct tdls_get_all_peers *tdls_peers;
862 	QDF_STATUS status;
863 
864 	tdls_peers = qdf_mem_malloc(sizeof(*tdls_peers));
865 	if (!tdls_peers)
866 		return QDF_STATUS_E_NOMEM;
867 
868 	tdls_peers->vdev = vdev;
869 	tdls_peers->buf_len = buflen;
870 	tdls_peers->buf = buf;
871 
872 	msg.bodyptr = tdls_peers;
873 	msg.callback = tdls_process_cmd;
874 	msg.type = TDLS_CMD_GET_ALL_PEERS;
875 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
876 					QDF_MODULE_ID_TDLS,
877 					QDF_MODULE_ID_OS_IF, &msg);
878 
879 	if (status != QDF_STATUS_SUCCESS)
880 		qdf_mem_free(tdls_peers);
881 
882 	return QDF_STATUS_SUCCESS;
883 }
884 
tdls_send_mgmt_frame_flush_callback(struct scheduler_msg * msg)885 static QDF_STATUS tdls_send_mgmt_frame_flush_callback(struct scheduler_msg *msg)
886 {
887 	struct tdls_action_frame_request *req;
888 
889 	if (!msg || !msg->bodyptr) {
890 		tdls_err("msg or msg->bodyptr is NULL");
891 		return QDF_STATUS_E_NULL_VALUE;
892 	}
893 	req = msg->bodyptr;
894 	if (req->vdev)
895 		wlan_objmgr_vdev_release_ref(req->vdev, WLAN_TDLS_NB_ID);
896 
897 	qdf_mem_free(req);
898 	return QDF_STATUS_SUCCESS;
899 }
900 
ucfg_tdls_send_mgmt_frame(struct tdls_action_frame_request * req)901 QDF_STATUS ucfg_tdls_send_mgmt_frame(
902 				struct tdls_action_frame_request *req)
903 {
904 	struct scheduler_msg msg = {0, };
905 	struct tdls_action_frame_request *mgmt_req;
906 	QDF_STATUS status;
907 
908 	if (!req || !req->vdev) {
909 		tdls_err("Invalid mgmt req params %pK", req);
910 		return QDF_STATUS_E_NULL_VALUE;
911 	}
912 
913 	mgmt_req = qdf_mem_malloc(sizeof(*mgmt_req) +
914 					req->len);
915 	if (!mgmt_req)
916 		return QDF_STATUS_E_NOMEM;
917 
918 	qdf_mem_copy(mgmt_req, req, sizeof(*req));
919 
920 	/*populate the additional IE's */
921 	if ((0 != req->len) && (req->cmd_buf)) {
922 		qdf_mem_copy(mgmt_req->tdls_mgmt.buf, req->cmd_buf,
923 				req->len);
924 		mgmt_req->tdls_mgmt.len = req->len;
925 	} else {
926 		mgmt_req->tdls_mgmt.len = 0;
927 	}
928 
929 	tdls_debug("vdev id: %d, session id : %d, action %d", mgmt_req->vdev_id,
930 		   mgmt_req->session_id, req->chk_frame.action_code);
931 	status = wlan_objmgr_vdev_try_get_ref(req->vdev, WLAN_TDLS_NB_ID);
932 
933 	if (QDF_IS_STATUS_ERROR(status)) {
934 		tdls_err("Unable to get vdev reference for tdls module");
935 		goto mem_free;
936 	}
937 
938 	msg.bodyptr = mgmt_req;
939 	msg.callback = tdls_process_cmd;
940 	msg.flush_callback = tdls_send_mgmt_frame_flush_callback;
941 	msg.type = TDLS_CMD_TX_ACTION;
942 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
943 					QDF_MODULE_ID_TDLS,
944 					QDF_MODULE_ID_OS_IF, &msg);
945 	if (QDF_IS_STATUS_ERROR(status))
946 		goto release_ref;
947 
948 	return status;
949 
950 release_ref:
951 	wlan_objmgr_vdev_release_ref(req->vdev, WLAN_TDLS_NB_ID);
952 mem_free:
953 	qdf_mem_free(mgmt_req);
954 	return status;
955 }
956 
ucfg_tdls_responder(struct tdls_set_responder_req * req)957 QDF_STATUS ucfg_tdls_responder(struct tdls_set_responder_req *req)
958 {
959 	struct scheduler_msg msg = {0, };
960 	struct tdls_set_responder_req *msg_req;
961 	QDF_STATUS status;
962 
963 	if (!req || !req->vdev) {
964 		tdls_err("invalid input %pK", req);
965 		return QDF_STATUS_E_NULL_VALUE;
966 	}
967 
968 	msg_req = qdf_mem_malloc(sizeof(*msg_req));
969 	if (!msg_req)
970 		return QDF_STATUS_E_NULL_VALUE;
971 
972 	msg_req->responder = req->responder;
973 	msg_req->vdev = req->vdev;
974 	qdf_mem_copy(msg_req->peer_mac, req->peer_mac, QDF_MAC_ADDR_SIZE);
975 
976 	msg.bodyptr = msg_req;
977 	msg.callback = tdls_process_cmd;
978 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
979 	msg.type = TDLS_CMD_SET_RESPONDER;
980 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
981 					QDF_MODULE_ID_TDLS,
982 					QDF_MODULE_ID_OS_IF, &msg);
983 	if (QDF_IS_STATUS_ERROR(status))
984 		qdf_mem_free(msg_req);
985 
986 	return status;
987 }
988 
ucfg_tdls_teardown_links_sync(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev)989 void ucfg_tdls_teardown_links_sync(struct wlan_objmgr_psoc *psoc,
990 				   struct wlan_objmgr_vdev *vdev)
991 {
992 	return wlan_tdls_check_and_teardown_links_sync(psoc, vdev);
993 }
994 
ucfg_tdls_teardown_links(struct wlan_objmgr_psoc * psoc)995 QDF_STATUS ucfg_tdls_teardown_links(struct wlan_objmgr_psoc *psoc)
996 {
997 	return wlan_tdls_teardown_links(psoc);
998 }
999 
ucfg_tdls_notify_reset_adapter(struct wlan_objmgr_vdev * vdev)1000 QDF_STATUS ucfg_tdls_notify_reset_adapter(struct wlan_objmgr_vdev *vdev)
1001 {
1002 	QDF_STATUS status;
1003 	struct scheduler_msg msg = {0, };
1004 
1005 	if (!vdev) {
1006 		tdls_err("vdev is NULL ");
1007 		return QDF_STATUS_E_NULL_VALUE;
1008 	}
1009 	tdls_debug("Enter ");
1010 	msg.bodyptr = vdev;
1011 	msg.callback = tdls_process_cmd;
1012 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
1013 	msg.type = TDLS_NOTIFY_RESET_ADAPTERS;
1014 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
1015 					QDF_MODULE_ID_TDLS,
1016 					QDF_MODULE_ID_OS_IF, &msg);
1017 	return status;
1018 }
1019 
ucfg_tdls_set_operating_mode(struct tdls_set_mode_params * set_mode_params)1020 QDF_STATUS ucfg_tdls_set_operating_mode(
1021 			struct tdls_set_mode_params *set_mode_params)
1022 {
1023 	struct scheduler_msg msg = {0, };
1024 	struct tdls_set_mode_params *set_mode;
1025 	QDF_STATUS status;
1026 
1027 	if (!set_mode_params || !set_mode_params->vdev) {
1028 		tdls_err("set_mode_params %pK", set_mode_params);
1029 		return QDF_STATUS_E_NULL_VALUE;
1030 	}
1031 
1032 	tdls_debug("Enter ");
1033 
1034 	set_mode = qdf_mem_malloc(sizeof(*set_mode));
1035 	if (!set_mode)
1036 		return QDF_STATUS_E_NULL_VALUE;
1037 
1038 	status = wlan_objmgr_vdev_try_get_ref(set_mode->vdev, WLAN_TDLS_NB_ID);
1039 	if (QDF_IS_STATUS_ERROR(status)) {
1040 		tdls_err("failed to get vdev ref");
1041 		qdf_mem_free(set_mode);
1042 		return status;
1043 	}
1044 
1045 	set_mode->source = set_mode_params->source;
1046 	set_mode->tdls_mode = set_mode_params->tdls_mode;
1047 	set_mode->update_last = set_mode_params->update_last;
1048 	set_mode->vdev = set_mode_params->vdev;
1049 
1050 	msg.bodyptr = set_mode;
1051 	msg.callback = tdls_process_cmd;
1052 	msg.type = TDLS_CMD_SET_TDLS_MODE;
1053 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
1054 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
1055 					QDF_MODULE_ID_TDLS,
1056 					QDF_MODULE_ID_OS_IF, &msg);
1057 	if (QDF_IS_STATUS_ERROR(status)) {
1058 		wlan_objmgr_vdev_release_ref(set_mode->vdev, WLAN_TDLS_NB_ID);
1059 		qdf_mem_free(set_mode);
1060 	}
1061 
1062 	tdls_debug("Exit ");
1063 
1064 	return QDF_STATUS_SUCCESS;
1065 }
1066 
ucfg_tdls_update_rx_pkt_cnt(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * mac_addr,struct qdf_mac_addr * dest_mac_addr)1067 void ucfg_tdls_update_rx_pkt_cnt(struct wlan_objmgr_vdev *vdev,
1068 				 struct qdf_mac_addr *mac_addr,
1069 				 struct qdf_mac_addr *dest_mac_addr)
1070 {
1071 	tdls_update_rx_pkt_cnt(vdev, mac_addr, dest_mac_addr);
1072 
1073 }
1074 
ucfg_tdls_update_tx_pkt_cnt(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * mac_addr)1075 void ucfg_tdls_update_tx_pkt_cnt(struct wlan_objmgr_vdev *vdev,
1076 				 struct qdf_mac_addr *mac_addr)
1077 {
1078 	tdls_update_tx_pkt_cnt(vdev, mac_addr);
1079 }
1080 
ucfg_tdls_antenna_switch(struct wlan_objmgr_vdev * vdev,uint32_t mode)1081 QDF_STATUS ucfg_tdls_antenna_switch(struct wlan_objmgr_vdev *vdev,
1082 				    uint32_t mode)
1083 {
1084 	QDF_STATUS status;
1085 	struct tdls_antenna_switch_request *req;
1086 	struct scheduler_msg msg = {0, };
1087 
1088 	req = qdf_mem_malloc(sizeof(*req));
1089 	if (!req)
1090 		return QDF_STATUS_E_NOMEM;
1091 
1092 	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_TDLS_NB_ID);
1093 	if (QDF_IS_STATUS_ERROR(status)) {
1094 		tdls_err("can't get vdev");
1095 		goto error;
1096 	}
1097 
1098 	req->vdev = vdev;
1099 	req->mode = mode;
1100 
1101 	msg.bodyptr = req;
1102 	msg.callback = tdls_process_cmd;
1103 	msg.flush_callback = tdls_antenna_switch_flush_callback;
1104 	msg.type = TDLS_CMD_ANTENNA_SWITCH;
1105 	status = scheduler_post_message(QDF_MODULE_ID_HDD,
1106 					QDF_MODULE_ID_TDLS,
1107 					QDF_MODULE_ID_OS_IF, &msg);
1108 	if (QDF_IS_STATUS_ERROR(status)) {
1109 		tdls_err("post antenna switch msg fail");
1110 		goto dec_ref;
1111 	}
1112 
1113 	return status;
1114 
1115 dec_ref:
1116 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
1117 error:
1118 	qdf_mem_free(req);
1119 	return status;
1120 }
1121 
ucfg_set_tdls_offchannel(struct wlan_objmgr_vdev * vdev,int offchannel)1122 QDF_STATUS ucfg_set_tdls_offchannel(struct wlan_objmgr_vdev *vdev,
1123 				    int offchannel)
1124 {
1125 	QDF_STATUS status = QDF_STATUS_SUCCESS;
1126 	struct scheduler_msg msg = {0, };
1127 	struct tdls_set_offchannel *req;
1128 
1129 	req = qdf_mem_malloc(sizeof(*req));
1130 	if (!req)
1131 		return QDF_STATUS_E_NOMEM;
1132 
1133 	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_TDLS_NB_ID);
1134 	if (QDF_IS_STATUS_ERROR(status)) {
1135 		tdls_err("can't get vdev");
1136 		goto free;
1137 	}
1138 
1139 	req->offchannel = offchannel;
1140 	req->vdev = vdev;
1141 	req->callback = wlan_tdls_offchan_parms_callback;
1142 	msg.bodyptr = req;
1143 	msg.callback = tdls_process_cmd;
1144 	msg.type = TDLS_CMD_SET_OFFCHANNEL;
1145 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
1146 	status = scheduler_post_message(QDF_MODULE_ID_HDD, QDF_MODULE_ID_TDLS,
1147 					QDF_MODULE_ID_OS_IF, &msg);
1148 	if (QDF_IS_STATUS_ERROR(status)) {
1149 		tdls_err("post set tdls offchannel msg fail");
1150 		goto dec_ref;
1151 	}
1152 
1153 	return status;
1154 
1155 dec_ref:
1156 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
1157 
1158 free:
1159 	qdf_mem_free(req);
1160 	return status;
1161 }
1162 
ucfg_set_tdls_offchan_mode(struct wlan_objmgr_vdev * vdev,int offchanmode)1163 QDF_STATUS ucfg_set_tdls_offchan_mode(struct wlan_objmgr_vdev *vdev,
1164 				      int offchanmode)
1165 {
1166 	QDF_STATUS status = QDF_STATUS_SUCCESS;
1167 	struct scheduler_msg msg = {0, };
1168 	struct tdls_set_offchanmode *req;
1169 
1170 	req = qdf_mem_malloc(sizeof(*req));
1171 	if (!req)
1172 		return QDF_STATUS_E_NOMEM;
1173 
1174 	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_TDLS_NB_ID);
1175 	if (QDF_IS_STATUS_ERROR(status)) {
1176 		tdls_err("can't get vdev");
1177 		goto free;
1178 	}
1179 
1180 	req->offchan_mode = offchanmode;
1181 	req->vdev = vdev;
1182 	req->callback = wlan_tdls_offchan_parms_callback;
1183 	msg.bodyptr = req;
1184 	msg.callback = tdls_process_cmd;
1185 	msg.type = TDLS_CMD_SET_OFFCHANMODE;
1186 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
1187 	status = scheduler_post_message(QDF_MODULE_ID_HDD, QDF_MODULE_ID_TDLS,
1188 					QDF_MODULE_ID_OS_IF, &msg);
1189 	if (QDF_IS_STATUS_ERROR(status)) {
1190 		tdls_err("post set offchanmode msg fail");
1191 		goto dec_ref;
1192 	}
1193 
1194 	return status;
1195 
1196 dec_ref:
1197 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
1198 
1199 free:
1200 	qdf_mem_free(req);
1201 	return status;
1202 }
1203 
ucfg_set_tdls_secoffchanneloffset(struct wlan_objmgr_vdev * vdev,int offchanoffset)1204 QDF_STATUS ucfg_set_tdls_secoffchanneloffset(struct wlan_objmgr_vdev *vdev,
1205 					     int offchanoffset)
1206 {
1207 	int status = QDF_STATUS_SUCCESS;
1208 	struct scheduler_msg msg = {0, };
1209 	struct tdls_set_secoffchanneloffset *req;
1210 
1211 	req = qdf_mem_malloc(sizeof(*req));
1212 	if (!req)
1213 		return QDF_STATUS_E_NOMEM;
1214 
1215 	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_TDLS_NB_ID);
1216 	if (QDF_IS_STATUS_ERROR(status)) {
1217 		tdls_err("can't get vdev");
1218 		goto free;
1219 	}
1220 
1221 	req->offchan_offset = offchanoffset;
1222 	req->vdev = vdev;
1223 	req->callback = wlan_tdls_offchan_parms_callback;
1224 	msg.bodyptr = req;
1225 	msg.callback = tdls_process_cmd;
1226 	msg.type = TDLS_CMD_SET_SECOFFCHANOFFSET;
1227 	msg.flush_callback = ucfg_tdls_post_msg_flush_cb;
1228 	status = scheduler_post_message(QDF_MODULE_ID_HDD, QDF_MODULE_ID_TDLS,
1229 					QDF_MODULE_ID_OS_IF, &msg);
1230 	if (QDF_IS_STATUS_ERROR(status)) {
1231 		tdls_err("post set secoffchan offset msg fail");
1232 		goto dec_ref;
1233 	}
1234 	return status;
1235 
1236 dec_ref:
1237 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
1238 
1239 free:
1240 	qdf_mem_free(req);
1241 	return status;
1242 }
1243 
ucfg_tdls_get_mlo_vdev(struct wlan_objmgr_vdev * vdev,uint8_t index,wlan_objmgr_ref_dbgid dbg_id)1244 struct wlan_objmgr_vdev *ucfg_tdls_get_mlo_vdev(struct wlan_objmgr_vdev *vdev,
1245 						uint8_t index,
1246 						wlan_objmgr_ref_dbgid dbg_id)
1247 {
1248 	return wlan_tdls_get_mlo_vdev(vdev, index, dbg_id);
1249 }
1250 
ucfg_tdls_release_mlo_vdev(struct wlan_objmgr_vdev * vdev,wlan_objmgr_ref_dbgid dbg_id)1251 void ucfg_tdls_release_mlo_vdev(struct wlan_objmgr_vdev *vdev,
1252 				wlan_objmgr_ref_dbgid dbg_id)
1253 {
1254 	return wlan_tdls_release_mlo_vdev(vdev, dbg_id);
1255 }
1256 
ucfg_tdls_discovery_on_going(struct wlan_objmgr_vdev * vdev)1257 bool ucfg_tdls_discovery_on_going(struct wlan_objmgr_vdev *vdev)
1258 {
1259 	struct tdls_soc_priv_obj *tdls_soc;
1260 	uint8_t count;
1261 
1262 	tdls_soc = wlan_vdev_get_tdls_soc_obj(vdev);
1263 	if (!tdls_soc)
1264 		return false;
1265 	count = qdf_atomic_read(&tdls_soc->timer_cnt);
1266 	tdls_debug("discovery req timer count %d", count);
1267 
1268 	return count ? true : false;
1269 }
1270 
ucfg_tdls_set_rssi(struct wlan_objmgr_vdev * vdev,uint8_t * mac,int8_t rssi)1271 QDF_STATUS ucfg_tdls_set_rssi(struct wlan_objmgr_vdev *vdev,
1272 			      uint8_t *mac, int8_t rssi)
1273 {
1274 	return tdls_set_rssi(vdev, mac, rssi);
1275 }
1276 
ucfg_tdls_notify_connect_failure(struct wlan_objmgr_psoc * psoc)1277 void ucfg_tdls_notify_connect_failure(struct wlan_objmgr_psoc *psoc)
1278 {
1279 	return tdls_notify_decrement_session(psoc);
1280 }
1281 
ucfg_get_tdls_conn_peer_count(struct wlan_objmgr_vdev * vdev)1282 uint16_t ucfg_get_tdls_conn_peer_count(struct wlan_objmgr_vdev *vdev)
1283 {
1284 	return tdls_get_connected_peer_count_from_vdev(vdev);
1285 }
1286 
ucfg_get_tdls_vdev(struct wlan_objmgr_psoc * psoc,wlan_objmgr_ref_dbgid dbg_id)1287 struct wlan_objmgr_vdev *ucfg_get_tdls_vdev(struct wlan_objmgr_psoc *psoc,
1288 					    wlan_objmgr_ref_dbgid dbg_id)
1289 {
1290 	return tdls_get_vdev(psoc, dbg_id);
1291 }
1292 
ucfg_tdls_check_is_tdls_allowed(struct wlan_objmgr_vdev * vdev)1293 bool ucfg_tdls_check_is_tdls_allowed(struct wlan_objmgr_vdev *vdev)
1294 {
1295 	return tdls_check_is_tdls_allowed(vdev);
1296 }
1297 
ucfg_tdls_set_user_tdls_enable(struct wlan_objmgr_vdev * vdev,bool is_user_tdls_enable)1298 void ucfg_tdls_set_user_tdls_enable(struct wlan_objmgr_vdev *vdev,
1299 				    bool is_user_tdls_enable)
1300 {
1301 	return tdls_set_user_tdls_enable(vdev, is_user_tdls_enable);
1302 }
1303