FreeBSD/sys/dev/ixl/if_ixlv.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
ixlv_detach(device_t dev)
{
	struct ixlv_sc	*sc = device_get_softc(dev);
	struct ixl_vsi 	*vsi = &sc->vsi;
	INIT_DBG_DEV(dev, "begin");
	if (vsi->ifp->if_vlantrunk != NULL) {
		if_printf(vsi->ifp, "Vlan in use, detach first\n");
		INIT_DBG_DEV(dev, "end");
		return (EBUSY);
	}
	ether_ifdetach(vsi->ifp);
	if (vsi->ifp->if_drv_flags & IFF_DRV_RUNNING) {
		mtx_lock(&sc->mtx);	
		ixlv_stop(sc);
		mtx_unlock(&sc->mtx);	
	}
	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(&sc->vc_mgr.callout);
	i40e_shutdown_adminq(&sc->hw);
	taskqueue_free(sc->tq);
	if_free(vsi->ifp);
	free(sc->vf_res, M_DEVBUF);
	ixlv_free_pci_resources(sc);
	ixlv_free_queues(vsi);
	mtx_destroy(&sc->mtx);
	ixlv_free_filters(sc);
	bus_generic_detach(dev);
	INIT_DBG_DEV(dev, "end");
	return (0);
}
static int ixlv_detach ( device_t dev ) { struct ixlv_sc * sc = device_get_softc ( dev ) ; struct ixl_vsi * vsi = & sc -> vsi ; INIT_DBG_DEV ( dev , " " ) ; if ( vsi -> ifp -> if_vlantrunk != NULL ) { if_printf ( vsi -> ifp , " \n " ) ; INIT_DBG_DEV ( dev , " " ) ; return ( EBUSY ) ; } ether_ifdetach ( vsi -> ifp ) ; if ( vsi -> ifp -> if_drv_flags & IFF_DRV_RUNNING ) { mtx_lock ( & sc -> mtx ) ; ixlv_stop ( sc ) ; mtx_unlock ( & sc -> mtx ) ; } 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 ( & sc -> vc_mgr . callout ) ; i40e_shutdown_adminq ( & sc -> hw ) ; taskqueue_free ( sc -> tq ) ; if_free ( vsi -> ifp ) ; free ( sc -> vf_res , M_DEVBUF ) ; ixlv_free_pci_resources ( sc ) ; ixlv_free_queues ( vsi ) ; mtx_destroy ( & sc -> mtx ) ; ixlv_free_filters ( sc ) ; bus_generic_detach ( dev ) ; INIT_DBG_DEV ( dev , " " ) ; 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 */ /* Stop driver */ /* Unregister VLAN events */ /* Drain VC mgr */