Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/dev/pci/if_sip.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/dev/pci/if_sip.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.96.6.2 retrieving revision 1.97 diff -u -p -r1.96.6.2 -r1.97 --- src/sys/dev/pci/if_sip.c 2005/03/19 08:35:11 1.96.6.2 +++ src/sys/dev/pci/if_sip.c 2005/01/30 18:56:34 1.97 @@ -1,4 +1,4 @@ -/* $NetBSD: if_sip.c,v 1.96.6.2 2005/03/19 08:35:11 yamt Exp $ */ +/* $NetBSD: if_sip.c,v 1.97 2005/01/30 18:56:34 thorpej Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ * SiS 7016 10/100, National Semiconductor DP83815 10/100, and * National Semiconductor DP83820 10/100/1000 PCI Ethernet * controllers. - * + * * Originally written to support the SiS 900 by Jason R. Thorpe for * Network Computer, Inc. * @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.96.6.2 2005/03/19 08:35:11 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.97 2005/01/30 18:56:34 thorpej Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -309,8 +309,6 @@ struct sip_softc { struct sip_txsq sc_txfreeq; /* free Tx descsofts */ struct sip_txsq sc_txdirtyq; /* dirty Tx descsofts */ - short sc_if_flags; - int sc_rxptr; /* next ready Rx descriptor/descsoft */ #if defined(DP83820) int sc_rxdiscard; @@ -485,7 +483,7 @@ struct sip_variant { void (*sipv_mii_writereg)(struct device *, int, int, int); void (*sipv_mii_statchg)(struct device *); void (*sipv_set_filter)(struct sip_softc *); - void (*sipv_read_macaddr)(struct sip_softc *, + void (*sipv_read_macaddr)(struct sip_softc *, const struct pci_attach_args *, u_int8_t *); }; @@ -981,7 +979,6 @@ SIP_DECL(attach)(struct device *parent, strcpy(ifp->if_xname, sc->sc_dev.dv_xname); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - sc->sc_if_flags = ifp->if_flags; ifp->if_ioctl = SIP_DECL(ioctl); ifp->if_start = SIP_DECL(start); ifp->if_watchdog = SIP_DECL(watchdog); @@ -1222,7 +1219,7 @@ SIP_DECL(start)(struct ifnet *ifp) "DMA segments, dropping...\n", sc->sc_dev.dv_xname); IFQ_DEQUEUE(&ifp->if_snd, m0); - m_freem(m0); + m_freem(m0); continue; } /* @@ -1354,10 +1351,11 @@ SIP_DECL(start)(struct ifnet *ifp) * This apparently has to be on the last descriptor of * the packet. */ - if ((mtag = VLAN_OUTPUT_TAG(&sc->sc_ethercom, m0)) != NULL) { + if (sc->sc_ethercom.ec_nvlans != 0 && + (mtag = m_tag_find(m0, PACKET_TAG_VLAN, NULL)) != NULL) { sc->sc_txdescs[lasttx].sipd_extsts |= htole32(EXTSTS_VPKT | - (VLAN_TAG_VALUE(mtag) & EXTSTS_VTCI)); + (*(u_int *)(mtag + 1) & EXTSTS_VTCI)); } /* @@ -1553,26 +1551,10 @@ SIP_DECL(ioctl)(struct ifnet *ifp, u_lon case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd); break; - case SIOCSIFFLAGS: - /* If the interface is up and running, only modify the receive - * filter when setting promiscuous or debug mode. Otherwise - * fall through to ether_ioctl, which will reset the chip. - */ -#define RESETIGN (IFF_CANTCHANGE|IFF_DEBUG) - if (((ifp->if_flags & (IFF_UP|IFF_RUNNING)) - == (IFF_UP|IFF_RUNNING)) - && ((ifp->if_flags & (~RESETIGN)) - == (sc->sc_if_flags & (~RESETIGN)))) { - /* Set up the receive filter. */ - (*sc->sc_model->sip_variant->sipv_set_filter)(sc); - error = 0; - break; -#undef RESETIGN - } - /* FALLTHROUGH */ + default: error = ether_ioctl(ifp, cmd, data); - if (error == ENETRESET) { + if (error == ENETRESET) { /* * Multicast list has changed; set the hardware filter * accordingly. @@ -1587,7 +1569,6 @@ SIP_DECL(ioctl)(struct ifnet *ifp, u_lon /* Try to get more packets going. */ SIP_DECL(start)(ifp); - sc->sc_if_flags = ifp->if_flags; splx(s); return (error); } @@ -1969,9 +1950,21 @@ SIP_DECL(rxintr)(struct sip_softc *sc) * If VLANs are enabled, VLAN packets have been unwrapped * for us. Associate the tag with the packet. */ - if ((extsts & EXTSTS_VPKT) != 0) { - VLAN_INPUT_TAG(ifp, m, ntohs(extsts & EXTSTS_VTCI), - continue); + if (sc->sc_ethercom.ec_nvlans != 0 && + (extsts & EXTSTS_VPKT) != 0) { + struct m_tag *vtag; + + vtag = m_tag_get(PACKET_TAG_VLAN, sizeof(u_int), + M_NOWAIT); + if (vtag == NULL) { + ifp->if_ierrors++; + printf("%s: unable to allocate VLAN tag\n", + sc->sc_dev.dv_xname); + m_freem(m); + continue; + } + + *(u_int *)(vtag + 1) = ntohs(extsts & EXTSTS_VTCI); } /* @@ -2462,7 +2455,7 @@ SIP_DECL(init)(struct ifnet *ifp) if (ifp->if_capenable & (IFCAP_CSUM_IPv4|IFCAP_CSUM_TCPv4|IFCAP_CSUM_UDPv4)) reg |= VRCR_IPEN; - if (VLAN_ATTACHED(&sc->sc_ethercom)) + if (sc->sc_ethercom.ec_nvlans != 0) reg |= VRCR_VTDEN|VRCR_VTREN; bus_space_write_4(st, sh, SIP_VRCR, reg); @@ -2475,7 +2468,7 @@ SIP_DECL(init)(struct ifnet *ifp) if (ifp->if_capenable & (IFCAP_CSUM_IPv4|IFCAP_CSUM_TCPv4|IFCAP_CSUM_UDPv4)) reg |= VTCR_PPCHK; - if (VLAN_ATTACHED(&sc->sc_ethercom)) + if (sc->sc_ethercom.ec_nvlans != 0) reg |= VTCR_VPPTI; bus_space_write_4(st, sh, SIP_VTCR, reg); @@ -2484,7 +2477,7 @@ SIP_DECL(init)(struct ifnet *ifp) * To understand why we bswap the VLAN Ethertype, see section * 4.2.36 of the DP83820 manual. */ - if (VLAN_ATTACHED(&sc->sc_ethercom)) + if (sc->sc_ethercom.ec_nvlans != 0) bus_space_write_4(st, sh, SIP_VDR, bswap16(ETHERTYPE_VLAN)); #endif /* DP83820 */ @@ -2549,7 +2542,6 @@ SIP_DECL(init)(struct ifnet *ifp) */ ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; - sc->sc_if_flags = ifp->if_flags; out: if (error) @@ -2683,13 +2675,13 @@ SIP_DECL(read_eeprom)(struct sip_softc * bus_space_write_4(st, sh, SIP_EROMAR, reg); delay(4); } - + /* Shift in address. */ for (x = 6; x > 0; x--) { if ((word + i) & (1 << (x - 1))) reg |= EROMAR_EEDI; else - reg &= ~EROMAR_EEDI; + reg &= ~EROMAR_EEDI; bus_space_write_4(st, sh, SIP_EROMAR, reg); bus_space_write_4(st, sh, SIP_EROMAR, reg | EROMAR_EESK); @@ -2730,7 +2722,7 @@ SIP_DECL(add_rxbuf)(struct sip_softc *sc int error; MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == NULL) + if (m == NULL) return (ENOBUFS); MCLGET(m, M_DONTWAIT); @@ -2923,10 +2915,10 @@ SIP_DECL(dp83815_set_filter)(struct sip_ bus_space_tag_t st = sc->sc_st; bus_space_handle_t sh = sc->sc_sh; struct ethercom *ec = &sc->sc_ethercom; - struct ifnet *ifp = &sc->sc_ethercom.ec_if; + struct ifnet *ifp = &sc->sc_ethercom.ec_if; struct ether_multi *enm; - u_int8_t *cp; - struct ether_multistep step; + u_int8_t *cp; + struct ether_multistep step; u_int32_t crc, hash, slot, bit; #ifdef DP83820 #define MCHASH_NWORDS 128 @@ -3047,7 +3039,7 @@ SIP_DECL(dp83815_set_filter)(struct sip_ * Re-enable the receiver filter. */ bus_space_write_4(st, sh, SIP_RFCR, sc->sc_rfcr); -} +} #if defined(DP83820) /*