From nobody Thu Apr 2 22:13:14 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 54CEE328260; Thu, 26 Mar 2026 05:18:59 +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=1774502339; cv=none; b=RlslipjJ5jYCgFLjkBieBYsDN8oDEW7R0jpLBKT1HTkWuqztHBE/Zy+crs5DM5oAiG4cm0yWsNymh/Fl+qQcBGHRQISTFY0WUqrJJ8u/CDyq1bBG5Ykiolm3ubE+1DrglFhPwnxlA0Aza25Qrs/7Fqiv+aotsHmT9cLRbPBJkEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774502339; c=relaxed/simple; bh=qHwtEmiaUzALs1U8lxciI7QvUZJpw94pPRYf1wfFSqU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FpY9TqzBM7n/axGvNCi7gI1KcXTtkf5d6Vq/M2bTywi2OIK4lfYvYFv+CRmDQ34Kaq5u0x3LFHqmD3PDbzebqWn3uL0oybwQ04+DYxfe38lQozKjFv+AR8oM98wacy8oU8ojyPOLNlV1kfmXqtR8qQgOr81S3Ku1nGU7uXbGhDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CFswEQtm; 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="CFswEQtm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 30153C2BC87; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774502339; bh=qHwtEmiaUzALs1U8lxciI7QvUZJpw94pPRYf1wfFSqU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=CFswEQtmEknwRv3F/kroYtIDMRI9+9Vn2lSXcToGZa8VqYW70KIO2rcT+oS38t2+V mWv/uJlyLkW1dO1ZteDPZvJdGmLVDE5ajxrRe1h2vwo6lnNBybF0HCjIAV3u5WXeuw Dsp3hVg4fQrmckHh/q7L938VFQpt7XHaBMHp5Zjg/ZvIeyE+DJmoQUYeg24yCZGp+0 65O6aZkpj4rYpuaWhf1dHMMWXguG/mjNJp4Nd3xpbGn4O98A84h5v1U8GDjhoR+//L oq9GGzNIPtj4DWs3bkHLKDWXfJGTFBvDknB7Yl7Twld9HXA/buU8RLmyc5Q3/XGUfv JKEGOb0GUjeZQ== 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 20520109E552; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 25 Mar 2026 22:18:59 -0700 Subject: [PATCH net-next v2 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: <20260325-enic-sriov-v2-prep-v2-1-f72cf716ebfa@cisco.com> References: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@cisco.com> In-Reply-To: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@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=1774502338; l=3356; i=satishkh@cisco.com; h=from:subject:message-id; bh=y0pGwL9wW5ULZUwdK19OUJqESwm7dxXUYk9R9IIroV8=; b=jezU0suFcewUN+3irj8bvJDft8gAVHaGGfGq/nHL+Wcv5Pc4x88C+DYLfOjZYrlPxgS83830c 64USyhns6MiDuY8+Y3HYUCNyeOpAIkkvwLXxj7bkLxC16cIxgD/1TI7 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 22:13:14 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 88DD5344DB5; Thu, 26 Mar 2026 05:18:59 +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=1774502339; cv=none; b=dhauZm4ynsYQPxXKkAzRB8PJou11A0RYdx5PMb83RnQJaQnmJOyGhGYwZY+a9roTwCqiFFEEM1hywNAi9V+jGzVwQ7YKPb8HmFSMqRVf2l0ZIjNCEPyP2Tethg7ggJNlbxXszzraMfL1cGx920fj2R4ob5PW1bTGLMWYhrgXshI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774502339; c=relaxed/simple; bh=GaJWaVTbn/UL3B4IZ3JOup4VGmfvjwuuWoZ7Ej05S78=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lT4LaAbok1SMdqVjBsj3BqbeaCuG8KNWeGUZDJcRa7zdVaE3fu8b5E9Yil39VQPy7J1PDKZG5bzRnRFIHhk2oeeObkryjmsNZDlOHbx8dcqoMKiUC0NGfPzUEZIXpoYTi79SZHyzbmYPhXCc20gw4UZjIlVgaS2F3XovkBDQ0KE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A+SH05WW; 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="A+SH05WW" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3D623C2BCB1; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774502339; bh=GaJWaVTbn/UL3B4IZ3JOup4VGmfvjwuuWoZ7Ej05S78=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=A+SH05WWMZAWbAjWDLduJrTACdXoQTHUfU3Ur+ZJwDbqx3NfS+v2fT7pVW1iBU8p4 TcCxG1EW+U9FRRRqbT0Nq4AyuL8h956XIN/KkpJQl0OllErcCJGfinDupgazCvHST2 Pyonj5p4LLj6767qCNTAV11MdjVA4fxEU/PyZgUxCuYrJa7Gyo2rgGFHFCqb0VOqpz 1EehLuAt+XGpFNTH2splid+x3qsJTvjoybV7LErRyVse114TOkOso/e+s73gHpv16s vPsLcdfO/evYW68mOywnqdW66xXz8KFUj50i4mrd7vXUrtoPmU7t6fwZVSgVauYFJZ DFKMviVGpd2HQ== 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 300D5109E54B; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 25 Mar 2026 22:19:00 -0700 Subject: [PATCH net-next v2 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: <20260325-enic-sriov-v2-prep-v2-2-f72cf716ebfa@cisco.com> References: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@cisco.com> In-Reply-To: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@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=1774502338; l=1690; i=satishkh@cisco.com; h=from:subject:message-id; bh=1chUHjnI8ZuULFMfvuOuwWNT2kAEAJEGnPmXwEaCezM=; b=LCqCZMsAv5YdqO+10oiZx4mUxfjzGgAdI+3ydSKmeNTVJ1MYaZQqN1qJs1nh94NLXJRG8FbLv ytm1oWn9e3CBKsRILsXjjA915aFc8jXbI3uYNGo6zGbQyMrJyIaOWgZ 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 22:13:14 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 88CBA33F5BC; Thu, 26 Mar 2026 05:18:59 +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=1774502339; cv=none; b=TyDjedoeiWBhycL4F03VZxCpkyQ5jQNAcCa83BKiOSOH7SSlN4XzsZdMSdKNBoOLti9HoZ2/ixNPTUrlemhX/BS3AZKcxQk+reVHXv9qJaMkioIVNrNJoIvesx2dO1Hvn3QuOZcuAEQE+sbCaUOPcWVsW/C8jXGNO9IiZccVqfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774502339; c=relaxed/simple; bh=ZxR9g+zCxK8pArCJ7PTFR8axACYwGxTDHOn4nO9U1U8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E/8eTRKiDWbqEAHg9dGbMTH9PDAwhFLpPaMAMJ4cBqLpRCokZKl4IEtCQ9MLVx/eWPZ70CDXeNpIhveWxG7DkBTGNqIkkdtJwmBI48e57+EnfDTcjMeql+MH3jpDfllwMi7H2ykPVaIpfboDQco+lne6ygFuMWT9Mm/jrvxktOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OEn/zSbu; 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="OEn/zSbu" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4722EC2BCB2; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774502339; bh=ZxR9g+zCxK8pArCJ7PTFR8axACYwGxTDHOn4nO9U1U8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OEn/zSbuLWAqDs7LnTNsxTluRfu9aP8df5/l/ORq7XVZLeMg4nCLfaLafAdOm6xcn 06AuBcM/axg0e3oH1nua/Vn/rvUFetXmIdOsEcreNhMuZEFx31rIhfBQBjFcTg4EL8 jWLH5WNynLCZMtYGRnqeSeRDLtmjhoVr4ysAWwnPuF9pIFxoRrImYayKs+VsT0X/m1 3Yc/Wlg0nj+c5fUNU/W3V76qGJHpZwjNvG4O3sxbg6+D+VLCtj17wMEf+xK+oW/H4p rKmDfSNt3qlYDRaj6TYWqEyiqebZdyYRx1vN7MUj5fjV5dxrapqgguvalP0gvLX8JQ tocRoCCChSb2Q== 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 3F96B109E536; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 25 Mar 2026 22:19:01 -0700 Subject: [PATCH net-next v2 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: <20260325-enic-sriov-v2-prep-v2-3-f72cf716ebfa@cisco.com> References: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@cisco.com> In-Reply-To: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@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=1774502338; l=3365; i=satishkh@cisco.com; h=from:subject:message-id; bh=EHjug9jFvuqtjK7rgKqTb+ZxcNgtnQ9ViaQc7HzlDNE=; b=AD0i77XBku6AEiTk8t2xkYir/gIjsd+fXx33Dw+/aSvAoL7RtiUjMV2ymSZWUddEPfCfux/yC q9l8UMp/3BDAoM1M835/mWX+uB0Jd9nf0RmRbbj2QmHcY9qSaA1A3fN 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 22:13:14 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 88D453431E3; Thu, 26 Mar 2026 05:18:59 +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=1774502339; cv=none; b=cE8RjpVSyy4aCV/hV+LQfys08FideUkUlnoZaXIPSE8x+XmUnoAf3kXPot/pD4WwTXk2IpSDksepPQYOStXxrsLgqHL5BM8fcpU4Bn+MraI7qdPT5eX8/ALhp0Ql065AiGRjw2gYRjts6bILO53bDrXg37D+HhmCvKnw2a5Rb7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774502339; c=relaxed/simple; bh=8nzLFxeuDNYsf3IkWcj76Hg9mmDN27Zptu4KIN/CWj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Eo1EuqbufAvL5d5NspDmRRrhHwnERi2w/PTr19vfUKKSLd35qTAIx8V6fnB+4G+0sA0bx7BiFzAFq5m+m8KW7BiGn4Cdkahvi0u/+po1cxf99ZNmh3nOyIJWR3zK+x0J7+h+JyAPpR+Lf1S8Y//40zTyGiQ0EtvT0Gg+U5EmlMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Uw2Fg2Aw; 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="Uw2Fg2Aw" Received: by smtp.kernel.org (Postfix) with ESMTPS id 560E5C19424; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774502339; bh=8nzLFxeuDNYsf3IkWcj76Hg9mmDN27Zptu4KIN/CWj8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Uw2Fg2Awo2ZC9SshWNX4To5unpSLUgX8Nt/lJ5MMzcGuMy7/PpqhCPMPAMJ0Xl8iG tvCd5vJ55w+kczDAll/72TkDfTaSMKrltXjzr5kt6r0hK6wD2JycJ9scgUUOEPizyP WIO8ftd0+ivEGLcewGxESW5dJBzDw1QyMyotIGUVOAxDct49KViDDCw814Da+qAjRy Icxx1q02UJ4HXkNTu3cKD4lsfLCWRkQClfPF1lB7EhhAAYq1zz2P/ZqjGIwvgSUmAk 290lcq7ByzxILXuZwFLzi6No5zGaDRhZtiq7/MX93TNuHKSeiY1NqhlefYykDum0PW +NwP6cRVvBe+A== 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 4E290109E553; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 25 Mar 2026 22:19:02 -0700 Subject: [PATCH net-next v2 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: <20260325-enic-sriov-v2-prep-v2-4-f72cf716ebfa@cisco.com> References: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@cisco.com> In-Reply-To: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@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=1774502338; l=2385; i=satishkh@cisco.com; h=from:subject:message-id; bh=UFxmA9CX8KV13iHlUmy26fUHGETjz4zvpBBpux+w9yI=; b=JxRD9wvJzsZNpmzXqnmy0W1K9LtqxIV3ezpNSHS96K1Hwfi6DG/04EE0ofRjcwuhe48wHQhNR qXU2fFOgy59Dg0xQFVEof8u1lRmjRsDvo3Adgu0xnAnymdZj2sBD3jJ 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). No functional change for the current single-caller data path. Signed-off-by: Satish Kharat --- drivers/net/ethernet/cisco/enic/enic.h | 1 + drivers/net/ethernet/cisco/enic/enic_dev.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 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; --=20 2.43.0 From nobody Thu Apr 2 22:13:14 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 89383344DB8; Thu, 26 Mar 2026 05:18:59 +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=1774502339; cv=none; b=Wo7FunVydTNDUurpqQccMyUoJfP+AEAHxnP6PTLHKsYcusEds8MVmkh4LwuRwlkD3HI6R+dbs3Ddr3EU2BBxwQrC8FFBoooXpcnUA/wD/1pSgfVsnYZ8/9FXGpK/qkfDR8QzOn4HKrpWIbRvcmUbWhdECIRhekWJEL08bXbWRqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774502339; c=relaxed/simple; bh=WXpYpK3yhKn2sm0AMqrjWN6OL03+heVozAsWmGdd/6M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O7oMkCo4D6V+iPADrB5e4ln2CLls8+7+Az9ZVEQcDTX2rg+oVAlmPVgaSARqW/Pk8WuGkNACXAOPHhxtttLbfxqAtMojFlc3U9pTQM4S2qoZU9FZH4ZfAnZol86s3YJovuy1vPio+yGjGBF4nizpVGZwggKW1p7Jl9IjgBPBegE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CMgVwr6z; 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="CMgVwr6z" Received: by smtp.kernel.org (Postfix) with ESMTPS id 663ADC2BCB6; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774502339; bh=WXpYpK3yhKn2sm0AMqrjWN6OL03+heVozAsWmGdd/6M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=CMgVwr6zvHiMBPYvnarXKD4unJXle9+gHNHUiJA+7tUAgCh+cKV1dNfj7RUhnp2wJ YWr2tBpspjmw9ZKyTekh43Qk6wIJ3S3Hq7vHL0nvIqfgOBONo6wzGrfUcDpkn/SA9V DiVBGNTYXNBK/fFU8w0DtTFKqidAK4z2cjuFth/IyNytO458z2pFnd8+li3Q1lDWAC 4p97DSZtqnUIKATnwxgj+14jtaV5XRMfakUazT0ngQ/AKelfMYolzJUq2RdzTwpvL3 5I0Z7fC4dF0oLDTlkXAKKZFMX1+XyMppGyN7wazTpjsHCNMFWTzfpQj26qyMNbGq2d aQcj9Coucm2cQ== 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 5DACA109E552; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 25 Mar 2026 22:19:03 -0700 Subject: [PATCH net-next v2 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: <20260325-enic-sriov-v2-prep-v2-5-f72cf716ebfa@cisco.com> References: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@cisco.com> In-Reply-To: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@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=1774502338; l=10146; i=satishkh@cisco.com; h=from:subject:message-id; bh=sStTy9Bg8r3IiBcBVUP3bIWBVt484dhT5KCgXRyPs1c=; b=1AeXR4Qe9/ZzOao/5zi5lVsMQHeeotUIF0pvS5hbFaIBl3HripGofdvwNjDQ0nkMzgrcKVGlA bIc4m0IH19RBBTTv4HvaHXzwMSJ4Wf4XOEAhZr0cQdAjdtOV7Gd12xj 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 22:13:14 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 AE5C3358381; Thu, 26 Mar 2026 05:18:59 +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=1774502339; cv=none; b=qP6fCT93aJxufRQji8BpEpC/D9ptFg4rLtIyhG4hVTLc/INxFDG31PoaUbSvGe7L1DKG+RSoIDZ0ePHbpOprrnlrMD09x2F0fxXkPcY0GLWyRrFFIKR/a4gHxYGqxO9Pg4yuwJibGuFytqNEOvuwJC7P01hw+gPkKT1QtVvGXBI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774502339; c=relaxed/simple; bh=DqwtVVfKBRtZG90awt3Hou5/bkkSaWRQy8JNg+A+L0k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gMOCKckBxo5xUPPir5hs7wWSZYE17fu6gKMu+W94Lu6HYgwKvGgEOlK2RE4880VbWRDnuqZO+bPb5MALSrB1W0pMWaM+f1NemrfAHUeSp2tDGBd7LmB/vvA5qksX0T/oXvaC6Z4df2Uoz1W0+wSEc8fsWqjTLG1CKe5nF0rI6SE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fB2m3Fx6; 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="fB2m3Fx6" Received: by smtp.kernel.org (Postfix) with ESMTPS id 78E47C2BCB5; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774502339; bh=DqwtVVfKBRtZG90awt3Hou5/bkkSaWRQy8JNg+A+L0k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fB2m3Fx6Bam1osAubW+SCM9REbC3zJETRa0/psToJB4Xofl0O2PYdyJLrfIBbeBfa GYnVTgP+MJpNRIPSSg+vknTxEQPXg6ZWjLvubeEYacn5TEq8xaI6d9K1DvZ3NKQ/61 nDbPcoyxhvK1lnKjhJMZC9XoOHNMXA2H5TGlb+gdLkD4pCf4ViBVSYU7E6GFn49rYs Cvr7Cwxkpw7VLfmSf7UO7+OmAO4MoF3q/AivWReNDhfzENPwJklFugsXksmrMIyStI oBqqkzo8BO66lYkolix7ImT1wS35U3yDZ/RdVDfHXKkx75mRD/uqhIGatBaj52PJ8e TNl/9EesTCF6w== 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 6F906109E54B; Thu, 26 Mar 2026 05:18:59 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 25 Mar 2026 22:19:04 -0700 Subject: [PATCH net-next v2 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: <20260325-enic-sriov-v2-prep-v2-6-f72cf716ebfa@cisco.com> References: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@cisco.com> In-Reply-To: <20260325-enic-sriov-v2-prep-v2-0-f72cf716ebfa@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=1774502338; l=2233; i=satishkh@cisco.com; h=from:subject:message-id; bh=6gUIHgzzr9QVCSafrLsAZ7By14yZUVkLBmnYaiDR2i4=; b=v7GTUw7Kvzi5vlc2XcICGyia+rK8OidbGzAvrvW5RBuE1VWde3IFOyIh9G78zee/JGI549ClY APmSYeGiS2KCsHTtha+X2mqcf1GvhBsctsQ9Suxhi1/K5cBv/aVeGRl 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. 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 | 11 +++++++++-- 2 files changed, 16 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..5ca3e5aec7f9 100644 --- a/drivers/net/ethernet/cisco/enic/enic_res.c +++ b/drivers/net/ethernet/cisco/enic/enic_res.c @@ -205,10 +205,17 @@ 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 1 && + 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