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
Date: Tue, 30 Oct 2018 13:25:19 -0400
From: linville@redhat.com
To: rhkernel-list@redhat.com
Cc: Lin Liu <linl@redhat.com>
Subject: [RHEL7 04/28] net: ena: fix driver when PAGE_SIZE == 64kB
 
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
 
The buffer length field in the ena rx descriptor is 16 bit, and the
current driver passes a full page in each ena rx descriptor.
When PAGE_SIZE equals 64kB or more, the buffer length field becomes
zero.
To solve this issue, limit the ena Rx descriptor to use 16kB even
when allocating 64kB kernel pages. This change would not impact ena
device functionality, as 16kB is still larger than maximum MTU.
 
Signed-off-by: Netanel Belgazal <netanel@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit ef5b0771d247379c90c8bf1332ff32f7f74bff7f)
Signed-off-by: John W. Linville <linville@redhat.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 10 +++++-----
 drivers/net/ethernet/amazon/ena/ena_netdev.h | 11 +++++++++++
 2 files changed, 16 insertions(+), 5 deletions(-)
 
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 9eb1e2da8a2d..773834b87a8c 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -461,7 +461,7 @@ static inline int ena_alloc_rx_page(struct ena_ring *rx_ring,
         return -ENOMEM;
     }
 
-    dma = dma_map_page(rx_ring->dev, page, 0, PAGE_SIZE,
+    dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE,
                DMA_FROM_DEVICE);
     if (unlikely(dma_mapping_error(rx_ring->dev, dma))) {
         u64_stats_update_begin(&rx_ring->syncp);
@@ -478,7 +478,7 @@ static inline int ena_alloc_rx_page(struct ena_ring *rx_ring,
     rx_info->page_offset = 0;
     ena_buf = &rx_info->ena_buf;
     ena_buf->paddr = dma;
-    ena_buf->len = PAGE_SIZE;
+    ena_buf->len = ENA_PAGE_SIZE;
 
     return 0;
 }
@@ -495,7 +495,7 @@ static void ena_free_rx_page(struct ena_ring *rx_ring,
         return;
     }
 
-    dma_unmap_page(rx_ring->dev, ena_buf->paddr, PAGE_SIZE,
+    dma_unmap_page(rx_ring->dev, ena_buf->paddr, ENA_PAGE_SIZE,
                DMA_FROM_DEVICE);
 
     __free_page(page);
@@ -917,10 +917,10 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
     do {
         dma_unmap_page(rx_ring->dev,
                    dma_unmap_addr(&rx_info->ena_buf, paddr),
-                   PAGE_SIZE, DMA_FROM_DEVICE);
+                   ENA_PAGE_SIZE, DMA_FROM_DEVICE);
 
         skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page,
-                rx_info->page_offset, len, PAGE_SIZE);
+                rx_info->page_offset, len, ENA_PAGE_SIZE);
 
         netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev,
               "rx skb updated. len %d. data_len %d\n",
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index 3b739f9d299b..c9c85332d134 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -353,4 +353,15 @@ void ena_dump_stats_to_buf(struct ena_adapter *adapter, u8 *buf);
 
 int ena_get_sset_count(struct net_device *netdev, int sset);
 
+/* The ENA buffer length fields is 16 bit long. So when PAGE_SIZE == 64kB the
+ * driver passas 0.
+ * Since the max packet size the ENA handles is ~9kB limit the buffer length to
+ * 16kB.
+ */
+#if PAGE_SIZE > SZ_16K
+#define ENA_PAGE_SIZE SZ_16K
+#else
+#define ENA_PAGE_SIZE PAGE_SIZE
+#endif
+
 #endif /* !(ENA_H) */
-- 
2.17.1