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
F170866120: D57299.id181526.diff
Mon, Sep 7, 3:25 AM
F170852331: D57299.id185203.diff
Mon, Sep 7, 1:24 AM
F170832956: D57299.id185203.diff
Sun, Sep 6, 10:15 PM
F170828278: D57299.id179039.diff
Sun, Sep 6, 9:26 PM
F170783946: D57299.id184248.diff
Sun, Sep 6, 2:54 PM
F170783636: D57299.id181526.diff
Sun, Sep 6, 2:51 PM
F170730994: D57299.id185203.diff
Sun, Sep 6, 6:46 AM
Unknown Object (File)
Sun, Sep 6, 5:15 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