]>
Commit | Line | Data |
---|---|---|
5eae00c5 GR |
1 | /******************************************************************************* |
2 | * | |
3 | * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver | |
e1dfee8e | 4 | * Copyright(c) 2013 - 2014 Intel Corporation. |
5eae00c5 GR |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms and conditions of the GNU General Public License, | |
8 | * version 2, as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope it will be useful, but WITHOUT | |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
14 | * | |
b831607d JB |
15 | * You should have received a copy of the GNU General Public License along |
16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | * | |
5eae00c5 GR |
18 | * The full GNU General Public License is included in this distribution in |
19 | * the file called "COPYING". | |
20 | * | |
21 | * Contact Information: | |
22 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | |
23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
24 | * | |
25 | ******************************************************************************/ | |
26 | ||
27 | #include "i40evf.h" | |
28 | #include "i40e_prototype.h" | |
29 | static int i40evf_setup_all_tx_resources(struct i40evf_adapter *adapter); | |
30 | static int i40evf_setup_all_rx_resources(struct i40evf_adapter *adapter); | |
169f4076 MW |
31 | static void i40evf_free_all_tx_resources(struct i40evf_adapter *adapter); |
32 | static void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter); | |
5eae00c5 GR |
33 | static int i40evf_close(struct net_device *netdev); |
34 | ||
35 | char i40evf_driver_name[] = "i40evf"; | |
36 | static const char i40evf_driver_string[] = | |
0af56f44 | 37 | "Intel(R) XL710/X710 Virtual Function Network Driver"; |
5eae00c5 | 38 | |
a36fdd8e | 39 | #define DRV_VERSION "1.0.6" |
5eae00c5 GR |
40 | const char i40evf_driver_version[] = DRV_VERSION; |
41 | static const char i40evf_copyright[] = | |
673f2ebf | 42 | "Copyright (c) 2013 - 2014 Intel Corporation."; |
5eae00c5 GR |
43 | |
44 | /* i40evf_pci_tbl - PCI Device ID Table | |
45 | * | |
46 | * Wildcard entries (PCI_ANY_ID) should come last | |
47 | * Last entry must be all 0s | |
48 | * | |
49 | * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, | |
50 | * Class, Class Mask, private data (not used) } | |
51 | */ | |
9baa3c34 | 52 | static const struct pci_device_id i40evf_pci_tbl[] = { |
ab60085e | 53 | {PCI_VDEVICE(INTEL, I40E_DEV_ID_VF), 0}, |
5eae00c5 GR |
54 | /* required last entry */ |
55 | {0, } | |
56 | }; | |
57 | ||
58 | MODULE_DEVICE_TABLE(pci, i40evf_pci_tbl); | |
59 | ||
60 | MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); | |
61 | MODULE_DESCRIPTION("Intel(R) XL710 X710 Virtual Function Network Driver"); | |
62 | MODULE_LICENSE("GPL"); | |
63 | MODULE_VERSION(DRV_VERSION); | |
64 | ||
65 | /** | |
66 | * i40evf_allocate_dma_mem_d - OS specific memory alloc for shared code | |
67 | * @hw: pointer to the HW structure | |
68 | * @mem: ptr to mem struct to fill out | |
69 | * @size: size of memory requested | |
70 | * @alignment: what to align the allocation to | |
71 | **/ | |
72 | i40e_status i40evf_allocate_dma_mem_d(struct i40e_hw *hw, | |
73 | struct i40e_dma_mem *mem, | |
74 | u64 size, u32 alignment) | |
75 | { | |
76 | struct i40evf_adapter *adapter = (struct i40evf_adapter *)hw->back; | |
77 | ||
78 | if (!mem) | |
79 | return I40E_ERR_PARAM; | |
80 | ||
81 | mem->size = ALIGN(size, alignment); | |
82 | mem->va = dma_alloc_coherent(&adapter->pdev->dev, mem->size, | |
83 | (dma_addr_t *)&mem->pa, GFP_KERNEL); | |
84 | if (mem->va) | |
85 | return 0; | |
86 | else | |
87 | return I40E_ERR_NO_MEMORY; | |
88 | } | |
89 | ||
90 | /** | |
91 | * i40evf_free_dma_mem_d - OS specific memory free for shared code | |
92 | * @hw: pointer to the HW structure | |
93 | * @mem: ptr to mem struct to free | |
94 | **/ | |
95 | i40e_status i40evf_free_dma_mem_d(struct i40e_hw *hw, struct i40e_dma_mem *mem) | |
96 | { | |
97 | struct i40evf_adapter *adapter = (struct i40evf_adapter *)hw->back; | |
98 | ||
99 | if (!mem || !mem->va) | |
100 | return I40E_ERR_PARAM; | |
101 | dma_free_coherent(&adapter->pdev->dev, mem->size, | |
102 | mem->va, (dma_addr_t)mem->pa); | |
103 | return 0; | |
104 | } | |
105 | ||
106 | /** | |
107 | * i40evf_allocate_virt_mem_d - OS specific memory alloc for shared code | |
108 | * @hw: pointer to the HW structure | |
109 | * @mem: ptr to mem struct to fill out | |
110 | * @size: size of memory requested | |
111 | **/ | |
112 | i40e_status i40evf_allocate_virt_mem_d(struct i40e_hw *hw, | |
113 | struct i40e_virt_mem *mem, u32 size) | |
114 | { | |
115 | if (!mem) | |
116 | return I40E_ERR_PARAM; | |
117 | ||
118 | mem->size = size; | |
119 | mem->va = kzalloc(size, GFP_KERNEL); | |
120 | ||
121 | if (mem->va) | |
122 | return 0; | |
123 | else | |
124 | return I40E_ERR_NO_MEMORY; | |
125 | } | |
126 | ||
127 | /** | |
128 | * i40evf_free_virt_mem_d - OS specific memory free for shared code | |
129 | * @hw: pointer to the HW structure | |
130 | * @mem: ptr to mem struct to free | |
131 | **/ | |
132 | i40e_status i40evf_free_virt_mem_d(struct i40e_hw *hw, | |
133 | struct i40e_virt_mem *mem) | |
134 | { | |
135 | if (!mem) | |
136 | return I40E_ERR_PARAM; | |
137 | ||
138 | /* it's ok to kfree a NULL pointer */ | |
139 | kfree(mem->va); | |
140 | ||
141 | return 0; | |
142 | } | |
143 | ||
144 | /** | |
145 | * i40evf_debug_d - OS dependent version of debug printing | |
146 | * @hw: pointer to the HW structure | |
147 | * @mask: debug level mask | |
148 | * @fmt_str: printf-type format description | |
149 | **/ | |
150 | void i40evf_debug_d(void *hw, u32 mask, char *fmt_str, ...) | |
151 | { | |
152 | char buf[512]; | |
153 | va_list argptr; | |
154 | ||
155 | if (!(mask & ((struct i40e_hw *)hw)->debug_mask)) | |
156 | return; | |
157 | ||
158 | va_start(argptr, fmt_str); | |
159 | vsnprintf(buf, sizeof(buf), fmt_str, argptr); | |
160 | va_end(argptr); | |
161 | ||
162 | /* the debug string is already formatted with a newline */ | |
163 | pr_info("%s", buf); | |
164 | } | |
165 | ||
166 | /** | |
167 | * i40evf_tx_timeout - Respond to a Tx Hang | |
168 | * @netdev: network interface device structure | |
169 | **/ | |
170 | static void i40evf_tx_timeout(struct net_device *netdev) | |
171 | { | |
172 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
173 | ||
174 | adapter->tx_timeout_count++; | |
625777e3 | 175 | if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) { |
3526d800 | 176 | adapter->flags |= I40EVF_FLAG_RESET_NEEDED; |
625777e3 MW |
177 | schedule_work(&adapter->reset_task); |
178 | } | |
5eae00c5 GR |
179 | } |
180 | ||
181 | /** | |
182 | * i40evf_misc_irq_disable - Mask off interrupt generation on the NIC | |
183 | * @adapter: board private structure | |
184 | **/ | |
185 | static void i40evf_misc_irq_disable(struct i40evf_adapter *adapter) | |
186 | { | |
187 | struct i40e_hw *hw = &adapter->hw; | |
75a64435 | 188 | |
5eae00c5 GR |
189 | wr32(hw, I40E_VFINT_DYN_CTL01, 0); |
190 | ||
191 | /* read flush */ | |
192 | rd32(hw, I40E_VFGEN_RSTAT); | |
193 | ||
194 | synchronize_irq(adapter->msix_entries[0].vector); | |
195 | } | |
196 | ||
197 | /** | |
198 | * i40evf_misc_irq_enable - Enable default interrupt generation settings | |
199 | * @adapter: board private structure | |
200 | **/ | |
201 | static void i40evf_misc_irq_enable(struct i40evf_adapter *adapter) | |
202 | { | |
203 | struct i40e_hw *hw = &adapter->hw; | |
75a64435 | 204 | |
5eae00c5 GR |
205 | wr32(hw, I40E_VFINT_DYN_CTL01, I40E_VFINT_DYN_CTL01_INTENA_MASK | |
206 | I40E_VFINT_DYN_CTL01_ITR_INDX_MASK); | |
207 | wr32(hw, I40E_VFINT_ICR0_ENA1, I40E_VFINT_ICR0_ENA_ADMINQ_MASK); | |
208 | ||
209 | /* read flush */ | |
210 | rd32(hw, I40E_VFGEN_RSTAT); | |
211 | } | |
212 | ||
213 | /** | |
214 | * i40evf_irq_disable - Mask off interrupt generation on the NIC | |
215 | * @adapter: board private structure | |
216 | **/ | |
217 | static void i40evf_irq_disable(struct i40evf_adapter *adapter) | |
218 | { | |
219 | int i; | |
220 | struct i40e_hw *hw = &adapter->hw; | |
221 | ||
dbb01c8a MW |
222 | if (!adapter->msix_entries) |
223 | return; | |
224 | ||
5eae00c5 GR |
225 | for (i = 1; i < adapter->num_msix_vectors; i++) { |
226 | wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), 0); | |
227 | synchronize_irq(adapter->msix_entries[i].vector); | |
228 | } | |
229 | /* read flush */ | |
230 | rd32(hw, I40E_VFGEN_RSTAT); | |
5eae00c5 GR |
231 | } |
232 | ||
233 | /** | |
234 | * i40evf_irq_enable_queues - Enable interrupt for specified queues | |
235 | * @adapter: board private structure | |
236 | * @mask: bitmap of queues to enable | |
237 | **/ | |
238 | void i40evf_irq_enable_queues(struct i40evf_adapter *adapter, u32 mask) | |
239 | { | |
240 | struct i40e_hw *hw = &adapter->hw; | |
241 | int i; | |
242 | ||
243 | for (i = 1; i < adapter->num_msix_vectors; i++) { | |
244 | if (mask & (1 << (i - 1))) { | |
245 | wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), | |
246 | I40E_VFINT_DYN_CTLN1_INTENA_MASK | | |
247 | I40E_VFINT_DYN_CTLN_CLEARPBA_MASK); | |
248 | } | |
249 | } | |
250 | } | |
251 | ||
252 | /** | |
253 | * i40evf_fire_sw_int - Generate SW interrupt for specified vectors | |
254 | * @adapter: board private structure | |
255 | * @mask: bitmap of vectors to trigger | |
256 | **/ | |
75a64435 | 257 | static void i40evf_fire_sw_int(struct i40evf_adapter *adapter, u32 mask) |
5eae00c5 GR |
258 | { |
259 | struct i40e_hw *hw = &adapter->hw; | |
260 | int i; | |
261 | uint32_t dyn_ctl; | |
262 | ||
164ec1bf MW |
263 | if (mask & 1) { |
264 | dyn_ctl = rd32(hw, I40E_VFINT_DYN_CTL01); | |
265 | dyn_ctl |= I40E_VFINT_DYN_CTLN_SWINT_TRIG_MASK | | |
266 | I40E_VFINT_DYN_CTLN_CLEARPBA_MASK; | |
267 | wr32(hw, I40E_VFINT_DYN_CTL01, dyn_ctl); | |
268 | } | |
5eae00c5 GR |
269 | for (i = 1; i < adapter->num_msix_vectors; i++) { |
270 | if (mask & (1 << i)) { | |
271 | dyn_ctl = rd32(hw, I40E_VFINT_DYN_CTLN1(i - 1)); | |
272 | dyn_ctl |= I40E_VFINT_DYN_CTLN_SWINT_TRIG_MASK | | |
273 | I40E_VFINT_DYN_CTLN_CLEARPBA_MASK; | |
274 | wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), dyn_ctl); | |
275 | } | |
276 | } | |
277 | } | |
278 | ||
279 | /** | |
280 | * i40evf_irq_enable - Enable default interrupt generation settings | |
281 | * @adapter: board private structure | |
282 | **/ | |
283 | void i40evf_irq_enable(struct i40evf_adapter *adapter, bool flush) | |
284 | { | |
285 | struct i40e_hw *hw = &adapter->hw; | |
286 | ||
164ec1bf | 287 | i40evf_misc_irq_enable(adapter); |
5eae00c5 GR |
288 | i40evf_irq_enable_queues(adapter, ~0); |
289 | ||
290 | if (flush) | |
291 | rd32(hw, I40E_VFGEN_RSTAT); | |
292 | } | |
293 | ||
294 | /** | |
295 | * i40evf_msix_aq - Interrupt handler for vector 0 | |
296 | * @irq: interrupt number | |
297 | * @data: pointer to netdev | |
298 | **/ | |
299 | static irqreturn_t i40evf_msix_aq(int irq, void *data) | |
300 | { | |
301 | struct net_device *netdev = data; | |
302 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
303 | struct i40e_hw *hw = &adapter->hw; | |
304 | u32 val; | |
305 | u32 ena_mask; | |
306 | ||
307 | /* handle non-queue interrupts */ | |
308 | val = rd32(hw, I40E_VFINT_ICR01); | |
309 | ena_mask = rd32(hw, I40E_VFINT_ICR0_ENA1); | |
310 | ||
311 | ||
312 | val = rd32(hw, I40E_VFINT_DYN_CTL01); | |
313 | val = val | I40E_PFINT_DYN_CTL0_CLEARPBA_MASK; | |
314 | wr32(hw, I40E_VFINT_DYN_CTL01, val); | |
315 | ||
316 | /* re-enable interrupt causes */ | |
317 | wr32(hw, I40E_VFINT_ICR0_ENA1, ena_mask); | |
318 | wr32(hw, I40E_VFINT_DYN_CTL01, I40E_VFINT_DYN_CTL01_INTENA_MASK); | |
319 | ||
320 | /* schedule work on the private workqueue */ | |
321 | schedule_work(&adapter->adminq_task); | |
322 | ||
323 | return IRQ_HANDLED; | |
324 | } | |
325 | ||
326 | /** | |
327 | * i40evf_msix_clean_rings - MSIX mode Interrupt Handler | |
328 | * @irq: interrupt number | |
329 | * @data: pointer to a q_vector | |
330 | **/ | |
331 | static irqreturn_t i40evf_msix_clean_rings(int irq, void *data) | |
332 | { | |
333 | struct i40e_q_vector *q_vector = data; | |
334 | ||
335 | if (!q_vector->tx.ring && !q_vector->rx.ring) | |
336 | return IRQ_HANDLED; | |
337 | ||
338 | napi_schedule(&q_vector->napi); | |
339 | ||
340 | return IRQ_HANDLED; | |
341 | } | |
342 | ||
343 | /** | |
344 | * i40evf_map_vector_to_rxq - associate irqs with rx queues | |
345 | * @adapter: board private structure | |
346 | * @v_idx: interrupt number | |
347 | * @r_idx: queue number | |
348 | **/ | |
349 | static void | |
350 | i40evf_map_vector_to_rxq(struct i40evf_adapter *adapter, int v_idx, int r_idx) | |
351 | { | |
352 | struct i40e_q_vector *q_vector = adapter->q_vector[v_idx]; | |
353 | struct i40e_ring *rx_ring = adapter->rx_rings[r_idx]; | |
354 | ||
355 | rx_ring->q_vector = q_vector; | |
356 | rx_ring->next = q_vector->rx.ring; | |
357 | rx_ring->vsi = &adapter->vsi; | |
358 | q_vector->rx.ring = rx_ring; | |
359 | q_vector->rx.count++; | |
360 | q_vector->rx.latency_range = I40E_LOW_LATENCY; | |
361 | } | |
362 | ||
363 | /** | |
364 | * i40evf_map_vector_to_txq - associate irqs with tx queues | |
365 | * @adapter: board private structure | |
366 | * @v_idx: interrupt number | |
367 | * @t_idx: queue number | |
368 | **/ | |
369 | static void | |
370 | i40evf_map_vector_to_txq(struct i40evf_adapter *adapter, int v_idx, int t_idx) | |
371 | { | |
372 | struct i40e_q_vector *q_vector = adapter->q_vector[v_idx]; | |
373 | struct i40e_ring *tx_ring = adapter->tx_rings[t_idx]; | |
374 | ||
375 | tx_ring->q_vector = q_vector; | |
376 | tx_ring->next = q_vector->tx.ring; | |
377 | tx_ring->vsi = &adapter->vsi; | |
378 | q_vector->tx.ring = tx_ring; | |
379 | q_vector->tx.count++; | |
380 | q_vector->tx.latency_range = I40E_LOW_LATENCY; | |
381 | q_vector->num_ringpairs++; | |
382 | q_vector->ring_mask |= (1 << t_idx); | |
383 | } | |
384 | ||
385 | /** | |
386 | * i40evf_map_rings_to_vectors - Maps descriptor rings to vectors | |
387 | * @adapter: board private structure to initialize | |
388 | * | |
389 | * This function maps descriptor rings to the queue-specific vectors | |
390 | * we were allotted through the MSI-X enabling code. Ideally, we'd have | |
391 | * one vector per ring/queue, but on a constrained vector budget, we | |
392 | * group the rings as "efficiently" as possible. You would add new | |
393 | * mapping configurations in here. | |
394 | **/ | |
395 | static int i40evf_map_rings_to_vectors(struct i40evf_adapter *adapter) | |
396 | { | |
397 | int q_vectors; | |
398 | int v_start = 0; | |
399 | int rxr_idx = 0, txr_idx = 0; | |
cc052927 MW |
400 | int rxr_remaining = adapter->num_active_queues; |
401 | int txr_remaining = adapter->num_active_queues; | |
5eae00c5 GR |
402 | int i, j; |
403 | int rqpv, tqpv; | |
404 | int err = 0; | |
405 | ||
406 | q_vectors = adapter->num_msix_vectors - NONQ_VECS; | |
407 | ||
408 | /* The ideal configuration... | |
409 | * We have enough vectors to map one per queue. | |
410 | */ | |
411 | if (q_vectors == (rxr_remaining * 2)) { | |
412 | for (; rxr_idx < rxr_remaining; v_start++, rxr_idx++) | |
413 | i40evf_map_vector_to_rxq(adapter, v_start, rxr_idx); | |
414 | ||
415 | for (; txr_idx < txr_remaining; v_start++, txr_idx++) | |
416 | i40evf_map_vector_to_txq(adapter, v_start, txr_idx); | |
417 | goto out; | |
418 | } | |
419 | ||
420 | /* If we don't have enough vectors for a 1-to-1 | |
421 | * mapping, we'll have to group them so there are | |
422 | * multiple queues per vector. | |
423 | * Re-adjusting *qpv takes care of the remainder. | |
424 | */ | |
425 | for (i = v_start; i < q_vectors; i++) { | |
426 | rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - i); | |
427 | for (j = 0; j < rqpv; j++) { | |
428 | i40evf_map_vector_to_rxq(adapter, i, rxr_idx); | |
429 | rxr_idx++; | |
430 | rxr_remaining--; | |
431 | } | |
432 | } | |
433 | for (i = v_start; i < q_vectors; i++) { | |
434 | tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - i); | |
435 | for (j = 0; j < tqpv; j++) { | |
436 | i40evf_map_vector_to_txq(adapter, i, txr_idx); | |
437 | txr_idx++; | |
438 | txr_remaining--; | |
439 | } | |
440 | } | |
441 | ||
442 | out: | |
443 | adapter->aq_required |= I40EVF_FLAG_AQ_MAP_VECTORS; | |
444 | ||
445 | return err; | |
446 | } | |
447 | ||
448 | /** | |
449 | * i40evf_request_traffic_irqs - Initialize MSI-X interrupts | |
450 | * @adapter: board private structure | |
451 | * | |
452 | * Allocates MSI-X vectors for tx and rx handling, and requests | |
453 | * interrupts from the kernel. | |
454 | **/ | |
455 | static int | |
456 | i40evf_request_traffic_irqs(struct i40evf_adapter *adapter, char *basename) | |
457 | { | |
458 | int vector, err, q_vectors; | |
459 | int rx_int_idx = 0, tx_int_idx = 0; | |
460 | ||
461 | i40evf_irq_disable(adapter); | |
462 | /* Decrement for Other and TCP Timer vectors */ | |
463 | q_vectors = adapter->num_msix_vectors - NONQ_VECS; | |
464 | ||
465 | for (vector = 0; vector < q_vectors; vector++) { | |
466 | struct i40e_q_vector *q_vector = adapter->q_vector[vector]; | |
467 | ||
468 | if (q_vector->tx.ring && q_vector->rx.ring) { | |
469 | snprintf(q_vector->name, sizeof(q_vector->name) - 1, | |
470 | "i40evf-%s-%s-%d", basename, | |
471 | "TxRx", rx_int_idx++); | |
472 | tx_int_idx++; | |
473 | } else if (q_vector->rx.ring) { | |
474 | snprintf(q_vector->name, sizeof(q_vector->name) - 1, | |
475 | "i40evf-%s-%s-%d", basename, | |
476 | "rx", rx_int_idx++); | |
477 | } else if (q_vector->tx.ring) { | |
478 | snprintf(q_vector->name, sizeof(q_vector->name) - 1, | |
479 | "i40evf-%s-%s-%d", basename, | |
480 | "tx", tx_int_idx++); | |
481 | } else { | |
482 | /* skip this unused q_vector */ | |
483 | continue; | |
484 | } | |
485 | err = request_irq( | |
486 | adapter->msix_entries[vector + NONQ_VECS].vector, | |
487 | i40evf_msix_clean_rings, | |
488 | 0, | |
489 | q_vector->name, | |
490 | q_vector); | |
491 | if (err) { | |
492 | dev_info(&adapter->pdev->dev, | |
493 | "%s: request_irq failed, error: %d\n", | |
494 | __func__, err); | |
495 | goto free_queue_irqs; | |
496 | } | |
497 | /* assign the mask for this irq */ | |
498 | irq_set_affinity_hint( | |
499 | adapter->msix_entries[vector + NONQ_VECS].vector, | |
500 | q_vector->affinity_mask); | |
501 | } | |
502 | ||
503 | return 0; | |
504 | ||
505 | free_queue_irqs: | |
506 | while (vector) { | |
507 | vector--; | |
508 | irq_set_affinity_hint( | |
509 | adapter->msix_entries[vector + NONQ_VECS].vector, | |
510 | NULL); | |
511 | free_irq(adapter->msix_entries[vector + NONQ_VECS].vector, | |
512 | adapter->q_vector[vector]); | |
513 | } | |
514 | return err; | |
515 | } | |
516 | ||
517 | /** | |
518 | * i40evf_request_misc_irq - Initialize MSI-X interrupts | |
519 | * @adapter: board private structure | |
520 | * | |
521 | * Allocates MSI-X vector 0 and requests interrupts from the kernel. This | |
522 | * vector is only for the admin queue, and stays active even when the netdev | |
523 | * is closed. | |
524 | **/ | |
525 | static int i40evf_request_misc_irq(struct i40evf_adapter *adapter) | |
526 | { | |
527 | struct net_device *netdev = adapter->netdev; | |
528 | int err; | |
529 | ||
b39c1e2c JB |
530 | snprintf(adapter->misc_vector_name, |
531 | sizeof(adapter->misc_vector_name) - 1, "i40evf:mbx"); | |
5eae00c5 | 532 | err = request_irq(adapter->msix_entries[0].vector, |
e1dfee8e MW |
533 | &i40evf_msix_aq, 0, |
534 | adapter->misc_vector_name, netdev); | |
5eae00c5 GR |
535 | if (err) { |
536 | dev_err(&adapter->pdev->dev, | |
77fa28be CS |
537 | "request_irq for %s failed: %d\n", |
538 | adapter->misc_vector_name, err); | |
5eae00c5 GR |
539 | free_irq(adapter->msix_entries[0].vector, netdev); |
540 | } | |
541 | return err; | |
542 | } | |
543 | ||
544 | /** | |
545 | * i40evf_free_traffic_irqs - Free MSI-X interrupts | |
546 | * @adapter: board private structure | |
547 | * | |
548 | * Frees all MSI-X vectors other than 0. | |
549 | **/ | |
550 | static void i40evf_free_traffic_irqs(struct i40evf_adapter *adapter) | |
551 | { | |
552 | int i; | |
553 | int q_vectors; | |
75a64435 | 554 | |
5eae00c5 GR |
555 | q_vectors = adapter->num_msix_vectors - NONQ_VECS; |
556 | ||
557 | for (i = 0; i < q_vectors; i++) { | |
558 | irq_set_affinity_hint(adapter->msix_entries[i+1].vector, | |
559 | NULL); | |
560 | free_irq(adapter->msix_entries[i+1].vector, | |
561 | adapter->q_vector[i]); | |
562 | } | |
563 | } | |
564 | ||
565 | /** | |
566 | * i40evf_free_misc_irq - Free MSI-X miscellaneous vector | |
567 | * @adapter: board private structure | |
568 | * | |
569 | * Frees MSI-X vector 0. | |
570 | **/ | |
571 | static void i40evf_free_misc_irq(struct i40evf_adapter *adapter) | |
572 | { | |
573 | struct net_device *netdev = adapter->netdev; | |
574 | ||
575 | free_irq(adapter->msix_entries[0].vector, netdev); | |
576 | } | |
577 | ||
578 | /** | |
579 | * i40evf_configure_tx - Configure Transmit Unit after Reset | |
580 | * @adapter: board private structure | |
581 | * | |
582 | * Configure the Tx unit of the MAC after a reset. | |
583 | **/ | |
584 | static void i40evf_configure_tx(struct i40evf_adapter *adapter) | |
585 | { | |
586 | struct i40e_hw *hw = &adapter->hw; | |
587 | int i; | |
75a64435 | 588 | |
cc052927 | 589 | for (i = 0; i < adapter->num_active_queues; i++) |
5eae00c5 GR |
590 | adapter->tx_rings[i]->tail = hw->hw_addr + I40E_QTX_TAIL1(i); |
591 | } | |
592 | ||
593 | /** | |
594 | * i40evf_configure_rx - Configure Receive Unit after Reset | |
595 | * @adapter: board private structure | |
596 | * | |
597 | * Configure the Rx unit of the MAC after a reset. | |
598 | **/ | |
599 | static void i40evf_configure_rx(struct i40evf_adapter *adapter) | |
600 | { | |
601 | struct i40e_hw *hw = &adapter->hw; | |
602 | struct net_device *netdev = adapter->netdev; | |
603 | int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; | |
604 | int i; | |
605 | int rx_buf_len; | |
606 | ||
607 | ||
608 | adapter->flags &= ~I40EVF_FLAG_RX_PS_CAPABLE; | |
609 | adapter->flags |= I40EVF_FLAG_RX_1BUF_CAPABLE; | |
610 | ||
611 | /* Decide whether to use packet split mode or not */ | |
612 | if (netdev->mtu > ETH_DATA_LEN) { | |
613 | if (adapter->flags & I40EVF_FLAG_RX_PS_CAPABLE) | |
614 | adapter->flags |= I40EVF_FLAG_RX_PS_ENABLED; | |
615 | else | |
616 | adapter->flags &= ~I40EVF_FLAG_RX_PS_ENABLED; | |
617 | } else { | |
618 | if (adapter->flags & I40EVF_FLAG_RX_1BUF_CAPABLE) | |
619 | adapter->flags &= ~I40EVF_FLAG_RX_PS_ENABLED; | |
620 | else | |
621 | adapter->flags |= I40EVF_FLAG_RX_PS_ENABLED; | |
622 | } | |
623 | ||
624 | /* Set the RX buffer length according to the mode */ | |
625 | if (adapter->flags & I40EVF_FLAG_RX_PS_ENABLED) { | |
626 | rx_buf_len = I40E_RX_HDR_SIZE; | |
627 | } else { | |
628 | if (netdev->mtu <= ETH_DATA_LEN) | |
629 | rx_buf_len = I40EVF_RXBUFFER_2048; | |
630 | else | |
631 | rx_buf_len = ALIGN(max_frame, 1024); | |
632 | } | |
633 | ||
cc052927 | 634 | for (i = 0; i < adapter->num_active_queues; i++) { |
5eae00c5 GR |
635 | adapter->rx_rings[i]->tail = hw->hw_addr + I40E_QRX_TAIL1(i); |
636 | adapter->rx_rings[i]->rx_buf_len = rx_buf_len; | |
637 | } | |
638 | } | |
639 | ||
640 | /** | |
641 | * i40evf_find_vlan - Search filter list for specific vlan filter | |
642 | * @adapter: board private structure | |
643 | * @vlan: vlan tag | |
644 | * | |
645 | * Returns ptr to the filter object or NULL | |
646 | **/ | |
647 | static struct | |
648 | i40evf_vlan_filter *i40evf_find_vlan(struct i40evf_adapter *adapter, u16 vlan) | |
649 | { | |
650 | struct i40evf_vlan_filter *f; | |
651 | ||
652 | list_for_each_entry(f, &adapter->vlan_filter_list, list) { | |
653 | if (vlan == f->vlan) | |
654 | return f; | |
655 | } | |
656 | return NULL; | |
657 | } | |
658 | ||
659 | /** | |
660 | * i40evf_add_vlan - Add a vlan filter to the list | |
661 | * @adapter: board private structure | |
662 | * @vlan: VLAN tag | |
663 | * | |
664 | * Returns ptr to the filter object or NULL when no memory available. | |
665 | **/ | |
666 | static struct | |
667 | i40evf_vlan_filter *i40evf_add_vlan(struct i40evf_adapter *adapter, u16 vlan) | |
668 | { | |
669 | struct i40evf_vlan_filter *f; | |
670 | ||
671 | f = i40evf_find_vlan(adapter, vlan); | |
348d4994 | 672 | if (!f) { |
5eae00c5 | 673 | f = kzalloc(sizeof(*f), GFP_ATOMIC); |
348d4994 | 674 | if (!f) |
5eae00c5 | 675 | return NULL; |
249c8b8d | 676 | |
5eae00c5 GR |
677 | f->vlan = vlan; |
678 | ||
679 | INIT_LIST_HEAD(&f->list); | |
680 | list_add(&f->list, &adapter->vlan_filter_list); | |
681 | f->add = true; | |
682 | adapter->aq_required |= I40EVF_FLAG_AQ_ADD_VLAN_FILTER; | |
683 | } | |
684 | ||
685 | return f; | |
686 | } | |
687 | ||
688 | /** | |
689 | * i40evf_del_vlan - Remove a vlan filter from the list | |
690 | * @adapter: board private structure | |
691 | * @vlan: VLAN tag | |
692 | **/ | |
693 | static void i40evf_del_vlan(struct i40evf_adapter *adapter, u16 vlan) | |
694 | { | |
695 | struct i40evf_vlan_filter *f; | |
696 | ||
697 | f = i40evf_find_vlan(adapter, vlan); | |
698 | if (f) { | |
699 | f->remove = true; | |
700 | adapter->aq_required |= I40EVF_FLAG_AQ_DEL_VLAN_FILTER; | |
701 | } | |
5eae00c5 GR |
702 | } |
703 | ||
704 | /** | |
705 | * i40evf_vlan_rx_add_vid - Add a VLAN filter to a device | |
706 | * @netdev: network device struct | |
707 | * @vid: VLAN tag | |
708 | **/ | |
709 | static int i40evf_vlan_rx_add_vid(struct net_device *netdev, | |
75a64435 | 710 | __always_unused __be16 proto, u16 vid) |
5eae00c5 GR |
711 | { |
712 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
713 | ||
714 | if (i40evf_add_vlan(adapter, vid) == NULL) | |
715 | return -ENOMEM; | |
716 | return 0; | |
717 | } | |
718 | ||
719 | /** | |
720 | * i40evf_vlan_rx_kill_vid - Remove a VLAN filter from a device | |
721 | * @netdev: network device struct | |
722 | * @vid: VLAN tag | |
723 | **/ | |
724 | static int i40evf_vlan_rx_kill_vid(struct net_device *netdev, | |
75a64435 | 725 | __always_unused __be16 proto, u16 vid) |
5eae00c5 GR |
726 | { |
727 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
728 | ||
729 | i40evf_del_vlan(adapter, vid); | |
730 | return 0; | |
731 | } | |
732 | ||
733 | /** | |
734 | * i40evf_find_filter - Search filter list for specific mac filter | |
735 | * @adapter: board private structure | |
736 | * @macaddr: the MAC address | |
737 | * | |
738 | * Returns ptr to the filter object or NULL | |
739 | **/ | |
740 | static struct | |
741 | i40evf_mac_filter *i40evf_find_filter(struct i40evf_adapter *adapter, | |
742 | u8 *macaddr) | |
743 | { | |
744 | struct i40evf_mac_filter *f; | |
745 | ||
746 | if (!macaddr) | |
747 | return NULL; | |
748 | ||
749 | list_for_each_entry(f, &adapter->mac_filter_list, list) { | |
750 | if (ether_addr_equal(macaddr, f->macaddr)) | |
751 | return f; | |
752 | } | |
753 | return NULL; | |
754 | } | |
755 | ||
756 | /** | |
757 | * i40e_add_filter - Add a mac filter to the filter list | |
758 | * @adapter: board private structure | |
759 | * @macaddr: the MAC address | |
760 | * | |
761 | * Returns ptr to the filter object or NULL when no memory available. | |
762 | **/ | |
763 | static struct | |
764 | i40evf_mac_filter *i40evf_add_filter(struct i40evf_adapter *adapter, | |
765 | u8 *macaddr) | |
766 | { | |
767 | struct i40evf_mac_filter *f; | |
768 | ||
769 | if (!macaddr) | |
770 | return NULL; | |
771 | ||
772 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, | |
773 | &adapter->crit_section)) | |
b65476cd | 774 | udelay(1); |
5eae00c5 GR |
775 | |
776 | f = i40evf_find_filter(adapter, macaddr); | |
348d4994 | 777 | if (!f) { |
5eae00c5 | 778 | f = kzalloc(sizeof(*f), GFP_ATOMIC); |
348d4994 | 779 | if (!f) { |
5eae00c5 GR |
780 | clear_bit(__I40EVF_IN_CRITICAL_TASK, |
781 | &adapter->crit_section); | |
782 | return NULL; | |
783 | } | |
784 | ||
9a173901 | 785 | ether_addr_copy(f->macaddr, macaddr); |
5eae00c5 GR |
786 | |
787 | list_add(&f->list, &adapter->mac_filter_list); | |
788 | f->add = true; | |
789 | adapter->aq_required |= I40EVF_FLAG_AQ_ADD_MAC_FILTER; | |
790 | } | |
791 | ||
792 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); | |
793 | return f; | |
794 | } | |
795 | ||
796 | /** | |
797 | * i40evf_set_mac - NDO callback to set port mac address | |
798 | * @netdev: network interface device structure | |
799 | * @p: pointer to an address structure | |
800 | * | |
801 | * Returns 0 on success, negative on failure | |
802 | **/ | |
803 | static int i40evf_set_mac(struct net_device *netdev, void *p) | |
804 | { | |
805 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
806 | struct i40e_hw *hw = &adapter->hw; | |
807 | struct i40evf_mac_filter *f; | |
808 | struct sockaddr *addr = p; | |
809 | ||
810 | if (!is_valid_ether_addr(addr->sa_data)) | |
811 | return -EADDRNOTAVAIL; | |
812 | ||
813 | if (ether_addr_equal(netdev->dev_addr, addr->sa_data)) | |
814 | return 0; | |
815 | ||
816 | f = i40evf_add_filter(adapter, addr->sa_data); | |
817 | if (f) { | |
9a173901 GR |
818 | ether_addr_copy(hw->mac.addr, addr->sa_data); |
819 | ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr); | |
5eae00c5 GR |
820 | } |
821 | ||
822 | return (f == NULL) ? -ENOMEM : 0; | |
823 | } | |
824 | ||
825 | /** | |
826 | * i40evf_set_rx_mode - NDO callback to set the netdev filters | |
827 | * @netdev: network interface device structure | |
828 | **/ | |
829 | static void i40evf_set_rx_mode(struct net_device *netdev) | |
830 | { | |
831 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
832 | struct i40evf_mac_filter *f, *ftmp; | |
833 | struct netdev_hw_addr *uca; | |
834 | struct netdev_hw_addr *mca; | |
835 | ||
836 | /* add addr if not already in the filter list */ | |
837 | netdev_for_each_uc_addr(uca, netdev) { | |
838 | i40evf_add_filter(adapter, uca->addr); | |
839 | } | |
840 | netdev_for_each_mc_addr(mca, netdev) { | |
841 | i40evf_add_filter(adapter, mca->addr); | |
842 | } | |
843 | ||
844 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, | |
845 | &adapter->crit_section)) | |
b65476cd | 846 | udelay(1); |
5eae00c5 GR |
847 | /* remove filter if not in netdev list */ |
848 | list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { | |
849 | bool found = false; | |
850 | ||
dc5f2de6 | 851 | if (is_multicast_ether_addr(f->macaddr)) { |
5eae00c5 GR |
852 | netdev_for_each_mc_addr(mca, netdev) { |
853 | if (ether_addr_equal(mca->addr, f->macaddr)) { | |
854 | found = true; | |
855 | break; | |
856 | } | |
857 | } | |
858 | } else { | |
859 | netdev_for_each_uc_addr(uca, netdev) { | |
860 | if (ether_addr_equal(uca->addr, f->macaddr)) { | |
861 | found = true; | |
862 | break; | |
863 | } | |
864 | } | |
865 | } | |
866 | if (found) { | |
867 | f->remove = true; | |
868 | adapter->aq_required |= I40EVF_FLAG_AQ_DEL_MAC_FILTER; | |
869 | } | |
870 | } | |
871 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); | |
872 | } | |
873 | ||
874 | /** | |
875 | * i40evf_napi_enable_all - enable NAPI on all queue vectors | |
876 | * @adapter: board private structure | |
877 | **/ | |
878 | static void i40evf_napi_enable_all(struct i40evf_adapter *adapter) | |
879 | { | |
880 | int q_idx; | |
881 | struct i40e_q_vector *q_vector; | |
882 | int q_vectors = adapter->num_msix_vectors - NONQ_VECS; | |
883 | ||
884 | for (q_idx = 0; q_idx < q_vectors; q_idx++) { | |
885 | struct napi_struct *napi; | |
75a64435 | 886 | |
5eae00c5 GR |
887 | q_vector = adapter->q_vector[q_idx]; |
888 | napi = &q_vector->napi; | |
889 | napi_enable(napi); | |
890 | } | |
891 | } | |
892 | ||
893 | /** | |
894 | * i40evf_napi_disable_all - disable NAPI on all queue vectors | |
895 | * @adapter: board private structure | |
896 | **/ | |
897 | static void i40evf_napi_disable_all(struct i40evf_adapter *adapter) | |
898 | { | |
899 | int q_idx; | |
900 | struct i40e_q_vector *q_vector; | |
901 | int q_vectors = adapter->num_msix_vectors - NONQ_VECS; | |
902 | ||
903 | for (q_idx = 0; q_idx < q_vectors; q_idx++) { | |
904 | q_vector = adapter->q_vector[q_idx]; | |
905 | napi_disable(&q_vector->napi); | |
906 | } | |
907 | } | |
908 | ||
909 | /** | |
910 | * i40evf_configure - set up transmit and receive data structures | |
911 | * @adapter: board private structure | |
912 | **/ | |
913 | static void i40evf_configure(struct i40evf_adapter *adapter) | |
914 | { | |
915 | struct net_device *netdev = adapter->netdev; | |
916 | int i; | |
917 | ||
918 | i40evf_set_rx_mode(netdev); | |
919 | ||
920 | i40evf_configure_tx(adapter); | |
921 | i40evf_configure_rx(adapter); | |
922 | adapter->aq_required |= I40EVF_FLAG_AQ_CONFIGURE_QUEUES; | |
923 | ||
cc052927 | 924 | for (i = 0; i < adapter->num_active_queues; i++) { |
5eae00c5 | 925 | struct i40e_ring *ring = adapter->rx_rings[i]; |
75a64435 | 926 | |
5eae00c5 GR |
927 | i40evf_alloc_rx_buffers(ring, ring->count); |
928 | ring->next_to_use = ring->count - 1; | |
929 | writel(ring->next_to_use, ring->tail); | |
930 | } | |
931 | } | |
932 | ||
933 | /** | |
934 | * i40evf_up_complete - Finish the last steps of bringing up a connection | |
935 | * @adapter: board private structure | |
936 | **/ | |
937 | static int i40evf_up_complete(struct i40evf_adapter *adapter) | |
938 | { | |
939 | adapter->state = __I40EVF_RUNNING; | |
940 | clear_bit(__I40E_DOWN, &adapter->vsi.state); | |
941 | ||
942 | i40evf_napi_enable_all(adapter); | |
943 | ||
944 | adapter->aq_required |= I40EVF_FLAG_AQ_ENABLE_QUEUES; | |
945 | mod_timer_pending(&adapter->watchdog_timer, jiffies + 1); | |
946 | return 0; | |
947 | } | |
948 | ||
5eae00c5 GR |
949 | /** |
950 | * i40e_down - Shutdown the connection processing | |
951 | * @adapter: board private structure | |
952 | **/ | |
953 | void i40evf_down(struct i40evf_adapter *adapter) | |
954 | { | |
955 | struct net_device *netdev = adapter->netdev; | |
956 | struct i40evf_mac_filter *f; | |
957 | ||
ddf0b3a6 MW |
958 | if (adapter->state == __I40EVF_DOWN) |
959 | return; | |
960 | ||
53d0b3ae MW |
961 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, |
962 | &adapter->crit_section)) | |
963 | usleep_range(500, 1000); | |
964 | ||
965 | i40evf_irq_disable(adapter); | |
966 | ||
ef8693eb | 967 | /* remove all MAC filters */ |
5eae00c5 GR |
968 | list_for_each_entry(f, &adapter->mac_filter_list, list) { |
969 | f->remove = true; | |
970 | } | |
ed1f5b58 MW |
971 | /* remove all VLAN filters */ |
972 | list_for_each_entry(f, &adapter->vlan_filter_list, list) { | |
973 | f->remove = true; | |
974 | } | |
ef8693eb MW |
975 | if (!(adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) && |
976 | adapter->state != __I40EVF_RESETTING) { | |
53d0b3ae MW |
977 | /* cancel any current operation */ |
978 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; | |
979 | adapter->aq_pending = 0; | |
980 | /* Schedule operations to close down the HW. Don't wait | |
981 | * here for this to complete. The watchdog is still running | |
982 | * and it will take care of this. | |
983 | */ | |
984 | adapter->aq_required = I40EVF_FLAG_AQ_DEL_MAC_FILTER; | |
ed1f5b58 | 985 | adapter->aq_required |= I40EVF_FLAG_AQ_DEL_VLAN_FILTER; |
ef8693eb | 986 | adapter->aq_required |= I40EVF_FLAG_AQ_DISABLE_QUEUES; |
ef8693eb | 987 | } |
5eae00c5 GR |
988 | netif_tx_disable(netdev); |
989 | ||
990 | netif_tx_stop_all_queues(netdev); | |
991 | ||
5eae00c5 GR |
992 | i40evf_napi_disable_all(adapter); |
993 | ||
53d0b3ae MW |
994 | msleep(20); |
995 | ||
5eae00c5 | 996 | netif_carrier_off(netdev); |
53d0b3ae | 997 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
5eae00c5 GR |
998 | } |
999 | ||
1000 | /** | |
1001 | * i40evf_acquire_msix_vectors - Setup the MSIX capability | |
1002 | * @adapter: board private structure | |
1003 | * @vectors: number of vectors to request | |
1004 | * | |
1005 | * Work with the OS to set up the MSIX vectors needed. | |
1006 | * | |
1007 | * Returns 0 on success, negative on failure | |
1008 | **/ | |
1009 | static int | |
1010 | i40evf_acquire_msix_vectors(struct i40evf_adapter *adapter, int vectors) | |
1011 | { | |
1012 | int err, vector_threshold; | |
1013 | ||
1014 | /* We'll want at least 3 (vector_threshold): | |
1015 | * 0) Other (Admin Queue and link, mostly) | |
1016 | * 1) TxQ[0] Cleanup | |
1017 | * 2) RxQ[0] Cleanup | |
1018 | */ | |
1019 | vector_threshold = MIN_MSIX_COUNT; | |
1020 | ||
1021 | /* The more we get, the more we will assign to Tx/Rx Cleanup | |
1022 | * for the separate queues...where Rx Cleanup >= Tx Cleanup. | |
1023 | * Right now, we simply care about how many we'll get; we'll | |
1024 | * set them up later while requesting irq's. | |
1025 | */ | |
fc2f2f5d AG |
1026 | err = pci_enable_msix_range(adapter->pdev, adapter->msix_entries, |
1027 | vector_threshold, vectors); | |
1028 | if (err < 0) { | |
80e72893 | 1029 | dev_err(&adapter->pdev->dev, "Unable to allocate MSI-X interrupts\n"); |
5eae00c5 GR |
1030 | kfree(adapter->msix_entries); |
1031 | adapter->msix_entries = NULL; | |
fc2f2f5d | 1032 | return err; |
5eae00c5 | 1033 | } |
fc2f2f5d AG |
1034 | |
1035 | /* Adjust for only the vectors we'll use, which is minimum | |
1036 | * of max_msix_q_vectors + NONQ_VECS, or the number of | |
1037 | * vectors we were allocated. | |
1038 | */ | |
1039 | adapter->num_msix_vectors = err; | |
1040 | return 0; | |
5eae00c5 GR |
1041 | } |
1042 | ||
1043 | /** | |
1044 | * i40evf_free_queues - Free memory for all rings | |
1045 | * @adapter: board private structure to initialize | |
1046 | * | |
1047 | * Free all of the memory associated with queue pairs. | |
1048 | **/ | |
1049 | static void i40evf_free_queues(struct i40evf_adapter *adapter) | |
1050 | { | |
1051 | int i; | |
1052 | ||
1053 | if (!adapter->vsi_res) | |
1054 | return; | |
cc052927 | 1055 | for (i = 0; i < adapter->num_active_queues; i++) { |
5eae00c5 GR |
1056 | if (adapter->tx_rings[i]) |
1057 | kfree_rcu(adapter->tx_rings[i], rcu); | |
1058 | adapter->tx_rings[i] = NULL; | |
1059 | adapter->rx_rings[i] = NULL; | |
1060 | } | |
1061 | } | |
1062 | ||
1063 | /** | |
1064 | * i40evf_alloc_queues - Allocate memory for all rings | |
1065 | * @adapter: board private structure to initialize | |
1066 | * | |
1067 | * We allocate one ring per queue at run-time since we don't know the | |
1068 | * number of queues at compile-time. The polling_netdev array is | |
1069 | * intended for Multiqueue, but should work fine with a single queue. | |
1070 | **/ | |
1071 | static int i40evf_alloc_queues(struct i40evf_adapter *adapter) | |
1072 | { | |
1073 | int i; | |
1074 | ||
cc052927 | 1075 | for (i = 0; i < adapter->num_active_queues; i++) { |
5eae00c5 GR |
1076 | struct i40e_ring *tx_ring; |
1077 | struct i40e_ring *rx_ring; | |
1078 | ||
75a64435 | 1079 | tx_ring = kzalloc(sizeof(*tx_ring) * 2, GFP_KERNEL); |
5eae00c5 GR |
1080 | if (!tx_ring) |
1081 | goto err_out; | |
1082 | ||
1083 | tx_ring->queue_index = i; | |
1084 | tx_ring->netdev = adapter->netdev; | |
1085 | tx_ring->dev = &adapter->pdev->dev; | |
d732a184 | 1086 | tx_ring->count = adapter->tx_desc_count; |
5eae00c5 GR |
1087 | adapter->tx_rings[i] = tx_ring; |
1088 | ||
1089 | rx_ring = &tx_ring[1]; | |
1090 | rx_ring->queue_index = i; | |
1091 | rx_ring->netdev = adapter->netdev; | |
1092 | rx_ring->dev = &adapter->pdev->dev; | |
d732a184 | 1093 | rx_ring->count = adapter->rx_desc_count; |
5eae00c5 GR |
1094 | adapter->rx_rings[i] = rx_ring; |
1095 | } | |
1096 | ||
1097 | return 0; | |
1098 | ||
1099 | err_out: | |
1100 | i40evf_free_queues(adapter); | |
1101 | return -ENOMEM; | |
1102 | } | |
1103 | ||
1104 | /** | |
1105 | * i40evf_set_interrupt_capability - set MSI-X or FAIL if not supported | |
1106 | * @adapter: board private structure to initialize | |
1107 | * | |
1108 | * Attempt to configure the interrupts using the best available | |
1109 | * capabilities of the hardware and the kernel. | |
1110 | **/ | |
1111 | static int i40evf_set_interrupt_capability(struct i40evf_adapter *adapter) | |
1112 | { | |
1113 | int vector, v_budget; | |
1114 | int pairs = 0; | |
1115 | int err = 0; | |
1116 | ||
1117 | if (!adapter->vsi_res) { | |
1118 | err = -EIO; | |
1119 | goto out; | |
1120 | } | |
cc052927 | 1121 | pairs = adapter->num_active_queues; |
5eae00c5 GR |
1122 | |
1123 | /* It's easy to be greedy for MSI-X vectors, but it really | |
1124 | * doesn't do us much good if we have a lot more vectors | |
1125 | * than CPU's. So let's be conservative and only ask for | |
1126 | * (roughly) twice the number of vectors as there are CPU's. | |
1127 | */ | |
30a500e2 MW |
1128 | v_budget = min_t(int, pairs, (int)(num_online_cpus() * 2)) + NONQ_VECS; |
1129 | v_budget = min_t(int, v_budget, (int)adapter->vf_res->max_vectors); | |
5eae00c5 | 1130 | |
5eae00c5 GR |
1131 | adapter->msix_entries = kcalloc(v_budget, |
1132 | sizeof(struct msix_entry), GFP_KERNEL); | |
1133 | if (!adapter->msix_entries) { | |
1134 | err = -ENOMEM; | |
1135 | goto out; | |
1136 | } | |
1137 | ||
1138 | for (vector = 0; vector < v_budget; vector++) | |
1139 | adapter->msix_entries[vector].entry = vector; | |
1140 | ||
1141 | i40evf_acquire_msix_vectors(adapter, v_budget); | |
1142 | ||
1143 | out: | |
1144 | adapter->netdev->real_num_tx_queues = pairs; | |
1145 | return err; | |
1146 | } | |
1147 | ||
1148 | /** | |
1149 | * i40evf_alloc_q_vectors - Allocate memory for interrupt vectors | |
1150 | * @adapter: board private structure to initialize | |
1151 | * | |
1152 | * We allocate one q_vector per queue interrupt. If allocation fails we | |
1153 | * return -ENOMEM. | |
1154 | **/ | |
1155 | static int i40evf_alloc_q_vectors(struct i40evf_adapter *adapter) | |
1156 | { | |
1157 | int q_idx, num_q_vectors; | |
1158 | struct i40e_q_vector *q_vector; | |
1159 | ||
1160 | num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; | |
1161 | ||
1162 | for (q_idx = 0; q_idx < num_q_vectors; q_idx++) { | |
75a64435 | 1163 | q_vector = kzalloc(sizeof(*q_vector), GFP_KERNEL); |
5eae00c5 GR |
1164 | if (!q_vector) |
1165 | goto err_out; | |
1166 | q_vector->adapter = adapter; | |
1167 | q_vector->vsi = &adapter->vsi; | |
1168 | q_vector->v_idx = q_idx; | |
1169 | netif_napi_add(adapter->netdev, &q_vector->napi, | |
75a64435 | 1170 | i40evf_napi_poll, NAPI_POLL_WEIGHT); |
5eae00c5 GR |
1171 | adapter->q_vector[q_idx] = q_vector; |
1172 | } | |
1173 | ||
1174 | return 0; | |
1175 | ||
1176 | err_out: | |
1177 | while (q_idx) { | |
1178 | q_idx--; | |
1179 | q_vector = adapter->q_vector[q_idx]; | |
1180 | netif_napi_del(&q_vector->napi); | |
1181 | kfree(q_vector); | |
1182 | adapter->q_vector[q_idx] = NULL; | |
1183 | } | |
1184 | return -ENOMEM; | |
1185 | } | |
1186 | ||
1187 | /** | |
1188 | * i40evf_free_q_vectors - Free memory allocated for interrupt vectors | |
1189 | * @adapter: board private structure to initialize | |
1190 | * | |
1191 | * This function frees the memory allocated to the q_vectors. In addition if | |
1192 | * NAPI is enabled it will delete any references to the NAPI struct prior | |
1193 | * to freeing the q_vector. | |
1194 | **/ | |
1195 | static void i40evf_free_q_vectors(struct i40evf_adapter *adapter) | |
1196 | { | |
1197 | int q_idx, num_q_vectors; | |
1198 | int napi_vectors; | |
1199 | ||
1200 | num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; | |
cc052927 | 1201 | napi_vectors = adapter->num_active_queues; |
5eae00c5 GR |
1202 | |
1203 | for (q_idx = 0; q_idx < num_q_vectors; q_idx++) { | |
1204 | struct i40e_q_vector *q_vector = adapter->q_vector[q_idx]; | |
1205 | ||
1206 | adapter->q_vector[q_idx] = NULL; | |
1207 | if (q_idx < napi_vectors) | |
1208 | netif_napi_del(&q_vector->napi); | |
1209 | kfree(q_vector); | |
1210 | } | |
1211 | } | |
1212 | ||
1213 | /** | |
1214 | * i40evf_reset_interrupt_capability - Reset MSIX setup | |
1215 | * @adapter: board private structure | |
1216 | * | |
1217 | **/ | |
1218 | void i40evf_reset_interrupt_capability(struct i40evf_adapter *adapter) | |
1219 | { | |
1220 | pci_disable_msix(adapter->pdev); | |
1221 | kfree(adapter->msix_entries); | |
1222 | adapter->msix_entries = NULL; | |
5eae00c5 GR |
1223 | } |
1224 | ||
1225 | /** | |
1226 | * i40evf_init_interrupt_scheme - Determine if MSIX is supported and init | |
1227 | * @adapter: board private structure to initialize | |
1228 | * | |
1229 | **/ | |
1230 | int i40evf_init_interrupt_scheme(struct i40evf_adapter *adapter) | |
1231 | { | |
1232 | int err; | |
1233 | ||
1234 | err = i40evf_set_interrupt_capability(adapter); | |
1235 | if (err) { | |
1236 | dev_err(&adapter->pdev->dev, | |
1237 | "Unable to setup interrupt capabilities\n"); | |
1238 | goto err_set_interrupt; | |
1239 | } | |
1240 | ||
1241 | err = i40evf_alloc_q_vectors(adapter); | |
1242 | if (err) { | |
1243 | dev_err(&adapter->pdev->dev, | |
1244 | "Unable to allocate memory for queue vectors\n"); | |
1245 | goto err_alloc_q_vectors; | |
1246 | } | |
1247 | ||
1248 | err = i40evf_alloc_queues(adapter); | |
1249 | if (err) { | |
1250 | dev_err(&adapter->pdev->dev, | |
1251 | "Unable to allocate memory for queues\n"); | |
1252 | goto err_alloc_queues; | |
1253 | } | |
1254 | ||
1255 | dev_info(&adapter->pdev->dev, "Multiqueue %s: Queue pair count = %u", | |
75a64435 MW |
1256 | (adapter->num_active_queues > 1) ? "Enabled" : "Disabled", |
1257 | adapter->num_active_queues); | |
5eae00c5 GR |
1258 | |
1259 | return 0; | |
1260 | err_alloc_queues: | |
1261 | i40evf_free_q_vectors(adapter); | |
1262 | err_alloc_q_vectors: | |
1263 | i40evf_reset_interrupt_capability(adapter); | |
1264 | err_set_interrupt: | |
1265 | return err; | |
1266 | } | |
1267 | ||
1268 | /** | |
1269 | * i40evf_watchdog_timer - Periodic call-back timer | |
1270 | * @data: pointer to adapter disguised as unsigned long | |
1271 | **/ | |
1272 | static void i40evf_watchdog_timer(unsigned long data) | |
1273 | { | |
1274 | struct i40evf_adapter *adapter = (struct i40evf_adapter *)data; | |
75a64435 | 1275 | |
5eae00c5 GR |
1276 | schedule_work(&adapter->watchdog_task); |
1277 | /* timer will be rescheduled in watchdog task */ | |
1278 | } | |
1279 | ||
1280 | /** | |
1281 | * i40evf_watchdog_task - Periodic call-back task | |
1282 | * @work: pointer to work_struct | |
1283 | **/ | |
1284 | static void i40evf_watchdog_task(struct work_struct *work) | |
1285 | { | |
1286 | struct i40evf_adapter *adapter = container_of(work, | |
75a64435 MW |
1287 | struct i40evf_adapter, |
1288 | watchdog_task); | |
5eae00c5 | 1289 | struct i40e_hw *hw = &adapter->hw; |
fd35886a | 1290 | uint32_t rstat_val; |
5eae00c5 | 1291 | |
ef8693eb MW |
1292 | if (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section)) |
1293 | goto restart_watchdog; | |
1294 | ||
1295 | if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) { | |
fd35886a AS |
1296 | rstat_val = rd32(hw, I40E_VFGEN_RSTAT) & |
1297 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; | |
1298 | if ((rstat_val == I40E_VFR_VFACTIVE) || | |
1299 | (rstat_val == I40E_VFR_COMPLETED)) { | |
ef8693eb MW |
1300 | /* A chance for redemption! */ |
1301 | dev_err(&adapter->pdev->dev, "Hardware came out of reset. Attempting reinit.\n"); | |
1302 | adapter->state = __I40EVF_STARTUP; | |
1303 | adapter->flags &= ~I40EVF_FLAG_PF_COMMS_FAILED; | |
1304 | schedule_delayed_work(&adapter->init_task, 10); | |
1305 | clear_bit(__I40EVF_IN_CRITICAL_TASK, | |
1306 | &adapter->crit_section); | |
1307 | /* Don't reschedule the watchdog, since we've restarted | |
1308 | * the init task. When init_task contacts the PF and | |
1309 | * gets everything set up again, it'll restart the | |
1310 | * watchdog for us. Down, boy. Sit. Stay. Woof. | |
1311 | */ | |
1312 | return; | |
1313 | } | |
1314 | adapter->aq_pending = 0; | |
1315 | adapter->aq_required = 0; | |
1316 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; | |
5eae00c5 | 1317 | goto watchdog_done; |
ef8693eb | 1318 | } |
5eae00c5 | 1319 | |
ef8693eb MW |
1320 | if ((adapter->state < __I40EVF_DOWN) || |
1321 | (adapter->flags & I40EVF_FLAG_RESET_PENDING)) | |
5eae00c5 GR |
1322 | goto watchdog_done; |
1323 | ||
ef8693eb | 1324 | /* check for reset */ |
fd35886a | 1325 | rstat_val = rd32(hw, I40E_VFGEN_RSTAT) & |
75a64435 | 1326 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; |
ef8693eb | 1327 | if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING) && |
fd35886a AS |
1328 | (rstat_val != I40E_VFR_VFACTIVE) && |
1329 | (rstat_val != I40E_VFR_COMPLETED)) { | |
5eae00c5 | 1330 | adapter->state = __I40EVF_RESETTING; |
ef8693eb | 1331 | adapter->flags |= I40EVF_FLAG_RESET_PENDING; |
249c8b8d | 1332 | dev_err(&adapter->pdev->dev, "Hardware reset detected\n"); |
5eae00c5 | 1333 | schedule_work(&adapter->reset_task); |
ef8693eb MW |
1334 | adapter->aq_pending = 0; |
1335 | adapter->aq_required = 0; | |
1336 | adapter->current_op = I40E_VIRTCHNL_OP_UNKNOWN; | |
5eae00c5 GR |
1337 | goto watchdog_done; |
1338 | } | |
1339 | ||
1340 | /* Process admin queue tasks. After init, everything gets done | |
1341 | * here so we don't race on the admin queue. | |
1342 | */ | |
1343 | if (adapter->aq_pending) | |
1344 | goto watchdog_done; | |
1345 | ||
1346 | if (adapter->aq_required & I40EVF_FLAG_AQ_MAP_VECTORS) { | |
1347 | i40evf_map_queues(adapter); | |
1348 | goto watchdog_done; | |
1349 | } | |
1350 | ||
1351 | if (adapter->aq_required & I40EVF_FLAG_AQ_ADD_MAC_FILTER) { | |
1352 | i40evf_add_ether_addrs(adapter); | |
1353 | goto watchdog_done; | |
1354 | } | |
1355 | ||
1356 | if (adapter->aq_required & I40EVF_FLAG_AQ_ADD_VLAN_FILTER) { | |
1357 | i40evf_add_vlans(adapter); | |
1358 | goto watchdog_done; | |
1359 | } | |
1360 | ||
1361 | if (adapter->aq_required & I40EVF_FLAG_AQ_DEL_MAC_FILTER) { | |
1362 | i40evf_del_ether_addrs(adapter); | |
1363 | goto watchdog_done; | |
1364 | } | |
1365 | ||
1366 | if (adapter->aq_required & I40EVF_FLAG_AQ_DEL_VLAN_FILTER) { | |
1367 | i40evf_del_vlans(adapter); | |
1368 | goto watchdog_done; | |
1369 | } | |
1370 | ||
1371 | if (adapter->aq_required & I40EVF_FLAG_AQ_DISABLE_QUEUES) { | |
1372 | i40evf_disable_queues(adapter); | |
1373 | goto watchdog_done; | |
1374 | } | |
1375 | ||
1376 | if (adapter->aq_required & I40EVF_FLAG_AQ_CONFIGURE_QUEUES) { | |
1377 | i40evf_configure_queues(adapter); | |
1378 | goto watchdog_done; | |
1379 | } | |
1380 | ||
1381 | if (adapter->aq_required & I40EVF_FLAG_AQ_ENABLE_QUEUES) { | |
1382 | i40evf_enable_queues(adapter); | |
1383 | goto watchdog_done; | |
1384 | } | |
1385 | ||
1386 | if (adapter->state == __I40EVF_RUNNING) | |
1387 | i40evf_request_stats(adapter); | |
5eae00c5 | 1388 | watchdog_done: |
4870e176 MW |
1389 | if (adapter->state == __I40EVF_RUNNING) { |
1390 | i40evf_irq_enable_queues(adapter, ~0); | |
1391 | i40evf_fire_sw_int(adapter, 0xFF); | |
1392 | } else { | |
1393 | i40evf_fire_sw_int(adapter, 0x1); | |
1394 | } | |
1395 | ||
ef8693eb MW |
1396 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); |
1397 | restart_watchdog: | |
d3e2edb7 AS |
1398 | if (adapter->state == __I40EVF_REMOVE) |
1399 | return; | |
5eae00c5 GR |
1400 | if (adapter->aq_required) |
1401 | mod_timer(&adapter->watchdog_timer, | |
1402 | jiffies + msecs_to_jiffies(20)); | |
1403 | else | |
1404 | mod_timer(&adapter->watchdog_timer, jiffies + (HZ * 2)); | |
5eae00c5 GR |
1405 | schedule_work(&adapter->adminq_task); |
1406 | } | |
1407 | ||
5b7af02c | 1408 | /** |
3dd5550f | 1409 | * next_queue - increment to next available tx queue |
5b7af02c MW |
1410 | * @adapter: board private structure |
1411 | * @j: queue counter | |
1412 | * | |
1413 | * Helper function for RSS programming to increment through available | |
1414 | * queus. Returns the next queue value. | |
1415 | **/ | |
96d47704 MW |
1416 | static int next_queue(struct i40evf_adapter *adapter, int j) |
1417 | { | |
1418 | j += 1; | |
1419 | ||
cc052927 | 1420 | return j >= adapter->num_active_queues ? 0 : j; |
96d47704 MW |
1421 | } |
1422 | ||
5eae00c5 GR |
1423 | /** |
1424 | * i40evf_configure_rss - Prepare for RSS if used | |
1425 | * @adapter: board private structure | |
1426 | **/ | |
1427 | static void i40evf_configure_rss(struct i40evf_adapter *adapter) | |
1428 | { | |
22f258a1 | 1429 | u32 rss_key[I40E_VFQF_HKEY_MAX_INDEX + 1]; |
5eae00c5 GR |
1430 | struct i40e_hw *hw = &adapter->hw; |
1431 | u32 lut = 0; | |
1432 | int i, j; | |
1433 | u64 hena; | |
1434 | ||
cc052927 MW |
1435 | /* No RSS for single queue. */ |
1436 | if (adapter->num_active_queues == 1) { | |
1437 | wr32(hw, I40E_VFQF_HENA(0), 0); | |
1438 | wr32(hw, I40E_VFQF_HENA(1), 0); | |
1439 | return; | |
1440 | } | |
5eae00c5 | 1441 | |
cc052927 | 1442 | /* Hash type is configured by the PF - we just supply the key */ |
22f258a1 | 1443 | netdev_rss_key_fill(rss_key, sizeof(rss_key)); |
5eae00c5 | 1444 | for (i = 0; i <= I40E_VFQF_HKEY_MAX_INDEX; i++) |
22f258a1 | 1445 | wr32(hw, I40E_VFQF_HKEY(i), rss_key[i]); |
5eae00c5 GR |
1446 | |
1447 | /* Enable PCTYPES for RSS, TCP/UDP with IPv4/IPv6 */ | |
1448 | hena = I40E_DEFAULT_RSS_HENA; | |
1449 | wr32(hw, I40E_VFQF_HENA(0), (u32)hena); | |
1450 | wr32(hw, I40E_VFQF_HENA(1), (u32)(hena >> 32)); | |
1451 | ||
1452 | /* Populate the LUT with max no. of queues in round robin fashion */ | |
cc052927 | 1453 | j = adapter->num_active_queues; |
96d47704 | 1454 | for (i = 0; i <= I40E_VFQF_HLUT_MAX_INDEX; i++) { |
5b7af02c MW |
1455 | j = next_queue(adapter, j); |
1456 | lut = j; | |
1457 | j = next_queue(adapter, j); | |
1458 | lut |= j << 8; | |
1459 | j = next_queue(adapter, j); | |
1460 | lut |= j << 16; | |
1461 | j = next_queue(adapter, j); | |
1462 | lut |= j << 24; | |
96d47704 | 1463 | wr32(hw, I40E_VFQF_HLUT(i), lut); |
5eae00c5 GR |
1464 | } |
1465 | i40e_flush(hw); | |
1466 | } | |
1467 | ||
ef8693eb MW |
1468 | #define I40EVF_RESET_WAIT_MS 100 |
1469 | #define I40EVF_RESET_WAIT_COUNT 200 | |
5eae00c5 GR |
1470 | /** |
1471 | * i40evf_reset_task - Call-back task to handle hardware reset | |
1472 | * @work: pointer to work_struct | |
1473 | * | |
1474 | * During reset we need to shut down and reinitialize the admin queue | |
1475 | * before we can use it to communicate with the PF again. We also clear | |
1476 | * and reinit the rings because that context is lost as well. | |
1477 | **/ | |
1478 | static void i40evf_reset_task(struct work_struct *work) | |
1479 | { | |
ef8693eb MW |
1480 | struct i40evf_adapter *adapter = container_of(work, |
1481 | struct i40evf_adapter, | |
1482 | reset_task); | |
5eae00c5 GR |
1483 | struct i40e_hw *hw = &adapter->hw; |
1484 | int i = 0, err; | |
1485 | uint32_t rstat_val; | |
1486 | ||
1487 | while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK, | |
1488 | &adapter->crit_section)) | |
f98a2006 | 1489 | usleep_range(500, 1000); |
3526d800 MW |
1490 | |
1491 | if (adapter->flags & I40EVF_FLAG_RESET_NEEDED) { | |
1492 | dev_info(&adapter->pdev->dev, "Requesting reset from PF\n"); | |
1493 | i40evf_request_reset(adapter); | |
1494 | } | |
1495 | ||
ef8693eb MW |
1496 | /* poll until we see the reset actually happen */ |
1497 | for (i = 0; i < I40EVF_RESET_WAIT_COUNT; i++) { | |
1498 | rstat_val = rd32(hw, I40E_VFGEN_RSTAT) & | |
1499 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; | |
fd35886a AS |
1500 | if ((rstat_val != I40E_VFR_VFACTIVE) && |
1501 | (rstat_val != I40E_VFR_COMPLETED)) | |
ef8693eb | 1502 | break; |
c88e38cc | 1503 | msleep(I40EVF_RESET_WAIT_MS); |
ef8693eb MW |
1504 | } |
1505 | if (i == I40EVF_RESET_WAIT_COUNT) { | |
ef8693eb MW |
1506 | adapter->flags &= ~I40EVF_FLAG_RESET_PENDING; |
1507 | goto continue_reset; /* act like the reset happened */ | |
1508 | } | |
5eae00c5 | 1509 | |
ef8693eb MW |
1510 | /* wait until the reset is complete and the PF is responding to us */ |
1511 | for (i = 0; i < I40EVF_RESET_WAIT_COUNT; i++) { | |
5eae00c5 GR |
1512 | rstat_val = rd32(hw, I40E_VFGEN_RSTAT) & |
1513 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; | |
fd35886a AS |
1514 | if ((rstat_val == I40E_VFR_VFACTIVE) || |
1515 | (rstat_val == I40E_VFR_COMPLETED)) | |
5eae00c5 | 1516 | break; |
c88e38cc | 1517 | msleep(I40EVF_RESET_WAIT_MS); |
5eae00c5 | 1518 | } |
ef8693eb | 1519 | if (i == I40EVF_RESET_WAIT_COUNT) { |
6ba36a24 MW |
1520 | struct i40evf_mac_filter *f, *ftmp; |
1521 | struct i40evf_vlan_filter *fv, *fvtmp; | |
1522 | ||
5eae00c5 | 1523 | /* reset never finished */ |
80e72893 | 1524 | dev_err(&adapter->pdev->dev, "Reset never finished (%x)\n", |
ef8693eb MW |
1525 | rstat_val); |
1526 | adapter->flags |= I40EVF_FLAG_PF_COMMS_FAILED; | |
1527 | ||
169f4076 MW |
1528 | if (netif_running(adapter->netdev)) { |
1529 | set_bit(__I40E_DOWN, &adapter->vsi.state); | |
1530 | i40evf_down(adapter); | |
1531 | i40evf_free_traffic_irqs(adapter); | |
1532 | i40evf_free_all_tx_resources(adapter); | |
1533 | i40evf_free_all_rx_resources(adapter); | |
1534 | } | |
6ba36a24 MW |
1535 | |
1536 | /* Delete all of the filters, both MAC and VLAN. */ | |
1537 | list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, | |
1538 | list) { | |
1539 | list_del(&f->list); | |
1540 | kfree(f); | |
1541 | } | |
1542 | list_for_each_entry_safe(fv, fvtmp, &adapter->vlan_filter_list, | |
1543 | list) { | |
1544 | list_del(&fv->list); | |
1545 | kfree(fv); | |
1546 | } | |
1547 | ||
ef8693eb MW |
1548 | i40evf_free_misc_irq(adapter); |
1549 | i40evf_reset_interrupt_capability(adapter); | |
1550 | i40evf_free_queues(adapter); | |
d31944d6 | 1551 | i40evf_free_q_vectors(adapter); |
ef8693eb MW |
1552 | kfree(adapter->vf_res); |
1553 | i40evf_shutdown_adminq(hw); | |
1554 | adapter->netdev->flags &= ~IFF_UP; | |
1555 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); | |
1556 | return; /* Do not attempt to reinit. It's dead, Jim. */ | |
5eae00c5 | 1557 | } |
ef8693eb MW |
1558 | |
1559 | continue_reset: | |
1560 | adapter->flags &= ~I40EVF_FLAG_RESET_PENDING; | |
1561 | ||
5eae00c5 GR |
1562 | i40evf_down(adapter); |
1563 | adapter->state = __I40EVF_RESETTING; | |
1564 | ||
1565 | /* kill and reinit the admin queue */ | |
1566 | if (i40evf_shutdown_adminq(hw)) | |
1567 | dev_warn(&adapter->pdev->dev, | |
75a64435 MW |
1568 | "%s: Failed to destroy the Admin Queue resources\n", |
1569 | __func__); | |
5eae00c5 GR |
1570 | err = i40evf_init_adminq(hw); |
1571 | if (err) | |
1572 | dev_info(&adapter->pdev->dev, "%s: init_adminq failed: %d\n", | |
75a64435 | 1573 | __func__, err); |
5eae00c5 GR |
1574 | |
1575 | adapter->aq_pending = 0; | |
1576 | adapter->aq_required = 0; | |
1577 | i40evf_map_queues(adapter); | |
1578 | clear_bit(__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section); | |
1579 | ||
1580 | mod_timer(&adapter->watchdog_timer, jiffies + 2); | |
1581 | ||
1582 | if (netif_running(adapter->netdev)) { | |
1583 | /* allocate transmit descriptors */ | |
1584 | err = i40evf_setup_all_tx_resources(adapter); | |
1585 | if (err) | |
1586 | goto reset_err; | |
1587 | ||
1588 | /* allocate receive descriptors */ | |
1589 | err = i40evf_setup_all_rx_resources(adapter); | |
1590 | if (err) | |
1591 | goto reset_err; | |
1592 | ||
1593 | i40evf_configure(adapter); | |
1594 | ||
1595 | err = i40evf_up_complete(adapter); | |
1596 | if (err) | |
1597 | goto reset_err; | |
1598 | ||
1599 | i40evf_irq_enable(adapter, true); | |
1600 | } | |
1601 | return; | |
1602 | reset_err: | |
80e72893 | 1603 | dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); |
5eae00c5 GR |
1604 | i40evf_close(adapter->netdev); |
1605 | } | |
1606 | ||
1607 | /** | |
1608 | * i40evf_adminq_task - worker thread to clean the admin queue | |
1609 | * @work: pointer to work_struct containing our data | |
1610 | **/ | |
1611 | static void i40evf_adminq_task(struct work_struct *work) | |
1612 | { | |
1613 | struct i40evf_adapter *adapter = | |
1614 | container_of(work, struct i40evf_adapter, adminq_task); | |
1615 | struct i40e_hw *hw = &adapter->hw; | |
1616 | struct i40e_arq_event_info event; | |
1617 | struct i40e_virtchnl_msg *v_msg; | |
1618 | i40e_status ret; | |
912257e5 | 1619 | u32 val, oldval; |
5eae00c5 GR |
1620 | u16 pending; |
1621 | ||
ef8693eb MW |
1622 | if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) |
1623 | return; | |
1624 | ||
1001dc37 MW |
1625 | event.buf_len = I40EVF_MAX_AQ_BUF_SIZE; |
1626 | event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); | |
249c8b8d | 1627 | if (!event.msg_buf) |
5eae00c5 | 1628 | return; |
249c8b8d | 1629 | |
5eae00c5 GR |
1630 | v_msg = (struct i40e_virtchnl_msg *)&event.desc; |
1631 | do { | |
1632 | ret = i40evf_clean_arq_element(hw, &event, &pending); | |
1633 | if (ret) | |
1634 | break; /* No event to process or error cleaning ARQ */ | |
1635 | ||
1636 | i40evf_virtchnl_completion(adapter, v_msg->v_opcode, | |
1637 | v_msg->v_retval, event.msg_buf, | |
1001dc37 | 1638 | event.msg_len); |
75a64435 | 1639 | if (pending != 0) |
5eae00c5 | 1640 | memset(event.msg_buf, 0, I40EVF_MAX_AQ_BUF_SIZE); |
5eae00c5 GR |
1641 | } while (pending); |
1642 | ||
912257e5 MW |
1643 | /* check for error indications */ |
1644 | val = rd32(hw, hw->aq.arq.len); | |
1645 | oldval = val; | |
1646 | if (val & I40E_VF_ARQLEN_ARQVFE_MASK) { | |
1647 | dev_info(&adapter->pdev->dev, "ARQ VF Error detected\n"); | |
1648 | val &= ~I40E_VF_ARQLEN_ARQVFE_MASK; | |
1649 | } | |
1650 | if (val & I40E_VF_ARQLEN_ARQOVFL_MASK) { | |
1651 | dev_info(&adapter->pdev->dev, "ARQ Overflow Error detected\n"); | |
1652 | val &= ~I40E_VF_ARQLEN_ARQOVFL_MASK; | |
1653 | } | |
1654 | if (val & I40E_VF_ARQLEN_ARQCRIT_MASK) { | |
1655 | dev_info(&adapter->pdev->dev, "ARQ Critical Error detected\n"); | |
1656 | val &= ~I40E_VF_ARQLEN_ARQCRIT_MASK; | |
1657 | } | |
1658 | if (oldval != val) | |
1659 | wr32(hw, hw->aq.arq.len, val); | |
1660 | ||
1661 | val = rd32(hw, hw->aq.asq.len); | |
1662 | oldval = val; | |
1663 | if (val & I40E_VF_ATQLEN_ATQVFE_MASK) { | |
1664 | dev_info(&adapter->pdev->dev, "ASQ VF Error detected\n"); | |
1665 | val &= ~I40E_VF_ATQLEN_ATQVFE_MASK; | |
1666 | } | |
1667 | if (val & I40E_VF_ATQLEN_ATQOVFL_MASK) { | |
1668 | dev_info(&adapter->pdev->dev, "ASQ Overflow Error detected\n"); | |
1669 | val &= ~I40E_VF_ATQLEN_ATQOVFL_MASK; | |
1670 | } | |
1671 | if (val & I40E_VF_ATQLEN_ATQCRIT_MASK) { | |
1672 | dev_info(&adapter->pdev->dev, "ASQ Critical Error detected\n"); | |
1673 | val &= ~I40E_VF_ATQLEN_ATQCRIT_MASK; | |
1674 | } | |
1675 | if (oldval != val) | |
1676 | wr32(hw, hw->aq.asq.len, val); | |
1677 | ||
5eae00c5 GR |
1678 | /* re-enable Admin queue interrupt cause */ |
1679 | i40evf_misc_irq_enable(adapter); | |
1680 | ||
1681 | kfree(event.msg_buf); | |
1682 | } | |
1683 | ||
1684 | /** | |
1685 | * i40evf_free_all_tx_resources - Free Tx Resources for All Queues | |
1686 | * @adapter: board private structure | |
1687 | * | |
1688 | * Free all transmit software resources | |
1689 | **/ | |
1690 | static void i40evf_free_all_tx_resources(struct i40evf_adapter *adapter) | |
1691 | { | |
1692 | int i; | |
1693 | ||
cc052927 | 1694 | for (i = 0; i < adapter->num_active_queues; i++) |
5eae00c5 GR |
1695 | if (adapter->tx_rings[i]->desc) |
1696 | i40evf_free_tx_resources(adapter->tx_rings[i]); | |
5eae00c5 GR |
1697 | } |
1698 | ||
1699 | /** | |
1700 | * i40evf_setup_all_tx_resources - allocate all queues Tx resources | |
1701 | * @adapter: board private structure | |
1702 | * | |
1703 | * If this function returns with an error, then it's possible one or | |
1704 | * more of the rings is populated (while the rest are not). It is the | |
1705 | * callers duty to clean those orphaned rings. | |
1706 | * | |
1707 | * Return 0 on success, negative on failure | |
1708 | **/ | |
1709 | static int i40evf_setup_all_tx_resources(struct i40evf_adapter *adapter) | |
1710 | { | |
1711 | int i, err = 0; | |
1712 | ||
cc052927 | 1713 | for (i = 0; i < adapter->num_active_queues; i++) { |
d732a184 | 1714 | adapter->tx_rings[i]->count = adapter->tx_desc_count; |
5eae00c5 GR |
1715 | err = i40evf_setup_tx_descriptors(adapter->tx_rings[i]); |
1716 | if (!err) | |
1717 | continue; | |
1718 | dev_err(&adapter->pdev->dev, | |
1719 | "%s: Allocation for Tx Queue %u failed\n", | |
1720 | __func__, i); | |
1721 | break; | |
1722 | } | |
1723 | ||
1724 | return err; | |
1725 | } | |
1726 | ||
1727 | /** | |
1728 | * i40evf_setup_all_rx_resources - allocate all queues Rx resources | |
1729 | * @adapter: board private structure | |
1730 | * | |
1731 | * If this function returns with an error, then it's possible one or | |
1732 | * more of the rings is populated (while the rest are not). It is the | |
1733 | * callers duty to clean those orphaned rings. | |
1734 | * | |
1735 | * Return 0 on success, negative on failure | |
1736 | **/ | |
1737 | static int i40evf_setup_all_rx_resources(struct i40evf_adapter *adapter) | |
1738 | { | |
1739 | int i, err = 0; | |
1740 | ||
cc052927 | 1741 | for (i = 0; i < adapter->num_active_queues; i++) { |
d732a184 | 1742 | adapter->rx_rings[i]->count = adapter->rx_desc_count; |
5eae00c5 GR |
1743 | err = i40evf_setup_rx_descriptors(adapter->rx_rings[i]); |
1744 | if (!err) | |
1745 | continue; | |
1746 | dev_err(&adapter->pdev->dev, | |
1747 | "%s: Allocation for Rx Queue %u failed\n", | |
1748 | __func__, i); | |
1749 | break; | |
1750 | } | |
1751 | return err; | |
1752 | } | |
1753 | ||
1754 | /** | |
1755 | * i40evf_free_all_rx_resources - Free Rx Resources for All Queues | |
1756 | * @adapter: board private structure | |
1757 | * | |
1758 | * Free all receive software resources | |
1759 | **/ | |
1760 | static void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter) | |
1761 | { | |
1762 | int i; | |
1763 | ||
cc052927 | 1764 | for (i = 0; i < adapter->num_active_queues; i++) |
5eae00c5 GR |
1765 | if (adapter->rx_rings[i]->desc) |
1766 | i40evf_free_rx_resources(adapter->rx_rings[i]); | |
1767 | } | |
1768 | ||
1769 | /** | |
1770 | * i40evf_open - Called when a network interface is made active | |
1771 | * @netdev: network interface device structure | |
1772 | * | |
1773 | * Returns 0 on success, negative value on failure | |
1774 | * | |
1775 | * The open entry point is called when a network interface is made | |
1776 | * active by the system (IFF_UP). At this point all resources needed | |
1777 | * for transmit and receive operations are allocated, the interrupt | |
1778 | * handler is registered with the OS, the watchdog timer is started, | |
1779 | * and the stack is notified that the interface is ready. | |
1780 | **/ | |
1781 | static int i40evf_open(struct net_device *netdev) | |
1782 | { | |
1783 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
1784 | int err; | |
1785 | ||
ef8693eb MW |
1786 | if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED) { |
1787 | dev_err(&adapter->pdev->dev, "Unable to open device due to PF driver failure.\n"); | |
1788 | return -EIO; | |
1789 | } | |
5eae00c5 GR |
1790 | if (adapter->state != __I40EVF_DOWN) |
1791 | return -EBUSY; | |
1792 | ||
1793 | /* allocate transmit descriptors */ | |
1794 | err = i40evf_setup_all_tx_resources(adapter); | |
1795 | if (err) | |
1796 | goto err_setup_tx; | |
1797 | ||
1798 | /* allocate receive descriptors */ | |
1799 | err = i40evf_setup_all_rx_resources(adapter); | |
1800 | if (err) | |
1801 | goto err_setup_rx; | |
1802 | ||
1803 | /* clear any pending interrupts, may auto mask */ | |
1804 | err = i40evf_request_traffic_irqs(adapter, netdev->name); | |
1805 | if (err) | |
1806 | goto err_req_irq; | |
1807 | ||
1808 | i40evf_configure(adapter); | |
1809 | ||
1810 | err = i40evf_up_complete(adapter); | |
1811 | if (err) | |
1812 | goto err_req_irq; | |
1813 | ||
1814 | i40evf_irq_enable(adapter, true); | |
1815 | ||
1816 | return 0; | |
1817 | ||
1818 | err_req_irq: | |
1819 | i40evf_down(adapter); | |
1820 | i40evf_free_traffic_irqs(adapter); | |
1821 | err_setup_rx: | |
1822 | i40evf_free_all_rx_resources(adapter); | |
1823 | err_setup_tx: | |
1824 | i40evf_free_all_tx_resources(adapter); | |
1825 | ||
1826 | return err; | |
1827 | } | |
1828 | ||
1829 | /** | |
1830 | * i40evf_close - Disables a network interface | |
1831 | * @netdev: network interface device structure | |
1832 | * | |
1833 | * Returns 0, this is not allowed to fail | |
1834 | * | |
1835 | * The close entry point is called when an interface is de-activated | |
1836 | * by the OS. The hardware is still under the drivers control, but | |
1837 | * needs to be disabled. All IRQs except vector 0 (reserved for admin queue) | |
1838 | * are freed, along with all transmit and receive resources. | |
1839 | **/ | |
1840 | static int i40evf_close(struct net_device *netdev) | |
1841 | { | |
1842 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
1843 | ||
ef8693eb MW |
1844 | if (adapter->state <= __I40EVF_DOWN) |
1845 | return 0; | |
1846 | ||
ef8693eb | 1847 | |
5eae00c5 GR |
1848 | set_bit(__I40E_DOWN, &adapter->vsi.state); |
1849 | ||
1850 | i40evf_down(adapter); | |
ddf0b3a6 | 1851 | adapter->state = __I40EVF_DOWN; |
5eae00c5 GR |
1852 | i40evf_free_traffic_irqs(adapter); |
1853 | ||
1854 | i40evf_free_all_tx_resources(adapter); | |
1855 | i40evf_free_all_rx_resources(adapter); | |
1856 | ||
1857 | return 0; | |
1858 | } | |
1859 | ||
1860 | /** | |
1861 | * i40evf_get_stats - Get System Network Statistics | |
1862 | * @netdev: network interface device structure | |
1863 | * | |
1864 | * Returns the address of the device statistics structure. | |
1865 | * The statistics are actually updated from the timer callback. | |
1866 | **/ | |
1867 | static struct net_device_stats *i40evf_get_stats(struct net_device *netdev) | |
1868 | { | |
1869 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
1870 | ||
1871 | /* only return the current stats */ | |
1872 | return &adapter->net_stats; | |
1873 | } | |
1874 | ||
1875 | /** | |
1876 | * i40evf_reinit_locked - Software reinit | |
1877 | * @adapter: board private structure | |
1878 | * | |
1879 | * Reinititalizes the ring structures in response to a software configuration | |
1880 | * change. Roughly the same as close followed by open, but skips releasing | |
1881 | * and reallocating the interrupts. | |
1882 | **/ | |
1883 | void i40evf_reinit_locked(struct i40evf_adapter *adapter) | |
1884 | { | |
1885 | struct net_device *netdev = adapter->netdev; | |
1886 | int err; | |
1887 | ||
1888 | WARN_ON(in_interrupt()); | |
1889 | ||
5eae00c5 GR |
1890 | i40evf_down(adapter); |
1891 | ||
1892 | /* allocate transmit descriptors */ | |
1893 | err = i40evf_setup_all_tx_resources(adapter); | |
1894 | if (err) | |
1895 | goto err_reinit; | |
1896 | ||
1897 | /* allocate receive descriptors */ | |
1898 | err = i40evf_setup_all_rx_resources(adapter); | |
1899 | if (err) | |
1900 | goto err_reinit; | |
1901 | ||
1902 | i40evf_configure(adapter); | |
1903 | ||
1904 | err = i40evf_up_complete(adapter); | |
1905 | if (err) | |
1906 | goto err_reinit; | |
1907 | ||
1908 | i40evf_irq_enable(adapter, true); | |
1909 | return; | |
1910 | ||
1911 | err_reinit: | |
80e72893 | 1912 | dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); |
5eae00c5 GR |
1913 | i40evf_close(netdev); |
1914 | } | |
1915 | ||
1916 | /** | |
1917 | * i40evf_change_mtu - Change the Maximum Transfer Unit | |
1918 | * @netdev: network interface device structure | |
1919 | * @new_mtu: new value for maximum frame size | |
1920 | * | |
1921 | * Returns 0 on success, negative on failure | |
1922 | **/ | |
1923 | static int i40evf_change_mtu(struct net_device *netdev, int new_mtu) | |
1924 | { | |
1925 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
1926 | int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; | |
1927 | ||
1928 | if ((new_mtu < 68) || (max_frame > I40E_MAX_RXBUFFER)) | |
1929 | return -EINVAL; | |
1930 | ||
1931 | /* must set new MTU before calling down or up */ | |
1932 | netdev->mtu = new_mtu; | |
1933 | i40evf_reinit_locked(adapter); | |
1934 | return 0; | |
1935 | } | |
1936 | ||
1937 | static const struct net_device_ops i40evf_netdev_ops = { | |
1938 | .ndo_open = i40evf_open, | |
1939 | .ndo_stop = i40evf_close, | |
1940 | .ndo_start_xmit = i40evf_xmit_frame, | |
1941 | .ndo_get_stats = i40evf_get_stats, | |
1942 | .ndo_set_rx_mode = i40evf_set_rx_mode, | |
1943 | .ndo_validate_addr = eth_validate_addr, | |
1944 | .ndo_set_mac_address = i40evf_set_mac, | |
1945 | .ndo_change_mtu = i40evf_change_mtu, | |
1946 | .ndo_tx_timeout = i40evf_tx_timeout, | |
1947 | .ndo_vlan_rx_add_vid = i40evf_vlan_rx_add_vid, | |
1948 | .ndo_vlan_rx_kill_vid = i40evf_vlan_rx_kill_vid, | |
1949 | }; | |
1950 | ||
1951 | /** | |
1952 | * i40evf_check_reset_complete - check that VF reset is complete | |
1953 | * @hw: pointer to hw struct | |
1954 | * | |
1955 | * Returns 0 if device is ready to use, or -EBUSY if it's in reset. | |
1956 | **/ | |
1957 | static int i40evf_check_reset_complete(struct i40e_hw *hw) | |
1958 | { | |
1959 | u32 rstat; | |
1960 | int i; | |
1961 | ||
1962 | for (i = 0; i < 100; i++) { | |
fd35886a AS |
1963 | rstat = rd32(hw, I40E_VFGEN_RSTAT) & |
1964 | I40E_VFGEN_RSTAT_VFR_STATE_MASK; | |
1965 | if ((rstat == I40E_VFR_VFACTIVE) || | |
1966 | (rstat == I40E_VFR_COMPLETED)) | |
5eae00c5 | 1967 | return 0; |
f98a2006 | 1968 | usleep_range(10, 20); |
5eae00c5 GR |
1969 | } |
1970 | return -EBUSY; | |
1971 | } | |
1972 | ||
1973 | /** | |
1974 | * i40evf_init_task - worker thread to perform delayed initialization | |
1975 | * @work: pointer to work_struct containing our data | |
1976 | * | |
1977 | * This task completes the work that was begun in probe. Due to the nature | |
1978 | * of VF-PF communications, we may need to wait tens of milliseconds to get | |
1979 | * reponses back from the PF. Rather than busy-wait in probe and bog down the | |
1980 | * whole system, we'll do it in a task so we can sleep. | |
1981 | * This task only runs during driver init. Once we've established | |
1982 | * communications with the PF driver and set up our netdev, the watchdog | |
1983 | * takes over. | |
1984 | **/ | |
1985 | static void i40evf_init_task(struct work_struct *work) | |
1986 | { | |
1987 | struct i40evf_adapter *adapter = container_of(work, | |
1988 | struct i40evf_adapter, | |
1989 | init_task.work); | |
1990 | struct net_device *netdev = adapter->netdev; | |
1991 | struct i40evf_mac_filter *f; | |
1992 | struct i40e_hw *hw = &adapter->hw; | |
1993 | struct pci_dev *pdev = adapter->pdev; | |
1994 | int i, err, bufsz; | |
1995 | ||
1996 | switch (adapter->state) { | |
1997 | case __I40EVF_STARTUP: | |
1998 | /* driver loaded, probe complete */ | |
ef8693eb MW |
1999 | adapter->flags &= ~I40EVF_FLAG_PF_COMMS_FAILED; |
2000 | adapter->flags &= ~I40EVF_FLAG_RESET_PENDING; | |
5eae00c5 GR |
2001 | err = i40e_set_mac_type(hw); |
2002 | if (err) { | |
c2a137cb MW |
2003 | dev_err(&pdev->dev, "Failed to set MAC type (%d)\n", |
2004 | err); | |
5eae00c5 GR |
2005 | goto err; |
2006 | } | |
2007 | err = i40evf_check_reset_complete(hw); | |
2008 | if (err) { | |
0d9c7ea8 | 2009 | dev_info(&pdev->dev, "Device is still in reset (%d), retrying\n", |
75a64435 | 2010 | err); |
5eae00c5 GR |
2011 | goto err; |
2012 | } | |
2013 | hw->aq.num_arq_entries = I40EVF_AQ_LEN; | |
2014 | hw->aq.num_asq_entries = I40EVF_AQ_LEN; | |
2015 | hw->aq.arq_buf_size = I40EVF_MAX_AQ_BUF_SIZE; | |
2016 | hw->aq.asq_buf_size = I40EVF_MAX_AQ_BUF_SIZE; | |
2017 | ||
2018 | err = i40evf_init_adminq(hw); | |
2019 | if (err) { | |
c2a137cb MW |
2020 | dev_err(&pdev->dev, "Failed to init Admin Queue (%d)\n", |
2021 | err); | |
5eae00c5 GR |
2022 | goto err; |
2023 | } | |
2024 | err = i40evf_send_api_ver(adapter); | |
2025 | if (err) { | |
10bdd67b | 2026 | dev_err(&pdev->dev, "Unable to send to PF (%d)\n", err); |
5eae00c5 GR |
2027 | i40evf_shutdown_adminq(hw); |
2028 | goto err; | |
2029 | } | |
2030 | adapter->state = __I40EVF_INIT_VERSION_CHECK; | |
2031 | goto restart; | |
5eae00c5 | 2032 | case __I40EVF_INIT_VERSION_CHECK: |
10bdd67b | 2033 | if (!i40evf_asq_done(hw)) { |
80e72893 | 2034 | dev_err(&pdev->dev, "Admin queue command never completed\n"); |
906a6937 MW |
2035 | i40evf_shutdown_adminq(hw); |
2036 | adapter->state = __I40EVF_STARTUP; | |
5eae00c5 | 2037 | goto err; |
10bdd67b | 2038 | } |
5eae00c5 GR |
2039 | |
2040 | /* aq msg sent, awaiting reply */ | |
2041 | err = i40evf_verify_api_ver(adapter); | |
2042 | if (err) { | |
d4f82fd3 | 2043 | if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) |
56f9920a | 2044 | err = i40evf_send_api_ver(adapter); |
5eae00c5 GR |
2045 | goto err; |
2046 | } | |
2047 | err = i40evf_send_vf_config_msg(adapter); | |
2048 | if (err) { | |
3f2ab172 | 2049 | dev_err(&pdev->dev, "Unable to send config request (%d)\n", |
5eae00c5 GR |
2050 | err); |
2051 | goto err; | |
2052 | } | |
2053 | adapter->state = __I40EVF_INIT_GET_RESOURCES; | |
2054 | goto restart; | |
5eae00c5 GR |
2055 | case __I40EVF_INIT_GET_RESOURCES: |
2056 | /* aq msg sent, awaiting reply */ | |
2057 | if (!adapter->vf_res) { | |
2058 | bufsz = sizeof(struct i40e_virtchnl_vf_resource) + | |
2059 | (I40E_MAX_VF_VSI * | |
2060 | sizeof(struct i40e_virtchnl_vsi_resource)); | |
2061 | adapter->vf_res = kzalloc(bufsz, GFP_KERNEL); | |
c2a137cb | 2062 | if (!adapter->vf_res) |
5eae00c5 | 2063 | goto err; |
5eae00c5 GR |
2064 | } |
2065 | err = i40evf_get_vf_config(adapter); | |
906a6937 | 2066 | if (err == I40E_ERR_ADMIN_QUEUE_NO_WORK) { |
906a6937 MW |
2067 | err = i40evf_send_vf_config_msg(adapter); |
2068 | goto err; | |
2069 | } | |
5eae00c5 | 2070 | if (err) { |
c2a137cb MW |
2071 | dev_err(&pdev->dev, "Unable to get VF config (%d)\n", |
2072 | err); | |
5eae00c5 GR |
2073 | goto err_alloc; |
2074 | } | |
2075 | adapter->state = __I40EVF_INIT_SW; | |
2076 | break; | |
2077 | default: | |
2078 | goto err_alloc; | |
2079 | } | |
2080 | /* got VF config message back from PF, now we can parse it */ | |
2081 | for (i = 0; i < adapter->vf_res->num_vsis; i++) { | |
2082 | if (adapter->vf_res->vsi_res[i].vsi_type == I40E_VSI_SRIOV) | |
2083 | adapter->vsi_res = &adapter->vf_res->vsi_res[i]; | |
2084 | } | |
2085 | if (!adapter->vsi_res) { | |
c2a137cb | 2086 | dev_err(&pdev->dev, "No LAN VSI found\n"); |
5eae00c5 GR |
2087 | goto err_alloc; |
2088 | } | |
2089 | ||
2090 | adapter->flags |= I40EVF_FLAG_RX_CSUM_ENABLED; | |
2091 | ||
5eae00c5 GR |
2092 | netdev->netdev_ops = &i40evf_netdev_ops; |
2093 | i40evf_set_ethtool_ops(netdev); | |
2094 | netdev->watchdog_timeo = 5 * HZ; | |
dbbd8111 MW |
2095 | netdev->features |= NETIF_F_HIGHDMA | |
2096 | NETIF_F_SG | | |
5eae00c5 GR |
2097 | NETIF_F_IP_CSUM | |
2098 | NETIF_F_SCTP_CSUM | | |
2099 | NETIF_F_IPV6_CSUM | | |
2100 | NETIF_F_TSO | | |
2101 | NETIF_F_TSO6 | | |
3415e8ce | 2102 | NETIF_F_RXCSUM | |
5eae00c5 GR |
2103 | NETIF_F_GRO; |
2104 | ||
2105 | if (adapter->vf_res->vf_offload_flags | |
2106 | & I40E_VIRTCHNL_VF_OFFLOAD_VLAN) { | |
2107 | netdev->vlan_features = netdev->features; | |
2108 | netdev->features |= NETIF_F_HW_VLAN_CTAG_TX | | |
2109 | NETIF_F_HW_VLAN_CTAG_RX | | |
2110 | NETIF_F_HW_VLAN_CTAG_FILTER; | |
2111 | } | |
2112 | ||
3415e8ce GR |
2113 | /* copy netdev features into list of user selectable features */ |
2114 | netdev->hw_features |= netdev->features; | |
2115 | netdev->hw_features &= ~NETIF_F_RXCSUM; | |
2116 | ||
5eae00c5 | 2117 | if (!is_valid_ether_addr(adapter->hw.mac.addr)) { |
b34f90e7 | 2118 | dev_info(&pdev->dev, "Invalid MAC address %pM, using random\n", |
c2a137cb | 2119 | adapter->hw.mac.addr); |
5eae00c5 GR |
2120 | random_ether_addr(adapter->hw.mac.addr); |
2121 | } | |
9a173901 GR |
2122 | ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr); |
2123 | ether_addr_copy(netdev->perm_addr, adapter->hw.mac.addr); | |
5eae00c5 | 2124 | |
5eae00c5 | 2125 | f = kzalloc(sizeof(*f), GFP_ATOMIC); |
348d4994 | 2126 | if (!f) |
5eae00c5 GR |
2127 | goto err_sw_init; |
2128 | ||
9a173901 | 2129 | ether_addr_copy(f->macaddr, adapter->hw.mac.addr); |
5eae00c5 GR |
2130 | f->add = true; |
2131 | adapter->aq_required |= I40EVF_FLAG_AQ_ADD_MAC_FILTER; | |
2132 | ||
2133 | list_add(&f->list, &adapter->mac_filter_list); | |
2134 | ||
2135 | init_timer(&adapter->watchdog_timer); | |
2136 | adapter->watchdog_timer.function = &i40evf_watchdog_timer; | |
2137 | adapter->watchdog_timer.data = (unsigned long)adapter; | |
2138 | mod_timer(&adapter->watchdog_timer, jiffies + 1); | |
2139 | ||
cc052927 MW |
2140 | adapter->num_active_queues = min_t(int, |
2141 | adapter->vsi_res->num_queue_pairs, | |
2142 | (int)(num_online_cpus())); | |
d732a184 MW |
2143 | adapter->tx_desc_count = I40EVF_DEFAULT_TXD; |
2144 | adapter->rx_desc_count = I40EVF_DEFAULT_RXD; | |
5eae00c5 GR |
2145 | err = i40evf_init_interrupt_scheme(adapter); |
2146 | if (err) | |
2147 | goto err_sw_init; | |
2148 | i40evf_map_rings_to_vectors(adapter); | |
2149 | i40evf_configure_rss(adapter); | |
2150 | err = i40evf_request_misc_irq(adapter); | |
2151 | if (err) | |
2152 | goto err_sw_init; | |
2153 | ||
2154 | netif_carrier_off(netdev); | |
2155 | ||
5eae00c5 GR |
2156 | adapter->vsi.id = adapter->vsi_res->vsi_id; |
2157 | adapter->vsi.seid = adapter->vsi_res->vsi_id; /* dummy */ | |
2158 | adapter->vsi.back = adapter; | |
2159 | adapter->vsi.base_vector = 1; | |
2160 | adapter->vsi.work_limit = I40E_DEFAULT_IRQ_WORK; | |
ca99eb99 MW |
2161 | adapter->vsi.rx_itr_setting = (I40E_ITR_DYNAMIC | |
2162 | ITR_REG_TO_USEC(I40E_ITR_RX_DEF)); | |
2163 | adapter->vsi.tx_itr_setting = (I40E_ITR_DYNAMIC | | |
2164 | ITR_REG_TO_USEC(I40E_ITR_TX_DEF)); | |
5eae00c5 GR |
2165 | adapter->vsi.netdev = adapter->netdev; |
2166 | ||
ef8693eb MW |
2167 | if (!adapter->netdev_registered) { |
2168 | err = register_netdev(netdev); | |
2169 | if (err) | |
2170 | goto err_register; | |
2171 | } | |
5eae00c5 GR |
2172 | |
2173 | adapter->netdev_registered = true; | |
2174 | ||
2175 | netif_tx_stop_all_queues(netdev); | |
2176 | ||
b34f90e7 | 2177 | dev_info(&pdev->dev, "MAC address: %pM\n", adapter->hw.mac.addr); |
5eae00c5 GR |
2178 | if (netdev->features & NETIF_F_GRO) |
2179 | dev_info(&pdev->dev, "GRO is enabled\n"); | |
2180 | ||
2181 | dev_info(&pdev->dev, "%s\n", i40evf_driver_string); | |
2182 | adapter->state = __I40EVF_DOWN; | |
2183 | set_bit(__I40E_DOWN, &adapter->vsi.state); | |
2184 | i40evf_misc_irq_enable(adapter); | |
2185 | return; | |
2186 | restart: | |
2187 | schedule_delayed_work(&adapter->init_task, | |
2188 | msecs_to_jiffies(50)); | |
2189 | return; | |
2190 | ||
2191 | err_register: | |
2192 | i40evf_free_misc_irq(adapter); | |
2193 | err_sw_init: | |
2194 | i40evf_reset_interrupt_capability(adapter); | |
5eae00c5 GR |
2195 | err_alloc: |
2196 | kfree(adapter->vf_res); | |
2197 | adapter->vf_res = NULL; | |
2198 | err: | |
2199 | /* Things went into the weeds, so try again later */ | |
2200 | if (++adapter->aq_wait_count > I40EVF_AQ_MAX_ERR) { | |
80e72893 | 2201 | dev_err(&pdev->dev, "Failed to communicate with PF; giving up\n"); |
ef8693eb | 2202 | adapter->flags |= I40EVF_FLAG_PF_COMMS_FAILED; |
5eae00c5 GR |
2203 | return; /* do not reschedule */ |
2204 | } | |
2205 | schedule_delayed_work(&adapter->init_task, HZ * 3); | |
5eae00c5 GR |
2206 | } |
2207 | ||
2208 | /** | |
2209 | * i40evf_shutdown - Shutdown the device in preparation for a reboot | |
2210 | * @pdev: pci device structure | |
2211 | **/ | |
2212 | static void i40evf_shutdown(struct pci_dev *pdev) | |
2213 | { | |
2214 | struct net_device *netdev = pci_get_drvdata(pdev); | |
2215 | ||
2216 | netif_device_detach(netdev); | |
2217 | ||
2218 | if (netif_running(netdev)) | |
2219 | i40evf_close(netdev); | |
2220 | ||
2221 | #ifdef CONFIG_PM | |
2222 | pci_save_state(pdev); | |
2223 | ||
2224 | #endif | |
2225 | pci_disable_device(pdev); | |
2226 | } | |
2227 | ||
2228 | /** | |
2229 | * i40evf_probe - Device Initialization Routine | |
2230 | * @pdev: PCI device information struct | |
2231 | * @ent: entry in i40evf_pci_tbl | |
2232 | * | |
2233 | * Returns 0 on success, negative on failure | |
2234 | * | |
2235 | * i40evf_probe initializes an adapter identified by a pci_dev structure. | |
2236 | * The OS initialization, configuring of the adapter private structure, | |
2237 | * and a hardware reset occur. | |
2238 | **/ | |
2239 | static int i40evf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |
2240 | { | |
2241 | struct net_device *netdev; | |
2242 | struct i40evf_adapter *adapter = NULL; | |
2243 | struct i40e_hw *hw = NULL; | |
dbbd8111 | 2244 | int err; |
5eae00c5 GR |
2245 | |
2246 | err = pci_enable_device(pdev); | |
2247 | if (err) | |
2248 | return err; | |
2249 | ||
6494294f | 2250 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); |
6494294f | 2251 | if (err) { |
e3e3bfdd JS |
2252 | err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); |
2253 | if (err) { | |
2254 | dev_err(&pdev->dev, | |
2255 | "DMA configuration failed: 0x%x\n", err); | |
2256 | goto err_dma; | |
2257 | } | |
5eae00c5 GR |
2258 | } |
2259 | ||
2260 | err = pci_request_regions(pdev, i40evf_driver_name); | |
2261 | if (err) { | |
2262 | dev_err(&pdev->dev, | |
2263 | "pci_request_regions failed 0x%x\n", err); | |
2264 | goto err_pci_reg; | |
2265 | } | |
2266 | ||
2267 | pci_enable_pcie_error_reporting(pdev); | |
2268 | ||
2269 | pci_set_master(pdev); | |
2270 | ||
2271 | netdev = alloc_etherdev_mq(sizeof(struct i40evf_adapter), | |
2272 | MAX_TX_QUEUES); | |
2273 | if (!netdev) { | |
2274 | err = -ENOMEM; | |
2275 | goto err_alloc_etherdev; | |
2276 | } | |
2277 | ||
2278 | SET_NETDEV_DEV(netdev, &pdev->dev); | |
2279 | ||
2280 | pci_set_drvdata(pdev, netdev); | |
2281 | adapter = netdev_priv(netdev); | |
5eae00c5 GR |
2282 | |
2283 | adapter->netdev = netdev; | |
2284 | adapter->pdev = pdev; | |
2285 | ||
2286 | hw = &adapter->hw; | |
2287 | hw->back = adapter; | |
2288 | ||
2289 | adapter->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1; | |
2290 | adapter->state = __I40EVF_STARTUP; | |
2291 | ||
2292 | /* Call save state here because it relies on the adapter struct. */ | |
2293 | pci_save_state(pdev); | |
2294 | ||
2295 | hw->hw_addr = ioremap(pci_resource_start(pdev, 0), | |
2296 | pci_resource_len(pdev, 0)); | |
2297 | if (!hw->hw_addr) { | |
2298 | err = -EIO; | |
2299 | goto err_ioremap; | |
2300 | } | |
2301 | hw->vendor_id = pdev->vendor; | |
2302 | hw->device_id = pdev->device; | |
2303 | pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); | |
2304 | hw->subsystem_vendor_id = pdev->subsystem_vendor; | |
2305 | hw->subsystem_device_id = pdev->subsystem_device; | |
2306 | hw->bus.device = PCI_SLOT(pdev->devfn); | |
2307 | hw->bus.func = PCI_FUNC(pdev->devfn); | |
2308 | ||
8bb1a540 SK |
2309 | INIT_LIST_HEAD(&adapter->mac_filter_list); |
2310 | INIT_LIST_HEAD(&adapter->vlan_filter_list); | |
2311 | ||
5eae00c5 GR |
2312 | INIT_WORK(&adapter->reset_task, i40evf_reset_task); |
2313 | INIT_WORK(&adapter->adminq_task, i40evf_adminq_task); | |
2314 | INIT_WORK(&adapter->watchdog_task, i40evf_watchdog_task); | |
2315 | INIT_DELAYED_WORK(&adapter->init_task, i40evf_init_task); | |
2316 | schedule_delayed_work(&adapter->init_task, 10); | |
2317 | ||
2318 | return 0; | |
2319 | ||
2320 | err_ioremap: | |
2321 | free_netdev(netdev); | |
2322 | err_alloc_etherdev: | |
2323 | pci_release_regions(pdev); | |
2324 | err_pci_reg: | |
2325 | err_dma: | |
2326 | pci_disable_device(pdev); | |
2327 | return err; | |
2328 | } | |
2329 | ||
2330 | #ifdef CONFIG_PM | |
2331 | /** | |
2332 | * i40evf_suspend - Power management suspend routine | |
2333 | * @pdev: PCI device information struct | |
2334 | * @state: unused | |
2335 | * | |
2336 | * Called when the system (VM) is entering sleep/suspend. | |
2337 | **/ | |
2338 | static int i40evf_suspend(struct pci_dev *pdev, pm_message_t state) | |
2339 | { | |
2340 | struct net_device *netdev = pci_get_drvdata(pdev); | |
2341 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
2342 | int retval = 0; | |
2343 | ||
2344 | netif_device_detach(netdev); | |
2345 | ||
2346 | if (netif_running(netdev)) { | |
2347 | rtnl_lock(); | |
2348 | i40evf_down(adapter); | |
2349 | rtnl_unlock(); | |
2350 | } | |
2351 | i40evf_free_misc_irq(adapter); | |
2352 | i40evf_reset_interrupt_capability(adapter); | |
2353 | ||
2354 | retval = pci_save_state(pdev); | |
2355 | if (retval) | |
2356 | return retval; | |
2357 | ||
2358 | pci_disable_device(pdev); | |
2359 | ||
2360 | return 0; | |
2361 | } | |
2362 | ||
2363 | /** | |
2364 | * i40evf_resume - Power managment resume routine | |
2365 | * @pdev: PCI device information struct | |
2366 | * | |
2367 | * Called when the system (VM) is resumed from sleep/suspend. | |
2368 | **/ | |
2369 | static int i40evf_resume(struct pci_dev *pdev) | |
2370 | { | |
2371 | struct i40evf_adapter *adapter = pci_get_drvdata(pdev); | |
2372 | struct net_device *netdev = adapter->netdev; | |
2373 | u32 err; | |
2374 | ||
2375 | pci_set_power_state(pdev, PCI_D0); | |
2376 | pci_restore_state(pdev); | |
2377 | /* pci_restore_state clears dev->state_saved so call | |
2378 | * pci_save_state to restore it. | |
2379 | */ | |
2380 | pci_save_state(pdev); | |
2381 | ||
2382 | err = pci_enable_device_mem(pdev); | |
2383 | if (err) { | |
2384 | dev_err(&pdev->dev, "Cannot enable PCI device from suspend.\n"); | |
2385 | return err; | |
2386 | } | |
2387 | pci_set_master(pdev); | |
2388 | ||
2389 | rtnl_lock(); | |
2390 | err = i40evf_set_interrupt_capability(adapter); | |
2391 | if (err) { | |
2392 | dev_err(&pdev->dev, "Cannot enable MSI-X interrupts.\n"); | |
2393 | return err; | |
2394 | } | |
2395 | err = i40evf_request_misc_irq(adapter); | |
2396 | rtnl_unlock(); | |
2397 | if (err) { | |
2398 | dev_err(&pdev->dev, "Cannot get interrupt vector.\n"); | |
2399 | return err; | |
2400 | } | |
2401 | ||
2402 | schedule_work(&adapter->reset_task); | |
2403 | ||
2404 | netif_device_attach(netdev); | |
2405 | ||
2406 | return err; | |
2407 | } | |
2408 | ||
2409 | #endif /* CONFIG_PM */ | |
2410 | /** | |
2411 | * i40evf_remove - Device Removal Routine | |
2412 | * @pdev: PCI device information struct | |
2413 | * | |
2414 | * i40evf_remove is called by the PCI subsystem to alert the driver | |
2415 | * that it should release a PCI device. The could be caused by a | |
2416 | * Hot-Plug event, or because the driver is going to be removed from | |
2417 | * memory. | |
2418 | **/ | |
2419 | static void i40evf_remove(struct pci_dev *pdev) | |
2420 | { | |
2421 | struct net_device *netdev = pci_get_drvdata(pdev); | |
2422 | struct i40evf_adapter *adapter = netdev_priv(netdev); | |
6ba36a24 | 2423 | struct i40evf_mac_filter *f, *ftmp; |
5eae00c5 | 2424 | struct i40e_hw *hw = &adapter->hw; |
53d0b3ae | 2425 | int count = 50; |
5eae00c5 GR |
2426 | |
2427 | cancel_delayed_work_sync(&adapter->init_task); | |
ef8693eb | 2428 | cancel_work_sync(&adapter->reset_task); |
5eae00c5 GR |
2429 | |
2430 | if (adapter->netdev_registered) { | |
2431 | unregister_netdev(netdev); | |
2432 | adapter->netdev_registered = false; | |
2433 | } | |
53d0b3ae MW |
2434 | while (count-- && adapter->aq_required) |
2435 | msleep(50); | |
2436 | ||
2437 | if (count < 0) | |
2438 | dev_err(&pdev->dev, "Timed out waiting for PF driver.\n"); | |
5eae00c5 GR |
2439 | adapter->state = __I40EVF_REMOVE; |
2440 | ||
dbb01c8a | 2441 | if (adapter->msix_entries) { |
5eae00c5 | 2442 | i40evf_misc_irq_disable(adapter); |
5eae00c5 | 2443 | i40evf_free_misc_irq(adapter); |
5eae00c5 | 2444 | i40evf_reset_interrupt_capability(adapter); |
d31944d6 | 2445 | i40evf_free_q_vectors(adapter); |
5eae00c5 GR |
2446 | } |
2447 | ||
e5d17c3e MW |
2448 | if (adapter->watchdog_timer.function) |
2449 | del_timer_sync(&adapter->watchdog_timer); | |
2450 | ||
dbb01c8a MW |
2451 | flush_scheduled_work(); |
2452 | ||
5eae00c5 GR |
2453 | if (hw->aq.asq.count) |
2454 | i40evf_shutdown_adminq(hw); | |
2455 | ||
2456 | iounmap(hw->hw_addr); | |
2457 | pci_release_regions(pdev); | |
2458 | ||
2459 | i40evf_free_queues(adapter); | |
2460 | kfree(adapter->vf_res); | |
6ba36a24 MW |
2461 | /* If we got removed before an up/down sequence, we've got a filter |
2462 | * hanging out there that we need to get rid of. | |
2463 | */ | |
2464 | list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) { | |
2465 | list_del(&f->list); | |
2466 | kfree(f); | |
2467 | } | |
37dfdf37 MW |
2468 | list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) { |
2469 | list_del(&f->list); | |
2470 | kfree(f); | |
2471 | } | |
5eae00c5 GR |
2472 | |
2473 | free_netdev(netdev); | |
2474 | ||
2475 | pci_disable_pcie_error_reporting(pdev); | |
2476 | ||
2477 | pci_disable_device(pdev); | |
2478 | } | |
2479 | ||
2480 | static struct pci_driver i40evf_driver = { | |
2481 | .name = i40evf_driver_name, | |
2482 | .id_table = i40evf_pci_tbl, | |
2483 | .probe = i40evf_probe, | |
2484 | .remove = i40evf_remove, | |
2485 | #ifdef CONFIG_PM | |
2486 | .suspend = i40evf_suspend, | |
2487 | .resume = i40evf_resume, | |
2488 | #endif | |
2489 | .shutdown = i40evf_shutdown, | |
2490 | }; | |
2491 | ||
2492 | /** | |
2493 | * i40e_init_module - Driver Registration Routine | |
2494 | * | |
2495 | * i40e_init_module is the first routine called when the driver is | |
2496 | * loaded. All it does is register with the PCI subsystem. | |
2497 | **/ | |
2498 | static int __init i40evf_init_module(void) | |
2499 | { | |
2500 | int ret; | |
75a64435 | 2501 | |
5eae00c5 | 2502 | pr_info("i40evf: %s - version %s\n", i40evf_driver_string, |
75a64435 | 2503 | i40evf_driver_version); |
5eae00c5 GR |
2504 | |
2505 | pr_info("%s\n", i40evf_copyright); | |
2506 | ||
2507 | ret = pci_register_driver(&i40evf_driver); | |
2508 | return ret; | |
2509 | } | |
2510 | ||
2511 | module_init(i40evf_init_module); | |
2512 | ||
2513 | /** | |
2514 | * i40e_exit_module - Driver Exit Cleanup Routine | |
2515 | * | |
2516 | * i40e_exit_module is called just before the driver is removed | |
2517 | * from memory. | |
2518 | **/ | |
2519 | static void __exit i40evf_exit_module(void) | |
2520 | { | |
2521 | pci_unregister_driver(&i40evf_driver); | |
2522 | } | |
2523 | ||
2524 | module_exit(i40evf_exit_module); | |
2525 | ||
2526 | /* i40evf_main.c */ |