Page MenuHomeFreeBSD

iflib: support for transmit side nic KTLS offload
ClosedPublic

Authored by gallatin on Dec 17 2025, 7:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jan 14, 6:44 AM
Unknown Object (File)
Tue, Jan 13, 1:16 PM
Unknown Object (File)
Sat, Jan 10, 4:55 PM
Unknown Object (File)
Tue, Jan 6, 4:26 AM
Unknown Object (File)
Sat, Jan 3, 10:31 PM
Unknown Object (File)
Fri, Jan 2, 11:05 AM
Unknown Object (File)
Wed, Dec 31, 2:33 AM
Unknown Object (File)
Wed, Dec 31, 12:05 AM

Details

Summary

This change adds support to iflib for drivers that want to do
transmit-side NIC ktls offload. This change does 2 things:

  • Extends the pkt info to include an optional mbuf pointer.

This gives drivers the ability to find the start of a TLS record if
they need to re-DMA part of the record to re-construct TLS state on
the NIC. This mbuf pointer is only passed when CSUM_SND_TAG is
present on the pkthdr. Note that I don't bother to inspect the send
tag on purpose; this will only be present for TLS offloaded or paced
connections

  • Allows the driver to specify how much ring padding is needed before the ring is considered to be full using the new isc_tx_pad field in if_softc_ctx.

This re-uses a field that was marked spare in 2019 via d49e83eac3baf.
Iflib initializes this to the previous value of 2 slots and allows the
driver to override it. The TXQ_AVAIL() macro has been adjusted to
subtract this padding, and uses of the macro have removed +2 from the
other side of the comparison. To avoid potential cache misses from
looking at the ifc_softc_ctx in TXQ_AVAIL(), the value is mirrored in
the txq (in an alignment hole).

Note: I realize poking a hole in the iflib abstraction to pass an mbuf down to thedriver may be controversial. But it is limited in scope and eliminates the need to add complexity to iflib itself in the near term. In the long term, if we gain multiple drivers that support ktls offload, we may want to move some of this functionality into iflib..

Note2: I did this in a way that I think can be MFC'ed. The only change to the driver ABI is the expansion of the pktinfo field, but my thought is that it should be ABI compatible to pass a larger pktinfo down to drivers.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

gallatin retitled this revision from iflib: support fo transmit side nic KTLS offload to iflib: support for transmit side nic KTLS offload.

I've had to poke the same hole for other reasons in the past... this is certainly better than the driver mmap()ing the paddr back into virtual memory.

This revision is now accepted and ready to land.Thu, Dec 18, 8:40 PM
kbowling added inline comments.
FreeBSD/sys/net/iflib.h
130 ↗(On Diff #168280)

I wonder if this should be renumbered to 0 in main

FreeBSD/sys/net/iflib.c
3670 ↗(On Diff #168280)
gallatin added inline comments.
FreeBSD/sys/net/iflib.c
3670 ↗(On Diff #168280)

Thank you.. Fixed this in my tree..

FreeBSD/sys/net/iflib.h
130 ↗(On Diff #168280)

I'm torn.. 1 is a reasonable place to start and keeps the diff minimal, but this is C, not fortran.. Let me know if you feel strongly. Otherwise I'll leave it as-is

FreeBSD/sys/net/iflib.h
130 ↗(On Diff #168280)

No worries

This revision was automatically updated to reflect the committed changes.
gallatin marked an inline comment as done.