Page MenuHomeFreeBSD

iflib: Plumb per-packet RX hardware timestamps from drivers to mbufs
ClosedPublic

Authored by kbowling on Aug 4 2026, 9:08 AM.
Tags
None
Referenced Files
F170707215: D58638.diff
Sun, Sep 6, 3:24 AM
F170694520: D58638.id184674.diff
Sun, Sep 6, 1:49 AM
Unknown Object (File)
Sat, Sep 5, 10:07 AM
Unknown Object (File)
Fri, Sep 4, 9:22 AM
Unknown Object (File)
Thu, Sep 3, 1:43 AM
Unknown Object (File)
Thu, Sep 3, 12:15 AM
Unknown Object (File)
Wed, Sep 2, 8:01 PM
Unknown Object (File)
Wed, Sep 2, 7:32 PM

Details

Summary
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 for
out-of-tree iflib drivers.

Suggested by:   gallatin
Signed-off-by:  Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Differential Revision: https://reviews.freebsd.org/D58638

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

gallatin requested changes to this revision.Aug 4 2026, 8:04 PM
gallatin added inline comments.
sys/net/iflib.h
90

All other fields are iri_$NAME. Please follow that convention here.

91

I really don't like this.

We already have iri_flags which is used only for M_VLANTAG.

I'd prefer you expand the existing iri_flags to a uint32_t and define
#define IFLIB_IRI_VALID_FLAGS (M_VLANTAG|M_TSTMP|M_TSTMP_HPREC)

And do:
m->m_flags |= IFLIB_IRI_VALID_FLAGS & ri->iri_flags

Then you can get rid of IFLIB_RX_TIMESTAMP and just check for IFLIB_IRI_VALID_FLAGS being defined in your driver.

This revision now requires changes to proceed.Aug 4 2026, 8:04 PM
sys/net/iflib.h
91

Agreed, will fix it up in next revision.

Thank you for doing this. I want to eventually add some 1588 stuff to some drivers so this will be a prerequisite. Consider documenting in iflibtxtx(9).

sys/net/iflib.h
92

might consider s/RX HW timestamp/Nanoseconds since boot/ to document the unit succinctly here since the free running clock may be different, Rx is obvious from the struct type.

iflibtxrx(9) needs updating for this feature.

And since this breaks binary compat for drivers, you also need to bump __FreeBSD_version in sys/sys/param.h

sys/net/iflib.h
92

Can you move this up to be just after iri_frags? By putting it here, you're creating a 4 byte alignment hole between iri_csum_data and the timestamp

kbowling commandeered this revision.EditedWed, Sep 2, 8:38 PM

@sumit.saxena_broadcom.com I'm going to help this along since it just needs some trivial changes to land, I will retain you as the author

kbowling edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Thu, Sep 3, 12:29 AM

@sumit.saxena_broadcom.com I'm going to help this along since it just needs some trivial changes to land, I will retain you as the author

Thank you !