Static void kue_setmulti(struct kue_softc *sc) { struct ifnet *ifp = GET_IFP(sc); struct ether_multi *enm; struct ether_multistep step; int i; DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev), __func__)); if (ifp->if_flags & IFF_PROMISC) { allmulti: ifp->if_flags |= IFF_ALLMULTI; sc->kue_rxfilt |= KUE_RXFILT_ALLMULTI; sc->kue_rxfilt &= ~KUE_RXFILT_MULTICAST; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); return; } sc->kue_rxfilt &= ~KUE_RXFILT_ALLMULTI; i = 0; #if defined (__NetBSD__) ETHER_FIRST_MULTI(step, &sc->kue_ec, enm); #else ETHER_FIRST_MULTI(step, &sc->arpcom, enm); #endif while (enm != NULL) { if (i == KUE_MCFILTCNT(sc) || memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN) != 0) goto allmulti; memcpy(KUE_MCFILT(sc, i), enm->enm_addrlo, ETHER_ADDR_LEN); ETHER_NEXT_MULTI(step, enm); i++; } ifp->if_flags &= ~IFF_ALLMULTI; sc->kue_rxfilt |= KUE_RXFILT_MULTICAST; kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SET_MCAST_FILTERS, i, sc->kue_mcfilters, i * ETHER_ADDR_LEN); kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); }
void kue_setmulti(struct kue_softc *sc) { struct arpcom *ac = &sc->arpcom; struct ifnet *ifp = GET_IFP(sc); struct ether_multi *enm; struct ether_multistep step; int i; DPRINTFN(5,("%s: %s: enter\n", sc->kue_dev.dv_xname, __func__)); if (ifp->if_flags & IFF_PROMISC || ac->ac_multirangecnt > 0) { allmulti: ifp->if_flags |= IFF_ALLMULTI; sc->kue_rxfilt |= KUE_RXFILT_ALLMULTI; sc->kue_rxfilt &= ~KUE_RXFILT_MULTICAST; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); return; } sc->kue_rxfilt &= ~KUE_RXFILT_ALLMULTI; i = 0; ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) { if (i == KUE_MCFILTCNT(sc)) goto allmulti; memcpy(KUE_MCFILT(sc, i), enm->enm_addrlo, ETHER_ADDR_LEN); ETHER_NEXT_MULTI(step, enm); i++; } ifp->if_flags &= ~IFF_ALLMULTI; sc->kue_rxfilt |= KUE_RXFILT_MULTICAST; kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SET_MCAST_FILTERS, i, sc->kue_mcfilters, i * ETHER_ADDR_LEN); kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); }
void kue_init(void *xsc) { struct kue_softc *sc = xsc; struct ifnet *ifp = GET_IFP(sc); int s; u_char *eaddr; DPRINTFN(5,("%s: %s: enter\n", sc->kue_dev.dv_xname,__func__)); if (ifp->if_flags & IFF_RUNNING) return; s = splnet(); eaddr = sc->arpcom.ac_enaddr; /* Set MAC address */ kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SET_MAC, 0, eaddr, ETHER_ADDR_LEN); sc->kue_rxfilt = KUE_RXFILT_UNICAST | KUE_RXFILT_BROADCAST; /* If we want promiscuous mode, set the allframes bit. */ if (ifp->if_flags & IFF_PROMISC) sc->kue_rxfilt |= KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); /* I'm not sure how to tune these. */ #if 0 /* * Leave this one alone for now; setting it * wrong causes lockups on some machines/controllers. */ kue_setword(sc, KUE_CMD_SET_SOFS, 1); #endif kue_setword(sc, KUE_CMD_SET_URB_SIZE, 64); /* Init TX ring. */ if (kue_tx_list_init(sc) == ENOBUFS) { printf("%s: tx list init failed\n", sc->kue_dev.dv_xname); splx(s); return; } /* Init RX ring. */ if (kue_rx_list_init(sc) == ENOBUFS) { printf("%s: rx list init failed\n", sc->kue_dev.dv_xname); splx(s); return; } /* Load the multicast filter. */ kue_setmulti(sc); if (sc->kue_ep[KUE_ENDPT_RX] == NULL) { if (kue_open_pipes(sc)) { splx(s); return; } } ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; splx(s); }
int kue_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { struct kue_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; DPRINTFN(5,("%s: %s: enter\n", sc->kue_dev.dv_xname,__func__)); if (sc->kue_dying) return (EIO); #ifdef DIAGNOSTIC if (!curproc) { printf("%s: no proc!!\n", sc->kue_dev.dv_xname); return EIO; } #endif s = splnet(); switch(command) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; kue_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: arp_ifinit(&sc->arpcom, ifa); break; #endif /* INET */ } break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && !(sc->kue_if_flags & IFF_PROMISC)) { sc->kue_rxfilt |= KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (ifp->if_flags & IFF_RUNNING && !(ifp->if_flags & IFF_PROMISC) && sc->kue_if_flags & IFF_PROMISC) { sc->kue_rxfilt &= ~KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (!(ifp->if_flags & IFF_RUNNING)) kue_init(sc); } else { if (ifp->if_flags & IFF_RUNNING) kue_stop(sc); } sc->kue_if_flags = ifp->if_flags; error = 0; break; default: error = ether_ioctl(ifp, &sc->arpcom, command, data); } if (error == ENETRESET) { if (ifp->if_flags & IFF_RUNNING) kue_setmulti(sc); error = 0; } splx(s); return (error); }
Static int kue_ioctl(struct ifnet *ifp, u_long command, void *data) { struct kue_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev),__func__)); if (sc->kue_dying) return (EIO); #ifdef DIAGNOSTIC if (!curproc) { printf("%s: no proc!!\n", USBDEVNAME(sc->kue_dev)); return EIO; } #endif s = splnet(); switch(command) { case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; kue_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: #if defined(__NetBSD__) arp_ifinit(ifp, ifa); #else arp_ifinit(&sc->arpcom, ifa); #endif break; #endif /* INET */ } break; case SIOCSIFMTU: if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) error = EINVAL; else if ((error = ifioctl_common(ifp, command, data)) == ENETRESET) error = 0; break; case SIOCSIFFLAGS: if ((error = ifioctl_common(ifp, command, data)) != 0) break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && !(sc->kue_if_flags & IFF_PROMISC)) { sc->kue_rxfilt |= KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (ifp->if_flags & IFF_RUNNING && !(ifp->if_flags & IFF_PROMISC) && sc->kue_if_flags & IFF_PROMISC) { sc->kue_rxfilt &= ~KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (!(ifp->if_flags & IFF_RUNNING)) kue_init(sc); } else { if (ifp->if_flags & IFF_RUNNING) kue_stop(sc); } sc->kue_if_flags = ifp->if_flags; error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: kue_setmulti(sc); error = 0; break; default: error = ether_ioctl(ifp, command, data); break; } splx(s); return (error); }
Static int kue_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { struct kue_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev),__func__)); if (sc->kue_dying) return (EIO); #ifdef DIAGNOSTIC if (!curproc) { printf("%s: no proc!!\n", USBDEVNAME(sc->kue_dev)); return EIO; } #endif s = splnet(); switch(command) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; kue_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: #if defined(__NetBSD__) arp_ifinit(ifp, ifa); #else arp_ifinit(&sc->arpcom, ifa); #endif break; #endif /* INET */ #ifdef NS case AF_NS: { struct ns_addr *ina = &IA_SNS(ifa)->sns_addr; if (ns_nullhost(*ina)) ina->x_host = *(union ns_host *) LLADDR(ifp->if_sadl); else memcpy(LLADDR(ifp->if_sadl), ina->x_host.c_host, ifp->if_addrlen); break; } #endif /* NS */ } break; case SIOCSIFMTU: if (ifr->ifr_mtu > ETHERMTU) error = EINVAL; else ifp->if_mtu = ifr->ifr_mtu; break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && !(sc->kue_if_flags & IFF_PROMISC)) { sc->kue_rxfilt |= KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (ifp->if_flags & IFF_RUNNING && !(ifp->if_flags & IFF_PROMISC) && sc->kue_if_flags & IFF_PROMISC) { sc->kue_rxfilt &= ~KUE_RXFILT_PROMISC; kue_setword(sc, KUE_CMD_SET_PKT_FILTER, sc->kue_rxfilt); } else if (!(ifp->if_flags & IFF_RUNNING)) kue_init(sc); } else { if (ifp->if_flags & IFF_RUNNING) kue_stop(sc); } sc->kue_if_flags = ifp->if_flags; error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: kue_setmulti(sc); error = 0; break; default: error = EINVAL; break; } splx(s); return (error); }