From 09aafe54025af2d6c2ef868bf74fe80bbcfed8a8 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Fri, 3 Nov 2000 00:37:45 +0000 Subject: [PATCH] Create a pcn_setfilt() routine that twiddles the promiscuous mode and nobroadcast bits in the mode register and call it both from pcn_init() and pcn_ioctl(). Sometimes we need to force the state of the nobroadcast bit after switching out of promisc mode. --- sys/pci/if_pcn.c | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/sys/pci/if_pcn.c b/sys/pci/if_pcn.c index 05e0ab70faa..dc04df8cde0 100644 --- a/sys/pci/if_pcn.c +++ b/sys/pci/if_pcn.c @@ -138,6 +138,7 @@ static int pcn_miibus_readreg __P((device_t, int, int)); static int pcn_miibus_writereg __P((device_t, int, int, int)); static void pcn_miibus_statchg __P((device_t)); +static void pcn_setfilt __P((struct ifnet *)); static void pcn_setmulti __P((struct pcn_softc *)); static u_int32_t pcn_crc __P((caddr_t)); static void pcn_reset __P((struct pcn_softc *)); @@ -1051,6 +1052,30 @@ static void pcn_start(ifp) return; } +static void pcn_setfilt(ifp) + struct ifnet *ifp; +{ + struct pcn_softc *sc; + + sc = ifp->if_softc; + + /* If we want promiscuous mode, set the allframes bit. */ + if (ifp->if_flags & IFF_PROMISC) { + PCN_CSR_SETBIT(sc, PCN_CSR_MODE, PCN_MODE_PROMISC); + } else { + PCN_CSR_CLRBIT(sc, PCN_CSR_MODE, PCN_MODE_PROMISC); + } + + /* Set the capture broadcast bit to capture broadcast frames. */ + if (ifp->if_flags & IFF_BROADCAST) { + PCN_CSR_CLRBIT(sc, PCN_CSR_MODE, PCN_MODE_RXNOBROAD); + } else { + PCN_CSR_SETBIT(sc, PCN_CSR_MODE, PCN_MODE_RXNOBROAD); + } + + return; +} + static void pcn_init(xsc) void *xsc; { @@ -1093,19 +1118,8 @@ static void pcn_init(xsc) /* Set up the mode register. */ pcn_csr_write(sc, PCN_CSR_MODE, PCN_PORT_MII); - /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) { - PCN_CSR_SETBIT(sc, PCN_CSR_MODE, PCN_MODE_PROMISC); - } else { - PCN_CSR_CLRBIT(sc, PCN_CSR_MODE, PCN_MODE_PROMISC); - } - - /* Set the capture broadcast bit to capture broadcast frames. */ - if (ifp->if_flags & IFF_BROADCAST) { - PCN_CSR_CLRBIT(sc, PCN_CSR_MODE, PCN_MODE_RXNOBROAD); - } else { - PCN_CSR_SETBIT(sc, PCN_CSR_MODE, PCN_MODE_RXNOBROAD); - } + /* Set up RX filter. */ + pcn_setfilt(ifp); /* * Load the multicast filter. @@ -1238,8 +1252,7 @@ static int pcn_ioctl(ifp, command, data) !(sc->pcn_if_flags & IFF_PROMISC)) { PCN_CSR_SETBIT(sc, PCN_CSR_EXTCTL1, PCN_EXTCTL1_SPND); - PCN_CSR_SETBIT(sc, PCN_CSR_MODE, - PCN_MODE_PROMISC); + pcn_setfilt(ifp); PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, PCN_EXTCTL1_SPND); pcn_csr_write(sc, PCN_CSR_CSR, @@ -1249,8 +1262,7 @@ static int pcn_ioctl(ifp, command, data) sc->pcn_if_flags & IFF_PROMISC) { PCN_CSR_SETBIT(sc, PCN_CSR_EXTCTL1, PCN_EXTCTL1_SPND); - PCN_CSR_CLRBIT(sc, PCN_CSR_MODE, - PCN_MODE_PROMISC); + pcn_setfilt(ifp); PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, PCN_EXTCTL1_SPND); pcn_csr_write(sc, PCN_CSR_CSR,