-/* uipc_mbuf.c 1.34 82/05/19 */
+/* uipc_mbuf.c 1.43 83/05/27 */
+
+#include "../machine/pte.h"
#include "../h/param.h"
#include "../h/dir.h"
#include "../h/user.h"
#include "../h/proc.h"
-#include "../h/pte.h"
#include "../h/cmap.h"
#include "../h/map.h"
#include "../h/mbuf.h"
-#include "../net/in_systm.h" /* XXX */
#include "../h/vm.h"
+#include "../h/kernel.h"
mbinit()
{
-COUNT(MBINIT);
- if (m_reserve(32) == 0)
- goto bad;
- if (m_clalloc(4, MPG_MBUFS) == 0)
+ if (m_clalloc(4096/CLBYTES, MPG_MBUFS) == 0)
goto bad;
- if (m_clalloc(32, MPG_CLUSTERS) == 0)
+ if (m_clalloc(8*4096/CLBYTES, MPG_CLUSTERS) == 0)
goto bad;
return;
bad:
register int i;
int s;
-COUNT(M_CLALLOC);
npg = ncl * CLSIZE;
s = splimp(); /* careful: rmalloc isn't reentrant */
- mbx = rmalloc(mbmap, npg);
+ mbx = rmalloc(mbmap, (long)npg);
splx(s);
if (mbx == 0)
return (0);
m = cltom(mbx / CLSIZE);
- if (memall(&Mbmap[mbx], npg, proc, CSYS) == 0)
+ if (memall(&Mbmap[mbx], npg, proc, CSYS) == 0) {
+ s = splimp();
+ rmfree(mbmap, (long)npg, (long)mbx);
+ splx(s);
return (0);
+ }
vmaccess(&Mbmap[mbx], (caddr_t)m, npg);
switch (how) {
case MPG_MBUFS:
for (i = ncl * CLBYTES / sizeof (*m); i > 0; i--) {
m->m_off = 0;
- m->m_free = 0;
+ m->m_type = MT_DATA;
+ mbstat.m_mtypes[MT_DATA]++;
mbstat.m_mbufs++;
(void) m_free(m);
m++;
int n;
{
-COUNT(M_PGFREE);
#ifdef lint
addr = addr; n = n;
#endif
m_expand()
{
-COUNT(M_EXPAND);
if (m_clalloc(1, MPG_MBUFS) == 0)
goto steal;
return (1);
/* NEED SOME WAY TO RELEASE SPACE */
-/*
- * Space reservation routines
- */
-m_reserve(mbufs)
- int mbufs;
-{
-
- if (mbstat.m_mbcommitted + mbufs >
- (nmbclusters * NMBPCL) * MBUFOVERALLOCFRACTION)
- return (0);
- mbstat.m_mbcommitted += mbufs;
- return (1);
-}
-
-m_release(mbufs)
- int mbufs;
-{
-
- mbstat.m_mbcommitted -= mbufs;
-}
-
/*
* Space allocation routines.
* These are also available as macros
* for critical paths.
*/
struct mbuf *
-m_get(canwait)
- int canwait;
+m_get(canwait, type)
+ int canwait, type;
{
register struct mbuf *m;
-COUNT(M_GET);
- MGET(m, canwait);
+ MGET(m, canwait, type);
return (m);
}
struct mbuf *
-m_getclr(canwait)
- int canwait;
+m_getclr(canwait, type)
+ int canwait, type;
{
register struct mbuf *m;
-COUNT(M_GETCLR);
- m = m_get(canwait);
+ m = m_get(canwait, type);
if (m == 0)
return (0);
- m->m_off = MMINOFF;
bzero(mtod(m, caddr_t), MLEN);
return (m);
}
{
register struct mbuf *n;
-COUNT(M_FREE);
MFREE(m, n);
return (n);
}
/*ARGSUSED*/
struct mbuf *
-m_more(type)
- int type;
+m_more(canwait, type)
+ int canwait, type;
{
register struct mbuf *m;
-COUNT(M_MORE);
if (!m_expand()) {
mbstat.m_drops++;
return (NULL);
}
-#define m_more(x) (panic("m_more"), (struct mbuf *)0)
- MGET(m, type);
+#define m_more(x,y) (panic("m_more"), (struct mbuf *)0)
+ MGET(m, canwait, type);
#undef m_more
return (m);
}
register struct mbuf *n;
register int s;
-COUNT(M_FREEM);
if (m == NULL)
return;
s = splimp();
{
register struct mbuf *n, **np;
struct mbuf *top, *p;
-COUNT(M_COPY);
+ int type;
if (len == 0)
return (0);
if (off < 0 || len < 0)
panic("m_copy");
+ type = m->m_type;
while (off > 0) {
if (m == 0)
panic("m_copy");
panic("m_copy");
break;
}
- MGET(n, 1);
+ MGET(n, M_WAIT, type);
*np = n;
if (n == 0)
goto nospace;
p = mtod(m, struct mbuf *);
n->m_off = ((int)p - (int)n) + off;
mclrefcnt[mtocl(p)]++;
- } else {
- n->m_off = MMINOFF;
+ } else
bcopy(mtod(m, caddr_t)+off, mtod(n, caddr_t),
(unsigned)n->m_len);
- }
if (len != M_COPYALL)
len -= n->m_len;
off = 0;
{
register struct mbuf *m, *n;
-COUNT(M_ADJ);
if ((m = mp) == NULL)
return;
if (len >= 0) {
n = m0;
if (len > MLEN)
goto bad;
- MGET(m, 0);
+ MGET(m, M_DONTWAIT, n->m_type);
if (m == 0)
goto bad;
- m->m_off = MMINOFF;
m->m_len = 0;
do {
count = MIN(MLEN - m->m_len, len);