]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
enic: detect admin channel resources for SR-IOV
authorSatish Kharat <satishkh@cisco.com>
Wed, 1 Apr 2026 15:31:16 +0000 (08:31 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 3 Apr 2026 01:05:06 +0000 (18:05 -0700)
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 <satishkh@cisco.com>
Link: https://patch.msgid.link/20260401-enic-sriov-v2-prep-v4-6-d5834b2ef1b9@cisco.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cisco/enic/enic.h
drivers/net/ethernet/cisco/enic/enic_res.c

index 67fd780b1fa1c94f7c5e42d1f2d8595724766eb5..08472420f3a1fd5dec5f7cfb486decd1384f4612 100644 (file)
@@ -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;
 };
 
 static inline struct net_device *vnic_get_netdev(struct vnic_dev *vdev)
index bbd3143ed73e77d25a1e4921e073c929e92d8230..2b7545d6a67fdcdff6b6e943e739411905c17720 100644 (file)
@@ -205,10 +205,18 @@ void enic_get_res_counts(struct enic *enic)
        enic->cq_count = enic->cq_avail;
        enic->intr_count = enic->intr_avail;
 
+       enic->has_admin_channel =
+               vnic_dev_get_res_count(enic->vdev, RES_TYPE_ADMIN_WQ) >= 1 &&
+               vnic_dev_get_res_count(enic->vdev, RES_TYPE_ADMIN_RQ) >= 1 &&
+               vnic_dev_get_res_count(enic->vdev, RES_TYPE_ADMIN_CQ) >=
+                       ARRAY_SIZE(enic->admin_cq) &&
+               vnic_dev_get_res_count(enic->vdev, RES_TYPE_SRIOV_INTR) >= 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");
 }
 
 void enic_init_vnic_resources(struct enic *enic)