Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/dev/pci Pull up following revision(s) (requested by m...



details:   https://anonhg.NetBSD.org/src/rev/42373cac756f
branches:  netbsd-9
changeset: 843584:42373cac756f
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Nov 26 08:20:47 2019 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #483):

        sys/dev/pci/if_cas.c: revision 1.36
        sys/dev/pci/if_alc.c: revision 1.44
        sys/dev/pci/if_ale.c: revision 1.35
        sys/dev/pci/if_ale.c: revision 1.36
        sys/dev/pci/if_age.c: revision 1.64

Fix a bug that IFF_ALLMULTI is almost always set.
 OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.

 Remove accidentally committed debug code. Sorry.

diffstat:

 sys/dev/pci/if_age.c |  48 +++++++++++++++++-----------
 sys/dev/pci/if_alc.c |  46 ++++++++++++++++----------
 sys/dev/pci/if_ale.c |  48 +++++++++++++++++-----------
 sys/dev/pci/if_cas.c |  88 ++++++++++++++++++++++++++++-----------------------
 4 files changed, 135 insertions(+), 95 deletions(-)

diffs (truncated from 328 to 300 lines):

diff -r bf04f557dedc -r 42373cac756f sys/dev/pci/if_age.c
--- a/sys/dev/pci/if_age.c      Tue Nov 26 08:18:40 2019 +0000
+++ b/sys/dev/pci/if_age.c      Tue Nov 26 08:20:47 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_age.c,v 1.60.2.3 2019/11/26 08:18:40 martin Exp $ */
+/*     $NetBSD: if_age.c,v 1.60.2.4 2019/11/26 08:20:47 martin Exp $ */
 /*     $OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $        */
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.3 2019/11/26 08:18:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.4 2019/11/26 08:20:47 martin Exp $");
 
 #include "vlan.h"
 
@@ -2275,27 +2275,37 @@
         */
        rxcfg |= MAC_CFG_BCAST;
 
-       if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-               ifp->if_flags |= IFF_ALLMULTI;
-               if (ifp->if_flags & IFF_PROMISC)
+       /* Program new filter. */
+       if ((ifp->if_flags & IFF_PROMISC) != 0)
+               goto update;
+
+       memset(mchash, 0, sizeof(mchash));
+
+       ETHER_LOCK(ec);
+       ETHER_FIRST_MULTI(step, ec, enm);
+       while (enm != NULL) {
+               if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+                       /* XXX Use ETHER_F_ALLMULTI in future. */
+                       ifp->if_flags |= IFF_ALLMULTI;
+                       ETHER_UNLOCK(ec);
+                       goto update;
+               }
+               crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+               mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+               ETHER_NEXT_MULTI(step, enm);
+       }
+       ETHER_UNLOCK(ec);
+
+update:
+       if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+               if (ifp->if_flags & IFF_PROMISC) {
                        rxcfg |= MAC_CFG_PROMISC;
-               else
+                       /* XXX Use ETHER_F_ALLMULTI in future. */
+                       ifp->if_flags |= IFF_ALLMULTI;
+               } else
                        rxcfg |= MAC_CFG_ALLMULTI;
                mchash[0] = mchash[1] = 0xFFFFFFFF;
-       } else {
-               /* Program new filter. */
-               memset(mchash, 0, sizeof(mchash));
-
-               ETHER_LOCK(ec);
-               ETHER_FIRST_MULTI(step, ec, enm);
-               while (enm != NULL) {
-                       crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-                       mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-                       ETHER_NEXT_MULTI(step, enm);
-               }
-               ETHER_UNLOCK(ec);
        }
-
        CSR_WRITE_4(sc, AGE_MAR0, mchash[0]);
        CSR_WRITE_4(sc, AGE_MAR1, mchash[1]);
        CSR_WRITE_4(sc, AGE_MAC_CFG, rxcfg);
diff -r bf04f557dedc -r 42373cac756f sys/dev/pci/if_alc.c
--- a/sys/dev/pci/if_alc.c      Tue Nov 26 08:18:40 2019 +0000
+++ b/sys/dev/pci/if_alc.c      Tue Nov 26 08:20:47 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_alc.c,v 1.38.2.2 2019/11/06 09:59:38 martin Exp $   */
+/*     $NetBSD: if_alc.c,v 1.38.2.3 2019/11/26 08:20:47 martin Exp $   */
 /*     $OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $        */
 /*-
  * Copyright (c) 2009, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -3443,27 +3443,37 @@
         */
        rxcfg |= MAC_CFG_BCAST;
 
