ena module for Driver Update Program
CentOS Sources
2019-01-09 fc384122a7a805dde4dbbf3c4c4ef94a5ca0f2fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
Date: Tue, 30 Oct 2018 13:25:35 -0400
From: linville@redhat.com
To: rhkernel-list@redhat.com
Cc: Lin Liu <linl@redhat.com>
Subject: [RHEL7 20/28] net: ena: use CSUM_CHECKED device indication to report
 skb's checksum status
 
From: "John W. Linville" <linville@redhat.com>
 
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1633418
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=18850510
 
Set skb->ip_summed to the correct value as reported by the device.
Add counter for the case where rx csum offload is enabled but
device didn't check it.
 
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit cb36bb36e1f17d2a7b9a9751e5cfec4235b46c93)
Signed-off-by: John W. Linville <linville@redhat.com>
---
 drivers/net/ethernet/amazon/ena/ena_eth_com.c     |  3 +++
 drivers/net/ethernet/amazon/ena/ena_eth_com.h     |  1 +
 drivers/net/ethernet/amazon/ena/ena_eth_io_defs.h | 10 ++++++++--
 drivers/net/ethernet/amazon/ena/ena_ethtool.c     |  1 +
 drivers/net/ethernet/amazon/ena/ena_netdev.c      | 13 ++++++++++++-
 drivers/net/ethernet/amazon/ena/ena_netdev.h      |  1 +
 6 files changed, 26 insertions(+), 3 deletions(-)
 
diff --git a/drivers/net/ethernet/amazon/ena/ena_eth_com.c b/drivers/net/ethernet/amazon/ena/ena_eth_com.c
index 17107ca107e3..f6c2d3855be8 100644
--- a/drivers/net/ethernet/amazon/ena/ena_eth_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_eth_com.c
@@ -354,6 +354,9 @@ static inline void ena_com_rx_set_flags(struct ena_com_rx_ctx *ena_rx_ctx,
     ena_rx_ctx->l4_csum_err =
         !!((cdesc->status & ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_ERR_MASK) >>
         ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_ERR_SHIFT);
+    ena_rx_ctx->l4_csum_checked =
+        !!((cdesc->status & ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_CHECKED_MASK) >>
+        ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_CHECKED_SHIFT);
     ena_rx_ctx->hash = cdesc->hash;
     ena_rx_ctx->frag =
         (cdesc->status & ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_MASK) >>
diff --git a/drivers/net/ethernet/amazon/ena/ena_eth_com.h b/drivers/net/ethernet/amazon/ena/ena_eth_com.h
index bcc84072367d..340d02b64ca6 100644
--- a/drivers/net/ethernet/amazon/ena/ena_eth_com.h
+++ b/drivers/net/ethernet/amazon/ena/ena_eth_com.h
@@ -67,6 +67,7 @@ struct ena_com_rx_ctx {
     enum ena_eth_io_l4_proto_index l4_proto;
     bool l3_csum_err;
     bool l4_csum_err;
+    u8 l4_csum_checked;
     /* fragmented packet */
     bool frag;
     u32 hash;
diff --git a/drivers/net/ethernet/amazon/ena/ena_eth_io_defs.h b/drivers/net/ethernet/amazon/ena/ena_eth_io_defs.h
index f320c58793a5..4c5ccaa13c42 100644
--- a/drivers/net/ethernet/amazon/ena/ena_eth_io_defs.h
+++ b/drivers/net/ethernet/amazon/ena/ena_eth_io_defs.h
@@ -242,9 +242,13 @@ struct ena_eth_io_rx_cdesc_base {
      *    checksum error detected, or, the controller didn't
      *    validate the checksum. This bit is valid only when
      *    l4_proto_idx indicates TCP/UDP packet, and,
-     *    ipv4_frag is not set
+     *    ipv4_frag is not set. This bit is valid only when
+     *    l4_csum_checked below is set.
      * 15 : ipv4_frag - Indicates IPv4 fragmented packet
-     * 23:16 : reserved16
+     * 16 : l4_csum_checked - L4 checksum was verified
+     *    (could be OK or error), when cleared the status of
+     *    checksum is unknown
+     * 23:17 : reserved17 - MBZ
      * 24 : phase
      * 25 : l3_csum2 - second checksum engine result
      * 26 : first - Indicates first descriptor in
@@ -390,6 +394,8 @@ struct ena_eth_io_numa_node_cfg_reg {
 #define ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_ERR_MASK BIT(14)
 #define ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_SHIFT 15
 #define ENA_ETH_IO_RX_CDESC_BASE_IPV4_FRAG_MASK BIT(15)
+#define ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_CHECKED_SHIFT 16
+#define ENA_ETH_IO_RX_CDESC_BASE_L4_CSUM_CHECKED_MASK BIT(16)
 #define ENA_ETH_IO_RX_CDESC_BASE_PHASE_SHIFT 24
 #define ENA_ETH_IO_RX_CDESC_BASE_PHASE_MASK BIT(24)
 #define ENA_ETH_IO_RX_CDESC_BASE_L3_CSUM2_SHIFT 25
diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
index 7643faaebb42..fd07122532f1 100644
--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
+++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
@@ -97,6 +97,7 @@ static const struct ena_stats ena_stats_rx_strings[] = {
     ENA_STAT_RX_ENTRY(rx_copybreak_pkt),
     ENA_STAT_RX_ENTRY(bad_req_id),
     ENA_STAT_RX_ENTRY(empty_rx_ring),
+    ENA_STAT_RX_ENTRY(csum_unchecked),
 };
 
 static const struct ena_stats ena_stats_ena_com_strings[] = {
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 3a1f7a89cf29..4a318f351ab2 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -996,8 +996,19 @@ static inline void ena_rx_checksum(struct ena_ring *rx_ring,
             return;
         }
 
-        skb->ip_summed = CHECKSUM_UNNECESSARY;
+        if (likely(ena_rx_ctx->l4_csum_checked)) {
+            skb->ip_summed = CHECKSUM_UNNECESSARY;
+        } else {
+            u64_stats_update_begin(&rx_ring->syncp);
+            rx_ring->rx_stats.csum_unchecked++;
+            u64_stats_update_end(&rx_ring->syncp);
+            skb->ip_summed = CHECKSUM_NONE;
+        }
+    } else {
+        skb->ip_summed = CHECKSUM_NONE;
+        return;
     }
+
 }
 
 static void ena_set_rx_hash(struct ena_ring *rx_ring,
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index 39b52db1de72..d9fc9c71215c 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -202,6 +202,7 @@ struct ena_stats_rx {
     u64 rx_copybreak_pkt;
     u64 bad_req_id;
     u64 empty_rx_ring;
+    u64 csum_unchecked;
 };
 
 struct ena_ring {
-- 
2.17.1