예제 #1
0
파일: if_fwe.c 프로젝트: ChristosKa/freebsd
static int
fwe_detach(device_t dev)
{
	struct fwe_softc *fwe;
	struct ifnet *ifp;
	int s;

	fwe = device_get_softc(dev);
	ifp = fwe->eth_softc.ifp;

#ifdef DEVICE_POLLING
	if (ifp->if_capenable & IFCAP_POLLING)
		ether_poll_deregister(ifp);
#endif
	s = splimp();

	fwe_stop(fwe);
#if defined(__DragonFly__) || __FreeBSD_version < 500000
	ether_ifdetach(ifp, 1);
#else
	ether_ifdetach(ifp);
	if_free(ifp);
#endif

	splx(s);
	mtx_destroy(&fwe->mtx);
	return 0;
}
예제 #2
0
static int
an_attach_isa(device_t dev)
{
	struct an_softc *sc = device_get_softc(dev);
	struct ifnet *ifp = &sc->arpcom.ac_if;
	int flags = device_get_flags(dev);
	int error;

	an_alloc_port(dev, sc->port_rid, 1);
	an_alloc_irq(dev, sc->irq_rid, 0);

	sc->an_bhandle = rman_get_bushandle(sc->port_res);
	sc->an_btag = rman_get_bustag(sc->port_res);

	error = an_attach(sc, dev, flags);
	if (error)
		goto fail;

	error = bus_setup_intr(dev, sc->irq_res, INTR_MPSAFE,
			       an_intr, sc, &sc->irq_handle, 
			       sc->arpcom.ac_if.if_serializer);
	if (error) {
		ether_ifdetach(&sc->arpcom.ac_if);
		ifmedia_removeall(&sc->an_ifmedia);
		goto fail;
	}

	ifq_set_cpuid(&ifp->if_snd, rman_get_cpuid(sc->irq_res));

	return (0);

fail:
	an_release_resources(dev);
	return(error);
}
예제 #3
0
파일: if_ed.c 프로젝트: ChaosJohn/freebsd
/*
 * Detach the driver from the hardware and other systems in the kernel.
 */
int
ed_detach(device_t dev)
{
	struct ed_softc *sc = device_get_softc(dev);
	struct ifnet *ifp = sc->ifp;

	if (mtx_initialized(ED_MUTEX(sc)))
		ED_ASSERT_UNLOCKED(sc);
	if (ifp) {
		ED_LOCK(sc);
		if (bus_child_present(dev))
			ed_stop(sc);
		ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
		ED_UNLOCK(sc);
		ether_ifdetach(ifp);
		callout_drain(&sc->tick_ch);
	}
	if (sc->irq_res != NULL && sc->irq_handle)
		bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
	ed_release_resources(dev);
	if (sc->miibus)
		device_delete_child(dev, sc->miibus);
	if (mtx_initialized(ED_MUTEX(sc)))
		ED_LOCK_DESTROY(sc);
	bus_generic_detach(dev);
	return (0);
}
예제 #4
0
int
vte_detach(struct device *self, int flags)
{
	struct vte_softc *sc = (struct vte_softc *)self;
	struct ifnet *ifp = &sc->sc_arpcom.ac_if;
	int s;

	s = splnet();
	vte_stop(sc);
	splx(s);

	mii_detach(&sc->sc_miibus, MII_PHY_ANY, MII_OFFSET_ANY);

	/* Delete all remaining media. */
	ifmedia_delete_instance(&sc->sc_miibus.mii_media, IFM_INST_ANY);
	
	ether_ifdetach(ifp);
	if_detach(ifp);
	vte_dma_free(sc);

	if (sc->sc_irq_handle != NULL) {
		pci_intr_disestablish(sc->sc_pct, sc->sc_irq_handle);
		sc->sc_irq_handle = NULL;
	}

	return (0);
}
예제 #5
0
static int
shmif_unclone(struct ifnet *ifp)
{
	struct shmif_sc *sc = ifp->if_softc;

	shmif_stop(ifp, 1);
	if_down(ifp);
	finibackend(sc);

	mutex_enter(&sc->sc_mtx);
	sc->sc_dying = true;
	cv_broadcast(&sc->sc_cv);
	mutex_exit(&sc->sc_mtx);

	if (sc->sc_rcvl)
		kthread_join(sc->sc_rcvl);
	sc->sc_rcvl = NULL;

	vmem_xfree(shmif_units, sc->sc_unit+1, 1);

	ether_ifdetach(ifp);
	if_detach(ifp);

	cv_destroy(&sc->sc_cv);
	mutex_destroy(&sc->sc_mtx);

	kmem_free(sc, sizeof(*sc));

	return 0;
}
예제 #6
0
void
ipfw_log_bpf(int onoff)
{
	struct ifnet *ifp;

	if (onoff) {
		if (log_if)
			return;
		ifp = if_alloc(IFT_ETHER);
		if (ifp == NULL)
			return;
		if_initname(ifp, "ipfw", 0);
		ifp->if_mtu = 65536;
		ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
		ifp->if_init = (void *)log_dummy;
		ifp->if_ioctl = log_dummy;
		ifp->if_start = (void *)log_dummy;
		ifp->if_output = (void *)log_dummy;
		ifp->if_addrlen = 6;
		ifp->if_hdrlen = 14;
		if_attach(ifp);
		ifp->if_baudrate = IF_Mbps(10);
		bpfattach(ifp, DLT_EN10MB, 14);
		log_if = ifp;
	} else {
		if (log_if) {
			ether_ifdetach(log_if);
			if_free(log_if);
		}
		log_if = NULL;
	}
}
예제 #7
0
/*
 * Cardbus detach function: deallocate all resources
 */
