From nobody Thu Apr 2 09:22:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B96FF2E2EEE; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; cv=none; b=hdPXggMAdgkHQiO9dJSUaJz0YWDt8fG8OOZ56xFwJZkFzuzW8p/2VBA/alva9WJsgrfjEVosBvsHPg3vl8Vghv6mCV7pbR5NauJyhEzQ94psfwmRHJyTPGFSSb6I3HImPJAPcAuRcT1el6Bdqi3vnG6qEnoMNAlZ4vSTtkcsDQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; c=relaxed/simple; bh=qHwtEmiaUzALs1U8lxciI7QvUZJpw94pPRYf1wfFSqU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DvxC+21eFU2YQa9dMb/gx/PQIizcZMVtsuyMzbG81sqWY4yoPGZTjSWHMte1h7JBCcbCN0BJpkpCRFlhgh54NRnNh3tVWFWkzqsLqDEwOh2cZehVpTxKUM0WsSiXZBYMQ8mZ9CqqEP6apz7St71q8M1QXrn4TUBOkHQGT7aIUZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l2E6Ivjf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l2E6Ivjf" Received: by smtp.kernel.org (Postfix) with ESMTPS id 78F4FC2BCB1; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774838717; bh=qHwtEmiaUzALs1U8lxciI7QvUZJpw94pPRYf1wfFSqU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=l2E6Ivjffgy5bKlSjlSqSRzKOu9xPbBGYDjGXo8acJHNeqqdn1sFAsaiUZVIa/6oY x6h4LBqOlS3CzxZRlgKiOY7+amaZsxjdJX4w1NS4TKIAfSxngroW33EBY5lIvbbtU3 EsLX+cgkE9B/pF42KABklfALwre6ZEk0Ina+6f1vbfSDgHan1nCq3/a9Ivk627E1m9 1ZOILjsUwPzJJDgpkpnJPIHenNvcBwbvf2hwDG85czokcMa1ZdfPH3PFLTE+JM0tIW R84sraeFccj8RL3K+1HV7cMD+seXiZTCO0ej4CpgaB76BwNwhDSkHKrmuYPFxAn42k bao8VVXqNeK/Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61459FF492D; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Sun, 29 Mar 2026 19:45:17 -0700 Subject: [PATCH net-next v3 1/6] enic: extend resource discovery for SR-IOV admin channel Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260329-enic-sriov-v2-prep-v3-1-19a477549ef6@cisco.com> References: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> In-Reply-To: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> To: Satish Kharat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774838716; l=3356; i=satishkh@cisco.com; h=from:subject:message-id; bh=y0pGwL9wW5ULZUwdK19OUJqESwm7dxXUYk9R9IIroV8=; b=H4tEtgWE4aeyE/CEjTFACK/GXLktaMM/YOQZp7nWuLzEnyI1lgx4ZKPCZkwKD72pJ2Xb4aaQk zzw6roCxfORDVqOmxfI2dZ6ijNMSTe4wcx2+1mVEkYyrbexcFwotYUV X-Developer-Key: i=satishkh@cisco.com; a=ed25519; pk=4BxbLoCGvHeIMH/PbpiNVx8/2IcTjFvqcr0AD8K6WLY= X-Endpoint-Received: by B4 Relay for satishkh@cisco.com/default with auth_id=639 X-Original-From: Satish Kharat Reply-To: satishkh@cisco.com From: Satish Kharat VIC firmware exposes admin channel resources (WQ, RQ, CQ) for PF-VF communication when SR-IOV is active. Add the corresponding resource type definitions and teach the discovery and access functions to handle them. Signed-off-by: Satish Kharat --- drivers/net/ethernet/cisco/enic/enic.h | 2 ++ drivers/net/ethernet/cisco/enic/vnic_dev.c | 10 ++++++++++ drivers/net/ethernet/cisco/enic/vnic_resource.h | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/= cisco/enic/enic.h index 6959e85ab516..366c65d072fc 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -297,6 +297,8 @@ static inline struct net_device *vnic_get_netdev(struct= vnic_dev *vdev) dev_warn(&(vdev)->pdev->dev, fmt, ##__VA_ARGS__) #define vdev_info(vdev, fmt, ...) \ dev_info(&(vdev)->pdev->dev, fmt, ##__VA_ARGS__) +#define vdev_dbg(vdev, fmt, ...) \ + dev_dbg(&(vdev)->pdev->dev, fmt, ##__VA_ARGS__) =20 #define vdev_neterr(vdev, fmt, ...) \ netdev_err(vnic_get_netdev(vdev), fmt, ##__VA_ARGS__) diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ether= net/cisco/enic/vnic_dev.c index c72452749f5e..c8d657e97094 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_dev.c +++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c @@ -77,6 +77,9 @@ static int vnic_dev_discover_res(struct vnic_dev *vdev, u32 count =3D ioread32(&r->count); u32 len; =20 + vdev_dbg(vdev, "res type %u bar %u offset 0x%x count %u\n", + type, bar_num, bar_offset, count); + r++; =20 if (bar_num >=3D num_bars) @@ -90,6 +93,9 @@ static int vnic_dev_discover_res(struct vnic_dev *vdev, case RES_TYPE_RQ: case RES_TYPE_CQ: case RES_TYPE_INTR_CTRL: + case RES_TYPE_ADMIN_WQ: + case RES_TYPE_ADMIN_RQ: + case RES_TYPE_ADMIN_CQ: /* each count is stride bytes long */ len =3D count * VNIC_RES_STRIDE; if (len + bar_offset > bar[bar_num].len) { @@ -102,6 +108,7 @@ static int vnic_dev_discover_res(struct vnic_dev *vdev, case RES_TYPE_INTR_PBA_LEGACY: case RES_TYPE_DEVCMD: case RES_TYPE_DEVCMD2: + case RES_TYPE_SRIOV_INTR: len =3D count; break; default: @@ -135,6 +142,9 @@ void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, e= num vnic_res_type type, case RES_TYPE_RQ: case RES_TYPE_CQ: case RES_TYPE_INTR_CTRL: + case RES_TYPE_ADMIN_WQ: + case RES_TYPE_ADMIN_RQ: + case RES_TYPE_ADMIN_CQ: return (char __iomem *)vdev->res[type].vaddr + index * VNIC_RES_STRIDE; default: diff --git a/drivers/net/ethernet/cisco/enic/vnic_resource.h b/drivers/net/= ethernet/cisco/enic/vnic_resource.h index b4776e334d63..d327821fa9b9 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_resource.h +++ b/drivers/net/ethernet/cisco/enic/vnic_resource.h @@ -42,6 +42,10 @@ enum vnic_res_type { RES_TYPE_DEPRECATED1, /* Old version of devcmd 2 */ RES_TYPE_DEPRECATED2, /* Old version of devcmd 2 */ RES_TYPE_DEVCMD2, /* Device control region */ + RES_TYPE_SRIOV_INTR =3D 45, /* SR-IOV VF interrupt */ + RES_TYPE_ADMIN_WQ =3D 49, /* Admin channel WQ */ + RES_TYPE_ADMIN_RQ, /* Admin channel RQ */ + RES_TYPE_ADMIN_CQ, /* Admin channel CQ */ =20 RES_TYPE_MAX, /* Count of resource types */ }; --=20 2.43.0 From nobody Thu Apr 2 09:22:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B97903624AD; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; cv=none; b=mJRwM8BknW0NKqM2Yi7V1lw6sp4iBaqAr5luf9uAiivqpLoY/l2DVk44piLAqdChM+4ogLB8kr6BhtkqeihPRENt2Y2YZSSQ1VJVS3CXxKxC4wcSeFA/WylR4oJXcww1WtKEIrz0BjeIoWqn2zdYmwXSOzwOne1bsxJp2JnDehs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; c=relaxed/simple; bh=GaJWaVTbn/UL3B4IZ3JOup4VGmfvjwuuWoZ7Ej05S78=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jBcnni6rdQNOYMh0XAMz1/NYUr9Lt470JwkDcYOfKr5XQAkTHEMrgc3DPm49xngeEraRoL1XWEOXdgn3zr2yEEIznLJjnhRF0sLmrtdeMfk3UogWN3QdyMut90vgN5LDUx8/ctm/TCzGMR7z/riMOTPsXb3H7E9MawrGfW9wyVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hQGV700+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hQGV700+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7DC36C2BCB3; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774838717; bh=GaJWaVTbn/UL3B4IZ3JOup4VGmfvjwuuWoZ7Ej05S78=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=hQGV700+6LhlKQwO/S8a9eBKtBSNfc3TP44zUTXLlIbneYF6O0aAdcRt7yYPp6hPX xWAtcgByJEDOzAQQQxlt3sL5gIutmSgDpKfEKTupWOU2ZEjpxNbVaJUrDFWCw0ZZyU iH/3ALKITj1l8Y8ytdXmLmIq7NF7JxvypW5r9zSFzGKD1fpxB24vGfEs9AfB8M46T/ GzIicKx5Q5zbGKwH9dK1V5QosJRKeC0m0LGSOctB1MV58fGbbzitjXRGuFgXygXG2U qttNoQXrJlgCaEkFpM0ODpfp/RmtG7ObttGEijvY3HcPYLO2zjz+jujzXRJEVM9XRI C5YtiJjbnAM+w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70AA7FF4935; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Sun, 29 Mar 2026 19:45:18 -0700 Subject: [PATCH net-next v3 2/6] enic: add V2 SR-IOV VF device ID Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260329-enic-sriov-v2-prep-v3-2-19a477549ef6@cisco.com> References: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> In-Reply-To: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> To: Satish Kharat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774838716; l=1690; i=satishkh@cisco.com; h=from:subject:message-id; bh=1chUHjnI8ZuULFMfvuOuwWNT2kAEAJEGnPmXwEaCezM=; b=H+q9+OEhmhKeDoujMW8Bu9aj6WPZ0kaGAZzEO0JhldRqzOszBr1aLbQe2bAnRC9zEaG4FaRx/ VTCnuDrEiFwCUl+UB3pi8wFddWL1qqW74DNtT7/uXZdL+5WnyGTy4QY X-Developer-Key: i=satishkh@cisco.com; a=ed25519; pk=4BxbLoCGvHeIMH/PbpiNVx8/2IcTjFvqcr0AD8K6WLY= X-Endpoint-Received: by B4 Relay for satishkh@cisco.com/default with auth_id=639 X-Original-From: Satish Kharat Reply-To: satishkh@cisco.com From: Satish Kharat Register the V2 VF PCI device ID (0x02b7) so the driver binds to V2 virtual functions created via sriov_configure. Update enic_is_sriov_vf() to recognize V2 VFs alongside the existing V1 type. Signed-off-by: Satish Kharat --- drivers/net/ethernet/cisco/enic/enic_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethe= rnet/cisco/enic/enic_main.c index e839081f9ee4..e16dfbcd2c22 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -66,12 +66,14 @@ #define PCI_DEVICE_ID_CISCO_VIC_ENET 0x0043 /* ethernet vnic */ #define PCI_DEVICE_ID_CISCO_VIC_ENET_DYN 0x0044 /* enet dynamic vnic = */ #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF 0x0071 /* enet SRIOV VF */ +#define PCI_DEVICE_ID_CISCO_VIC_ENET_VF_V2 0x02b7 /* enet SRIOV V2 VF */ =20 /* Supported devices */ static const struct pci_device_id enic_id_table[] =3D { { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET) }, { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_DYN) }, { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_VF) }, + { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_VF_V2) }, { 0, } /* end of table */ }; =20 @@ -307,7 +309,8 @@ int enic_sriov_enabled(struct enic *enic) =20 static int enic_is_sriov_vf(struct enic *enic) { - return enic->pdev->device =3D=3D PCI_DEVICE_ID_CISCO_VIC_ENET_VF; + return enic->pdev->device =3D=3D PCI_DEVICE_ID_CISCO_VIC_ENET_VF || + enic->pdev->device =3D=3D PCI_DEVICE_ID_CISCO_VIC_ENET_VF_V2; } =20 int enic_is_valid_vf(struct enic *enic, int vf) --=20 2.43.0 From nobody Thu Apr 2 09:22:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B966B4A35; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; cv=none; b=O11PaJZX5fELJKOSo4Nu70Fmv2qQ+dHRkkNdD7pa7oZccGUpM2Te5aZsVewV73DnY510JqGimyEIgxk7RpE/eEQJHeicfVK7F2Xt1E+3H8jbyitetrgaYQ1FK/xJ80vJR2pUKwiPfg228WWBnIEydzo12l1s+MCU5Ul2VtbxC/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; c=relaxed/simple; bh=ZxR9g+zCxK8pArCJ7PTFR8axACYwGxTDHOn4nO9U1U8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aiF+fm8r6/kl+g5yzOhldsZZaRj3rkDt8+thxAz/TEj3x32hZNeowwpz/kaRWzzh7u5K15wlyLrmFYDTAayZw2fK1z349/qHjwrtfLl13eXYcmaWqcKKU4ltPofweBmB4Tr9DG2m/tovy81OZKm89ciix5AfALGUen/46+WWz1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MDDIXOYt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MDDIXOYt" Received: by smtp.kernel.org (Postfix) with ESMTPS id 88976C2BCB4; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774838717; bh=ZxR9g+zCxK8pArCJ7PTFR8axACYwGxTDHOn4nO9U1U8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MDDIXOYtYoXe1GtAIyTRyUxprRwpfpxy8kZlgl8NQQ8/9QrosM0jK4Fb+QNK6A8DY Ny9Ni2fZG9mcCEw9pxswauJhILqW2TKcRwDxNk8u9sLRrAcz2m6mPo+2VsOIRESuC+ gdjGD6BvGp+VXNSbNA3yoKcs118Ei6COncptB6sJt2Sr2sRbYqeGiLuS9o8fEGOpQ3 NI74kppngzZF2YEZBX6Lbedzr12b5tuYkTG9HNQEqpMor4D+/CtJWmsIJwTXDNka/D Jhsfg59ZMSoM87gVM0HSVVtopOMsjvvpXgo2wGjW/RLoYzn/nRp6iLYuAczMZe8lkq Tp8Pk+845w29Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F42AFF4934; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Sun, 29 Mar 2026 19:45:19 -0700 Subject: [PATCH net-next v3 3/6] enic: detect SR-IOV VF type from PCI capability Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260329-enic-sriov-v2-prep-v3-3-19a477549ef6@cisco.com> References: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> In-Reply-To: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> To: Satish Kharat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774838716; l=3365; i=satishkh@cisco.com; h=from:subject:message-id; bh=EHjug9jFvuqtjK7rgKqTb+ZxcNgtnQ9ViaQc7HzlDNE=; b=D/BEZvPa4Gw73XjlMiux2p+psMbdfXBKO+bFLDb2zgnYNRMiYEzrsidmOV22123Sh+0aQ4/yR NbGp9/DcDOHBTIg9r9Vbv9aIPGHqok9tlu60xNPZ83uX7jIbCBKNFA8 X-Developer-Key: i=satishkh@cisco.com; a=ed25519; pk=4BxbLoCGvHeIMH/PbpiNVx8/2IcTjFvqcr0AD8K6WLY= X-Endpoint-Received: by B4 Relay for satishkh@cisco.com/default with auth_id=639 X-Original-From: Satish Kharat Reply-To: satishkh@cisco.com From: Satish Kharat Read the VF device ID from the SR-IOV PCI capability at probe time to determine whether the PF is configured for V1, USNIC, or V2 virtual functions. Store the result in enic->vf_type for use by subsequent SR-IOV operations. The VF type is a firmware-configured property (set via UCSM, CIMC, Intersight etc) that is immutable from the driver's perspective. Only PFs are probed for this capability; VFs and dynamic vnics skip detection. Signed-off-by: Satish Kharat --- drivers/net/ethernet/cisco/enic/enic.h | 8 +++++++ drivers/net/ethernet/cisco/enic/enic_main.c | 37 +++++++++++++++++++++++++= ++++ 2 files changed, 45 insertions(+) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/= cisco/enic/enic.h index 366c65d072fc..0fd9cd917132 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -225,6 +225,13 @@ struct enic_rq { struct page_pool *pool; } ____cacheline_aligned; =20 +enum enic_vf_type { + ENIC_VF_TYPE_NONE, + ENIC_VF_TYPE_V1, + ENIC_VF_TYPE_USNIC, + ENIC_VF_TYPE_V2, +}; + /* Per-instance private data structure */ struct enic { struct net_device *netdev; @@ -252,6 +259,7 @@ struct enic { #ifdef CONFIG_PCI_IOV u16 num_vfs; #endif + enum enic_vf_type vf_type; spinlock_t enic_api_lock; bool enic_api_busy; struct enic_port_profile *pp; diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethe= rnet/cisco/enic/enic_main.c index e16dfbcd2c22..acd05350ec1a 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -67,6 +67,7 @@ #define PCI_DEVICE_ID_CISCO_VIC_ENET_DYN 0x0044 /* enet dynamic vnic = */ #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF 0x0071 /* enet SRIOV VF */ #define PCI_DEVICE_ID_CISCO_VIC_ENET_VF_V2 0x02b7 /* enet SRIOV V2 VF */ +#define PCI_DEVICE_ID_CISCO_VIC_ENET_VF_USNIC 0x00cf /* enet USNIC VF */ =20 /* Supported devices */ static const struct pci_device_id enic_id_table[] =3D { @@ -2621,6 +2622,41 @@ static void enic_iounmap(struct enic *enic) iounmap(enic->bar[i].vaddr); } =20 +#ifdef CONFIG_PCI_IOV +static void enic_sriov_detect_vf_type(struct enic *enic) +{ + struct pci_dev *pdev =3D enic->pdev; + int pos; + u16 vf_dev_id; + + if (enic_is_sriov_vf(enic) || enic_is_dynamic(enic)) + return; + + pos =3D pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_SRIOV); + if (!pos) { + enic->vf_type =3D ENIC_VF_TYPE_NONE; + return; + } + + pci_read_config_word(pdev, pos + PCI_SRIOV_VF_DID, &vf_dev_id); + + switch (vf_dev_id) { + case PCI_DEVICE_ID_CISCO_VIC_ENET_VF: + enic->vf_type =3D ENIC_VF_TYPE_V1; + break; + case PCI_DEVICE_ID_CISCO_VIC_ENET_VF_USNIC: + enic->vf_type =3D ENIC_VF_TYPE_USNIC; + break; + case PCI_DEVICE_ID_CISCO_VIC_ENET_VF_V2: + enic->vf_type =3D ENIC_VF_TYPE_V2; + break; + default: + enic->vf_type =3D ENIC_VF_TYPE_NONE; + break; + } +} +#endif + static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *en= t) { struct device *dev =3D &pdev->dev; @@ -2734,6 +2770,7 @@ static int enic_probe(struct pci_dev *pdev, const str= uct pci_device_id *ent) num_pps =3D enic->num_vfs; } } + enic_sriov_detect_vf_type(enic); #endif =20 /* Allocate structure for port profiles */ --=20 2.43.0 From nobody Thu Apr 2 09:22:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE7A339151B; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; cv=none; b=aalfCdPQspUEAmjyX4L6erTPN8tlo4M+zPk4m3qrsPXpBCoSiiXkBBqaKTGi38y59DslnHoVMfjjI3xmM2aU7JRX+8749g7j84TfWYu4MEyLMnBAyQRPKMYLSE8lxk4Iu/s5wFv9e41CBJni7hHDXb6kghEPRwgxTCl9zexSihk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838717; c=relaxed/simple; bh=BpaDyxuEEWGwH8+zxRnZgYWjvYFs0B64GTKhbxeNAS4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jYkw/mW+6Wrs8//AYR9INz9qY8HQz2VOobnRBcdFpzEugMDYU8srKMj+wUydrVN9YiC8BtF7/lxOdi+ap2m8YxHeYVyNKGG91ziI7RjWlDkgtLEsd8p3yfaTLhjaKrBRI0MnkAMHo++YwS/RRNaebf5B8lKNaxxi9pwj6J9LG5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IxH3Mw68; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IxH3Mw68" Received: by smtp.kernel.org (Postfix) with ESMTPS id B1C07C2BCB7; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774838717; bh=BpaDyxuEEWGwH8+zxRnZgYWjvYFs0B64GTKhbxeNAS4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=IxH3Mw68UQRXjzB1HOpN/KqKXtYzk/XWZ9dTKAtdFpqhTOgZTCO6e2Uwd54qSdqCk BTigMD/5SgJB6H82xkw/q2VhQEjI87EhL96vdsEqZ65wFfHwAMRa57hCYjUo2dvx8+ +MvQsuDlbEEMyOEpYpk153Mp2I9+zvR7l3ZNScgJvDc3HIzvUFIMdPSHKr7QHsyMil pZwg4cc36lQO4bIsSLN35NN0X+fqBO/ls2wYNdc6ir72P9h2xcGJ4JWRFL/as24Lz0 BBGekgnHDTcajIIrBMwokMyTsbldT+CeYJVbH7HO1RM5vqq/Ih2Flm2ib+cWNdEdxC 533M52YVtIiQA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD1CBFF492D; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Sun, 29 Mar 2026 19:45:20 -0700 Subject: [PATCH net-next v3 4/6] enic: make enic_dev_enable/disable ref-counted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260329-enic-sriov-v2-prep-v3-4-19a477549ef6@cisco.com> References: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> In-Reply-To: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> To: Satish Kharat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774838716; l=4130; i=satishkh@cisco.com; h=from:subject:message-id; bh=zvvdRfwq8gsBZZOSKyc4TXaUkVuYP93HpEGc0xRpx0k=; b=KflXMJygQFdksHqK2PJ5a9eLSq02ebxaBkEXTmD1qq2XkgOrJIVA3mLuJkMSdvUwDNOP5gUdy 0etpzaTfZBwATXKb9/agR8LFnU3pVBPiA6l2C/UC4m3gFKzTuZpA2G1 X-Developer-Key: i=satishkh@cisco.com; a=ed25519; pk=4BxbLoCGvHeIMH/PbpiNVx8/2IcTjFvqcr0AD8K6WLY= X-Endpoint-Received: by B4 Relay for satishkh@cisco.com/default with auth_id=639 X-Original-From: Satish Kharat Reply-To: satishkh@cisco.com From: Satish Kharat Both the data path (ndo_open/ndo_stop) and the upcoming admin channel need to enable and disable the vNIC device independently. Without reference counting, closing the admin channel while the netdev is up would inadvertently disable the entire device. Add an enable_count to struct enic, protected by the existing devcmd_lock. enic_dev_enable() issues CMD_ENABLE_WAIT only on the first caller (0 -> 1 transition), and enic_dev_disable() issues CMD_DISABLE only when the last caller releases (1 -> 0 transition). Also check the return value of enic_dev_enable() in enic_open() and fail the open if the firmware enable command fails. Without this check, a failed enable leaves enable_count at zero while the interface appears up, which can cause a later admin channel enable/disable cycle to incorrectly disable the hardware under the active data path. Signed-off-by: Satish Kharat --- drivers/net/ethernet/cisco/enic/enic.h | 1 + drivers/net/ethernet/cisco/enic/enic_dev.c | 17 +++++++++++++---- drivers/net/ethernet/cisco/enic/enic_main.c | 17 ++++++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/= cisco/enic/enic.h index 0fd9cd917132..67fd780b1fa1 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -260,6 +260,7 @@ struct enic { u16 num_vfs; #endif enum enic_vf_type vf_type; + unsigned int enable_count; spinlock_t enic_api_lock; bool enic_api_busy; struct enic_port_profile *pp; diff --git a/drivers/net/ethernet/cisco/enic/enic_dev.c b/drivers/net/ether= net/cisco/enic/enic_dev.c index 2cbae7c6cc3d..659787f73cf1 100644 --- a/drivers/net/ethernet/cisco/enic/enic_dev.c +++ b/drivers/net/ethernet/cisco/enic/enic_dev.c @@ -131,10 +131,13 @@ int enic_dev_set_ig_vlan_rewrite_mode(struct enic *en= ic) =20 int enic_dev_enable(struct enic *enic) { - int err; + int err =3D 0; =20 spin_lock_bh(&enic->devcmd_lock); - err =3D vnic_dev_enable_wait(enic->vdev); + if (enic->enable_count =3D=3D 0) + err =3D vnic_dev_enable_wait(enic->vdev); + if (!err) + enic->enable_count++; spin_unlock_bh(&enic->devcmd_lock); =20 return err; @@ -142,10 +145,16 @@ int enic_dev_enable(struct enic *enic) =20 int enic_dev_disable(struct enic *enic) { - int err; + int err =3D 0; =20 spin_lock_bh(&enic->devcmd_lock); - err =3D vnic_dev_disable(enic->vdev); + if (enic->enable_count =3D=3D 0) { + spin_unlock_bh(&enic->devcmd_lock); + return 0; + } + enic->enable_count--; + if (enic->enable_count =3D=3D 0) + err =3D vnic_dev_disable(enic->vdev); spin_unlock_bh(&enic->devcmd_lock); =20 return err; diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethe= rnet/cisco/enic/enic_main.c index acd05350ec1a..e7125b818087 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -1750,7 +1750,11 @@ static int enic_open(struct net_device *netdev) if (vnic_dev_get_intr_mode(enic->vdev) =3D=3D VNIC_DEV_INTR_MODE_MSIX) for (i =3D 0; i < enic->wq_count; i++) napi_enable(&enic->napi[enic_cq_wq(enic, i)]); - enic_dev_enable(enic); + err =3D enic_dev_enable(enic); + if (err) { + netdev_err(netdev, "Failed to enable device: %d\n", err); + goto err_out_dev_enable; + } =20 for (i =3D 0; i < enic->intr_count; i++) vnic_intr_unmask(&enic->intr[i]); @@ -1760,6 +1764,17 @@ static int enic_open(struct net_device *netdev) =20 return 0; =20 +err_out_dev_enable: + for (i =3D 0; i < enic->rq_count; i++) + napi_disable(&enic->napi[i]); + if (vnic_dev_get_intr_mode(enic->vdev) =3D=3D VNIC_DEV_INTR_MODE_MSIX) + for (i =3D 0; i < enic->wq_count; i++) + napi_disable(&enic->napi[enic_cq_wq(enic, i)]); + netif_tx_disable(netdev); + if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic)) + enic_dev_del_station_addr(enic); + for (i =3D 0; i < enic->wq_count; i++) + vnic_wq_disable(&enic->wq[i].vwq); err_out_free_rq: for (i =3D 0; i < enic->rq_count; i++) { ret =3D vnic_rq_disable(&enic->rq[i].vrq); --=20 2.43.0 From nobody Thu Apr 2 09:22:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3AFA3939AE; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838718; cv=none; b=g0HsyCmUYTdSaA/yj5OL2tKSf8tRujlnWYF6OqzZpCHhKQi9/LiWuChc/JUMZSuqqYxUlIXVmeliKrvgciX91dCanflJDb8cbTMG9UMdSDGC28SYhgSeameZDBEYCOxI9SzTHFtH28NF7/QE8rWBnc3LeMNNIhDaBeAApOYP/O8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838718; c=relaxed/simple; bh=WXpYpK3yhKn2sm0AMqrjWN6OL03+heVozAsWmGdd/6M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iaF5RXs11fvcsyJXZpc35xcEsDxcO4pne6TS1QAY7beWjVoVbxyC9E8bq9RByuG2XBf76SPn2BUf9rsit0x28kv1g80cU9ccoTnpbplXs7txl4uK7ty4K3vxp6Qe6d6GCyuYDC6KcvuEo5PwOpCtpqtc75hgcCnPvhM9cxLZjkc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rd+Oknxh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rd+Oknxh" Received: by smtp.kernel.org (Postfix) with ESMTPS id C5170C2BCB5; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774838717; bh=WXpYpK3yhKn2sm0AMqrjWN6OL03+heVozAsWmGdd/6M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=rd+OknxhIAKjWsUTjjsJym4N1MYvV2aWjvyw5LLjRWSFUrBnatF3i/luPIaM2+kDh 2xp1YU9ZcIJZBFpd33odebeknIF4RnoXKtG/z8uyXsHiqOZtef9mu8xQPiwNPviUmD kdt2e4lMaI7FvTLQEnXkHzRTevFhurfMbQNQRdJIaE+iFlT0GqBmMqyLWPYMdmCOB7 qac0JeUQiOycKj9Z7UycKknHwJKylD4FZJl5uIA/ysAv9jEQ5hT+YJM4mpKB5xyzQ3 WXjUUd43SEu8pyOiNp6zHlWY9yGcwvR5C68ESjRiFZaDaTE8iwpO4d92WRI2Qk8xS3 MH3+cNnTicQCw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD3AAFF4935; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Sun, 29 Mar 2026 19:45:21 -0700 Subject: [PATCH net-next v3 5/6] enic: add type-aware alloc for WQ, RQ, CQ and INTR resources Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260329-enic-sriov-v2-prep-v3-5-19a477549ef6@cisco.com> References: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> In-Reply-To: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> To: Satish Kharat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774838716; l=10146; i=satishkh@cisco.com; h=from:subject:message-id; bh=sStTy9Bg8r3IiBcBVUP3bIWBVt484dhT5KCgXRyPs1c=; b=hqDjqLx5Ao1tD97X7cUkKa1NE8ee5G4In9HhY+0vNut3lahiILGp5PQhx3KAYb1L1EtWLJHHf FjTYnBIhN6zCL8kX3TepE58vhVDx0poQBvTBfMbZZUyu1bwWDpyn9o4 X-Developer-Key: i=satishkh@cisco.com; a=ed25519; pk=4BxbLoCGvHeIMH/PbpiNVx8/2IcTjFvqcr0AD8K6WLY= X-Endpoint-Received: by B4 Relay for satishkh@cisco.com/default with auth_id=639 X-Original-From: Satish Kharat Reply-To: satishkh@cisco.com From: Satish Kharat The existing vnic_wq_alloc(), vnic_rq_alloc(), vnic_cq_alloc() and vnic_intr_alloc() hardcode data-path resource types (RES_TYPE_WQ, RES_TYPE_RQ, RES_TYPE_CQ, RES_TYPE_INTR_CTRL). The upcoming admin channel uses different BAR resource types (RES_TYPE_ADMIN_WQ/RQ/CQ, RES_TYPE_SRIOV_INTR) for its queues. Add _with_type() variants that accept an explicit resource type parameter. Refactor the original functions as thin wrappers that pass the default data-path type. No functional change. Signed-off-by: Satish Kharat --- drivers/net/ethernet/cisco/enic/vnic_cq.c | 14 +++++++++++--- drivers/net/ethernet/cisco/enic/vnic_cq.h | 3 +++ drivers/net/ethernet/cisco/enic/vnic_intr.c | 12 +++++++++--- drivers/net/ethernet/cisco/enic/vnic_intr.h | 2 ++ drivers/net/ethernet/cisco/enic/vnic_rq.c | 14 +++++++++++--- drivers/net/ethernet/cisco/enic/vnic_rq.h | 3 +++ drivers/net/ethernet/cisco/enic/vnic_wq.c | 14 +++++++++++--- drivers/net/ethernet/cisco/enic/vnic_wq.h | 3 +++ 8 files changed, 53 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/vnic_cq.c b/drivers/net/ethern= et/cisco/enic/vnic_cq.c index 27c885e91552..5a0dbb816223 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_cq.c +++ b/drivers/net/ethernet/cisco/enic/vnic_cq.c @@ -20,13 +20,14 @@ void vnic_cq_free(struct vnic_cq *cq) cq->ctrl =3D NULL; } =20 -int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int = index, - unsigned int desc_count, unsigned int desc_size) +int vnic_cq_alloc_with_type(struct vnic_dev *vdev, struct vnic_cq *cq, + unsigned int index, unsigned int desc_count, + unsigned int desc_size, unsigned int res_type) { cq->index =3D index; cq->vdev =3D vdev; =20 - cq->ctrl =3D vnic_dev_get_res(vdev, RES_TYPE_CQ, index); + cq->ctrl =3D vnic_dev_get_res(vdev, res_type, index); if (!cq->ctrl) { vdev_err(vdev, "Failed to hook CQ[%d] resource\n", index); return -EINVAL; @@ -35,6 +36,13 @@ int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq = *cq, unsigned int index, return vnic_dev_alloc_desc_ring(vdev, &cq->ring, desc_count, desc_size); } =20 +int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int = index, + unsigned int desc_count, unsigned int desc_size) +{ + return vnic_cq_alloc_with_type(vdev, cq, index, desc_count, desc_size, + RES_TYPE_CQ); +} + void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable, unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail, unsigned int cq_tail_color, unsigned int interrupt_enable, diff --git a/drivers/net/ethernet/cisco/enic/vnic_cq.h b/drivers/net/ethern= et/cisco/enic/vnic_cq.h index 0e37f5d5e527..d46d4d2ef6bb 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_cq.h +++ b/drivers/net/ethernet/cisco/enic/vnic_cq.h @@ -73,6 +73,9 @@ static inline void vnic_cq_inc_to_clean(struct vnic_cq *c= q) void vnic_cq_free(struct vnic_cq *cq); int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int = index, unsigned int desc_count, unsigned int desc_size); +int vnic_cq_alloc_with_type(struct vnic_dev *vdev, struct vnic_cq *cq, + unsigned int index, unsigned int desc_count, + unsigned int desc_size, unsigned int res_type); void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable, unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail, unsigned int cq_tail_color, unsigned int interrupt_enable, diff --git a/drivers/net/ethernet/cisco/enic/vnic_intr.c b/drivers/net/ethe= rnet/cisco/enic/vnic_intr.c index 25319f072a04..010ad8c2108d 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_intr.c +++ b/drivers/net/ethernet/cisco/enic/vnic_intr.c @@ -19,13 +19,13 @@ void vnic_intr_free(struct vnic_intr *intr) intr->ctrl =3D NULL; } =20 -int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, - unsigned int index) +int vnic_intr_alloc_with_type(struct vnic_dev *vdev, struct vnic_intr *int= r, + unsigned int index, unsigned int res_type) { intr->index =3D index; intr->vdev =3D vdev; =20 - intr->ctrl =3D vnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index); + intr->ctrl =3D vnic_dev_get_res(vdev, res_type, index); if (!intr->ctrl) { vdev_err(vdev, "Failed to hook INTR[%d].ctrl resource\n", index); @@ -35,6 +35,12 @@ int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_i= ntr *intr, return 0; } =20 +int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, + unsigned int index) +{ + return vnic_intr_alloc_with_type(vdev, intr, index, RES_TYPE_INTR_CTRL); +} + void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer, unsigned int coalescing_type, unsigned int mask_on_assertion) { diff --git a/drivers/net/ethernet/cisco/enic/vnic_intr.h b/drivers/net/ethe= rnet/cisco/enic/vnic_intr.h index 33a72aa10b26..2bc2dbffdb80 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_intr.h +++ b/drivers/net/ethernet/cisco/enic/vnic_intr.h @@ -89,6 +89,8 @@ static inline u32 vnic_intr_legacy_pba(u32 __iomem *legac= y_pba) void vnic_intr_free(struct vnic_intr *intr); int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, unsigned int index); +int vnic_intr_alloc_with_type(struct vnic_dev *vdev, struct vnic_intr *int= r, + unsigned int index, unsigned int res_type); void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer, unsigned int coalescing_type, unsigned int mask_on_assertion); void vnic_intr_coalescing_timer_set(struct vnic_intr *intr, diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.c b/drivers/net/ethern= et/cisco/enic/vnic_rq.c index 5ae80551f17c..a662d9fd1199 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_rq.c +++ b/drivers/net/ethernet/cisco/enic/vnic_rq.c @@ -69,15 +69,16 @@ void vnic_rq_free(struct vnic_rq *rq) rq->ctrl =3D NULL; } =20 -int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int = index, - unsigned int desc_count, unsigned int desc_size) +int vnic_rq_alloc_with_type(struct vnic_dev *vdev, struct vnic_rq *rq, + unsigned int index, unsigned int desc_count, + unsigned int desc_size, unsigned int res_type) { int err; =20 rq->index =3D index; rq->vdev =3D vdev; =20 - rq->ctrl =3D vnic_dev_get_res(vdev, RES_TYPE_RQ, index); + rq->ctrl =3D vnic_dev_get_res(vdev, res_type, index); if (!rq->ctrl) { vdev_err(vdev, "Failed to hook RQ[%d] resource\n", index); return -EINVAL; @@ -98,6 +99,13 @@ int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq = *rq, unsigned int index, return 0; } =20 +int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int = index, + unsigned int desc_count, unsigned int desc_size) +{ + return vnic_rq_alloc_with_type(vdev, rq, index, desc_count, desc_size, + RES_TYPE_RQ); +} + static void vnic_rq_init_start(struct vnic_rq *rq, unsigned int cq_index, unsigned int fetch_index, unsigned int posted_index, unsigned int error_interrupt_enable, diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.h b/drivers/net/ethern= et/cisco/enic/vnic_rq.h index a1cdd729caec..9fc2090eac44 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_rq.h +++ b/drivers/net/ethernet/cisco/enic/vnic_rq.h @@ -196,6 +196,9 @@ static inline int vnic_rq_fill(struct vnic_rq *rq, void vnic_rq_free(struct vnic_rq *rq); int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int = index, unsigned int desc_count, unsigned int desc_size); +int vnic_rq_alloc_with_type(struct vnic_dev *vdev, struct vnic_rq *rq, + unsigned int index, unsigned int desc_count, + unsigned int desc_size, unsigned int res_type); void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index, unsigned int error_interrupt_enable, unsigned int error_interrupt_offset); diff --git a/drivers/net/ethernet/cisco/enic/vnic_wq.c b/drivers/net/ethern= et/cisco/enic/vnic_wq.c index 29c7900349b2..5a20bdc62141 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_wq.c +++ b/drivers/net/ethernet/cisco/enic/vnic_wq.c @@ -72,15 +72,16 @@ void vnic_wq_free(struct vnic_wq *wq) wq->ctrl =3D NULL; } =20 -int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int = index, - unsigned int desc_count, unsigned int desc_size) +int vnic_wq_alloc_with_type(struct vnic_dev *vdev, struct vnic_wq *wq, + unsigned int index, unsigned int desc_count, + unsigned int desc_size, unsigned int res_type) { int err; =20 wq->index =3D index; wq->vdev =3D vdev; =20 - wq->ctrl =3D vnic_dev_get_res(vdev, RES_TYPE_WQ, index); + wq->ctrl =3D vnic_dev_get_res(vdev, res_type, index); if (!wq->ctrl) { vdev_err(vdev, "Failed to hook WQ[%d] resource\n", index); return -EINVAL; @@ -101,6 +102,13 @@ int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_w= q *wq, unsigned int index, return 0; } =20 +int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int = index, + unsigned int desc_count, unsigned int desc_size) +{ + return vnic_wq_alloc_with_type(vdev, wq, index, desc_count, desc_size, + RES_TYPE_WQ); +} + int enic_wq_devcmd2_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int desc_count, unsigned int desc_size) { diff --git a/drivers/net/ethernet/cisco/enic/vnic_wq.h b/drivers/net/ethern= et/cisco/enic/vnic_wq.h index 3bb4758100ba..1d448b7a9ba2 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_wq.h +++ b/drivers/net/ethernet/cisco/enic/vnic_wq.h @@ -165,6 +165,9 @@ static inline void vnic_wq_service(struct vnic_wq *wq, void vnic_wq_free(struct vnic_wq *wq); int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int = index, unsigned int desc_count, unsigned int desc_size); +int vnic_wq_alloc_with_type(struct vnic_dev *vdev, struct vnic_wq *wq, + unsigned int index, unsigned int desc_count, + unsigned int desc_size, unsigned int res_type); void vnic_wq_init(struct vnic_wq *wq, unsigned int cq_index, unsigned int error_interrupt_enable, unsigned int error_interrupt_offset); --=20 2.43.0 From nobody Thu Apr 2 09:22:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFD293939AF; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838718; cv=none; b=c11kqI5PZyiJJ+nJs0oATJZ1HSypRU6vqZowhBZgn8YAXb7rnlLuxp6eqlUYE3mThpQY6Gj1baRquLJfWEzAxblgdyvE6TUPemnsk3Lk3rhZCTuaqFZmeSJssaIcrK6+W7VlxeC98q145XioZj3fsxqEKksF8rL5LGZagiTbq5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774838718; c=relaxed/simple; bh=YhIMr4yYwBZ5EllsEmbIO/ym48ayC5JDhQ8YCwvYqy4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Btvt+6GaAHi+ilDoYKvtNN1k0GP3ozozvJ6UdrMjMniVylRg4FAVFdUq/cuZZo5L1F7XJ7eomtacaLxJbAPhJoMBRqIWqZkxbEQ4wm9WZhQ3AEjzDZSq6Exa3yphcY4I5gm4+wQduLRG4HlNSJ3ZD3Xez4BWTG33xyWKsDOKPY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kT+U+oJA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kT+U+oJA" Received: by smtp.kernel.org (Postfix) with ESMTPS id D23E5C2BCB2; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774838717; bh=YhIMr4yYwBZ5EllsEmbIO/ym48ayC5JDhQ8YCwvYqy4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=kT+U+oJAZyIxRAtDgVTRzxcEg4FTCHTNh4TziPcxfubv8KFYBMVKv0xsKbcGKWFaN mzZyif+OagQBy5a5LkoGK2jRTSPOFHqdet+vUEXUSHs17WGfmrFYZssWQOd7yeBV4D Dqyxi/uG7KBLFg5CaYFq4HVPTIi+YKbaE7xLRzmlrfDlN3jxr6rJGNweMNfbFKpGgj fRr14m6/xeht05GKoUbpruWzlBjM31CHspwUhM2OacWJJMujRvf9Whk8aVor8zKiFa /boW/ccDkLli8t3d8b6werWrq34CPyiJfFrLPzY2WuKCmOl7g0eMVg7PjzfjeaS9Cu rATSDVD8RC6Kg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBB18FF4934; Mon, 30 Mar 2026 02:45:17 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Sun, 29 Mar 2026 19:45:22 -0700 Subject: [PATCH net-next v3 6/6] enic: detect admin channel resources for SR-IOV Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260329-enic-sriov-v2-prep-v3-6-19a477549ef6@cisco.com> References: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> In-Reply-To: <20260329-enic-sriov-v2-prep-v3-0-19a477549ef6@cisco.com> To: Satish Kharat , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774838716; l=2466; i=satishkh@cisco.com; h=from:subject:message-id; bh=1nJliUotDMusF5w/UMmuyqwJOqlCYgr21D/fx9rjM1w=; b=FP3N6n9JNqA14RAcxqQshUiFQzZBox6Hs9ztDbhE85d+PFcCHb2lUFqDb+YhKX9YHpF/yaE8j GOKEOtvVDYaCEZQAGa6PQk5dxH8bmwgEKsBktNdKFJMu0DkDpYCipUg X-Developer-Key: i=satishkh@cisco.com; a=ed25519; pk=4BxbLoCGvHeIMH/PbpiNVx8/2IcTjFvqcr0AD8K6WLY= X-Endpoint-Received: by B4 Relay for satishkh@cisco.com/default with auth_id=639 X-Original-From: Satish Kharat Reply-To: satishkh@cisco.com From: Satish Kharat Check for the presence of admin channel BAR resources (RES_TYPE_ADMIN_WQ, ADMIN_RQ, ADMIN_CQ, SRIOV_INTR) during resource discovery. Set has_admin_channel when all four are available. Use ARRAY_SIZE(enic->admin_cq) for the admin CQ count check since the driver allocates two admin CQs (one for WQ completions, one for RQ completions) and both must be backed by hardware resources. Add admin WQ, RQ, CQ and INTR fields to struct enic for use by the upcoming admin channel open/close paths. Signed-off-by: Satish Kharat --- drivers/net/ethernet/cisco/enic/enic.h | 7 +++++++ drivers/net/ethernet/cisco/enic/enic_res.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/= cisco/enic/enic.h index 67fd780b1fa1..08472420f3a1 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h @@ -289,6 +289,13 @@ struct enic { u8 rss_key[ENIC_RSS_LEN]; struct vnic_gen_stats gen_stats; enum ext_cq ext_cq; + + /* Admin channel resources for SR-IOV MBOX */ + bool has_admin_channel; + struct vnic_wq admin_wq; + struct vnic_rq admin_rq; + struct vnic_cq admin_cq[2]; + struct vnic_intr admin_intr; }; =20 static inline struct net_device *vnic_get_netdev(struct vnic_dev *vdev) diff --git a/drivers/net/ethernet/cisco/enic/enic_res.c b/drivers/net/ether= net/cisco/enic/enic_res.c index bbd3143ed73e..2b7545d6a67f 100644 --- a/drivers/net/ethernet/cisco/enic/enic_res.c +++ b/drivers/net/ethernet/cisco/enic/enic_res.c @@ -205,10 +205,18 @@ void enic_get_res_counts(struct enic *enic) enic->cq_count =3D enic->cq_avail; enic->intr_count =3D enic->intr_avail; =20 + enic->has_admin_channel =3D + vnic_dev_get_res_count(enic->vdev, RES_TYPE_ADMIN_WQ) >=3D 1 && + vnic_dev_get_res_count(enic->vdev, RES_TYPE_ADMIN_RQ) >=3D 1 && + vnic_dev_get_res_count(enic->vdev, RES_TYPE_ADMIN_CQ) >=3D + ARRAY_SIZE(enic->admin_cq) && + vnic_dev_get_res_count(enic->vdev, RES_TYPE_SRIOV_INTR) >=3D 1; + dev_info(enic_get_dev(enic), - "vNIC resources avail: wq %d rq %d cq %d intr %d\n", + "vNIC resources avail: wq %d rq %d cq %d intr %d admin %s\n", enic->wq_avail, enic->rq_avail, - enic->cq_avail, enic->intr_avail); + enic->cq_avail, enic->intr_avail, + enic->has_admin_channel ? "yes" : "no"); } =20 void enic_init_vnic_resources(struct enic *enic) --=20 2.43.0