From nobody Tue Jul 21 20:07:40 2026 X-Original-To: dev-commits-src-all@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 4h4T2T6lPgz6mP2B for ; Tue, 21 Jul 2026 20:07:45 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h4T2T5w95z3QqJ for ; Tue, 21 Jul 2026 20:07:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784664465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VOP5k3qoLr0tQ/AImbEs35+ZUbgezYwcH+ppYq06qgI=; b=KcCpCPhy8Ir/BuufF+ygVgw5NPV6CmZH1JKwzx4lsmwj+BkJSuIOnVtNZHPOSY8DhjF9w/ CTEJuBsKYxOfVYq7CmJrzxQRtkcrow7BwvHMncOgOkmqnUrQH5/BJgGSdK0YB9DPShekRc yXYJwQK0yxZRY7zK9UNy88BGfdQN6MZkikmLquK3etrjHoq0qfeeS1sDmeHmb7PrjAq/BL iDiu/2mK9xtubphAuIzRaI7FQGHs7SMGmq57LiXpqp+R201XcE1JLnRA0UBJ6HzWcSyFMd EUai11oQ+SwTAFSxgUEFs89FtPeoi8LSbV85/gTEYYt201t2XmmTHMP5tDcEGA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1784664465; a=rsa-sha256; cv=none; b=P5BEZw8WQ0tas31e6Yo+N5fALsyo90TF2yUHUSvMFcIMHQy3wnbpQVtzDfVCpvpOo+hyu7 0+8YkZa3FlBtgnJT1sxqMimu5ngWNZtzxpzDfIisacni1vYTQK615ntg91WElw838pGaeC umy/65QUkS46mlgnf2nfGudGDHwD6b8Pt7LYkNNV0rUwSjtWHuzSbOdqxyZ7kmsVn+dpAl 6Givrhq+Bs8EDj734JhTMQbPaC30HSgZA4UFmPU+Suj6EJgqBj9QAKfd0ppi/KeQynmIzz SSqWnNesGhiqdiq07AgPoAnM70yBxjKYxi5B7//kvjdUDGBCa7o+n9oJCELYlQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784664465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VOP5k3qoLr0tQ/AImbEs35+ZUbgezYwcH+ppYq06qgI=; b=Dd6hVwiU2sHpE+wDcL6bzNj+qm+QDdMs+eWv6Sp1pyyCCuGPd501juF8XsR7Yj5IBwZccP f8W59Ms//ibKnMIipd5zUXfBa7bSYbOPKYwWlZPk6EZscHR4/fdcMerUo40iXQi/vGkNB4 pbFKVa/e7B9pGMhKT20GFJoEHHePeqedcyQakkEfLJ2YmZjBJwLQfIRltuHkVxjXXc2PUk nizs42eCl23+7gML+J8L6URg3bmtbsC1Y4ODjn9erq4vbNEkD4xVu/EGUcXJkE+VW1Z7TZ QVPWYFUfbpiHBW/QtFEaXKTxmmOcLaU0ke4DXk/itQYnQ4pKu60U/mOuH8yLMA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h4T2T4hFMz1359 for ; Tue, 21 Jul 2026 20:07:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 219dc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 21 Jul 2026 20:07:40 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Faraz Vahedi From: Pouria Mousavizadeh Tehrani Subject: git: 5481c2d3ac1f - main - vtnet: Retry feature negotiation without offloads List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pouria X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5481c2d3ac1fc7682cdd184c7a797c0583e391c0 Auto-Submitted: auto-generated Date: Tue, 21 Jul 2026 20:07:40 +0000 Message-Id: <6a5fd18c.219dc.70ea402e@gitrepo.freebsd.org> The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=5481c2d3ac1fc7682cdd184c7a797c0583e391c0 commit 5481c2d3ac1fc7682cdd184c7a797c0583e391c0 Author: Faraz Vahedi AuthorDate: 2026-07-12 18:48:36 +0000 Commit: Pouria Mousavizadeh Tehrani CommitDate: 2026-07-21 20:06:30 +0000 vtnet: Retry feature negotiation without offloads A device is permitted to reject an otherwise valid subset of its offered features by refusing to accept FEATURES_OK (VirtIO v1.3, 2.2.2). Apple's Virtualization.framework does this in practice; it treats the offered CSUM/TSO offloads as all-or-nothing, while vtnet's default request contains only part of that group because of hw.vtnet.lro_disable that would drop the guest TSO bits, thus negotiation fails and the device does not attach. If FEATURES_OK is rejected, retry the negotiation once with every offload-related feature stripped. Changing the feature set after a failed FEATURES_OK requires re-initialising from device reset (VirtIO v1.3, 3.1.1), so the retry goes through virtio_reinit(). A NIC without offloads is preferable to no NIC at all. Devices that accept the initial feature set are unaffected, while those that also reject the reduced set continue to fail attachment as before. Signed-off-by: Faraz Vahedi Reviewed by: adrian Pull Request: https://github.com/freebsd/freebsd-src/pull/2322 --- sys/dev/virtio/network/if_vtnet.c | 16 ++++++++++++++-- sys/dev/virtio/network/if_vtnetvar.h | 16 ++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index ad642052d06d..ac5c08f60a0e 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -758,7 +758,7 @@ vtnet_negotiate_features(struct vtnet_softc *sc) { device_t dev; uint64_t features, negotiated_features; - int no_csum; + int error, no_csum; dev = sc->vtnet_dev; features = virtio_bus_is_modern(dev) ? VTNET_MODERN_FEATURES : @@ -836,7 +836,19 @@ vtnet_negotiate_features(struct vtnet_softc *sc) sc->vtnet_features = negotiated_features; sc->vtnet_negotiated_features = negotiated_features; - return (virtio_finalize_features(dev)); + error = virtio_finalize_features(dev); + if (error != 0 && (features & VTNET_OFFLOAD_FEATURES) != 0) { + device_printf(dev, + "retrying feature negotiation without offloads\n"); + features &= ~VTNET_OFFLOAD_FEATURES; + negotiated_features &= ~VTNET_OFFLOAD_FEATURES; + sc->vtnet_flags &= ~VTNET_FLAG_LRO_NOMRG; + sc->vtnet_features = negotiated_features; + sc->vtnet_negotiated_features = negotiated_features; + error = virtio_reinit(dev, features); + } + + return (error); } static int diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h index e445bdf6d6cb..77a7680e5b43 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -369,6 +369,22 @@ CTASSERT(sizeof(struct vtnet_mac_filter) <= PAGE_SIZE); #define VTNET_LRO_FEATURES (VIRTIO_NET_F_GUEST_TSO4 | \ VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN) +/* + * Union of the offload-related features offered by the driver. As per spec, + * a device is permitted to reject an otherwise valid subset of its offered + * features by failing FEATURES_OK (v1.3 ยง2.2.2). Offloads are where this + * happens in practice, so feature negotiation retries without this entire + * group when the device rejects the first feature set. + * + * Must cover every offload-related bit in VTNET_COMMON_FEATURES. + */ +#define VTNET_OFFLOAD_FEATURES \ + (VIRTIO_NET_F_CSUM | \ + VIRTIO_NET_F_GUEST_CSUM | \ + VIRTIO_NET_F_CTRL_GUEST_OFFLOADS | \ + VTNET_TSO_FEATURES | \ + VTNET_LRO_FEATURES) + #define VTNET_MIN_MTU 68 #define VTNET_MAX_MTU 65536 #define VTNET_MAX_RX_SIZE 65550