Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177552072
D61281.1794698087.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D61281.1794698087.diff
View Options
diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -375,6 +375,13 @@
struct netmap_adapter *na = &gna->up.up;
if_t ifp = netmap_generic_getifp(gna);
+ /* Each tx slot is copied into a single mbuf cluster. */
+ if (intercept && NETMAP_BUF_SIZE(na) > NM_GENERIC_MAX_BUF_SIZE) {
+ nm_prerr("%s: buf size %u exceeds emulated mode max %d",
+ na->name, NETMAP_BUF_SIZE(na), NM_GENERIC_MAX_BUF_SIZE);
+ return (EINVAL);
+ }
+
nm_os_ifnet_lock();
if (intercept) {
na->if_transmit = if_gettransmitfn(ifp);
@@ -420,6 +427,9 @@
M_ASSERTPKTHDR(m);
KASSERT((m->m_flags & M_EXT) != 0,
("%s: mbuf %p has no cluster", __func__, m));
+ KASSERT(m->m_ext.ext_size >= len,
+ ("%s: mbuf %p cluster size %u < len %u", __func__, m,
+ m->m_ext.ext_size, len));
if (MBUF_REFCNT(m) != 1) {
nm_prerr("invalid refcnt %d for %p", MBUF_REFCNT(m), m);
diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c
--- a/sys/dev/netmap/netmap_generic.c
+++ b/sys/dev/netmap/netmap_generic.c
@@ -102,9 +102,9 @@
#include <linux/hrtimer.h>
static inline struct mbuf *
-nm_os_get_mbuf(struct ifnet *ifp, int len)
+nm_os_get_mbuf(struct ifnet *ifp, uint32_t size)
{
- return alloc_skb(LL_RESERVED_SPACE(ifp) + len +
+ return alloc_skb(LL_RESERVED_SPACE(ifp) + size +
ifp->needed_tailroom, GFP_ATOMIC);
}
diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h
--- a/sys/dev/netmap/netmap_kern.h
+++ b/sys/dev/netmap/netmap_kern.h
@@ -2414,10 +2414,12 @@
* has a KASSERT(), checking that the mbuf dtor function is not NULL.
*/
+#define NM_GENERIC_MAX_BUF_SIZE MJUM16BYTES
+
static inline void
nm_generic_mbuf_dtor(struct mbuf *m)
{
- uma_zfree(zone_clust, m->m_ext.ext_buf);
+ uma_zfree(m_getzone(m->m_ext.ext_size), m->m_ext.ext_buf);
}
#define SET_MBUF_DESTRUCTOR(m, fn, na) do { \
@@ -2427,22 +2429,33 @@
} while (0)
static inline struct mbuf *
-nm_os_get_mbuf(if_t ifp __unused, int len)
+nm_os_get_mbuf(if_t ifp __unused, uint32_t size)
{
struct mbuf *m;
void *buf;
- KASSERT(len <= MCLBYTES, ("%s: len %d", __func__, len));
+ KASSERT(size <= NM_GENERIC_MAX_BUF_SIZE,
+ ("%s: size %u > %d", __func__, size, NM_GENERIC_MAX_BUF_SIZE));
m = m_gethdr(M_NOWAIT, MT_DATA);
if (__predict_false(m == NULL))
return (NULL);
- buf = uma_zalloc(zone_clust, M_NOWAIT);
+ if (size <= MCLBYTES)
+ size = MCLBYTES;
+#if MJUMPAGESIZE != MCLBYTES
+ else if (size <= MJUMPAGESIZE)
+ size = MJUMPAGESIZE;
+#endif
+ else if (size <= MJUM9BYTES)
+ size = MJUM9BYTES;
+ else
+ size = MJUM16BYTES;
+ buf = uma_zalloc(m_getzone(size), M_NOWAIT);
if (__predict_false(buf == NULL)) {
m_free(m);
return (NULL);
}
- m_extadd(m, buf, MCLBYTES, nm_generic_mbuf_dtor, NULL, NULL, 0,
+ m_extadd(m, buf, size, nm_generic_mbuf_dtor, NULL, NULL, 0,
EXT_NET_DRV);
return (m);
}
@@ -2451,16 +2464,15 @@
nm_os_mbuf_reinit(struct mbuf *m)
{
void *buf;
+ uint32_t size;
KASSERT((m->m_flags & M_EXT) != 0,
("%s: mbuf %p has no external storage", __func__, m));
- KASSERT(m->m_ext.ext_size == MCLBYTES,
- ("%s: mbuf %p has wrong external storage size %u", __func__, m,
- m->m_ext.ext_size));
buf = m->m_ext.ext_buf;
+ size = m->m_ext.ext_size;
m_init(m, M_NOWAIT, MT_DATA, M_PKTHDR);
- m_extadd(m, buf, MCLBYTES, nm_generic_mbuf_dtor, NULL, NULL, 0,
+ m_extadd(m, buf, size, nm_generic_mbuf_dtor, NULL, NULL, 0,
EXT_NET_DRV);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 14, 11:14 PM (18 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41676037
Default Alt Text
D61281.1794698087.diff (3 KB)
Attached To
Mode
D61281: netmap: Handle TX buffers larger than MCLBYTES
Attached
Detach File
Event Timeline