int
re_cardbus_detach(struct device *self, int flags)
{
	struct re_cardbus_softc *csc = (void *)self;
	struct rl_softc *sc = &csc->sc_rl;
	struct cardbus_devfunc *ct = csc->ct;
	struct ifnet *ifp = &sc->sc_arpcom.ac_if;

	/* Remove timeout handler */
	timeout_del(&sc->timer_handle);

	/* Detach PHY */
	if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
		mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);

	/* Delete media stuff */
	ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
	ether_ifdetach(ifp);
	if_detach(ifp);

	/* Disable interrupts */
	if (csc->sc_ih != NULL)
		cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih);

	/* Free cardbus resources */
	Cardbus_mapreg_unmap(ct, csc->sc_bar_reg, sc->rl_btag, sc->rl_bhandle,
	    csc->sc_mapsize);

	return (0);
}
예제 #8
0
파일: if_re_pci.c 프로젝트: sofuture/bitrig
int
re_pci_detach(struct device *self, int flags)
{
	struct re_pci_softc	*psc = (struct re_pci_softc *)self;
	struct rl_softc		*sc = &psc->sc_rl;
	struct ifnet		*ifp = &sc->sc_arpcom.ac_if;

	/* Remove timeout handler */
	timeout_del(&sc->timer_handle);

	/* Detach PHY */
	if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
		mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);

	/* Delete media stuff */
	ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
	ether_ifdetach(ifp);
	if_detach(ifp);

	/* Disable interrupts */
	if (psc->sc_ih != NULL)
		pci_intr_disestablish(psc->sc_pc, psc->sc_ih);

	/* Free pci resources */
	bus_space_unmap(sc->rl_btag, sc->rl_bhandle, psc->sc_iosize);

	return (0);
}
예제 #9
0
static int
txp_detach(device_t dev)
{
	struct txp_softc *sc = device_get_softc(dev);
	struct ifnet *ifp = &sc->sc_arpcom.ac_if;
	int i;

	lwkt_serialize_enter(ifp->if_serializer);

	txp_stop(sc);
	txp_shutdown(dev);
	bus_teardown_intr(dev, sc->sc_irq, sc->sc_intrhand);

	lwkt_serialize_exit(ifp->if_serializer);

	ifmedia_removeall(&sc->sc_ifmedia);
	ether_ifdetach(ifp);

	for (i = 0; i < RXBUF_ENTRIES; i++)
		kfree(sc->sc_rxbufs[i].rb_sd, M_DEVBUF);

	txp_release_resources(dev);

	return(0);
}
예제 #10
0
/*
 * Dtor.
 */
