git: b919bf05966c - main - cxgbe: Move helper functions for mbuf metadata to adapter.h.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Feb 2023 17:08:17 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=b919bf05966c34cef8e02451ff1dfe9eec0f9cbd
commit b919bf05966c34cef8e02451ff1dfe9eec0f9cbd
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-02-17 17:06:12 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-02-17 17:06:12 +0000
cxgbe: Move helper functions for mbuf metadata to adapter.h.
Previously private to t4_sge.c, this allows other parts of the driver
(such as NIC TLS) to use these helpers directly.
Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D38578
---
sys/dev/cxgbe/adapter.h | 58 +++++++++++++++++++++++++++++++++++++++++++++
sys/dev/cxgbe/t4_sge.c | 63 -------------------------------------------------
2 files changed, 58 insertions(+), 63 deletions(-)
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index b470d1a6461c..7076b1cf781a 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -1118,6 +1118,64 @@ hw_off_limits(struct adapter *sc)
return (__predict_false(off_limits != 0));
}
+static inline int
+mbuf_nsegs(struct mbuf *m)
+{
+ M_ASSERTPKTHDR(m);
+ KASSERT(m->m_pkthdr.inner_l5hlen > 0,
+ ("%s: mbuf %p missing information on # of segments.", __func__, m));
+
+ return (m->m_pkthdr.inner_l5hlen);
+}
+
+static inline void
+set_mbuf_nsegs(struct mbuf *m, uint8_t nsegs)
+{
+ M_ASSERTPKTHDR(m);
+ m->m_pkthdr.inner_l5hlen = nsegs;
+}
+
+/* Internal mbuf flags stored in PH_loc.eight[1]. */
+#define MC_NOMAP 0x01
+#define MC_RAW_WR 0x02
+#define MC_TLS 0x04
+
+static inline int
+mbuf_cflags(struct mbuf *m)
+{
+ M_ASSERTPKTHDR(m);
+ return (m->m_pkthdr.PH_loc.eight[4]);
+}
+
+static inline void
+set_mbuf_cflags(struct mbuf *m, uint8_t flags)
+{
+ M_ASSERTPKTHDR(m);
+ m->m_pkthdr.PH_loc.eight[4] = flags;
+}
+
+static inline int
+mbuf_len16(struct mbuf *m)
+{
+ int n;
+
+ M_ASSERTPKTHDR(m);
+ n = m->m_pkthdr.PH_loc.eight[0];
+ if (!(mbuf_cflags(m) & MC_TLS))
+ MPASS(n > 0 && n <= SGE_MAX_WR_LEN / 16);
+
+ return (n);
+}
+
+static inline void
+set_mbuf_len16(struct mbuf *m, uint8_t len16)
+{
+ M_ASSERTPKTHDR(m);
+ if (!(mbuf_cflags(m) & MC_TLS))
+ MPASS(len16 > 0 && len16 <= SGE_MAX_WR_LEN / 16);
+ m->m_pkthdr.PH_loc.eight[0] = len16;
+}
+
static inline uint32_t
t4_read_reg(struct adapter *sc, uint32_t reg)
{
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index ad3cb63dade4..94fc705bd1d4 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -87,11 +87,6 @@ __FBSDID("$FreeBSD$");
#define RX_COPY_THRESHOLD MINCLSIZE
#endif
-/* Internal mbuf flags stored in PH_loc.eight[1]. */
-#define MC_NOMAP 0x01
-#define MC_RAW_WR 0x02
-#define MC_TLS 0x04
-
/*
* Ethernet frames are DMA'd at this byte offset into the freelist buffer.
* 0-7 are valid values.
@@ -2284,64 +2279,6 @@ t4_update_fl_bufsize(struct ifnet *ifp)
#endif
}
-static inline int
-mbuf_nsegs(struct mbuf *m)
-{
-
- M_ASSERTPKTHDR(m);
- KASSERT(m->m_pkthdr.inner_l5hlen > 0,
- ("%s: mbuf %p missing information on # of segments.", __func__, m));
-
- return (m->m_pkthdr.inner_l5hlen);
-}
-
-static inline void
-set_mbuf_nsegs(struct mbuf *m, uint8_t nsegs)
-{
-
- M_ASSERTPKTHDR(m);
- m->m_pkthdr.inner_l5hlen = nsegs;
-}
-
-static inline int
-mbuf_cflags(struct mbuf *m)
-{
-
- M_ASSERTPKTHDR(m);
- return (m->m_pkthdr.PH_loc.eight[4]);
-}
-
-static inline void
-set_mbuf_cflags(struct mbuf *m, uint8_t flags)
-{
-
- M_ASSERTPKTHDR(m);
- m->m_pkthdr.PH_loc.eight[4] = flags;
-}
-
-static inline int
-mbuf_len16(struct mbuf *m)
-{
- int n;
-
- M_ASSERTPKTHDR(m);
- n = m->m_pkthdr.PH_loc.eight[0];
- if (!(mbuf_cflags(m) & MC_TLS))
- MPASS(n > 0 && n <= SGE_MAX_WR_LEN / 16);
-
- return (n);
-}
-
-static inline void
-set_mbuf_len16(struct mbuf *m, uint8_t len16)
-{
-
- M_ASSERTPKTHDR(m);
- if (!(mbuf_cflags(m) & MC_TLS))
- MPASS(len16 > 0 && len16 <= SGE_MAX_WR_LEN / 16);
- m->m_pkthdr.PH_loc.eight[0] = len16;
-}
-
#ifdef RATELIMIT
static inline int
mbuf_eo_nsegs(struct mbuf *m)