From nobody Fri Oct 30 17:35:50 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 4jGStg3yMDz6xFtD for ; Fri, 30 Oct 2026 17:35:55 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jGStg2fvmz4cM9 for ; Fri, 30 Oct 2026 17:35:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793381755; 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=8/TEyXp21JFvdv6GqmoWqQwPBOsA0ja1NwPbwItKAnQ=; b=lnDZ5AnybsXrLCzONAbMJ8UIjIXQmPf0sNfG+O9tG3hjolzOp8kxlG7rLB9ADRtVGM8ZZt 2z7MP47RN/hp9atFQKsOb02Ov47Ut4kORPNdkcWEy9UzHWOE+ky5CbxmtjpXYHHn0o4Txr 1rS644Ee6QsOfaRNxe2UhuxmGuAAEYp++ixkaA3pok/znVYvjGSh+ymUlo0jDeWx4Mw8UN YZsVaTo8hsHqM7CCiuL38j+s8j3XGGrjknQMgJVP/1r3PDI9DkfHsAoy7NYUXoRvFFVrIc VSQq4iPIfMC3FBRNLTN2cf48K56Hl746c2qfojQC8vegWcPoyqCLO76dLL0EBw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793381755; b=ys8ZkS/MMjc6/hAXxu3dVAQIu2m7fQC6n3ppF885vUmU/7wg8C+8yGQv0+VMmMKLReI50W EKldVZMGsYhdeT4mT6zEB1lmGZvWGRI3dX3QOmcmNP0d6G/KFZRiaDeP4/WBowb75EPyEa ekjcn9csCFAfbxJUGhReaxB5zM393+MA2jYRX7QHGpbe5ZhA6YXfNjKvu5JYxj/1KGD7nf WjUdeGGGxbvdBVtewxZPtPlcTqNrYdThSemkikI/v/pTrwvOyD8fbCVMIILiTnbzYjzQDM G1QAFz/X+whkTe763365M3UvC2Mcp4YxEoDVpnJT40qdkp/8kTXPPXAVKKcgeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793381755; 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=8/TEyXp21JFvdv6GqmoWqQwPBOsA0ja1NwPbwItKAnQ=; b=oWhhK5Z2aK4N8ADAZ7eZQPVQk8Lc1IuxeO2aRBDlfW62V+iLR98HFy0OC+dRNGsfyr8D6N 9oUyQHVIhm8ux2DifUC+Ebo5MNmu5ZW7ZNqMwwTcnqmITLwXPXwnaxQv4lULW+uJ80BGep SSjLTFfhtU9U/T+sG/xrpelaEa7v2vMIOO7xUx5oCAr6QgLcl634SPTSccq36jOMewpI8j MfRHM1DHerOgrXHiRKnke/Xu/7ZCWDJsU2cQ5yt/5EATY+V3gnQ7Bhnhh4wMCQnN2qrOQp 5kaAneGCsiMyyA9I6dhzdcuTdXDh8y/5x8v06xtSNJdMF0AZHXEEUKgV5gygqQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jGStg21dTzdlD for ; Fri, 30 Oct 2026 17:35:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 4038d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 30 Oct 2026 17:35:50 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Faraz Vahedi From: Kevin Bowling Subject: git: 57ccd4ea2886 - stable/15 - vtnet: Retry feature negotiation without offloads List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository 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: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 57ccd4ea288601e38e4798999d08e06e2ee9d656 Auto-Submitted: auto-generated Date: Fri, 30 Oct 2026 17:35:50 +0000 Message-Id: <6ae4d576.4038d.468a9f4@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=57ccd4ea288601e38e4798999d08e06e2ee9d656 commit 57ccd4ea288601e38e4798999d08e06e2ee9d656 Author: Faraz Vahedi AuthorDate: 2026-07-12 18:48:36 +0000 Commit: Kevin Bowling CommitDate: 2026-10-30 17:35:39 +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 (cherry picked from commit 5481c2d3ac1fc7682cdd184c7a797c0583e391c0) --- 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 da89dea03f87..112edde34b03 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -641,7 +641,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 : @@ -719,7 +719,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 eb5e6784b07f..237b86fd0244 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -353,6 +353,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