From owner-freebsd-net@FreeBSD.ORG Fri Dec 1 16:11:32 2006 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5A1AE16A492; Fri, 1 Dec 2006 16:11:32 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (palm.hoeg.nl [83.98.131.212]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0F2F943C9D; Fri, 1 Dec 2006 16:11:17 +0000 (GMT) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 15CF81CFFF; Fri, 1 Dec 2006 17:11:31 +0100 (CET) Date: Fri, 1 Dec 2006 17:11:31 +0100 From: Ed Schouten To: Bill Paul Message-ID: <20061201161131.GD16100@hoeg.nl> References: <20061130210524.GY16100@hoeg.nl> <20061201001657.9F44E16A407@hub.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jdAw5H+0hw/nhz1g" Content-Disposition: inline In-Reply-To: <20061201001657.9F44E16A407@hub.freebsd.org> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: pyunyh@gmail.com, stable@freebsd.org, net@freebsd.org Subject: Re: re(4) needs promisc to work properly X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Dec 2006 16:11:32 -0000 --jdAw5H+0hw/nhz1g Content-Type: multipart/mixed; boundary="6CNdTR4UDBbLlHcf" Content-Disposition: inline --6CNdTR4UDBbLlHcf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Bill, * Bill Paul wrote: > > - Switching from and to promiscuous mode takes 7 seconds. All packets > > are dropped in the mean time. >=20 > The SIOCSIFFLAGS handler in re_ioctl() currently just takes a shortcut > of calling re_init(). While this does eventually end up changing the RX > filter settings accordingly, it takes a while because re_init() also shuts > down and re-initializes the whole chip (including resetting the link). >=20 > This is relatively easy to fix though. The IFF_PROMISC flag can be > singled out and handled separately. (A few other drivers already do this.) I wrote a small patch that moves all rxcfg code in re_init_locked() to a separate function. This way, we can just call that function instead of re_init_locked when reaching SIOCSIFFLAGS. I tested it by reverting your patch and ping6'ing the box. When I run tcpdump, the box doesn't freeze and enters promiscuous mode (suddenly the ping6 starts to work then). What do you think about this patch? Yours, --=20 Ed Schouten WWW: http://g-rave.nl/ --6CNdTR4UDBbLlHcf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="if_re.c.patch" Content-Transfer-Encoding: quoted-printable --- sys/dev/re/if_re.c Fri Dec 1 17:01:48 2006 +++ sys/dev/re/if_re.c Fri Dec 1 17:02:35 2006 @@ -249,6 +249,7 @@ static int re_ioctl (struct ifnet *, u_long, caddr_t); static void re_init (void *); static void re_init_locked (struct rl_softc *); +static void re_init_rxcfg (struct rl_softc *); static void re_stop (struct rl_softc *); static void re_watchdog (struct ifnet *); static int re_suspend (device_t); @@ -2254,7 +2255,6 @@ { struct ifnet *ifp =3D sc->rl_ifp; struct mii_data *mii; - u_int32_t rxcfg =3D 0; union { uint32_t align_dummy; u_char eaddr[ETHER_ADDR_LEN]; @@ -2316,31 +2316,8 @@ } else CSR_WRITE_4(sc, RL_TXCFG, RL_TXCFG_CONFIG); CSR_WRITE_4(sc, RL_RXCFG, RL_RXCFG_CONFIG); - - /* Set the individual bit to receive frames for this host only. */ - rxcfg =3D CSR_READ_4(sc, RL_RXCFG); - rxcfg |=3D RL_RXCFG_RX_INDIV; - - /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) - rxcfg |=3D RL_RXCFG_RX_ALLPHYS; - else - rxcfg &=3D ~RL_RXCFG_RX_ALLPHYS; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - - /* - * Set capture broadcast bit to capture broadcast frames. - */ - if (ifp->if_flags & IFF_BROADCAST) - rxcfg |=3D RL_RXCFG_RX_BROAD; - else - rxcfg &=3D ~RL_RXCFG_RX_BROAD; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - - /* - * Program the multicast filter, if necessary. - */ - re_setmulti(sc); +=09 + re_init_rxcfg(sc); =20 #ifdef DEVICE_POLLING /* @@ -2422,6 +2399,39 @@ callout_reset(&sc->rl_stat_callout, hz, re_tick, sc); } =20 +static void +re_init_rxcfg(sc) + struct rl_softc *sc; +{ + u_int32_t rxcfg; + struct ifnet *ifp =3D sc->rl_ifp; + + /* Set the individual bit to receive frames for this host only. */ + rxcfg =3D CSR_READ_4(sc, RL_RXCFG); + rxcfg |=3D RL_RXCFG_RX_INDIV; + + /* If we want promiscuous mode, set the allframes bit. */ + if (ifp->if_flags & IFF_PROMISC) + rxcfg |=3D RL_RXCFG_RX_ALLPHYS; + else + rxcfg &=3D ~RL_RXCFG_RX_ALLPHYS; + CSR_WRITE_4(sc, RL_RXCFG, rxcfg); + + /* + * Set capture broadcast bit to capture broadcast frames. + */ + if (ifp->if_flags & IFF_BROADCAST) + rxcfg |=3D RL_RXCFG_RX_BROAD; + else + rxcfg &=3D ~RL_RXCFG_RX_BROAD; + CSR_WRITE_4(sc, RL_RXCFG, rxcfg); + + /* + * Program the multicast filter, if necessary. + */ + re_setmulti(sc); +} + /* * Set media options. */ @@ -2484,7 +2494,7 @@ case SIOCSIFFLAGS: RL_LOCK(sc); if (ifp->if_flags & IFF_UP) - re_init_locked(sc); + re_init_rxcfg(sc); else if (ifp->if_drv_flags & IFF_DRV_RUNNING) re_stop(sc); RL_UNLOCK(sc); --6CNdTR4UDBbLlHcf-- --jdAw5H+0hw/nhz1g Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFcFQz52SDGA2eCwURAshKAJ9fgUQflsE0m86l1EJXNEO3xc9jSQCdEtEe U5vc1Uzuf/7E+8f8Dsp8eVE= =yi93 -----END PGP SIGNATURE----- --jdAw5H+0hw/nhz1g--