1 /* 2 * Copyright (c) 2021, The Linux Foundation. All rights reserved. 3 * Copyright (c) 2021-2022 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 peer functionality 20 */ 21 #ifndef _WLAN_MLO_MGR_PEER_H_ 22 #define _WLAN_MLO_MGR_PEER_H_ 23 24 #include "wlan_objmgr_peer_obj.h" 25 26 #define WLAN_LINK_ID_INVALID 0xff 27 28 /** 29 * mlo_peer_create - Initiatiate peer create on secondary link(s) 30 * by posting a message 31 * 32 * @vdev: pointer to vdev 33 * @peer: pointer to peer context 34 * @mlo_ie: MLO information element 35 * @aid: association ID 36 * 37 * Initiate the peer on the second link 38 * 39 * Return: none 40 */ 41 void mlo_peer_create(struct wlan_objmgr_vdev *vdev, 42 struct wlan_objmgr_peer *peer, uint8_t *mlo_ie, 43 uint8_t aid); 44 45 /** 46 * mlo_get_mlpeer - Get ML peer corresponds to the MLD address 47 * @ml_dev: MLO DEV object 48 * @ml_addr: MLD MAC address 49 * 50 * This API will be used to get the ML peer associated with MLD address. 51 * It will return Null if the peer does not exist for the given MLD address. 52 * 53 * Return: Pointer to the ML peer context structure 54 */ 55 struct wlan_mlo_peer_context *mlo_get_mlpeer( 56 struct wlan_mlo_dev_context *ml_dev, 57 struct qdf_mac_addr *ml_addr); 58 59 /** 60 * mlo_peer_attach - Attaches the peer by updating the MLO peer context with 61 * the new link information 62 * 63 * @vdev: pointer to vdev 64 * @peer: pointer to peer context 65 * 66 * Return: none 67 */ 68 void mlo_peer_attach(struct wlan_objmgr_vdev *vdev, 69 struct wlan_objmgr_peer *peer); 70 71 /** 72 * mlo_peer_setup_failed_notify - Notify MLO manager that peer setup has failed 73 * and to cleanup by deleting the partner peers 74 * 75 * @vdev: pointer to vdev 76 * 77 * This API is called in scenarios where peer create or peer assoc fails 78 * 79 * Return: none 80 */ 81 void mlo_peer_setup_failed_notify(struct wlan_objmgr_vdev *vdev); 82 83 /** 84 * mlo_peer_disconnect_notify - Notify MLO manager that peer has disconnected 85 * and to clean up by deleting partner peers 86 * 87 * @vdev: pointer to vdev 88 * 89 * Return: none 90 */ 91 void mlo_peer_disconnect_notify(struct wlan_objmgr_peer *peer); 92 93 /** 94 * wlan_peer_delete_complete - Notify MLO manager that peer delete is completed 95 * and to clean up by unlinking the peer object 96 * 97 * @peer: pointer to peer context 98 * 99 * Return: none 100 */ 101 void wlan_peer_delete_complete(struct wlan_objmgr_peer *peer); 102 103 /** 104 * mlo_peer_delete - Delete the peer object 105 * 106 * @peer: pointer to peer context 107 * 108 * Return: none 109 */ 110 void mlo_peer_delete(struct wlan_objmgr_peer *peer); 111 112 /** 113 * is_mlo_all_peer_links_deleted - Check if all the peer links are deleted 114 * 115 * Return: true if all the peer links are deleted, false otherwise 116 */ 117 bool is_mlo_all_peer_links_deleted(void); 118 119 /** 120 * wlan_mlo_peer_is_disconnect_progress() - MLO peer is in disconnect progress 121 * @ml_peer: MLO peer 122 * 123 * This function checks whether MLO Peer is in disconnect progress 124 * 125 * Return: SUCCESS if MLO Peer is in disconnect progress 126 */ 127 QDF_STATUS wlan_mlo_peer_is_disconnect_progress( 128 struct wlan_mlo_peer_context *ml_peer); 129 130 /** 131 * wlan_mlo_peer_is_assoc_done() - MLO peer is Assoc complete 132 * @ml_peer: MLO peer 133 * 134 * This function checks whether MLO Peer's Assoc is completed 135 * 136 * Return: SUCCESS if MLO Peer Assoc is completed 137 */ 138 QDF_STATUS wlan_mlo_peer_is_assoc_done(struct wlan_mlo_peer_context *ml_peer); 139 140 /** 141 * wlan_mlo_peer_get_assoc_peer() - get assoc peer 142 * @ml_peer: MLO peer 143 * 144 * This function returns assoc peer of MLO peer 145 * 146 * Return: assoc peer, if it is found, otherwise NULL 147 */ 148 struct wlan_objmgr_peer *wlan_mlo_peer_get_assoc_peer( 149 struct wlan_mlo_peer_context *ml_peer); 150 151 /** 152 * mlo_peer_is_assoc_peer() - check whether the peer is assoc peer 153 * @ml_peer: MLO peer 154 * @peer: Link peer 155 * 156 * This function checks whether the peer is assoc peer of MLO peer, 157 * This API doesn't have lock protection, caller needs to take the lock 158 * 159 * Return: true, if it is assoc peer 160 */ 161 bool mlo_peer_is_assoc_peer(struct wlan_mlo_peer_context *ml_peer, 162 struct wlan_objmgr_peer *peer); 163 164 /** 165 * wlan_mlo_peer_is_assoc_peer() - check whether the peer is assoc peer 166 * @ml_peer: MLO peer 167 * @peer: Link peer 168 * 169 * This function checks whether the peer is assoc peer of MLO peer 170 * 171 * Return: true, if it is assoc peer 172 */ 173 bool wlan_mlo_peer_is_assoc_peer(struct wlan_mlo_peer_context *ml_peer, 174 struct wlan_objmgr_peer *peer); 175 176 /** 177 * wlan_mlo_partner_peer_assoc_post() - Notify partner peer assoc 178 * @peer: Link peer 179 * 180 * This function notifies link peers to send peer assoc command to FW 181 * 182 * Return: void 183 */ 184 void wlan_mlo_partner_peer_assoc_post(struct wlan_objmgr_peer *assoc_peer); 185 186 /** 187 * wlan_mlo_peer_deauth_init() - Initiate Deauth of MLO peer 188 * @ml_peer: MLO peer 189 * 190 * This function initiates deauth on MLO peer and its links peers 191 * 192 * Return: void 193 */ 194 void wlan_mlo_peer_deauth_init(struct wlan_mlo_peer_context *ml_peer); 195 196 /** 197 * wlan_mlo_partner_peer_create_failed_notify() - Notify peer creation fail 198 * @ml_peer: MLO peer 199 * 200 * This function notifies about link peer creation failure 201 * 202 * Return: void 203 */ 204 void wlan_mlo_partner_peer_create_failed_notify( 205 struct wlan_mlo_peer_context *ml_peer); 206 207 /** 208 * wlan_mlo_partner_peer_disconnect_notify() - Notify peer disconnect 209 * @peer: Link peer 210 * 211 * This function notifies about disconnect is being initilated on link peer 212 * 213 * Return: void 214 */ 215 void wlan_mlo_partner_peer_disconnect_notify(struct wlan_objmgr_peer *src_peer); 216 217 /** 218 * wlan_mlo_peer_create() - MLO peer create 219 * @vdev: Link VDEV 220 * @link_peer: Link peer 221 * @ml_info: ML links info 222 * @frm_buf: Assoc req buffer 223 * @aid: AID, if already allocated 224 * 225 * This function creates MLO peer and notifies other partner VDEVs to create 226 * link peers 227 * 228 * Return: SUCCESS, if MLO peer is successfully created 229 */ 230 QDF_STATUS wlan_mlo_peer_create(struct wlan_objmgr_vdev *vdev, 231 struct wlan_objmgr_peer *link_peer, 232 struct mlo_partner_info *ml_info, 233 qdf_nbuf_t frm_buf, 234 uint16_t aid); 235 236 /** 237 * mlo_peer_cleanup() - Free MLO peer 238 * @ml_peer: MLO peer 239 * 240 * This function frees MLO peer and resets MLO peer associations 241 * Note, this API is ref count protected, it should be always invoked 242 * from wlan_mlo_peer_release_ref() 243 * 244 * Return: void 245 */ 246 void mlo_peer_cleanup(struct wlan_mlo_peer_context *ml_peer); 247 248 /** 249 * wlan_mlo_peer_get_ref() - Get ref of MLO peer 250 * @ml_peer: MLO peer 251 * 252 * This function gets ref of MLO peer 253 * 254 * Return: void 255 */ 256 static inline void wlan_mlo_peer_get_ref(struct wlan_mlo_peer_context *ml_peer) 257 { 258 qdf_atomic_inc(&ml_peer->ref_cnt); 259 } 260 261 /** 262 * wlan_mlo_peer_release_ref() - Release ref of MLO peer 263 * @ml_peer: MLO peer 264 * 265 * This function releases ref of MLO peer, if ref is 0, invokes MLO peer free 266 * 267 * Return: void 268 */ 269 static inline void wlan_mlo_peer_release_ref( 270 struct wlan_mlo_peer_context *ml_peer) 271 { 272 if (qdf_atomic_dec_and_test(&ml_peer->ref_cnt)) 273 mlo_peer_cleanup(ml_peer); 274 } 275 276 /** 277 * wlan_mlo_link_peer_attach() - MLO link peer attach 278 * @ml_peer: MLO peer 279 * @peer: Link peer 280 * @frm_buf: Assoc resp buffer of non-assoc link 281 * 282 * This function attaches link peer to MLO peer 283 * 284 * Return: SUCCESS, if peer is successfully attached to MLO peer 285 */ 286 QDF_STATUS wlan_mlo_link_peer_attach(struct wlan_mlo_peer_context *ml_peer, 287 struct wlan_objmgr_peer *peer, 288 qdf_nbuf_t frm_buf); 289 290 /** 291 * wlan_mlo_link_peer_delete() - MLO link peer delete 292 * @peer: Link peer 293 * 294 * This function detaches link peer from MLO peer, if this peer is last link 295 * peer, then MLO peer gets deleted 296 * 297 * Return: SUCCESS, if peer is detached from MLO peer 298 */ 299 QDF_STATUS wlan_mlo_link_peer_delete(struct wlan_objmgr_peer *peer); 300 301 /** 302 * mlo_peer_get_link_peer_assoc_req_buf() - API to get link assoc req buffer 303 * @peer: Object manager peer 304 * @link_ix: link id of vdev 305 * 306 * Return: assoc req buffer 307 */ 308 qdf_nbuf_t mlo_peer_get_link_peer_assoc_req_buf( 309 struct wlan_mlo_peer_context *ml_peer, 310 uint8_t link_ix); 311 312 /** 313 * mlo_peer_get_link_peer_assoc_resp_buf() - get MLO link peer assoc resp buf 314 * @ml_peer: MLO peer 315 * @link_ix: Link index of the link peer 316 * 317 * This function retrieves stored assoc resp buffer of link peer 318 * 319 * Return: resp_buf, if link_peer is available 320 * NULL, if link_peer is not present 321 */ 322 qdf_nbuf_t mlo_peer_get_link_peer_assoc_resp_buf( 323 struct wlan_mlo_peer_context *ml_peer, 324 uint8_t link_ix); 325 326 /** 327 * wlan_mlo_peer_free_all_link_assoc_resp_buf() - Free all assoc resp buffers 328 * @peer: Link peer 329 * 330 * This function frees all assoc resp link buffers 331 * 332 * Return: void 333 */ 334 void wlan_mlo_peer_free_all_link_assoc_resp_buf(struct wlan_objmgr_peer *peer); 335 336 /** 337 * wlan_mlo_peer_get_links_info() - get MLO peer partner links info 338 * @peer: Link peer 339 * @ml_links: structure to be filled with partner link info 340 * 341 * This function retrieves partner link info of link peer such as hw link id, 342 * vdev id 343 * 344 * Return: void 345 */ 346 void wlan_mlo_peer_get_links_info(struct wlan_objmgr_peer *peer, 347 struct mlo_tgt_partner_info *ml_links); 348 349 /** 350 * wlan_mlo_peer_get_primary_peer_link_id() - get vdev link ID of primary peer 351 * @peer: Link peer 352 * 353 * This function checks for the peers and returns vdev link id of the primary 354 * peer. 355 * 356 * Return: link id of primary vdev 357 */ 358 uint8_t wlan_mlo_peer_get_primary_peer_link_id(struct wlan_objmgr_peer *peer); 359 360 /** 361 * wlan_mlo_peer_get_partner_links_info() - get MLO peer partner links info 362 * @peer: Link peer 363 * @ml_links: structure to be filled with partner link info 364 * 365 * This function retrieves partner link info of link peer such as link id, 366 * mac address 367 * 368 * Return: void 369 */ 370 void wlan_mlo_peer_get_partner_links_info(struct wlan_objmgr_peer *peer, 371 struct mlo_partner_info *ml_links); 372 373 /** 374 ** APIs to operations on ML peer object 375 */ 376 typedef QDF_STATUS (*wlan_mlo_op_handler)(struct wlan_mlo_dev_context *ml_dev, 377 void *ml_peer, 378 void *arg); 379 380 /** 381 * wlan_mlo_iterate_ml_peerlist() - iterate through all ml peer objects 382 * @ml_dev: MLO DEV object 383 * @handler: the handler will be called for each ml peer 384 * the handler should be implemented to perform required operation 385 * @arg: arguments passed by caller 386 * 387 * API to be used for performing the operations on all ML PEER objects 388 * 389 * Return: SUCCESS/FAILURE 390 */ 391 QDF_STATUS wlan_mlo_iterate_ml_peerlist(struct wlan_mlo_dev_context *ml_dev, 392 wlan_mlo_op_handler handler, 393 void *arg); 394 395 /** 396 * wlan_mlo_get_mlpeer_by_linkmac() - find ML peer by Link MAC address 397 * @ml_dev: MLO DEV object 398 * @link_mac: Link peer MAC address 399 * 400 * API to get ML peer using link MAC address 401 * 402 * Return: ML peer object, if it is found 403 * otherwise, returns NULL 404 */ 405 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer_by_linkmac( 406 struct wlan_mlo_dev_context *ml_dev, 407 struct qdf_mac_addr *link_mac); 408 409 /** 410 * wlan_mlo_get_mlpeer_by_aid() - find ML peer by AID 411 * @ml_dev: MLO DEV object 412 * @aid: AID 413 * 414 * API to get ML peer using AID 415 * 416 * Return: ML peer object, if it is found 417 * otherwise, returns NULL 418 */ 419 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer_by_aid( 420 struct wlan_mlo_dev_context *ml_dev, 421 uint16_t assoc_id); 422 423 /** 424 * wlan_mlo_get_mlpeer_by_ml_peerid() - find ML peer by ML peer id 425 * @ml_dev: MLO DEV object 426 * @ml_peerid: ML Peer ID 427 * 428 * API to get ML peer using ML peer id 429 * 430 * Return: ML peer object, if it is found 431 * otherwise, returns NULL 432 */ 433 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer_by_ml_peerid( 434 struct wlan_mlo_dev_context *ml_dev, 435 uint16_t ml_peerid); 436 437 /** 438 * wlan_mlo_get_mlpeer() - find ML peer by MLD MAC address 439 * @ml_dev: MLO DEV object 440 * @ml_addr: MLO MAC address 441 * 442 * API to get ML peer using MLO MAC address 443 * 444 * Return: ML peer object, if it is found 445 * otherwise, returns NULL 446 */ 447 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer( 448 struct wlan_mlo_dev_context *ml_dev, 449 struct qdf_mac_addr *ml_addr); 450 451 /** 452 * mlo_dev_mlpeer_attach() - Add ML PEER to ML peer list 453 * @ml_dev: MLO DEV object 454 * @ml_peer: ML peer 455 * 456 * API to attach ML PEER to MLD PEER table 457 * 458 * Return: SUCCESS, if it attached successfully 459 * otherwise, returns FAILURE 460 */ 461 QDF_STATUS mlo_dev_mlpeer_attach(struct wlan_mlo_dev_context *ml_dev, 462 struct wlan_mlo_peer_context *ml_peer); 463 464 /** 465 * mlo_dev_mlpeer_detach() - Delete ML PEER from ML peer list 466 * @ml_dev: MLO DEV object 467 * @ml_peer: ML peer 468 * 469 * API to detach ML PEER from MLD PEER table 470 * 471 * Return: SUCCESS, if it detached successfully 472 * otherwise, returns FAILURE 473 */ 474 QDF_STATUS mlo_dev_mlpeer_detach(struct wlan_mlo_dev_context *ml_dev, 475 struct wlan_mlo_peer_context *ml_peer); 476 477 /** 478 * mlo_dev_mlpeer_list_init() - Initialize ML peer list 479 * @ml_dev: MLO DEV object 480 * 481 * API to initialize MLO peer list 482 * 483 * Return: SUCCESS, if initialized successfully 484 */ 485 QDF_STATUS mlo_dev_mlpeer_list_init(struct wlan_mlo_dev_context *ml_dev); 486 487 /** 488 * mlo_dev_mlpeer_list_deinit() - destroys ML peer list 489 * @ml_dev: MLO DEV object 490 * 491 * API to destroys MLO peer list 492 * 493 * Return: SUCCESS, if initialized successfully 494 */ 495 QDF_STATUS mlo_dev_mlpeer_list_deinit(struct wlan_mlo_dev_context *ml_dev); 496 497 /** 498 * wlan_peer_is_mlo() - check whether peer is MLO link peer 499 * @peer: link peer object 500 * 501 * API to check link peer is part of MLO peer or not 502 * 503 * Return: true if it MLO peer 504 * false, if it is not MLO peer 505 */ 506 static inline uint8_t wlan_peer_is_mlo(struct wlan_objmgr_peer *peer) 507 { 508 return wlan_peer_mlme_flag_ext_get(peer, WLAN_PEER_FEXT_MLO); 509 } 510 511 /** 512 * wlan_peer_set_mlo() - Set peer as MLO link peer 513 * @peer: link peer object 514 * 515 * API to set MLO peer flag in link peer is part of MLO peer 516 * 517 * Return: void 518 */ 519 static inline void wlan_peer_set_mlo(struct wlan_objmgr_peer *peer) 520 { 521 return wlan_peer_mlme_flag_ext_set(peer, WLAN_PEER_FEXT_MLO); 522 } 523 524 /** 525 * wlan_peer_clear_mlo() - clear peer as MLO link peer 526 * @peer: link peer object 527 * 528 * API to clear MLO peer flag in link peer 529 * 530 * Return: void 531 */ 532 static inline void wlan_peer_clear_mlo(struct wlan_objmgr_peer *peer) 533 { 534 return wlan_peer_mlme_flag_ext_clear(peer, WLAN_PEER_FEXT_MLO); 535 } 536 537 #ifdef UMAC_SUPPORT_MLNAWDS 538 /** 539 * wlan_mlo_peer_is_nawds() - Check if ml_peer is configured to operate as NAWDS 540 * @ml_peer: MLO peer 541 * 542 * Return TRUE if ml peer is configured as NAWDS 543 */ 544 bool wlan_mlo_peer_is_nawds(struct wlan_mlo_peer_context *ml_peer); 545 #else 546 static inline 547 bool wlan_mlo_peer_is_nawds(struct wlan_mlo_peer_context *ml_peer) 548 { 549 return false; 550 } 551 #endif 552 #ifdef UMAC_MLO_AUTH_DEFER 553 /** 554 * mlo_peer_link_auth_defer() - Auth request defer for MLO peer 555 * @ml_peer: ML peer 556 * @link_mac: Link peer MAC address 557 * @auth_params: Defer Auth param 558 * 559 * This function saves Auth request params in MLO peer 560 * 561 * Return: SUCCESS if MAC address matches one of the link peers 562 * FAILURE, if MAC address doesn't match 563 */ 564 QDF_STATUS mlo_peer_link_auth_defer(struct wlan_mlo_peer_context *ml_peer, 565 struct qdf_mac_addr *link_mac, 566 struct mlpeer_auth_params *auth_params); 567 568 /** 569 * mlo_peer_free_auth_param() - Free deferred Auth request params 570 * @auth_params: Defer Auth param 571 * 572 * This function frees Auth request params 573 * 574 * Return: void 575 */ 576 void mlo_peer_free_auth_param(struct mlpeer_auth_params *auth_params); 577 #else 578 static inline void 579 mlo_peer_free_auth_param(struct mlpeer_auth_params *auth_params) 580 { 581 } 582 #endif 583 #endif 584