1 /* 2 * Copyright (c) 2016-2018 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 #ifndef _DP_RX_H 20 #define _DP_RX_H 21 22 #include "hal_rx.h" 23 #include "dp_tx.h" 24 #include "dp_peer.h" 25 #include "dp_internal.h" 26 27 #ifdef RXDMA_OPTIMIZATION 28 #define RX_BUFFER_ALIGNMENT 128 29 #else /* RXDMA_OPTIMIZATION */ 30 #define RX_BUFFER_ALIGNMENT 4 31 #endif /* RXDMA_OPTIMIZATION */ 32 33 #ifdef QCA_HOST2FW_RXBUF_RING 34 #define DP_WBM2SW_RBM HAL_RX_BUF_RBM_SW1_BM 35 #else 36 #define DP_WBM2SW_RBM HAL_RX_BUF_RBM_SW3_BM 37 #endif 38 #define RX_BUFFER_SIZE 2048 39 #define RX_BUFFER_RESERVATION 0 40 41 #define DP_PEER_METADATA_PEER_ID_MASK 0x0000ffff 42 #define DP_PEER_METADATA_PEER_ID_SHIFT 0 43 #define DP_PEER_METADATA_VDEV_ID_MASK 0x00070000 44 #define DP_PEER_METADATA_VDEV_ID_SHIFT 16 45 46 #define DP_PEER_METADATA_PEER_ID_GET(_peer_metadata) \ 47 (((_peer_metadata) & DP_PEER_METADATA_PEER_ID_MASK) \ 48 >> DP_PEER_METADATA_PEER_ID_SHIFT) 49 50 #define DP_PEER_METADATA_ID_GET(_peer_metadata) \ 51 (((_peer_metadata) & DP_PEER_METADATA_VDEV_ID_MASK) \ 52 >> DP_PEER_METADATA_VDEV_ID_SHIFT) 53 54 #define DP_RX_DESC_MAGIC 0xdec0de 55 56 /** 57 * struct dp_rx_desc 58 * 59 * @nbuf : VA of the "skb" posted 60 * @rx_buf_start : VA of the original Rx buffer, before 61 * movement of any skb->data pointer 62 * @cookie : index into the sw array which holds 63 * the sw Rx descriptors 64 * Cookie space is 21 bits: 65 * lower 18 bits -- index 66 * upper 3 bits -- pool_id 67 * @pool_id : pool Id for which this allocated. 68 * Can only be used if there is no flow 69 * steering 70 * @in_use rx_desc is in use 71 * @unmapped used to mark rx_desc an unmapped if the corresponding 72 * nbuf is already unmapped 73 */ 74 struct dp_rx_desc { 75 qdf_nbuf_t nbuf; 76 uint8_t *rx_buf_start; 77 uint32_t cookie; 78 uint8_t pool_id; 79 #ifdef RX_DESC_DEBUG_CHECK 80 uint32_t magic; 81 #endif 82 uint8_t in_use:1, 83 unmapped:1; 84 }; 85 86 #define RX_DESC_COOKIE_INDEX_SHIFT 0 87 #define RX_DESC_COOKIE_INDEX_MASK 0x3ffff /* 18 bits */ 88 #define RX_DESC_COOKIE_POOL_ID_SHIFT 18 89 #define RX_DESC_COOKIE_POOL_ID_MASK 0x1c0000 90 91 #define DP_RX_DESC_COOKIE_POOL_ID_GET(_cookie) \ 92 (((_cookie) & RX_DESC_COOKIE_POOL_ID_MASK) >> \ 93 RX_DESC_COOKIE_POOL_ID_SHIFT) 94 95 #define DP_RX_DESC_COOKIE_INDEX_GET(_cookie) \ 96 (((_cookie) & RX_DESC_COOKIE_INDEX_MASK) >> \ 97 RX_DESC_COOKIE_INDEX_SHIFT) 98 99 /* 100 *dp_rx_xor_block() - xor block of data 101 *@b: destination data block 102 *@a: source data block 103 *@len: length of the data to process 104 * 105 *Returns: None 106 */ 107 static inline void dp_rx_xor_block(uint8_t *b, const uint8_t *a, qdf_size_t len) 108 { 109 qdf_size_t i; 110 111 for (i = 0; i < len; i++) 112 b[i] ^= a[i]; 113 } 114 115 /* 116 *dp_rx_rotl() - rotate the bits left 117 *@val: unsigned integer input value 118 *@bits: number of bits 119 * 120 *Returns: Integer with left rotated by number of 'bits' 121 */ 122 static inline uint32_t dp_rx_rotl(uint32_t val, int bits) 123 { 124 return (val << bits) | (val >> (32 - bits)); 125 } 126 127 /* 128 *dp_rx_rotr() - rotate the bits right 129 *@val: unsigned integer input value 130 *@bits: number of bits 131 * 132 *Returns: Integer with right rotated by number of 'bits' 133 */ 134 static inline uint32_t dp_rx_rotr(uint32_t val, int bits) 135 { 136 return (val >> bits) | (val << (32 - bits)); 137 } 138 139 /* 140 * dp_set_rx_queue() - set queue_mapping in skb 141 * @nbuf: skb 142 * @queue_id: rx queue_id 143 * 144 * Return: void 145 */ 146 #ifdef QCA_OL_RX_MULTIQ_SUPPORT 147 static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id) 148 { 149 qdf_nbuf_record_rx_queue(nbuf, queue_id); 150 return; 151 } 152 #else 153 static inline void dp_set_rx_queue(qdf_nbuf_t nbuf, uint8_t queue_id) 154 { 155 } 156 #endif 157 158 /* 159 *dp_rx_xswap() - swap the bits left 160 *@val: unsigned integer input value 161 * 162 *Returns: Integer with bits swapped 163 */ 164 static inline uint32_t dp_rx_xswap(uint32_t val) 165 { 166 return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8); 167 } 168 169 /* 170 *dp_rx_get_le32_split() - get little endian 32 bits split 171 *@b0: byte 0 172 *@b1: byte 1 173 *@b2: byte 2 174 *@b3: byte 3 175 * 176 *Returns: Integer with split little endian 32 bits 177 */ 178 static inline uint32_t dp_rx_get_le32_split(uint8_t b0, uint8_t b1, uint8_t b2, 179 uint8_t b3) 180 { 181 return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); 182 } 183 184 /* 185 *dp_rx_get_le32() - get little endian 32 bits 186 *@b0: byte 0 187 *@b1: byte 1 188 *@b2: byte 2 189 *@b3: byte 3 190 * 191 *Returns: Integer with little endian 32 bits 192 */ 193 static inline uint32_t dp_rx_get_le32(const uint8_t *p) 194 { 195 return dp_rx_get_le32_split(p[0], p[1], p[2], p[3]); 196 } 197 198 /* 199 * dp_rx_put_le32() - put little endian 32 bits 200 * @p: destination char array 201 * @v: source 32-bit integer 202 * 203 * Returns: None 204 */ 205 static inline void dp_rx_put_le32(uint8_t *p, uint32_t v) 206 { 207 p[0] = (v) & 0xff; 208 p[1] = (v >> 8) & 0xff; 209 p[2] = (v >> 16) & 0xff; 210 p[3] = (v >> 24) & 0xff; 211 } 212 213 /* Extract michal mic block of data */ 214 #define dp_rx_michael_block(l, r) \ 215 do { \ 216 r ^= dp_rx_rotl(l, 17); \ 217 l += r; \ 218 r ^= dp_rx_xswap(l); \ 219 l += r; \ 220 r ^= dp_rx_rotl(l, 3); \ 221 l += r; \ 222 r ^= dp_rx_rotr(l, 2); \ 223 l += r; \ 224 } while (0) 225 226 /** 227 * struct dp_rx_desc_list_elem_t 228 * 229 * @next : Next pointer to form free list 230 * @rx_desc : DP Rx descriptor 231 */ 232 union dp_rx_desc_list_elem_t { 233 union dp_rx_desc_list_elem_t *next; 234 struct dp_rx_desc rx_desc; 235 }; 236 237 /** 238 * dp_rx_cookie_2_va_rxdma_buf() - Converts cookie to a virtual address of 239 * the Rx descriptor on Rx DMA source ring buffer 240 * @soc: core txrx main context 241 * @cookie: cookie used to lookup virtual address 242 * 243 * Return: void *: Virtual Address of the Rx descriptor 244 */ 245 static inline 246 void *dp_rx_cookie_2_va_rxdma_buf(struct dp_soc *soc, uint32_t cookie) 247 { 248 uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie); 249 uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie); 250 struct rx_desc_pool *rx_desc_pool; 251 252 if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS)) 253 return NULL; 254 255 rx_desc_pool = &soc->rx_desc_buf[pool_id]; 256 257 if (qdf_unlikely(index >= rx_desc_pool->pool_size)) 258 return NULL; 259 260 return &(soc->rx_desc_buf[pool_id].array[index].rx_desc); 261 } 262 263 /** 264 * dp_rx_cookie_2_va_mon_buf() - Converts cookie to a virtual address of 265 * the Rx descriptor on monitor ring buffer 266 * @soc: core txrx main context 267 * @cookie: cookie used to lookup virtual address 268 * 269 * Return: void *: Virtual Address of the Rx descriptor 270 */ 271 static inline 272 void *dp_rx_cookie_2_va_mon_buf(struct dp_soc *soc, uint32_t cookie) 273 { 274 uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie); 275 uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie); 276 /* TODO */ 277 /* Add sanity for pool_id & index */ 278 return &(soc->rx_desc_mon[pool_id].array[index].rx_desc); 279 } 280 281 /** 282 * dp_rx_cookie_2_va_mon_status() - Converts cookie to a virtual address of 283 * the Rx descriptor on monitor status ring buffer 284 * @soc: core txrx main context 285 * @cookie: cookie used to lookup virtual address 286 * 287 * Return: void *: Virtual Address of the Rx descriptor 288 */ 289 static inline 290 void *dp_rx_cookie_2_va_mon_status(struct dp_soc *soc, uint32_t cookie) 291 { 292 uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie); 293 uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie); 294 /* TODO */ 295 /* Add sanity for pool_id & index */ 296 return &(soc->rx_desc_status[pool_id].array[index].rx_desc); 297 } 298 299 void dp_rx_add_desc_list_to_free_list(struct dp_soc *soc, 300 union dp_rx_desc_list_elem_t **local_desc_list, 301 union dp_rx_desc_list_elem_t **tail, 302 uint16_t pool_id, 303 struct rx_desc_pool *rx_desc_pool); 304 305 uint16_t dp_rx_get_free_desc_list(struct dp_soc *soc, uint32_t pool_id, 306 struct rx_desc_pool *rx_desc_pool, 307 uint16_t num_descs, 308 union dp_rx_desc_list_elem_t **desc_list, 309 union dp_rx_desc_list_elem_t **tail); 310 311 312 QDF_STATUS dp_rx_pdev_attach(struct dp_pdev *pdev); 313 314 void dp_rx_pdev_detach(struct dp_pdev *pdev); 315 316 317 uint32_t 318 dp_rx_process(struct dp_intr *int_ctx, void *hal_ring, uint8_t reo_ring_num, 319 uint32_t quota); 320 321 uint32_t dp_rx_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota); 322 323 uint32_t 324 dp_rx_wbm_err_process(struct dp_soc *soc, void *hal_ring, uint32_t quota); 325 326 /** 327 * dp_rx_sg_create() - create a frag_list for MSDUs which are spread across 328 * multiple nbufs. 329 * @nbuf: pointer to the first msdu of an amsdu. 330 * @rx_tlv_hdr: pointer to the start of RX TLV headers. 331 * 332 * This function implements the creation of RX frag_list for cases 333 * where an MSDU is spread across multiple nbufs. 334 * 335 * Return: returns the head nbuf which contains complete frag_list. 336 */ 337 qdf_nbuf_t dp_rx_sg_create(qdf_nbuf_t nbuf, uint8_t *rx_tlv_hdr); 338 339 QDF_STATUS dp_rx_desc_pool_alloc(struct dp_soc *soc, 340 uint32_t pool_id, 341 uint32_t pool_size, 342 struct rx_desc_pool *rx_desc_pool); 343 344 void dp_rx_desc_pool_free(struct dp_soc *soc, 345 uint32_t pool_id, 346 struct rx_desc_pool *rx_desc_pool); 347 348 void dp_rx_deliver_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf_list, 349 struct dp_peer *peer); 350 351 /** 352 * dp_rx_add_to_free_desc_list() - Adds to a local free descriptor list 353 * 354 * @head: pointer to the head of local free list 355 * @tail: pointer to the tail of local free list 356 * @new: new descriptor that is added to the free list 357 * 358 * Return: void: 359 */ 360 static inline 361 void dp_rx_add_to_free_desc_list(union dp_rx_desc_list_elem_t **head, 362 union dp_rx_desc_list_elem_t **tail, 363 struct dp_rx_desc *new) 364 { 365 qdf_assert(head && new); 366 367 new->nbuf = NULL; 368 new->in_use = 0; 369 new->unmapped = 0; 370 371 ((union dp_rx_desc_list_elem_t *)new)->next = *head; 372 *head = (union dp_rx_desc_list_elem_t *)new; 373 if (*tail == NULL) 374 *tail = *head; 375 376 } 377 378 /** 379 * dp_rx_wds_srcport_learn() - Add or update the STA PEER which 380 * is behind the WDS repeater. 381 * 382 * @soc: core txrx main context 383 * @rx_tlv_hdr: base address of RX TLV header 384 * @ta_peer: WDS repeater peer 385 * @nbuf: rx pkt 386 * 387 * Return: void: 388 */ 389 #ifdef FEATURE_WDS 390 static inline void 391 dp_rx_wds_srcport_learn(struct dp_soc *soc, 392 uint8_t *rx_tlv_hdr, 393 struct dp_peer *ta_peer, 394 qdf_nbuf_t nbuf) 395 { 396 uint16_t sa_sw_peer_id = hal_rx_msdu_end_sa_sw_peer_id_get(rx_tlv_hdr); 397 uint32_t flags = IEEE80211_NODE_F_WDS_HM; 398 uint32_t ret = 0; 399 uint8_t wds_src_mac[IEEE80211_ADDR_LEN]; 400 struct dp_peer *sa_peer; 401 struct dp_ast_entry *ast; 402 uint16_t sa_idx; 403 404 if (qdf_unlikely(!ta_peer)) 405 return; 406 407 /* For AP mode : Do wds source port learning only if it is a 408 * 4-address mpdu 409 * 410 * For STA mode : Frames from RootAP backend will be in 3-address mode, 411 * till RootAP does the WDS source port learning; Hence in repeater/STA 412 * mode, we enable learning even in 3-address mode , to avoid RootAP 413 * backbone getting wrongly learnt as MEC on repeater 414 */ 415 if (ta_peer->vdev->opmode != wlan_op_mode_sta) { 416 if (!(qdf_nbuf_is_rx_chfrag_start(nbuf) && 417 hal_rx_get_mpdu_mac_ad4_valid(rx_tlv_hdr))) 418 return; 419 } else { 420 /* For HKv2 Source port learing is not needed in STA mode 421 * as we have support in HW 422 */ 423 if (soc->ast_override_support) 424 return; 425 } 426 427 memcpy(wds_src_mac, (qdf_nbuf_data(nbuf) + IEEE80211_ADDR_LEN), 428 IEEE80211_ADDR_LEN); 429 430 if (qdf_unlikely(!hal_rx_msdu_end_sa_is_valid_get(rx_tlv_hdr))) { 431 ret = dp_peer_add_ast(soc, 432 ta_peer, 433 wds_src_mac, 434 CDP_TXRX_AST_TYPE_WDS, 435 flags); 436 return; 437 } 438 439 /* 440 * Get the AST entry from HW SA index and mark it as active 441 */ 442 sa_idx = hal_rx_msdu_end_sa_idx_get(rx_tlv_hdr); 443 444 qdf_spin_lock_bh(&soc->ast_lock); 445 ast = soc->ast_table[sa_idx]; 446 447 if (!ast) { 448 qdf_spin_unlock_bh(&soc->ast_lock); 449 return; 450 } 451 452 qdf_spin_unlock_bh(&soc->ast_lock); 453 454 /* 455 * Ensure we are updating the right AST entry by 456 * validating ast_idx. 457 * There is a possibility we might arrive here without 458 * AST MAP event , so this check is mandatory 459 */ 460 if (ast->ast_idx == sa_idx) 461 ast->is_active = TRUE; 462 463 if (sa_sw_peer_id != ta_peer->peer_ids[0]) { 464 sa_peer = ast->peer; 465 466 if ((ast->type != CDP_TXRX_AST_TYPE_STATIC) && 467 (ast->type != CDP_TXRX_AST_TYPE_SELF) && 468 (ast->type != CDP_TXRX_AST_TYPE_STA_BSS)) { 469 if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) { 470 ret = dp_peer_add_ast(soc, 471 ta_peer, wds_src_mac, 472 CDP_TXRX_AST_TYPE_WDS, 473 flags); 474 } else { 475 qdf_spin_lock_bh(&soc->ast_lock); 476 dp_peer_update_ast(soc, ta_peer, ast, flags); 477 qdf_spin_unlock_bh(&soc->ast_lock); 478 return; 479 } 480 } 481 /* 482 * Do not kickout STA if it belongs to a different radio. 483 * For DBDC repeater, it is possible to arrive here 484 * for multicast loopback frames originated from connected 485 * clients and looped back (intrabss) by Root AP 486 */ 487 if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) { 488 return; 489 } 490 491 /* 492 * Kickout, when direct associated peer(SA) roams 493 * to another AP and reachable via TA peer 494 */ 495 if (!sa_peer->delete_in_progress) { 496 sa_peer->delete_in_progress = true; 497 if (soc->cdp_soc.ol_ops->peer_sta_kickout) { 498 soc->cdp_soc.ol_ops->peer_sta_kickout( 499 sa_peer->vdev->pdev->ctrl_pdev, 500 wds_src_mac); 501 } 502 } 503 } 504 505 return; 506 } 507 #else 508 static inline void 509 dp_rx_wds_srcport_learn(struct dp_soc *soc, 510 uint8_t *rx_tlv_hdr, 511 struct dp_peer *ta_peer, 512 qdf_nbuf_t nbuf) 513 { 514 } 515 #endif 516 517 uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf); 518 void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc, 519 qdf_nbuf_t mpdu, bool mpdu_done); 520 void dp_rx_process_mic_error(struct dp_soc *soc, qdf_nbuf_t nbuf, 521 uint8_t *rx_tlv_hdr, struct dp_peer *peer); 522 523 #define DP_RX_LIST_APPEND(head, tail, elem) \ 524 do { \ 525 if (!(head)) { \ 526 (head) = (elem); \ 527 QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head) = 1;\ 528 } else { \ 529 qdf_nbuf_set_next((tail), (elem)); \ 530 QDF_NBUF_CB_RX_NUM_ELEMENTS_IN_LIST(head)++; \ 531 } \ 532 (tail) = (elem); \ 533 qdf_nbuf_set_next((tail), NULL); \ 534 } while (0) 535 536 #ifndef BUILD_X86 537 static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf, 538 qdf_dma_addr_t *paddr, struct dp_pdev *pdev) 539 { 540 return QDF_STATUS_SUCCESS; 541 } 542 #else 543 #define MAX_RETRY 100 544 static inline int check_x86_paddr(struct dp_soc *dp_soc, qdf_nbuf_t *rx_netbuf, 545 qdf_dma_addr_t *paddr, struct dp_pdev *pdev) 546 { 547 uint32_t nbuf_retry = 0; 548 int32_t ret; 549 const uint32_t x86_phy_addr = 0x50000000; 550 /* 551 * in M2M emulation platforms (x86) the memory below 0x50000000 552 * is reserved for target use, so any memory allocated in this 553 * region should not be used by host 554 */ 555 do { 556 if (qdf_likely(*paddr > x86_phy_addr)) 557 return QDF_STATUS_SUCCESS; 558 else { 559 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO, 560 "phy addr %pK exceeded 0x50000000 trying again", 561 paddr); 562 563 nbuf_retry++; 564 if ((*rx_netbuf)) { 565 qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf, 566 QDF_DMA_BIDIRECTIONAL); 567 /* Not freeing buffer intentionally. 568 * Observed that same buffer is getting 569 * re-allocated resulting in longer load time 570 * WMI init timeout. 571 * This buffer is anyway not useful so skip it. 572 **/ 573 } 574 575 *rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev, 576 RX_BUFFER_SIZE, 577 RX_BUFFER_RESERVATION, 578 RX_BUFFER_ALIGNMENT, 579 FALSE); 580 581 if (qdf_unlikely(!(*rx_netbuf))) 582 return QDF_STATUS_E_FAILURE; 583 584 ret = qdf_nbuf_map_single(dp_soc->osdev, *rx_netbuf, 585 QDF_DMA_BIDIRECTIONAL); 586 587 if (qdf_unlikely(ret == QDF_STATUS_E_FAILURE)) { 588 qdf_nbuf_free(*rx_netbuf); 589 *rx_netbuf = NULL; 590 continue; 591 } 592 593 *paddr = qdf_nbuf_get_frag_paddr(*rx_netbuf, 0); 594 } 595 } while (nbuf_retry < MAX_RETRY); 596 597 if ((*rx_netbuf)) { 598 qdf_nbuf_unmap_single(dp_soc->osdev, *rx_netbuf, 599 QDF_DMA_BIDIRECTIONAL); 600 qdf_nbuf_free(*rx_netbuf); 601 } 602 603 return QDF_STATUS_E_FAILURE; 604 } 605 #endif 606 607 /** 608 * dp_rx_cookie_2_link_desc_va() - Converts cookie to a virtual address of 609 * the MSDU Link Descriptor 610 * @soc: core txrx main context 611 * @buf_info: buf_info include cookie that used to lookup virtual address of 612 * link descriptor Normally this is just an index into a per SOC array. 613 * 614 * This is the VA of the link descriptor, that HAL layer later uses to 615 * retrieve the list of MSDU's for a given MPDU. 616 * 617 * Return: void *: Virtual Address of the Rx descriptor 618 */ 619 static inline 620 void *dp_rx_cookie_2_link_desc_va(struct dp_soc *soc, 621 struct hal_buf_info *buf_info) 622 { 623 void *link_desc_va; 624 uint32_t bank_id = LINK_DESC_COOKIE_BANK_ID(buf_info->sw_cookie); 625 626 627 /* TODO */ 628 /* Add sanity for cookie */ 629 630 link_desc_va = soc->link_desc_banks[bank_id].base_vaddr + 631 (buf_info->paddr - 632 soc->link_desc_banks[bank_id].base_paddr); 633 634 return link_desc_va; 635 } 636 637 /** 638 * dp_rx_cookie_2_mon_link_desc_va() - Converts cookie to a virtual address of 639 * the MSDU Link Descriptor 640 * @pdev: core txrx pdev context 641 * @buf_info: buf_info includes cookie that used to lookup virtual address of 642 * link descriptor. Normally this is just an index into a per pdev array. 643 * 644 * This is the VA of the link descriptor in monitor mode destination ring, 645 * that HAL layer later uses to retrieve the list of MSDU's for a given MPDU. 646 * 647 * Return: void *: Virtual Address of the Rx descriptor 648 */ 649 static inline 650 void *dp_rx_cookie_2_mon_link_desc_va(struct dp_pdev *pdev, 651 struct hal_buf_info *buf_info, 652 int mac_id) 653 { 654 void *link_desc_va; 655 int mac_for_pdev = dp_get_mac_id_for_mac(pdev->soc, mac_id); 656 657 /* TODO */ 658 /* Add sanity for cookie */ 659 660 link_desc_va = 661 pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_vaddr + 662 (buf_info->paddr - 663 pdev->link_desc_banks[mac_for_pdev][buf_info->sw_cookie].base_paddr); 664 665 return link_desc_va; 666 } 667 668 /** 669 * dp_rx_defrag_concat() - Concatenate the fragments 670 * 671 * @dst: destination pointer to the buffer 672 * @src: source pointer from where the fragment payload is to be copied 673 * 674 * Return: QDF_STATUS 675 */ 676 static inline QDF_STATUS dp_rx_defrag_concat(qdf_nbuf_t dst, qdf_nbuf_t src) 677 { 678 /* 679 * Inside qdf_nbuf_cat, if it is necessary to reallocate dst 680 * to provide space for src, the headroom portion is copied from 681 * the original dst buffer to the larger new dst buffer. 682 * (This is needed, because the headroom of the dst buffer 683 * contains the rx desc.) 684 */ 685 if (qdf_nbuf_cat(dst, src)) 686 return QDF_STATUS_E_DEFRAG_ERROR; 687 688 return QDF_STATUS_SUCCESS; 689 } 690 691 /* 692 * dp_rx_ast_set_active() - set the active flag of the astentry 693 * corresponding to a hw index. 694 * @soc: core txrx main context 695 * @sa_idx: hw idx 696 * @is_active: active flag 697 * 698 */ 699 #ifdef FEATURE_WDS 700 static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active) 701 { 702 struct dp_ast_entry *ast; 703 qdf_spin_lock_bh(&soc->ast_lock); 704 ast = soc->ast_table[sa_idx]; 705 706 /* 707 * Ensure we are updating the right AST entry by 708 * validating ast_idx. 709 * There is a possibility we might arrive here without 710 * AST MAP event , so this check is mandatory 711 */ 712 if (ast && (ast->ast_idx == sa_idx)) { 713 ast->is_active = is_active; 714 qdf_spin_unlock_bh(&soc->ast_lock); 715 return QDF_STATUS_SUCCESS; 716 } 717 718 qdf_spin_unlock_bh(&soc->ast_lock); 719 return QDF_STATUS_E_FAILURE; 720 } 721 #else 722 static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active) 723 { 724 return QDF_STATUS_SUCCESS; 725 } 726 #endif 727 728 /* 729 * check_qwrap_multicast_loopback() - Check if rx packet is a loopback packet. 730 * In qwrap mode, packets originated from 731 * any vdev should not loopback and 732 * should be dropped. 733 * @vdev: vdev on which rx packet is received 734 * @nbuf: rx pkt 735 * 736 */ 737 #if ATH_SUPPORT_WRAP 738 static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev, 739 qdf_nbuf_t nbuf) 740 { 741 struct dp_vdev *psta_vdev; 742 struct dp_pdev *pdev = vdev->pdev; 743 struct dp_soc *soc = pdev->soc; 744 uint8_t *data = qdf_nbuf_data(nbuf); 745 uint8_t i; 746 747 for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) { 748 pdev = soc->pdev_list[i]; 749 if (qdf_unlikely(vdev->proxysta_vdev)) { 750 /* In qwrap isolation mode, allow loopback packets as all 751 * packets go to RootAP and Loopback on the mpsta. 752 */ 753 if (vdev->isolation_vdev) 754 return false; 755 TAILQ_FOREACH(psta_vdev, &pdev->vdev_list, vdev_list_elem) { 756 if (qdf_unlikely(psta_vdev->proxysta_vdev && 757 !qdf_mem_cmp(psta_vdev->mac_addr.raw, 758 &data[DP_MAC_ADDR_LEN], DP_MAC_ADDR_LEN))) { 759 /* Drop packet if source address is equal to 760 * any of the vdev addresses. 761 */ 762 return true; 763 } 764 } 765 } 766 } 767 return false; 768 } 769 #else 770 static inline bool check_qwrap_multicast_loopback(struct dp_vdev *vdev, 771 qdf_nbuf_t nbuf) 772 { 773 return false; 774 } 775 #endif 776 777 /* 778 * dp_rx_buffers_replenish() - replenish rxdma ring with rx nbufs 779 * called during dp rx initialization 780 * and at the end of dp_rx_process. 781 * 782 * @soc: core txrx main context 783 * @mac_id: mac_id which is one of 3 mac_ids 784 * @dp_rxdma_srng: dp rxdma circular ring 785 * @rx_desc_pool: Pointer to free Rx descriptor pool 786 * @num_req_buffers: number of buffer to be replenished 787 * @desc_list: list of descs if called from dp_rx_process 788 * or NULL during dp rx initialization or out of buffer 789 * interrupt. 790 * @tail: tail of descs list 791 * Return: return success or failure 792 */ 793 QDF_STATUS dp_rx_buffers_replenish(struct dp_soc *dp_soc, uint32_t mac_id, 794 struct dp_srng *dp_rxdma_srng, 795 struct rx_desc_pool *rx_desc_pool, 796 uint32_t num_req_buffers, 797 union dp_rx_desc_list_elem_t **desc_list, 798 union dp_rx_desc_list_elem_t **tail); 799 800 /** 801 * dp_rx_link_desc_return() - Return a MPDU link descriptor to HW 802 * (WBM), following error handling 803 * 804 * @soc: core DP main context 805 * @buf_addr_info: opaque pointer to the REO error ring descriptor 806 * @buf_addr_info: void pointer to the buffer_addr_info 807 * @bm_action: put to idle_list or release to msdu_list 808 * Return: QDF_STATUS 809 */ 810 QDF_STATUS 811 dp_rx_link_desc_return(struct dp_soc *soc, void *ring_desc, uint8_t bm_action); 812 813 QDF_STATUS 814 dp_rx_link_desc_buf_return(struct dp_soc *soc, struct dp_srng *dp_rxdma_srng, 815 void *buf_addr_info, uint8_t bm_action); 816 /** 817 * dp_rx_link_desc_return_by_addr - Return a MPDU link descriptor to 818 * (WBM) by address 819 * 820 * @soc: core DP main context 821 * @link_desc_addr: link descriptor addr 822 * 823 * Return: QDF_STATUS 824 */ 825 QDF_STATUS 826 dp_rx_link_desc_return_by_addr(struct dp_soc *soc, void *link_desc_addr, 827 uint8_t bm_action); 828 829 uint32_t 830 dp_rxdma_err_process(struct dp_soc *soc, uint32_t mac_id, 831 uint32_t quota); 832 833 void dp_rx_fill_mesh_stats(struct dp_vdev *vdev, qdf_nbuf_t nbuf, 834 uint8_t *rx_tlv_hdr, struct dp_peer *peer); 835 QDF_STATUS dp_rx_filter_mesh_packets(struct dp_vdev *vdev, qdf_nbuf_t nbuf, 836 uint8_t *rx_tlv_hdr); 837 838 int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr, struct dp_vdev *vdev, 839 struct dp_peer *peer, int rx_mcast); 840 841 qdf_nbuf_t 842 dp_rx_nbuf_prepare(struct dp_soc *soc, struct dp_pdev *pdev); 843 844 #endif /* _DP_RX_H */ 845