1 /*
2 * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 /*
18 * DOC: contains ML STA link force active/inactive public API
19 */
20 #ifndef _WLAN_MLO_LINK_FORCE_H_
21 #define _WLAN_MLO_LINK_FORCE_H_
22
23 #include <wlan_mlo_mgr_cmn.h>
24 #include <wlan_mlo_mgr_public_structs.h>
25 #include <wlan_mlo_mgr_link_switch.h>
26
27 /**
28 * enum ml_nlink_change_event_type - Ml link state change trigger event
29 * @ml_nlink_link_switch_start_evt: link switch start
30 * @ml_nlink_link_switch_pre_completion_evt: link switch pre-completion
31 * @ml_nlink_roam_sync_start_evt: roam sync start
32 * @ml_nlink_roam_sync_completion_evt: roam sync completion
33 * @ml_nlink_connect_start_evt: STA/CLI connect start
34 * @ml_nlink_connect_completion_evt: STA/CLI connect completion
35 * @ml_nlink_disconnect_start_evt: STA/CLI disconnect start
36 * @ml_nlink_disconnect_completion_evt: STA/CLI disconnect completion
37 * @ml_nlink_ap_started_evt: SAP/GO bss started
38 * @ml_nlink_ap_stopped_evt: SAP/GO bss stopped
39 * @ml_nlink_connection_updated_evt: connection home channel changed
40 * @ml_nlink_tdls_request_evt: tdls request link enable/disable
41 * @ml_nlink_vendor_cmd_request_evt: vendor command request
42 */
43 enum ml_nlink_change_event_type {
44 ml_nlink_link_switch_start_evt,
45 ml_nlink_link_switch_pre_completion_evt,
46 ml_nlink_roam_sync_start_evt,
47 ml_nlink_roam_sync_completion_evt,
48 ml_nlink_connect_start_evt,
49 ml_nlink_connect_completion_evt,
50 ml_nlink_disconnect_start_evt,
51 ml_nlink_disconnect_completion_evt,
52 ml_nlink_ap_started_evt,
53 ml_nlink_ap_stopped_evt,
54 ml_nlink_connection_updated_evt,
55 ml_nlink_tdls_request_evt,
56 ml_nlink_vendor_cmd_request_evt,
57 };
58
59 /**
60 * enum link_control_modes - the types of MLO links state
61 * control modes. This enum is internal mapping of
62 * qca_wlan_vendor_link_state_control_modes.
63 * @LINK_CONTROL_MODE_DEFAULT: MLO links state controlled
64 * by the driver.
65 * @LINK_CONTROL_MODE_USER: MLO links state controlled by
66 * user space.
67 * @LINK_CONTROL_MODE_MIXED: User space provides the
68 * desired number of MLO links to operate in active state at any given time.
69 * The driver will choose which MLO links should operate in the active state.
70 * See enum qca_wlan_vendor_link_state for active state definition.
71 */
72 enum link_control_modes {
73 LINK_CONTROL_MODE_DEFAULT = 0,
74 LINK_CONTROL_MODE_USER = 1,
75 LINK_CONTROL_MODE_MIXED = 2,
76 };
77
78 /**
79 * struct ml_nlink_change_event - connection change event data struct
80 * @evt: event parameters
81 * @link_switch: link switch start parameters
82 * @tdls: tdls parameters
83 * @vendor: vendor command set link parameters
84 */
85 struct ml_nlink_change_event {
86 union {
87 struct {
88 uint8_t curr_ieee_link_id;
89 uint8_t new_ieee_link_id;
90 uint32_t new_primary_freq;
91 enum wlan_mlo_link_switch_reason reason;
92 } link_switch;
93 struct {
94 uint32_t link_bitmap;
95 uint8_t vdev_count;
96 uint8_t mlo_vdev_lst[WLAN_UMAC_MLO_MAX_VDEVS];
97 enum mlo_link_force_mode mode;
98 enum mlo_link_force_reason reason;
99 } tdls;
100 struct {
101 enum link_control_modes link_ctrl_mode;
102 uint8_t link_num;
103 uint32_t link_bitmap;
104 uint32_t link_bitmap2;
105 enum mlo_link_force_mode mode;
106 enum mlo_link_force_reason reason;
107 } vendor;
108 } evt;
109 };
110
111 #ifdef WLAN_FEATURE_11BE_MLO
force_mode_to_string(uint32_t mode)112 static inline const char *force_mode_to_string(uint32_t mode)
113 {
114 switch (mode) {
115 CASE_RETURN_STRING(MLO_LINK_FORCE_MODE_ACTIVE);
116 CASE_RETURN_STRING(MLO_LINK_FORCE_MODE_INACTIVE);
117 CASE_RETURN_STRING(MLO_LINK_FORCE_MODE_ACTIVE_NUM);
118 CASE_RETURN_STRING(MLO_LINK_FORCE_MODE_INACTIVE_NUM);
119 CASE_RETURN_STRING(MLO_LINK_FORCE_MODE_NO_FORCE);
120 CASE_RETURN_STRING(MLO_LINK_FORCE_MODE_ACTIVE_INACTIVE);
121 default:
122 return "Unknown";
123 }
124 };
125
126 #define ml_nlink_dump_force_state(_force_state, format, args...) \
127 mlo_debug("inactive 0x%x active 0x%x inact num %d 0x%x act num %d 0x%x dyn 0x%x"format, \
128 (_force_state)->force_inactive_bitmap, \
129 (_force_state)->force_active_bitmap, \
130 (_force_state)->force_inactive_num, \
131 (_force_state)->force_inactive_num_bitmap, \
132 (_force_state)->force_active_num, \
133 (_force_state)->force_active_num_bitmap, \
134 (_force_state)->curr_dynamic_inactive_bitmap, \
135 ##args);
136
link_evt_to_string(uint32_t evt)137 static inline const char *link_evt_to_string(uint32_t evt)
138 {
139 switch (evt) {
140 CASE_RETURN_STRING(ml_nlink_link_switch_start_evt);
141 CASE_RETURN_STRING(ml_nlink_link_switch_pre_completion_evt);
142 CASE_RETURN_STRING(ml_nlink_roam_sync_start_evt);
143 CASE_RETURN_STRING(ml_nlink_roam_sync_completion_evt);
144 CASE_RETURN_STRING(ml_nlink_connect_start_evt);
145 CASE_RETURN_STRING(ml_nlink_connect_completion_evt);
146 CASE_RETURN_STRING(ml_nlink_disconnect_start_evt);
147 CASE_RETURN_STRING(ml_nlink_disconnect_completion_evt);
148 CASE_RETURN_STRING(ml_nlink_ap_started_evt);
149 CASE_RETURN_STRING(ml_nlink_ap_stopped_evt);
150 CASE_RETURN_STRING(ml_nlink_connection_updated_evt);
151 CASE_RETURN_STRING(ml_nlink_tdls_request_evt);
152 CASE_RETURN_STRING(ml_nlink_vendor_cmd_request_evt);
153 default:
154 return "Unknown";
155 }
156 };
157
158 /**
159 * ml_nlink_conn_change_notify() - Notify connection state
160 * change to force link module
161 * @psoc: pointer to pdev
162 * @vdev_id: vdev id
163 * @evt: event type
164 * @data: event data
165 *
166 * Return: QDF_STATUS_SUCCESS in the case of success
167 */
168 QDF_STATUS
169 ml_nlink_conn_change_notify(struct wlan_objmgr_psoc *psoc,
170 uint8_t vdev_id,
171 enum ml_nlink_change_event_type evt,
172 struct ml_nlink_change_event *data);
173
174 #define MLO_MAX_VDEV_COUNT_PER_BIMTAP_ELEMENT (sizeof(uint32_t) * 8)
175
176 /**
177 * ml_nlink_convert_linkid_bitmap_to_vdev_bitmap() - convert link
178 * id bitmap to vdev id bitmap
179 * state
180 * @psoc: psoc object
181 * @vdev: vdev object
182 * @link_bitmap: link id bitmap
183 * @associated_bitmap: all associated the link id bitmap
184 * @vdev_id_bitmap_sz: number vdev id bitamp in vdev_id_bitmap
185 * @vdev_id_bitmap: array to return the vdev id bitmaps
186 * @vdev_id_num: total vdev id number in vdev_ids
187 * @vdev_ids: vdev id array
188 *
189 * Return: None
190 */
191 void
192 ml_nlink_convert_linkid_bitmap_to_vdev_bitmap(
193 struct wlan_objmgr_psoc *psoc,
194 struct wlan_objmgr_vdev *vdev,
195 uint32_t link_bitmap,
196 uint32_t *associated_bitmap,
197 uint32_t *vdev_id_bitmap_sz,
198 uint32_t vdev_id_bitmap[MLO_VDEV_BITMAP_SZ],
199 uint8_t *vdev_id_num,
200 uint8_t vdev_ids[WLAN_MLO_MAX_VDEVS]);
201
202 /**
203 * ml_nlink_convert_vdev_bitmap_to_linkid_bitmap() - convert vdev
204 * id bitmap to link id bitmap
205 * state
206 * @psoc: psoc object
207 * @vdev: vdev object
208 * @vdev_id_bitmap_sz: array size of vdev_id_bitmap
209 * @vdev_id_bitmap: vdev bitmap array
210 * @link_bitmap: link id bitamp converted from vdev id bitmap
211 * @associated_bitmap: all associated the link id bitmap
212 *
213 * Return: None
214 */
215 void
216 ml_nlink_convert_vdev_bitmap_to_linkid_bitmap(
217 struct wlan_objmgr_psoc *psoc,
218 struct wlan_objmgr_vdev *vdev,
219 uint32_t vdev_id_bitmap_sz,
220 uint32_t *vdev_id_bitmap,
221 uint32_t *link_bitmap,
222 uint32_t *associated_bitmap);
223
224 /**
225 * convert_link_bitmap_to_link_ids() - Convert link bitmap to link ids
226 * @link_bitmap: PSOC object information
227 * @link_id_sz: link_ids array size
228 * @link_ids: link id array
229 *
230 * Return: num of link id in link_ids array converted from link bitmap
231 */
232 uint32_t
233 convert_link_bitmap_to_link_ids(uint32_t link_bitmap,
234 uint8_t link_id_sz,
235 uint8_t *link_ids);
236
237 /**
238 * ml_nlink_convert_link_bitmap_to_ids() - convert link bitmap
239 * to link ids
240 * @link_bitmap: link bitmap
241 * @link_id_sz: array size of link_ids
242 * @link_ids: link id array
243 *
244 * Return: number of link ids
245 */
246 uint32_t
247 ml_nlink_convert_link_bitmap_to_ids(uint32_t link_bitmap,
248 uint8_t link_id_sz,
249 uint8_t *link_ids);
250
251 /**
252 * enum set_curr_control - control flag to update current force bitmap
253 * @LINK_OVERWRITE: use bitmap to overwrite existing force bitmap
254 * @LINK_CLR: clr the input bitmap from existing force bitmap
255 * @LINK_ADD: append the input bitmap to existing force bitamp
256 *
257 * This control value will be used in ml_nlink_set_* API to indicate
258 * how to update input link_bitmap to current bitmap
259 */
260 enum set_curr_control {
261 LINK_OVERWRITE = 0x0,
262 LINK_CLR = 0x1,
263 LINK_ADD = 0x2,
264 };
265
266 /**
267 * ml_nlink_set_curr_force_active_state() - set link force active
268 * state
269 * @psoc: psoc object
270 * @vdev: vdev object
271 * @link_bitmap: force active link id bitmap
272 * @ctrl: control value to indicate how to update link_bitmap to current
273 * bitmap
274 *
275 * Return: None
276 */
277 void
278 ml_nlink_set_curr_force_active_state(struct wlan_objmgr_psoc *psoc,
279 struct wlan_objmgr_vdev *vdev,
280 uint16_t link_bitmap,
281 enum set_curr_control ctrl);
282
283 /**
284 * ml_nlink_set_curr_force_inactive_state() - set link force inactive
285 * state
286 * @psoc: psoc object
287 * @vdev: vdev object
288 * @link_bitmap: force inactive link id bitmap
289 * @ctrl: control value to indicate how to update link_bitmap to current
290 * bitmap
291 *
292 * Return: None
293 */
294 void
295 ml_nlink_set_curr_force_inactive_state(struct wlan_objmgr_psoc *psoc,
296 struct wlan_objmgr_vdev *vdev,
297 uint16_t link_bitmap,
298 enum set_curr_control ctrl);
299
300 /**
301 * ml_nlink_set_curr_force_active_num_state() - set link force active
302 * number state
303 * @psoc: psoc object
304 * @vdev: vdev object
305 * @link_num: force active num
306 * @link_bitmap: force active num link id bitmap
307 *
308 * Return: None
309 */
310 void
311 ml_nlink_set_curr_force_active_num_state(struct wlan_objmgr_psoc *psoc,
312 struct wlan_objmgr_vdev *vdev,
313 uint8_t link_num,
314 uint16_t link_bitmap);
315
316 /**
317 * ml_nlink_set_curr_force_inactive_num_state() - set link force inactive
318 * number state
319 * @psoc: psoc object
320 * @vdev: vdev object
321 * @link_num: force inactive num
322 * @link_bitmap: force inactive num link id bitmap
323 *
324 * Return: None
325 */
326 void
327 ml_nlink_set_curr_force_inactive_num_state(struct wlan_objmgr_psoc *psoc,
328 struct wlan_objmgr_vdev *vdev,
329 uint8_t link_num,
330 uint16_t link_bitmap);
331
332 /**
333 * ml_nlink_set_dynamic_inactive_links() - set link dynamic inactive
334 * link bitmap
335 * @psoc: psoc object
336 * @vdev: vdev object
337 * @dynamic_link_bitmap: dynamic inactive bitmap
338 *
339 * Return: None
340 */
341 void
342 ml_nlink_set_dynamic_inactive_links(struct wlan_objmgr_psoc *psoc,
343 struct wlan_objmgr_vdev *vdev,
344 uint16_t dynamic_link_bitmap);
345
346 /**
347 * ml_nlink_get_dynamic_inactive_links() - get link dynamic inactive
348 * link bitmap
349 * @psoc: psoc object
350 * @vdev: vdev object
351 * @dynamic_link_bitmap: dynamic inactive bitmap
352 * @force_link_bitmap: forced inactive bitmap
353 *
354 * Return: None
355 */
356 void
357 ml_nlink_get_dynamic_inactive_links(struct wlan_objmgr_psoc *psoc,
358 struct wlan_objmgr_vdev *vdev,
359 uint16_t *dynamic_link_bitmap,
360 uint16_t *force_link_bitmap);
361
362 /**
363 * ml_nlink_init_concurrency_link_request() - Init concurrency force
364 * link request
365 * link bitmap
366 * @psoc: psoc object
367 * @vdev: vdev object
368 *
369 * When ML STA associated or Roam, initialize the concurrency
370 * force link request based on "current" force link state
371 *
372 * Return: None
373 */
374 void ml_nlink_init_concurrency_link_request(
375 struct wlan_objmgr_psoc *psoc,
376 struct wlan_objmgr_vdev *vdev);
377
378 /**
379 * ml_nlink_get_force_link_request() - get link request of source
380 * link bitmap
381 * @psoc: psoc object
382 * @vdev: vdev object
383 * @req: set link request
384 * @source: the source to query
385 *
386 * Return: None
387 */
388 void
389 ml_nlink_get_force_link_request(struct wlan_objmgr_psoc *psoc,
390 struct wlan_objmgr_vdev *vdev,
391 struct set_link_req *req,
392 enum set_link_source source);
393
394 /**
395 * ml_nlink_get_curr_force_state() - get link force state
396 * @psoc: psoc object
397 * @vdev: vdev object
398 * @force_cmd: current force state
399 *
400 * Return: None
401 */
402 void
403 ml_nlink_get_curr_force_state(struct wlan_objmgr_psoc *psoc,
404 struct wlan_objmgr_vdev *vdev,
405 struct ml_link_force_state *force_cmd);
406
407 /**
408 * ml_nlink_clr_force_state() - clear all link force state
409 * @psoc: psoc object
410 * @vdev: vdev object
411 *
412 * Return: None
413 */
414 void
415 ml_nlink_clr_force_state(struct wlan_objmgr_psoc *psoc,
416 struct wlan_objmgr_vdev *vdev);
417
418 /**
419 * ml_nlink_vendor_command_set_link() - Update vendor command
420 * set link parameters
421 * @psoc: psoc object
422 * @vdev_id: vdev id
423 * @link_control_mode: link control mode: default, user, mix
424 * @reason: reason to set
425 * @mode: mode to set
426 * @link_num: number of link, valid for mode:
427 * @link_bitmap: link bitmap, valid for mode:
428 * @link_bitmap2: inactive link bitmap, only valid for mode
429 *
430 * Return: void
431 */
432 void
433 ml_nlink_vendor_command_set_link(struct wlan_objmgr_psoc *psoc,
434 uint8_t vdev_id,
435 enum link_control_modes link_control_mode,
436 enum mlo_link_force_reason reason,
437 enum mlo_link_force_mode mode,
438 uint8_t link_num,
439 uint16_t link_bitmap,
440 uint16_t link_bitmap2);
441
442 /**
443 * ml_is_nlink_service_supported() - support nlink or not
444 * @psoc: psoc object
445 *
446 * Return: true if supported
447 */
448 bool ml_is_nlink_service_supported(struct wlan_objmgr_psoc *psoc);
449
450 /**
451 * ml_nlink_get_standby_link_bitmap() - Get standby link info
452 * @psoc: psoc
453 * @vdev: vdev object
454 *
455 * Return: standby link bitmap
456 */
457 uint32_t
458 ml_nlink_get_standby_link_bitmap(struct wlan_objmgr_psoc *psoc,
459 struct wlan_objmgr_vdev *vdev);
460 #else
461 static inline QDF_STATUS
ml_nlink_conn_change_notify(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,enum ml_nlink_change_event_type evt,struct ml_nlink_change_event * data)462 ml_nlink_conn_change_notify(struct wlan_objmgr_psoc *psoc,
463 uint8_t vdev_id,
464 enum ml_nlink_change_event_type evt,
465 struct ml_nlink_change_event *data)
466 {
467 return QDF_STATUS_SUCCESS;
468 }
469
470 static inline bool
ml_is_nlink_service_supported(struct wlan_objmgr_psoc * psoc)471 ml_is_nlink_service_supported(struct wlan_objmgr_psoc *psoc)
472 {
473 return false;
474 }
475 #endif
476 #endif
477