1 /******************************************************************************
3 Copyright (c) 2013-2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ******************************************************************************/
40 #include "ixl_iw_int.h"
44 #include "ixl_pf_iov.h"
47 /*********************************************************************
49 *********************************************************************/
50 char ixl_driver_version[] = "1.7.12-k";
52 /*********************************************************************
55 * Used by probe to select devices to load on
56 * Last field stores an index into ixl_strings
57 * Last entry must be all 0s
59 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, String Index }
60 *********************************************************************/
62 static ixl_vendor_info_t ixl_vendor_info_array[] =
64 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_SFP_XL710, 0, 0, 0},
65 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_KX_B, 0, 0, 0},
66 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_KX_C, 0, 0, 0},
67 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_QSFP_A, 0, 0, 0},
68 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_QSFP_B, 0, 0, 0},
69 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_QSFP_C, 0, 0, 0},
70 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_10G_BASE_T, 0, 0, 0},
71 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_10G_BASE_T4, 0, 0, 0},
72 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_KX_X722, 0, 0, 0},
73 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_QSFP_X722, 0, 0, 0},
74 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_SFP_X722, 0, 0, 0},
75 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_1G_BASE_T_X722, 0, 0, 0},
76 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_10G_BASE_T_X722, 0, 0, 0},
77 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_SFP_I_X722, 0, 0, 0},
78 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_25G_B, 0, 0, 0},
79 {I40E_INTEL_VENDOR_ID, I40E_DEV_ID_25G_SFP28, 0, 0, 0},
80 /* required last entry */
84 /*********************************************************************
85 * Table of branding strings
86 *********************************************************************/
88 static char *ixl_strings[] = {
89 "Intel(R) Ethernet Connection XL710/X722 Driver"
93 /*********************************************************************
95 *********************************************************************/
96 static int ixl_probe(device_t);
97 static int ixl_attach(device_t);
98 static int ixl_detach(device_t);
99 static int ixl_shutdown(device_t);
101 static int ixl_save_pf_tunables(struct ixl_pf *);
102 static int ixl_attach_get_link_status(struct ixl_pf *);
104 /*********************************************************************
105 * FreeBSD Device Interface Entry Points
106 *********************************************************************/
108 static device_method_t ixl_methods[] = {
109 /* Device interface */
110 DEVMETHOD(device_probe, ixl_probe),
111 DEVMETHOD(device_attach, ixl_attach),
112 DEVMETHOD(device_detach, ixl_detach),
113 DEVMETHOD(device_shutdown, ixl_shutdown),
115 DEVMETHOD(pci_iov_init, ixl_iov_init),
116 DEVMETHOD(pci_iov_uninit, ixl_iov_uninit),
117 DEVMETHOD(pci_iov_add_vf, ixl_add_vf),
122 static driver_t ixl_driver = {
123 "ixl", ixl_methods, sizeof(struct ixl_pf),
126 devclass_t ixl_devclass;
127 DRIVER_MODULE(ixl, pci, ixl_driver, ixl_devclass, 0, 0);
129 MODULE_VERSION(ixl, 1);
131 MODULE_DEPEND(ixl, pci, 1, 1, 1);
132 MODULE_DEPEND(ixl, ether, 1, 1, 1);
133 #if defined(DEV_NETMAP) && __FreeBSD_version >= 1100000
134 MODULE_DEPEND(ixl, netmap, 1, 1, 1);
135 #endif /* DEV_NETMAP */
138 ** TUNEABLE PARAMETERS:
141 static SYSCTL_NODE(_hw, OID_AUTO, ixl, CTLFLAG_RD, 0,
142 "IXL driver parameters");
145 * MSIX should be the default for best performance,
146 * but this allows it to be forced off for testing.
148 static int ixl_enable_msix = 1;
149 TUNABLE_INT("hw.ixl.enable_msix", &ixl_enable_msix);
150 SYSCTL_INT(_hw_ixl, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixl_enable_msix, 0,
151 "Enable MSI-X interrupts");
154 ** Number of descriptors per ring:
155 ** - TX and RX are the same size
157 static int ixl_ring_size = IXL_DEFAULT_RING;
158 TUNABLE_INT("hw.ixl.ring_size", &ixl_ring_size);
159 SYSCTL_INT(_hw_ixl, OID_AUTO, ring_size, CTLFLAG_RDTUN,
160 &ixl_ring_size, 0, "Descriptor Ring Size");
163 ** This can be set manually, if left as 0 the
164 ** number of queues will be calculated based
165 ** on cpus and msix vectors available.
167 static int ixl_max_queues = 0;
168 TUNABLE_INT("hw.ixl.max_queues", &ixl_max_queues);
169 SYSCTL_INT(_hw_ixl, OID_AUTO, max_queues, CTLFLAG_RDTUN,
170 &ixl_max_queues, 0, "Number of Queues");
172 static int ixl_enable_tx_fc_filter = 1;
173 TUNABLE_INT("hw.ixl.enable_tx_fc_filter",
174 &ixl_enable_tx_fc_filter);
175 SYSCTL_INT(_hw_ixl, OID_AUTO, enable_tx_fc_filter, CTLFLAG_RDTUN,
176 &ixl_enable_tx_fc_filter, 0,
177 "Filter out packets with Ethertype 0x8808 from being sent out by non-HW sources");
179 static int ixl_core_debug_mask = 0;
180 TUNABLE_INT("hw.ixl.core_debug_mask",
181 &ixl_core_debug_mask);
182 SYSCTL_INT(_hw_ixl, OID_AUTO, core_debug_mask, CTLFLAG_RDTUN,
183 &ixl_core_debug_mask, 0,
184 "Display debug statements that are printed in non-shared code");
186 static int ixl_shared_debug_mask = 0;
187 TUNABLE_INT("hw.ixl.shared_debug_mask",
188 &ixl_shared_debug_mask);
189 SYSCTL_INT(_hw_ixl, OID_AUTO, shared_debug_mask, CTLFLAG_RDTUN,
190 &ixl_shared_debug_mask, 0,
191 "Display debug statements that are printed in shared code");
194 ** Controls for Interrupt Throttling
195 ** - true/false for dynamic adjustment
196 ** - default values for static ITR
198 static int ixl_dynamic_rx_itr = 1;
199 TUNABLE_INT("hw.ixl.dynamic_rx_itr", &ixl_dynamic_rx_itr);
200 SYSCTL_INT(_hw_ixl, OID_AUTO, dynamic_rx_itr, CTLFLAG_RDTUN,
201 &ixl_dynamic_rx_itr, 0, "Dynamic RX Interrupt Rate");
203 static int ixl_dynamic_tx_itr = 1;
204 TUNABLE_INT("hw.ixl.dynamic_tx_itr", &ixl_dynamic_tx_itr);
205 SYSCTL_INT(_hw_ixl, OID_AUTO, dynamic_tx_itr, CTLFLAG_RDTUN,
206 &ixl_dynamic_tx_itr, 0, "Dynamic TX Interrupt Rate");
208 static int ixl_rx_itr = IXL_ITR_8K;
209 TUNABLE_INT("hw.ixl.rx_itr", &ixl_rx_itr);
210 SYSCTL_INT(_hw_ixl, OID_AUTO, rx_itr, CTLFLAG_RDTUN,
211 &ixl_rx_itr, 0, "RX Interrupt Rate");
213 static int ixl_tx_itr = IXL_ITR_4K;
214 TUNABLE_INT("hw.ixl.tx_itr", &ixl_tx_itr);
215 SYSCTL_INT(_hw_ixl, OID_AUTO, tx_itr, CTLFLAG_RDTUN,
216 &ixl_tx_itr, 0, "TX Interrupt Rate");
219 int ixl_enable_iwarp = 0;
220 TUNABLE_INT("hw.ixl.enable_iwarp", &ixl_enable_iwarp);
224 #define NETMAP_IXL_MAIN /* only bring in one part of the netmap code */
225 #include <dev/netmap/if_ixl_netmap.h>
226 #endif /* DEV_NETMAP */
228 /*********************************************************************
229 * Device identification routine
231 * ixl_probe determines if the driver should be loaded on
232 * the hardware based on PCI vendor/device id of the device.
234 * return BUS_PROBE_DEFAULT on success, positive on failure
235 *********************************************************************/
238 ixl_probe(device_t dev)
240 ixl_vendor_info_t *ent;
242 u16 pci_vendor_id, pci_device_id;
243 u16 pci_subvendor_id, pci_subdevice_id;
244 char device_name[256];
247 INIT_DEBUGOUT("ixl_probe: begin");
249 pci_vendor_id = pci_get_vendor(dev);
250 if (pci_vendor_id != I40E_INTEL_VENDOR_ID)
253 pci_device_id = pci_get_device(dev);
254 pci_subvendor_id = pci_get_subvendor(dev);
255 pci_subdevice_id = pci_get_subdevice(dev);
257 ent = ixl_vendor_info_array;
258 while (ent->vendor_id != 0) {
259 if ((pci_vendor_id == ent->vendor_id) &&
260 (pci_device_id == ent->device_id) &&
262 ((pci_subvendor_id == ent->subvendor_id) ||
263 (ent->subvendor_id == 0)) &&
265 ((pci_subdevice_id == ent->subdevice_id) ||
266 (ent->subdevice_id == 0))) {
267 sprintf(device_name, "%s, Version - %s",
268 ixl_strings[ent->index],
270 device_set_desc_copy(dev, device_name);
271 return (BUS_PROBE_DEFAULT);
279 ixl_attach_get_link_status(struct ixl_pf *pf)
281 struct i40e_hw *hw = &pf->hw;
282 device_t dev = pf->dev;
285 if (((hw->aq.fw_maj_ver == 4) && (hw->aq.fw_min_ver < 33)) ||
286 (hw->aq.fw_maj_ver < 4)) {
288 error = i40e_aq_set_link_restart_an(hw, TRUE, NULL);
290 device_printf(dev, "link restart failed, aq_err=%d\n",
291 pf->hw.aq.asq_last_status);
296 /* Determine link state */
297 hw->phy.get_link_info = TRUE;
298 i40e_get_link_status(hw, &pf->link_up);
303 * Sanity check and save off tunable values.
306 ixl_save_pf_tunables(struct ixl_pf *pf)
308 device_t dev = pf->dev;
310 /* Save tunable information */
311 pf->enable_msix = ixl_enable_msix;
312 pf->max_queues = ixl_max_queues;
313 pf->enable_tx_fc_filter = ixl_enable_tx_fc_filter;
314 pf->dynamic_rx_itr = ixl_dynamic_rx_itr;
315 pf->dynamic_tx_itr = ixl_dynamic_tx_itr;
316 pf->dbg_mask = ixl_core_debug_mask;
317 pf->hw.debug_mask = ixl_shared_debug_mask;
319 if (ixl_ring_size < IXL_MIN_RING
320 || ixl_ring_size > IXL_MAX_RING
321 || ixl_ring_size % IXL_RING_INCREMENT != 0) {
322 device_printf(dev, "Invalid ring_size value of %d set!\n",
324 device_printf(dev, "ring_size must be between %d and %d, "
325 "inclusive, and must be a multiple of %d\n",
326 IXL_MIN_RING, IXL_MAX_RING, IXL_RING_INCREMENT);
327 device_printf(dev, "Using default value of %d instead\n",
329 pf->ringsz = IXL_DEFAULT_RING;
331 pf->ringsz = ixl_ring_size;
333 if (ixl_tx_itr < 0 || ixl_tx_itr > IXL_MAX_ITR) {
334 device_printf(dev, "Invalid tx_itr value of %d set!\n",
336 device_printf(dev, "tx_itr must be between %d and %d, "
339 device_printf(dev, "Using default value of %d instead\n",
341 pf->tx_itr = IXL_ITR_4K;
343 pf->tx_itr = ixl_tx_itr;
345 if (ixl_rx_itr < 0 || ixl_rx_itr > IXL_MAX_ITR) {
346 device_printf(dev, "Invalid rx_itr value of %d set!\n",
348 device_printf(dev, "rx_itr must be between %d and %d, "
351 device_printf(dev, "Using default value of %d instead\n",
353 pf->rx_itr = IXL_ITR_8K;
355 pf->rx_itr = ixl_rx_itr;
360 /*********************************************************************
361 * Device initialization routine
363 * The attach entry point is called when the driver is being loaded.
364 * This routine identifies the type of hardware, allocates all resources
365 * and initializes the hardware.
367 * return 0 on success, positive on failure
368 *********************************************************************/
371 ixl_attach(device_t dev)
376 enum i40e_status_code status;
379 INIT_DEBUGOUT("ixl_attach: begin");
381 /* Allocate, clear, and link in our primary soft structure */
382 pf = device_get_softc(dev);
383 pf->dev = pf->osdep.dev = dev;
387 ** Note this assumes we have a single embedded VSI,
388 ** this could be enhanced later to allocate multiple
393 /* Save tunable values */
394 error = ixl_save_pf_tunables(pf);
399 IXL_PF_LOCK_INIT(pf, device_get_nameunit(dev));
401 /* Set up the timer callout */
402 callout_init_mtx(&pf->timer, &pf->pf_mtx, 0);
404 /* Do PCI setup - map BAR0, etc */
405 if (ixl_allocate_pci_resources(pf)) {
406 device_printf(dev, "Allocation of PCI resources failed\n");
411 /* Establish a clean starting point */
413 status = i40e_pf_reset(hw);
415 device_printf(dev, "PF reset failure %s\n",
416 i40e_stat_str(hw, status));
421 /* Initialize the shared code */
422 status = i40e_init_shared_code(hw);
424 device_printf(dev, "Unable to initialize shared code, error %s\n",
425 i40e_stat_str(hw, status));
431 * Allocate interrupts and figure out number of queues to use
434 pf->msix = ixl_init_msix(pf);
436 /* Set up the admin queue */
437 hw->aq.num_arq_entries = IXL_AQ_LEN;
438 hw->aq.num_asq_entries = IXL_AQ_LEN;
439 hw->aq.arq_buf_size = IXL_AQ_BUF_SZ;
440 hw->aq.asq_buf_size = IXL_AQ_BUF_SZ;
442 status = i40e_init_adminq(hw);
443 if (status != 0 && status != I40E_ERR_FIRMWARE_API_VERSION) {
444 device_printf(dev, "Unable to initialize Admin Queue, error %s\n",
445 i40e_stat_str(hw, status));
449 ixl_print_nvm_version(pf);
451 if (status == I40E_ERR_FIRMWARE_API_VERSION) {
452 device_printf(dev, "The driver for the device stopped "
453 "because the NVM image is newer than expected.\n"
454 "You must install the most recent version of "
455 "the network driver.\n");
460 if (hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&
461 hw->aq.api_min_ver > I40E_FW_API_VERSION_MINOR)
462 device_printf(dev, "The driver for the device detected "
463 "a newer version of the NVM image than expected.\n"
464 "Please install the most recent version of the network driver.\n");
465 else if (hw->aq.api_maj_ver < I40E_FW_API_VERSION_MAJOR ||
466 hw->aq.api_min_ver < (I40E_FW_API_VERSION_MINOR - 1))
467 device_printf(dev, "The driver for the device detected "
468 "an older version of the NVM image than expected.\n"
469 "Please update the NVM image.\n");
472 i40e_clear_pxe_mode(hw);
474 /* Get capabilities from the device */
475 error = ixl_get_hw_capabilities(pf);
477 device_printf(dev, "HW capabilities failure!\n");
481 /* Set up host memory cache */
482 status = i40e_init_lan_hmc(hw, hw->func_caps.num_tx_qp,
483 hw->func_caps.num_rx_qp, 0, 0);
485 device_printf(dev, "init_lan_hmc failed: %s\n",
486 i40e_stat_str(hw, status));
490 status = i40e_configure_lan_hmc(hw, I40E_HMC_MODEL_DIRECT_ONLY);
492 device_printf(dev, "configure_lan_hmc failed: %s\n",
493 i40e_stat_str(hw, status));
497 /* Init queue allocation manager */
498 error = ixl_pf_qmgr_init(&pf->qmgr, hw->func_caps.num_tx_qp);
500 device_printf(dev, "Failed to init queue manager for PF queues, error %d\n",
504 /* reserve a contiguous allocation for the PF's VSI */
505 error = ixl_pf_qmgr_alloc_contiguous(&pf->qmgr, vsi->num_queues, &pf->qtag);
507 device_printf(dev, "Failed to reserve queues for PF LAN VSI, error %d\n",
511 device_printf(dev, "Allocating %d queues for PF LAN VSI; %d queues active\n",
512 pf->qtag.num_allocated, pf->qtag.num_active);
514 /* Disable LLDP from the firmware for certain NVM versions */
515 if (((pf->hw.aq.fw_maj_ver == 4) && (pf->hw.aq.fw_min_ver < 3)) ||
516 (pf->hw.aq.fw_maj_ver < 4))
517 i40e_aq_stop_lldp(hw, TRUE, NULL);
519 /* Get MAC addresses from hardware */
520 i40e_get_mac_addr(hw, hw->mac.addr);
521 error = i40e_validate_mac_addr(hw->mac.addr);
523 device_printf(dev, "validate_mac_addr failed: %d\n", error);
526 bcopy(hw->mac.addr, hw->mac.perm_addr, ETHER_ADDR_LEN);
527 i40e_get_port_mac_addr(hw, hw->mac.port_addr);
529 /* Initialize mac filter list for VSI */
530 SLIST_INIT(&vsi->ftl);
532 /* Set up SW VSI and allocate queue memory and rings */
533 if (ixl_setup_stations(pf)) {
534 device_printf(dev, "setup stations failed!\n");
539 /* Setup OS network interface / ifnet */
540 if (ixl_setup_interface(dev, vsi)) {
541 device_printf(dev, "interface setup failed!\n");
546 /* Determine link state */
547 if (ixl_attach_get_link_status(pf)) {
552 error = ixl_switch_config(pf);
554 device_printf(dev, "Initial ixl_switch_config() failed: %d\n",
559 /* Limit PHY interrupts to link, autoneg, and modules failure */
560 status = i40e_aq_set_phy_int_mask(hw, IXL_DEFAULT_PHY_INT_MASK,
563 device_printf(dev, "i40e_aq_set_phy_mask() failed: err %s,"
564 " aq_err %s\n", i40e_stat_str(hw, status),
565 i40e_aq_str(hw, hw->aq.asq_last_status));
569 /* Get the bus configuration and set the shared code's config */
570 ixl_get_bus_info(pf);
573 * In MSI-X mode, initialize the Admin Queue interrupt,
574 * so userland tools can communicate with the adapter regardless of
575 * the ifnet interface's status.
578 error = ixl_setup_adminq_msix(pf);
580 device_printf(dev, "ixl_setup_adminq_msix() error: %d\n",
584 error = ixl_setup_adminq_tq(pf);
586 device_printf(dev, "ixl_setup_adminq_tq() error: %d\n",
590 ixl_configure_intr0_msix(pf);
591 ixl_enable_intr0(hw);
593 error = ixl_setup_queue_msix(vsi);
595 device_printf(dev, "ixl_setup_queue_msix() error: %d\n",
597 error = ixl_setup_queue_tqs(vsi);
599 device_printf(dev, "ixl_setup_queue_tqs() error: %d\n",
602 error = ixl_setup_legacy(pf);
604 error = ixl_setup_adminq_tq(pf);
606 device_printf(dev, "ixl_setup_adminq_tq() error: %d\n",
611 error = ixl_setup_queue_tqs(vsi);
613 device_printf(dev, "ixl_setup_queue_tqs() error: %d\n",
618 device_printf(dev, "interrupt setup error: %d\n", error);
621 /* Set initial advertised speed sysctl value */
622 ixl_get_initial_advertised_speeds(pf);
624 /* Initialize statistics & add sysctls */
625 ixl_add_device_sysctls(pf);
627 ixl_pf_reset_stats(pf);
628 ixl_update_stats_counters(pf);
629 ixl_add_hw_stats(pf);
631 /* Register for VLAN events */
632 vsi->vlan_attach = EVENTHANDLER_REGISTER(vlan_config,
633 ixl_register_vlan, vsi, EVENTHANDLER_PRI_FIRST);
634 vsi->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig,
635 ixl_unregister_vlan, vsi, EVENTHANDLER_PRI_FIRST);
638 ixl_initialize_sriov(pf);
642 ixl_netmap_attach(vsi);
643 #endif /* DEV_NETMAP */
646 if (hw->func_caps.iwarp && ixl_enable_iwarp) {
647 pf->iw_enabled = (pf->iw_msix > 0) ? true : false;
648 if (pf->iw_enabled) {
649 error = ixl_iw_pf_attach(pf);
652 "interfacing to iwarp driver failed: %d\n",
658 "iwarp disabled on this device (no msix vectors)\n");
660 pf->iw_enabled = false;
661 device_printf(dev, "The device is not iWARP enabled\n");
665 INIT_DEBUGOUT("ixl_attach: end");
669 if (vsi->ifp != NULL) {
670 ether_ifdetach(vsi->ifp);
674 i40e_shutdown_lan_hmc(hw);
676 i40e_shutdown_adminq(hw);
678 ixl_free_pci_resources(pf);
680 IXL_PF_LOCK_DESTROY(pf);
684 /*********************************************************************
685 * Device removal routine
687 * The detach entry point is called when the driver is being removed.
688 * This routine stops the adapter and deallocates all the resources
689 * that were allocated for driver operation.
691 * return 0 on success, positive on failure
692 *********************************************************************/
695 ixl_detach(device_t dev)
697 struct ixl_pf *pf = device_get_softc(dev);
698 struct i40e_hw *hw = &pf->hw;
699 struct ixl_vsi *vsi = &pf->vsi;
700 enum i40e_status_code status;
701 #if defined(PCI_IOV) || defined(IXL_IW)
705 INIT_DEBUGOUT("ixl_detach: begin");
707 /* Make sure VLANS are not using driver */
708 if (vsi->ifp->if_vlantrunk != NULL) {
709 device_printf(dev, "Vlan in use, detach first\n");
714 error = pci_iov_detach(dev);
716 device_printf(dev, "SR-IOV in use; detach first.\n");
721 ether_ifdetach(vsi->ifp);
722 if (vsi->ifp->if_drv_flags & IFF_DRV_RUNNING)
725 /* Shutdown LAN HMC */
726 status = i40e_shutdown_lan_hmc(hw);
729 "Shutdown LAN HMC failed with code %d\n", status);
731 /* Teardown LAN queue resources */
732 ixl_teardown_queue_msix(vsi);
733 ixl_free_queue_tqs(vsi);
734 /* Shutdown admin queue */
735 ixl_disable_intr0(hw);
736 ixl_teardown_adminq_msix(pf);
737 ixl_free_adminq_tq(pf);
738 status = i40e_shutdown_adminq(hw);
741 "Shutdown Admin queue failed with code %d\n", status);
743 /* Unregister VLAN events */
744 if (vsi->vlan_attach != NULL)
745 EVENTHANDLER_DEREGISTER(vlan_config, vsi->vlan_attach);
746 if (vsi->vlan_detach != NULL)
747 EVENTHANDLER_DEREGISTER(vlan_unconfig, vsi->vlan_detach);
749 callout_drain(&pf->timer);
752 if (ixl_enable_iwarp && pf->iw_enabled) {
753 error = ixl_iw_pf_detach(pf);
754 if (error == EBUSY) {
755 device_printf(dev, "iwarp in use; stop it first.\n");
762 netmap_detach(vsi->ifp);
763 #endif /* DEV_NETMAP */
764 ixl_pf_qmgr_destroy(&pf->qmgr);
765 ixl_free_pci_resources(pf);
766 bus_generic_detach(dev);
769 IXL_PF_LOCK_DESTROY(pf);
773 /*********************************************************************
775 * Shutdown entry point
777 **********************************************************************/
780 ixl_shutdown(device_t dev)
782 struct ixl_pf *pf = device_get_softc(dev);