Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Enable hash-table-based multicast filter:
details: https://anonhg.NetBSD.org/src/rev/7bba95f1db2f
branches: trunk
changeset: 996420:7bba95f1db2f
user: rin <rin%NetBSD.org@localhost>
date: Thu Jan 31 15:26:24 2019 +0000
description:
Enable hash-table-based multicast filter:
- Drop AXEN_RXCTL_ACPT_PHY_MCAST bit (neither Linux nor FreeBSD sets it).
- 0x0010 bit is not AXEN_RXCTL_ACPT_BCAST ("accept broadcast") but
AXEN_RXCTL_ACPT_MCAST ("accept multicast (hash-table-based)").
diffstat:
sys/dev/usb/if_axen.c | 41 +++++++++++++++++++++++------------------
sys/dev/usb/if_axenreg.h | 4 ++--
2 files changed, 25 insertions(+), 20 deletions(-)
diffs (98 lines):
diff -r cfac30724b80 -r 7bba95f1db2f sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c Thu Jan 31 15:24:13 2019 +0000
+++ b/sys/dev/usb/if_axen.c Thu Jan 31 15:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axen.c,v 1.22 2019/01/31 15:24:13 rin Exp $ */
+/* $NetBSD: if_axen.c,v 1.23 2019/01/31 15:26:24 rin Exp $ */
/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
/*
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.22 2019/01/31 15:24:13 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.23 2019/01/31 15:26:24 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -354,32 +354,38 @@
axen_lock_mii(sc);
axen_cmd(sc, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval);
rxmode = le16toh(wval);
- rxmode &= ~(AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_ACPT_PHY_MCAST |
- AXEN_RXCTL_PROMISC);
+ rxmode &= ~(AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_PROMISC |
+ AXEN_RXCTL_ACPT_MCAST);
ifp->if_flags &= ~IFF_ALLMULTI;
- /*
- * Always accept broadcast frames.
- * Always accept frames destined to our station address.
- */
- rxmode |= AXEN_RXCTL_ACPT_BCAST;
-
- if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0 /* XXX */) {
- ifp->if_flags |= IFF_ALLMULTI;
- rxmode |= AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_ACPT_PHY_MCAST;
- if (ifp->if_flags & IFF_PROMISC)
- rxmode |= AXEN_RXCTL_PROMISC;
+ if (ifp->if_flags & IFF_PROMISC) {
+ DPRINTF(("%s: promisc\n", device_xname(sc->axen_dev)));
+ rxmode |= AXEN_RXCTL_PROMISC;
+allmulti: ifp->if_flags |= IFF_ALLMULTI;
+ rxmode |= AXEN_RXCTL_ACPT_ALL_MCAST
+ /* | AXEN_RXCTL_ACPT_PHY_MCAST */;
} else {
- rxmode |= AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_ACPT_PHY_MCAST;
-
/* now program new ones */
+ DPRINTF(("%s: initializing hash table\n",
+ device_xname(sc->axen_dev)));
ETHER_FIRST_MULTI(step, ec, enm);
while (enm != NULL) {
+ if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
+ ETHER_ADDR_LEN)) {
+ DPRINTF(("%s: allmulti\n",
+ device_xname(sc->axen_dev)));
+ memset(hashtbl, 0, sizeof(hashtbl));
+ goto allmulti;
+ }
h = ether_crc32_be(enm->enm_addrlo,
ETHER_ADDR_LEN) >> 26;
hashtbl[h / 8] |= 1 << (h % 8);
+ DPRINTF(("%s: %s added\n",
+ device_xname(sc->axen_dev),
+ ether_sprintf(enm->enm_addrlo)));
ETHER_NEXT_MULTI(step, enm);
}
+ rxmode |= AXEN_RXCTL_ACPT_MCAST;
}
axen_cmd(sc, AXEN_CMD_MAC_WRITE_FILTER, 8, AXEN_FILTER_MULTI, hashtbl);
@@ -570,7 +576,6 @@
/* Set RX/TX configuration. */
/* Set RX control register */
ctl = AXEN_RXCTL_IPE | AXEN_RXCTL_DROPCRCERR | AXEN_RXCTL_AUTOB;
- ctl |= AXEN_RXCTL_ACPT_PHY_MCAST | AXEN_RXCTL_ACPT_ALL_MCAST;
wval = htole16(ctl);
axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval);
diff -r cfac30724b80 -r 7bba95f1db2f sys/dev/usb/if_axenreg.h
--- a/sys/dev/usb/if_axenreg.h Thu Jan 31 15:24:13 2019 +0000
+++ b/sys/dev/usb/if_axenreg.h Thu Jan 31 15:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axenreg.h,v 1.4 2019/01/30 11:13:25 rin Exp $ */
+/* $NetBSD: if_axenreg.h,v 1.5 2019/01/31 15:26:24 rin Exp $ */
/* $OpenBSD: if_axenreg.h,v 1.1 2013/10/07 05:37:41 yuo Exp $ */
/*
@@ -153,7 +153,7 @@
#define AXEN_RXCTL_ACPT_ALL_MCAST 0x0002
#define AXEN_RXCTL_HA8B 0x0004
#define AXEN_RXCTL_AUTOB 0x0008
-#define AXEN_RXCTL_ACPT_BCAST 0x0010
+#define AXEN_RXCTL_ACPT_MCAST 0x0010
#define AXEN_RXCTL_ACPT_PHY_MCAST 0x0020
#define AXEN_RXCTL_START 0x0080
#define AXEN_RXCTL_DROPCRCERR 0x0100
Home |
Main Index |
Thread Index |
Old Index