On 01/12/13 8:45 PM, Brad Smith wrote:
Here is a diff for the sf(4) Starfire driver to clean up and update the
receive filter / ioctl handling code to be in line with the other drivers.

Oops. Should have said..

Here is a diff for the nge(4) DP83820 / DP83821 driver to clean up and
update the receive filter / ioctl handling code to be in line with the
other drivers.

Anyone with hw and able to test? OK?


Index: if_nge.c
===================================================================
RCS file: /home/cvs/src/sys/dev/pci/if_nge.c,v
retrieving revision 1.78
diff -u -p -r1.78 if_nge.c
--- if_nge.c    26 Nov 2013 09:50:33 -0000      1.78
+++ if_nge.c    2 Dec 2013 01:42:46 -0000
@@ -173,7 +173,7 @@ int nge_miibus_readreg(struct device *,
  void nge_miibus_writereg(struct device *, int, int, int);
  void nge_miibus_statchg(struct device *);

-void nge_setmulti(struct nge_softc *);
+void nge_iff(struct nge_softc *);
  void nge_reset(struct nge_softc *);
  int nge_list_rx_init(struct nge_softc *);
  int nge_list_tx_init(struct nge_softc *);
@@ -577,7 +577,7 @@ nge_miibus_statchg(struct device *dev)
  }

  void
-nge_setmulti(struct nge_softc *sc)
+nge_iff(struct nge_softc *sc)
  {
        struct arpcom           *ac = &sc->arpcom;
        struct ifnet            *ifp = &ac->ac_if;
@@ -1491,7 +1491,6 @@ nge_intr(void *arg)

                if (status & NGE_ISR_SYSERR) {
                        nge_reset(sc);
-                       ifp->if_flags &= ~IFF_RUNNING;
                        nge_init(sc);
                }

@@ -1650,9 +1649,6 @@ nge_init(void *xsc)
        u_int32_t               txcfg, rxcfg;
        int                     s, media;

-       if (ifp->if_flags & IFF_RUNNING)
-               return;
-
        s = splnet();

        /*
@@ -1688,32 +1684,9 @@ nge_init(void *xsc)
        nge_list_tx_init(sc);

        /*
-        * For the NatSemi chip, we have to explicitly enable the
-        * reception of ARP frames, as well as turn on the 'perfect
-        * match' filter where we store the station address, otherwise
-        * we won't receive unicasts meant for this host.
-        */
-       NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ARP);
-       NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_PERFECT);
-
-        /* If we want promiscuous mode, set the allframes bit. */
-       if (ifp->if_flags & IFF_PROMISC)
-               NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ALLPHYS);
-       else
-               NGE_CLRBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ALLPHYS);
-
-       /*
-        * Set the capture broadcast bit to capture broadcast frames.
-        */
-       if (ifp->if_flags & IFF_BROADCAST)
-               NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_BROAD);
-       else
-               NGE_CLRBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_BROAD);
-
-       /*
-        * Load the multicast filter.
+        * Program promiscuous mode and multicast filters.
         */
-       nge_setmulti(sc);
+       nge_iff(sc);

        /* Turn the receive filter on */
        NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ENABLE);
@@ -1969,7 +1942,6 @@ nge_ioctl(struct ifnet *ifp, u_long comm
        struct nge_softc        *sc = ifp->if_softc;
        struct ifaddr           *ifa = (struct ifaddr *) data;
        struct ifreq            *ifr = (struct ifreq *) data;
-       struct mii_data         *mii;
        int                     s, error = 0;

        s = splnet();
@@ -1977,45 +1949,25 @@ nge_ioctl(struct ifnet *ifp, u_long comm
        switch(command) {
        case SIOCSIFADDR:
                ifp->if_flags |= IFF_UP;
-               switch (ifa->ifa_addr->sa_family) {
-#ifdef INET
-               case AF_INET:
+               if (!(ifp->if_flags & IFF_RUNNING))
                        nge_init(sc);
+
+#ifdef INET
+               if (ifa->ifa_addr->sa_family == AF_INET)
                        arp_ifinit(&sc->arpcom, ifa);
-                       break;
-#endif /* INET */
-               default:
-                       nge_init(sc);
-                       break;
-                }
+#endif
                break;

        case SIOCSIFFLAGS:
                if (ifp->if_flags & IFF_UP) {
-                       if (ifp->if_flags & IFF_RUNNING &&
-                           ifp->if_flags & IFF_PROMISC &&
-                           !(sc->nge_if_flags & IFF_PROMISC)) {
-                               NGE_SETBIT(sc, NGE_RXFILT_CTL,
-                                   NGE_RXFILTCTL_ALLPHYS|
-                                   NGE_RXFILTCTL_ALLMULTI);
-                       } else if (ifp->if_flags & IFF_RUNNING &&
-                           !(ifp->if_flags & IFF_PROMISC) &&
-                           sc->nge_if_flags & IFF_PROMISC) {
-                               NGE_CLRBIT(sc, NGE_RXFILT_CTL,
-                                   NGE_RXFILTCTL_ALLPHYS);
-                               if (!(ifp->if_flags & IFF_ALLMULTI))
-                                       NGE_CLRBIT(sc, NGE_RXFILT_CTL,
-                                           NGE_RXFILTCTL_ALLMULTI);
-                       } else {
-                               ifp->if_flags &= ~IFF_RUNNING;
+                       if (ifp->if_flags & IFF_RUNNING)
+                               error = ENETRESET;
+                       else
                                nge_init(sc);
-                       }
                } else {
                        if (ifp->if_flags & IFF_RUNNING)
                                nge_stop(sc);
                }
-               sc->nge_if_flags = ifp->if_flags;
-               error = 0;
                break;

        case SIOCGIFMEDIA:
@@ -2024,8 +1976,7 @@ nge_ioctl(struct ifnet *ifp, u_long comm
                        error = ifmedia_ioctl(ifp, ifr, &sc->nge_ifmedia,
                                              command);
                } else {
-                       mii = &sc->nge_mii;
-                       error = ifmedia_ioctl(ifp, ifr, &mii->mii_media,
+                       error = ifmedia_ioctl(ifp, ifr, &sc->nge_mii.mii_media,
                                              command);
                }
                break;
@@ -2036,7 +1987,7 @@ nge_ioctl(struct ifnet *ifp, u_long comm

        if (error == ENETRESET) {
                if (ifp->if_flags & IFF_RUNNING)
-                       nge_setmulti(sc);
+                       nge_iff(sc);
                error = 0;
        }

@@ -2056,7 +2007,6 @@ nge_watchdog(struct ifnet *ifp)

        nge_stop(sc);
        nge_reset(sc);
-       ifp->if_flags &= ~IFF_RUNNING;
        nge_init(sc);

        if (!IFQ_IS_EMPTY(&ifp->if_snd))
Index: if_ngereg.h
===================================================================
RCS file: /home/cvs/src/sys/dev/pci/if_ngereg.h,v
retrieving revision 1.9
diff -u -p -r1.9 if_ngereg.h
--- if_ngereg.h 18 Oct 2012 21:44:21 -0000      1.9
+++ if_ngereg.h 2 Dec 2013 01:40:52 -0000
@@ -652,7 +652,6 @@ struct nge_softc {
        bus_space_tag_t         nge_btag;
        void                    *nge_intrhand;
        struct mii_data         nge_mii;
-       int                     nge_if_flags;
        u_int8_t                nge_type;
        u_int8_t                nge_link;
        u_int8_t                nge_width;



--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to