Esempio n. 1
0
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;
}
Esempio n. 2
0
static int
fwip_detach(device_t dev)
{
	struct fwip_softc *fwip;
	struct ifnet *ifp;
	int s;

	fwip = (struct fwip_softc *)device_get_softc(dev);
	ifp = fwip->fw_softc.fwip_ifp;

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

	s = splimp();

	fwip_stop(fwip);
	firewire_ifdetach(ifp);
	if_free(ifp);
	mtx_destroy(&fwip->mtx);

	splx(s);
	return 0;
}
Esempio n. 3
0
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);
	ether_ifdetach(ifp);
	if_free(ifp);

	splx(s);
	mtx_destroy(&fwe->mtx);
	return 0;
}
Esempio n. 4
0
static int
fwe_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
{
	struct fwe_softc *fwe = ((struct fwe_eth_softc *)ifp->if_softc)->fwe;
	struct ifstat *ifs = NULL;
	int s, error;

	switch (cmd) {
		case SIOCSIFFLAGS:
			s = splimp();
			if (ifp->if_flags & IFF_UP) {
#if defined(__FreeBSD__)
				if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
#else
				if (!(ifp->if_flags & IFF_RUNNING))
#endif
					fwe_init(&fwe->eth_softc);
			} else {
#if defined(__FreeBSD__)
				if (ifp->if_drv_flags & IFF_DRV_RUNNING)
#else
				if (ifp->if_flags & IFF_RUNNING)
#endif
					fwe_stop(fwe);
			}
			/* XXX keep promiscoud mode */
			ifp->if_flags |= IFF_PROMISC;
			splx(s);
			break;
		case SIOCADDMULTI:
		case SIOCDELMULTI:
			break;

		case SIOCGIFSTATUS:
			s = splimp();
			ifs = (struct ifstat *)data;
			snprintf(ifs->ascii, sizeof(ifs->ascii),
			    "\tch %d dma %d\n",	fwe->stream_ch, fwe->dma_ch);
			splx(s);
			break;
		case SIOCSIFCAP:
#ifdef DEVICE_POLLING
		    {
			struct ifreq *ifr = (struct ifreq *) data;
			struct firewire_comm *fc = fwe->fd.fc;

			if (ifr->ifr_reqcap & IFCAP_POLLING &&
			    !(ifp->if_capenable & IFCAP_POLLING)) {
				error = ether_poll_register(fwe_poll, ifp);
				if (error)
					return(error);
				/* Disable interrupts */
				fc->set_intr(fc, 0);
				ifp->if_capenable |= IFCAP_POLLING;
				ifp->if_capenable |= IFCAP_POLLING_NOCOUNT;
				return (error);
			}
			if (!(ifr->ifr_reqcap & IFCAP_POLLING) &&
			    ifp->if_capenable & IFCAP_POLLING) {
				error = ether_poll_deregister(ifp);
				/* Enable interrupts. */
				fc->set_intr(fc, 1);
				ifp->if_capenable &= ~IFCAP_POLLING;
				ifp->if_capenable &= ~IFCAP_POLLING_NOCOUNT;
				return (error);
			}
		    }
#endif /* DEVICE_POLLING */
			break;
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
		default:
#else
		case SIOCSIFADDR:
		case SIOCGIFADDR:
		case SIOCSIFMTU:
#endif
			s = splimp();
			error = ether_ioctl(ifp, cmd, data);
			splx(s);
			return (error);
#if defined(__DragonFly__) || __FreeBSD_version < 500000
		default:
			return (EINVAL);
#endif
	}

	return (0);
}
Esempio n. 5
0
int
smc_detach(device_t dev)
{
	int			type;
	struct smc_softc	*sc;

	sc = device_get_softc(dev);
	SMC_LOCK(sc);
	smc_stop(sc);
	SMC_UNLOCK(sc);

	if (sc->smc_ifp != NULL) {
		ether_ifdetach(sc->smc_ifp);
	}
	
	callout_drain(&sc->smc_watchdog);
	callout_drain(&sc->smc_mii_tick_ch);
	
#ifdef DEVICE_POLLING
	if (sc->smc_ifp->if_capenable & IFCAP_POLLING)
		ether_poll_deregister(sc->smc_ifp);
#endif

	if (sc->smc_ih != NULL)
		bus_teardown_intr(sc->smc_dev, sc->smc_irq, sc->smc_ih);

	if (sc->smc_tq != NULL) {
		taskqueue_drain(sc->smc_tq, &sc->smc_intr);
		taskqueue_drain(sc->smc_tq, &sc->smc_rx);
		taskqueue_drain(sc->smc_tq, &sc->smc_tx);
		taskqueue_free(sc->smc_tq);
		sc->smc_tq = NULL;
	}

	if (sc->smc_ifp != NULL) {
		if_free(sc->smc_ifp);
	}

	if (sc->smc_miibus != NULL) {
		device_delete_child(sc->smc_dev, sc->smc_miibus);
		bus_generic_detach(sc->smc_dev);
	}

	if (sc->smc_reg != NULL) {
		type = SYS_RES_IOPORT;
		if (sc->smc_usemem)
			type = SYS_RES_MEMORY;

		bus_release_resource(sc->smc_dev, type, sc->smc_reg_rid,
		    sc->smc_reg);
	}

	if (sc->smc_irq != NULL)
		bus_release_resource(sc->smc_dev, SYS_RES_IRQ, sc->smc_irq_rid,
		   sc->smc_irq);

	if (mtx_initialized(&sc->smc_mtx))
		mtx_destroy(&sc->smc_mtx);

	return (0);
}
Esempio n. 6
0
int
ether_poll_deregister_drv(if_t ifh)
{
	return (ether_poll_deregister((struct ifnet *)ifh));
}