From nobody Mon Nov 10 15:40:49 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4d4v5F6ctcz6GsKN; Mon, 10 Nov 2025 15:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d4v5F5jWMz41Fy; Mon, 10 Nov 2025 15:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762789249; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1AJkGI5SEPW/1TrgRkS+UPcOisxB/9nqzY06T5mZqhI=; b=VTKZ59x0g3Rcutq41I9s7Z3bZqoRO15WhsiWc5FuaBAmYoOXo+30nw9pwsfRsrmwoQAXf6 S8Vzbwg+Xu96CbfpF+VN2r0Zmp3o+OMs+nExm7RkA+Dkyx2d96PIDGfT5QkKbIeIVxvxHN j0cX2mGEv9R6UbyOtApTrHoxucCwbstcULKBLKeEV3KJ58OWw7YnHNZ/T3fd6Ukq/KsO5l nym05HDUSHfsnNAx5I8o5XZBge2qb1WIcUL71z0eyqgoPf4qbnS0ZkLQo9G0c0uYoq1lRV 6jinaTjdXq0iOMZlh5bmSgzO+vJsSY09Sgl/efVHPf+ySL1qeYqeqtTHeDsItg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762789249; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1AJkGI5SEPW/1TrgRkS+UPcOisxB/9nqzY06T5mZqhI=; b=h4JETvPqAF0LTMc4XZG8SI5L4FoMC6OQFj7ocmcU8PuPA8u+MkxR+rEByicLffj+B10F22 7fN6K7XOCAeA2snADrJGHVyJc3im0q6LYMTGos+hrRF9AnyngXyk6/0ie4FjngXYd8fXyx h37v+JzuQ0Sq1xN80YXgRe0p7cmiVYAUxcL8ESDjU/AHIVEi5kQ9fY327puiT84jdjObu/ ZYPtR8LCQ4I4fCYJABs8N5zWZx4zuh/V5gHxxANW4cF5lNDJZn/wLW8YpLr70BfPWr/58g +TA9lTL1Ytbwor1GHfllhK/mdGq3SNu3JbBSrKBJGk4Y6n/LTRFVCe/tPCywhA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762789249; a=rsa-sha256; cv=none; b=oEjStydUA9qnfODDa0iF7xtBcgxGIP1kbfu8yaZPXqt0NZfNMVDuwUAe6eebukct6Zq5e5 rp9dtfTDExnKRToEMHLZb03RhnBcvpsmUvSEZxx7iD/Nw4YYh3YraRbdIMDMzCvk28j5m1 KbcFLhKpRxfISHVqFHSFlozC5eD+Zsi3ReZvVWCOKterShCl7QSp/wlcalIbohWW/Qqmej AHpgmswSZ6tPr0oXztDI9RpCcBL7KejQmQzLQUaxIhdnRUMwKjuNYfJGVdfMdNhlhdhF55 XPq3DwL5AVahHMp1TSpxJtRomN/x4VrnOBfvGRXHH93/MHK7q5CcW+GthvQtfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4d4v5F4Nkpz8DW; Mon, 10 Nov 2025 15:40:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5AAFentO031372; Mon, 10 Nov 2025 15:40:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5AAFeni4031369; Mon, 10 Nov 2025 15:40:49 GMT (envelope-from git) Date: Mon, 10 Nov 2025 15:40:49 GMT Message-Id: <202511101540.5AAFeni4031369@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 4c50ac68166c - main - vtnet: fix enabling/disabling tso List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4c50ac68166caf7e08c5a9984d63fa91490fa50d Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=4c50ac68166caf7e08c5a9984d63fa91490fa50d commit 4c50ac68166caf7e08c5a9984d63fa91490fa50d Author: Michael Tuexen AuthorDate: 2025-11-10 15:34:53 +0000 Commit: Michael Tuexen CommitDate: 2025-11-10 15:34:53 +0000 vtnet: fix enabling/disabling tso Transmit segment offloading depends on transmit checksum offloading. Enforce that constraint. This also fixes a bug, since if_hwassist bits are from the CSUM_ space, not from the IFCAP_ space. PR: 290773 Reviewed by: Timo Völker Tested by: lg@efficientip.com MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53629 --- sys/dev/virtio/network/if_vtnet.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index a61b0aac0bfa..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)) {