static void
vether_clone_destroy(struct ifnet *ifp)
{
	struct vether_softc *sc;	
	
	sc = ifp->if_softc;	
 
	VETHER_LOCK(sc);
	vether_stop(ifp, 1);
	
	ifp->if_flags &= ~IFF_UP;	
	VETHER_UNLOCK(sc);		

	mtx_lock(&vether_list_mtx);
	LIST_REMOVE(sc, vether_list);
	mtx_unlock(&vether_list_mtx);	
/*
 * Inverse element of ether_ifattach.
 */
	ether_ifdetach(ifp);
/*
 * Release bound ressources.
 */	
	if_free(ifp);
	
	VETHER_LOCK_DESTROY(sc);
	free(sc, M_DEVBUF);
}
예제 #11
0
static int
if_netmap_setup_interface(struct if_netmap_softc *sc)
{
	struct ifnet *ifp;

	ifp = sc->ifp = if_alloc(IFT_ETHER);

	ifp->if_init =  if_netmap_init;
	ifp->if_softc = sc;

	if_initname(ifp, sc->cfg->name, IF_DUNIT_NONE);
	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
	ifp->if_ioctl = if_netmap_ioctl;
	ifp->if_start = if_netmap_start;

	/* XXX what values? */
	IFQ_SET_MAXLEN(&ifp->if_snd, if_netmap_txslots(sc->nm_host_ctx));
	ifp->if_snd.ifq_drv_maxlen = if_netmap_txslots(sc->nm_host_ctx);

	IFQ_SET_READY(&ifp->if_snd);

	ifp->if_fib = sc->cfg->cdom;

	ether_ifattach(ifp, sc->addr);
	ifp->if_capabilities = ifp->if_capenable = IFCAP_HWSTATS;


	mtx_init(&sc->tx_lock, "txlk", NULL, MTX_DEF);
	cv_init(&sc->tx_cv, "txcv");

	if (kthread_add(if_netmap_send, sc, NULL, &sc->tx_thread.thr, 0, 0, "nm_tx: %s", ifp->if_xname)) {
		printf("Could not start transmit thread for %s (%s)\n", ifp->if_xname, sc->host_ifname);
		ether_ifdetach(ifp);
		if_free(ifp);
		return (1);
	}


	if (kthread_add(if_netmap_receive, sc, NULL, &sc->rx_thread.thr, 0, 0, "nm_rx: %s", ifp->if_xname)) {
		printf("Could not start receive thread for %s (%s)\n", ifp->if_xname, sc->host_ifname);
		ether_ifdetach(ifp);
		if_free(ifp);
		return (1);
	}

	return (0);
}
예제 #12
0
/* 
 * Tear down vap state and reclaim the ifnet.
 * The driver is assumed to have prepared for
 * this; e.g. by turning off interrupts for the
 * underlying device.
 */
void
ieee80211_vap_detach(struct ieee80211vap *vap)
{
	struct ieee80211com *ic = vap->iv_ic;
	struct ifnet *ifp = vap->iv_ifp;

	IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s parent %s\n",
	    __func__, ieee80211_opmode_name[vap->iv_opmode],
	    ic->ic_ifp->if_xname);

	/* NB: bpfdetach is called by ether_ifdetach and claims all taps */
	ether_ifdetach(ifp);

	ieee80211_stop(vap);

	/*
	 * Flush any deferred vap tasks.
	 */
	ieee80211_draintask(ic, &vap->iv_nstate_task);
	ieee80211_draintask(ic, &vap->iv_swbmiss_task);

	/* XXX band-aid until ifnet handles this for us */
	taskqueue_drain(taskqueue_swi, &ifp->if_linktask);

	IEEE80211_LOCK(ic);
	KASSERT(vap->iv_state == IEEE80211_S_INIT , ("vap still running"));
	TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next);
	ieee80211_syncflag_locked(ic, IEEE80211_F_WME);
#ifdef IEEE80211_SUPPORT_SUPERG
	ieee80211_syncflag_locked(ic, IEEE80211_F_TURBOP);
#endif
	ieee80211_syncflag_locked(ic, IEEE80211_F_PCF);
	ieee80211_syncflag_locked(ic, IEEE80211_F_BURST);
	ieee80211_syncflag_ht_locked(ic, IEEE80211_FHT_HT);
	ieee80211_syncflag_ht_locked(ic, IEEE80211_FHT_USEHT40);
	/* NB: this handles the bpfdetach done below */
	ieee80211_syncflag_ext_locked(ic, IEEE80211_FEXT_BPF);
	ieee80211_syncifflag_locked(ic, IFF_PROMISC);
	ieee80211_syncifflag_locked(ic, IFF_ALLMULTI);
	IEEE80211_UNLOCK(ic);

	ifmedia_removeall(&vap->iv_media);

	ieee80211_radiotap_vdetach(vap);
	ieee80211_regdomain_vdetach(vap);
	ieee80211_scan_vdetach(vap);
