| .. | .. |
|---|
| 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 |
|---|
| .. | .. |
|---|
| 341 | 330 | u32 d0; |
|---|
| 342 | 331 | u32 d1; |
|---|
| 343 | 332 | __le16 seq_num; /* only lower 12 bits */ |
|---|
| 344 | | - u16 pn_15_0; |
|---|
| 345 | | - u32 pn_47_16; |
|---|
| 333 | + struct_group_attr(pn, __packed, |
|---|
| 334 | + u16 pn_15_0; |
|---|
| 335 | + u32 pn_47_16; |
|---|
| 336 | + ); |
|---|
| 346 | 337 | } __packed; |
|---|
| 347 | 338 | |
|---|
| 348 | 339 | struct wil_rx_status_extended { |
|---|
| .. | .. |
|---|
| 364 | 355 | { |
|---|
| 365 | 356 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1, |
|---|
| 366 | 357 | 16, 21); |
|---|
| 358 | +} |
|---|
| 359 | + |
|---|
| 360 | +static inline u8 wil_rx_status_get_cb_mode(void *msg) |
|---|
| 361 | +{ |
|---|
| 362 | + return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d1, |
|---|
| 363 | + 22, 23); |
|---|
| 367 | 364 | } |
|---|
| 368 | 365 | |
|---|
| 369 | 366 | static inline u16 wil_rx_status_get_flow_id(void *msg) |
|---|
| .. | .. |
|---|
| 415 | 412 | return val & WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK; |
|---|
| 416 | 413 | } |
|---|
| 417 | 414 | |
|---|
| 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 | 415 | static inline int wil_rx_status_get_eop(void *msg) /* EoP = End of Packet */ |
|---|
| 425 | 416 | { |
|---|
| 426 | 417 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|
| 427 | 418 | 30, 30); |
|---|
| 419 | +} |
|---|
| 420 | + |
|---|
| 421 | +static inline void wil_rx_status_reset_buff_id(struct wil_status_ring *s) |
|---|
| 422 | +{ |
|---|
| 423 | + ((struct wil_rx_status_compressed *) |
|---|
| 424 | + (s->va + (s->elem_size * s->swhead)))->buff_id = 0; |
|---|
| 428 | 425 | } |
|---|
| 429 | 426 | |
|---|
| 430 | 427 | static inline __le16 wil_rx_status_get_buff_id(void *msg) |
|---|
| .. | .. |
|---|
| 484 | 481 | return 0; /* use the default MID */ |
|---|
| 485 | 482 | |
|---|
| 486 | 483 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|
| 487 | | - 20, 21); |
|---|
| 484 | + 21, 22); |
|---|
| 488 | 485 | } |
|---|
| 489 | 486 | |
|---|
| 490 | 487 | static inline int wil_rx_status_get_error(void *msg) |
|---|
| .. | .. |
|---|
| 511 | 508 | 5, 6); |
|---|
| 512 | 509 | } |
|---|
| 513 | 510 | |
|---|
| 511 | +/* L4 L3 Expected result |
|---|
| 512 | + * 0 0 Ok. No L3 and no L4 known protocols found. |
|---|
| 513 | + * Treated as L2 packet. (no offloads on this packet) |
|---|
| 514 | + * 0 1 Ok. It means that L3 was found, and checksum check passed. |
|---|
| 515 | + * No known L4 protocol was found. |
|---|
| 516 | + * 0 2 It means that L3 protocol was found, and checksum check failed. |
|---|
| 517 | + * No L4 known protocol was found. |
|---|
| 518 | + * 1 any Ok. It means that L4 was found, and checksum check passed. |
|---|
| 519 | + * 3 0 Not a possible scenario. |
|---|
| 520 | + * 3 1 Recalculate. It means that L3 protocol was found, and checksum |
|---|
| 521 | + * passed. But L4 checksum failed. Need to see if really failed, |
|---|
| 522 | + * or due to fragmentation. |
|---|
| 523 | + * 3 2 Both L3 and L4 checksum check failed. |
|---|
| 524 | + */ |
|---|
| 525 | +static inline int wil_rx_status_get_checksum(void *msg, |
|---|
| 526 | + struct wil_net_stats *stats) |
|---|
| 527 | +{ |
|---|
| 528 | + int l3_rx_status = wil_rx_status_get_l3_rx_status(msg); |
|---|
| 529 | + int l4_rx_status = wil_rx_status_get_l4_rx_status(msg); |
|---|
| 530 | + |
|---|
| 531 | + if (l4_rx_status == 1) |
|---|
| 532 | + return CHECKSUM_UNNECESSARY; |
|---|
| 533 | + |
|---|
| 534 | + if (l4_rx_status == 0 && l3_rx_status == 1) |
|---|
| 535 | + return CHECKSUM_UNNECESSARY; |
|---|
| 536 | + |
|---|
| 537 | + if (l3_rx_status == 0 && l4_rx_status == 0) |
|---|
| 538 | + /* L2 packet */ |
|---|
| 539 | + return CHECKSUM_NONE; |
|---|
| 540 | + |
|---|
| 541 | + /* If HW reports bad checksum, let IP stack re-check it |
|---|
| 542 | + * For example, HW doesn't understand Microsoft IP stack that |
|---|
| 543 | + * mis-calculates TCP checksum - if it should be 0x0, |
|---|
| 544 | + * it writes 0xffff in violation of RFC 1624 |
|---|
| 545 | + */ |
|---|
| 546 | + stats->rx_csum_err++; |
|---|
| 547 | + return CHECKSUM_NONE; |
|---|
| 548 | +} |
|---|
| 549 | + |
|---|
| 514 | 550 | static inline int wil_rx_status_get_security(void *msg) |
|---|
| 515 | 551 | { |
|---|
| 516 | 552 | return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0, |
|---|