-       if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-               ifp->if_flags |= IFF_ALLMULTI;
-               if (ifp->if_flags & IFF_PROMISC)
+       /* Program new filter. */
+       if ((ifp->if_flags & IFF_PROMISC) != 0)
+               goto update;
+
+       memset(mchash, 0, sizeof(mchash));
+
+       ETHER_LOCK(ec);
+       ETHER_FIRST_MULTI(step, ec, enm);
+       while (enm != NULL) {
+               if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+                       /* XXX Use ETHER_F_ALLMULTI in future. */
+                       ifp->if_flags |= IFF_ALLMULTI;
+                       ETHER_UNLOCK(ec);
+                       goto update;
+               }
+               crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+               mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+               ETHER_NEXT_MULTI(step, enm);
+       }
+       ETHER_UNLOCK(ec);
+
+update:
+       if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+               if (ifp->if_flags & IFF_PROMISC) {
                        rxcfg |= MAC_CFG_PROMISC;
-               else
+                       /* XXX Use ETHER_F_ALLMULTI in future. */
+                       ifp->if_flags |= IFF_ALLMULTI;
+               } else
                        rxcfg |= MAC_CFG_ALLMULTI;
                mchash[0] = mchash[1] = 0xFFFFFFFF;
-       } else {
-               /* Program new filter. */
-               memset(mchash, 0, sizeof(mchash));
-
-               ETHER_LOCK(ec);
-               ETHER_FIRST_MULTI(step, ec, enm);
-               while (enm != NULL) {
-                       crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-                       mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-                       ETHER_NEXT_MULTI(step, enm);
-               }
-               ETHER_UNLOCK(ec);
        }
-
        CSR_WRITE_4(sc, ALC_MAR0, mchash[0]);
        CSR_WRITE_4(sc, ALC_MAR1, mchash[1]);
        CSR_WRITE_4(sc, ALC_MAC_CFG, rxcfg);
diff -r bf04f557dedc -r 42373cac756f sys/dev/pci/if_ale.c
--- a/sys/dev/pci/if_ale.c      Tue Nov 26 08:18:40 2019 +0000
+++ b/sys/dev/pci/if_ale.c      Tue Nov 26 08:20:47 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ale.c,v 1.33.2.1 2019/11/06 09:59:39 martin Exp $   */
+/*     $NetBSD: if_ale.c,v 1.33.2.2 2019/11/26 08:20:47 martin Exp $   */
 
 /*-
  * Copyright (c) 2008, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -32,7 +32,7 @@
 /* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.33.2.1 2019/11/06 09:59:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.33.2.2 2019/11/26 08:20:47 martin Exp $");
 
 #include "vlan.h"
 
@@ -1996,27 +1996,37 @@
         */
        rxcfg |= MAC_CFG_BCAST;
 
-       if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-               ifp->if_flags |= IFF_ALLMULTI;
-               if (ifp->if_flags & IFF_PROMISC)
+       /* Program new filter. */
+       if ((ifp->if_flags & IFF_PROMISC) != 0)
+               goto update;
+
+       memset(mchash, 0, sizeof(mchash));
+
+       ETHER_LOCK(ec);
+       ETHER_FIRST_MULTI(step, ec, enm);
+       while (enm != NULL) {
+               if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+                       /* XXX Use ETHER_F_ALLMULTI in future. */
+                       ifp->if_flags |= IFF_ALLMULTI;
+                       ETHER_UNLOCK(ec);
+                       goto update;
+               }
+               crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+               mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+               ETHER_NEXT_MULTI(step, enm);
+       }
+       ETHER_UNLOCK(ec);
+
+update:
+       if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+               if (ifp->if_flags & IFF_PROMISC) {
                        rxcfg |= MAC_CFG_PROMISC;
-               else
+                       /* XXX Use ETHER_F_ALLMULTI in future. */
+                       ifp->if_flags |= IFF_ALLMULTI;
+               } else
                        rxcfg |= MAC_CFG_ALLMULTI;
                mchash[0] = mchash[1] = 0xFFFFFFFF;
