lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 14 Jul 2020 11:37:11 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Luo bin <luobin9@...wei.com>
Cc:     <davem@...emloft.net>, <linux-kernel@...r.kernel.org>,
        <netdev@...r.kernel.org>, <luoxianjun@...wei.com>,
        <yin.yinshi@...wei.com>, <cloud.wangxiaoyun@...wei.com>,
        <chiqijun@...wei.com>
Subject: Re: [PATCH net-next v2] hinic: add firmware update support

On Tue, 14 Jul 2020 20:54:33 +0800 Luo bin wrote:
> add support to update firmware by the devlink flashing API
> 
> Signed-off-by: Luo bin <luobin9@...wei.com>

Minor nits below, otherwise I think this looks good.

> +static int hinic_firmware_update(struct hinic_devlink_priv *priv,
> +				 const struct firmware *fw)
> +{
> +	struct host_image_st host_image;
> +	int err;
> +
> +	memset(&host_image, 0, sizeof(struct host_image_st));
> +
> +	if (!check_image_valid(priv, fw->data, fw->size, &host_image) ||
> +	    !check_image_integrity(priv, &host_image, FW_UPDATE_COLD) ||
> +	    !check_image_device_type(priv, host_image.device_id))

These helpers should also set an appropriate message in extack, so the
user can see it on the command line / inside their application.

> +		return -EINVAL;
> +
> +	dev_info(&priv->hwdev->hwif->pdev->dev, "Flash firmware begin\n");
> +
> +	err = hinic_flash_fw(priv, fw->data, &host_image);
> +	if (err) {
> +		if (err == HINIC_FW_DISMATCH_ERROR)
> +			dev_err(&priv->hwdev->hwif->pdev->dev, "Firmware image doesn't match this card, please use newer image, err: %d\n",

Here as well - please make sure to return an error messages through
extack.

> +				err);
> +		else
> +			dev_err(&priv->hwdev->hwif->pdev->dev, "Send firmware image data failed, err: %d\n",
> +				err);
> +		return err;
> +	}
> +
> +	dev_info(&priv->hwdev->hwif->pdev->dev, "Flash firmware end\n");
> +
> +	return 0;
> +}

> @@ -1086,6 +1090,17 @@ static int nic_dev_init(struct pci_dev *pdev)
>  		return PTR_ERR(hwdev);
>  	}
>  
> +	devlink = hinic_devlink_alloc();
> +	if (!devlink) {
> +		dev_err(&pdev->dev, "Hinic devlink alloc failed\n");
> +		err = -ENOMEM;
> +		goto err_devlink_alloc;
> +	}
> +
> +	priv = devlink_priv(devlink);
> +	priv->hwdev = hwdev;
> +	priv->devlink = devlink;

No need to remember the devlink pointer here, you can use
priv_to_devlink(priv) to go from priv to devlink.

> +
>  	num_qps = hinic_hwdev_num_qps(hwdev);
>  	if (num_qps <= 0) {
>  		dev_err(&pdev->dev, "Invalid number of QPS\n");

Powered by blists - more mailing lists