summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mbuf.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2005-12-08 13:13:06 +0000
committerandre <andre@FreeBSD.org>2005-12-08 13:13:06 +0000
commit143b5d29e0d9125ec7b70a1abe48aebb3989b192 (patch)
treeef9ad18ce650bb77fc2801cc4bd0b25200db2c0f /sys/kern/kern_mbuf.c
parent73cd477217779d7ee3e655b770b157dc8923c01c (diff)
downloadFreeBSD-src-143b5d29e0d9125ec7b70a1abe48aebb3989b192.zip
FreeBSD-src-143b5d29e0d9125ec7b70a1abe48aebb3989b192.tar.gz
Add an API for jumbo mbuf cluster allocation and also provide
4k clusters in addition to 9k and 16k ones. struct mbuf *m_getjcl(int how, short type, int flags, int size) void *m_cljget(struct mbuf *m, int how, int size) m_getjcl() returns an mbuf with a cluster of the specified size attached like m_getcl() does for 2k clusters. m_cljget() is different from m_clget() as it can allocate clusters without attaching them to an mbuf. In that case the return value is the pointer to the cluster of the requested size. If an mbuf was specified, it gets the cluster attached to it and the return value can be safely ignored. For size both take MCLBYTES, MJUM4BYTES, MJUM9BYTES, MJUM16BYTES. Reviewed by: glebius Tested by: glebius Sponsored by: TCP/IP Optimization Fundraise 2005
Diffstat (limited to 'sys/kern/kern_mbuf.c')
-rw-r--r--sys/kern/kern_mbuf.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index 9e398cd..2ac069b 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -95,6 +95,7 @@ __FBSDID("$FreeBSD$");
*/
int nmbclusters; /* limits number of mbuf clusters */
+int nmbjumbo4; /* limits number of 4k jumbo clusters */
int nmbjumbo9; /* limits number of 9k jumbo clusters */
int nmbjumbo16; /* limits number of 16k jumbo clusters */
struct mbstat mbstat;
@@ -113,6 +114,8 @@ SYSCTL_DECL(_kern_ipc);
/* XXX: These should be tuneables. Can't change UMA limits on the fly. */
SYSCTL_INT(_kern_ipc, OID_AUTO, nmbclusters, CTLFLAG_RW, &nmbclusters, 0,
"Maximum number of mbuf clusters allowed");
+SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbo4, CTLFLAG_RW, &nmbjumbo4, 0,
+ "Maximum number of mbuf 4k jumbo clusters allowed");
SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbo9, CTLFLAG_RW, &nmbjumbo9, 0,
"Maximum number of mbuf 9k jumbo clusters allowed");
SYSCTL_INT(_kern_ipc, OID_AUTO, nmbjumbo16, CTLFLAG_RW, &nmbjumbo16, 0,
@@ -126,6 +129,7 @@ SYSCTL_STRUCT(_kern_ipc, OID_AUTO, mbstat, CTLFLAG_RD, &mbstat, mbstat,
uma_zone_t zone_mbuf;
uma_zone_t zone_clust;
uma_zone_t zone_pack;
+uma_zone_t zone_jumbo4;
uma_zone_t zone_jumbo9;
uma_zone_t zone_jumbo16;
uma_zone_t zone_ext_refcnt;
@@ -182,7 +186,18 @@ mbuf_init(void *dummy)
zone_pack = uma_zsecond_create(MBUF_PACKET_MEM_NAME, mb_ctor_pack,
mb_dtor_pack, mb_zinit_pack, mb_zfini_pack, zone_mbuf);
- /* Make jumbo frame zone too. 9k and 16k. */
+ /* Make jumbo frame zone too. 4k, 9k and 16k. */
+ zone_jumbo4 = uma_zcreate(MBUF_JUMBO4_MEM_NAME, MJUM4BYTES,
+ mb_ctor_clust, mb_dtor_clust,
+#ifdef INVARIANTS
+ trash_init, trash_fini,
+#else
+ NULL, NULL,
+#endif
+ UMA_ALIGN_PTR, UMA_ZONE_REFCNT);
+ if (nmbjumbo4 > 0)
+ uma_zone_set_max(zone_jumbo4, nmbjumbo4);
+
zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES,
mb_ctor_clust, mb_dtor_clust,
#ifdef INVARIANTS
@@ -363,6 +378,9 @@ mb_ctor_clust(void *mem, int size, void *arg, int how)
case MCLBYTES:
type = EXT_CLUSTER;
break;
+ case MJUM4BYTES:
+ type = EXT_JUMBO4;
+ break;
case MJUM9BYTES:
type = EXT_JUMBO9;
break;
OpenPOWER on IntegriCloud