/* mbuf.h 4.13 82/06/14 */
* Constants related to memory allocator.
#define MSIZE 128 /* size of an mbuf */
#define MMINOFF 12 /* mbuf header length */
#define MMAXOFF (MSIZE-MTAIL) /* offset where data ends */
#define MLEN (MSIZE-MMINOFF-MTAIL) /* mbuf data length */
#define NMBPCL (CLBYTES/MSIZE) /* # mbufs per cluster */
* Macros for type conversion
/* network cluster number to virtual address, and back */
#define cltom(x) ((struct mbuf *)((int)mbutl + ((x) << CLSHIFT)))
#define mtocl(x) (((int)x - (int)mbutl) >> CLSHIFT)
/* address in mbuf to mbuf head */
#define dtom(x) ((struct mbuf *)((int)x & ~(MSIZE-1)))
/* mbuf head, to typed data */
#define mtod(x,t) ((t)((int)(x) + (x)->m_off))
struct mbuf
*m_next
; /* next buffer in chain */
u_long m_off
; /* offset of data */
short m_len
; /* amount of data in this mbuf */
short m_free
; /* is mbuf free? (consistency check) */
u_char m_dat
[MLEN
]; /* data storage */
struct mbuf
*m_act
; /* link in higher-level mbuf list */
#define MPG_MBUFS 0 /* put new mbufs on free list */
#define MPG_CLUSTERS 1 /* put new clusters on free list */
#define MPG_SPACE 2 /* don't free; caller wants space */
/* length to m_copy to copy all */
#define M_COPYALL 1000000000
{ if ((m)->m_free == 0) panic("mget"); (m)->m_free = 0; \
mbstat.m_mbfree--; mfree = (m)->m_next; (m)->m_next = 0; } \
{++mclrefcnt[mtocl(m)];mbstat.m_clfree--;mclfree = (m)->m_next;} \
if ((m)->m_free) panic("mfree"); (m)->m_free = 1; \
if ((m)->m_off > MSIZE) { \
(n) = (struct mbuf *)(mtod(m, int)&~0x3ff); \
if (--mclrefcnt[mtocl(n)] == 0) \
{ (n)->m_next = mclfree;mclfree = (n);mbstat.m_clfree++;} \
(n) = (m)->m_next; (m)->m_next = mfree; \
(m)->m_off = 0; (m)->m_act = 0; mfree = (m); mbstat.m_mbfree++; \
short m_mbufs
; /* mbufs obtained from page pool */
short m_mbfree
; /* mbufs on our free list */
short m_clusters
; /* clusters obtained from page pool */
short m_clfree
; /* free clusters */
short m_drops
; /* times failed to find space */
extern struct mbuf mbutl
[]; /* virtual address of net free mem */
extern struct pte Mbmap
[]; /* page tables to map Netutl */
struct mbuf
*mfree
, *mclfree
;
char mclrefcnt
[NMBCLUSTERS
];
struct mbuf
*m_get(),*m_getclr(),*m_free(),*m_more(),*m_copy(),*m_pullup();