diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h b/sys/compat/linuxkpi/common/include/linux/skbuff.h --- a/sys/compat/linuxkpi/common/include/linux/skbuff.h +++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h @@ -154,7 +154,9 @@ }; struct list_head list; }; +#ifdef SKB_DMA32_MALLOC uint32_t _alloc_len; /* Length of alloc data-buf. XXX-BZ give up for truesize? */ +#endif uint32_t len; /* ? */ uint32_t data_len; /* ? If we have frags? */ uint32_t truesize; /* The total size of all buffers, incl. frags. */ @@ -166,8 +168,8 @@ uint16_t qmap; /* queue mapping */ uint16_t _flags; /* Internal flags. */ #define _SKB_FLAGS_SKBEXTFRAG 0x0001 - enum sk_buff_pkt_type pkt_type; uint16_t mac_header; /* offset of mac_header */ + enum sk_buff_pkt_type pkt_type; refcount_t refcnt; /* "Scratch" area for layers to store metadata. */ diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -6356,9 +6356,9 @@ goto no_trace_beacons; if (linuxkpi_debug_80211 & D80211_TRACE_RX) - printf("TRACE-RX: %s: skb %p a/l/d/t-len (%u/%u/%u/%u) " + printf("TRACE-RX: %s: skb %p l/d/t-len (%u/%u/%u) " "h %p d %p t %p e %p sh %p (%u) m %p plen %u len %u%s\n", - __func__, skb, skb->_alloc_len, skb->len, skb->data_len, + __func__, skb, skb->len, skb->data_len, skb->truesize, skb->head, skb->data, skb->tail, skb->end, shinfo, shinfo->nr_frags, m, m->m_pkthdr.len, m->m_len, is_beacon ? " beacon" : ""); diff --git a/sys/compat/linuxkpi/common/src/linux_skbuff.c b/sys/compat/linuxkpi/common/src/linux_skbuff.c --- a/sys/compat/linuxkpi/common/src/linux_skbuff.c +++ b/sys/compat/linuxkpi/common/src/linux_skbuff.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2020-2022 The FreeBSD Foundation + * Copyright (c) 2020-2025 The FreeBSD Foundation * Copyright (c) 2021-2022 Bjoern A. Zeeb * * This software was developed by Björn Zeeb under sponsorship from @@ -63,6 +63,7 @@ &linuxkpi_debug_skb, 0, "SKB debug level"); #endif +#ifdef SKB_DMA32_MALLOC #ifdef __LP64__ /* * Realtek wireless drivers (e.g., rtw88) require 32bit DMA in a single segment. @@ -71,6 +72,9 @@ * Work around this for now by allowing a tunable to enforce physical addresses * allocation limits on 64bit platforms using "old-school" contigmalloc(9) to * avoid bouncing. + * Note: with the malloc + kmalloc changes also providing contig physical + * memory, and the nseg=1 limit for bouncing we should in theory be fine now + * and not need any of this anymore. */ static int linuxkpi_skb_memlimit; SYSCTL_INT(_compat_linuxkpi_skb, OID_AUTO, mem_limit, CTLFLAG_RDTUN, @@ -79,6 +83,7 @@ #endif static MALLOC_DEFINE(M_LKPISKB, "lkpiskb", "Linux KPI skbuff compat"); +#endif struct sk_buff * linuxkpi_alloc_skb(size_t size, gfp_t gfp) @@ -91,6 +96,7 @@ * Using our own type here not backing my kmalloc. * We assume no one calls kfree directly on the skb. */ +#ifdef SKB_DMA32_MALLOC #ifdef __LP64__ if (__predict_true(linuxkpi_skb_memlimit == 0)) { skb = malloc(len, M_LKPISKB, linux_check_m_flags(gfp) | M_ZERO); @@ -112,10 +118,15 @@ } #else skb = malloc(len, M_LKPISKB, linux_check_m_flags(gfp) | M_ZERO); +#endif +#else /* !SKB_DMA32_MALLOC */ + skb = __kmalloc(len, linux_check_m_flags(gfp) | M_ZERO); #endif if (skb == NULL) return (skb); +#ifdef SKB_DMA32_MALLOC skb->_alloc_len = len; +#endif skb->truesize = size; skb->head = skb->data = skb->tail = (uint8_t *)(skb+1); @@ -258,6 +269,7 @@ skb_free_frag(p); } +#ifdef SKB_DMA32_MALLOC #ifdef __LP64__ if (__predict_true(linuxkpi_skb_memlimit == 0)) free(skb, M_LKPISKB); @@ -266,6 +278,9 @@ #else free(skb, M_LKPISKB); #endif +#else + kfree(skb); +#endif } #ifdef DDB @@ -284,9 +299,11 @@ db_printf("skb %p\n", skb); db_printf("\tnext %p prev %p\n", skb->next, skb->prev); db_printf("\tlist %p\n", &skb->list); - db_printf("\t_alloc_len %u len %u data_len %u truesize %u mac_len %u\n", - skb->_alloc_len, skb->len, skb->data_len, skb->truesize, - skb->mac_len); +#ifdef SKB_DMA32_MALLOC + db_printf("\t_alloc_len %u\n", skb->_alloc_len); +#endif + db_printf("\tlen %u data_len %u truesize %u mac_len %u\n", + skb->len, skb->data_len, skb->truesize, skb->mac_len); db_printf("\tcsum %#06x l3hdroff %u l4hdroff %u priority %u qmap %u\n", skb->csum, skb->l3hdroff, skb->l4hdroff, skb->priority, skb->qmap); db_printf("\tpkt_type %d dev %p sk %p\n",