vtnet: remove loader tunable fixup_needs_csum
Removes the deprecated loader tunable fixup_needs_csum. Removes also the sysctl counter rx_csum_bad_offset that is no longer in use. Reviewed by: tuexen Event: Wiesbaden Hackathon 2026 Differential Revision: https://reviews.freebsd.org/D55588
This commit is contained in:
committed by
Michael Tuexen
parent
1f72d525fc
commit
1bfd392b9e
+2
-22
@@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd December 19, 2025
|
||||
.Dd April 26, 2026
|
||||
.Dt VTNET 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -87,19 +87,6 @@ UDP.
|
||||
This also implies that TCP segmentation offloading and large receive offload
|
||||
are disabled.
|
||||
The default value is 0.
|
||||
.It Va hw.vtnet.fixup_needs_csum
|
||||
.It Va hw.vtnet. Ns Ar X Ns Va .fixup_needs_csum
|
||||
This tunable enforces the calculation of a valid TCP or UDP checksum for
|
||||
packets received with
|
||||
.Dv VIRTIO_NET_HDR_F_NEEDS_CSUM
|
||||
being set in the
|
||||
.Va flags
|
||||
field of the structure
|
||||
.Vt struct virtio_net_hdr .
|
||||
It also marks the checksum as being correct in the mbuf packet header.
|
||||
The default value is 0.
|
||||
This tunable is deprecated and will be removed in
|
||||
.Fx 16 .
|
||||
.It Va hw.vtnet.tso_disable
|
||||
.It Va hw.vtnet. Ns Ar X Ns Va .tso_disable
|
||||
This tunable disables TCP segmentation offloading.
|
||||
@@ -174,9 +161,8 @@ offloading was received and this request failed.
|
||||
The different reasons for the failure are counted by
|
||||
.Va dev.vtnet. Ns Ar X Ns Va .rx_csum_inaccessible_ipproto ,
|
||||
.Va dev.vtnet. Ns Ar X Ns Va .rx_csum_bad_ipproto ,
|
||||
.Va dev.vtnet. Ns Ar X Ns Va .rx_csum_bad_ethtype ,
|
||||
and
|
||||
.Va dev.vtnet. Ns Ar X Ns Va .rx_csum_bad_offset .
|
||||
.Va dev.vtnet. Ns Ar X Ns Va .rx_csum_bad_ethtype .
|
||||
.It Va dev.vtnet. Ns Ar X Ns Va .rxq Ns Ar Y Ns Va .csum
|
||||
The number of times receive checksum offloading for UDP or TCP was performed.
|
||||
.It Va dev.vtnet. Ns Ar X Ns Va .rxq Ns Ar Y Ns Va .ierrors
|
||||
@@ -239,12 +225,6 @@ over all receive queues of the interface.
|
||||
.It Va dev.vtnet. Ns Ar X Ns Va .rx_csum_inaccessible_ipproto
|
||||
The number of times a packet with a request for receive or transmit checksum
|
||||
offloading was received where the IP protocol was not accessible.
|
||||
.It Va dev.vtnet. Ns Ar X Ns Va .rx_csum_bad_offset
|
||||
The number of times fixing the checksum required by
|
||||
.Va hw.vtnet.fixup_needs_csum
|
||||
or
|
||||
.Va hw.vtnet. Ns Ar X Ns Va .fixup_needs_csum
|
||||
was attempted for a packet where the csum is not located in the first mbuf.
|
||||
.It Va dev.vtnet. Ns Ar X Ns Va .rx_csum_bad_ipproto
|
||||
The number of times a packet with a request for receive or transmit checksum
|
||||
offloading was received where the IP protocol was neither TCP nor UDP.
|
||||
|
||||
@@ -651,13 +651,13 @@ awg_encap(struct awg_softc *sc, struct mbuf **mp)
|
||||
|
||||
flags = TX_FIR_DESC;
|
||||
status = 0;
|
||||
if ((m->m_pkthdr.csum_flags & CSUM_IP) != 0) {
|
||||
if ((m->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP)) != 0)
|
||||
csum_flags = TX_CHECKSUM_CTL_FULL;
|
||||
else
|
||||
else if ((m->m_pkthdr.csum_flags & CSUM_IP) != 0)
|
||||
csum_flags = TX_CHECKSUM_CTL_IP;
|
||||
else
|
||||
csum_flags = 0;
|
||||
flags |= (csum_flags << TX_CHECKSUM_CTL_SHIFT);
|
||||
}
|
||||
|
||||
for (i = 0; i < nsegs; i++) {
|
||||
sc->tx.segs++;
|
||||
|
||||
@@ -135,7 +135,7 @@ static int vtnet_rxq_replace_buf(struct vtnet_rxq *, struct mbuf *, int);
|
||||
static int vtnet_rxq_enqueue_buf(struct vtnet_rxq *, struct mbuf *);
|
||||
static int vtnet_rxq_new_buf(struct vtnet_rxq *);
|
||||
#if defined(INET) || defined(INET6)
|
||||
static int vtnet_rxq_csum_needs_csum(struct vtnet_rxq *, struct mbuf *,
|
||||
static void vtnet_rxq_csum_needs_csum(struct vtnet_rxq *, struct mbuf *,
|
||||
bool, int, struct virtio_net_hdr *);
|
||||
static void vtnet_rxq_csum_data_valid(struct vtnet_rxq *, struct mbuf *,
|
||||
int);
|
||||
@@ -273,11 +273,6 @@ static int vtnet_csum_disable = 0;
|
||||
SYSCTL_INT(_hw_vtnet, OID_AUTO, csum_disable, CTLFLAG_RDTUN,
|
||||
&vtnet_csum_disable, 0, "Disables receive and send checksum offload");
|
||||
|
||||
static int vtnet_fixup_needs_csum = 0;
|
||||
SYSCTL_INT(_hw_vtnet, OID_AUTO, fixup_needs_csum, CTLFLAG_RDTUN,
|
||||
&vtnet_fixup_needs_csum, 0,
|
||||
"Calculate valid checksum for NEEDS_CSUM packets");
|
||||
|
||||
static int vtnet_tso_disable = 0;
|
||||
SYSCTL_INT(_hw_vtnet, OID_AUTO, tso_disable, CTLFLAG_RDTUN,
|
||||
&vtnet_tso_disable, 0, "Disables TSO");
|
||||
@@ -1158,10 +1153,6 @@ vtnet_setup_interface(struct vtnet_softc *sc)
|
||||
if_setcapabilitiesbit(ifp, IFCAP_RXCSUM, 0);
|
||||
if_setcapabilitiesbit(ifp, IFCAP_RXCSUM_IPV6, 0);
|
||||
|
||||
if (vtnet_tunable_int(sc, "fixup_needs_csum",
|
||||
vtnet_fixup_needs_csum) != 0)
|
||||
sc->vtnet_flags |= VTNET_FLAG_FIXUP_NEEDS_CSUM;
|
||||
|
||||
/* Support either "hardware" or software LRO. */
|
||||
if_setcapabilitiesbit(ifp, IFCAP_LRO, 0);
|
||||
}
|
||||
@@ -1784,12 +1775,10 @@ vtnet_rxq_new_buf(struct vtnet_rxq *rxq)
|
||||
}
|
||||
|
||||
#if defined(INET) || defined(INET6)
|
||||
static int
|
||||
static void
|
||||
vtnet_rxq_csum_needs_csum(struct vtnet_rxq *rxq, struct mbuf *m, bool isipv6,
|
||||
int protocol, struct virtio_net_hdr *hdr)
|
||||
{
|
||||
struct vtnet_softc *sc;
|
||||
|
||||
/*
|
||||
* The packet is likely from another VM on the same host or from the
|
||||
* host that itself performed checksum offloading so Tx/Rx is basically
|
||||
@@ -1800,57 +1789,18 @@ vtnet_rxq_csum_needs_csum(struct vtnet_rxq *rxq, struct mbuf *m, bool isipv6,
|
||||
("%s: unsupported IP protocol %d", __func__, protocol));
|
||||
|
||||
/*
|
||||
* If the user don't want us to fix it up here by computing the
|
||||
* checksum, just forward the order to compute the checksum by setting
|
||||
* Just forward the order to compute the checksum by setting
|
||||
* the corresponding mbuf flag (e.g., CSUM_TCP).
|
||||
*/
|
||||
sc = rxq->vtnrx_sc;
|
||||
if ((sc->vtnet_flags & VTNET_FLAG_FIXUP_NEEDS_CSUM) == 0) {
|
||||
switch (protocol) {
|
||||
case IPPROTO_TCP:
|
||||
m->m_pkthdr.csum_flags |=
|
||||
(isipv6 ? CSUM_TCP_IPV6 : CSUM_TCP);
|
||||
m->m_pkthdr.csum_flags |= (isipv6 ? CSUM_TCP_IPV6 : CSUM_TCP);
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
m->m_pkthdr.csum_flags |=
|
||||
(isipv6 ? CSUM_UDP_IPV6 : CSUM_UDP);
|
||||
m->m_pkthdr.csum_flags |= (isipv6 ? CSUM_UDP_IPV6 : CSUM_UDP);
|
||||
break;
|
||||
}
|
||||
m->m_pkthdr.csum_data = hdr->csum_offset;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the checksum in the driver so the packet will contain a
|
||||
* valid checksum. The checksum is at csum_offset from csum_start.
|
||||
*/
|
||||
int csum_off, csum_end;
|
||||
uint16_t csum;
|
||||
|
||||
csum_off = hdr->csum_start + hdr->csum_offset;
|
||||
csum_end = csum_off + sizeof(uint16_t);
|
||||
|
||||
/* Assume checksum will be in the first mbuf. */
|
||||
if (m->m_len < csum_end || m->m_pkthdr.len < csum_end) {
|
||||
sc->vtnet_stats.rx_csum_bad_offset++;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Like in_delayed_cksum()/in6_delayed_cksum(), compute the
|
||||
* checksum and write it at the specified offset. We could
|
||||
* try to verify the packet: csum_start should probably
|
||||
* correspond to the start of the TCP/UDP header.
|
||||
*
|
||||
* BMV: Need to properly handle UDP with zero checksum. Is
|
||||
* the IPv4 header checksum implicitly validated?
|
||||
*/
|
||||
csum = in_cksum_skip(m, m->m_pkthdr.len, hdr->csum_start);
|
||||
*(uint16_t *)(mtodo(m, csum_off)) = csum;
|
||||
m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
|
||||
m->m_pkthdr.csum_data = 0xFFFF;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1934,8 +1884,7 @@ vtnet_rxq_csum(struct vtnet_rxq *rxq, struct mbuf *m,
|
||||
}
|
||||
|
||||
if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM)
|
||||
return (vtnet_rxq_csum_needs_csum(rxq, m, isipv6, protocol,
|
||||
hdr));
|
||||
vtnet_rxq_csum_needs_csum(rxq, m, isipv6, protocol, hdr);
|
||||
else /* VIRTIO_NET_HDR_F_DATA_VALID */
|
||||
vtnet_rxq_csum_data_valid(rxq, m, protocol);
|
||||
|
||||
@@ -4354,9 +4303,6 @@ vtnet_setup_stat_sysctl(struct sysctl_ctx_list *ctx,
|
||||
SYSCTL_ADD_UQUAD(ctx, child, OID_AUTO, "rx_csum_bad_ipproto",
|
||||
CTLFLAG_RD | CTLFLAG_STATS, &stats->rx_csum_bad_ipproto,
|
||||
"Received checksum offloaded buffer with incorrect IP protocol");
|
||||
SYSCTL_ADD_UQUAD(ctx, child, OID_AUTO, "rx_csum_bad_offset",
|
||||
CTLFLAG_RD | CTLFLAG_STATS, &stats->rx_csum_bad_offset,
|
||||
"Received checksum offloaded buffer with incorrect offset");
|
||||
SYSCTL_ADD_UQUAD(ctx, child, OID_AUTO, "rx_csum_inaccessible_ipproto",
|
||||
CTLFLAG_RD | CTLFLAG_STATS, &stats->rx_csum_inaccessible_ipproto,
|
||||
"Received checksum offloaded buffer with inaccessible IP protocol");
|
||||
|
||||
Reference in New Issue
Block a user