# Re: \[PATCH net-next v4 5/5\] eth: fbnic: Add devlink dev flash support

- From: Simon Horman \<horms@kernel.org\>
- Date: 2025-05-12 14:31:13 
- List: linux-doc
- Page: https://ratatoskr.run/linux-doc/2025/05/3051648
- Thread: https://ratatoskr.run/netdev/2025/05/3049964/t.md

```text
On Fri, May 09, 2025 at 05:21:17PM -0700, Lee Trager wrote:
> Add support to update the CMRT and control firmware as well as the UEFI
> driver on fbnic using devlink dev flash.
> 
> Make sure the shutdown / quiescence paths like suspend take the devlink
> lock to prevent them from interrupting the FW flashing process.
> 
> Signed-off-by: Lee Trager <redacted>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

...

> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c

...

> @@ -109,8 +111,264 @@ static int fbnic_devlink_info_get(struct devlink *devlink,
>  	return 0;
>  }
> 
> +static bool
> +fbnic_pldm_match_record(struct pldmfw *context, struct pldmfw_record *record)
> +{
> +	struct pldmfw_desc_tlv *desc;
> +	u32 anti_rollback_ver = 0;
> +	struct devlink *devlink;
> +	struct fbnic_dev *fbd;
> +	struct pci_dev *pdev;
> +
> +	/* First, use the standard PCI matching function */
> +	if (!pldmfw_op_pci_match_record(context, record))
> +		return -ENODEV;

Hi Lee,

The return type of this function is bool, but here a negative integer is
being returned. Perhaps this should be:

		return false;

Flagged by Smatch

> +
> +	pdev = to_pci_dev(context->dev);
> +	fbd = pci_get_drvdata(pdev);
> +	devlink = priv_to_devlink(fbd);
> +
> +	/* If PCI match is successful, check for vendor-specific descriptors */
> +	list_for_each_entry(desc, &record->descs, entry) {
> +		if (desc->type != PLDM_DESC_ID_VENDOR_DEFINED)
> +			continue;
> +
> +		if (desc->size < 21 || desc->data[0] != 1 ||
> +		    desc->data[1] != 15)
> +			continue;
> +
> +		if (memcmp(desc->data + 2, "AntiRollbackVer", 15) != 0)
> +			continue;
> +
> +		anti_rollback_ver = get_unaligned_le32(desc->data + 17);
> +		break;
> +	}
> +
> +	/* Compare versions and return error if they do not match */
> +	if (anti_rollback_ver < fbd->fw_cap.anti_rollback_version) {
> +		char buf[128];
> +
> +		snprintf(buf, sizeof(buf),
> +			 "New firmware anti-rollback version (0x%x) is older than device version (0x%x)!",
> +			 anti_rollback_ver, fbd->fw_cap.anti_rollback_version);
> +		devlink_flash_update_status_notify(devlink, buf,
> +						   "Anti-Rollback", 0, 0);
> +
> +		return false;
> +	}
> +
> +	return true;
> +}

...
```
