diff options
| author | Timo Völker <timo.voelker@fh-muenster.de> | 2026-08-18 12:49:40 +0000 |
|---|---|---|
| committer | Michael Tuexen <tuexen@FreeBSD.org> | 2026-08-18 12:49:40 +0000 |
| commit | 44cddaa99dee0a634cf2713f71e799eb41397355 (patch) | |
| tree | 1d6c05b75ab676a421c6bfb02ed61ec383c80ffa /sys/dev/netmap | |
| parent | 33e2eac3e3e738daa95a06f42d6c661b87ad9aac (diff) | |
vtnet: move offload functions to virtio_net.h to share them
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.
Reviewed by: tuexen
MFC after: 1 month
MFC to: stable/15
Differential Revision: https://reviews.freebsd.org/D57299
Diffstat (limited to 'sys/dev/netmap')
| -rw-r--r-- | sys/dev/netmap/if_ptnet.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/dev/netmap/if_ptnet.c b/sys/dev/netmap/if_ptnet.c index 9c06f7fec530..660b1930aa76 100644 --- a/sys/dev/netmap/if_ptnet.c +++ b/sys/dev/netmap/if_ptnet.c @@ -1464,8 +1464,17 @@ ptnet_drain_transmit_queue(struct ptnet_queue *pq, unsigned int budget, * two 8-bytes-wide writes. */ memset(nmbuf, 0, PTNET_HDR_SIZE); if (mhead->m_pkthdr.csum_flags & PTNET_ALL_OFFLOAD) { - mhead = virtio_net_tx_offload(ifp, mhead, false, - vh); + /* + * Translate the CSUM_* flags in the mbuf to the + * corresponding flags in the VirtIO header. + * + * ptnet does not negotiate ECN and orders the + * bytes in the VirtIO header as if the VirtIO + * modern mode is not used. So, pass false for + * both. + */ + virtio_net_tx_offload(ifp, &mhead, vh, false, + false); if (unlikely(!mhead)) { /* Packet dropped because errors * occurred while preparing the vnet @@ -1842,7 +1851,14 @@ host_sync: } } - if (unlikely(have_vnet_hdr && virtio_net_rx_csum(mhead, vh))) { + /* + * Translate the VirtIO header flags to the corresponding + * CSUM_* flags in the mbuf. + */ + if (unlikely(have_vnet_hdr && + ((vh->flags & (VIRTIO_NET_HDR_F_NEEDS_CSUM | + VIRTIO_NET_HDR_F_DATA_VALID)) != 0) && + (virtio_net_rx_csum(mhead, vh) != 0))) { m_freem(mhead); nm_prlim(1, "Csum offload error: dropping"); pq->stats.iqdrops ++; |
