FreeBSD/sys/dev/ixl/if_ixl.c
/*********************************************************************
 *  Device removal routine
 *
 *  The detach entry point is called when the driver is being removed.
 *  This routine stops the adapter and deallocates all the resources
 *  that were allocated for driver operation.
 *
 *  return 0 on success, positive on failure
 *********************************************************************/
Device removal routine
The detach entry point is called when the driver is being removed.
This routine stops the adapter and deallocates all the resources
that were allocated for driver operation.

return 0 on success, positive on failure
Device removal routine The detach entry point is called when the driver is being removed . This routine stops the adapter and deallocates all the resources that were allocated for driver operation . return 0 on success positive on failure
static int
ixl_detach(device_t dev)
{
	struct ixl_pf		*pf = device_get_softc(dev);
	struct i40e_hw		*hw = &pf->hw;
	struct ixl_vsi		*vsi = &pf->vsi;
	enum i40e_status_code	status;
#ifdef PCI_IOV
	int			error;
#endif
	INIT_DEBUGOUT("ixl_detach: begin");
	if (vsi->ifp->if_vlantrunk != NULL) {
		device_printf(dev, "Vlan in use, detach first\n");
		return (EBUSY);
	}
#ifdef PCI_IOV
	error = pci_iov_detach(dev);
	if (error != 0) {
		device_printf(dev, "SR-IOV in use; detach first.\n");
		return (error);
	}
#endif
	ether_ifdetach(vsi->ifp);
	if (vsi->ifp->if_drv_flags & IFF_DRV_RUNNING)
		ixl_stop(pf);
	ixl_free_queue_tqs(vsi);
	status = i40e_shutdown_lan_hmc(hw);
	if (status)
		device_printf(dev,
		    "Shutdown LAN HMC failed with code %d\n", status);
	ixl_disable_adminq(hw);
	ixl_free_adminq_tq(pf);
	ixl_teardown_adminq_msix(pf);
	status = i40e_shutdown_adminq(hw);
	if (status)
		device_printf(dev,
		    "Shutdown Admin queue failed with code %d\n", status);
	if (vsi->vlan_attach != NULL)
		EVENTHANDLER_DEREGISTER(vlan_config, vsi->vlan_attach);
	if (vsi->vlan_detach != NULL)
		EVENTHANDLER_DEREGISTER(vlan_unconfig, vsi->vlan_detach);
	callout_drain(&pf->timer);
#ifdef DEV_NETMAP
	netmap_detach(vsi->ifp);
#endif 
	ixl_pf_qmgr_destroy(&pf->qmgr);
	ixl_free_pci_resources(pf);
	bus_generic_detach(dev);
	if_free(vsi->ifp);
	ixl_free_vsi(vsi);
	IXL_PF_LOCK_DESTROY(pf);
	return (0);
}
static int ixl_detach ( device_t dev ) { struct ixl_pf * pf = device_get_softc ( dev ) ; struct i40e_hw * hw = & pf -> hw ; struct ixl_vsi * vsi = & pf -> vsi ; enum i40e_status_code status ; #ifdef PCI_IOV int error ; #endif INIT_DEBUGOUT ( " " ) ; if ( vsi -> ifp -> if_vlantrunk != NULL ) { device_printf ( dev , " \n " ) ; return ( EBUSY ) ; } #ifdef PCI_IOV error = pci_iov_detach ( dev ) ; if ( error != 0 ) { device_printf ( dev , " \n " ) ; return ( error ) ; } #endif ether_ifdetach ( vsi -> ifp ) ; if ( vsi -> ifp -> if_drv_flags & IFF_DRV_RUNNING ) ixl_stop ( pf ) ; ixl_free_queue_tqs ( vsi ) ; status = i40e_shutdown_lan_hmc ( hw ) ; if ( status ) device_printf ( dev , " \n " , status ) ; ixl_disable_adminq ( hw ) ; ixl_free_adminq_tq ( pf ) ; ixl_teardown_adminq_msix ( pf ) ; status = i40e_shutdown_adminq ( hw ) ; if ( status ) device_printf ( dev , " \n " , status ) ; if ( vsi -> vlan_attach != NULL ) EVENTHANDLER_DEREGISTER ( vlan_config , vsi -> vlan_attach ) ; if ( vsi -> vlan_detach != NULL ) EVENTHANDLER_DEREGISTER ( vlan_unconfig , vsi -> vlan_detach ) ; callout_drain ( & pf -> timer ) ; #ifdef DEV_NETMAP netmap_detach ( vsi -> ifp ) ; #endif ixl_pf_qmgr_destroy ( & pf -> qmgr ) ; ixl_free_pci_resources ( pf ) ; bus_generic_detach ( dev ) ; if_free ( vsi -> ifp ) ; ixl_free_vsi ( vsi ) ; IXL_PF_LOCK_DESTROY ( pf ) ; return ( 0 ) ; }
Device removal routine
  The detach entry point is called when the driver is being removed.
Device removal routine The detach entry point is called when the driver is being removed .
/* Make sure VLANS are not using driver */ /* Shutdown LAN HMC */ /* Shutdown admin queue */ /* Unregister VLAN events */ /* DEV_NETMAP */