From nobody Wed Apr 1 21:00:03 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 8F412272E7C; Wed, 1 Apr 2026 15:31:15 +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=1775057475; cv=none; b=BLcz01OXQl54ZXYeydVb7VGZuHAJuxt5zBCrJvCpTh5CtU9Om2micWgWee02oAHeq+YSSt90+ONYBNE274I53YdysKDxhM/l+eFJy832TL4mZkcx/5M3trZnsxvRAYvE0IGKYXvGYyno1tIulgTkO8z4uubMboJXXkAfQToMEmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775057475; c=relaxed/simple; bh=qHwtEmiaUzALs1U8lxciI7QvUZJpw94pPRYf1wfFSqU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y8VO83eW7W25kURYO5cGqUbtGIYMk1iXHUb5XDdBoxtW4jIAro9yv7mLTfW4n+FJePSHVPNzqJ750rKo86cg2OCrMQ/XfjyMbHwtbKZOHgK7Spxdo5nFSKReQ0fU/o94biJ4HOp1L/FNPL6vUKZZnWrG4P5fRZ8DBZzfZ2CkEtQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cMmyiwom; 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="cMmyiwom" Received: by smtp.kernel.org (Postfix) with ESMTPS id 33F1DC19423; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775057475; bh=qHwtEmiaUzALs1U8lxciI7QvUZJpw94pPRYf1wfFSqU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cMmyiwomhgLSso3TKn4eYkzFQVY088BFI58f3gpMh8a6LLqnd17myfxG7CP4XU3ti XMX6Gxp+SN2GtVexdhjqNVkR3wwvTwri1u/2gYMiywHa3r5eLwNACCkYm+xTxCkpFx dbkG2nKNnMngWzTLfwr3nqcJY9g7HBnPihV6PPeZfcgMQJMWlDpjZYKD8ph9HvwSA7 MnMzztkmaQ2dqwfrfxmS9p9CuuEFvbG8/cfjMW3y5xLR+3J66KKH7GtSLa0T35Lk0f QQnUIBmBl40X07f3jgFtAUTI8ypZ3S4ionfG0ByI45fQtiMCa5VL8HBbHIelDU6UJR hK+fDr/xJSMqA== 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 08FED10F6FD9; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 01 Apr 2026 08:31:11 -0700 Subject: [PATCH net-next v4 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: <20260401-enic-sriov-v2-prep-v4-1-d5834b2ef1b9@cisco.com> References: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@cisco.com> In-Reply-To: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@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=1775057474; l=3356; i=satishkh@cisco.com; h=from:subject:message-id; bh=y0pGwL9wW5ULZUwdK19OUJqESwm7dxXUYk9R9IIroV8=; b=ZP9Adj0tYDtyKk8NvLNaGcW7dIiyFFcr0tbrBPONiWiuehFPYidDcpH6qC7pmXcqmXfbajRdE 0FnBEGKIU2pDQEMzhIZh4oo313Rk0QtzRildB1suTNEcikpT5Phf8Ds 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 Wed Apr 1 21:00:03 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 8F3A3272801; Wed, 1 Apr 2026 15:31:15 +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=1775057475; cv=none; b=ssnLMC3tui/vKio5qxcNDIGERihS17sMm8fxOTy16q5DV/QPyzOETUXL2HaM1dIetI7wZrXpjrExaJktqfZe0hVFQjQyuaSl7hgSyUS4n0UB4a2nV9vLrawoSaKdEHsvj1zG3CVg5+lcg24u1ynkKwg26jqGeJbUzLqeihlG3qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775057475; c=relaxed/simple; bh=GaJWaVTbn/UL3B4IZ3JOup4VGmfvjwuuWoZ7Ej05S78=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ju/wXPJfnk6+xiZOXe90kUcOkhVhCazsdd5yNwSZVnhNgc3qZtg19PWOXNhMcqX7ynlfRJKl+F+92+Iv8n8lODjYa62qxJyLrr8+p4LoCrlos4cFGIm9xH02oGsrN0K6alW0prEV/lPb6mWsiXVk54HpKhJVP33RFLU8AcYbOnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ruSnJGof; 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="ruSnJGof" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3A489C2BCB6; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775057475; bh=GaJWaVTbn/UL3B4IZ3JOup4VGmfvjwuuWoZ7Ej05S78=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ruSnJGofAJWvrkz5NtIAObFjp/7vnROm9jL9nU6kHRCyJGoS6oldOcBnj5XDNXHCP SLRMpZ24Ty5xUYc9ba5+J8AmG2AVv+It1e/SdIy75C9GcuZpgt7GDVwJGT5KVuQwQL qT2Ism5sn12zx+0fB9ZqJaCND6J2oBto1Bk7jKNnI5fMq79amPkag/D2t3WvcKP0XD /AkIv6okWHUawZKiJXPGkbN9+iKsVOD5dop0bsr4cCnD11UD2C2dv8aZ8j1RTbjop+ yuB9bXND5M6Nzm+74gmVe4+qzWvonRRihTZF9yIIuUHVgYBZJMz+7k57STW6i7EKbm qS+Gyv4NWatMQ== 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 1917810F6FDB; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 01 Apr 2026 08:31:12 -0700 Subject: [PATCH net-next v4 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: <20260401-enic-sriov-v2-prep-v4-2-d5834b2ef1b9@cisco.com> References: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@cisco.com> In-Reply-To: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@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=1775057474; l=1690; i=satishkh@cisco.com; h=from:subject:message-id; bh=1chUHjnI8ZuULFMfvuOuwWNT2kAEAJEGnPmXwEaCezM=; b=VdARdc/68EthQ2LiE4zTo5gPesx5qdedeo65YYbauF5KIG0/QcpnXZLrXRh4wjBtI3Q7r0AE8 hfzhR4fDH+YDU3jZeI5hyzxYViv0CgoEwujZl/Vri0UeRIBDh18puHE 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 Wed Apr 1 21:00:03 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 9835D31E848; Wed, 1 Apr 2026 15:31:15 +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=1775057475; cv=none; b=UULxjz97LY65V59G/WK7VY11ZZsGM1HMRvYZMVTRKGnGHodABNPMVmRiDk61SB1ws4LxZhGteOaMUsAs1wyL0RcsAsT6ifCKbdLMa+3atamo9U4oodPw760tQSWBoKJd2SAdE17lfCW3Gqp+SGltCaRFJ7KbDIgI2rLyvj6SWrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775057475; c=relaxed/simple; bh=ZxR9g+zCxK8pArCJ7PTFR8axACYwGxTDHOn4nO9U1U8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d8mq1U5iJrFKH+2zklwiuiIn0B3nKokXt4EZ1E81IlKXsL2Wwx5BywX1cTdPovc9QiMpnRcxLJkyfukkFp5tYVkJLyjLjH5yN8KoqHHW+WeBYVQqc/aarAptRoQUnRRZA9n83Je+GOSVJa/qqo8ieVGaCW9ntj+WM1ynmy1a4oc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uA0oydwT; 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="uA0oydwT" Received: by smtp.kernel.org (Postfix) with ESMTPS id 51B85C2BCB7; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775057475; bh=ZxR9g+zCxK8pArCJ7PTFR8axACYwGxTDHOn4nO9U1U8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=uA0oydwTFgmYGiier3lyvcobLsquPjGlxR4v5y7mS1Je36CQAFHwuJ2RbD6i7Jh2r 6oMj/FWcmZHSyccf0GLx02bW2wcprmjA9MEMdrdakcA+KZbRFp/LLS5osewihZMh+K daD26feJHuF+gAx+sx/T5NGk6Wlr/zCLu3UyiCkbq5ZzHfH2ZZtDX5O7f0NQZ/Mc8s s1io8VHFb5P+4wHZ4TQTweETM1wO05kIwsleZquvI46Y6jdfU5mX0EYccBlnJ/n6xP lvcdKgtO3lNMg0nbsy/wD8uvFinWHhatlVtBzsqMjxqduFXQTLW69RSOX5zP0Sx75W tJLllct2UMIPA== 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 2832510F6FBF; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 01 Apr 2026 08:31:13 -0700 Subject: [PATCH net-next v4 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: <20260401-enic-sriov-v2-prep-v4-3-d5834b2ef1b9@cisco.com> References: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@cisco.com> In-Reply-To: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@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=1775057474; l=3365; i=satishkh@cisco.com; h=from:subject:message-id; bh=EHjug9jFvuqtjK7rgKqTb+ZxcNgtnQ9ViaQc7HzlDNE=; b=vJPjAYIT6ICjjuxvqdFVbQXPctQcktrz/bLD7aFH5psIc8RpqXJlPmAIN5lvKkGG+nYtsLBlR zJn/g44P3m8A6VLlqEDzHlgHvU9A/wSzgFRamOBUOgq0t1teLkUizQs 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 Wed Apr 1 21:00:03 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 B5DB13630B8; Wed, 1 Apr 2026 15:31:15 +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=1775057475; cv=none; b=Et8PqCMtZakQC0mxEju+BfptFYNIh4miwcLLNP86rLVxUOoJsuJlOOQGNiGXRrz9ca1Kav/w1IpAhPtFsyq3nsEYueUEkocowxRokJdpqNwSUqqQrvXfnBYT/gnGBUxOdkX4j/mGsODrZlNjVA942/Aw8K6fNeqtpQ9lmrfNcFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775057475; c=relaxed/simple; bh=BpaDyxuEEWGwH8+zxRnZgYWjvYFs0B64GTKhbxeNAS4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R9uK+4gT0xbnu3oirtVCT82BrXevRKiId5i1Xxv3OSTbXnvh4NJANev98BM2ZFCH66odKD/DeFG42Q/EEsps1thxc5o/1do/8z+8o9oIgZdv6EvGtS9ud0/0omW94C+IJSkYo9O2vnAeF8IjyHniEMmuOoXBGPy+c+oz8SVa+sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HnTEvgFv; 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="HnTEvgFv" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6C3BDC2BCC4; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775057475; bh=BpaDyxuEEWGwH8+zxRnZgYWjvYFs0B64GTKhbxeNAS4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=HnTEvgFvL7SVHIxr09UQRIORG4Ka3R0g1NVvDzwSdP81kbQWbz//2i5FmZ3PpjcBJ 21H1jzjYJ0zVYEEmB2BidUDAkrZKZicC4hFBrYjwjPCYhJQUeq6V7pQ8WzqNCzBTB3 KL6YP9OIH7voYL78YRTpMJ/ExV24BrSpG8ON7et1YbBTss7pSy5IKCYjhqb+akVruM Xt9X+w8wF0YhqaHv/taAdAjcAi2khODpOcztKmiWJzNh9/n9rrMBzs++EqT225C8ED nMsSCUg1scQKmsywo5mHXNDxd46+YPiB80UEwU1U9UWAJ8Mlv+Bs3Xh//BafOp7n11 rmvpKUTIEywWA== 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 37E4D10F6FDE; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 01 Apr 2026 08:31:14 -0700 Subject: [PATCH net-next v4 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: <20260401-enic-sriov-v2-prep-v4-4-d5834b2ef1b9@cisco.com> References: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@cisco.com> In-Reply-To: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@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=1775057474; l=4130; i=satishkh@cisco.com; h=from:subject:message-id; bh=zvvdRfwq8gsBZZOSKyc4TXaUkVuYP93HpEGc0xRpx0k=; b=faHAjZwd4ltGsy3HOtd2pkMIBkRUiT6vgD8Is0FcEb0Nuo6GQ8M0JUPbQJqeWzqgpF+JeJS8D BL7reGlC7dsA4Bf8oRCLz4HoX1h8IbD9W8dsp6ls/VslCAPqOMu2uJf 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 Wed Apr 1 21:00:03 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 C07DF3644D0; Wed, 1 Apr 2026 15:31:15 +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=1775057475; cv=none; b=AdfDj0pEmGXMPfR6gY3AHNB+ZERwSpzfiYqBWvMn4aaYv6D/ZTl0fowFNZZk0ml0YgY+5ZwRrXL0x04eyzLwloaJwOTXgQTcOC29Im3mUcCKD9ZOKDdQeTCkR80xY0zUCiJ2aJV5KWykOLtSCv80NzKjups878T153jGtlyQyhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775057475; c=relaxed/simple; bh=WXpYpK3yhKn2sm0AMqrjWN6OL03+heVozAsWmGdd/6M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SOuYelwKyDHwDKobV186nODM632Uq7kpp+pbml4fZRTQHyn+TML16E3K8fMLWuElC2WyqmsCVOqpoC4wPcPL7cMU2GyGAQCbnpPJZrIq8qQUOndVhwrd5B/pHt+15zYhalVG72hPdWvC4rcaiLWP8Eh7yxm1aFSaZbSpRMfgeis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K15S9q4q; 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="K15S9q4q" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7FA22C2BCC9; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775057475; bh=WXpYpK3yhKn2sm0AMqrjWN6OL03+heVozAsWmGdd/6M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=K15S9q4qAlBYpsQNWmOQkPFm4xa4B832TB0O2KmzDNExhB2HReBWdTyAVU27RO7tu oOHa34ZYp1C2exZlNREuZRrb/q/IlHEBit+W7M35cjTZxoEhPUbpmEUP6IUWSNE+JD F19/B0Zu0nnjU8HCktln6GXE1nSJo/o6/oaXukqIJaIzv1+KjmlQSXw83WUxiyigmp Zt8SBZpFeFVMTYMmdsgubEhT+k3oxBT3R4amKfxj1aaU4k1MXQLL4l8Y2yC1hNMwQ5 w+eortLosyVKKlEtPNKf/URBdAnGVbBOT26cmg+qD8n8TG/+L8ZpJ6ZVaVGNQM7SBN 7/Weoj+0tx3LQ== 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 48C9710F6FDC; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 01 Apr 2026 08:31:15 -0700 Subject: [PATCH net-next v4 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: <20260401-enic-sriov-v2-prep-v4-5-d5834b2ef1b9@cisco.com> References: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@cisco.com> In-Reply-To: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@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=1775057474; l=10146; i=satishkh@cisco.com; h=from:subject:message-id; bh=sStTy9Bg8r3IiBcBVUP3bIWBVt484dhT5KCgXRyPs1c=; b=QDWbSAdilTGNFIidA6YoRSI3LNJAipzz9EPQY7zXH9No1iZy380co2BRD4Y0Bt7bBoRzfEGy9 mp2c2be6+DsCDOZ6uGPCx99Q0VWhRfN4K5FMew9AaOUDJjdHnVvycxZ 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 Wed Apr 1 21:00:03 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 C5BD93644D5; Wed, 1 Apr 2026 15:31:15 +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=1775057475; cv=none; b=LPqvcWJYC+9i50QdSgjL7HZdeuA56ZE7YEPrLcJCtZ+CsIZlDNco/zduCjLgradAEIMlK1jD1EKsF/tKRwV9RDk8Q21jcXPaPp8yxAvuSTj5dVTZFxl6le2iYFTnktPY9ARav7oRXxE/Lu/TZAEe/IjDVQZM/8+AynZck85aGQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775057475; c=relaxed/simple; bh=YhIMr4yYwBZ5EllsEmbIO/ym48ayC5JDhQ8YCwvYqy4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RPr7NWAkCypw/6JhmvjisqCeY5whcO9pn5nwsWcJY/6TS1y3iJs/BmauWtiY/v4vWMmOFS8kt8UwSKT4gdINPimXvyt5gA5V2oeil754ufj1+r/6BMM6NXDd/o+A1Bc967mzky0YEyCO/dCPks1KaLKrTD7xJTNDZn/e9Kk7NVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NHa07fb5; 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="NHa07fb5" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7836FC2BCC6; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775057475; bh=YhIMr4yYwBZ5EllsEmbIO/ym48ayC5JDhQ8YCwvYqy4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=NHa07fb5a0VWwbCb+B08dKympPj4BhcFSThp1oOyjZGqmBINdqrpQ0CQdK4uV/cgH VLcEKzJxNgACfGvSrZAyEnaLyYk5+lraR2uo8iVJk0T7DAwTYXC37HMNMQB/QdJxun 1POzcMoNlClwCPQ7pmOlkpEU1qcTflwtPo6IO4JDPKjMKdfCWHlv//EirUDZsR6YL9 aXxZHizkAkWiGuhyaYHi0jOPrai08yqPmpOXZBNonrxh4RdfARcrVARnJ2Sdf2VYlq zf9uGK7BOcShwIicgkAt0gzb9arX0icA4O3IXYirQO9c20Vp69E3CwBq3yyMpL43JB UeroWYrpF+FtQ== 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 563F11076381; Wed, 1 Apr 2026 15:31:15 +0000 (UTC) From: Satish Kharat via B4 Relay Date: Wed, 01 Apr 2026 08:31:16 -0700 Subject: [PATCH net-next v4 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: <20260401-enic-sriov-v2-prep-v4-6-d5834b2ef1b9@cisco.com> References: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@cisco.com> In-Reply-To: <20260401-enic-sriov-v2-prep-v4-0-d5834b2ef1b9@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=1775057474; l=2466; i=satishkh@cisco.com; h=from:subject:message-id; bh=1nJliUotDMusF5w/UMmuyqwJOqlCYgr21D/fx9rjM1w=; b=z2YAxCOM/ke0G7APDq98nCEY38H4/XW/owLDHsp0MaxZl2zYCZcmhcy+Pn3PkC464V3BSi5hu 6AJ5I0DR1D+AfrN34+602nw1cW+UMRz7DG0b7dj+e6d2kyi3WgYkyfH 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