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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
Date: Tue, 30 Oct 2018 13:25:36 -0400
From: linville@redhat.com
To: rhkernel-list@redhat.com
Cc: Lin Liu <linl@redhat.com>
Subject: [RHEL7 21/28] net: ena: explicit casting and initialization, and
 clearer error handling
 
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
 
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit bd791175a6432d24fc5d7b348304276027372545)
Signed-off-by: John W. Linville <linville@redhat.com>
---
 drivers/net/ethernet/amazon/ena/ena_com.c    | 39 ++++++++++++--------
 drivers/net/ethernet/amazon/ena/ena_netdev.c |  5 +--
 drivers/net/ethernet/amazon/ena/ena_netdev.h | 27 ++++++++------
 3 files changed, 40 insertions(+), 31 deletions(-)
 
diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index 5220c7578d6b..5c468b28723b 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -235,7 +235,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
     tail_masked = admin_queue->sq.tail & queue_size_mask;
 
     /* In case of queue FULL */
-    cnt = atomic_read(&admin_queue->outstanding_cmds);
+    cnt = (u16)atomic_read(&admin_queue->outstanding_cmds);
     if (cnt >= admin_queue->q_depth) {
         pr_debug("admin queue is full.\n");
         admin_queue->stats.out_of_space++;
@@ -304,7 +304,7 @@ static struct ena_comp_ctx *ena_com_submit_admin_cmd(struct ena_com_admin_queue
                              struct ena_admin_acq_entry *comp,
                              size_t comp_size_in_bytes)
 {
-    unsigned long flags;
+    unsigned long flags = 0;
     struct ena_comp_ctx *comp_ctx;
 
     spin_lock_irqsave(&admin_queue->q_lock, flags);
@@ -332,7 +332,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 
     memset(&io_sq->desc_addr, 0x0, sizeof(io_sq->desc_addr));
 
-    io_sq->dma_addr_bits = ena_dev->dma_addr_bits;
+    io_sq->dma_addr_bits = (u8)ena_dev->dma_addr_bits;
     io_sq->desc_entry_size =
         (io_sq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ?
         sizeof(struct ena_eth_io_tx_desc) :
@@ -486,7 +486,7 @@ static void ena_com_handle_admin_completion(struct ena_com_admin_queue *admin_qu
 
     /* Go over all the completions */
     while ((READ_ONCE(cqe->acq_common_descriptor.flags) &
-            ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK) == phase) {
+        ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK) == phase) {
         /* Do not read the rest of the completion entry before the
          * phase bit was validated
          */
@@ -537,7 +537,8 @@ static int ena_com_comp_status_to_errno(u8 comp_status)
 static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_ctx,
                              struct ena_com_admin_queue *admin_queue)
 {
-    unsigned long flags, timeout;
+    unsigned long flags = 0;
+    unsigned long timeout;
     int ret;
 
     timeout = jiffies + usecs_to_jiffies(admin_queue->completion_timeout);
@@ -736,7 +737,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *comp_ctx,
                             struct ena_com_admin_queue *admin_queue)
 {
-    unsigned long flags;
+    unsigned long flags = 0;
     int ret;
 
     wait_for_completion_timeout(&comp_ctx->wait_event,
@@ -782,7 +783,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
     volatile struct ena_admin_ena_mmio_req_read_less_resp *read_resp =
         mmio_read->read_resp;
     u32 mmio_read_reg, ret, i;
-    unsigned long flags;
+    unsigned long flags = 0;
     u32 timeout = mmio_read->reg_read_to;
 
     might_sleep();
@@ -1426,7 +1427,7 @@ void ena_com_abort_admin_commands(struct ena_com_dev *ena_dev)
 void ena_com_wait_for_abort_completion(struct ena_com_dev *ena_dev)
 {
     struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
-    unsigned long flags;
+    unsigned long flags = 0;
 
     spin_lock_irqsave(&admin_queue->q_lock, flags);
     while (atomic_read(&admin_queue->outstanding_cmds) != 0) {
@@ -1470,7 +1471,7 @@ bool ena_com_get_admin_running_state(struct ena_com_dev *ena_dev)
 void ena_com_set_admin_running_state(struct ena_com_dev *ena_dev, bool state)
 {
     struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
-    unsigned long flags;
+    unsigned long flags = 0;
 
     spin_lock_irqsave(&admin_queue->q_lock, flags);
     ena_dev->admin_queue.running_state = state;
@@ -1504,7 +1505,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
     }
 
     if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) {
-        pr_warn("Trying to set unsupported aenq events. supported flag: %x asked flag: %x\n",
+        pr_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
             get_resp.u.aenq.supported_groups, groups_flag);
         return -EOPNOTSUPP;
     }
@@ -1652,7 +1653,7 @@ int ena_com_mmio_reg_read_request_init(struct ena_com_dev *ena_dev)
                     sizeof(*mmio_read->read_resp),
                     &mmio_read->read_resp_dma_addr, GFP_KERNEL);
     if (unlikely(!mmio_read->read_resp))
-        return -ENOMEM;
+        goto err;
 
     ena_com_mmio_reg_read_request_write_dev_addr(ena_dev);
 
@@ -1661,6 +1662,10 @@ int ena_com_mmio_reg_read_request_init(struct ena_com_dev *ena_dev)
     mmio_read->readless_supported = true;
 
     return 0;
+
+err:
+
+    return -ENOMEM;
 }
 
 void ena_com_set_mmio_read_mode(struct ena_com_dev *ena_dev, bool readless_supported)
@@ -1961,6 +1966,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
     struct ena_admin_aenq_entry *aenq_e;
     struct ena_admin_aenq_common_desc *aenq_common;
     struct ena_com_aenq *aenq  = &dev->aenq;
+    unsigned long long timestamp;
     ena_aenq_handler handler_cb;
     u16 masked_head, processed = 0;
     u8 phase;
@@ -1978,10 +1984,11 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
          */
         dma_rmb();
 
+        timestamp =
+            (unsigned long long)aenq_common->timestamp_low |
+            ((unsigned long long)aenq_common->timestamp_high << 32);
         pr_debug("AENQ! Group[%x] Syndrom[%x] timestamp: [%llus]\n",
-             aenq_common->group, aenq_common->syndrom,
-             (u64)aenq_common->timestamp_low +
-                 ((u64)aenq_common->timestamp_high << 32));
+             aenq_common->group, aenq_common->syndrom, timestamp);
 
         /* Handle specific event*/
         handler_cb = ena_com_get_specific_aenq_cb(dev,
@@ -2623,8 +2630,8 @@ int ena_com_allocate_host_info(struct ena_com_dev *ena_dev)
     if (unlikely(!host_attr->host_info))
         return -ENOMEM;
 
-    host_attr->host_info->ena_spec_version =
-        ((ENA_COMMON_SPEC_VERSION_MAJOR << ENA_REGS_VERSION_MAJOR_VERSION_SHIFT) |
+    host_attr->host_info->ena_spec_version = ((ENA_COMMON_SPEC_VERSION_MAJOR <<
+        ENA_REGS_VERSION_MAJOR_VERSION_SHIFT) |
         (ENA_COMMON_SPEC_VERSION_MINOR));
 
     return 0;
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 4a318f351ab2..b11bb6f52d16 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2598,15 +2598,14 @@ static void ena_destroy_device(struct ena_adapter *adapter, bool graceful)
 
     dev_up = test_bit(ENA_FLAG_DEV_UP, &adapter->flags);
     adapter->dev_up_before_reset = dev_up;
-
     if (!graceful)
         ena_com_set_admin_running_state(ena_dev, false);
 
     if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags))
         ena_down(adapter);
 
-    /* Before releasing the ENA resources, a device reset is required.
-     * (to prevent the device from accessing them).
+    /* Stop the device from sending AENQ events (in case reset flag is set
+     *  and device is up, ena_close already reset the device
      * In case the reset flag is set and the device is up, ena_down()
      * already perform the reset, so it can be skipped.
      */
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index d9fc9c71215c..727d62cdfa90 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -58,7 +58,21 @@
 #define DEVICE_NAME    "Elastic Network Adapter (ENA)"
 
 /* 1 for AENQ + ADMIN */
-#define ENA_MAX_MSIX_VEC(io_queues)    (1 + (io_queues))
+#define ENA_ADMIN_MSIX_VEC        1
+#define ENA_MAX_MSIX_VEC(io_queues)    (ENA_ADMIN_MSIX_VEC + (io_queues))
+
+/* The ENA buffer length fields is 16 bit long. So when PAGE_SIZE == 64kB the
+ * driver passes 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
+
+#define ENA_MIN_MSIX_VEC        2
 
 #define ENA_REG_BAR            0
 #define ENA_MEM_BAR            2
@@ -360,15 +374,4 @@ 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