aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio/network/if_vtnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/virtio/network/if_vtnet.c')
-rw-r--r--sys/dev/virtio/network/if_vtnet.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index 471c6b3714b2..d9daa5bfd70a 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -1346,20 +1346,40 @@ vtnet_ioctl_ifcap(struct vtnet_softc *sc, struct ifreq *ifr)
VTNET_CORE_LOCK_ASSERT(sc);
if (mask & IFCAP_TXCSUM) {
+ if (if_getcapenable(ifp) & IFCAP_TXCSUM &&
+ if_getcapenable(ifp) & IFCAP_TSO4) {
+ /* Disable tso4, because txcsum will be disabled. */
+ if_setcapenablebit(ifp, 0, IFCAP_TSO4);
+ if_sethwassistbits(ifp, 0, CSUM_IP_TSO);
+ mask &= ~IFCAP_TSO4;
+ }
if_togglecapenable(ifp, IFCAP_TXCSUM);
if_togglehwassist(ifp, VTNET_CSUM_OFFLOAD);
}
if (mask & IFCAP_TXCSUM_IPV6) {
+ if (if_getcapenable(ifp) & IFCAP_TXCSUM_IPV6 &&
+ if_getcapenable(ifp) & IFCAP_TSO6) {
+ /* Disable tso6, because txcsum6 will be disabled. */
+ if_setcapenablebit(ifp, 0, IFCAP_TSO6);
+ if_sethwassistbits(ifp, 0, CSUM_IP6_TSO);
+ mask &= ~IFCAP_TSO6;
+ }
if_togglecapenable(ifp, IFCAP_TXCSUM_IPV6);
if_togglehwassist(ifp, VTNET_CSUM_OFFLOAD_IPV6);
}
if (mask & IFCAP_TSO4) {
- if_togglecapenable(ifp, IFCAP_TSO4);
- if_togglehwassist(ifp, IFCAP_TSO4);
+ if (if_getcapenable(ifp) & (IFCAP_TXCSUM | IFCAP_TSO4)) {
+ /* tso4 can only be enabled, if txcsum is enabled. */
+ if_togglecapenable(ifp, IFCAP_TSO4);
+ if_togglehwassist(ifp, CSUM_IP_TSO);
+ }
}
if (mask & IFCAP_TSO6) {
- if_togglecapenable(ifp, IFCAP_TSO6);
- if_togglehwassist(ifp, IFCAP_TSO6);
+ if (if_getcapenable(ifp) & (IFCAP_TXCSUM_IPV6 | IFCAP_TSO6)) {
+ /* tso6 can only be enabled, if txcsum6 is enabled. */
+ if_togglecapenable(ifp, IFCAP_TSO6);
+ if_togglehwassist(ifp, CSUM_IP6_TSO);
+ }
}
if (mask & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | IFCAP_LRO)) {
@@ -2505,10 +2525,6 @@ vtnet_txq_offload(struct vtnet_txq *txq, struct mbuf *m,
hdr->csum_start = vtnet_gtoh16(sc, csum_start);
hdr->csum_offset = vtnet_gtoh16(sc, m->m_pkthdr.csum_data);
txq->vtntx_stats.vtxs_csum++;
- } else if ((flags & (CSUM_DATA_VALID | CSUM_PSEUDO_HDR)) &&
- (proto == IPPROTO_TCP || proto == IPPROTO_UDP) &&
- (m->m_pkthdr.csum_data == 0xFFFF)) {
- hdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID;
}
if (flags & (CSUM_IP_TSO | CSUM_IP6_TSO)) {
@@ -2622,8 +2638,7 @@ vtnet_txq_encap(struct vtnet_txq *txq, struct mbuf **m_head, int flags)
m->m_flags &= ~M_VLANTAG;
}
- if (m->m_pkthdr.csum_flags &
- (VTNET_CSUM_ALL_OFFLOAD | CSUM_DATA_VALID)) {
+ if (m->m_pkthdr.csum_flags & VTNET_CSUM_ALL_OFFLOAD) {
m = vtnet_txq_offload(txq, m, hdr);
if ((*m_head = m) == NULL) {
error = ENOBUFS;