1 /* 2 * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * @file cdp_txrx_ctrl.h 21 * @brief Define the host data path control API functions 22 * called by the host control SW and the OS interface module 23 */ 24 25 #ifndef _CDP_TXRX_CTRL_H_ 26 #define _CDP_TXRX_CTRL_H_ 27 #include "cdp_txrx_handle.h" 28 #include "cdp_txrx_cmn_struct.h" 29 #include "cdp_txrx_cmn.h" 30 #include "cdp_txrx_ops.h" 31 32 static inline int cdp_is_target_ar900b 33 (ol_txrx_soc_handle soc) 34 { 35 if (!soc || !soc->ops) { 36 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 37 "%s: Invalid Instance:", __func__); 38 QDF_BUG(0); 39 return 0; 40 } 41 42 if (!soc->ops->ctrl_ops || 43 !soc->ops->ctrl_ops->txrx_is_target_ar900b) 44 return 0; 45 46 return soc->ops->ctrl_ops->txrx_is_target_ar900b(soc); 47 } 48 49 50 /* WIN */ 51 static inline int 52 cdp_mempools_attach(ol_txrx_soc_handle soc) 53 { 54 if (!soc || !soc->ops) { 55 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 56 "%s: Invalid Instance:", __func__); 57 QDF_BUG(0); 58 return 0; 59 } 60 61 if (!soc->ops->ctrl_ops || 62 !soc->ops->ctrl_ops->txrx_mempools_attach) 63 return 0; 64 65 return soc->ops->ctrl_ops->txrx_mempools_attach(soc); 66 } 67 68 69 #if defined(ATH_SUPPORT_NAC) || defined(ATH_SUPPORT_NAC_RSSI) 70 /** 71 * @brief update the neighbour peer addresses 72 * @details 73 * This defines interface function to update neighbour peers addresses 74 * which needs to be filtered 75 * 76 * @param soc - the pointer to soc object 77 * @param vdev_id - id of the pointer to vdev 78 * @param cmd - add/del entry into peer table 79 * @param macaddr - the address of neighbour peer 80 * @return - int 81 */ 82 static inline int 83 cdp_update_filter_neighbour_peers(ol_txrx_soc_handle soc, 84 uint8_t vdev_id, uint32_t cmd, uint8_t *macaddr) 85 { 86 if (!soc || !soc->ops) { 87 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 88 "%s: Invalid Instance:", __func__); 89 QDF_BUG(0); 90 return 0; 91 } 92 93 if (!soc->ops->ctrl_ops || 94 !soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers) 95 return 0; 96 97 return soc->ops->ctrl_ops->txrx_update_filter_neighbour_peers 98 (soc, vdev_id, cmd, macaddr); 99 } 100 #endif /* ATH_SUPPORT_NAC || ATH_SUPPORT_NAC_RSSI*/ 101 102 /** 103 * @brief set the Reo Destination ring for the pdev 104 * @details 105 * This will be used to configure the Reo Destination ring for this pdev. 106 * 107 * @param soc - pointer to the soc 108 * @param pdev_id - id of the data physical device object 109 * @param val - the Reo destination ring index (1 to 4) 110 * @return - QDF_STATUS 111 */ 112 static inline QDF_STATUS 113 cdp_set_pdev_reo_dest(ol_txrx_soc_handle soc, 114 uint8_t pdev_id, enum cdp_host_reo_dest_ring val) 115 { 116 if (!soc || !soc->ops) { 117 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 118 "%s: Invalid Instance:", __func__); 119 QDF_BUG(0); 120 return QDF_STATUS_E_FAILURE; 121 } 122 123 if (!soc->ops->ctrl_ops || 124 !soc->ops->ctrl_ops->txrx_set_pdev_reo_dest) 125 return QDF_STATUS_E_FAILURE; 126 127 return soc->ops->ctrl_ops->txrx_set_pdev_reo_dest 128 (soc, pdev_id, val); 129 } 130 131 /** 132 * @brief get the Reo Destination ring for the pdev 133 * 134 * @param soc - pointer to the soc 135 * @param pdev_id - id of physical device object 136 * @return - the Reo destination ring index (1 to 4), 0 if not supported. 137 */ 138 static inline enum cdp_host_reo_dest_ring 139 cdp_get_pdev_reo_dest(ol_txrx_soc_handle soc, uint8_t pdev_id) 140 { 141 if (!soc || !soc->ops) { 142 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 143 "%s: Invalid Instance:", __func__); 144 QDF_BUG(0); 145 return cdp_host_reo_dest_ring_unknown; 146 } 147 148 if (!soc->ops->ctrl_ops || 149 !soc->ops->ctrl_ops->txrx_get_pdev_reo_dest) 150 return cdp_host_reo_dest_ring_unknown; 151 152 return soc->ops->ctrl_ops->txrx_get_pdev_reo_dest(soc, pdev_id); 153 } 154 155 /* Is this similar to ol_txrx_peer_state_update() in MCL */ 156 /** 157 * @brief Update the authorize peer object at association time 158 * @details 159 * For the host-based implementation of rate-control, it 160 * updates the peer/node-related parameters within rate-control 161 * context of the peer at association. 162 * 163 * @param soc - pointer to the soc 164 * @param vdev_id - id of the pointer to vdev 165 * @param peer_mac - mac address of the node's object 166 * @authorize - either to authorize or unauthorize peer 167 * 168 * @return QDF_STATUS 169 */ 170 static inline QDF_STATUS 171 cdp_peer_authorize(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac, 172 u_int32_t authorize) 173 { 174 if (!soc || !soc->ops) { 175 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 176 "%s: Invalid Instance:", __func__); 177 QDF_BUG(0); 178 return QDF_STATUS_E_FAILURE; 179 } 180 181 if (!soc->ops->ctrl_ops || 182 !soc->ops->ctrl_ops->txrx_peer_authorize) 183 return QDF_STATUS_E_FAILURE; 184 185 return soc->ops->ctrl_ops->txrx_peer_authorize 186 (soc, vdev_id, peer_mac, authorize); 187 } 188 189 static inline void cdp_tx_flush_buffers 190 (ol_txrx_soc_handle soc, uint8_t vdev_id) 191 { 192 if (!soc || !soc->ops) { 193 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 194 "%s: Invalid Instance:", __func__); 195 QDF_BUG(0); 196 return; 197 } 198 199 if (!soc->ops->ctrl_ops || 200 !soc->ops->ctrl_ops->tx_flush_buffers) 201 return; 202 203 soc->ops->ctrl_ops->tx_flush_buffers(soc, vdev_id); 204 } 205 206 static inline QDF_STATUS cdp_txrx_get_vdev_param(ol_txrx_soc_handle soc, 207 uint8_t vdev_id, 208 enum cdp_vdev_param_type type, 209 cdp_config_param_type *val) 210 { 211 if (!soc || !soc->ops) { 212 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 213 "%s: Invalid Instance:", __func__); 214 QDF_BUG(0); 215 return QDF_STATUS_E_FAILURE; 216 } 217 218 if (!soc->ops->ctrl_ops || 219 !soc->ops->ctrl_ops->txrx_get_vdev_param) { 220 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 221 "%s: callback not registered:", __func__); 222 return QDF_STATUS_E_FAILURE; 223 } 224 225 return soc->ops->ctrl_ops->txrx_get_vdev_param(soc, vdev_id, 226 type, val); 227 } 228 229 static inline QDF_STATUS 230 cdp_txrx_set_vdev_param(ol_txrx_soc_handle soc, 231 uint8_t vdev_id, enum cdp_vdev_param_type type, 232 cdp_config_param_type val) 233 { 234 if (!soc || !soc->ops) { 235 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 236 "%s: Invalid Instance:", __func__); 237 QDF_BUG(0); 238 return QDF_STATUS_E_FAILURE; 239 } 240 241 if (!soc->ops->ctrl_ops || 242 !soc->ops->ctrl_ops->txrx_set_vdev_param) 243 return QDF_STATUS_E_FAILURE; 244 245 return soc->ops->ctrl_ops->txrx_set_vdev_param(soc, vdev_id, 246 type, val); 247 } 248 249 static inline QDF_STATUS 250 cdp_txrx_set_psoc_param(ol_txrx_soc_handle soc, 251 enum cdp_psoc_param_type type, 252 cdp_config_param_type val) 253 { 254 if (!soc || !soc->ops) { 255 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 256 "%s: Invalid Instance:", __func__); 257 QDF_BUG(0); 258 return QDF_STATUS_E_FAILURE; 259 } 260 261 if (!soc->ops->ctrl_ops || 262 !soc->ops->ctrl_ops->txrx_set_psoc_param) 263 return QDF_STATUS_E_FAILURE; 264 265 return soc->ops->ctrl_ops->txrx_set_psoc_param(soc, type, val); 266 } 267 268 static inline QDF_STATUS 269 cdp_txrx_get_psoc_param(ol_txrx_soc_handle soc, 270 enum cdp_psoc_param_type type, 271 cdp_config_param_type *val) 272 { 273 if (!soc || !soc->ops) { 274 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 275 "%s: Invalid Instance:", __func__); 276 QDF_BUG(0); 277 return QDF_STATUS_E_FAILURE; 278 } 279 280 if (!soc->ops->ctrl_ops || 281 !soc->ops->ctrl_ops->txrx_get_psoc_param) 282 return QDF_STATUS_E_FAILURE; 283 284 return soc->ops->ctrl_ops->txrx_get_psoc_param(soc, type, val); 285 } 286 287 #ifdef VDEV_PEER_PROTOCOL_COUNT 288 /** 289 * cdp_set_vdev_peer_protocol_count() - set per-peer protocol count tracking 290 * 291 * @soc - pointer to the soc 292 * @vdev - the data virtual device object 293 * @enable - enable per-peer protocol count 294 * 295 * Set per-peer protocol count feature enable 296 * 297 * Return: void 298 */ 299 static inline 300 void cdp_set_vdev_peer_protocol_count(ol_txrx_soc_handle soc, int8_t vdev_id, 301 bool enable) 302 { 303 if (!soc || !soc->ops) { 304 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 305 "%s: Invalid Instance:", __func__); 306 QDF_BUG(0); 307 return; 308 } 309 310 if (!soc->ops->ctrl_ops || 311 !soc->ops->ctrl_ops->txrx_enable_peer_protocol_count) 312 return; 313 314 soc->ops->ctrl_ops->txrx_enable_peer_protocol_count(soc, vdev_id, 315 enable); 316 } 317 318 /** 319 * cdp_set_vdev_peer_protocol_drop_mask() - set per-peer protocol drop mask 320 * 321 * @soc - pointer to the soc 322 * @vdev - the data virtual device object 323 * @drop_mask - drop_mask 324 * 325 * Set per-peer protocol drop_mask 326 * 327 * Return - void 328 */ 329 static inline 330 void cdp_set_vdev_peer_protocol_drop_mask(ol_txrx_soc_handle soc, 331 int8_t vdev_id, int drop_mask) 332 { 333 if (!soc || !soc->ops) { 334 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 335 "%s: Invalid Instance:", __func__); 336 QDF_BUG(0); 337 return; 338 } 339 340 if (!soc->ops->ctrl_ops || 341 !soc->ops->ctrl_ops->txrx_set_peer_protocol_drop_mask) 342 return; 343 344 soc->ops->ctrl_ops->txrx_set_peer_protocol_drop_mask(soc, vdev_id, 345 drop_mask); 346 } 347 348 /** 349 * cdp_is_vdev_peer_protocol_count_enabled() - whether peer-protocol tracking 350 * enabled 351 * 352 * @soc - pointer to the soc 353 * @vdev - the data virtual device object 354 * 355 * Get whether peer protocol count feature enabled or not 356 * 357 * Return: whether feature enabled or not 358 */ 359 static inline 360 int cdp_is_vdev_peer_protocol_count_enabled(ol_txrx_soc_handle soc, 361 int8_t vdev_id) 362 { 363 if (!soc || !soc->ops) { 364 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 365 "%s: Invalid Instance:", __func__); 366 QDF_BUG(0); 367 return 0; 368 } 369 370 if (!soc->ops->ctrl_ops || 371 !soc->ops->ctrl_ops->txrx_is_peer_protocol_count_enabled) 372 return 0; 373 374 return soc->ops->ctrl_ops->txrx_is_peer_protocol_count_enabled(soc, 375 vdev_id); 376 } 377 378 /** 379 * cdp_get_peer_protocol_drop_mask() - get per-peer protocol count drop-mask 380 * 381 * @soc - pointer to the soc 382 * @vdev - the data virtual device object 383 * 384 * Get peer-protocol-count drop-mask 385 * 386 * Return: peer-protocol-count drop-mask 387 */ 388 static inline 389 int cdp_get_peer_protocol_drop_mask(ol_txrx_soc_handle soc, int8_t vdev_id) 390 { 391 if (!soc || !soc->ops) { 392 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 393 "%s: Invalid Instance:", __func__); 394 QDF_BUG(0); 395 return 0; 396 } 397 398 if (!soc->ops->ctrl_ops || 399 !soc->ops->ctrl_ops->txrx_get_peer_protocol_drop_mask) 400 return 0; 401 402 return soc->ops->ctrl_ops->txrx_get_peer_protocol_drop_mask(soc, 403 vdev_id); 404 } 405 406 /* 407 * Rx-Ingress and Tx-Egress are in the lower level DP layer 408 * Rx-Egress and Tx-ingress are handled in osif layer for DP 409 * So 410 * Rx-Ingress and Tx-Egress definitions are in DP layer 411 * Rx-Egress and Tx-ingress mask definitions are here below 412 */ 413 #define VDEV_PEER_PROTOCOL_RX_INGRESS_MASK 1 414 #define VDEV_PEER_PROTOCOL_TX_INGRESS_MASK 2 415 #define VDEV_PEER_PROTOCOL_RX_EGRESS_MASK 4 416 #define VDEV_PEER_PROTOCOL_TX_EGRESS_MASK 8 417 418 #else 419 #define cdp_set_vdev_peer_protocol_count(soc, vdev_id, enable) 420 #define cdp_set_vdev_peer_protocol_drop_mask(soc, vdev_id, drop_mask) 421 #define cdp_is_vdev_peer_protocol_count_enabled(soc, vdev_id) 0 422 #define cdp_get_peer_protocol_drop_mask(soc, vdev_id) 0 423 #endif 424 425 /** 426 * cdp_txrx_set_pdev_param() - set pdev parameter 427 * @soc: opaque soc handle 428 * @pdev_id: id of data path pdev handle 429 * @type: param type 430 * @val: value 431 * 432 * Return: status: 0 - Success, non-zero: Failure 433 */ 434 static inline QDF_STATUS cdp_txrx_set_pdev_param(ol_txrx_soc_handle soc, 435 uint8_t pdev_id, 436 enum cdp_pdev_param_type type, 437 cdp_config_param_type val) 438 { 439 if (!soc || !soc->ops) { 440 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 441 "%s: Invalid Instance:", __func__); 442 QDF_BUG(0); 443 return QDF_STATUS_E_FAILURE; 444 } 445 446 if (!soc->ops->ctrl_ops || 447 !soc->ops->ctrl_ops->txrx_set_pdev_param) 448 return QDF_STATUS_E_FAILURE; 449 450 return soc->ops->ctrl_ops->txrx_set_pdev_param 451 (soc, pdev_id, type, val); 452 } 453 454 /** 455 * cdp_txrx_set_peer_param() - set pdev parameter 456 * @soc: opaque soc handle 457 * @vdev_id: id of data path vdev handle 458 * @peer_mac: peer mac address 459 * @type: param type 460 * @val: value 461 * 462 * Return: status: 0 - Success, non-zero: Failure 463 */ 464 static inline QDF_STATUS cdp_txrx_set_peer_param(ol_txrx_soc_handle soc, 465 uint8_t vdev_id, 466 uint8_t *peer_mac, 467 enum cdp_peer_param_type type, 468 cdp_config_param_type val) 469 { 470 if (!soc || !soc->ops) { 471 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 472 "%s: Invalid Instance:", __func__); 473 QDF_BUG(0); 474 return QDF_STATUS_E_FAILURE; 475 } 476 477 if (!soc->ops->ctrl_ops || 478 !soc->ops->ctrl_ops->txrx_set_peer_param) 479 return QDF_STATUS_E_FAILURE; 480 481 return soc->ops->ctrl_ops->txrx_set_peer_param 482 (soc, vdev_id, peer_mac, type, val); 483 } 484 485 /** 486 * cdp_txrx_get_peer_param() - set pdev parameter 487 * @soc: opaque soc handle 488 * @vdev_id: id of data path vdev handle 489 * @peer_mac: peer mac address 490 * @type: param type 491 * @val: address of buffer 492 * 493 * Return: status 494 */ 495 static inline QDF_STATUS cdp_txrx_get_peer_param(ol_txrx_soc_handle soc, 496 uint8_t vdev_id, 497 uint8_t *peer_mac, 498 enum cdp_peer_param_type type, 499 cdp_config_param_type *val) 500 { 501 if (!soc || !soc->ops) { 502 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 503 "%s: Invalid Instance:", __func__); 504 QDF_BUG(0); 505 return QDF_STATUS_E_FAILURE; 506 } 507 508 if (!soc->ops->ctrl_ops || 509 !soc->ops->ctrl_ops->txrx_get_peer_param) 510 return QDF_STATUS_E_FAILURE; 511 512 return soc->ops->ctrl_ops->txrx_get_peer_param 513 (soc, vdev_id, peer_mac, type, val); 514 } 515 516 #ifdef QCA_MULTIPASS_SUPPORT 517 static inline void 518 cdp_peer_set_vlan_id(ol_txrx_soc_handle soc, uint8_t vdev_id, 519 uint8_t *peer_mac, uint8_t vlan_id) 520 { 521 if (!soc || !soc->ops) { 522 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 523 "%s: Invalid Instance:", __func__); 524 QDF_BUG(0); 525 return; 526 } 527 528 if (!soc->ops->ctrl_ops || 529 !soc->ops->ctrl_ops->txrx_peer_set_vlan_id) 530 return; 531 532 soc->ops->ctrl_ops->txrx_peer_set_vlan_id(soc, vdev_id, peer_mac, 533 vlan_id); 534 } 535 #endif 536 537 /** 538 * cdp_txrx_get_pdev_param() - get pdev parameter 539 * @soc: opaque soc handle 540 * @pdev_id: id of data path pdev handle 541 * @type: param type 542 * @value: address of value buffer 543 * 544 * Return: status 545 */ 546 static inline QDF_STATUS cdp_txrx_get_pdev_param(ol_txrx_soc_handle soc, 547 uint8_t pdev_id, 548 enum cdp_pdev_param_type type, 549 cdp_config_param_type *value) 550 { 551 if (!soc || !soc->ops) { 552 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 553 "%s: Invalid Instance:", __func__); 554 QDF_BUG(0); 555 return QDF_STATUS_E_FAILURE; 556 } 557 558 if (!soc->ops->ctrl_ops || 559 !soc->ops->ctrl_ops->txrx_get_pdev_param) 560 return QDF_STATUS_E_FAILURE; 561 562 return soc->ops->ctrl_ops->txrx_get_pdev_param 563 (soc, pdev_id, type, value); 564 } 565 566 /** 567 * cdp_txrx_peer_protocol_cnt() - set peer protocol count 568 * @soc: opaque soc handle 569 * @vdev: opaque vdev handle 570 * @nbuf: data packet 571 * @is_egress: whether egress or ingress 572 * @is_rx: whether tx or rx 573 * 574 * Return: void 575 */ 576 #ifdef VDEV_PEER_PROTOCOL_COUNT 577 static inline void 578 cdp_txrx_peer_protocol_cnt(ol_txrx_soc_handle soc, 579 int8_t vdev_id, 580 qdf_nbuf_t nbuf, 581 enum vdev_peer_protocol_enter_exit is_egress, 582 enum vdev_peer_protocol_tx_rx is_rx) 583 { 584 if (!soc || !soc->ops) { 585 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 586 "%s: Invalid Instance:", __func__); 587 QDF_BUG(0); 588 return; 589 } 590 591 if (!soc->ops->ctrl_ops || 592 !soc->ops->ctrl_ops->txrx_peer_protocol_cnt) 593 return; 594 595 soc->ops->ctrl_ops->txrx_peer_protocol_cnt(soc, vdev_id, nbuf, 596 is_egress, is_rx); 597 } 598 #else 599 #define cdp_txrx_peer_protocol_cnt(soc, vdev_id, nbuf, is_egress, is_rx) 600 #endif 601 602 /** 603 * cdp_enable_peer_based_pktlog()- Set flag in peer structure 604 * 605 * @soc: pointer to the soc 606 * @pdev_id: id of the data physical device object 607 * @enable: enable or disable peer based filter based pktlog 608 * @peer_macaddr: Mac address of peer which needs to be 609 * filtered 610 * 611 * This function will set flag in peer structure if peer based filtering 612 * is enabled for pktlog 613 * 614 * Return: int 615 */ 616 static inline int 617 cdp_enable_peer_based_pktlog(ol_txrx_soc_handle soc, uint8_t pdev_id, 618 char *peer_macaddr, 619 uint8_t enable) 620 { 621 if (!soc || !soc->ops) { 622 QDF_TRACE_ERROR(QDF_MODULE_ID_DP, 623 "%s invalid instance", __func__); 624 QDF_BUG(0); 625 return 0; 626 } 627 628 if (!soc->ops->ctrl_ops || 629 !soc->ops->ctrl_ops->enable_peer_based_pktlog) 630 return 0; 631 632 return soc->ops->ctrl_ops->enable_peer_based_pktlog 633 (soc, pdev_id, peer_macaddr, enable); 634 } 635 636 /** 637 * cdp_calculate_delay_stats()- get rx delay stats 638 * 639 * @soc: pointer to the soc 640 * @vdev_id: id of vdev handle 641 * @nbuf: nbuf which is passed 642 * 643 * This function will calculate rx delay statistics. 644 */ 645 static inline QDF_STATUS 646 cdp_calculate_delay_stats(ol_txrx_soc_handle soc, uint8_t vdev_id, 647 qdf_nbuf_t nbuf) 648 { 649 if (!soc || !soc->ops) { 650 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 651 "%s: Invalid Instance:", __func__); 652 QDF_BUG(0); 653 return QDF_STATUS_E_FAILURE; 654 } 655 656 if (!soc->ops->ctrl_ops || 657 !soc->ops->ctrl_ops->calculate_delay_stats) { 658 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 659 "%s: callback not registered:", __func__); 660 return QDF_STATUS_E_FAILURE; 661 } 662 663 return soc->ops->ctrl_ops->calculate_delay_stats(soc, vdev_id, nbuf); 664 } 665 666 /** 667 * @brief Subscribe to a specified WDI event. 668 * @details 669 * This function adds the provided wdi_event_subscribe object to a list of 670 * subscribers for the specified WDI event. 671 * When the event in question happens, each subscriber for the event will 672 * have their callback function invoked. 673 * The order in which callback functions from multiple subscribers are 674 * invoked is unspecified. 675 * 676 * @param soc - pointer to the soc 677 * @param pdev_id - id of the data physical device object 678 * @param event_cb_sub - the callback and context for the event subscriber 679 * @param event - which event's notifications are being subscribed to 680 * @return - int 681 */ 682 static inline int 683 cdp_wdi_event_sub(ol_txrx_soc_handle soc, uint8_t pdev_id, 684 wdi_event_subscribe *event_cb_sub, uint32_t event) 685 { 686 687 if (!soc || !soc->ops) { 688 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 689 "%s invalid instance", __func__); 690 QDF_BUG(0); 691 return 0; 692 } 693 694 if (!soc->ops->ctrl_ops || 695 !soc->ops->ctrl_ops->txrx_wdi_event_sub) 696 return 0; 697 698 return soc->ops->ctrl_ops->txrx_wdi_event_sub 699 (soc, pdev_id, event_cb_sub, event); 700 } 701 702 /** 703 * @brief Unsubscribe from a specified WDI event. 704 * @details 705 * This function removes the provided event subscription object from the 706 * list of subscribers for its event. 707 * This function shall only be called if there was a successful prior call 708 * to event_sub() on the same wdi_event_subscribe object. 709 * 710 * @param soc - pointer to the soc 711 * @param pdev_id - id of the data physical device object 712 * @param event_cb_sub - the callback and context for the event subscriber 713 * @param event - which event's notifications are being subscribed to 714 * @return - int 715 */ 716 static inline int 717 cdp_wdi_event_unsub(ol_txrx_soc_handle soc, 718 uint8_t pdev_id, wdi_event_subscribe *event_cb_sub, 719 uint32_t event) 720 { 721 722 if (!soc || !soc->ops) { 723 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 724 "%s invalid instance", __func__); 725 QDF_BUG(0); 726 return 0; 727 } 728 729 if (!soc->ops->ctrl_ops || 730 !soc->ops->ctrl_ops->txrx_wdi_event_unsub) 731 return 0; 732 733 return soc->ops->ctrl_ops->txrx_wdi_event_unsub 734 (soc, pdev_id, event_cb_sub, event); 735 } 736 737 /** 738 * @brief Get security type from the from peer. 739 * @details 740 * This function gets the Security information from the peer handler. 741 * The security information is got from the rx descriptor and filled in 742 * to the peer handler. 743 * 744 * @param soc - pointer to the soc 745 * @param vdev_id - id of vdev handle 746 * @param peer mac - peer mac address 747 * @param sec_idx - mcast or ucast frame type. 748 * @return - int 749 */ 750 static inline int 751 cdp_get_sec_type(ol_txrx_soc_handle soc, uint8_t vdev_id, uint8_t *peer_mac, 752 uint8_t sec_idx) 753 { 754 if (!soc || !soc->ops) { 755 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 756 "%s invalid instance", __func__); 757 QDF_BUG(0); 758 return A_ERROR; 759 } 760 761 if (!soc->ops->ctrl_ops || 762 !soc->ops->ctrl_ops->txrx_get_sec_type) 763 return A_ERROR; 764 765 return soc->ops->ctrl_ops->txrx_get_sec_type 766 (soc, vdev_id, peer_mac, sec_idx); 767 } 768 769 /** 770 * cdp_set_mgmt_tx_power(): function to set tx power for mgmt frames 771 * @param soc - pointer to the soc 772 * @vdev_id : id of vdev handle 773 * @subtype_index: subtype 774 * @tx_power: Tx power 775 * Return: QDF_STATUS 776 */ 777 static inline QDF_STATUS 778 cdp_set_mgmt_tx_power(ol_txrx_soc_handle soc, 779 uint8_t vdev_id, uint8_t subtype, uint8_t tx_power) 780 { 781 if (!soc || !soc->ops) { 782 QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG, 783 "%s: Invalid Instance:", __func__); 784 QDF_BUG(0); 785 return QDF_STATUS_E_FAILURE; 786 } 787 788 if (!soc->ops->ctrl_ops || 789 !soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev) 790 return QDF_STATUS_E_FAILURE; 791 792 return soc->ops->ctrl_ops->txrx_update_mgmt_txpow_vdev(soc, vdev_id, 793 subtype, tx_power); 794 } 795 796 /** 797 * cdp_get_pldev() - function to get pktlog device handle 798 * @soc: datapath soc handle 799 * @pdev_id: physical device id 800 * 801 * Return: pktlog device handle or NULL 802 */ 803 static inline void * 804 cdp_get_pldev(ol_txrx_soc_handle soc, uint8_t pdev_id) 805 { 806 if (!soc || !soc->ops) { 807 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 808 "%s invalid instance", __func__); 809 QDF_BUG(0); 810 return NULL; 811 } 812 813 if (!soc->ops->ctrl_ops || !soc->ops->ctrl_ops->txrx_get_pldev) 814 return NULL; 815 816 return soc->ops->ctrl_ops->txrx_get_pldev(soc, pdev_id); 817 } 818 819 #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE) 820 /** 821 * cdp_cfr_filter() - Configure Host RX monitor status ring for CFR 822 * @soc: SOC TXRX handle 823 * @pdev_id: ID of the physical device object 824 * @enable: Enable or disable CFR 825 * @filter_val: Flag to select filter for monitor mode 826 */ 827 static inline void 828 cdp_cfr_filter(ol_txrx_soc_handle soc, 829 uint8_t pdev_id, 830 bool enable, 831 struct cdp_monitor_filter *filter_val) 832 { 833 if (!soc || !soc->ops) { 834 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 835 "%s invalid instance", __func__); 836 QDF_BUG(0); 837 return; 838 } 839 840 if (!soc->ops->cfr_ops || !soc->ops->cfr_ops->txrx_cfr_filter) 841 return; 842 843 soc->ops->cfr_ops->txrx_cfr_filter(soc, pdev_id, enable, filter_val); 844 } 845 846 /** 847 * cdp_get_cfr_rcc() - get cfr rcc config 848 * @soc: Datapath soc handle 849 * @pdev_id: id of objmgr pdev 850 * 851 * Return: true/false based on cfr mode setting 852 */ 853 static inline 854 bool cdp_get_cfr_rcc(ol_txrx_soc_handle soc, uint8_t pdev_id) 855 { 856 if (!soc || !soc->ops) { 857 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 858 "%s invalid instance", __func__); 859 QDF_BUG(0); 860 return 0; 861 } 862 863 if (!soc->ops->cfr_ops || !soc->ops->cfr_ops->txrx_get_cfr_rcc) 864 return 0; 865 866 return soc->ops->cfr_ops->txrx_get_cfr_rcc(soc, pdev_id); 867 } 868 869 /** 870 * cdp_set_cfr_rcc() - enable/disable cfr rcc config 871 * @soc: Datapath soc handle 872 * @pdev_id: id of objmgr pdev 873 * @enable: Enable/Disable cfr rcc mode 874 * 875 * Return: none 876 */ 877 static inline 878 void cdp_set_cfr_rcc(ol_txrx_soc_handle soc, uint8_t pdev_id, bool enable) 879 { 880 if (!soc || !soc->ops) { 881 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 882 "%s invalid instance", __func__); 883 QDF_BUG(0); 884 return; 885 } 886 887 if (!soc->ops->cfr_ops || !soc->ops->cfr_ops->txrx_set_cfr_rcc) 888 return; 889 890 return soc->ops->cfr_ops->txrx_set_cfr_rcc(soc, pdev_id, enable); 891 } 892 #endif 893 894 #if defined(WLAN_TX_PKT_CAPTURE_ENH) || defined(WLAN_RX_PKT_CAPTURE_ENH) 895 /** 896 * cdp_update_peer_pkt_capture_params() - Sets Rx & Tx Capture params for a peer 897 * @soc: SOC TXRX handle 898 * @pdev_id: id of CDP pdev pointer 899 * @is_rx_pkt_cap_enable: enable/disable rx pkt capture for this peer 900 * @is_tx_pkt_cap_enable: enable/disable tx pkt capture for this peer 901 * @peer_mac: MAC address of peer for which pkt_cap is to be enabled/disabled 902 * 903 * Return: Success when matching peer is found & flags are set, error otherwise 904 */ 905 static inline QDF_STATUS 906 cdp_update_peer_pkt_capture_params(ol_txrx_soc_handle soc, 907 uint8_t pdev_id, 908 bool is_rx_pkt_cap_enable, 909 bool is_tx_pkt_cap_enable, 910 uint8_t *peer_mac) 911 { 912 if (!soc || !soc->ops) { 913 dp_err("Invalid SOC instance"); 914 QDF_BUG(0); 915 return QDF_STATUS_E_FAILURE; 916 } 917 918 if (!soc->ops->ctrl_ops || 919 !soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params) 920 return QDF_STATUS_E_FAILURE; 921 922 return soc->ops->ctrl_ops->txrx_update_peer_pkt_capture_params 923 (soc, pdev_id, is_rx_pkt_cap_enable, 924 is_tx_pkt_cap_enable, 925 peer_mac); 926 } 927 #endif /* WLAN_TX_PKT_CAPTURE_ENH || WLAN_RX_PKT_CAPTURE_ENH */ 928 929 #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG 930 /** 931 * cdp_update_pdev_rx_protocol_tag() - wrapper function to set the protocol 932 * tag in CDP layer from cfg layer 933 * @soc: SOC TXRX handle 934 * @pdev_id: id of CDP pdev pointer 935 * @protocol_mask: Bitmap for protocol for which tagging is enabled 936 * @protocol_type: Protocol type for which the tag should be update 937 * @tag: Actual tag value for the given prototype 938 * Return: Returns QDF_STATUS_SUCCESS/FAILURE 939 */ 940 static inline QDF_STATUS 941 cdp_update_pdev_rx_protocol_tag(ol_txrx_soc_handle soc, 942 uint8_t pdev_id, uint32_t protocol_mask, 943 uint16_t protocol_type, uint16_t tag) 944 { 945 if (!soc || !soc->ops) { 946 dp_err("Invalid SOC instance"); 947 QDF_BUG(0); 948 return QDF_STATUS_E_FAILURE; 949 } 950 951 if (!soc->ops->ctrl_ops || 952 !soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag) 953 return QDF_STATUS_E_FAILURE; 954 955 return soc->ops->ctrl_ops->txrx_update_pdev_rx_protocol_tag 956 (soc, pdev_id, protocol_mask, protocol_type, tag); 957 } 958 959 #ifdef WLAN_SUPPORT_RX_TAG_STATISTICS 960 /** 961 * cdp_dump_pdev_rx_protocol_tag_stats() - wrapper function to dump the protocol 962 tag statistics for given or all protocols 963 * @soc: SOC TXRX handle 964 * @pdev_id: id of CDP pdev pointer 965 * @protocol_type: Protocol type for which the tag should be update 966 * Return: Returns QDF_STATUS_SUCCESS/FAILURE 967 */ 968 static inline QDF_STATUS 969 cdp_dump_pdev_rx_protocol_tag_stats(ol_txrx_soc_handle soc, 970 uint8_t pdev_id, 971 uint16_t protocol_type) 972 { 973 if (!soc || !soc->ops) { 974 dp_err("Invalid SOC instance"); 975 QDF_BUG(0); 976 return QDF_STATUS_E_FAILURE; 977 } 978 979 if (!soc->ops->ctrl_ops || 980 !soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats) 981 return QDF_STATUS_E_FAILURE; 982 983 soc->ops->ctrl_ops->txrx_dump_pdev_rx_protocol_tag_stats(soc, pdev_id, 984 protocol_type); 985 return QDF_STATUS_SUCCESS; 986 } 987 #endif /* WLAN_SUPPORT_RX_TAG_STATISTICS */ 988 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */ 989 990 #ifdef ATH_SUPPORT_NAC_RSSI 991 /** 992 * cdp_vdev_config_for_nac_rssi(): To invoke dp callback for nac rssi config 993 * @soc: soc pointer 994 * @vdev_id: id of vdev 995 * @nac_cmd: specfies nac_rss config action add, del, list 996 * @bssid: Neighbour bssid 997 * @client_macaddr: Non-Associated client MAC 998 * @chan_num: channel number to scan 999 * 1000 * Return: QDF_STATUS 1001 */ 1002 static inline QDF_STATUS cdp_vdev_config_for_nac_rssi(ol_txrx_soc_handle soc, 1003 uint8_t vdev_id, enum cdp_nac_param_cmd nac_cmd, 1004 char *bssid, char *client_macaddr, uint8_t chan_num) 1005 { 1006 if (!soc || !soc->ops) { 1007 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 1008 "%s invalid instance", __func__); 1009 QDF_BUG(0); 1010 return QDF_STATUS_E_FAILURE; 1011 } 1012 1013 if (!soc->ops->ctrl_ops || 1014 !soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi) 1015 return QDF_STATUS_E_FAILURE; 1016 1017 return soc->ops->ctrl_ops->txrx_vdev_config_for_nac_rssi(soc, vdev_id, 1018 nac_cmd, bssid, client_macaddr, chan_num); 1019 } 1020 1021 /* 1022 * cdp_vdev_get_neighbour_rssi(): To invoke dp callback to get rssi value of nac 1023 * @soc: soc pointer 1024 * @vdev_id: id of vdev 1025 * @macaddr: Non-Associated client MAC 1026 * @rssi: rssi 1027 * 1028 * Return: QDF_STATUS 1029 */ 1030 static inline QDF_STATUS cdp_vdev_get_neighbour_rssi(ol_txrx_soc_handle soc, 1031 uint8_t vdev_id, 1032 char *macaddr, 1033 uint8_t *rssi) 1034 { 1035 if (!soc || !soc->ops) { 1036 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL, 1037 "%s invalid instance", __func__); 1038 QDF_BUG(0); 1039 return QDF_STATUS_E_FAILURE; 1040 } 1041 1042 if (!soc->ops->ctrl_ops || 1043 !soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi) 1044 return QDF_STATUS_E_FAILURE; 1045 1046 return soc->ops->ctrl_ops->txrx_vdev_get_neighbour_rssi(soc, vdev_id, 1047 macaddr, 1048 rssi); 1049 } 1050 #endif 1051 1052 #ifdef WLAN_SUPPORT_RX_FLOW_TAG 1053 /** 1054 * cdp_set_rx_flow_tag() - wrapper function to set the flow 1055 * tag in CDP layer from cfg layer 1056 * @soc: SOC TXRX handle 1057 * @pdev_id: id of CDP pdev pointer 1058 * @flow_info: Flow 5-tuple, along with tag, if any, that needs to added/deleted 1059 * 1060 * Return: Success when add/del operation is successful, error otherwise 1061 */ 1062 static inline QDF_STATUS 1063 cdp_set_rx_flow_tag(ol_txrx_soc_handle soc, uint8_t pdev_id, 1064 struct cdp_rx_flow_info *flow_info) 1065 { 1066 if (!soc || !soc->ops) { 1067 dp_err("Invalid SOC instance"); 1068 QDF_BUG(0); 1069 return QDF_STATUS_E_FAILURE; 1070 } 1071 1072 if (!soc->ops->ctrl_ops || 1073 !soc->ops->ctrl_ops->txrx_set_rx_flow_tag) 1074 return QDF_STATUS_E_FAILURE; 1075 1076 return soc->ops->ctrl_ops->txrx_set_rx_flow_tag(soc, pdev_id, 1077 flow_info); 1078 } 1079 1080 /** 1081 * cdp_dump_rx_flow_tag_stats() - wrapper function to dump the flow 1082 * tag statistics for given flow 1083 * @soc: SOC TXRX handle 1084 * @pdev_id: id of CDP pdev 1085 * @flow_info: Flow tuple for which we want to print the statistics 1086 * 1087 * Return: Success when flow is found and stats are printed, error otherwise 1088 */ 1089 static inline QDF_STATUS 1090 cdp_dump_rx_flow_tag_stats(ol_txrx_soc_handle soc, uint8_t pdev_id, 1091 struct cdp_rx_flow_info *flow_info) 1092 { 1093 if (!soc || !soc->ops) { 1094 dp_err("Invalid SOC instance"); 1095 QDF_BUG(0); 1096 return QDF_STATUS_E_FAILURE; 1097 } 1098 1099 if (!soc->ops->ctrl_ops || 1100 !soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats) 1101 return QDF_STATUS_E_FAILURE; 1102 1103 return soc->ops->ctrl_ops->txrx_dump_rx_flow_tag_stats(soc, 1104 pdev_id, 1105 flow_info); 1106 } 1107 #endif /* WLAN_SUPPORT_RX_FLOW_TAG */ 1108 #endif /* _CDP_TXRX_CTRL_H_ */ 1109