1 /*
2 * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
3 * Copyright (c) 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: This file contains TDLS configures interface definitions
22 */
23
24 #include <wlan_objmgr_psoc_obj.h>
25 #include "wlan_tdls_cfg_api.h"
26 #include "../../core/src/wlan_tdls_main.h"
27
28 QDF_STATUS
cfg_tdls_get_support_enable(struct wlan_objmgr_psoc * psoc,bool * val)29 cfg_tdls_get_support_enable(struct wlan_objmgr_psoc *psoc,
30 bool *val)
31 {
32 struct tdls_soc_priv_obj *soc_obj;
33
34 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
35 if (!soc_obj) {
36 *val = false;
37 tdls_err("tdls soc null");
38 return QDF_STATUS_E_INVAL;
39 }
40
41 *val = soc_obj->tdls_configs.tdls_support_enable;
42
43 return QDF_STATUS_SUCCESS;
44 }
45
46 QDF_STATUS
cfg_tdls_set_support_enable(struct wlan_objmgr_psoc * psoc,bool val)47 cfg_tdls_set_support_enable(struct wlan_objmgr_psoc *psoc,
48 bool val)
49 {
50 struct tdls_soc_priv_obj *soc_obj;
51
52 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
53 if (!soc_obj) {
54 tdls_err("tdls soc null");
55 return QDF_STATUS_E_INVAL;
56 }
57
58 soc_obj->tdls_configs.tdls_support_enable = val;
59
60 return QDF_STATUS_SUCCESS;
61 }
62
63 QDF_STATUS
cfg_tdls_get_external_control(struct wlan_objmgr_psoc * psoc,bool * val)64 cfg_tdls_get_external_control(struct wlan_objmgr_psoc *psoc,
65 bool *val)
66 {
67 struct tdls_soc_priv_obj *soc_obj;
68
69 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
70 if (!soc_obj) {
71 *val = false;
72 tdls_err("tdls soc null");
73 return QDF_STATUS_E_INVAL;
74 }
75
76 *val = soc_obj->tdls_configs.tdls_external_control;
77
78 return QDF_STATUS_SUCCESS;
79 }
80
81 QDF_STATUS
cfg_tdls_get_uapsd_mask(struct wlan_objmgr_psoc * psoc,uint32_t * val)82 cfg_tdls_get_uapsd_mask(struct wlan_objmgr_psoc *psoc,
83 uint32_t *val)
84 {
85 struct tdls_soc_priv_obj *soc_obj;
86
87 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
88 if (!soc_obj) {
89 *val = 0;
90 tdls_err("tdls soc null");
91 return QDF_STATUS_E_INVAL;
92 }
93
94 *val = soc_obj->tdls_configs.tdls_uapsd_mask;
95
96 return QDF_STATUS_SUCCESS;
97 }
98
99 QDF_STATUS
cfg_tdls_get_buffer_sta_enable(struct wlan_objmgr_psoc * psoc,bool * val)100 cfg_tdls_get_buffer_sta_enable(struct wlan_objmgr_psoc *psoc,
101 bool *val)
102 {
103 struct tdls_soc_priv_obj *soc_obj;
104
105 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
106 if (!soc_obj) {
107 *val = false;
108 tdls_err("tdls soc null");
109 return QDF_STATUS_E_INVAL;
110 }
111
112 *val = soc_obj->tdls_configs.tdls_buffer_sta_enable;
113
114 return QDF_STATUS_SUCCESS;
115 }
116
117 QDF_STATUS
cfg_tdls_set_buffer_sta_enable(struct wlan_objmgr_psoc * psoc,bool val)118 cfg_tdls_set_buffer_sta_enable(struct wlan_objmgr_psoc *psoc,
119 bool val)
120 {
121 struct tdls_soc_priv_obj *soc_obj;
122
123 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
124 if (!soc_obj) {
125 tdls_err("tdls soc null");
126 return QDF_STATUS_E_INVAL;
127 }
128
129 soc_obj->tdls_configs.tdls_buffer_sta_enable = val;
130
131 return QDF_STATUS_SUCCESS;
132 }
133
134 QDF_STATUS
cfg_tdls_get_uapsd_inactivity_time(struct wlan_objmgr_psoc * psoc,uint32_t * val)135 cfg_tdls_get_uapsd_inactivity_time(struct wlan_objmgr_psoc *psoc,
136 uint32_t *val)
137 {
138 struct tdls_soc_priv_obj *soc_obj;
139
140 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
141 if (!soc_obj) {
142 *val = 0;
143 tdls_err("tdls soc null");
144 return QDF_STATUS_E_INVAL;
145 }
146
147 *val = soc_obj->tdls_configs.tdls_uapsd_inactivity_time;
148
149 return QDF_STATUS_SUCCESS;
150 }
151
152 QDF_STATUS
cfg_tdls_get_rx_pkt_threshold(struct wlan_objmgr_psoc * psoc,uint32_t * val)153 cfg_tdls_get_rx_pkt_threshold(struct wlan_objmgr_psoc *psoc,
154 uint32_t *val)
155 {
156 struct tdls_soc_priv_obj *soc_obj;
157
158 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
159 if (!soc_obj) {
160 *val = 0;
161 tdls_err("tdls soc null");
162 return QDF_STATUS_E_INVAL;
163 }
164
165 *val = soc_obj->tdls_configs.tdls_rx_pkt_threshold;
166
167 return QDF_STATUS_SUCCESS;
168 }
169
170 QDF_STATUS
cfg_tdls_get_off_channel_enable(struct wlan_objmgr_psoc * psoc,bool * val)171 cfg_tdls_get_off_channel_enable(struct wlan_objmgr_psoc *psoc,
172 bool *val)
173 {
174 struct tdls_soc_priv_obj *soc_obj;
175
176 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
177 if (!soc_obj) {
178 *val = false;
179 tdls_err("tdls soc null");
180 return QDF_STATUS_E_INVAL;
181 }
182
183 *val = soc_obj->tdls_configs.tdls_off_chan_enable;
184
185 return QDF_STATUS_SUCCESS;
186 }
187
188 QDF_STATUS
cfg_tdls_set_off_channel_enable(struct wlan_objmgr_psoc * psoc,bool val)189 cfg_tdls_set_off_channel_enable(struct wlan_objmgr_psoc *psoc,
190 bool val)
191 {
192 struct tdls_soc_priv_obj *soc_obj;
193
194 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
195 if (!soc_obj) {
196 tdls_err("tdls soc null");
197 return QDF_STATUS_E_INVAL;
198 }
199
200 soc_obj->tdls_configs.tdls_off_chan_enable = val;
201
202 return QDF_STATUS_SUCCESS;
203 }
204
205 QDF_STATUS
cfg_tdls_get_off_channel_enable_orig(struct wlan_objmgr_psoc * psoc,bool * val)206 cfg_tdls_get_off_channel_enable_orig(struct wlan_objmgr_psoc *psoc,
207 bool *val)
208 {
209 struct tdls_soc_priv_obj *soc_obj;
210
211 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
212 if (!soc_obj) {
213 *val = false;
214 tdls_err("tdls soc null");
215 return QDF_STATUS_E_INVAL;
216 }
217
218 *val = soc_obj->tdls_configs.tdls_off_chan_enable_orig;
219
220 return QDF_STATUS_SUCCESS;
221 }
222
cfg_tdls_store_off_channel_enable(struct wlan_objmgr_psoc * psoc)223 void cfg_tdls_store_off_channel_enable(struct wlan_objmgr_psoc *psoc)
224 {
225 struct tdls_soc_priv_obj *soc_obj;
226
227 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
228 if (!soc_obj) {
229 tdls_err("tdls soc null");
230 return;
231 }
232
233 soc_obj->tdls_configs.tdls_off_chan_enable_orig =
234 soc_obj->tdls_configs.tdls_off_chan_enable;
235 }
236
cfg_tdls_restore_off_channel_enable(struct wlan_objmgr_psoc * psoc)237 void cfg_tdls_restore_off_channel_enable(struct wlan_objmgr_psoc *psoc)
238 {
239 struct tdls_soc_priv_obj *soc_obj;
240
241 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
242 if (!soc_obj) {
243 tdls_err("tdls soc null");
244 return;
245 }
246
247 soc_obj->tdls_configs.tdls_off_chan_enable =
248 soc_obj->tdls_configs.tdls_off_chan_enable_orig;
249 soc_obj->tdls_configs.tdls_off_chan_enable_orig = false;
250 }
251
252 QDF_STATUS
cfg_tdls_get_wmm_mode_enable(struct wlan_objmgr_psoc * psoc,bool * val)253 cfg_tdls_get_wmm_mode_enable(struct wlan_objmgr_psoc *psoc,
254 bool *val)
255 {
256 struct tdls_soc_priv_obj *soc_obj;
257
258 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
259 if (!soc_obj) {
260 *val = false;
261 tdls_err("tdls soc null");
262 return QDF_STATUS_E_INVAL;
263 }
264
265 *val = soc_obj->tdls_configs.tdls_wmm_mode_enable;
266
267 return QDF_STATUS_SUCCESS;
268 }
269
270 QDF_STATUS
cfg_tdls_set_vdev_nss_2g(struct wlan_objmgr_psoc * psoc,uint8_t val)271 cfg_tdls_set_vdev_nss_2g(struct wlan_objmgr_psoc *psoc,
272 uint8_t val)
273 {
274 struct tdls_soc_priv_obj *soc_obj;
275
276 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
277 if (!soc_obj) {
278 tdls_err("tdls soc null");
279 return QDF_STATUS_E_INVAL;
280 }
281
282 soc_obj->tdls_configs.tdls_vdev_nss_2g = val;
283
284 return QDF_STATUS_SUCCESS;
285 }
286
287 QDF_STATUS
cfg_tdls_set_vdev_nss_5g(struct wlan_objmgr_psoc * psoc,uint8_t val)288 cfg_tdls_set_vdev_nss_5g(struct wlan_objmgr_psoc *psoc,
289 uint8_t val)
290 {
291 struct tdls_soc_priv_obj *soc_obj;
292
293 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
294 if (!soc_obj) {
295 tdls_err("tdls soc null");
296 return QDF_STATUS_E_INVAL;
297 }
298
299 soc_obj->tdls_configs.tdls_vdev_nss_5g = val;
300
301 return QDF_STATUS_SUCCESS;
302 }
303
304 QDF_STATUS
cfg_tdls_get_sleep_sta_enable(struct wlan_objmgr_psoc * psoc,bool * val)305 cfg_tdls_get_sleep_sta_enable(struct wlan_objmgr_psoc *psoc,
306 bool *val)
307 {
308 struct tdls_soc_priv_obj *soc_obj;
309
310 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
311 if (!soc_obj) {
312 *val = false;
313 tdls_err("tdls soc null");
314 return QDF_STATUS_E_INVAL;
315 }
316
317 *val = soc_obj->tdls_configs.tdls_sleep_sta_enable;
318
319 return QDF_STATUS_SUCCESS;
320 }
321
322 QDF_STATUS
cfg_tdls_set_sleep_sta_enable(struct wlan_objmgr_psoc * psoc,bool val)323 cfg_tdls_set_sleep_sta_enable(struct wlan_objmgr_psoc *psoc,
324 bool val)
325 {
326 struct tdls_soc_priv_obj *soc_obj;
327
328 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
329 if (!soc_obj) {
330 tdls_err("tdls soc null");
331 return QDF_STATUS_E_INVAL;
332 }
333
334 soc_obj->tdls_configs.tdls_sleep_sta_enable = val;
335
336 return QDF_STATUS_SUCCESS;
337 }
338
339 QDF_STATUS
cfg_tdls_get_scan_enable(struct wlan_objmgr_psoc * psoc,bool * val)340 cfg_tdls_get_scan_enable(struct wlan_objmgr_psoc *psoc,
341 bool *val)
342 {
343 struct tdls_soc_priv_obj *soc_obj;
344
345 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
346 if (!soc_obj) {
347 *val = false;
348 tdls_err("tdls soc null");
349 return QDF_STATUS_E_INVAL;
350 }
351
352 *val = soc_obj->tdls_configs.tdls_scan_enable;
353
354 return QDF_STATUS_SUCCESS;
355 }
356
357 QDF_STATUS
cfg_tdls_set_scan_enable(struct wlan_objmgr_psoc * psoc,bool val)358 cfg_tdls_set_scan_enable(struct wlan_objmgr_psoc *psoc,
359 bool val)
360 {
361 struct tdls_soc_priv_obj *soc_obj;
362
363 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
364 if (!soc_obj) {
365 tdls_err("tdls soc null");
366 return QDF_STATUS_E_INVAL;
367 }
368
369 soc_obj->tdls_configs.tdls_scan_enable = val;
370
371 return QDF_STATUS_SUCCESS;
372 }
373
cfg_tdls_get_link_id(struct wlan_objmgr_psoc * psoc)374 int cfg_tdls_get_link_id(struct wlan_objmgr_psoc *psoc)
375 {
376 struct tdls_soc_priv_obj *soc_obj;
377
378 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
379 if (!soc_obj) {
380 tdls_err("tdls soc null");
381 return QDF_STATUS_E_INVAL;
382 }
383
384 return soc_obj->tdls_configs.tdls_link_id;
385 }
386
387 QDF_STATUS
cfg_tdls_set_link_id(struct wlan_objmgr_psoc * psoc,int val)388 cfg_tdls_set_link_id(struct wlan_objmgr_psoc *psoc, int val)
389 {
390 struct tdls_soc_priv_obj *soc_obj;
391
392 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
393 if (!soc_obj) {
394 tdls_err("tdls soc null");
395 return QDF_STATUS_E_INVAL;
396 }
397
398 soc_obj->tdls_configs.tdls_link_id = val;
399
400 return QDF_STATUS_SUCCESS;
401 }
402
403 uint16_t
cfg_tdls_get_max_peer_count(struct wlan_objmgr_psoc * psoc)404 cfg_tdls_get_max_peer_count(struct wlan_objmgr_psoc *psoc)
405 {
406 struct tdls_soc_priv_obj *soc_obj;
407
408 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
409 if (!soc_obj) {
410 tdls_err("tdls soc null");
411 return 1;
412 }
413
414 return soc_obj->max_num_tdls_sta;
415 }
416
417 uint16_t
cfg_tdls_get_connected_peer_count(struct wlan_objmgr_psoc * psoc)418 cfg_tdls_get_connected_peer_count(struct wlan_objmgr_psoc *psoc)
419 {
420 struct tdls_soc_priv_obj *soc_obj;
421
422 soc_obj = wlan_psoc_get_tdls_soc_obj(psoc);
423 if (!soc_obj) {
424 tdls_err("tdls soc null");
425 return 0;
426 }
427
428 return soc_obj->connected_peer_count;
429 }
430