Re: [PATCH net-next v2 6/6] enic: detect admin channel resources for SR-IOV
From: Jakub Kicinski
Date: Sun Mar 29 2026 - 16:16:20 EST
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
enic: detect admin channel resources for SR-IOV
This commit checks for the presence of admin channel BAR resources during
resource discovery and sets has_admin_channel when all four are available.
It also adds admin WQ, RQ, CQ and INTR fields to struct enic.
> diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
> index 67fd780b1fa1c..08472420f3a1f 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;
> };
[ ... ]
> diff --git a/drivers/net/ethernet/cisco/enic/enic_res.c b/drivers/net/ethernet/cisco/enic/enic_res.c
> index bbd3143ed73e7..5ca3e5aec7f93 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 = 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) >= 1 &&
Is it possible for the hardware to provide exactly 1 admin completion queue?
Because struct enic allocates two admin_cq entries:
struct vnic_cq admin_cq[2];
If the firmware only provides one RES_TYPE_ADMIN_CQ, this check will pass,
but later initialization of admin_cq[1] might access memory past the end of
the validated memory-mapped I/O boundary.
Should this check be >= 2, or use ARRAY_SIZE(enic->admin_cq), to ensure
both queues are backed by hardware?
> + vnic_dev_get_res_count(enic->vdev, RES_TYPE_SRIOV_INTR) >= 1;
> +