git: ae25b4889309 - stable/15 - iflib: Plumb per-packet RX hardware timestamps to mbufs

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 23:37:06 UTC
The branch stable/15 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=ae25b4889309623a1015d95acfaf5ed13447380b

commit ae25b4889309623a1015d95acfaf5ed13447380b
Author:     Sumit Saxena <ssaxena@FreeBSD.org>
AuthorDate: 2026-09-02 19:36:43 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-29 22:53:00 +0000

    iflib: Plumb per-packet RX hardware timestamps to mbufs
    
    Add iri_rcv_tstmp to if_rxd_info so an isc_rxd_pkt_get() driver can
    report a hardware RX timestamp.  Copy it into m_pkthdr.rcv_tstmp,
    reusing the generic mbuf timestamp path.
    
    Widen iri_flags from uint8_t to uint32_t and define the flags drivers
    may supply.  Mask the flags before copying them into the mbuf so no
    other mbuf state can leak through the driver callback.
    
    Place the timestamp next to iri_frags to avoid an alignment hole, and
    document its nanoseconds-since-boot representation and validity flags.
    Bump __FreeBSD_version because changing if_rxd_info breaks KBI.
    
    Reviewed by:    gallatin
    Signed-off-by:  Sreekanth Reddy <sreekanth.reddy@broadcom.com>
    Differential Revision:  https://reviews.freebsd.org/D58638
    
    (cherry picked from commit 3c928ccadbb5d7baa3ce18d33d09d9a1d2770397)
---
 UPDATING                   |  4 ++++
 share/man/man9/iflibtxrx.9 | 22 ++++++++++++++++++----
 sys/net/iflib.c            |  3 ++-
 sys/net/iflib.h            | 10 +++++++++-
 sys/sys/param.h            |  2 +-
 5 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/UPDATING b/UPDATING
index 2f056ee9d47e..9116e396bb8f 100644
--- a/UPDATING
+++ b/UPDATING
@@ -12,6 +12,10 @@ Items affecting the ports and packages system can be found in
 /usr/ports/UPDATING.  Please read that file before updating system packages
 and/or ports.
 
+20261029:
+	struct if_rxd_info now carries a receive timestamp.  iflib drivers
+	must be rebuilt.  __FreeBSD_version has been bumped to 1501506.
+
 20260925:
 	less(1) has been updated to version 710, which removes the obsolete
 	lesskey(1) utility.  It is no longer built or installed, and the
diff --git a/share/man/man9/iflibtxrx.9 b/share/man/man9/iflibtxrx.9
index df017dea0130..bbea0a3ed999 100644
--- a/share/man/man9/iflibtxrx.9
+++ b/share/man/man9/iflibtxrx.9
@@ -1,4 +1,4 @@
-.Dd December 17, 2020
+.Dd September 2, 2026
 .Dt IFLIBTXTX 9
 .Os
 .Sh NAME
@@ -154,10 +154,24 @@ consumer queue.
 .It Va iri_flowid
 .Pq Vt "uint32_t"
 Value of the RSS hash for the packet.
+.It Va iri_rcv_tstmp
+.Pq Vt "uint64_t"
+Receive timestamp in nanoseconds since boot.
+The driver must set
+.Dv M_TSTMP
+in
+.Va iri_flags
+when the timestamp is valid, and may additionally set
+.Dv M_TSTMP_HPREC
+when the timestamp was taken by hardware at the port.
 .It Va iri_flags
-.Pq Vt "uint"
- Flags describing the operational parameters of the mbuf contained in the
- receive packet.
+.Pq Vt "uint32_t"
+Flags to copy to the received mbuf.
+Drivers may set only
+.Dv M_VLANTAG ,
+.Dv M_TSTMP ,
+and
+.Dv M_TSTMP_HPREC .
 .It Va iri_csum_flags
 .Pq Vt "uint32_t"
 Flags describing the checksum value contained in the receive packet.
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 718bfc4d6508..8b6fb3fbb9f5 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -3240,7 +3240,7 @@ iflib_rxd_pkt_get(iflib_rxq_t rxq, if_rxd_info_t ri)
 	}
 	m->m_pkthdr.len = ri->iri_len;
 	m->m_pkthdr.rcvif = ri->iri_ifp;
-	m->m_flags |= ri->iri_flags;
+	m->m_flags |= ri->iri_flags & IFLIB_IRI_VALID_FLAGS;
 	m->m_pkthdr.ether_vtag = ri->iri_vtag;
 	m->m_pkthdr.flowid = ri->iri_flowid;
 #ifdef NUMA
@@ -3249,6 +3249,7 @@ iflib_rxd_pkt_get(iflib_rxq_t rxq, if_rxd_info_t ri)
 	M_HASHTYPE_SET(m, ri->iri_rsstype);
 	m->m_pkthdr.csum_flags = ri->iri_csum_flags;
 	m->m_pkthdr.csum_data = ri->iri_csum_data;
+	m->m_pkthdr.rcv_tstmp = ri->iri_rcv_tstmp;
 	return (m);
 }
 
diff --git a/sys/net/iflib.h b/sys/net/iflib.h
index d629e6b3c6b9..9bf1a1d8dbbf 100644
--- a/sys/net/iflib.h
+++ b/sys/net/iflib.h
@@ -66,6 +66,13 @@ typedef struct if_rxd_frag {
 /* bnxt supports 64 with hardware LRO enabled */
 #define IFLIB_MAX_RX_SEGS		64
 
+/*
+ * iri_flags bits an isc_rxd_pkt_get() driver callback is permitted to
+ * set.  iflib masks iri_flags against this set before copying the flags
+ * into an mbuf.
+ */
+#define IFLIB_IRI_VALID_FLAGS	(M_VLANTAG | M_TSTMP | M_TSTMP_HPREC)
+
 typedef struct if_rxd_info {
 	/* set by iflib */
 	uint16_t iri_qsidx;		/* qset index */
@@ -77,11 +84,12 @@ typedef struct if_rxd_info {
 
 	/* updated by driver */
 	if_rxd_frag_t iri_frags;
+	uint64_t iri_rcv_tstmp;		/* nanoseconds since boot */
 	uint32_t iri_flowid;		/* RSS hash for packet */
 	uint32_t iri_csum_flags;	/* m_pkthdr csum flags */
 
 	uint32_t iri_csum_data;		/* m_pkthdr csum data */
-	uint8_t iri_flags;		/* mbuf flags for packet */
+	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 */
 	uint8_t	 iri_pad;		/* any padding in the received data */
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 4b140fc5e4ff..14caee9369a2 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -74,7 +74,7 @@
  * cannot include sys/param.h and should only be updated here.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1501505
+#define __FreeBSD_version 1501506
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,