#ifdef IEEE80211_SUPPORT_SUPERG
	ieee80211_superg_vdetach(vap);
#endif
	ieee80211_ht_vdetach(vap);
	/* NB: must be before ieee80211_node_vdetach */
	ieee80211_proto_vdetach(vap);
	ieee80211_crypto_vdetach(vap);
	ieee80211_power_vdetach(vap);
	ieee80211_node_vdetach(vap);
	ieee80211_sysctl_vdetach(vap);

	if_free(ifp);
}
예제 #13
0
파일: if_snc.c 프로젝트: coyizumi/cs111
int
snc_attach(device_t dev)
{
	struct snc_softc *sc = device_get_softc(dev);
	u_int8_t myea[ETHER_ADDR_LEN];
	int error;

	if (snc_nec16_register_irq(sc, rman_get_start(sc->irq)) == 0 || 
	    snc_nec16_register_mem(sc, rman_get_start(sc->iomem)) == 0) {
		snc_release_resources(dev);
		return(ENOENT);
	}

	snc_nec16_get_enaddr(sc->sc_iot, sc->sc_ioh, myea);
	device_printf(dev, "%s Ethernet\n", snc_nec16_detect_type(myea));

	sc->sc_dev = dev;

	sc->sncr_dcr = DCR_SYNC | DCR_WAIT0 |
            DCR_DMABLOCK | DCR_RFT16 | DCR_TFT28;
	sc->sncr_dcr2 = 0;	/* XXX */
	sc->bitmode = 0;	/* 16 bit card */

	sc->sc_nic_put = snc_nec16_nic_put;
	sc->sc_nic_get = snc_nec16_nic_get;
	sc->sc_writetodesc = snc_nec16_writetodesc;
	sc->sc_readfromdesc = snc_nec16_readfromdesc;
	sc->sc_copytobuf = snc_nec16_copytobuf;
	sc->sc_copyfrombuf = snc_nec16_copyfrombuf;
	sc->sc_zerobuf = snc_nec16_zerobuf;

	/* sncsetup returns 1 if something fails */
	if (sncsetup(sc, myea)) {
		snc_release_resources(dev);
		return(ENOENT);
	}

	mtx_init(&sc->sc_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK,
	    MTX_DEF);
	callout_init_mtx(&sc->sc_timer, &sc->sc_lock, 0);
	error = sncconfig(sc, NULL, 0, 0, myea);
	if (error) {
		snc_release_resources(dev);
		mtx_destroy(&sc->sc_lock);
		return (error);
	}

	error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
			       NULL, sncintr, sc, &sc->irq_handle);
	if (error) {
		printf("snc_isa_attach: bus_setup_intr() failed\n");
		ether_ifdetach(sc->sc_ifp);		
		snc_release_resources(dev);
		mtx_destroy(&sc->sc_lock);
		return (error);
	}

	return 0;
}
예제 #14
0
파일: if_fwe.c 프로젝트: MarginC/kame
static int
fwe_detach(device_t dev)
{
	struct fwe_softc *fwe;
	int s;

	fwe = (struct fwe_softc *)device_get_softc(dev);
	s = splimp();

	fwe_stop(fwe);
#if __FreeBSD_version >= 500000
	ether_ifdetach(&fwe->fwe_if);
#else
	ether_ifdetach(&fwe->fwe_if, 1);
#endif

	splx(s);
	return 0;
}
예제 #15
0
/* detach */
int
url_detach(device_t self, int flags)
{
	struct url_softc *sc = device_private(self);
	struct ifnet *ifp = GET_IFP(sc);
	int s;

	DPRINTF(("%s: %s: enter\n", device_xname(sc->sc_dev), __func__));

	/* Detached before attached finished */
	if (!sc->sc_attached)
		return (0);

	callout_stop(&sc->sc_stat_ch);

	/* Remove any pending tasks */
	usb_rem_task(sc->sc_udev, &sc->sc_tick_task);
	usb_rem_task(sc->sc_udev, &sc->sc_stop_task);

	s = splusb();

	if (--sc->sc_refcnt >= 0) {
		/* Wait for processes to go away */
		usb_detach_waitold(sc->sc_dev);
	}

	if (ifp->if_flags & IFF_RUNNING)
		url_stop(GET_IFP(sc), 1);

	rnd_detach_source(&sc->rnd_source);
	mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
	ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
	ether_ifdetach(ifp);
	if_detach(ifp);

#ifdef DIAGNOSTIC
	if (sc->sc_pipe_tx != NULL)
		aprint_debug_dev(self, "detach has active tx endpoint.\n");
	if (sc->sc_pipe_rx != NULL)
		aprint_debug_dev(self, "detach has active rx endpoint.\n");
	if (sc->sc_pipe_intr != NULL)
		aprint_debug_dev(self, "detach has active intr endpoint.\n");
#endif

	sc->sc_attached = 0;

	splx(s);

	rw_destroy(&sc->sc_mii_rwlock);
	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
			   sc->sc_dev);

	return (0);
}
예제 #16
0
static int
kr_detach(device_t dev)
{
	struct kr_softc		*sc = device_get_softc(dev);
	struct ifnet		*ifp = sc->kr_ifp;

	KASSERT(mtx_initialized(&sc->kr_mtx), ("vr mutex not initialized"));

	/* These should only be active if attach succeeded */
	if (device_is_attached(dev)) {
		KR_LOCK(sc);
		sc->kr_detach = 1;
		kr_stop(sc);
		KR_UNLOCK(sc);
		taskqueue_drain(taskqueue_swi, &sc->kr_link_task);
		ether_ifdetach(ifp);
	}
	if (sc->kr_miibus)
		device_delete_child(dev, sc->kr_miibus);
	bus_generic_detach(dev);

	if (sc->kr_rx_intrhand)
		bus_teardown_intr(dev, sc->kr_rx_irq, sc->kr_rx_intrhand);
	if (sc->kr_rx_irq)
		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->kr_rx_irq);
	if (sc->kr_tx_intrhand)
		bus_teardown_intr(dev, sc->kr_tx_irq, sc->kr_tx_intrhand);
	if (sc->kr_tx_irq)
		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->kr_tx_irq);
	if (sc->kr_rx_und_intrhand)
		bus_teardown_intr(dev, sc->kr_rx_und_irq, 
		    sc->kr_rx_und_intrhand);
	if (sc->kr_rx_und_irq)
		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->kr_rx_und_irq);
	if (sc->kr_tx_ovr_intrhand)
		bus_teardown_intr(dev, sc->kr_tx_ovr_irq, 
		    sc->kr_tx_ovr_intrhand);
	if (sc->kr_tx_ovr_irq)
		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->kr_tx_ovr_irq);

	if (sc->kr_res)
		bus_release_resource(dev, SYS_RES_MEMORY, sc->kr_rid, 
		    sc->kr_res);

	if (ifp)
		if_free(ifp);

	kr_dma_free(sc);

	mtx_destroy(&sc->kr_mtx);

	return (0);

}
예제 #17
0
파일: ieee80211.c 프로젝트: sofuture/bitrig
void
ieee80211_ifdetach(struct ifnet *ifp)
{
	struct ieee80211com *ic = (void *)ifp;

	ieee80211_proto_detach(ifp);
	ieee80211_crypto_detach(ifp);
	ieee80211_node_detach(ifp);
	LIST_REMOVE(ic, ic_list);
	ifmedia_delete_instance(&ic->ic_media, IFM_INST_ANY);
	ether_ifdetach(ifp);
}
예제 #18
0
파일: if_fe_pccard.c 프로젝트: MarginC/kame
/*
 *	feunload - unload the driver and clear the table.
 *	XXX TODO:
 *	This is usually called when the card is ejected, but
 *	can be caused by a modunload of a controller driver.
 *	The idea is to reset the driver's view of the device
 *	and ensure that any driver entry points such as
 *	read and write do not hang.
 */
