1 /*******************************************************************************
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 - 2016 Intel Corporation.
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.
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
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/>.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
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
25 ******************************************************************************/
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
);
31 static int i40evf_close(struct net_device
*netdev
);
33 char i40evf_driver_name
[] = "i40evf";
34 static const char i40evf_driver_string
[] =
35 "Intel(R) 40-10 Gigabit Virtual Function Network Driver";
39 #define DRV_VERSION_MAJOR 1
40 #define DRV_VERSION_MINOR 5
41 #define DRV_VERSION_BUILD 10
42 #define DRV_VERSION __stringify(DRV_VERSION_MAJOR) "." \
43 __stringify(DRV_VERSION_MINOR) "." \
44 __stringify(DRV_VERSION_BUILD) \
46 const char i40evf_driver_version
[] = DRV_VERSION
;
47 static const char i40evf_copyright
[] =
48 "Copyright (c) 2013 - 2015 Intel Corporation.";
50 /* i40evf_pci_tbl - PCI Device ID Table
52 * Wildcard entries (PCI_ANY_ID) should come last
53 * Last entry must be all 0s
55 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
56 * Class, Class Mask, private data (not used) }
58 static const struct pci_device_id i40evf_pci_tbl
[] = {
59 {PCI_VDEVICE(INTEL
, I40E_DEV_ID_VF
), 0},
60 {PCI_VDEVICE(INTEL
, I40E_DEV_ID_X722_VF
), 0},
61 /* required last entry */
65 MODULE_DEVICE_TABLE(pci
, i40evf_pci_tbl
);
67 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
68 MODULE_DESCRIPTION("Intel(R) XL710 X710 Virtual Function Network Driver");
69 MODULE_LICENSE("GPL");
70 MODULE_VERSION(DRV_VERSION
);
72 static struct workqueue_struct
*i40evf_wq
;
75 * i40evf_allocate_dma_mem_d - OS specific memory alloc for shared code
76 * @hw: pointer to the HW structure
77 * @mem: ptr to mem struct to fill out
78 * @size: size of memory requested
79 * @alignment: what to align the allocation to
81 i40e_status
i40evf_allocate_dma_mem_d(struct i40e_hw
*hw
,
82 struct i40e_dma_mem
*mem
,
83 u64 size
, u32 alignment
)
85 struct i40evf_adapter
*adapter
= (struct i40evf_adapter
*)hw
->back
;
88 return I40E_ERR_PARAM
;
90 mem
->size
= ALIGN(size
, alignment
);
91 mem
->va
= dma_alloc_coherent(&adapter
->pdev
->dev
, mem
->size
,
92 (dma_addr_t
*)&mem
->pa
, GFP_KERNEL
);
96 return I40E_ERR_NO_MEMORY
;
100 * i40evf_free_dma_mem_d - OS specific memory free for shared code
101 * @hw: pointer to the HW structure
102 * @mem: ptr to mem struct to free
104 i40e_status
i40evf_free_dma_mem_d(struct i40e_hw
*hw
, struct i40e_dma_mem
*mem
)
106 struct i40evf_adapter
*adapter
= (struct i40evf_adapter
*)hw
->back
;
108 if (!mem
|| !mem
->va
)
109 return I40E_ERR_PARAM
;
110 dma_free_coherent(&adapter
->pdev
->dev
, mem
->size
,
111 mem
->va
, (dma_addr_t
)mem
->pa
);
116 * i40evf_allocate_virt_mem_d - OS specific memory alloc for shared code
117 * @hw: pointer to the HW structure
118 * @mem: ptr to mem struct to fill out
119 * @size: size of memory requested
121 i40e_status
i40evf_allocate_virt_mem_d(struct i40e_hw
*hw
,
122 struct i40e_virt_mem
*mem
, u32 size
)
125 return I40E_ERR_PARAM
;
128 mem
->va
= kzalloc(size
, GFP_KERNEL
);
133 return I40E_ERR_NO_MEMORY
;
137 * i40evf_free_virt_mem_d - OS specific memory free for shared code
138 * @hw: pointer to the HW structure
139 * @mem: ptr to mem struct to free
141 i40e_status
i40evf_free_virt_mem_d(struct i40e_hw
*hw
,
142 struct i40e_virt_mem
*mem
)
145 return I40E_ERR_PARAM
;
147 /* it's ok to kfree a NULL pointer */
154 * i40evf_debug_d - OS dependent version of debug printing
155 * @hw: pointer to the HW structure
156 * @mask: debug level mask
157 * @fmt_str: printf-type format description
159 void i40evf_debug_d(void *hw
, u32 mask
, char *fmt_str
, ...)
164 if (!(mask
& ((struct i40e_hw
*)hw
)->debug_mask
))
167 va_start(argptr
, fmt_str
);
168 vsnprintf(buf
, sizeof(buf
), fmt_str
, argptr
);
171 /* the debug string is already formatted with a newline */
176 * i40evf_schedule_reset - Set the flags and schedule a reset event
177 * @adapter: board private structure
179 void i40evf_schedule_reset(struct i40evf_adapter
*adapter
)
181 if (!(adapter
->flags
&
182 (I40EVF_FLAG_RESET_PENDING
| I40EVF_FLAG_RESET_NEEDED
))) {
183 adapter
->flags
|= I40EVF_FLAG_RESET_NEEDED
;
184 schedule_work(&adapter
->reset_task
);
189 * i40evf_tx_timeout - Respond to a Tx Hang
190 * @netdev: network interface device structure
192 static void i40evf_tx_timeout(struct net_device
*netdev
)
194 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
196 adapter
->tx_timeout_count
++;
197 i40evf_schedule_reset(adapter
);
201 * i40evf_misc_irq_disable - Mask off interrupt generation on the NIC
202 * @adapter: board private structure
204 static void i40evf_misc_irq_disable(struct i40evf_adapter
*adapter
)
206 struct i40e_hw
*hw
= &adapter
->hw
;
208 wr32(hw
, I40E_VFINT_DYN_CTL01
, 0);
211 rd32(hw
, I40E_VFGEN_RSTAT
);
213 synchronize_irq(adapter
->msix_entries
[0].vector
);
217 * i40evf_misc_irq_enable - Enable default interrupt generation settings
218 * @adapter: board private structure
220 static void i40evf_misc_irq_enable(struct i40evf_adapter
*adapter
)
222 struct i40e_hw
*hw
= &adapter
->hw
;
224 wr32(hw
, I40E_VFINT_DYN_CTL01
, I40E_VFINT_DYN_CTL01_INTENA_MASK
|
225 I40E_VFINT_DYN_CTL01_ITR_INDX_MASK
);
226 wr32(hw
, I40E_VFINT_ICR0_ENA1
, I40E_VFINT_ICR0_ENA1_ADMINQ_MASK
);
229 rd32(hw
, I40E_VFGEN_RSTAT
);
233 * i40evf_irq_disable - Mask off interrupt generation on the NIC
234 * @adapter: board private structure
236 static void i40evf_irq_disable(struct i40evf_adapter
*adapter
)
239 struct i40e_hw
*hw
= &adapter
->hw
;
241 if (!adapter
->msix_entries
)
244 for (i
= 1; i
< adapter
->num_msix_vectors
; i
++) {
245 wr32(hw
, I40E_VFINT_DYN_CTLN1(i
- 1), 0);
246 synchronize_irq(adapter
->msix_entries
[i
].vector
);
249 rd32(hw
, I40E_VFGEN_RSTAT
);
253 * i40evf_irq_enable_queues - Enable interrupt for specified queues
254 * @adapter: board private structure
255 * @mask: bitmap of queues to enable
257 void i40evf_irq_enable_queues(struct i40evf_adapter
*adapter
, u32 mask
)
259 struct i40e_hw
*hw
= &adapter
->hw
;
262 for (i
= 1; i
< adapter
->num_msix_vectors
; i
++) {
263 if (mask
& BIT(i
- 1)) {
264 wr32(hw
, I40E_VFINT_DYN_CTLN1(i
- 1),
265 I40E_VFINT_DYN_CTLN1_INTENA_MASK
|
266 I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK
|
267 I40E_VFINT_DYN_CTLN1_CLEARPBA_MASK
);
273 * i40evf_fire_sw_int - Generate SW interrupt for specified vectors
274 * @adapter: board private structure
275 * @mask: bitmap of vectors to trigger
277 static void i40evf_fire_sw_int(struct i40evf_adapter
*adapter
, u32 mask
)
279 struct i40e_hw
*hw
= &adapter
->hw
;
284 dyn_ctl
= rd32(hw
, I40E_VFINT_DYN_CTL01
);
285 dyn_ctl
|= I40E_VFINT_DYN_CTLN1_SWINT_TRIG_MASK
|
286 I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK
|
287 I40E_VFINT_DYN_CTLN1_CLEARPBA_MASK
;
288 wr32(hw
, I40E_VFINT_DYN_CTL01
, dyn_ctl
);
290 for (i
= 1; i
< adapter
->num_msix_vectors
; i
++) {
292 dyn_ctl
= rd32(hw
, I40E_VFINT_DYN_CTLN1(i
- 1));
293 dyn_ctl
|= I40E_VFINT_DYN_CTLN1_SWINT_TRIG_MASK
|
294 I40E_VFINT_DYN_CTLN1_ITR_INDX_MASK
|
295 I40E_VFINT_DYN_CTLN1_CLEARPBA_MASK
;
296 wr32(hw
, I40E_VFINT_DYN_CTLN1(i
- 1), dyn_ctl
);
302 * i40evf_irq_enable - Enable default interrupt generation settings
303 * @adapter: board private structure
304 * @flush: boolean value whether to run rd32()
306 void i40evf_irq_enable(struct i40evf_adapter
*adapter
, bool flush
)
308 struct i40e_hw
*hw
= &adapter
->hw
;
310 i40evf_misc_irq_enable(adapter
);
311 i40evf_irq_enable_queues(adapter
, ~0);
314 rd32(hw
, I40E_VFGEN_RSTAT
);
318 * i40evf_msix_aq - Interrupt handler for vector 0
319 * @irq: interrupt number
320 * @data: pointer to netdev
322 static irqreturn_t
i40evf_msix_aq(int irq
, void *data
)
324 struct net_device
*netdev
= data
;
325 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
326 struct i40e_hw
*hw
= &adapter
->hw
;
329 /* handle non-queue interrupts, these reads clear the registers */
330 val
= rd32(hw
, I40E_VFINT_ICR01
);
331 val
= rd32(hw
, I40E_VFINT_ICR0_ENA1
);
333 val
= rd32(hw
, I40E_VFINT_DYN_CTL01
) |
334 I40E_VFINT_DYN_CTL01_CLEARPBA_MASK
;
335 wr32(hw
, I40E_VFINT_DYN_CTL01
, val
);
337 /* schedule work on the private workqueue */
338 schedule_work(&adapter
->adminq_task
);
344 * i40evf_msix_clean_rings - MSIX mode Interrupt Handler
345 * @irq: interrupt number
346 * @data: pointer to a q_vector
348 static irqreturn_t
i40evf_msix_clean_rings(int irq
, void *data
)
350 struct i40e_q_vector
*q_vector
= data
;
352 if (!q_vector
->tx
.ring
&& !q_vector
->rx
.ring
)
355 napi_schedule_irqoff(&q_vector
->napi
);
361 * i40evf_map_vector_to_rxq - associate irqs with rx queues
362 * @adapter: board private structure
363 * @v_idx: interrupt number
364 * @r_idx: queue number
367 i40evf_map_vector_to_rxq(struct i40evf_adapter
*adapter
, int v_idx
, int r_idx
)
369 struct i40e_q_vector
*q_vector
= &adapter
->q_vectors
[v_idx
];
370 struct i40e_ring
*rx_ring
= &adapter
->rx_rings
[r_idx
];
372 rx_ring
->q_vector
= q_vector
;
373 rx_ring
->next
= q_vector
->rx
.ring
;
374 rx_ring
->vsi
= &adapter
->vsi
;
375 q_vector
->rx
.ring
= rx_ring
;
376 q_vector
->rx
.count
++;
377 q_vector
->rx
.latency_range
= I40E_LOW_LATENCY
;
378 q_vector
->itr_countdown
= ITR_COUNTDOWN_START
;
382 * i40evf_map_vector_to_txq - associate irqs with tx queues
383 * @adapter: board private structure
384 * @v_idx: interrupt number
385 * @t_idx: queue number
388 i40evf_map_vector_to_txq(struct i40evf_adapter
*adapter
, int v_idx
, int t_idx
)
390 struct i40e_q_vector
*q_vector
= &adapter
->q_vectors
[v_idx
];
391 struct i40e_ring
*tx_ring
= &adapter
->tx_rings
[t_idx
];
393 tx_ring
->q_vector
= q_vector
;
394 tx_ring
->next
= q_vector
->tx
.ring
;
395 tx_ring
->vsi
= &adapter
->vsi
;
396 q_vector
->tx
.ring
= tx_ring
;
397 q_vector
->tx
.count
++;
398 q_vector
->tx
.latency_range
= I40E_LOW_LATENCY
;
399 q_vector
->itr_countdown
= ITR_COUNTDOWN_START
;
400 q_vector
->num_ringpairs
++;
401 q_vector
->ring_mask
|= BIT(t_idx
);
405 * i40evf_map_rings_to_vectors - Maps descriptor rings to vectors
406 * @adapter: board private structure to initialize
408 * This function maps descriptor rings to the queue-specific vectors
409 * we were allotted through the MSI-X enabling code. Ideally, we'd have
410 * one vector per ring/queue, but on a constrained vector budget, we
411 * group the rings as "efficiently" as possible. You would add new
412 * mapping configurations in here.
414 static int i40evf_map_rings_to_vectors(struct i40evf_adapter
*adapter
)
418 int rxr_idx
= 0, txr_idx
= 0;
419 int rxr_remaining
= adapter
->num_active_queues
;
420 int txr_remaining
= adapter
->num_active_queues
;
425 q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
427 /* The ideal configuration...
428 * We have enough vectors to map one per queue.
430 if (q_vectors
>= (rxr_remaining
* 2)) {
431 for (; rxr_idx
< rxr_remaining
; v_start
++, rxr_idx
++)
432 i40evf_map_vector_to_rxq(adapter
, v_start
, rxr_idx
);
434 for (; txr_idx
< txr_remaining
; v_start
++, txr_idx
++)
435 i40evf_map_vector_to_txq(adapter
, v_start
, txr_idx
);
439 /* If we don't have enough vectors for a 1-to-1
440 * mapping, we'll have to group them so there are
441 * multiple queues per vector.
442 * Re-adjusting *qpv takes care of the remainder.
444 for (i
= v_start
; i
< q_vectors
; i
++) {
445 rqpv
= DIV_ROUND_UP(rxr_remaining
, q_vectors
- i
);
446 for (j
= 0; j
< rqpv
; j
++) {
447 i40evf_map_vector_to_rxq(adapter
, i
, rxr_idx
);
452 for (i
= v_start
; i
< q_vectors
; i
++) {
453 tqpv
= DIV_ROUND_UP(txr_remaining
, q_vectors
- i
);
454 for (j
= 0; j
< tqpv
; j
++) {
455 i40evf_map_vector_to_txq(adapter
, i
, txr_idx
);
462 adapter
->aq_required
|= I40EVF_FLAG_AQ_MAP_VECTORS
;
467 #ifdef CONFIG_NET_POLL_CONTROLLER
469 * i40evf_netpoll - A Polling 'interrupt' handler
470 * @netdev: network interface device structure
472 * This is used by netconsole to send skbs without having to re-enable
473 * interrupts. It's not called while the normal interrupt routine is executing.
475 static void i40evf_netpoll(struct net_device
*netdev
)
477 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
478 int q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
481 /* if interface is down do nothing */
482 if (test_bit(__I40E_DOWN
, &adapter
->vsi
.state
))
485 for (i
= 0; i
< q_vectors
; i
++)
486 i40evf_msix_clean_rings(0, &adapter
->q_vectors
[i
]);
491 * i40evf_request_traffic_irqs - Initialize MSI-X interrupts
492 * @adapter: board private structure
494 * Allocates MSI-X vectors for tx and rx handling, and requests
495 * interrupts from the kernel.
498 i40evf_request_traffic_irqs(struct i40evf_adapter
*adapter
, char *basename
)
500 int vector
, err
, q_vectors
;
501 int rx_int_idx
= 0, tx_int_idx
= 0;
503 i40evf_irq_disable(adapter
);
504 /* Decrement for Other and TCP Timer vectors */
505 q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
507 for (vector
= 0; vector
< q_vectors
; vector
++) {
508 struct i40e_q_vector
*q_vector
= &adapter
->q_vectors
[vector
];
510 if (q_vector
->tx
.ring
&& q_vector
->rx
.ring
) {
511 snprintf(q_vector
->name
, sizeof(q_vector
->name
) - 1,
512 "i40evf-%s-%s-%d", basename
,
513 "TxRx", rx_int_idx
++);
515 } else if (q_vector
->rx
.ring
) {
516 snprintf(q_vector
->name
, sizeof(q_vector
->name
) - 1,
517 "i40evf-%s-%s-%d", basename
,
519 } else if (q_vector
->tx
.ring
) {
520 snprintf(q_vector
->name
, sizeof(q_vector
->name
) - 1,
521 "i40evf-%s-%s-%d", basename
,
524 /* skip this unused q_vector */
528 adapter
->msix_entries
[vector
+ NONQ_VECS
].vector
,
529 i40evf_msix_clean_rings
,
534 dev_info(&adapter
->pdev
->dev
,
535 "Request_irq failed, error: %d\n", err
);
536 goto free_queue_irqs
;
538 /* assign the mask for this irq */
539 irq_set_affinity_hint(
540 adapter
->msix_entries
[vector
+ NONQ_VECS
].vector
,
541 q_vector
->affinity_mask
);
549 irq_set_affinity_hint(
550 adapter
->msix_entries
[vector
+ NONQ_VECS
].vector
,
552 free_irq(adapter
->msix_entries
[vector
+ NONQ_VECS
].vector
,
553 &adapter
->q_vectors
[vector
]);
559 * i40evf_request_misc_irq - Initialize MSI-X interrupts
560 * @adapter: board private structure
562 * Allocates MSI-X vector 0 and requests interrupts from the kernel. This
563 * vector is only for the admin queue, and stays active even when the netdev
566 static int i40evf_request_misc_irq(struct i40evf_adapter
*adapter
)
568 struct net_device
*netdev
= adapter
->netdev
;
571 snprintf(adapter
->misc_vector_name
,
572 sizeof(adapter
->misc_vector_name
) - 1, "i40evf-%s:mbx",
573 dev_name(&adapter
->pdev
->dev
));
574 err
= request_irq(adapter
->msix_entries
[0].vector
,
576 adapter
->misc_vector_name
, netdev
);
578 dev_err(&adapter
->pdev
->dev
,
579 "request_irq for %s failed: %d\n",
580 adapter
->misc_vector_name
, err
);
581 free_irq(adapter
->msix_entries
[0].vector
, netdev
);
587 * i40evf_free_traffic_irqs - Free MSI-X interrupts
588 * @adapter: board private structure
590 * Frees all MSI-X vectors other than 0.
592 static void i40evf_free_traffic_irqs(struct i40evf_adapter
*adapter
)
597 q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
599 for (i
= 0; i
< q_vectors
; i
++) {
600 irq_set_affinity_hint(adapter
->msix_entries
[i
+1].vector
,
602 free_irq(adapter
->msix_entries
[i
+1].vector
,
603 &adapter
->q_vectors
[i
]);
608 * i40evf_free_misc_irq - Free MSI-X miscellaneous vector
609 * @adapter: board private structure
611 * Frees MSI-X vector 0.
613 static void i40evf_free_misc_irq(struct i40evf_adapter
*adapter
)
615 struct net_device
*netdev
= adapter
->netdev
;
617 free_irq(adapter
->msix_entries
[0].vector
, netdev
);
621 * i40evf_configure_tx - Configure Transmit Unit after Reset
622 * @adapter: board private structure
624 * Configure the Tx unit of the MAC after a reset.
626 static void i40evf_configure_tx(struct i40evf_adapter
*adapter
)
628 struct i40e_hw
*hw
= &adapter
->hw
;
631 for (i
= 0; i
< adapter
->num_active_queues
; i
++)
632 adapter
->tx_rings
[i
].tail
= hw
->hw_addr
+ I40E_QTX_TAIL1(i
);
636 * i40evf_configure_rx - Configure Receive Unit after Reset
637 * @adapter: board private structure
639 * Configure the Rx unit of the MAC after a reset.
641 static void i40evf_configure_rx(struct i40evf_adapter
*adapter
)
643 struct i40e_hw
*hw
= &adapter
->hw
;
646 for (i
= 0; i
< adapter
->num_active_queues
; i
++) {
647 adapter
->rx_rings
[i
].tail
= hw
->hw_addr
+ I40E_QRX_TAIL1(i
);
648 adapter
->rx_rings
[i
].rx_buf_len
= I40EVF_RXBUFFER_2048
;
653 * i40evf_find_vlan - Search filter list for specific vlan filter
654 * @adapter: board private structure
657 * Returns ptr to the filter object or NULL
660 i40evf_vlan_filter
*i40evf_find_vlan(struct i40evf_adapter
*adapter
, u16 vlan
)
662 struct i40evf_vlan_filter
*f
;
664 list_for_each_entry(f
, &adapter
->vlan_filter_list
, list
) {
672 * i40evf_add_vlan - Add a vlan filter to the list
673 * @adapter: board private structure
676 * Returns ptr to the filter object or NULL when no memory available.
679 i40evf_vlan_filter
*i40evf_add_vlan(struct i40evf_adapter
*adapter
, u16 vlan
)
681 struct i40evf_vlan_filter
*f
= NULL
;
684 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK
,
685 &adapter
->crit_section
)) {
691 f
= i40evf_find_vlan(adapter
, vlan
);
693 f
= kzalloc(sizeof(*f
), GFP_ATOMIC
);
699 INIT_LIST_HEAD(&f
->list
);
700 list_add(&f
->list
, &adapter
->vlan_filter_list
);
702 adapter
->aq_required
|= I40EVF_FLAG_AQ_ADD_VLAN_FILTER
;
706 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
712 * i40evf_del_vlan - Remove a vlan filter from the list
713 * @adapter: board private structure
716 static void i40evf_del_vlan(struct i40evf_adapter
*adapter
, u16 vlan
)
718 struct i40evf_vlan_filter
*f
;
721 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK
,
722 &adapter
->crit_section
)) {
728 f
= i40evf_find_vlan(adapter
, vlan
);
731 adapter
->aq_required
|= I40EVF_FLAG_AQ_DEL_VLAN_FILTER
;
733 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
737 * i40evf_vlan_rx_add_vid - Add a VLAN filter to a device
738 * @netdev: network device struct
741 static int i40evf_vlan_rx_add_vid(struct net_device
*netdev
,
742 __always_unused __be16 proto
, u16 vid
)
744 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
746 if (!VLAN_ALLOWED(adapter
))
748 if (i40evf_add_vlan(adapter
, vid
) == NULL
)
754 * i40evf_vlan_rx_kill_vid - Remove a VLAN filter from a device
755 * @netdev: network device struct
758 static int i40evf_vlan_rx_kill_vid(struct net_device
*netdev
,
759 __always_unused __be16 proto
, u16 vid
)
761 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
763 if (VLAN_ALLOWED(adapter
)) {
764 i40evf_del_vlan(adapter
, vid
);
771 * i40evf_find_filter - Search filter list for specific mac filter
772 * @adapter: board private structure
773 * @macaddr: the MAC address
775 * Returns ptr to the filter object or NULL
778 i40evf_mac_filter
*i40evf_find_filter(struct i40evf_adapter
*adapter
,
781 struct i40evf_mac_filter
*f
;
786 list_for_each_entry(f
, &adapter
->mac_filter_list
, list
) {
787 if (ether_addr_equal(macaddr
, f
->macaddr
))
794 * i40e_add_filter - Add a mac filter to the filter list
795 * @adapter: board private structure
796 * @macaddr: the MAC address
798 * Returns ptr to the filter object or NULL when no memory available.
801 i40evf_mac_filter
*i40evf_add_filter(struct i40evf_adapter
*adapter
,
804 struct i40evf_mac_filter
*f
;
810 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK
,
811 &adapter
->crit_section
)) {
817 f
= i40evf_find_filter(adapter
, macaddr
);
819 f
= kzalloc(sizeof(*f
), GFP_ATOMIC
);
821 clear_bit(__I40EVF_IN_CRITICAL_TASK
,
822 &adapter
->crit_section
);
826 ether_addr_copy(f
->macaddr
, macaddr
);
828 list_add(&f
->list
, &adapter
->mac_filter_list
);
830 adapter
->aq_required
|= I40EVF_FLAG_AQ_ADD_MAC_FILTER
;
833 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
838 * i40evf_set_mac - NDO callback to set port mac address
839 * @netdev: network interface device structure
840 * @p: pointer to an address structure
842 * Returns 0 on success, negative on failure
844 static int i40evf_set_mac(struct net_device
*netdev
, void *p
)
846 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
847 struct i40e_hw
*hw
= &adapter
->hw
;
848 struct i40evf_mac_filter
*f
;
849 struct sockaddr
*addr
= p
;
851 if (!is_valid_ether_addr(addr
->sa_data
))
852 return -EADDRNOTAVAIL
;
854 if (ether_addr_equal(netdev
->dev_addr
, addr
->sa_data
))
857 if (adapter
->flags
& I40EVF_FLAG_ADDR_SET_BY_PF
)
860 f
= i40evf_find_filter(adapter
, hw
->mac
.addr
);
863 adapter
->aq_required
|= I40EVF_FLAG_AQ_DEL_MAC_FILTER
;
866 f
= i40evf_add_filter(adapter
, addr
->sa_data
);
868 ether_addr_copy(hw
->mac
.addr
, addr
->sa_data
);
869 ether_addr_copy(netdev
->dev_addr
, adapter
->hw
.mac
.addr
);
872 return (f
== NULL
) ? -ENOMEM
: 0;
876 * i40evf_set_rx_mode - NDO callback to set the netdev filters
877 * @netdev: network interface device structure
879 static void i40evf_set_rx_mode(struct net_device
*netdev
)
881 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
882 struct i40evf_mac_filter
*f
, *ftmp
;
883 struct netdev_hw_addr
*uca
;
884 struct netdev_hw_addr
*mca
;
885 struct netdev_hw_addr
*ha
;
888 /* add addr if not already in the filter list */
889 netdev_for_each_uc_addr(uca
, netdev
) {
890 i40evf_add_filter(adapter
, uca
->addr
);
892 netdev_for_each_mc_addr(mca
, netdev
) {
893 i40evf_add_filter(adapter
, mca
->addr
);
896 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK
,
897 &adapter
->crit_section
)) {
900 dev_err(&adapter
->pdev
->dev
,
901 "Failed to get lock in %s\n", __func__
);
905 /* remove filter if not in netdev list */
906 list_for_each_entry_safe(f
, ftmp
, &adapter
->mac_filter_list
, list
) {
907 netdev_for_each_mc_addr(mca
, netdev
)
908 if (ether_addr_equal(mca
->addr
, f
->macaddr
))
909 goto bottom_of_search_loop
;
911 netdev_for_each_uc_addr(uca
, netdev
)
912 if (ether_addr_equal(uca
->addr
, f
->macaddr
))
913 goto bottom_of_search_loop
;
915 for_each_dev_addr(netdev
, ha
)
916 if (ether_addr_equal(ha
->addr
, f
->macaddr
))
917 goto bottom_of_search_loop
;
919 if (ether_addr_equal(f
->macaddr
, adapter
->hw
.mac
.addr
))
920 goto bottom_of_search_loop
;
922 /* f->macaddr wasn't found in uc, mc, or ha list so delete it */
924 adapter
->aq_required
|= I40EVF_FLAG_AQ_DEL_MAC_FILTER
;
926 bottom_of_search_loop
:
930 if (netdev
->flags
& IFF_PROMISC
&&
931 !(adapter
->flags
& I40EVF_FLAG_PROMISC_ON
))
932 adapter
->aq_required
|= I40EVF_FLAG_AQ_REQUEST_PROMISC
;
933 else if (!(netdev
->flags
& IFF_PROMISC
) &&
934 adapter
->flags
& I40EVF_FLAG_PROMISC_ON
)
935 adapter
->aq_required
|= I40EVF_FLAG_AQ_RELEASE_PROMISC
;
937 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
941 * i40evf_napi_enable_all - enable NAPI on all queue vectors
942 * @adapter: board private structure
944 static void i40evf_napi_enable_all(struct i40evf_adapter
*adapter
)
947 struct i40e_q_vector
*q_vector
;
948 int q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
950 for (q_idx
= 0; q_idx
< q_vectors
; q_idx
++) {
951 struct napi_struct
*napi
;
953 q_vector
= &adapter
->q_vectors
[q_idx
];
954 napi
= &q_vector
->napi
;
960 * i40evf_napi_disable_all - disable NAPI on all queue vectors
961 * @adapter: board private structure
963 static void i40evf_napi_disable_all(struct i40evf_adapter
*adapter
)
966 struct i40e_q_vector
*q_vector
;
967 int q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
969 for (q_idx
= 0; q_idx
< q_vectors
; q_idx
++) {
970 q_vector
= &adapter
->q_vectors
[q_idx
];
971 napi_disable(&q_vector
->napi
);
976 * i40evf_configure - set up transmit and receive data structures
977 * @adapter: board private structure
979 static void i40evf_configure(struct i40evf_adapter
*adapter
)
981 struct net_device
*netdev
= adapter
->netdev
;
984 i40evf_set_rx_mode(netdev
);
986 i40evf_configure_tx(adapter
);
987 i40evf_configure_rx(adapter
);
988 adapter
->aq_required
|= I40EVF_FLAG_AQ_CONFIGURE_QUEUES
;
990 for (i
= 0; i
< adapter
->num_active_queues
; i
++) {
991 struct i40e_ring
*ring
= &adapter
->rx_rings
[i
];
993 i40evf_alloc_rx_buffers(ring
, ring
->count
);
994 ring
->next_to_use
= ring
->count
- 1;
995 writel(ring
->next_to_use
, ring
->tail
);
1000 * i40evf_up_complete - Finish the last steps of bringing up a connection
1001 * @adapter: board private structure
1003 static int i40evf_up_complete(struct i40evf_adapter
*adapter
)
1005 adapter
->state
= __I40EVF_RUNNING
;
1006 clear_bit(__I40E_DOWN
, &adapter
->vsi
.state
);
1008 i40evf_napi_enable_all(adapter
);
1010 adapter
->aq_required
|= I40EVF_FLAG_AQ_ENABLE_QUEUES
;
1011 mod_timer_pending(&adapter
->watchdog_timer
, jiffies
+ 1);
1016 * i40e_down - Shutdown the connection processing
1017 * @adapter: board private structure
1019 void i40evf_down(struct i40evf_adapter
*adapter
)
1021 struct net_device
*netdev
= adapter
->netdev
;
1022 struct i40evf_mac_filter
*f
;
1024 if (adapter
->state
<= __I40EVF_DOWN_PENDING
)
1027 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK
,
1028 &adapter
->crit_section
))
1029 usleep_range(500, 1000);
1031 netif_carrier_off(netdev
);
1032 netif_tx_disable(netdev
);
1033 i40evf_napi_disable_all(adapter
);
1034 i40evf_irq_disable(adapter
);
1036 /* remove all MAC filters */
1037 list_for_each_entry(f
, &adapter
->mac_filter_list
, list
) {
1040 /* remove all VLAN filters */
1041 list_for_each_entry(f
, &adapter
->vlan_filter_list
, list
) {
1044 if (!(adapter
->flags
& I40EVF_FLAG_PF_COMMS_FAILED
) &&
1045 adapter
->state
!= __I40EVF_RESETTING
) {
1046 /* cancel any current operation */
1047 adapter
->current_op
= I40E_VIRTCHNL_OP_UNKNOWN
;
1048 /* Schedule operations to close down the HW. Don't wait
1049 * here for this to complete. The watchdog is still running
1050 * and it will take care of this.
1052 adapter
->aq_required
= I40EVF_FLAG_AQ_DEL_MAC_FILTER
;
1053 adapter
->aq_required
|= I40EVF_FLAG_AQ_DEL_VLAN_FILTER
;
1054 adapter
->aq_required
|= I40EVF_FLAG_AQ_DISABLE_QUEUES
;
1057 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
1061 * i40evf_acquire_msix_vectors - Setup the MSIX capability
1062 * @adapter: board private structure
1063 * @vectors: number of vectors to request
1065 * Work with the OS to set up the MSIX vectors needed.
1067 * Returns 0 on success, negative on failure
1070 i40evf_acquire_msix_vectors(struct i40evf_adapter
*adapter
, int vectors
)
1072 int err
, vector_threshold
;
1074 /* We'll want at least 3 (vector_threshold):
1075 * 0) Other (Admin Queue and link, mostly)
1079 vector_threshold
= MIN_MSIX_COUNT
;
1081 /* The more we get, the more we will assign to Tx/Rx Cleanup
1082 * for the separate queues...where Rx Cleanup >= Tx Cleanup.
1083 * Right now, we simply care about how many we'll get; we'll
1084 * set them up later while requesting irq's.
1086 err
= pci_enable_msix_range(adapter
->pdev
, adapter
->msix_entries
,
1087 vector_threshold
, vectors
);
1089 dev_err(&adapter
->pdev
->dev
, "Unable to allocate MSI-X interrupts\n");
1090 kfree(adapter
->msix_entries
);
1091 adapter
->msix_entries
= NULL
;
1095 /* Adjust for only the vectors we'll use, which is minimum
1096 * of max_msix_q_vectors + NONQ_VECS, or the number of
1097 * vectors we were allocated.
1099 adapter
->num_msix_vectors
= err
;
1104 * i40evf_free_queues - Free memory for all rings
1105 * @adapter: board private structure to initialize
1107 * Free all of the memory associated with queue pairs.
1109 static void i40evf_free_queues(struct i40evf_adapter
*adapter
)
1111 if (!adapter
->vsi_res
)
1113 kfree(adapter
->tx_rings
);
1114 adapter
->tx_rings
= NULL
;
1115 kfree(adapter
->rx_rings
);
1116 adapter
->rx_rings
= NULL
;
1120 * i40evf_alloc_queues - Allocate memory for all rings
1121 * @adapter: board private structure to initialize
1123 * We allocate one ring per queue at run-time since we don't know the
1124 * number of queues at compile-time. The polling_netdev array is
1125 * intended for Multiqueue, but should work fine with a single queue.
1127 static int i40evf_alloc_queues(struct i40evf_adapter
*adapter
)
1131 adapter
->tx_rings
= kcalloc(adapter
->num_active_queues
,
1132 sizeof(struct i40e_ring
), GFP_KERNEL
);
1133 if (!adapter
->tx_rings
)
1135 adapter
->rx_rings
= kcalloc(adapter
->num_active_queues
,
1136 sizeof(struct i40e_ring
), GFP_KERNEL
);
1137 if (!adapter
->rx_rings
)
1140 for (i
= 0; i
< adapter
->num_active_queues
; i
++) {
1141 struct i40e_ring
*tx_ring
;
1142 struct i40e_ring
*rx_ring
;
1144 tx_ring
= &adapter
->tx_rings
[i
];
1146 tx_ring
->queue_index
= i
;
1147 tx_ring
->netdev
= adapter
->netdev
;
1148 tx_ring
->dev
= &adapter
->pdev
->dev
;
1149 tx_ring
->count
= adapter
->tx_desc_count
;
1150 if (adapter
->flags
& I40E_FLAG_WB_ON_ITR_CAPABLE
)
1151 tx_ring
->flags
|= I40E_TXR_FLAGS_WB_ON_ITR
;
1153 rx_ring
= &adapter
->rx_rings
[i
];
1154 rx_ring
->queue_index
= i
;
1155 rx_ring
->netdev
= adapter
->netdev
;
1156 rx_ring
->dev
= &adapter
->pdev
->dev
;
1157 rx_ring
->count
= adapter
->rx_desc_count
;
1163 i40evf_free_queues(adapter
);
1168 * i40evf_set_interrupt_capability - set MSI-X or FAIL if not supported
1169 * @adapter: board private structure to initialize
1171 * Attempt to configure the interrupts using the best available
1172 * capabilities of the hardware and the kernel.
1174 static int i40evf_set_interrupt_capability(struct i40evf_adapter
*adapter
)
1176 int vector
, v_budget
;
1180 if (!adapter
->vsi_res
) {
1184 pairs
= adapter
->num_active_queues
;
1186 /* It's easy to be greedy for MSI-X vectors, but it really
1187 * doesn't do us much good if we have a lot more vectors
1188 * than CPU's. So let's be conservative and only ask for
1189 * (roughly) twice the number of vectors as there are CPU's.
1191 v_budget
= min_t(int, pairs
, (int)(num_online_cpus() * 2)) + NONQ_VECS
;
1192 v_budget
= min_t(int, v_budget
, (int)adapter
->vf_res
->max_vectors
);
1194 adapter
->msix_entries
= kcalloc(v_budget
,
1195 sizeof(struct msix_entry
), GFP_KERNEL
);
1196 if (!adapter
->msix_entries
) {
1201 for (vector
= 0; vector
< v_budget
; vector
++)
1202 adapter
->msix_entries
[vector
].entry
= vector
;
1204 err
= i40evf_acquire_msix_vectors(adapter
, v_budget
);
1207 netif_set_real_num_rx_queues(adapter
->netdev
, pairs
);
1208 netif_set_real_num_tx_queues(adapter
->netdev
, pairs
);
1213 * i40e_config_rss_aq - Configure RSS keys and lut by using AQ commands
1214 * @adapter: board private structure
1216 * Return 0 on success, negative on failure
1218 static int i40evf_config_rss_aq(struct i40evf_adapter
*adapter
)
1220 struct i40e_aqc_get_set_rss_key_data
*rss_key
=
1221 (struct i40e_aqc_get_set_rss_key_data
*)adapter
->rss_key
;
1222 struct i40e_hw
*hw
= &adapter
->hw
;
1225 if (adapter
->current_op
!= I40E_VIRTCHNL_OP_UNKNOWN
) {
1226 /* bail because we already have a command pending */
1227 dev_err(&adapter
->pdev
->dev
, "Cannot configure RSS, command %d pending\n",
1228 adapter
->current_op
);
1232 ret
= i40evf_aq_set_rss_key(hw
, adapter
->vsi
.id
, rss_key
);
1234 dev_err(&adapter
->pdev
->dev
, "Cannot set RSS key, err %s aq_err %s\n",
1235 i40evf_stat_str(hw
, ret
),
1236 i40evf_aq_str(hw
, hw
->aq
.asq_last_status
));
1241 ret
= i40evf_aq_set_rss_lut(hw
, adapter
->vsi
.id
, false,
1242 adapter
->rss_lut
, adapter
->rss_lut_size
);
1244 dev_err(&adapter
->pdev
->dev
, "Cannot set RSS lut, err %s aq_err %s\n",
1245 i40evf_stat_str(hw
, ret
),
1246 i40evf_aq_str(hw
, hw
->aq
.asq_last_status
));
1254 * i40evf_config_rss_reg - Configure RSS keys and lut by writing registers
1255 * @adapter: board private structure
1257 * Returns 0 on success, negative on failure
1259 static int i40evf_config_rss_reg(struct i40evf_adapter
*adapter
)
1261 struct i40e_hw
*hw
= &adapter
->hw
;
1265 dw
= (u32
*)adapter
->rss_key
;
1266 for (i
= 0; i
<= adapter
->rss_key_size
/ 4; i
++)
1267 wr32(hw
, I40E_VFQF_HKEY(i
), dw
[i
]);
1269 dw
= (u32
*)adapter
->rss_lut
;
1270 for (i
= 0; i
<= adapter
->rss_lut_size
/ 4; i
++)
1271 wr32(hw
, I40E_VFQF_HLUT(i
), dw
[i
]);
1279 * i40evf_config_rss - Configure RSS keys and lut
1280 * @adapter: board private structure
1282 * Returns 0 on success, negative on failure
1284 int i40evf_config_rss(struct i40evf_adapter
*adapter
)
1287 if (RSS_PF(adapter
)) {
1288 adapter
->aq_required
|= I40EVF_FLAG_AQ_SET_RSS_LUT
|
1289 I40EVF_FLAG_AQ_SET_RSS_KEY
;
1291 } else if (RSS_AQ(adapter
)) {
1292 return i40evf_config_rss_aq(adapter
);
1294 return i40evf_config_rss_reg(adapter
);
1299 * i40evf_fill_rss_lut - Fill the lut with default values
1300 * @adapter: board private structure
1302 static void i40evf_fill_rss_lut(struct i40evf_adapter
*adapter
)
1306 for (i
= 0; i
< adapter
->rss_lut_size
; i
++)
1307 adapter
->rss_lut
[i
] = i
% adapter
->num_active_queues
;
1311 * i40evf_init_rss - Prepare for RSS
1312 * @adapter: board private structure
1314 * Return 0 on success, negative on failure
1316 static int i40evf_init_rss(struct i40evf_adapter
*adapter
)
1318 struct i40e_hw
*hw
= &adapter
->hw
;
1321 if (!RSS_PF(adapter
)) {
1322 /* Enable PCTYPES for RSS, TCP/UDP with IPv4/IPv6 */
1323 if (adapter
->vf_res
->vf_offload_flags
&
1324 I40E_VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2
)
1325 adapter
->hena
= I40E_DEFAULT_RSS_HENA_EXPANDED
;
1327 adapter
->hena
= I40E_DEFAULT_RSS_HENA
;
1329 wr32(hw
, I40E_VFQF_HENA(0), (u32
)adapter
->hena
);
1330 wr32(hw
, I40E_VFQF_HENA(1), (u32
)(adapter
->hena
>> 32));
1333 i40evf_fill_rss_lut(adapter
);
1335 netdev_rss_key_fill((void *)adapter
->rss_key
, adapter
->rss_key_size
);
1336 ret
= i40evf_config_rss(adapter
);
1342 * i40evf_alloc_q_vectors - Allocate memory for interrupt vectors
1343 * @adapter: board private structure to initialize
1345 * We allocate one q_vector per queue interrupt. If allocation fails we
1348 static int i40evf_alloc_q_vectors(struct i40evf_adapter
*adapter
)
1350 int q_idx
= 0, num_q_vectors
;
1351 struct i40e_q_vector
*q_vector
;
1353 num_q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
1354 adapter
->q_vectors
= kcalloc(num_q_vectors
, sizeof(*q_vector
),
1356 if (!adapter
->q_vectors
)
1359 for (q_idx
= 0; q_idx
< num_q_vectors
; q_idx
++) {
1360 q_vector
= &adapter
->q_vectors
[q_idx
];
1361 q_vector
->adapter
= adapter
;
1362 q_vector
->vsi
= &adapter
->vsi
;
1363 q_vector
->v_idx
= q_idx
;
1364 netif_napi_add(adapter
->netdev
, &q_vector
->napi
,
1365 i40evf_napi_poll
, NAPI_POLL_WEIGHT
);
1372 * i40evf_free_q_vectors - Free memory allocated for interrupt vectors
1373 * @adapter: board private structure to initialize
1375 * This function frees the memory allocated to the q_vectors. In addition if
1376 * NAPI is enabled it will delete any references to the NAPI struct prior
1377 * to freeing the q_vector.
1379 static void i40evf_free_q_vectors(struct i40evf_adapter
*adapter
)
1381 int q_idx
, num_q_vectors
;
1384 num_q_vectors
= adapter
->num_msix_vectors
- NONQ_VECS
;
1385 napi_vectors
= adapter
->num_active_queues
;
1387 for (q_idx
= 0; q_idx
< num_q_vectors
; q_idx
++) {
1388 struct i40e_q_vector
*q_vector
= &adapter
->q_vectors
[q_idx
];
1389 if (q_idx
< napi_vectors
)
1390 netif_napi_del(&q_vector
->napi
);
1392 kfree(adapter
->q_vectors
);
1396 * i40evf_reset_interrupt_capability - Reset MSIX setup
1397 * @adapter: board private structure
1400 void i40evf_reset_interrupt_capability(struct i40evf_adapter
*adapter
)
1402 pci_disable_msix(adapter
->pdev
);
1403 kfree(adapter
->msix_entries
);
1404 adapter
->msix_entries
= NULL
;
1408 * i40evf_init_interrupt_scheme - Determine if MSIX is supported and init
1409 * @adapter: board private structure to initialize
1412 int i40evf_init_interrupt_scheme(struct i40evf_adapter
*adapter
)
1416 err
= i40evf_set_interrupt_capability(adapter
);
1418 dev_err(&adapter
->pdev
->dev
,
1419 "Unable to setup interrupt capabilities\n");
1420 goto err_set_interrupt
;
1423 err
= i40evf_alloc_q_vectors(adapter
);
1425 dev_err(&adapter
->pdev
->dev
,
1426 "Unable to allocate memory for queue vectors\n");
1427 goto err_alloc_q_vectors
;
1430 err
= i40evf_alloc_queues(adapter
);
1432 dev_err(&adapter
->pdev
->dev
,
1433 "Unable to allocate memory for queues\n");
1434 goto err_alloc_queues
;
1437 dev_info(&adapter
->pdev
->dev
, "Multiqueue %s: Queue pair count = %u",
1438 (adapter
->num_active_queues
> 1) ? "Enabled" : "Disabled",
1439 adapter
->num_active_queues
);
1443 i40evf_free_q_vectors(adapter
);
1444 err_alloc_q_vectors
:
1445 i40evf_reset_interrupt_capability(adapter
);
1451 * i40evf_free_rss - Free memory used by RSS structs
1452 * @adapter: board private structure
1454 static void i40evf_free_rss(struct i40evf_adapter
*adapter
)
1456 kfree(adapter
->rss_key
);
1457 adapter
->rss_key
= NULL
;
1459 kfree(adapter
->rss_lut
);
1460 adapter
->rss_lut
= NULL
;
1464 * i40evf_watchdog_timer - Periodic call-back timer
1465 * @data: pointer to adapter disguised as unsigned long
1467 static void i40evf_watchdog_timer(unsigned long data
)
1469 struct i40evf_adapter
*adapter
= (struct i40evf_adapter
*)data
;
1471 schedule_work(&adapter
->watchdog_task
);
1472 /* timer will be rescheduled in watchdog task */
1476 * i40evf_watchdog_task - Periodic call-back task
1477 * @work: pointer to work_struct
1479 static void i40evf_watchdog_task(struct work_struct
*work
)
1481 struct i40evf_adapter
*adapter
= container_of(work
,
1482 struct i40evf_adapter
,
1484 struct i40e_hw
*hw
= &adapter
->hw
;
1487 if (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
))
1488 goto restart_watchdog
;
1490 if (adapter
->flags
& I40EVF_FLAG_PF_COMMS_FAILED
) {
1491 reg_val
= rd32(hw
, I40E_VFGEN_RSTAT
) &
1492 I40E_VFGEN_RSTAT_VFR_STATE_MASK
;
1493 if ((reg_val
== I40E_VFR_VFACTIVE
) ||
1494 (reg_val
== I40E_VFR_COMPLETED
)) {
1495 /* A chance for redemption! */
1496 dev_err(&adapter
->pdev
->dev
, "Hardware came out of reset. Attempting reinit.\n");
1497 adapter
->state
= __I40EVF_STARTUP
;
1498 adapter
->flags
&= ~I40EVF_FLAG_PF_COMMS_FAILED
;
1499 schedule_delayed_work(&adapter
->init_task
, 10);
1500 clear_bit(__I40EVF_IN_CRITICAL_TASK
,
1501 &adapter
->crit_section
);
1502 /* Don't reschedule the watchdog, since we've restarted
1503 * the init task. When init_task contacts the PF and
1504 * gets everything set up again, it'll restart the
1505 * watchdog for us. Down, boy. Sit. Stay. Woof.
1509 adapter
->aq_required
= 0;
1510 adapter
->current_op
= I40E_VIRTCHNL_OP_UNKNOWN
;
1514 if ((adapter
->state
< __I40EVF_DOWN
) ||
1515 (adapter
->flags
& I40EVF_FLAG_RESET_PENDING
))
1518 /* check for reset */
1519 reg_val
= rd32(hw
, I40E_VF_ARQLEN1
) & I40E_VF_ARQLEN1_ARQENABLE_MASK
;
1520 if (!(adapter
->flags
& I40EVF_FLAG_RESET_PENDING
) && !reg_val
) {
1521 adapter
->state
= __I40EVF_RESETTING
;
1522 adapter
->flags
|= I40EVF_FLAG_RESET_PENDING
;
1523 dev_err(&adapter
->pdev
->dev
, "Hardware reset detected\n");
1524 schedule_work(&adapter
->reset_task
);
1525 adapter
->aq_required
= 0;
1526 adapter
->current_op
= I40E_VIRTCHNL_OP_UNKNOWN
;
1530 /* Process admin queue tasks. After init, everything gets done
1531 * here so we don't race on the admin queue.
1533 if (adapter
->current_op
) {
1534 if (!i40evf_asq_done(hw
)) {
1535 dev_dbg(&adapter
->pdev
->dev
, "Admin queue timeout\n");
1536 i40evf_send_api_ver(adapter
);
1540 if (adapter
->aq_required
& I40EVF_FLAG_AQ_GET_CONFIG
) {
1541 i40evf_send_vf_config_msg(adapter
);
1545 if (adapter
->aq_required
& I40EVF_FLAG_AQ_DISABLE_QUEUES
) {
1546 i40evf_disable_queues(adapter
);
1550 if (adapter
->aq_required
& I40EVF_FLAG_AQ_MAP_VECTORS
) {
1551 i40evf_map_queues(adapter
);
1555 if (adapter
->aq_required
& I40EVF_FLAG_AQ_ADD_MAC_FILTER
) {
1556 i40evf_add_ether_addrs(adapter
);
1560 if (adapter
->aq_required
& I40EVF_FLAG_AQ_ADD_VLAN_FILTER
) {
1561 i40evf_add_vlans(adapter
);
1565 if (adapter
->aq_required
& I40EVF_FLAG_AQ_DEL_MAC_FILTER
) {
1566 i40evf_del_ether_addrs(adapter
);
1570 if (adapter
->aq_required
& I40EVF_FLAG_AQ_DEL_VLAN_FILTER
) {
1571 i40evf_del_vlans(adapter
);
1575 if (adapter
->aq_required
& I40EVF_FLAG_AQ_CONFIGURE_QUEUES
) {
1576 i40evf_configure_queues(adapter
);
1580 if (adapter
->aq_required
& I40EVF_FLAG_AQ_ENABLE_QUEUES
) {
1581 i40evf_enable_queues(adapter
);
1585 if (adapter
->aq_required
& I40EVF_FLAG_AQ_CONFIGURE_RSS
) {
1586 /* This message goes straight to the firmware, not the
1587 * PF, so we don't have to set current_op as we will
1588 * not get a response through the ARQ.
1590 i40evf_init_rss(adapter
);
1591 adapter
->aq_required
&= ~I40EVF_FLAG_AQ_CONFIGURE_RSS
;
1594 if (adapter
->aq_required
& I40EVF_FLAG_AQ_GET_HENA
) {
1595 i40evf_get_hena(adapter
);
1598 if (adapter
->aq_required
& I40EVF_FLAG_AQ_SET_HENA
) {
1599 i40evf_set_hena(adapter
);
1602 if (adapter
->aq_required
& I40EVF_FLAG_AQ_SET_RSS_KEY
) {
1603 i40evf_set_rss_key(adapter
);
1606 if (adapter
->aq_required
& I40EVF_FLAG_AQ_SET_RSS_LUT
) {
1607 i40evf_set_rss_lut(adapter
);
1611 if (adapter
->aq_required
& I40EVF_FLAG_AQ_REQUEST_PROMISC
) {
1612 i40evf_set_promiscuous(adapter
, I40E_FLAG_VF_UNICAST_PROMISC
|
1613 I40E_FLAG_VF_MULTICAST_PROMISC
);
1617 if (adapter
->aq_required
& I40EVF_FLAG_AQ_RELEASE_PROMISC
) {
1618 i40evf_set_promiscuous(adapter
, 0);
1622 if (adapter
->state
== __I40EVF_RUNNING
)
1623 i40evf_request_stats(adapter
);
1625 if (adapter
->state
== __I40EVF_RUNNING
) {
1626 i40evf_irq_enable_queues(adapter
, ~0);
1627 i40evf_fire_sw_int(adapter
, 0xFF);
1629 i40evf_fire_sw_int(adapter
, 0x1);
1632 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
1634 if (adapter
->state
== __I40EVF_REMOVE
)
1636 if (adapter
->aq_required
)
1637 mod_timer(&adapter
->watchdog_timer
,
1638 jiffies
+ msecs_to_jiffies(20));
1640 mod_timer(&adapter
->watchdog_timer
, jiffies
+ (HZ
* 2));
1641 schedule_work(&adapter
->adminq_task
);
1644 #define I40EVF_RESET_WAIT_MS 10
1645 #define I40EVF_RESET_WAIT_COUNT 500
1647 * i40evf_reset_task - Call-back task to handle hardware reset
1648 * @work: pointer to work_struct
1650 * During reset we need to shut down and reinitialize the admin queue
1651 * before we can use it to communicate with the PF again. We also clear
1652 * and reinit the rings because that context is lost as well.
1654 static void i40evf_reset_task(struct work_struct
*work
)
1656 struct i40evf_adapter
*adapter
= container_of(work
,
1657 struct i40evf_adapter
,
1659 struct net_device
*netdev
= adapter
->netdev
;
1660 struct i40e_hw
*hw
= &adapter
->hw
;
1661 struct i40evf_vlan_filter
*vlf
;
1662 struct i40evf_mac_filter
*f
;
1666 while (test_and_set_bit(__I40EVF_IN_CRITICAL_TASK
,
1667 &adapter
->crit_section
))
1668 usleep_range(500, 1000);
1670 i40evf_misc_irq_disable(adapter
);
1671 if (adapter
->flags
& I40EVF_FLAG_RESET_NEEDED
) {
1672 adapter
->flags
&= ~I40EVF_FLAG_RESET_NEEDED
;
1673 /* Restart the AQ here. If we have been reset but didn't
1674 * detect it, or if the PF had to reinit, our AQ will be hosed.
1676 i40evf_shutdown_adminq(hw
);
1677 i40evf_init_adminq(hw
);
1678 i40evf_request_reset(adapter
);
1680 adapter
->flags
|= I40EVF_FLAG_RESET_PENDING
;
1682 /* poll until we see the reset actually happen */
1683 for (i
= 0; i
< I40EVF_RESET_WAIT_COUNT
; i
++) {
1684 reg_val
= rd32(hw
, I40E_VF_ARQLEN1
) &
1685 I40E_VF_ARQLEN1_ARQENABLE_MASK
;
1688 usleep_range(5000, 10000);
1690 if (i
== I40EVF_RESET_WAIT_COUNT
) {
1691 dev_info(&adapter
->pdev
->dev
, "Never saw reset\n");
1692 goto continue_reset
; /* act like the reset happened */
1695 /* wait until the reset is complete and the PF is responding to us */
1696 for (i
= 0; i
< I40EVF_RESET_WAIT_COUNT
; i
++) {
1697 reg_val
= rd32(hw
, I40E_VFGEN_RSTAT
) &
1698 I40E_VFGEN_RSTAT_VFR_STATE_MASK
;
1699 if (reg_val
== I40E_VFR_VFACTIVE
)
1701 msleep(I40EVF_RESET_WAIT_MS
);
1703 pci_set_master(adapter
->pdev
);
1704 /* extra wait to make sure minimum wait is met */
1705 msleep(I40EVF_RESET_WAIT_MS
);
1706 if (i
== I40EVF_RESET_WAIT_COUNT
) {
1707 struct i40evf_mac_filter
*ftmp
;
1708 struct i40evf_vlan_filter
*fv
, *fvtmp
;
1710 /* reset never finished */
1711 dev_err(&adapter
->pdev
->dev
, "Reset never finished (%x)\n",
1713 adapter
->flags
|= I40EVF_FLAG_PF_COMMS_FAILED
;
1715 if (netif_running(adapter
->netdev
)) {
1716 set_bit(__I40E_DOWN
, &adapter
->vsi
.state
);
1717 netif_carrier_off(netdev
);
1718 netif_tx_disable(netdev
);
1719 i40evf_napi_disable_all(adapter
);
1720 i40evf_irq_disable(adapter
);
1721 i40evf_free_traffic_irqs(adapter
);
1722 i40evf_free_all_tx_resources(adapter
);
1723 i40evf_free_all_rx_resources(adapter
);
1726 /* Delete all of the filters, both MAC and VLAN. */
1727 list_for_each_entry_safe(f
, ftmp
, &adapter
->mac_filter_list
,
1733 list_for_each_entry_safe(fv
, fvtmp
, &adapter
->vlan_filter_list
,
1735 list_del(&fv
->list
);
1739 i40evf_free_misc_irq(adapter
);
1740 i40evf_reset_interrupt_capability(adapter
);
1741 i40evf_free_queues(adapter
);
1742 i40evf_free_q_vectors(adapter
);
1743 kfree(adapter
->vf_res
);
1744 i40evf_shutdown_adminq(hw
);
1745 adapter
->netdev
->flags
&= ~IFF_UP
;
1746 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
1747 adapter
->flags
&= ~I40EVF_FLAG_RESET_PENDING
;
1748 adapter
->state
= __I40EVF_DOWN
;
1749 dev_info(&adapter
->pdev
->dev
, "Reset task did not complete, VF disabled\n");
1750 return; /* Do not attempt to reinit. It's dead, Jim. */
1754 if (netif_running(adapter
->netdev
)) {
1755 netif_carrier_off(netdev
);
1756 netif_tx_stop_all_queues(netdev
);
1757 i40evf_napi_disable_all(adapter
);
1759 i40evf_irq_disable(adapter
);
1761 adapter
->state
= __I40EVF_RESETTING
;
1762 adapter
->flags
&= ~I40EVF_FLAG_RESET_PENDING
;
1764 /* free the Tx/Rx rings and descriptors, might be better to just
1765 * re-use them sometime in the future
1767 i40evf_free_all_rx_resources(adapter
);
1768 i40evf_free_all_tx_resources(adapter
);
1770 /* kill and reinit the admin queue */
1771 if (i40evf_shutdown_adminq(hw
))
1772 dev_warn(&adapter
->pdev
->dev
, "Failed to shut down adminq\n");
1773 adapter
->current_op
= I40E_VIRTCHNL_OP_UNKNOWN
;
1774 err
= i40evf_init_adminq(hw
);
1776 dev_info(&adapter
->pdev
->dev
, "Failed to init adminq: %d\n",
1779 adapter
->aq_required
= I40EVF_FLAG_AQ_GET_CONFIG
;
1780 adapter
->aq_required
|= I40EVF_FLAG_AQ_MAP_VECTORS
;
1782 /* re-add all MAC filters */
1783 list_for_each_entry(f
, &adapter
->mac_filter_list
, list
) {
1786 /* re-add all VLAN filters */
1787 list_for_each_entry(vlf
, &adapter
->vlan_filter_list
, list
) {
1790 adapter
->aq_required
|= I40EVF_FLAG_AQ_ADD_MAC_FILTER
;
1791 adapter
->aq_required
|= I40EVF_FLAG_AQ_ADD_VLAN_FILTER
;
1792 clear_bit(__I40EVF_IN_CRITICAL_TASK
, &adapter
->crit_section
);
1793 i40evf_misc_irq_enable(adapter
);
1795 mod_timer(&adapter
->watchdog_timer
, jiffies
+ 2);
1797 if (netif_running(adapter
->netdev
)) {
1798 /* allocate transmit descriptors */
1799 err
= i40evf_setup_all_tx_resources(adapter
);
1803 /* allocate receive descriptors */
1804 err
= i40evf_setup_all_rx_resources(adapter
);
1808 i40evf_configure(adapter
);
1810 err
= i40evf_up_complete(adapter
);
1814 i40evf_irq_enable(adapter
, true);
1816 adapter
->state
= __I40EVF_DOWN
;
1821 dev_err(&adapter
->pdev
->dev
, "failed to allocate resources during reinit\n");
1822 i40evf_close(adapter
->netdev
);
1826 * i40evf_adminq_task - worker thread to clean the admin queue
1827 * @work: pointer to work_struct containing our data
1829 static void i40evf_adminq_task(struct work_struct
*work
)
1831 struct i40evf_adapter
*adapter
=
1832 container_of(work
, struct i40evf_adapter
, adminq_task
);
1833 struct i40e_hw
*hw
= &adapter
->hw
;
1834 struct i40e_arq_event_info event
;
1835 struct i40e_virtchnl_msg
*v_msg
;
1840 if (adapter
->flags
& I40EVF_FLAG_PF_COMMS_FAILED
)
1843 event
.buf_len
= I40EVF_MAX_AQ_BUF_SIZE
;
1844 event
.msg_buf
= kzalloc(event
.buf_len
, GFP_KERNEL
);
1848 v_msg
= (struct i40e_virtchnl_msg
*)&event
.desc
;
1850 ret
= i40evf_clean_arq_element(hw
, &event
, &pending
);
1851 if (ret
|| !v_msg
->v_opcode
)
1852 break; /* No event to process or error cleaning ARQ */
1854 i40evf_virtchnl_completion(adapter
, v_msg
->v_opcode
,
1855 v_msg
->v_retval
, event
.msg_buf
,
1858 memset(event
.msg_buf
, 0, I40EVF_MAX_AQ_BUF_SIZE
);
1861 if ((adapter
->flags
&
1862 (I40EVF_FLAG_RESET_PENDING
| I40EVF_FLAG_RESET_NEEDED
)) ||
1863 adapter
->state
== __I40EVF_RESETTING
)
1866 /* check for error indications */
1867 val
= rd32(hw
, hw
->aq
.arq
.len
);
1868 if (val
== 0xdeadbeef) /* indicates device in reset */
1871 if (val
& I40E_VF_ARQLEN1_ARQVFE_MASK
) {
1872 dev_info(&adapter
->pdev
->dev
, "ARQ VF Error detected\n");
1873 val
&= ~I40E_VF_ARQLEN1_ARQVFE_MASK
;
1875 if (val
& I40E_VF_ARQLEN1_ARQOVFL_MASK
) {
1876 dev_info(&adapter
->pdev
->dev
, "ARQ Overflow Error detected\n");
1877 val
&= ~I40E_VF_ARQLEN1_ARQOVFL_MASK
;
1879 if (val
& I40E_VF_ARQLEN1_ARQCRIT_MASK
) {
1880 dev_info(&adapter
->pdev
->dev
, "ARQ Critical Error detected\n");
1881 val
&= ~I40E_VF_ARQLEN1_ARQCRIT_MASK
;
1884 wr32(hw
, hw
->aq
.arq
.len
, val
);
1886 val
= rd32(hw
, hw
->aq
.asq
.len
);
1888 if (val
& I40E_VF_ATQLEN1_ATQVFE_MASK
) {
1889 dev_info(&adapter
->pdev
->dev
, "ASQ VF Error detected\n");
1890 val
&= ~I40E_VF_ATQLEN1_ATQVFE_MASK
;
1892 if (val
& I40E_VF_ATQLEN1_ATQOVFL_MASK
) {
1893 dev_info(&adapter
->pdev
->dev
, "ASQ Overflow Error detected\n");
1894 val
&= ~I40E_VF_ATQLEN1_ATQOVFL_MASK
;
1896 if (val
& I40E_VF_ATQLEN1_ATQCRIT_MASK
) {
1897 dev_info(&adapter
->pdev
->dev
, "ASQ Critical Error detected\n");
1898 val
&= ~I40E_VF_ATQLEN1_ATQCRIT_MASK
;
1901 wr32(hw
, hw
->aq
.asq
.len
, val
);
1904 kfree(event
.msg_buf
);
1906 /* re-enable Admin queue interrupt cause */
1907 i40evf_misc_irq_enable(adapter
);
1911 * i40evf_free_all_tx_resources - Free Tx Resources for All Queues
1912 * @adapter: board private structure
1914 * Free all transmit software resources
1916 void i40evf_free_all_tx_resources(struct i40evf_adapter
*adapter
)
1920 if (!adapter
->tx_rings
)
1923 for (i
= 0; i
< adapter
->num_active_queues
; i
++)
1924 if (adapter
->tx_rings
[i
].desc
)
1925 i40evf_free_tx_resources(&adapter
->tx_rings
[i
]);
1929 * i40evf_setup_all_tx_resources - allocate all queues Tx resources
1930 * @adapter: board private structure
1932 * If this function returns with an error, then it's possible one or
1933 * more of the rings is populated (while the rest are not). It is the
1934 * callers duty to clean those orphaned rings.
1936 * Return 0 on success, negative on failure
1938 static int i40evf_setup_all_tx_resources(struct i40evf_adapter
*adapter
)
1942 for (i
= 0; i
< adapter
->num_active_queues
; i
++) {
1943 adapter
->tx_rings
[i
].count
= adapter
->tx_desc_count
;
1944 err
= i40evf_setup_tx_descriptors(&adapter
->tx_rings
[i
]);
1947 dev_err(&adapter
->pdev
->dev
,
1948 "Allocation for Tx Queue %u failed\n", i
);
1956 * i40evf_setup_all_rx_resources - allocate all queues Rx resources
1957 * @adapter: board private structure
1959 * If this function returns with an error, then it's possible one or
1960 * more of the rings is populated (while the rest are not). It is the
1961 * callers duty to clean those orphaned rings.
1963 * Return 0 on success, negative on failure
1965 static int i40evf_setup_all_rx_resources(struct i40evf_adapter
*adapter
)
1969 for (i
= 0; i
< adapter
->num_active_queues
; i
++) {
1970 adapter
->rx_rings
[i
].count
= adapter
->rx_desc_count
;
1971 err
= i40evf_setup_rx_descriptors(&adapter
->rx_rings
[i
]);
1974 dev_err(&adapter
->pdev
->dev
,
1975 "Allocation for Rx Queue %u failed\n", i
);
1982 * i40evf_free_all_rx_resources - Free Rx Resources for All Queues
1983 * @adapter: board private structure
1985 * Free all receive software resources
1987 void i40evf_free_all_rx_resources(struct i40evf_adapter
*adapter
)
1991 if (!adapter
->rx_rings
)
1994 for (i
= 0; i
< adapter
->num_active_queues
; i
++)
1995 if (adapter
->rx_rings
[i
].desc
)
1996 i40evf_free_rx_resources(&adapter
->rx_rings
[i
]);
2000 * i40evf_open - Called when a network interface is made active
2001 * @netdev: network interface device structure
2003 * Returns 0 on success, negative value on failure
2005 * The open entry point is called when a network interface is made
2006 * active by the system (IFF_UP). At this point all resources needed
2007 * for transmit and receive operations are allocated, the interrupt
2008 * handler is registered with the OS, the watchdog timer is started,
2009 * and the stack is notified that the interface is ready.
2011 static int i40evf_open(struct net_device
*netdev
)
2013 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2016 if (adapter
->flags
& I40EVF_FLAG_PF_COMMS_FAILED
) {
2017 dev_err(&adapter
->pdev
->dev
, "Unable to open device due to PF driver failure.\n");
2021 if (adapter
->state
!= __I40EVF_DOWN
)
2024 /* allocate transmit descriptors */
2025 err
= i40evf_setup_all_tx_resources(adapter
);
2029 /* allocate receive descriptors */
2030 err
= i40evf_setup_all_rx_resources(adapter
);
2034 /* clear any pending interrupts, may auto mask */
2035 err
= i40evf_request_traffic_irqs(adapter
, netdev
->name
);
2039 i40evf_add_filter(adapter
, adapter
->hw
.mac
.addr
);
2040 i40evf_configure(adapter
);
2042 err
= i40evf_up_complete(adapter
);
2046 i40evf_irq_enable(adapter
, true);
2051 i40evf_down(adapter
);
2052 i40evf_free_traffic_irqs(adapter
);
2054 i40evf_free_all_rx_resources(adapter
);
2056 i40evf_free_all_tx_resources(adapter
);
2062 * i40evf_close - Disables a network interface
2063 * @netdev: network interface device structure
2065 * Returns 0, this is not allowed to fail
2067 * The close entry point is called when an interface is de-activated
2068 * by the OS. The hardware is still under the drivers control, but
2069 * needs to be disabled. All IRQs except vector 0 (reserved for admin queue)
2070 * are freed, along with all transmit and receive resources.
2072 static int i40evf_close(struct net_device
*netdev
)
2074 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2076 if (adapter
->state
<= __I40EVF_DOWN_PENDING
)
2080 set_bit(__I40E_DOWN
, &adapter
->vsi
.state
);
2082 i40evf_down(adapter
);
2083 adapter
->state
= __I40EVF_DOWN_PENDING
;
2084 i40evf_free_traffic_irqs(adapter
);
2090 * i40evf_get_stats - Get System Network Statistics
2091 * @netdev: network interface device structure
2093 * Returns the address of the device statistics structure.
2094 * The statistics are actually updated from the timer callback.
2096 static struct net_device_stats
*i40evf_get_stats(struct net_device
*netdev
)
2098 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2100 /* only return the current stats */
2101 return &adapter
->net_stats
;
2105 * i40evf_change_mtu - Change the Maximum Transfer Unit
2106 * @netdev: network interface device structure
2107 * @new_mtu: new value for maximum frame size
2109 * Returns 0 on success, negative on failure
2111 static int i40evf_change_mtu(struct net_device
*netdev
, int new_mtu
)
2113 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2114 int max_frame
= new_mtu
+ ETH_HLEN
+ ETH_FCS_LEN
;
2116 if ((new_mtu
< 68) || (max_frame
> I40E_MAX_RXBUFFER
))
2119 netdev
->mtu
= new_mtu
;
2120 adapter
->flags
|= I40EVF_FLAG_RESET_NEEDED
;
2121 schedule_work(&adapter
->reset_task
);
2126 #define I40EVF_VLAN_FEATURES (NETIF_F_HW_VLAN_CTAG_TX |\
2127 NETIF_F_HW_VLAN_CTAG_RX |\
2128 NETIF_F_HW_VLAN_CTAG_FILTER)
2131 * i40evf_fix_features - fix up the netdev feature bits
2132 * @netdev: our net device
2133 * @features: desired feature bits
2135 * Returns fixed-up features bits
2137 static netdev_features_t
i40evf_fix_features(struct net_device
*netdev
,
2138 netdev_features_t features
)
2140 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2142 features
&= ~I40EVF_VLAN_FEATURES
;
2143 if (adapter
->vf_res
->vf_offload_flags
& I40E_VIRTCHNL_VF_OFFLOAD_VLAN
)
2144 features
|= I40EVF_VLAN_FEATURES
;
2148 static const struct net_device_ops i40evf_netdev_ops
= {
2149 .ndo_open
= i40evf_open
,
2150 .ndo_stop
= i40evf_close
,
2151 .ndo_start_xmit
= i40evf_xmit_frame
,
2152 .ndo_get_stats
= i40evf_get_stats
,
2153 .ndo_set_rx_mode
= i40evf_set_rx_mode
,
2154 .ndo_validate_addr
= eth_validate_addr
,
2155 .ndo_set_mac_address
= i40evf_set_mac
,
2156 .ndo_change_mtu
= i40evf_change_mtu
,
2157 .ndo_tx_timeout
= i40evf_tx_timeout
,
2158 .ndo_vlan_rx_add_vid
= i40evf_vlan_rx_add_vid
,
2159 .ndo_vlan_rx_kill_vid
= i40evf_vlan_rx_kill_vid
,
2160 .ndo_fix_features
= i40evf_fix_features
,
2161 #ifdef CONFIG_NET_POLL_CONTROLLER
2162 .ndo_poll_controller
= i40evf_netpoll
,
2167 * i40evf_check_reset_complete - check that VF reset is complete
2168 * @hw: pointer to hw struct
2170 * Returns 0 if device is ready to use, or -EBUSY if it's in reset.
2172 static int i40evf_check_reset_complete(struct i40e_hw
*hw
)
2177 for (i
= 0; i
< 100; i
++) {
2178 rstat
= rd32(hw
, I40E_VFGEN_RSTAT
) &
2179 I40E_VFGEN_RSTAT_VFR_STATE_MASK
;
2180 if ((rstat
== I40E_VFR_VFACTIVE
) ||
2181 (rstat
== I40E_VFR_COMPLETED
))
2183 usleep_range(10, 20);
2189 * i40evf_process_config - Process the config information we got from the PF
2190 * @adapter: board private structure
2192 * Verify that we have a valid config struct, and set up our netdev features
2193 * and our VSI struct.
2195 int i40evf_process_config(struct i40evf_adapter
*adapter
)
2197 struct i40e_virtchnl_vf_resource
*vfres
= adapter
->vf_res
;
2198 struct net_device
*netdev
= adapter
->netdev
;
2199 struct i40e_vsi
*vsi
= &adapter
->vsi
;
2202 /* got VF config message back from PF, now we can parse it */
2203 for (i
= 0; i
< vfres
->num_vsis
; i
++) {
2204 if (vfres
->vsi_res
[i
].vsi_type
== I40E_VSI_SRIOV
)
2205 adapter
->vsi_res
= &vfres
->vsi_res
[i
];
2207 if (!adapter
->vsi_res
) {
2208 dev_err(&adapter
->pdev
->dev
, "No LAN VSI found\n");
2212 netdev
->hw_enc_features
|= NETIF_F_SG
|
2216 NETIF_F_SOFT_FEATURES
|
2221 NETIF_F_GSO_GRE_CSUM
|
2224 NETIF_F_GSO_UDP_TUNNEL
|
2225 NETIF_F_GSO_UDP_TUNNEL_CSUM
|
2226 NETIF_F_GSO_PARTIAL
|
2232 if (!(adapter
->flags
& I40EVF_FLAG_OUTER_UDP_CSUM_CAPABLE
))
2233 netdev
->gso_partial_features
|= NETIF_F_GSO_UDP_TUNNEL_CSUM
;
2235 netdev
->gso_partial_features
|= NETIF_F_GSO_GRE_CSUM
;
2237 /* record features VLANs can make use of */
2238 netdev
->vlan_features
|= netdev
->hw_enc_features
|
2239 NETIF_F_TSO_MANGLEID
;
2241 /* Write features and hw_features separately to avoid polluting
2242 * with, or dropping, features that are set when we registgered.
2244 netdev
->hw_features
|= netdev
->hw_enc_features
;
2246 netdev
->features
|= netdev
->hw_enc_features
| I40EVF_VLAN_FEATURES
;
2247 netdev
->hw_enc_features
|= NETIF_F_TSO_MANGLEID
;
2249 /* disable VLAN features if not supported */
2250 if (!(vfres
->vf_offload_flags
& I40E_VIRTCHNL_VF_OFFLOAD_VLAN
))
2251 netdev
->features
^= I40EVF_VLAN_FEATURES
;
2253 adapter
->vsi
.id
= adapter
->vsi_res
->vsi_id
;
2255 adapter
->vsi
.back
= adapter
;
2256 adapter
->vsi
.base_vector
= 1;
2257 adapter
->vsi
.work_limit
= I40E_DEFAULT_IRQ_WORK
;
2258 adapter
->vsi
.rx_itr_setting
= (I40E_ITR_DYNAMIC
|
2259 ITR_REG_TO_USEC(I40E_ITR_RX_DEF
));
2260 adapter
->vsi
.tx_itr_setting
= (I40E_ITR_DYNAMIC
|
2261 ITR_REG_TO_USEC(I40E_ITR_TX_DEF
));
2262 vsi
->netdev
= adapter
->netdev
;
2263 vsi
->qs_handle
= adapter
->vsi_res
->qset_handle
;
2264 if (vfres
->vf_offload_flags
& I40E_VIRTCHNL_VF_OFFLOAD_RSS_PF
) {
2265 adapter
->rss_key_size
= vfres
->rss_key_size
;
2266 adapter
->rss_lut_size
= vfres
->rss_lut_size
;
2268 adapter
->rss_key_size
= I40EVF_HKEY_ARRAY_SIZE
;
2269 adapter
->rss_lut_size
= I40EVF_HLUT_ARRAY_SIZE
;
2276 * i40evf_init_task - worker thread to perform delayed initialization
2277 * @work: pointer to work_struct containing our data
2279 * This task completes the work that was begun in probe. Due to the nature
2280 * of VF-PF communications, we may need to wait tens of milliseconds to get
2281 * responses back from the PF. Rather than busy-wait in probe and bog down the
2282 * whole system, we'll do it in a task so we can sleep.
2283 * This task only runs during driver init. Once we've established
2284 * communications with the PF driver and set up our netdev, the watchdog
2287 static void i40evf_init_task(struct work_struct
*work
)
2289 struct i40evf_adapter
*adapter
= container_of(work
,
2290 struct i40evf_adapter
,
2292 struct net_device
*netdev
= adapter
->netdev
;
2293 struct i40e_hw
*hw
= &adapter
->hw
;
2294 struct pci_dev
*pdev
= adapter
->pdev
;
2297 switch (adapter
->state
) {
2298 case __I40EVF_STARTUP
:
2299 /* driver loaded, probe complete */
2300 adapter
->flags
&= ~I40EVF_FLAG_PF_COMMS_FAILED
;
2301 adapter
->flags
&= ~I40EVF_FLAG_RESET_PENDING
;
2302 err
= i40e_set_mac_type(hw
);
2304 dev_err(&pdev
->dev
, "Failed to set MAC type (%d)\n",
2308 err
= i40evf_check_reset_complete(hw
);
2310 dev_info(&pdev
->dev
, "Device is still in reset (%d), retrying\n",
2314 hw
->aq
.num_arq_entries
= I40EVF_AQ_LEN
;
2315 hw
->aq
.num_asq_entries
= I40EVF_AQ_LEN
;
2316 hw
->aq
.arq_buf_size
= I40EVF_MAX_AQ_BUF_SIZE
;
2317 hw
->aq
.asq_buf_size
= I40EVF_MAX_AQ_BUF_SIZE
;
2319 err
= i40evf_init_adminq(hw
);
2321 dev_err(&pdev
->dev
, "Failed to init Admin Queue (%d)\n",
2325 err
= i40evf_send_api_ver(adapter
);
2327 dev_err(&pdev
->dev
, "Unable to send to PF (%d)\n", err
);
2328 i40evf_shutdown_adminq(hw
);
2331 adapter
->state
= __I40EVF_INIT_VERSION_CHECK
;
2333 case __I40EVF_INIT_VERSION_CHECK
:
2334 if (!i40evf_asq_done(hw
)) {
2335 dev_err(&pdev
->dev
, "Admin queue command never completed\n");
2336 i40evf_shutdown_adminq(hw
);
2337 adapter
->state
= __I40EVF_STARTUP
;
2341 /* aq msg sent, awaiting reply */
2342 err
= i40evf_verify_api_ver(adapter
);
2344 if (err
== I40E_ERR_ADMIN_QUEUE_NO_WORK
)
2345 err
= i40evf_send_api_ver(adapter
);
2347 dev_err(&pdev
->dev
, "Unsupported PF API version %d.%d, expected %d.%d\n",
2348 adapter
->pf_version
.major
,
2349 adapter
->pf_version
.minor
,
2350 I40E_VIRTCHNL_VERSION_MAJOR
,
2351 I40E_VIRTCHNL_VERSION_MINOR
);
2354 err
= i40evf_send_vf_config_msg(adapter
);
2356 dev_err(&pdev
->dev
, "Unable to send config request (%d)\n",
2360 adapter
->state
= __I40EVF_INIT_GET_RESOURCES
;
2362 case __I40EVF_INIT_GET_RESOURCES
:
2363 /* aq msg sent, awaiting reply */
2364 if (!adapter
->vf_res
) {
2365 bufsz
= sizeof(struct i40e_virtchnl_vf_resource
) +
2367 sizeof(struct i40e_virtchnl_vsi_resource
));
2368 adapter
->vf_res
= kzalloc(bufsz
, GFP_KERNEL
);
2369 if (!adapter
->vf_res
)
2372 err
= i40evf_get_vf_config(adapter
);
2373 if (err
== I40E_ERR_ADMIN_QUEUE_NO_WORK
) {
2374 err
= i40evf_send_vf_config_msg(adapter
);
2376 } else if (err
== I40E_ERR_PARAM
) {
2377 /* We only get ERR_PARAM if the device is in a very bad
2378 * state or if we've been disabled for previous bad
2379 * behavior. Either way, we're done now.
2381 i40evf_shutdown_adminq(hw
);
2382 dev_err(&pdev
->dev
, "Unable to get VF config due to PF error condition, not retrying\n");
2386 dev_err(&pdev
->dev
, "Unable to get VF config (%d)\n",
2390 adapter
->state
= __I40EVF_INIT_SW
;
2396 if (hw
->mac
.type
== I40E_MAC_X722_VF
)
2397 adapter
->flags
|= I40EVF_FLAG_OUTER_UDP_CSUM_CAPABLE
;
2399 if (i40evf_process_config(adapter
))
2401 adapter
->current_op
= I40E_VIRTCHNL_OP_UNKNOWN
;
2403 adapter
->flags
|= I40EVF_FLAG_RX_CSUM_ENABLED
;
2405 netdev
->netdev_ops
= &i40evf_netdev_ops
;
2406 i40evf_set_ethtool_ops(netdev
);
2407 netdev
->watchdog_timeo
= 5 * HZ
;
2409 if (!is_valid_ether_addr(adapter
->hw
.mac
.addr
)) {
2410 dev_info(&pdev
->dev
, "Invalid MAC address %pM, using random\n",
2411 adapter
->hw
.mac
.addr
);
2412 eth_hw_addr_random(netdev
);
2413 ether_addr_copy(adapter
->hw
.mac
.addr
, netdev
->dev_addr
);
2415 adapter
->flags
|= I40EVF_FLAG_ADDR_SET_BY_PF
;
2416 ether_addr_copy(netdev
->dev_addr
, adapter
->hw
.mac
.addr
);
2417 ether_addr_copy(netdev
->perm_addr
, adapter
->hw
.mac
.addr
);
2420 init_timer(&adapter
->watchdog_timer
);
2421 adapter
->watchdog_timer
.function
= &i40evf_watchdog_timer
;
2422 adapter
->watchdog_timer
.data
= (unsigned long)adapter
;
2423 mod_timer(&adapter
->watchdog_timer
, jiffies
+ 1);
2425 adapter
->num_active_queues
= min_t(int,
2426 adapter
->vsi_res
->num_queue_pairs
,
2427 (int)(num_online_cpus()));
2428 adapter
->tx_desc_count
= I40EVF_DEFAULT_TXD
;
2429 adapter
->rx_desc_count
= I40EVF_DEFAULT_RXD
;
2430 err
= i40evf_init_interrupt_scheme(adapter
);
2433 i40evf_map_rings_to_vectors(adapter
);
2434 if (adapter
->vf_res
->vf_offload_flags
&
2435 I40E_VIRTCHNL_VF_OFFLOAD_WB_ON_ITR
)
2436 adapter
->flags
|= I40EVF_FLAG_WB_ON_ITR_CAPABLE
;
2438 err
= i40evf_request_misc_irq(adapter
);
2442 netif_carrier_off(netdev
);
2444 if (!adapter
->netdev_registered
) {
2445 err
= register_netdev(netdev
);
2450 adapter
->netdev_registered
= true;
2452 netif_tx_stop_all_queues(netdev
);
2454 dev_info(&pdev
->dev
, "MAC address: %pM\n", adapter
->hw
.mac
.addr
);
2455 if (netdev
->features
& NETIF_F_GRO
)
2456 dev_info(&pdev
->dev
, "GRO is enabled\n");
2458 adapter
->state
= __I40EVF_DOWN
;
2459 set_bit(__I40E_DOWN
, &adapter
->vsi
.state
);
2460 i40evf_misc_irq_enable(adapter
);
2462 adapter
->rss_key
= kzalloc(adapter
->rss_key_size
, GFP_KERNEL
);
2463 adapter
->rss_lut
= kzalloc(adapter
->rss_lut_size
, GFP_KERNEL
);
2464 if (!adapter
->rss_key
|| !adapter
->rss_lut
)
2467 if (RSS_AQ(adapter
)) {
2468 adapter
->aq_required
|= I40EVF_FLAG_AQ_CONFIGURE_RSS
;
2469 mod_timer_pending(&adapter
->watchdog_timer
, jiffies
+ 1);
2471 i40evf_init_rss(adapter
);
2475 schedule_delayed_work(&adapter
->init_task
, msecs_to_jiffies(30));
2478 i40evf_free_rss(adapter
);
2480 i40evf_free_misc_irq(adapter
);
2482 i40evf_reset_interrupt_capability(adapter
);
2484 kfree(adapter
->vf_res
);
2485 adapter
->vf_res
= NULL
;
2487 /* Things went into the weeds, so try again later */
2488 if (++adapter
->aq_wait_count
> I40EVF_AQ_MAX_ERR
) {
2489 dev_err(&pdev
->dev
, "Failed to communicate with PF; waiting before retry\n");
2490 adapter
->flags
|= I40EVF_FLAG_PF_COMMS_FAILED
;
2491 i40evf_shutdown_adminq(hw
);
2492 adapter
->state
= __I40EVF_STARTUP
;
2493 schedule_delayed_work(&adapter
->init_task
, HZ
* 5);
2496 schedule_delayed_work(&adapter
->init_task
, HZ
);
2500 * i40evf_shutdown - Shutdown the device in preparation for a reboot
2501 * @pdev: pci device structure
2503 static void i40evf_shutdown(struct pci_dev
*pdev
)
2505 struct net_device
*netdev
= pci_get_drvdata(pdev
);
2506 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2508 netif_device_detach(netdev
);
2510 if (netif_running(netdev
))
2511 i40evf_close(netdev
);
2513 /* Prevent the watchdog from running. */
2514 adapter
->state
= __I40EVF_REMOVE
;
2515 adapter
->aq_required
= 0;
2518 pci_save_state(pdev
);
2521 pci_disable_device(pdev
);
2525 * i40evf_probe - Device Initialization Routine
2526 * @pdev: PCI device information struct
2527 * @ent: entry in i40evf_pci_tbl
2529 * Returns 0 on success, negative on failure
2531 * i40evf_probe initializes an adapter identified by a pci_dev structure.
2532 * The OS initialization, configuring of the adapter private structure,
2533 * and a hardware reset occur.
2535 static int i40evf_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
2537 struct net_device
*netdev
;
2538 struct i40evf_adapter
*adapter
= NULL
;
2539 struct i40e_hw
*hw
= NULL
;
2542 err
= pci_enable_device(pdev
);
2546 err
= dma_set_mask_and_coherent(&pdev
->dev
, DMA_BIT_MASK(64));
2548 err
= dma_set_mask_and_coherent(&pdev
->dev
, DMA_BIT_MASK(32));
2551 "DMA configuration failed: 0x%x\n", err
);
2556 err
= pci_request_regions(pdev
, i40evf_driver_name
);
2559 "pci_request_regions failed 0x%x\n", err
);
2563 pci_enable_pcie_error_reporting(pdev
);
2565 pci_set_master(pdev
);
2567 netdev
= alloc_etherdev_mq(sizeof(struct i40evf_adapter
), MAX_QUEUES
);
2570 goto err_alloc_etherdev
;
2573 SET_NETDEV_DEV(netdev
, &pdev
->dev
);
2575 pci_set_drvdata(pdev
, netdev
);
2576 adapter
= netdev_priv(netdev
);
2578 adapter
->netdev
= netdev
;
2579 adapter
->pdev
= pdev
;
2584 adapter
->msg_enable
= BIT(DEFAULT_DEBUG_LEVEL_SHIFT
) - 1;
2585 adapter
->state
= __I40EVF_STARTUP
;
2587 /* Call save state here because it relies on the adapter struct. */
2588 pci_save_state(pdev
);
2590 hw
->hw_addr
= ioremap(pci_resource_start(pdev
, 0),
2591 pci_resource_len(pdev
, 0));
2596 hw
->vendor_id
= pdev
->vendor
;
2597 hw
->device_id
= pdev
->device
;
2598 pci_read_config_byte(pdev
, PCI_REVISION_ID
, &hw
->revision_id
);
2599 hw
->subsystem_vendor_id
= pdev
->subsystem_vendor
;
2600 hw
->subsystem_device_id
= pdev
->subsystem_device
;
2601 hw
->bus
.device
= PCI_SLOT(pdev
->devfn
);
2602 hw
->bus
.func
= PCI_FUNC(pdev
->devfn
);
2604 /* set up the locks for the AQ, do this only once in probe
2605 * and destroy them only once in remove
2607 mutex_init(&hw
->aq
.asq_mutex
);
2608 mutex_init(&hw
->aq
.arq_mutex
);
2610 INIT_LIST_HEAD(&adapter
->mac_filter_list
);
2611 INIT_LIST_HEAD(&adapter
->vlan_filter_list
);
2613 INIT_WORK(&adapter
->reset_task
, i40evf_reset_task
);
2614 INIT_WORK(&adapter
->adminq_task
, i40evf_adminq_task
);
2615 INIT_WORK(&adapter
->watchdog_task
, i40evf_watchdog_task
);
2616 INIT_DELAYED_WORK(&adapter
->init_task
, i40evf_init_task
);
2617 schedule_delayed_work(&adapter
->init_task
,
2618 msecs_to_jiffies(5 * (pdev
->devfn
& 0x07)));
2623 free_netdev(netdev
);
2625 pci_release_regions(pdev
);
2628 pci_disable_device(pdev
);
2634 * i40evf_suspend - Power management suspend routine
2635 * @pdev: PCI device information struct
2638 * Called when the system (VM) is entering sleep/suspend.
2640 static int i40evf_suspend(struct pci_dev
*pdev
, pm_message_t state
)
2642 struct net_device
*netdev
= pci_get_drvdata(pdev
);
2643 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2646 netif_device_detach(netdev
);
2648 if (netif_running(netdev
)) {
2650 i40evf_down(adapter
);
2653 i40evf_free_misc_irq(adapter
);
2654 i40evf_reset_interrupt_capability(adapter
);
2656 retval
= pci_save_state(pdev
);
2660 pci_disable_device(pdev
);
2666 * i40evf_resume - Power management resume routine
2667 * @pdev: PCI device information struct
2669 * Called when the system (VM) is resumed from sleep/suspend.
2671 static int i40evf_resume(struct pci_dev
*pdev
)
2673 struct i40evf_adapter
*adapter
= pci_get_drvdata(pdev
);
2674 struct net_device
*netdev
= adapter
->netdev
;
2677 pci_set_power_state(pdev
, PCI_D0
);
2678 pci_restore_state(pdev
);
2679 /* pci_restore_state clears dev->state_saved so call
2680 * pci_save_state to restore it.
2682 pci_save_state(pdev
);
2684 err
= pci_enable_device_mem(pdev
);
2686 dev_err(&pdev
->dev
, "Cannot enable PCI device from suspend.\n");
2689 pci_set_master(pdev
);
2692 err
= i40evf_set_interrupt_capability(adapter
);
2695 dev_err(&pdev
->dev
, "Cannot enable MSI-X interrupts.\n");
2698 err
= i40evf_request_misc_irq(adapter
);
2701 dev_err(&pdev
->dev
, "Cannot get interrupt vector.\n");
2705 schedule_work(&adapter
->reset_task
);
2707 netif_device_attach(netdev
);
2712 #endif /* CONFIG_PM */
2714 * i40evf_remove - Device Removal Routine
2715 * @pdev: PCI device information struct
2717 * i40evf_remove is called by the PCI subsystem to alert the driver
2718 * that it should release a PCI device. The could be caused by a
2719 * Hot-Plug event, or because the driver is going to be removed from
2722 static void i40evf_remove(struct pci_dev
*pdev
)
2724 struct net_device
*netdev
= pci_get_drvdata(pdev
);
2725 struct i40evf_adapter
*adapter
= netdev_priv(netdev
);
2726 struct i40evf_mac_filter
*f
, *ftmp
;
2727 struct i40e_hw
*hw
= &adapter
->hw
;
2729 cancel_delayed_work_sync(&adapter
->init_task
);
2730 cancel_work_sync(&adapter
->reset_task
);
2732 if (adapter
->netdev_registered
) {
2733 unregister_netdev(netdev
);
2734 adapter
->netdev_registered
= false;
2737 /* Shut down all the garbage mashers on the detention level */
2738 adapter
->state
= __I40EVF_REMOVE
;
2739 adapter
->aq_required
= 0;
2740 i40evf_request_reset(adapter
);
2742 /* If the FW isn't responding, kick it once, but only once. */
2743 if (!i40evf_asq_done(hw
)) {
2744 i40evf_request_reset(adapter
);
2748 if (adapter
->msix_entries
) {
2749 i40evf_misc_irq_disable(adapter
);
2750 i40evf_free_misc_irq(adapter
);
2751 i40evf_reset_interrupt_capability(adapter
);
2752 i40evf_free_q_vectors(adapter
);
2755 if (adapter
->watchdog_timer
.function
)
2756 del_timer_sync(&adapter
->watchdog_timer
);
2758 flush_scheduled_work();
2760 i40evf_free_rss(adapter
);
2762 if (hw
->aq
.asq
.count
)
2763 i40evf_shutdown_adminq(hw
);
2765 /* destroy the locks only once, here */
2766 mutex_destroy(&hw
->aq
.arq_mutex
);
2767 mutex_destroy(&hw
->aq
.asq_mutex
);
2769 iounmap(hw
->hw_addr
);
2770 pci_release_regions(pdev
);
2772 i40evf_free_all_tx_resources(adapter
);
2773 i40evf_free_all_rx_resources(adapter
);
2774 i40evf_free_queues(adapter
);
2775 kfree(adapter
->vf_res
);
2776 /* If we got removed before an up/down sequence, we've got a filter
2777 * hanging out there that we need to get rid of.
2779 list_for_each_entry_safe(f
, ftmp
, &adapter
->mac_filter_list
, list
) {
2783 list_for_each_entry_safe(f
, ftmp
, &adapter
->vlan_filter_list
, list
) {
2788 free_netdev(netdev
);
2790 pci_disable_pcie_error_reporting(pdev
);
2792 pci_disable_device(pdev
);
2795 static struct pci_driver i40evf_driver
= {
2796 .name
= i40evf_driver_name
,
2797 .id_table
= i40evf_pci_tbl
,
2798 .probe
= i40evf_probe
,
2799 .remove
= i40evf_remove
,
2801 .suspend
= i40evf_suspend
,
2802 .resume
= i40evf_resume
,
2804 .shutdown
= i40evf_shutdown
,
2808 * i40e_init_module - Driver Registration Routine
2810 * i40e_init_module is the first routine called when the driver is
2811 * loaded. All it does is register with the PCI subsystem.
2813 static int __init
i40evf_init_module(void)
2817 pr_info("i40evf: %s - version %s\n", i40evf_driver_string
,
2818 i40evf_driver_version
);
2820 pr_info("%s\n", i40evf_copyright
);
2822 i40evf_wq
= create_singlethread_workqueue(i40evf_driver_name
);
2824 pr_err("%s: Failed to create workqueue\n", i40evf_driver_name
);
2827 ret
= pci_register_driver(&i40evf_driver
);
2831 module_init(i40evf_init_module
);
2834 * i40e_exit_module - Driver Exit Cleanup Routine
2836 * i40e_exit_module is called just before the driver is removed
2839 static void __exit
i40evf_exit_module(void)
2841 pci_unregister_driver(&i40evf_driver
);
2842 destroy_workqueue(i40evf_wq
);
2845 module_exit(i40evf_exit_module
);