diff options
| author | deraadt <deraadt@NetBSD.org> | 1994-04-13 06:09:00 +0000 |
|---|---|---|
| committer | deraadt <deraadt@NetBSD.org> | 1994-04-13 06:09:00 +0000 |
| commit | 920c317ff93bb63b258c1fec27af66ac472bf978 (patch) | |
| tree | f8786062474b952cde3a475342d6f8d4f89e24a6 /sys/dev | |
| parent | eee893f9ea24fc80d2dc59aa04f0c356cec74fee (diff) | |
deallocate mbuf cache on ifconfig down.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/isa/if_ep.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/sys/dev/isa/if_ep.c b/sys/dev/isa/if_ep.c index 05f21ca8413..1db12d9df3b 100644 --- a/sys/dev/isa/if_ep.c +++ b/sys/dev/isa/if_ep.c @@ -21,12 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: if_ep.c,v 1.28 1994/04/11 11:09:00 deraadt Exp $ - */ -/* - * TODO: - * Multi-509 configs. - * deallocate mbufs when ifconfig'd down. + * $Id: if_ep.c,v 1.29 1994/04/13 06:09:00 deraadt Exp $ */ #include "bpfilter.h" @@ -106,7 +101,8 @@ static int epstart __P((struct ifnet *)); static int epwatchdog __P((int)); static void epreset __P((struct ep_softc *)); static void epread __P((struct ep_softc *)); -static void epmbufqueue __P((struct ep_softc *)); +static void epmbuffill __P((struct ep_softc *)); +static void epmbufempty __P((struct ep_softc *)); static void epstop __P((struct ep_softc *)); static u_short epreadeeprom __P((int id_port, int offset)); @@ -440,7 +436,7 @@ epinit(sc) */ sc->last_mb = 0; sc->next_mb = 0; - epmbufqueue(sc); + epmbuffill(sc); epstart(ifp); splx(s); @@ -748,7 +744,7 @@ epread(sc) if (m == 0) goto out; } else { - timeout(epmbufqueue, sc, 1); + timeout(epmbuffill, sc, 1); sc->next_mb = (sc->next_mb + 1) % MAX_MBS; } if (totlen >= MINCLSIZE) @@ -876,6 +872,7 @@ epioctl(ifp, cmd, data) if ((ifp->if_flags & IFF_UP) == 0 && ifp->if_flags & IFF_RUNNING) { ifp->if_flags &= ~IFF_RUNNING; epstop(sc); + epmbufempty(sc); break; } if (ifp->if_flags & IFF_UP && (ifp->if_flags & IFF_RUNNING) == 0) @@ -989,24 +986,37 @@ epbusyeeprom(sc) } static void -epmbufqueue(sc) +epmbuffill(sc) struct ep_softc *sc; { - int i = 0; - int s; + int s, i; s = splimp(); i = sc->last_mb; - if (sc->mb[i]) { - splx(s); - return; - } do { - MGET(sc->mb[i], M_DONTWAIT, MT_DATA); - if (!sc->mb[i]) + if (sc->mb[i] == NULL) + MGET(sc->mb[i], M_DONTWAIT, MT_DATA); + if (sc->mb[i] == NULL) break; i = (i + 1) % MAX_MBS; } while (i != sc->next_mb); sc->last_mb = i; splx(s); } + +static void +epmbufempty(sc) + struct ep_softc *sc; +{ + int s, i; + + s = splimp(); + for (i = 0; i<MAX_MBS; i++) { + if (sc->mb[i]) { + m_freem(sc->mb[i]); + sc->mb[i] = NULL; + } + } + sc->last_mb = sc->next_mb = 0; + splx(s); +} |