static int
fe_pccard_detach(device_t dev)
{
	struct fe_softc *sc = device_get_softc(dev);
	struct ifnet *ifp = &sc->arpcom.ac_if;

	fe_stop(sc);
	ether_ifdetach(ifp);
	bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
	fe_release_resource(dev);

	return 0;
}
예제 #19
0
파일: sfxge.c 프로젝트: AhmadTux/freebsd
static void
sfxge_ifnet_fini(struct ifnet *ifp)
{
	struct sfxge_softc *sc = ifp->if_softc;

	sx_xlock(&sc->softc_lock);
	sfxge_stop(sc);
	sx_xunlock(&sc->softc_lock);

	ifmedia_removeall(&sc->media);
	ether_ifdetach(ifp);
	if_free(ifp);
}
예제 #20
0
void
iee_detach(struct iee_softc *sc, int flags)
{
	struct ifnet *ifp = &sc->sc_ethercom.ec_if;

	if ((ifp->if_flags & IFF_RUNNING) != 0)
		iee_stop(ifp, 1);
	ether_ifdetach(ifp);
	if_detach(ifp);
	bus_dmamap_unload(sc->sc_dmat, sc->sc_shmem_map);
	bus_dmamap_destroy(sc->sc_dmat, sc->sc_shmem_map);
	bus_dmamem_unmap(sc->sc_dmat, sc->sc_shmem_addr, sc->sc_shmem_sz);
	bus_dmamem_free(sc->sc_dmat, &sc->sc_dma_segs, sc->sc_dma_rsegs);
}
예제 #21
0
static int
ex_pccard_detach(device_t dev)
{
	struct ex_softc		*sc = device_get_softc(dev);
	struct ifnet		*ifp = &sc->arpcom.ac_if;

	lwkt_serialize_enter(ifp->if_serializer);
	ex_stop(sc);
	ifp->if_flags &= ~IFF_RUNNING;
	lwkt_serialize_exit(ifp->if_serializer);

	ether_ifdetach(ifp);
	ex_release_resources(dev);
	return (0);
}
예제 #22
0
static int
sn_pccard_detach(device_t dev)
{
	struct sn_softc *sc = device_get_softc(dev);
	struct ifnet *ifp = &sc->arpcom.ac_if;

	lwkt_serialize_enter(ifp->if_serializer);
	ifp->if_flags &= ~IFF_RUNNING;
	bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
	lwkt_serialize_enter(ifp->if_serializer);

	ether_ifdetach(&sc->arpcom.ac_if);
	sn_deactivate(dev);

	return 0;
}
예제 #23
0
/*
 * Destroy an interface instance.
 */
