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