1 /* 2 * Copyright (c) 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 any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /* 19 * DOC: contains MLO manager public file containing AP functionality 20 */ 21 #ifndef _WLAN_MLO_MGR_AP_H_ 22 #define _WLAN_MLO_MGR_AP_H_ 23 24 #include <wlan_mlo_mgr_cmn.h> 25 #include <wlan_mlo_mgr_public_structs.h> 26 #include "wlan_mlo_mgr_msgq.h" 27 28 #define WLAN_RESV_AID_BITS 0xc000 29 #define WLAN_AID(b) ((b) & ~0xc000) 30 /** 31 * mlo_ap_vdev_attach() - update vdev obj and vdev count to 32 * wlan_mlo_dev_context 33 * @vdev: vdev pointer 34 * @link_id: link id 35 * @vdev_count: number of vdev in the mlo 36 * 37 * Return: true if succeeds 38 */ 39 bool mlo_ap_vdev_attach(struct wlan_objmgr_vdev *vdev, 40 uint8_t link_id, 41 uint16_t vdev_count); 42 43 /** 44 * mlo_ap_get_vdev_list() - get mlo vdev list 45 * @vdev: vdev pointer 46 * @vdev_count: vdev count 47 * @wlan_vdev_list: vdev list 48 * 49 * This API gets all partner vdev's which have WLAN_VDEV_FEXT2_MLO bit 50 * set. 51 * 52 * It takes references for all vdev's with bit set in the list. Callers 53 * of this API should properly release references before destroying the 54 * list. 55 * 56 * Return: None 57 */ 58 void mlo_ap_get_vdev_list(struct wlan_objmgr_vdev *vdev, 59 uint16_t *vdev_count, 60 struct wlan_objmgr_vdev **wlan_vdev_list); 61 62 /** 63 * mlo_ap_get_active_vdev_list() - get mlo vdev list 64 * @vdev: vdev pointer 65 * @vdev_count: vdev count 66 * @wlan_vdev_list: vdev list 67 * 68 * This API gets all active partner vdev's which have WLAN_VDEV_FEXT2_MLO bit 69 * set. 70 * 71 * It takes references for all vdev's with bit set in the list. Callers 72 * of this API should properly release references before destroying the 73 * list. 74 * 75 * Return: None 76 */ 77 void mlo_ap_get_active_vdev_list(struct wlan_objmgr_vdev *vdev, 78 uint16_t *vdev_count, 79 struct wlan_objmgr_vdev **wlan_vdev_list); 80 81 /** 82 * mlo_ap_get_partner_vdev_list_from_mld() - get partner vdev from MLD 83 * vdev_list without checking 84 * WLAN_VDEV_FEXT2_MLO bit 85 * @vdev: vdev pointer 86 * @vdev_count: vdev count 87 * @wlan_vdev_list: vdev list 88 * 89 * This API gets all partner vdev's irrespective of WLAN_VDEV_FEXT2_MLO 90 * bit. Ideally, it copies all partners of the MLD with references. 91 * 92 * It takes references for all vdev's in the list. The callers of this 93 * API should properly release references before destroying the list. 94 * 95 * Return: None 96 */ 97 void mlo_ap_get_partner_vdev_list_from_mld( 98 struct wlan_objmgr_vdev *vdev, 99 uint16_t *vdev_count, 100 struct wlan_objmgr_vdev **wlan_vdev_list); 101 102 /** 103 * mlo_ap_link_sync_wait_notify() - notify the mlo manager, once vdev 104 * enters WLAN_VDEV_SS_MLO_SYNC_WAIT 105 * @vdev: vdev pointer 106 * 107 * Return: true if MLO_SYNC_COMPLETE is posted, else false 108 */ 109 bool mlo_ap_link_sync_wait_notify(struct wlan_objmgr_vdev *vdev); 110 111 /** 112 * mlo_ap_link_start_rsp_notify - Notify that the link start is completed 113 * 114 * @vdev: pointer to vdev 115 * 116 * Return: none 117 */ 118 void mlo_ap_link_start_rsp_notify(struct wlan_objmgr_vdev *vdev); 119 120 /** 121 * mlo_ap_vdev_detach() - notify the mlo manager to detach given vdev 122 * @vdev: vdev pointer 123 * 124 * Return: None 125 */ 126 void mlo_ap_vdev_detach(struct wlan_objmgr_vdev *vdev); 127 128 /** 129 * mlo_ap_link_down_cmpl_notify() - notify the mlo manager, once vdev 130 * is down completely 131 * @vdev: vdev pointer 132 * 133 * Return: None 134 */ 135 void mlo_ap_link_down_cmpl_notify(struct wlan_objmgr_vdev *vdev); 136 137 /** 138 * wlan_vdev_mlme_aid_mgr_max_aid_set() - set VDEV Max AID 139 * @vdev: vdev pointer 140 * @max_aid: max AID 141 * 142 * This function sets max AID for the VDEV 143 * 144 * Return: void 145 */ 146 void wlan_vdev_mlme_aid_mgr_max_aid_set(struct wlan_objmgr_vdev *vdev, 147 uint16_t max_aid); 148 149 /** 150 * wlan_vdev_mlme_set_start_aid() - set VDEV start AID 151 * @vdev: vdev pointer 152 * @start_aid: start AID 153 * 154 * This function sets start AID for the VDEV 155 * 156 * Return: void 157 */ 158 QDF_STATUS wlan_vdev_mlme_set_start_aid(struct wlan_objmgr_vdev *vdev, 159 uint16_t start_aid); 160 161 /** 162 * wlan_vdev_mlme_get_start_aid() - set VDEV start AID 163 * @vdev: vdev pointer 164 * 165 * This function sets start AID for the VDEV 166 * 167 * Return: start AID 168 */ 169 uint16_t wlan_vdev_mlme_get_start_aid(struct wlan_objmgr_vdev *vdev); 170 171 /** 172 * wlan_mlo_vdev_init_mbss_aid_mgr() - Assigns tx vdev aid mgr to a VDEV 173 * @ml_dev: MLO DEV context 174 * @vdev: VDEV 175 * @tx_vdev: Transmit VDEV 176 * 177 * This function assigns Tx VDEV's AID mgr to non-Tx VDEV 178 * 179 * Return: SUCCESS if assigned successfully 180 */ 181 QDF_STATUS wlan_mlo_vdev_init_mbss_aid_mgr(struct wlan_mlo_dev_context *ml_dev, 182 struct wlan_objmgr_vdev *vdev, 183 struct wlan_objmgr_vdev *tx_vdev); 184 185 /** 186 * wlan_mlo_vdev_deinit_mbss_aid_mgr() - Resets aid mgr to a non-Tx VDEV 187 * @mldev: MLO DEV context 188 * @vdev: VDEV 189 * @tx_vdev: Transmit VDEV 190 * 191 * This function resets AID mgr of non-Tx VDEV 192 * 193 * Return: SUCCESS if reset successfully 194 */ 195 QDF_STATUS wlan_mlo_vdev_deinit_mbss_aid_mgr(struct wlan_mlo_dev_context *mldev, 196 struct wlan_objmgr_vdev *vdev, 197 struct wlan_objmgr_vdev *tx_vdev); 198 199 /** 200 * wlan_mlme_vdev_init_mbss_aid_mgr() - Assigns tx vdev aid mgr to a VDEV 201 * @vdev: VDEV 202 * @tx_vdev: Transmit VDEV 203 * 204 * This function assigns Tx VDEV's AID mgr to non-Tx VDEV 205 * 206 * Return: SUCCESS if assigned successfully 207 */ 208 QDF_STATUS wlan_mlme_vdev_init_mbss_aid_mgr(struct wlan_objmgr_vdev *vdev, 209 struct wlan_objmgr_vdev *tx_vdev); 210 211 /** 212 * wlan_mlme_vdev_deinit_mbss_aid_mgr() - Resets aid mgr to a non-Tx VDEV 213 * @vdev: VDEV 214 * @tx_vdev: Transmit VDEV 215 * 216 * This function resets AID mgr of non-Tx VDEV 217 * 218 * Return: SUCCESS if reset successfully 219 */ 220 QDF_STATUS wlan_mlme_vdev_deinit_mbss_aid_mgr(struct wlan_objmgr_vdev *vdev, 221 struct wlan_objmgr_vdev *tx_vdev); 222 223 /** 224 * wlan_vdev_aid_mgr_init() - VDEV AID mgr init 225 * @max_aid: max AID 226 * 227 * This function is called as part of vdev/MLO DEV initialization. 228 * This will allocate aid mgr structure for a VDEV 229 * 230 * Return: aid_mgr 231 */ 232 struct wlan_vdev_aid_mgr *wlan_vdev_aid_mgr_init(uint16_t max_aid); 233 234 /** 235 * wlan_vdev_aid_mgr_free() - VDEV AID mgr free 236 * @aid_mgr: AID mgr 237 * 238 * This function frees the aid mgr of the VDEV 239 * 240 * Return: void 241 */ 242 void wlan_vdev_aid_mgr_free(struct wlan_vdev_aid_mgr *aid_mgr); 243 244 /** 245 * wlan_mlo_vdev_aid_mgr_init() - MLO AID mgr init 246 * @ml_dev: MLO DEV context 247 * 248 * This function allocate AID space for all associated VDEVs of MLD 249 * 250 * Return: SUCCESS if allocated successfully 251 */ 252 QDF_STATUS wlan_mlo_vdev_aid_mgr_init(struct wlan_mlo_dev_context *ml_dev); 253 254 /** 255 * wlan_mlo_vdev_aid_mgr_deinit() - MLO AID mgr free 256 * @ml_dev: MLO DEV context 257 * 258 * This function frees AID space for all associated VDEVs of MLD 259 * 260 * Return: void 261 */ 262 void wlan_mlo_vdev_aid_mgr_deinit(struct wlan_mlo_dev_context *ml_dev); 263 264 /** 265 * wlan_mlo_vdev_alloc_aid_mgr() - Allocate AID space for a VDEV 266 * @ml_dev: MLO DEV context 267 * @vdev: VDEV 268 * 269 * This function allocates AID space for an associated VDEV of MLD 270 * 271 * Return: SUCCESS if allocated successfully 272 */ 273 QDF_STATUS wlan_mlo_vdev_alloc_aid_mgr(struct wlan_mlo_dev_context *ml_dev, 274 struct wlan_objmgr_vdev *vdev); 275 276 /** 277 * wlan_mlo_vdev_free_aid_mgr() - Free AID space for a VDEV 278 * @ml_dev: MLO DEV context 279 * @vdev: VDEV 280 * 281 * This function frees AID space for an associated VDEV of MLD 282 * 283 * Return: SUCCESS if freed successfully 284 */ 285 QDF_STATUS wlan_mlo_vdev_free_aid_mgr(struct wlan_mlo_dev_context *ml_dev, 286 struct wlan_objmgr_vdev *vdev); 287 288 /** 289 * mlo_peer_allocate_aid() - Allocate AID for MLO peer 290 * @ml_dev: MLO DEV context 291 * @ml_peer: MLO peer object 292 * 293 * This function allocates AID for an MLO peer 294 * 295 * Return: SUCCESS if allocated successfully 296 */ 297 QDF_STATUS mlo_peer_allocate_aid( 298 struct wlan_mlo_dev_context *ml_dev, 299 struct wlan_mlo_peer_context *ml_peer); 300 301 /** 302 * mlo_get_aid() - Allocate AID for a associated station 303 * @vdev: VDEV 304 * 305 * This function allocates AID for an associated station of MLD 306 * 307 * Return: AID 308 */ 309 uint16_t mlo_get_aid(struct wlan_objmgr_vdev *vdev); 310 311 /** 312 * mlo_free_aid() - Frees AID for a station 313 * @vdev: VDEV 314 * @assoc_id: Assoc ID 315 * 316 * This function frees AID for an associated station of MLD 317 * 318 * Return: SUCCESS if freed 319 */ 320 QDF_STATUS mlo_free_aid(struct wlan_objmgr_vdev *vdev, uint16_t assoc_id); 321 322 /** 323 * mlme_get_aid() - Allocate AID for a non-MLD station 324 * @vdev: VDEV 325 * 326 * This function allocates AID for an associated NON-MLD station of MLD 327 * 328 * Return: AID 329 */ 330 uint16_t mlme_get_aid(struct wlan_objmgr_vdev *vdev); 331 332 /** 333 * mlme_is_aid_set() - Check whether the AID is already allocated 334 * @vdev: VDEV 335 * @assoc_id: Assoc ID 336 * 337 * This function checks whether the AID is already allocated 338 * 339 * Return: 1 for AID is already allocated 340 * 0 for AID is available 341 */ 342 int mlme_is_aid_set(struct wlan_objmgr_vdev *vdev, uint16_t assoc_id); 343 344 /** 345 * wlan_mlo_peer_free_aid() - Free assoc id 346 * @ml_aid_mgr: MLO AID mgr 347 * @link_ix: Link index 348 * @assoc_id: Assoc id to be freed 349 * 350 * This function frees assoc id, resets bit in all bitmaps 351 * 352 * Return: SUCCESS,if it freed 353 */ 354 QDF_STATUS wlan_mlo_peer_free_aid( 355 struct wlan_ml_vdev_aid_mgr *ml_aid_mgr, 356 uint8_t link_ix, 357 uint16_t assoc_id); 358 359 /** 360 * wlan_mlme_peer_free_aid() - Free link assoc id 361 * @vdev_aid_mgr: VDEV AID mgr 362 * @no_lock: lock needed for the operation 363 * @assoc_id: Assoc id to be freed 364 * 365 * This function frees assoc id of a specific VDEV 366 * 367 * Return: void 368 */ 369 void wlan_mlme_peer_free_aid( 370 struct wlan_vdev_aid_mgr *vdev_aid_mgr, 371 bool no_lock, uint16_t assoc_id); 372 373 /** 374 * mlo_peer_free_aid() - public API to free AID 375 * @ml_dev: MLO DEV context 376 * @ml_peer: MLO peer object 377 * 378 * This function invokes low level API to free assoc id 379 * 380 * Return: SUCCESS, if it freed 381 */ 382 QDF_STATUS mlo_peer_free_aid(struct wlan_mlo_dev_context *ml_dev, 383 struct wlan_mlo_peer_context *ml_peer); 384 385 /** 386 * mlme_free_aid() - public API to free link assoc id 387 * @vdev: VDEV object 388 * @assoc_id: Assoc id to be freed 389 * 390 * This function invokes low level API to free assoc id of a specific VDEV 391 * 392 * Return: void 393 */ 394 void mlme_free_aid(struct wlan_objmgr_vdev *vdev, uint16_t assoc_id); 395 396 /** 397 * mlo_set_aid() - public API to reserve AID 398 * @vdev: VDEV object 399 * @assoc_id: Assoc id to be reserved 400 * 401 * This function reserves AID of MLO VDEV 402 * 403 * Return: SUCCESS, if it is reserved 404 * FAILURE, if it is already allocated 405 */ 406 QDF_STATUS mlo_set_aid(struct wlan_objmgr_vdev *vdev, 407 uint16_t assoc_id); 408 409 /** 410 * mlme_set_aid() - public API to reserve AID 411 * @vdev: VDEV object 412 * @assoc_id: Assoc id to be reserved 413 * 414 * This function reserves AID of VDEV 415 * 416 * Return: SUCCESS, if it is reserved 417 * FAILURE, if it is already allocated 418 */ 419 QDF_STATUS mlme_set_aid(struct wlan_objmgr_vdev *vdev, 420 uint16_t assoc_id); 421 422 /** 423 * wlan_mlme_get_aid_count() - public API to get AID count 424 * @vdev: VDEV object 425 * 426 * This function counts number AIDs allocated for the VDEV 427 * 428 * Return: aid count value 429 */ 430 uint16_t wlan_mlme_get_aid_count(struct wlan_objmgr_vdev *vdev); 431 432 /** 433 * mlo_ap_ml_peerid_alloc() - public API to allocate MLO peer id 434 * 435 * This function allocates MLO peer ID 436 * 437 * Return: mlo_peer_id on success, 438 * MLO_INVALID_PEER_ID on failure 439 */ 440 uint16_t mlo_ap_ml_peerid_alloc(void); 441 442 /** 443 * mlo_ap_ml_peerid_free() - public API to free MLO peer id 444 * @mlo_peer_id: ML peer id 445 * 446 * This function frees MLO peer ID 447 * 448 * Return: void 449 */ 450 void mlo_ap_ml_peerid_free(uint16_t mlo_peer_id); 451 452 #define ML_PRIMARY_UMAC_ID_INVAL 0xff 453 /** 454 * mlo_peer_assign_primary_umac() - Assign Primary UMAC 455 * @ml_peer: MLO peer object 456 * @peer_entry: Link peer entry 457 * 458 * This function assigns primary UMAC flag in peer entry 459 * 460 * Return: SUCCESS,if it allocated 461 */ 462 void mlo_peer_assign_primary_umac( 463 struct wlan_mlo_peer_context *ml_peer, 464 struct wlan_mlo_link_peer_entry *peer_entry); 465 466 /** 467 * mlo_peer_allocate_primary_umac() - Allocate Primary UMAC 468 * @ml_dev: MLO DEV context 469 * @ml_peer: MLO peer object 470 * @link_vdevs: link vdev array 471 * 472 * This function allocates primary UMAC for a MLO peer 473 * 474 * Return: SUCCESS,if it allocated 475 */ 476 QDF_STATUS mlo_peer_allocate_primary_umac( 477 struct wlan_mlo_dev_context *ml_dev, 478 struct wlan_mlo_peer_context *ml_peer, 479 struct wlan_objmgr_vdev *link_vdevs[]); 480 481 /** 482 * mlo_peer_free_primary_umac() - Free Primary UMAC 483 * @ml_dev: MLO DEV context 484 * @ml_peer: MLO peer object 485 * 486 * This function frees primary UMAC for a MLO peer 487 * 488 * Return: SUCCESS,if it is freed 489 */ 490 QDF_STATUS mlo_peer_free_primary_umac( 491 struct wlan_mlo_dev_context *ml_dev, 492 struct wlan_mlo_peer_context *ml_peer); 493 494 /** 495 * mlo_ap_vdev_quiet_set() - Set quiet bitmap for requested vdev 496 * @vdev: Pointer to object manager vdev 497 * 498 * Return: void 499 */ 500 void mlo_ap_vdev_quiet_set(struct wlan_objmgr_vdev *vdev); 501 502 /** 503 * mlo_ap_vdev_quiet_clear() - Clear quiet bitmap for requested vdev 504 * @vdev: Pointer to object manager vdev 505 * 506 * Return: void 507 */ 508 void mlo_ap_vdev_quiet_clear(struct wlan_objmgr_vdev *vdev); 509 510 /** 511 * mlo_ap_vdev_quiet_is_any_idx_set() - Check if any index is set in 512 * quiet bitmap 513 * @vdev: Pointer to object manager vdev 514 * 515 * Return: true, if any index is set, else false 516 */ 517 bool mlo_ap_vdev_quiet_is_any_idx_set(struct wlan_objmgr_vdev *vdev); 518 519 #if defined(MESH_MODE_SUPPORT) && defined(WLAN_FEATURE_11BE_MLO) 520 /** 521 * mlo_peer_populate_mesh_params() - Populate mesh parameters in ml_peer 522 * @ml_peer: ml_peer to which mesh config parameters need to be populated 523 * @ml_info: ml_info with mesh config associated with this link 524 * 525 * Return: void 526 */ 527 void mlo_peer_populate_mesh_params( 528 struct wlan_mlo_peer_context *ml_peer, 529 struct mlo_partner_info *ml_info); 530 #else 531 static inline 532 void mlo_peer_populate_mesh_params( 533 struct wlan_mlo_peer_context *ml_peer, 534 struct mlo_partner_info *ml_info) 535 { 536 } 537 #endif 538 539 #ifdef UMAC_SUPPORT_MLNAWDS 540 /** 541 * mlo_peer_populate_nawds_params() - Populate nawds parameters in ml_peer 542 * @ml_peer: ml_peer to which nawds config parameters need to be populated 543 * @ml_info: ml_info with nawds config associated with this link 544 * 545 * Return: void 546 */ 547 void mlo_peer_populate_nawds_params( 548 struct wlan_mlo_peer_context *ml_peer, 549 struct mlo_partner_info *ml_info); 550 #else 551 static inline 552 void mlo_peer_populate_nawds_params( 553 struct wlan_mlo_peer_context *ml_peer, 554 struct mlo_partner_info *ml_info) 555 { 556 } 557 #endif 558 559 /** 560 * mlo_peer_create_get_frm_buf() - get frm_buf to peer_create 561 * @ml_peer: MLO peer 562 * @peer_create: pointer to peer_create_notif context 563 * @frm_buf: pointer to frame buffer to be cloned to peer_create 564 * 565 * Return: SUCCESS if 566 * - peer_create frame buffer cloned successfully in non NAWDS case Or 567 * - ml_peer is in NAWDS mode. 568 */ 569 QDF_STATUS mlo_peer_create_get_frm_buf( 570 struct wlan_mlo_peer_context *ml_peer, 571 struct peer_create_notif_s *peer_create, 572 qdf_nbuf_t frm_buf); 573 574 /** 575 * wlan_mlo_ap_get_active_links() - Get number of active link VDEVs of MLD 576 * @vdev: vdev pointer 577 * 578 * Return: active vdev count. 579 */ 580 uint16_t wlan_mlo_ap_get_active_links(struct wlan_objmgr_vdev *vdev); 581 582 #endif 583