static void
edsc_clone_destroy(struct ifnet *ifp)
{
	struct edsc_softc	*sc = ifp->if_softc;

	/*
	 * Detach from the network interface framework.
	 */
	ether_ifdetach(ifp);

	/*
	 * Free memory occupied by ifnet and softc.
	 */
	if_free(ifp);
	free(sc, M_EDSC);
}
예제 #24
0
static int
xennet_xenbus_detach(device_t self, int flags)
{
	struct xennet_xenbus_softc *sc = device_private(self);
	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
	int s0, s1;
	RING_IDX i;

	DPRINTF(("%s: xennet_xenbus_detach\n", device_xname(self)));
	s0 = splnet();
	xennet_stop(ifp, 1);
	/* wait for pending TX to complete, and collect pending RX packets */
	xennet_handler(sc);
	while (sc->sc_tx_ring.sring->rsp_prod != sc->sc_tx_ring.rsp_cons) {
		tsleep(xennet_xenbus_detach, PRIBIO, "xnet_detach", hz/2);
		xennet_handler(sc);
	}
	xennet_free_rx_buffer(sc);

	s1 = splvm();
	for (i = 0; i < NET_RX_RING_SIZE; i++) {
		struct xennet_rxreq *rxreq = &sc->sc_rxreqs[i];
		uvm_km_free(kernel_map, rxreq->rxreq_va, PAGE_SIZE,
		    UVM_KMF_WIRED);
	}
	splx(s1);
		
	ether_ifdetach(ifp);
	if_detach(ifp);
	while (xengnt_status(sc->sc_tx_ring_gntref)) {
		tsleep(xennet_xenbus_detach, PRIBIO, "xnet_txref", hz/2);
	}
	xengnt_revoke_access(sc->sc_tx_ring_gntref);
	uvm_km_free(kernel_map, (vaddr_t)sc->sc_tx_ring.sring, PAGE_SIZE,
	    UVM_KMF_WIRED);
	while (xengnt_status(sc->sc_rx_ring_gntref)) {
		tsleep(xennet_xenbus_detach, PRIBIO, "xnet_rxref", hz/2);
	}
	xengnt_revoke_access(sc->sc_rx_ring_gntref);
	uvm_km_free(kernel_map, (vaddr_t)sc->sc_rx_ring.sring, PAGE_SIZE,
	    UVM_KMF_WIRED);
	softint_disestablish(sc->sc_softintr);
	event_remove_handler(sc->sc_evtchn, &xennet_handler, sc);
	splx(s0);
	DPRINTF(("%s: xennet_xenbus_detach done\n", device_xname(self)));
	return 0;
}
예제 #25
0
/*
 * Device detached.
 */
