Subject: Re: [PATCH net-next v2 01/10] enic: verify firmware supports V2 SR-IOV at probe time

From: Breno Leitao <[email-masked]>
Date: Wed, 8 Apr 2026 09:04:20 -0700

On Wed, Apr 08, 2026 at 08:08:11AM -0700, Satish Kharat via B4 Relay wrote:
> From: Satish Kharat <[email-masked]>
> 
> During PF probe, query the firmware get-supported-feature interface
> to verify that the running firmware supports V2 SR-IOV. Firmware
> version 5.3(4.72) and later report VIC_FEATURE_SRIOV via
> CMD_GET_SUPP_FEATURE_VER. If the firmware does not support the
> feature, set vf_type to ENIC_VF_TYPE_NONE and log a warning so the
> admin knows a firmware upgrade is needed.
> 
> The VIC_FEATURE_SRIOV enum value (4) matches the firmware ABI. A
> placeholder entry (VIC_FEATURE_PTP at position 3) is added to keep
> the enum in sync with firmware's feature numbering.
> 
> Signed-off-by: Satish Kharat <[email-masked]>
> ---
>  drivers/net/ethernet/cisco/enic/enic_main.c   | 18 ++++++++++++++++++
>  drivers/net/ethernet/cisco/enic/vnic_devcmd.h |  2 ++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
> index e7125b818087..3a4afd6da41f 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_main.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_main.c
> @@ -2641,8 +2641,10 @@ static void enic_iounmap(struct enic *enic)
>  static void enic_sriov_detect_vf_type(struct enic *enic)
>  {
>  	struct pci_dev *pdev = enic->pdev;
> +	u64 supported_versions, a1 = 0;
>  	int pos;
>  	u16 vf_dev_id;
> +	int err;
>  
>  	if (enic_is_sriov_vf(enic) || enic_is_dynamic(enic))
>  		return;
> @@ -2669,6 +2671,22 @@ static void enic_sriov_detect_vf_type(struct enic *enic)
>  		enic->vf_type = ENIC_VF_TYPE_NONE;
>  		break;
>  	}
> +
> +	if (enic->vf_type == ENIC_VF_TYPE_V2) {

Maybe invert the if case here?

	if (enic->vf_type != ENIC_VF_TYPE_V2)
		return

And then shift the rest to the left

This might be easier to read, and the code looks better, in general.