summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2009-06-20 15:42:30 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2009-06-20 15:42:30 +0000
commitcbc42328f38b730de93021fcf1649992df323704 (patch)
tree90a446ed2993fb600d438da0ea3cde163ba1939d /sys/dev
parentadfc14e5d3756ef6d2c25867b9ba3431ca38358f (diff)
Rewrite the interface flag handling case code and update the receive
filter handling to take advantage of ac_multirangecnt and have correct IFF_ALLMULTI handling. From Brad.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_bnx.c36
-rw-r--r--sys/dev/pci/if_bnxreg.h4
2 files changed, 16 insertions, 24 deletions
diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c
index ee38a65867f..df79367be9d 100644
--- a/sys/dev/pci/if_bnx.c
+++ b/sys/dev/pci/if_bnx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bnx.c,v 1.78 2009/04/22 01:17:26 dlg Exp $ */
+/* $OpenBSD: if_bnx.c,v 1.79 2009/06/20 15:42:28 naddy Exp $ */
/*-
* Copyright (c) 2006 Broadcom Corporation
@@ -397,7 +397,7 @@ void bnx_disable_intr(struct bnx_softc *);
void bnx_enable_intr(struct bnx_softc *);
int bnx_intr(void *);
-void bnx_set_rx_mode(struct bnx_softc *);
+void bnx_iff(struct bnx_softc *);
void bnx_stats_update(struct bnx_softc *);
void bnx_tick(void *);
@@ -4314,7 +4314,7 @@ bnx_init(void *xsc)
sc->mbuf_alloc_size, sc->max_frame_size);
/* Program appropriate promiscuous/multicast filtering. */
- bnx_set_rx_mode(sc);
+ bnx_iff(sc);
/* Init RX buffer descriptor chain. */
bnx_init_rx_chain(sc);
@@ -4639,19 +4639,14 @@ bnx_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
case SIOCSIFFLAGS:
if (ifp->if_flags & IFF_UP) {
- if ((ifp->if_flags & IFF_RUNNING) &&
- ((ifp->if_flags ^ sc->bnx_if_flags) &
- (IFF_ALLMULTI | IFF_PROMISC)) != 0) {
- bnx_set_rx_mode(sc);
- } else {
- if (!(ifp->if_flags & IFF_RUNNING))
- bnx_init(sc);
- }
+ if (ifp->if_flags & IFF_RUNNING)
+ error = ENETRESET;
+ else
+ bnx_init(sc);
} else {
if (ifp->if_flags & IFF_RUNNING)
bnx_stop(sc);
}
- sc->bnx_if_flags = ifp->if_flags;
break;
case SIOCSIFMEDIA:
@@ -4668,7 +4663,7 @@ bnx_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
if (error == ENETRESET) {
if (ifp->if_flags & IFF_RUNNING)
- bnx_set_rx_mode(sc);
+ bnx_iff(sc);
error = 0;
}
@@ -4837,7 +4832,7 @@ bnx_intr(void *xsc)
/* Nothing. */
/****************************************************************************/
void
-bnx_set_rx_mode(struct bnx_softc *sc)
+bnx_iff(struct bnx_softc *sc)
{
struct arpcom *ac = &sc->arpcom;
struct ifnet *ifp = &ac->ac_if;
@@ -4851,6 +4846,7 @@ bnx_set_rx_mode(struct bnx_softc *sc)
rx_mode = sc->rx_mode & ~(BNX_EMAC_RX_MODE_PROMISCUOUS |
BNX_EMAC_RX_MODE_KEEP_VLAN_TAG);
sort_mode = 1 | BNX_RPM_SORT_USER0_BC_EN;
+ ifp->if_flags &= ~IFF_ALLMULTI;
/*
* ASF/IPMI/UMP firmware requires that VLAN tag stripping
@@ -4867,13 +4863,14 @@ bnx_set_rx_mode(struct bnx_softc *sc)
if (ifp->if_flags & IFF_PROMISC) {
DBPRINT(sc, BNX_INFO, "Enabling promiscuous mode.\n");
+ ifp->if_flags |= IFF_ALLMULTI;
/* Enable promiscuous mode. */
rx_mode |= BNX_EMAC_RX_MODE_PROMISCUOUS;
sort_mode |= BNX_RPM_SORT_USER0_PROM_EN;
- } else if (ifp->if_flags & IFF_ALLMULTI) {
-allmulti:
+ } else if (ac->ac_multirangecnt > 0) {
DBPRINT(sc, BNX_INFO, "Enabling all multicast mode.\n");
+ ifp->if_flags |= IFF_ALLMULTI;
/* Enable all multicast addresses. */
for (i = 0; i < NUM_MC_HASH_REGISTERS; i++)
REG_WR(sc, BNX_EMAC_MULTICAST_HASH0 + (i * 4),
@@ -4885,14 +4882,11 @@ allmulti:
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
- if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
- ETHER_ADDR_LEN)) {
- ifp->if_flags |= IFF_ALLMULTI;
- goto allmulti;
- }
h = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN) &
0xFF;
+
hashes[(h & 0xE0) >> 5] |= 1 << (h & 0x1F);
+
ETHER_NEXT_MULTI(step, enm);
}
diff --git a/sys/dev/pci/if_bnxreg.h b/sys/dev/pci/if_bnxreg.h
index b8b17d423ca..089f21852b0 100644
--- a/sys/dev/pci/if_bnxreg.h
+++ b/sys/dev/pci/if_bnxreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bnxreg.h,v 1.28 2009/04/22 00:38:04 dlg Exp $ */
+/* $OpenBSD: if_bnxreg.h,v 1.29 2009/06/20 15:42:29 naddy Exp $ */
/*-
* Copyright (c) 2006 Broadcom Corporation
@@ -4643,8 +4643,6 @@ struct bnx_softc {
u_int32_t bnx_shared_hw_cfg;
u_int32_t bnx_port_hw_cfg;
- int bnx_if_flags;
-
u_int16_t bus_speed_mhz; /* PCI bus speed */
struct flash_spec *bnx_flash_info; /* Flash NVRAM settings */
u_int32_t bnx_flash_size; /* Flash NVRAM size */