freebsd_network: Implement m_cljget without mbuf.

This returns an ext_buf that can be attached to an mbuf later,
which is something iflib does.
This commit is contained in:
Augustin Cavalier
2019-01-03 21:20:34 -05:00
parent a9116ea8db
commit 8582775421
+20 -8
View File
@@ -65,8 +65,8 @@ m_init(struct mbuf *m, int how, short type, int flags)
} }
static int static void*
construct_ext_sized_mbuf(struct mbuf *memoryBuffer, int how, int size) allocate_ext_buf(int how, int size, int* ext_type)
{ {
object_cache *cache; object_cache *cache;
int extType; int extType;
@@ -84,7 +84,18 @@ construct_ext_sized_mbuf(struct mbuf *memoryBuffer, int how, int size)
extType = EXT_JUMBOP; extType = EXT_JUMBOP;
} }
memoryBuffer->m_ext.ext_buf = object_cache_alloc(cache, m_to_oc_flags(how)); if (ext_type != NULL)
*ext_type = extType;
return object_cache_alloc(cache, m_to_oc_flags(how));
}
static int
construct_ext_sized_mbuf(struct mbuf *memoryBuffer, int how, int size)
{
int extType;
memoryBuffer->m_ext.ext_buf = allocate_ext_buf(how, size, &extType);
if (memoryBuffer->m_ext.ext_buf == NULL) if (memoryBuffer->m_ext.ext_buf == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -209,17 +220,18 @@ m_clget(struct mbuf *memoryBuffer, int how)
} }
void * void*
m_cljget(struct mbuf *memoryBuffer, int how, int size) m_cljget(struct mbuf* memoryBuffer, int how, int size)
{ {
if (memoryBuffer == NULL) if (memoryBuffer == NULL)
panic("m_cljget doesn't support allocate mbuf"); return allocate_ext_buf(how, size, NULL);
memoryBuffer->m_ext.ext_buf = NULL; memoryBuffer->m_ext.ext_buf = NULL;
construct_ext_sized_mbuf(memoryBuffer, how, size); construct_ext_sized_mbuf(memoryBuffer, how, size);
/* shouldn't be used */ return memoryBuffer->m_ext.ext_buf;
return NULL;
} }
static void static void
mb_free_ext(struct mbuf *memoryBuffer) mb_free_ext(struct mbuf *memoryBuffer)
{ {