forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 958e46acc8e900e8569dd467c1af9b8d2d019394
kernel/drivers/net/wireless/ath/wil6210/txrx_edma.h
....@@ -1,17 +1,6 @@
1
+/* SPDX-License-Identifier: ISC */
12 /*
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.
154 */
165
176 #ifndef WIL6210_TXRX_EDMA_H
....@@ -23,9 +12,9 @@
2312 #define WIL_SRING_SIZE_ORDER_MIN (WIL_RING_SIZE_ORDER_MIN)
2413 #define WIL_SRING_SIZE_ORDER_MAX (WIL_RING_SIZE_ORDER_MAX)
2514 /* 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)
2918
3019 #define WIL_DEFAULT_RX_STATUS_RING_ID 0
3120 #define WIL_RX_DESC_RING_ID 0
....@@ -57,7 +46,7 @@
5746
5847 #define WIL_RX_EDMA_DLPF_LU_MISS_TID_POS 5
5948
60
-#define WIL_RX_EDMA_MID_VALID_BIT BIT(22)
49
+#define WIL_RX_EDMA_MID_VALID_BIT BIT(20)
6150
6251 #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_POS 16
6352 #define WIL_EDMA_DESC_TX_MAC_CFG_0_QID_LEN 6
....@@ -255,8 +244,8 @@
255244 * calculated, Bit1- L4Err - TCP/UDP Checksum Error
256245 * bit 7 : Reserved:1
257246 * 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
260249 * bit 23 : L3T:1 - IP types: 0-IPv6, 1-IPv4
261250 * bit 24 : L4T:1 - Layer 4 Type: 0-UDP, 1-TCP
262251 * bit 25 : BC:1 - The received MPDU is broadcast
....@@ -366,6 +355,12 @@
366355 16, 21);
367356 }
368357
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
+
369364 static inline u16 wil_rx_status_get_flow_id(void *msg)
370365 {
371366 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
....@@ -415,16 +410,16 @@
415410 return val & WIL_RX_EDMA_DLPF_LU_MISS_CID_TID_MASK;
416411 }
417412
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
-
424413 static inline int wil_rx_status_get_eop(void *msg) /* EoP = End of Packet */
425414 {
426415 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
427416 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;
428423 }
429424
430425 static inline __le16 wil_rx_status_get_buff_id(void *msg)
....@@ -484,7 +479,7 @@
484479 return 0; /* use the default MID */
485480
486481 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,
487
- 20, 21);
482
+ 21, 22);
488483 }
489484
490485 static inline int wil_rx_status_get_error(void *msg)
....@@ -511,6 +506,45 @@
511506 5, 6);
512507 }
513508
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
+
514548 static inline int wil_rx_status_get_security(void *msg)
515549 {
516550 return WIL_GET_BITS(((struct wil_rx_status_compressed *)msg)->d0,