Пример #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;
}
Пример #2
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, len;

	switch (cmd) {
		case SIOCSIFFLAGS:
			s = splimp();
			if (ifp->if_flags & IFF_UP) {
				if (!(ifp->if_flags & IFF_RUNNING))
					fwe_init(&fwe->eth_softc);
			} else {
				if (ifp->if_flags & IFF_RUNNING)
					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;
			len = strlen(ifs->ascii);
			if (len < sizeof(ifs->ascii))
				snprintf(ifs->ascii + len,
					sizeof(ifs->ascii) - len,
					"\tch %d dma %d\n",
						fwe->stream_ch, fwe->dma_ch);
			splx(s);
			break;
#if __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 __FreeBSD_version < 500000
		default:
			return (EINVAL);
#endif
	}

	return (0);
}
Пример #3
0
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;
}
Пример #4
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;
}
Пример #5
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);
}