summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-09-07 07:54:45 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-09-07 07:54:45 +0000
commit563b09f689fffae2065862f01263692fa58175b4 (patch)
tree3027dcf4ecee50e09c97eaef23b4be674d354961 /sys/dev/pci
parent50a9099ddaa433c1fdfb3fc8fd6c0cbdc7564659 (diff)
Bring the promiscuous/multicast handling code in line with the current OpenBSD
practice; from brad
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_se.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/sys/dev/pci/if_se.c b/sys/dev/pci/if_se.c
index fb624b24c87..048b317b637 100644
--- a/sys/dev/pci/if_se.c
+++ b/sys/dev/pci/if_se.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_se.c,v 1.5 2010/09/05 12:42:54 miod Exp $ */
+/* $OpenBSD: if_se.c,v 1.6 2010/09/07 07:54:44 miod Exp $ */
/*-
* Copyright (c) 2009, 2010 Christopher Zimmermann <madroach@zakweb.de>
@@ -452,23 +452,31 @@ se_iff(struct se_softc *sc)
uint16_t rxfilt;
rxfilt = CSR_READ_2(sc, RxMacControl);
- rxfilt &= ~(AcceptBroadcast | AcceptAllPhys | AcceptMulticast);
- rxfilt |= AcceptMyPhys;
- if ((ifp->if_flags & IFF_BROADCAST) != 0)
- rxfilt |= AcceptBroadcast;
- if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
- if ((ifp->if_flags & IFF_PROMISC) != 0)
+ rxfilt &= ~(AcceptAllPhys | AcceptBroadcast | AcceptMulticast);
+ ifp->if_flags &= ~IFF_ALLMULTI;
+
+ /*
+ * Always accept broadcast frames.
+ * Always accept frames destined to our station address.
+ */
+ rxfilt |= AcceptBroadcast | AcceptMyPhys;
+
+ if (ifp->if_flags & IFF_PROMISC || ac->ac_multirangecnt > 0) {
+ ifp->if_flags |= IFF_ALLMULTI;
+ if (ifp->if_flags & IFF_PROMISC)
rxfilt |= AcceptAllPhys;
rxfilt |= AcceptMulticast;
hashes[0] = hashes[1] = 0xffffffff;
} else {
rxfilt |= AcceptMulticast;
- /* Now program new ones. */
- ETHER_FIRST_MULTI(step, ac, enm);
hashes[0] = hashes[1] = 0;
+
+ ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+
hashes[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+
ETHER_NEXT_MULTI(step, enm);
}
}
@@ -1250,9 +1258,6 @@ se_init(struct ifnet *ifp)
splassert(IPL_NET);
- if ((ifp->if_flags & IFF_RUNNING) != 0)
- return 0;
-
/*
* Cancel pending I/O and free all RX/TX buffers.
*/
@@ -1286,6 +1291,8 @@ se_init(struct ifnet *ifp)
/* Configure RX MAC. */
rxfilt = RXMAC_STRIP_FCS | RXMAC_PAD_ENB | RXMAC_CSUM_ENB;
CSR_WRITE_2(sc, RxMacControl, rxfilt);
+
+ /* Program promiscuous mode and multicast filters. */
se_iff(sc);
/*
@@ -1406,7 +1413,6 @@ se_watchdog(struct ifnet *ifp)
ifp->if_oerrors++;
s = splnet();
- ifp->if_flags &= ~IFF_RUNNING;
se_init(ifp);
if (!IFQ_IS_EMPTY(&ifp->if_snd))
se_start(ifp);