Page MenuHomeFreeBSD

vtnet: move offload functions to virtio_net.h to share them
ClosedPublic

Authored by timo.voelker_fh-muenster.de on May 28 2026, 12:21 PM.
Tags
None
Referenced Files
F169150199: D57299.id181526.diff
Mon, Aug 31, 2:41 PM
F169149340: D57299.id.diff
Mon, Aug 31, 2:37 PM
F169131638: D57299.id183781.diff
Mon, Aug 31, 1:03 PM
F169071048: D57299.id179039.diff
Mon, Aug 31, 8:06 AM
F168998053: D57299.id178810.diff
Mon, Aug 31, 2:30 AM
F168974626: D57299.id183781.diff
Mon, Aug 31, 12:53 AM
Unknown Object (File)
Sun, Aug 30, 2:03 AM
Unknown Object (File)
Sun, Aug 30, 12:00 AM
Subscribers

Details

Summary

Move the functions vtnet_rxq_csum() and vtnet_txq_offload() and the subfunctions they call from if_vtnet.c to virtio_net.h. This allows us to call these functions from if_tuntap.c and if_ptnet.c.

virtio_net.h already contained a copy of these functions, but a copy of an outdated version. The functions evolved in if_vtnet.c. In if_vtnet.c, the copy has never been used because it increments counters in their own functions.

This patch removes the outdated copy from virtio_net.h and moves the new version of the functions from if_vtnet.c to virtio_net.h. if_tuntap.c, if_ptnet.c, and if_vtnet.c just call these functions, and if_vtnet.c increments its counters depending on the return value.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Call virtio_net_rx_csum() only if VIRTIO_NET_HDR_F_NEEDS_CSUM or VIRTIO_NET_HDR_F_DATA_VALID is set.

Rebased the patch on the current FreeBSD main branch.

Changes how virtio_net.h does byte conversion. Instead of using virtio_gtoh16, which is unintuitive when called from the host, it uses the new macro VIRTIO_NET_TX_MODERN_LE.

This revision is now accepted and ready to land.Tue, Aug 18, 12:54 PM

vtnet defined the receive-side offload functions only if INET or INET6 were defined. While I copied this to virtio_net.h, I missed checking if INET or INET6 was defined when calling one of these functions from tuntap.

Now, I enclosed the transmit-side offload function in the INET or INET6 defined section in virtio_net.h too and added a check for INET or INET6 before calling the transmit-side offload function in if_vtnet.c and both offload functions in if_tuntap.c. A check in if_ptnet.c is not necessary, because this file is included in the build process only with INET.

This revision is now accepted and ready to land.Thu, Aug 27, 12:41 PM