| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: ISC */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | | - * Copyright (c) 2012-2016,2018, The Linux Foundation. All rights reserved. |
|---|
| 3 | | - * |
|---|
| 4 | | - * Permission to use, copy, modify, and/or distribute this software for any |
|---|
| 5 | | - * purpose with or without fee is hereby granted, provided that the above |
|---|
| 6 | | - * copyright notice and this permission notice appear in all copies. |
|---|
| 7 | | - * |
|---|
| 8 | | - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|---|
| 9 | | - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|---|
| 10 | | - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|---|
| 11 | | - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|---|
| 12 | | - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|---|
| 13 | | - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|---|
| 14 | | - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|---|
| 3 | + * Copyright (c) 2012-2016,2018-2019, The Linux Foundation. All rights reserved. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | |
|---|
| 17 | 6 | #ifndef WIL6210_TXRX_EDMA_H |
|---|
| .. | .. |
|---|
| 23 | 12 | #define WIL_SRING_SIZE_ORDER_MIN (WIL_RING_SIZE_ORDER_MIN) |
|---|
| 24 | 13 | #define WIL_SRING_SIZE_ORDER_MAX (WIL_RING_SIZE_ORDER_MAX) |
|---|
| 25 | 14 | /* RX sring order should be bigger than RX ring order */ |
|---|
| 26 | | -#define WIL_RX_SRING_SIZE_ORDER_DEFAULT (11) |
|---|
| 27 | | -#define WIL_TX_SRING_SIZE_ORDER_DEFAULT (12) |
|---|
| 28 | | -#define WIL_RX_BUFF_ARR_SIZE_DEFAULT (1536) |
|---|
| 15 | +#define WIL_RX_SRING_SIZE_ORDER_DEFAULT (12) |
|---|
| 16 | +#define WIL_TX_SRING_SIZE_ORDER_DEFAULT (14) |
|---|
| 17 | +#define WIL_RX_BUFF_ARR_SIZE_DEFAULT (2600) |
|---|
| 29 | 18 | |
|---|
| 30 | 19 | #define WIL_DEFAULT_RX_STATUS_RING_ID 0 |
|---|
| 31 | 20 | #define WIL_RX_DESC_RING_ID 0 |
|---|
| .. | .. |
|---|
| 57 | 46 | |
|---|
| 58 | 47 | #define WIL_RX_EDMA_DLPF_LU_MISS_TID_POS 5 |
|---|
| 59 | 48 | |
|---|
| 60 | | -#define WIL_RX_EDMA_MID_VALID_BIT BIT(22) |
|---|
| 49 | +#define WIL_RX_EDMA_MID_VALID_BIT BIT(20) |
|---|
| 61 | 50 | |
|---|
| 62 | 51 | #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS 16 |
|---|
| 63 | 52 | #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_LEN 6 |
|---|
| .. | .. |
|---|
| 255 | 244 | * calculated, Bit1- L4Err - TCP/UDP Checksum Error |
|---|
| 256 | 245 | * bit 7 : Reserved:1 |
|---|
| 257 | 246 | * bit 8..19 : Flow ID:12 - MSDU flow ID |
|---|
| 258 | | - * bit 20..21 : MID:2 - The MAC ID |
|---|
| 259 | | - * bit 22 : MID_V:1 - The MAC ID field is valid |
|---|
| 247 | + * bit 20 : MID_V:1 - The MAC ID field is valid |
|---|
| 248 | + * bit 21..22 : MID:2 - The MAC ID |
|---|
| 260 | 249 | * bit 23 : L3T:1 - IP types: 0-IPv6, 1-IPv4 |
|---|
| 261 | 250 | * bit 24 : L4T:1 - Layer 4 Type: 0-UDP, 1-TCP |
|---|
| 262 | 251 | * bit 25 : BC:1 - The received MPDU is broadcast |
|---|
| .. | .. |
|---|
| 366 | 355 | 16, 21); |
|---|
| 367 | 356 | } |
|---|
| 368 | 357 | |
|---|
| 358 | +static inline u8 wil_rx_status_get_cb_mode(void *msg) |
|---|
| 359 | +{ |
|---|
| 360 | + return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1, |
|---|
| 361 | + 22, 23); |
|---|
| 362 | +} |
|---|
| 363 | + |
|---|
| 369 | 364 | static inline u16 wil_rx_status_get_flow_id(void *msg) |
|---|
| 370 | 365 | { |
|---|
| 371 | 366 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|
| .. | .. |
|---|
| 415 | 410 | return val & WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK; |
|---|
| 416 | 411 | } |
|---|
| 417 | 412 | |
|---|
| 418 | | -static inline int wil_rx_status_get_desc_rdy_bit(void *msg) |
|---|
| 419 | | -{ |
|---|
| 420 | | - return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|
| 421 | | - 31, 31); |
|---|
| 422 | | -} |
|---|
| 423 | | - |
|---|
| 424 | 413 | static inline int wil_rx_status_get_eop(void *msg) /* EoP = End of Packet */ |
|---|
| 425 | 414 | { |
|---|
| 426 | 415 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|
| 427 | 416 | 30, 30); |
|---|
| 417 | +} |
|---|
| 418 | + |
|---|
| 419 | +static inline void wil_rx_status_reset_buff_id(struct wil_status_ring *s) |
|---|
| 420 | +{ |
|---|
| 421 | + ((struct wil_rx_status_compressed *) |
|---|
| 422 | + (s->va + (s->elem_size * s->swhead)))->buff_id = 0; |
|---|
| 428 | 423 | } |
|---|
| 429 | 424 | |
|---|
| 430 | 425 | static inline __le16 wil_rx_status_get_buff_id(void *msg) |
|---|
| .. | .. |
|---|
| 484 | 479 | return 0; /* use the default MID */ |
|---|
| 485 | 480 | |
|---|
| 486 | 481 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|
| 487 | | - 20, 21); |
|---|
| 482 | + 21, 22); |
|---|
| 488 | 483 | } |
|---|
| 489 | 484 | |
|---|
| 490 | 485 | static inline int wil_rx_status_get_error(void *msg) |
|---|
| .. | .. |
|---|
| 511 | 506 | 5, 6); |
|---|
| 512 | 507 | } |
|---|
| 513 | 508 | |
|---|
| 509 | +/* L4 L3 Expected result |
|---|
| 510 | + * 0 0 Ok. No L3 and no L4 known protocols found. |
|---|
| 511 | + * Treated as L2 packet. (no offloads on this packet) |
|---|
| 512 | + * 0 1 Ok. It means that L3 was found, and checksum check passed. |
|---|
| 513 | + * No known L4 protocol was found. |
|---|
| 514 | + * 0 2 It means that L3 protocol was found, and checksum check failed. |
|---|
| 515 | + * No L4 known protocol was found. |
|---|
| 516 | + * 1 any Ok. It means that L4 was found, and checksum check passed. |
|---|
| 517 | + * 3 0 Not a possible scenario. |
|---|
| 518 | + * 3 1 Recalculate. It means that L3 protocol was found, and checksum |
|---|
| 519 | + * passed. But L4 checksum failed. Need to see if really failed, |
|---|
| 520 | + * or due to fragmentation. |
|---|
| 521 | + * 3 2 Both L3 and L4 checksum check failed. |
|---|
| 522 | + */ |
|---|
| 523 | +static inline int wil_rx_status_get_checksum(void *msg, |
|---|
| 524 | + struct wil_net_stats *stats) |
|---|
| 525 | +{ |
|---|
| 526 | + int l3_rx_status = wil_rx_status_get_l3_rx_status(msg); |
|---|
| 527 | + int l4_rx_status = wil_rx_status_get_l4_rx_status(msg); |
|---|
| 528 | + |
|---|
| 529 | + if (l4_rx_status == 1) |
|---|
| 530 | + return CHECKSUM_UNNECESSARY; |
|---|
| 531 | + |
|---|
| 532 | + if (l4_rx_status == 0 && l3_rx_status == 1) |
|---|
| 533 | + return CHECKSUM_UNNECESSARY; |
|---|
| 534 | + |
|---|
| 535 | + if (l3_rx_status == 0 && l4_rx_status == 0) |
|---|
| 536 | + /* L2 packet */ |
|---|
| 537 | + return CHECKSUM_NONE; |
|---|
| 538 | + |
|---|
| 539 | + /* If HW reports bad checksum, let IP stack re-check it |
|---|
| 540 | + * For example, HW doesn't understand Microsoft IP stack that |
|---|
| 541 | + * mis-calculates TCP checksum - if it should be 0x0, |
|---|
| 542 | + * it writes 0xffff in violation of RFC 1624 |
|---|
| 543 | + */ |
|---|
| 544 | + stats->rx_csum_err++; |
|---|
| 545 | + return CHECKSUM_NONE; |
|---|
| 546 | +} |
|---|
| 547 | + |
|---|
| 514 | 548 | static inline int wil_rx_status_get_security(void *msg) |
|---|
| 515 | 549 | { |
|---|
| 516 | 550 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|