diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2000-08-19 08:32:59 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2000-08-19 08:32:59 +0000 |
commit | df0e25bf6c3619217f1f2c8b5a35a6e706f2a0b4 (patch) | |
tree | 47f526cc36bae230ba5426a392413b1b46c0d678 /sys/pci/if_wb.c | |
parent | 2f92e39a0fe52366609e44e5a1978feb243c8755 (diff) | |
download | FreeBSD-src-df0e25bf6c3619217f1f2c8b5a35a6e706f2a0b4.zip FreeBSD-src-df0e25bf6c3619217f1f2c8b5a35a6e706f2a0b4.tar.gz |
Replace the mbuf external reference counting code with something
that should be better.
The old code counted references to mbuf clusters by using the offset
of the cluster from the start of memory allocated for mbufs and
clusters as an index into an array of chars, which did the reference
counting. If the external storage was not a cluster then reference
counting had to be done by the code using that external storage.
NetBSD's system of linked lists of mbufs was cosidered, but Alfred
felt it would have locking issues when the kernel was made more
SMP friendly.
The system implimented uses a pool of unions to track external
storage. The union contains an int for counting the references and
a pointer for forming a free list. The reference counts are
incremented and decremented atomically and so should be SMP friendly.
This system can track reference counts for any sort of external
storage.
Access to the reference counting stuff is now through macros defined
in mbuf.h, so it should be easier to make changes to the system in
the future.
The possibility of storing the reference count in one of the
referencing mbufs was considered, but was rejected 'cos it would
often leave extra mbufs allocated. Storing the reference count in
the cluster was also considered, but because the external storage
may not be a cluster this isn't an option.
The size of the pool of reference counters is available in the
stats provided by "netstat -m".
PR: 19866
Submitted by: Bosko Milekic <bmilekic@dsuper.net>
Reviewed by: alfred (glanced at by others on -net)
Diffstat (limited to 'sys/pci/if_wb.c')
-rw-r--r-- | sys/pci/if_wb.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sys/pci/if_wb.c b/sys/pci/if_wb.c index 397ca20..b33c542 100644 --- a/sys/pci/if_wb.c +++ b/sys/pci/if_wb.c @@ -147,7 +147,7 @@ static int wb_probe __P((device_t)); static int wb_attach __P((device_t)); static int wb_detach __P((device_t)); -static void wb_bfree __P((caddr_t, u_int)); +static void wb_bfree __P((caddr_t, void *args)); static int wb_newbuf __P((struct wb_softc *, struct wb_chain_onefrag *, struct mbuf *)); @@ -1078,9 +1078,9 @@ static int wb_list_rx_init(sc) return(0); } -static void wb_bfree(buf, size) +static void wb_bfree(buf, args) caddr_t buf; - u_int size; + void *args; { return; } @@ -1102,13 +1102,9 @@ static int wb_newbuf(sc, c, m) "list -- packet dropped!\n", sc->wb_unit); return(ENOBUFS); } - - m_new->m_data = m_new->m_ext.ext_buf = c->wb_buf; - m_new->m_flags |= M_EXT; - m_new->m_ext.ext_size = m_new->m_pkthdr.len = - m_new->m_len = WB_BUFBYTES; - m_new->m_ext.ext_free = wb_bfree; - m_new->m_ext.ext_ref = wb_bfree; + m_new->m_data = c->wb_buf; + m_new->m_pkthdr.len = m_new->m_len = WB_BUFBYTES; + MEXTADD(m_new, c->wb_buf, WB_BUFBYTES, wb_bfree, NULL); } else { m_new = m; m_new->m_len = m_new->m_pkthdr.len = WB_BUFBYTES; |