/* * Initialize the mbuf allocator. */ void mbinit(void) { int i; #if DIAGNOSTIC if (mclsizes[0] != MCLBYTES) panic("mbinit: the smallest cluster size != MCLBYTES"); if (mclsizes[nitems(mclsizes) - 1] != MAXMCLBYTES) panic("mbinit: the largest cluster size != MAXMCLBYTES"); #endif pool_init(&mbpool, MSIZE, 0, 0, 0, "mbufpl", NULL); pool_setipl(&mbpool, IPL_NET); pool_set_constraints(&mbpool, &kp_dma_contig); pool_setlowat(&mbpool, mblowat); pool_init(&mtagpool, PACKET_TAG_MAXSIZE + sizeof(struct m_tag), 0, 0, 0, "mtagpl", NULL); pool_setipl(&mtagpool, IPL_NET); for (i = 0; i < nitems(mclsizes); i++) { snprintf(mclnames[i], sizeof(mclnames[0]), "mcl%dk", mclsizes[i] >> 10); pool_init(&mclpools[i], mclsizes[i], 0, 0, 0, mclnames[i], NULL); pool_setipl(&mclpools[i], IPL_NET); pool_set_constraints(&mclpools[i], &kp_dma_contig); pool_setlowat(&mclpools[i], mcllowat); } nmbclust_update(); }
/* * Initialize the mbuf allocator. */ void mbinit(void) { pool_init(&mbpool, MSIZE, 0, 0, 0, "mbpl", NULL); pool_init(&mclpool, MCLBYTES, 0, 0, 0, "mclpl", NULL); nmbclust_update(); /* * Set a low water mark for both mbufs and clusters. This should * help ensure that they can be allocated in a memory starvation * situation. This is important for e.g. diskless systems which * must allocate mbufs in order for the pagedaemon to clean pages. */ pool_setlowat(&mbpool, mblowat); pool_setlowat(&mclpool, mcllowat); }