From 4a845497316284fc31758c4452909e29eacda21a Mon Sep 17 00:00:00 2001 From: bz Date: Thu, 17 Mar 2005 14:18:58 +0000 Subject: * When adding/deleting multicast addresses, only whack the address filter if the interface is marked RUNNING. Obtained from: NetBSD if_sk.c rev. 1.12 * Don't initialize the card (and start an autonegotiation) every time the IP address changes. Makes 'dhclient sk0' invocations way faster and more consistant. i.e. one DHCPREQUEST elicits the DHCPACK. Obtained from: OpenBSD if_sk.c rev. 1.56 * Additional locking changes in sk_ioctl. PR: kern/61296 should see improvements by the last two. Approved by: rwatson (mentor) MFC after: 5 days --- sys/dev/sk/if_sk.c | 21 +++++++++++++++------ sys/pci/if_sk.c | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 89e5e22..d6e1cf3 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1178,18 +1178,18 @@ sk_ioctl(ifp, command, data) int error = 0; struct mii_data *mii; - SK_IF_LOCK(sc_if); - switch(command) { case SIOCSIFMTU: if (ifr->ifr_mtu > SK_JUMBO_MTU) error = EINVAL; else { ifp->if_mtu = ifr->ifr_mtu; + ifp->if_flags &= ~IFF_RUNNING; sk_init(sc_if); } break; case SIOCSIFFLAGS: + SK_IF_LOCK(sc_if); if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING) { if ((ifp->if_flags ^ sc_if->sk_if_flags) @@ -1204,12 +1204,17 @@ sk_ioctl(ifp, command, data) sk_stop(sc_if); } sc_if->sk_if_flags = ifp->if_flags; + SK_IF_UNLOCK(sc_if); error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: - sk_setmulti(sc_if); - error = 0; + if (ifp->if_flags & IFF_RUNNING) { + SK_IF_LOCK(sc_if); + sk_setmulti(sc_if); + SK_IF_UNLOCK(sc_if); + error = 0; + } break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: @@ -1221,8 +1226,6 @@ sk_ioctl(ifp, command, data) break; } - SK_IF_UNLOCK(sc_if); - return(error); } @@ -1892,6 +1895,7 @@ sk_watchdog(ifp) sc_if = ifp->if_softc; printf("sk%d: watchdog timeout\n", sc_if->sk_unit); + ifp->if_flags &= ~IFF_RUNNING; sk_init(sc_if); return; @@ -2557,6 +2561,11 @@ sk_init(xsc) sc = sc_if->sk_softc; mii = device_get_softc(sc_if->sk_miibus); + if (ifp->if_flags & IFF_RUNNING) { + SK_IF_UNLOCK(sc_if); + return; + } + /* Cancel pending I/O and free all RX/TX buffers. */ sk_stop(sc_if); diff --git a/sys/pci/if_sk.c b/sys/pci/if_sk.c index 89e5e22..d6e1cf3 100644 --- a/sys/pci/if_sk.c +++ b/sys/pci/if_sk.c @@ -1178,18 +1178,18 @@ sk_ioctl(ifp, command, data) int error = 0; struct mii_data *mii; - SK_IF_LOCK(sc_if); - switch(command) { case SIOCSIFMTU: if (ifr->ifr_mtu > SK_JUMBO_MTU) error = EINVAL; else { ifp->if_mtu = ifr->ifr_mtu; + ifp->if_flags &= ~IFF_RUNNING; sk_init(sc_if); } break; case SIOCSIFFLAGS: + SK_IF_LOCK(sc_if); if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING) { if ((ifp->if_flags ^ sc_if->sk_if_flags) @@ -1204,12 +1204,17 @@ sk_ioctl(ifp, command, data) sk_stop(sc_if); } sc_if->sk_if_flags = ifp->if_flags; + SK_IF_UNLOCK(sc_if); error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: - sk_setmulti(sc_if); - error = 0; + if (ifp->if_flags & IFF_RUNNING) { + SK_IF_LOCK(sc_if); + sk_setmulti(sc_if); + SK_IF_UNLOCK(sc_if); + error = 0; + } break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: @@ -1221,8 +1226,6 @@ sk_ioctl(ifp, command, data) break; } - SK_IF_UNLOCK(sc_if); - return(error); } @@ -1892,6 +1895,7 @@ sk_watchdog(ifp) sc_if = ifp->if_softc; printf("sk%d: watchdog timeout\n", sc_if->sk_unit); + ifp->if_flags &= ~IFF_RUNNING; sk_init(sc_if); return; @@ -2557,6 +2561,11 @@ sk_init(xsc) sc = sc_if->sk_softc; mii = device_get_softc(sc_if->sk_miibus); + if (ifp->if_flags & IFF_RUNNING) { + SK_IF_UNLOCK(sc_if); + return; + } + /* Cancel pending I/O and free all RX/TX buffers. */ sk_stop(sc_if); -- cgit v1.1