static int
lgue_detach(device_t dev)
{
	struct lgue_softc *sc;
	struct ifnet *ifp;

	sc = device_get_softc(dev);
	ifp = &sc->lgue_arpcom.ac_if;
	ether_ifdetach(ifp);

	if (sc->lgue_ep[LGUE_ENDPT_TX] != NULL)
		usbd_abort_pipe(sc->lgue_ep[LGUE_ENDPT_TX]);
	if (sc->lgue_ep[LGUE_ENDPT_RX] != NULL)
		usbd_abort_pipe(sc->lgue_ep[LGUE_ENDPT_RX]);
	if (sc->lgue_ep[LGUE_ENDPT_INTR] != NULL)
		usbd_abort_pipe(sc->lgue_ep[LGUE_ENDPT_INTR]);
	return(0);
}
예제 #26
0
/*
 *	feunload - unload the driver and clear the table.
 */
static int
fe_pccard_detach(device_t dev)
{
    struct fe_softc *sc = device_get_softc(dev);
    struct ifnet *ifp = sc->ifp;

    FE_LOCK(sc);
    fe_stop(sc);
    FE_UNLOCK(sc);
    callout_drain(&sc->timer);
    ether_ifdetach(ifp);
    bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
    if_free(ifp);
    fe_release_resource(dev);
    mtx_destroy(&sc->lock);

    return 0;
}
예제 #27
0
파일: ieee80211.c 프로젝트: MarginC/kame
void
ieee80211_ifdetach(struct ifnet *ifp)
{
	struct ieee80211com *ic = (void *)ifp;

	ieee80211_proto_detach(ifp);
	ieee80211_crypto_detach(ifp);
	ieee80211_node_detach(ifp);
#ifdef __FreeBSD__
	ifmedia_removeall(&ic->ic_media);
#else
        ifmedia_delete_instance(&ic->ic_media, IFM_INST_ANY);
#endif
#if NBPFILTER > 0
	bpfdetach(ifp);
#endif
	ether_ifdetach(ifp);
}
void
uether_ifdetach(struct usb_ether *ue)
{
	struct ifnet *ifp;

	/* wait for any post attach or other command to complete */
	usb_proc_drain(&ue->ue_tq);

	/* read "ifnet" pointer after taskqueue drain */
	ifp = ue->ue_ifp;

	if (ifp != NULL) {

		/* we are not running any more */
		UE_LOCK(ue);
		ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
		UE_UNLOCK(ue);

		/* drain any callouts */
		usb_callout_drain(&ue->ue_watchdog);

		/* detach miibus */
		if (ue->ue_miibus != NULL) {
			mtx_lock(&Giant);	/* device_xxx() depends on this */
			device_delete_child(ue->ue_dev, ue->ue_miibus);
			mtx_unlock(&Giant);
		}

		/* detach ethernet */
		ether_ifdetach(ifp);

		/* free interface instance */
		if_free(ifp);

		/* free sysctl */
		sysctl_ctx_free(&ue->ue_sysctl_ctx);

		/* free unit */
		free_unr(ueunit, ue->ue_unit);
	}

	/* free taskqueue, if any */
	usb_proc_free(&ue->ue_tq);
}
예제 #29
0
static int
ntb_teardown_interface()
{

	if (net_softc.qp != NULL)
		ntb_transport_link_down(net_softc.qp);

	if (net_softc.ifp != NULL) {
		ether_ifdetach(net_softc.ifp);
		if_free(net_softc.ifp);
	}

	if (net_softc.qp != NULL) {
		ntb_transport_free_queue(net_softc.qp);
		ntb_transport_free(&net_softc);
	}

	return (0);
}
예제 #30
0
void
ieee80211_ifdetach(struct ieee80211com *ic)
{
	struct ifnet *ifp = ic->ic_ifp;

	ieee80211_remove_vap(ic);

	ieee80211_sysctl_detach(ic);
	ieee80211_proto_detach(ic);
	ieee80211_crypto_detach(ic);
	ieee80211_node_detach(ic);
	LIST_REMOVE(ic, ic_list);
	ifmedia_delete_instance(&ic->ic_media, IFM_INST_ANY);

	IEEE80211_BEACON_LOCK_DESTROY(ic);

	bpf_detach(ifp);
	ether_ifdetach(ifp);
}