Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177784440
D60987.1795276126.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
8 KB
Referenced Files
None
Subscribers
None
D60987.1795276126.diff
View Options
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -51,6 +51,9 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20261102: mbuf_test removed
+OLD_FILES+=usr/tests/sys/sys/mbuf_test
+
# 20261020: Regenerate trust store
OLD_FILES+=usr/share/certs/trusted/Atos_TrustedRoot_2011.pem
OLD_FILES+=usr/share/certs/trusted/SecureSign_Root_CA12.pem
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -2160,7 +2160,7 @@
#if defined(INET) || defined(INET6)
if (rxq->iq.flags & IQ_LRO_ENABLED &&
- (m0->m_pkthdr.rsstype & M_HASHTYPE_INNER) == 0 &&
+ (m0->m_pkthdr.rssflags & M_HASHFLAG_INNER) == 0 &&
(M_HASHTYPE_GET(m0) == M_HASHTYPE_RSS_TCP_IPV4 ||
M_HASHTYPE_GET(m0) == M_HASHTYPE_RSS_TCP_IPV6)) {
if (sort_before_lro(lro)) {
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -897,7 +897,6 @@
void
m_adj_decap(struct mbuf *mp, int len)
{
- uint8_t rsstype;
m_adj(mp, len);
if ((mp->m_flags & M_PKTHDR) != 0) {
@@ -908,9 +907,8 @@
* internals of m_adj, which keeps pkthdr as is, in
* particular not changing rsstype and flowid.
*/
- rsstype = mp->m_pkthdr.rsstype;
- if ((rsstype & M_HASHTYPE_INNER) != 0) {
- M_HASHTYPE_SET(mp, rsstype & ~M_HASHTYPE_INNER);
+ if ((mp->m_pkthdr.rssflags & M_HASHFLAG_INNER) != 0) {
+ mp->m_pkthdr.rssflags &= ~M_HASHFLAG_INNER;
} else {
M_HASHTYPE_CLEAR(mp);
}
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -1260,6 +1260,7 @@
m0->m_pkthdr.csum_flags = 0;
m0->m_pkthdr.fibnum = 0;
m0->m_pkthdr.rsstype = 0;
+ m0->m_pkthdr.rssflags = 0;
}
if (ctrl_last)
ctrl_last->m_next = m0; /* concatenate data to control */
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1034,6 +1034,7 @@
m->m_pkthdr.csum_flags = 0;
m->m_pkthdr.fibnum = 0;
m->m_pkthdr.rsstype = 0;
+ m->m_pkthdr.rssflags = 0;
mc_init_m(mc, m);
MPASS(m->m_pkthdr.len == mc->mc_len);
diff --git a/sys/net/iflib.h b/sys/net/iflib.h
--- a/sys/net/iflib.h
+++ b/sys/net/iflib.h
@@ -91,7 +91,7 @@
uint32_t iri_csum_data; /* m_pkthdr csum data */
uint32_t iri_flags; /* see IFLIB_IRI_VALID_FLAGS */
uint8_t iri_nfrags; /* number of fragments in packet */
- uint8_t iri_rsstype; /* RSS hash type */
+ enum m_hashtype iri_rsstype:4; /* RSS hash type */
uint8_t iri_pad; /* any padding in the received data */
} *if_rxd_info_t;
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -165,7 +165,23 @@
uint32_t csum_flags; /* checksum and offload features */
uint16_t fibnum; /* this packet should use this fib */
uint8_t numa_domain; /* NUMA domain of recvd pkt */
- uint8_t rsstype; /* hash type */
+ enum m_hashtype { /* Microsoft RSS standard hash types */
+ M_HASHTYPE_NONE = 0,
+ M_HASHTYPE_OPAQUE = 1, /* not a hash, ordering */
+ M_HASHTYPE_RSS_IPV4 = 2, /* IPv4 2-tuple */
+ M_HASHTYPE_RSS_TCP_IPV4 = 3, /* TCPv4 4-tuple */
+ M_HASHTYPE_RSS_IPV6 = 4, /* IPv6 2-tuple */
+ M_HASHTYPE_RSS_TCP_IPV6 = 5, /* TCPv6 4-tuple */
+ M_HASHTYPE_RSS_IPV6_EX = 6, /* IPv6 2-tuple + ext hdrs */
+ M_HASHTYPE_RSS_TCP_IPV6_EX = 7, /* TCPv6 4-tuple + ext hdrs */
+ M_HASHTYPE_RSS_UDP_IPV4 = 8, /* IPv4 UDP 4-tuple*/
+ M_HASHTYPE_RSS_UDP_IPV6 = 9, /* IPv6 UDP 4-tuple*/
+ M_HASHTYPE_RSS_UDP_IPV6_EX = 10, /* UDPv6 4-tuple + ext hdrs */
+ M_HASHTYPE_OPAQUE_HASH = 11,
+ } rsstype:4;
+ enum m_hashflags {
+ M_HASHFLAG_INNER = (1<<0),
+ } rssflags:4;
#if !defined(__LP64__)
uint32_t pad; /* pad for 64bit alignment */
#endif
@@ -524,6 +540,7 @@
"\27M_PROTO10\28M_PROTO11"
#define M_FLAG_PRINTF (M_FLAG_BITS M_FLAG_PROTOBITS)
+#ifdef _KERNEL
/*
* Network interface cards are able to hash protocol fields (such as IPv4
* addresses and TCP port numbers) classify packets into flows. These flows
@@ -551,54 +568,33 @@
* Quoted from:
* https://docs.microsoft.com/en-us/windows-hardware/drivers/network/rss-hashing-types#ndishashipv6ex
*/
-#define M_HASHTYPE_HASHPROP 0x80 /* has hash properties */
-#define M_HASHTYPE_INNER 0x40 /* calculated from inner headers */
-#define M_HASHTYPE_HASH(t) (M_HASHTYPE_HASHPROP | (t))
-/* Microsoft RSS standard hash types */
-#define M_HASHTYPE_NONE 0
-#define M_HASHTYPE_RSS_IPV4 M_HASHTYPE_HASH(1) /* IPv4 2-tuple */
-#define M_HASHTYPE_RSS_TCP_IPV4 M_HASHTYPE_HASH(2) /* TCPv4 4-tuple */
-#define M_HASHTYPE_RSS_IPV6 M_HASHTYPE_HASH(3) /* IPv6 2-tuple */
-#define M_HASHTYPE_RSS_TCP_IPV6 M_HASHTYPE_HASH(4) /* TCPv6 4-tuple */
-#define M_HASHTYPE_RSS_IPV6_EX M_HASHTYPE_HASH(5) /* IPv6 2-tuple +
- * ext hdrs */
-#define M_HASHTYPE_RSS_TCP_IPV6_EX M_HASHTYPE_HASH(6) /* TCPv6 4-tuple +
- * ext hdrs */
-#define M_HASHTYPE_RSS_UDP_IPV4 M_HASHTYPE_HASH(7) /* IPv4 UDP 4-tuple*/
-#define M_HASHTYPE_RSS_UDP_IPV6 M_HASHTYPE_HASH(9) /* IPv6 UDP 4-tuple*/
-#define M_HASHTYPE_RSS_UDP_IPV6_EX M_HASHTYPE_HASH(10)/* IPv6 UDP 4-tuple +
- * ext hdrs */
-
-#define M_HASHTYPE_OPAQUE 0x3f /* ordering, not affinity */
-#define M_HASHTYPE_OPAQUE_HASH M_HASHTYPE_HASH(M_HASHTYPE_OPAQUE)
- /* ordering+hash, not affinity*/
-
-#define M_HASHTYPE_CLEAR(m) ((m)->m_pkthdr.rsstype = 0)
-#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype & ~M_HASHTYPE_INNER)
-#define M_HASHTYPE_SET(m, v) ((m)->m_pkthdr.rsstype = (v))
+#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype)
+#define M_HASHTYPE_SET(m, v) do { \
+ (m)->m_pkthdr.rsstype = (v); \
+ (m)->m_pkthdr.rssflags = 0; \
+} while (0)
+#define M_HASHTYPE_CLEAR(m) M_HASHTYPE_SET(m, M_HASHTYPE_NONE)
#define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v))
-#define M_HASHTYPE_ISHASH(m) \
- (((m)->m_pkthdr.rsstype & M_HASHTYPE_HASHPROP) != 0)
+#define M_HASHTYPE_ISHASH(m) (M_HASHTYPE_GET(m) > M_HASHTYPE_OPAQUE)
-static inline int
+static inline bool
m_hashtype_ishash_tcp(const struct mbuf *m)
{
-
- /* Hash types are encoded values, not independent bits. */
switch (M_HASHTYPE_GET(m)) {
case M_HASHTYPE_RSS_TCP_IPV4:
case M_HASHTYPE_RSS_TCP_IPV6:
case M_HASHTYPE_RSS_TCP_IPV6_EX:
- return (1);
+ return (true);
default:
- return (0);
+ return (false);
}
}
#define M_HASHTYPE_ISHASH_TCP(m) m_hashtype_ishash_tcp(m)
#define M_HASHTYPE_SETINNER(m) do { \
- (m)->m_pkthdr.rsstype |= M_HASHTYPE_INNER; \
+ (m)->m_pkthdr.rssflags |= M_HASHFLAG_INNER; \
} while (0)
+#endif /* _KERNEL */
/*
* External mbuf storage buffer types.
diff --git a/tests/sys/sys/Makefile b/tests/sys/sys/Makefile
--- a/tests/sys/sys/Makefile
+++ b/tests/sys/sys/Makefile
@@ -6,7 +6,6 @@
bitset_test \
bitstring_test \
buf_ring_test \
- mbuf_test \
qmath_test \
queue_test \
rb_test \
diff --git a/tests/sys/sys/mbuf_test.c b/tests/sys/sys/mbuf_test.c
deleted file mode 100644
--- a/tests/sys/sys/mbuf_test.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2026 Kevin Bowling
- */
-
-#include <sys/param.h>
-#include <sys/mbuf.h>
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include <atf-c.h>
-
-ATF_TC_WITHOUT_HEAD(hashtype_ishash_tcp);
-ATF_TC_BODY(hashtype_ishash_tcp, tc)
-{
- static const bool expected[UINT8_MAX + 1] = {
- [M_HASHTYPE_RSS_TCP_IPV4] = true,
- [M_HASHTYPE_RSS_TCP_IPV6] = true,
- [M_HASHTYPE_RSS_TCP_IPV6_EX] = true,
- [M_HASHTYPE_RSS_TCP_IPV4 | M_HASHTYPE_INNER] = true,
- [M_HASHTYPE_RSS_TCP_IPV6 | M_HASHTYPE_INNER] = true,
- [M_HASHTYPE_RSS_TCP_IPV6_EX | M_HASHTYPE_INNER] = true,
- };
- struct mbuf m = { 0 };
-
- /* Only TCP four-tuple hashes qualify, including inner-header hashes. */
- for (u_int type = 0; type < nitems(expected); type++) {
- M_HASHTYPE_SET(&m, type);
- ATF_CHECK_MSG(!!M_HASHTYPE_ISHASH_TCP(&m) == expected[type],
- "hash type %#x: expected %d", type, expected[type]);
- }
-}
-
-ATF_TC_WITHOUT_HEAD(hashtype_ishash_tcp_evaluate_once);
-ATF_TC_BODY(hashtype_ishash_tcp_evaluate_once, tc)
-{
- struct mbuf mbufs[3] = { 0 };
- const struct mbuf *m;
-
- m = mbufs;
- ATF_CHECK(!M_HASHTYPE_ISHASH_TCP(m++));
- ATF_CHECK(m == &mbufs[1]);
-}
-
-ATF_TP_ADD_TCS(tp)
-{
- ATF_TP_ADD_TC(tp, hashtype_ishash_tcp);
- ATF_TP_ADD_TC(tp, hashtype_ishash_tcp_evaluate_once);
-
- return (atf_no_error());
-}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 3:48 PM (23 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41891788
Default Alt Text
D60987.1795276126.diff (8 KB)
Attached To
Mode
D60987: mbuf: declare mbuf hash types as distinct types, not flags
Attached
Detach File
Event Timeline