Page MenuHomeFreeBSD

vtnet: move offload functions to virtio_net.h to share them
Needs ReviewPublic

Authored by timo.voelker_fh-muenster.de on May 28 2026, 12:21 PM.
Tags
None
Referenced Files
F166849724: D57299.id.diff
Mon, Aug 17, 2:29 AM
Unknown Object (File)
Wed, Aug 12, 8:19 PM
Unknown Object (File)
Wed, Aug 12, 6:19 PM
Unknown Object (File)
Mon, Aug 10, 9:43 AM
Unknown Object (File)
Mon, Aug 10, 7:51 AM
Unknown Object (File)
Sun, Aug 9, 5:08 AM
Unknown Object (File)
Sat, Aug 8, 7:14 PM
Unknown Object (File)
Sat, Aug 8, 2:33 PM
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.