-       } else {
-               /* Program new filter. */
-               memset(mchash, 0, sizeof(mchash));
-
-               ETHER_LOCK(ec);
-               ETHER_FIRST_MULTI(step, ec, enm);
-               while (enm != NULL) {
-                       crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-                       mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-                       ETHER_NEXT_MULTI(step, enm);
-               }
-               ETHER_UNLOCK(ec);
        }
-
        CSR_WRITE_4(sc, ALE_MAR0, mchash[0]);
        CSR_WRITE_4(sc, ALE_MAR1, mchash[1]);
        CSR_WRITE_4(sc, ALE_MAC_CFG, rxcfg);
diff -r bf04f557dedc -r 42373cac756f sys/dev/pci/if_cas.c
--- a/sys/dev/pci/if_cas.c      Tue Nov 26 08:18:40 2019 +0000
+++ b/sys/dev/pci/if_cas.c      Tue Nov 26 08:20:47 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cas.c,v 1.35 2019/05/28 07:41:49 msaitoh Exp $      */
+/*     $NetBSD: if_cas.c,v 1.35.2.1 2019/11/26 08:20:47 martin Exp $   */
 /*     $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $    */
 
 /*
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.35 2019/05/28 07:41:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.35.2.1 2019/11/26 08:20:47 martin Exp $");
 
 #ifndef _MODULE
 #include "opt_inet.h"
@@ -1905,52 +1905,62 @@
            CAS_MAC_RX_PROMISC_GRP);
        ifp->if_flags &= ~IFF_ALLMULTI;
 
-       if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-               ifp->if_flags |= IFF_ALLMULTI;
-               if (ifp->if_flags & IFF_PROMISC)
-                       rxcfg |= CAS_MAC_RX_PROMISCUOUS;
-               else
-                       rxcfg |= CAS_MAC_RX_PROMISC_GRP;
-       } else {
-               /*
-                * Set up multicast address filter by passing all multicast
-                * addresses through a crc generator, and then using the
-                * high order 8 bits as an index into the 256 bit logical
-                * address filter.  The high order 4 bits selects the word,
-                * while the other 4 bits select the bit within the word
-                * (where bit 0 is the MSB).
-                */
+       if ((ifp->if_flags & IFF_PROMISC) != 0)
+               goto update;
 
-               rxcfg |= CAS_MAC_RX_HASH_FILTER;
+       /*
+        * Set up multicast address filter by passing all multicast
+        * addresses through a crc generator, and then using the
+        * high order 8 bits as an index into the 256 bit logical
+        * address filter.  The high order 4 bits selects the word,
+        * while the other 4 bits select the bit within the word
+        * (where bit 0 is the MSB).
+        */
 
-               /* Clear hash table */
-               for (i = 0; i < 16; i++)
-                       hash[i] = 0;
+       /* Clear hash table */
+       for (i = 0; i < 16; i++)
+               hash[i] = 0;
 
-               ETHER_LOCK(ec);
-               ETHER_FIRST_MULTI(step, ec, enm);
-               while (enm != NULL) {
-                       crc = ether_crc32_le(enm->enm_addrlo,
-                           ETHER_ADDR_LEN);
+       ETHER_LOCK(ec);
+       ETHER_FIRST_MULTI(step, ec, enm);
+       while (enm != NULL) {
+               if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+                       /* XXX Use ETHER_F_ALLMULTI in future. */
+                       ifp->if_flags |= IFF_ALLMULTI;
+                       ETHER_UNLOCK(ec);
+                       goto update;
+               }
 
-                       /* Just want the 8 most significant bits. */
-                       crc >>= 24;
+               crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
+
+               /* Just want the 8 most significant bits. */
+               crc >>= 24;
 
-                       /* Set the corresponding bit in the filter. */
-                       hash[crc >> 4] |= 1 << (15 - (crc & 15));
+               /* Set the corresponding bit in the filter. */
+               hash[crc >> 4] |= 1 << (15 - (crc & 15));
 
-                       ETHER_NEXT_MULTI(step, enm);
-               }
-               ETHER_UNLOCK(ec);
+               ETHER_NEXT_MULTI(step, enm);
+       }
+       ETHER_UNLOCK(ec);



Home | Main Index | Thread Index | Old Index