mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "luobin (L)" <luobin9@huawei.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <davem@davemloft.net>, <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>, <luoxianjun@huawei.com>,
	<yin.yinshi@huawei.com>, <cloud.wangxiaoyun@huawei.com>,
	<chiqijun@huawei.com>
Subject: Re: [PATCH net-next v1] hinic: add firmware update support
Date: Tue, 14 Jul 2020 08:56:09 +0800	[thread overview]
Message-ID: <d4f47ea5-7696-e8e2-81cd-dc398f383413@huawei.com> (raw)
In-Reply-To: <20200713154208.7d123d5e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

On 2020/7/14 6:42, Jakub Kicinski wrote:
> On Mon, 13 Jul 2020 22:05:22 +0800 Luo bin wrote:
>> add support to update firmware by the devlink flashing API
>>
>> Signed-off-by: Luo bin <luobin9@huawei.com>
>> ---
>> V0~V1: remove the implementation from ethtool to devlink
> 
> Thanks!
> 
>> +static int check_image_device_type(struct hinic_dev *nic_dev,
>> +				   u32 image_device_type)
>> +{
>> +	struct hinic_comm_board_info board_info = {0};
>> +
>> +	if (image_device_type) {
>> +		if (!hinic_get_board_info(nic_dev->hwdev, &board_info)) {
>> +			if (image_device_type == board_info.info.board_type)
>> +				return true;
> 
> Please simplify this, you shouldn't need more than 1 indentation level
> here.
> 
>> +			dev_err(&nic_dev->hwdev->hwif->pdev->dev, "The device type of upgrade file doesn't match the device type of current firmware, please check the upgrade file\n");
>> +			dev_err(&nic_dev->hwdev->hwif->pdev->dev, "The image device type: 0x%x, firmware device type: 0x%x\n",
>> +				image_device_type, board_info.info.board_type);
>> +
>> +			return false;
>> +		}
>> +	}
>> +
>> +	return false;
>> +}
>> +
>> +static int hinic_flash_fw(struct hinic_dev *nic_dev, const u8 *data,
>> +			  struct host_image_st *host_image, u32 boot_flag)
> 
> You seem to always pass boot_flag = 0, AFAICT, please remove the
> parameter and related code.
> 
>> +{
>> +	u32 section_remain_send_len, send_fragment_len, send_pos, up_total_len;
>> +	struct hinic_cmd_update_fw *fw_update_msg = NULL;
>> +	u32 section_type, section_crc, section_version;
>> +	u32 i, len, section_len, section_offset;
>> +	u16 out_size = sizeof(*fw_update_msg);
>> +	int total_len_flag = 0;
>> +	int err;
> 
>> +int hinic_devlink_register(struct devlink *devlink, struct device *dev)
>> +{
>> +	int err;
>> +
>> +	err = devlink_register(devlink, dev);
>> +
>> +	return err;
> 
> No need for temporary variable.
> 
>> +}
>> +
>> +void hinic_devlink_unregister(struct devlink *devlink)
>> +{
>> +	devlink_unregister(devlink);
>> +}
> 
>> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
>> index 834a20a0043c..1dfa09411590 100644
>> --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
>> +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
>> @@ -18,6 +18,7 @@
>>  #include <linux/semaphore.h>
>>  #include <linux/workqueue.h>
>>  #include <net/ip.h>
>> +#include <net/devlink.h>
>>  #include <linux/bitops.h>
>>  #include <linux/bitmap.h>
>>  #include <linux/delay.h>
>> @@ -25,6 +26,7 @@
>>  
>>  #include "hinic_hw_qp.h"
>>  #include "hinic_hw_dev.h"
>> +#include "hinic_devlink.h"
>>  #include "hinic_port.h"
>>  #include "hinic_tx.h"
>>  #include "hinic_rx.h"
>> @@ -1075,9 +1077,11 @@ static int nic_dev_init(struct pci_dev *pdev)
>>  	struct hinic_rx_mode_work *rx_mode_work;
>>  	struct hinic_txq_stats *tx_stats;
>>  	struct hinic_rxq_stats *rx_stats;
>> +	struct hinic_dev *devlink_dev;
>>  	struct hinic_dev *nic_dev;
>>  	struct net_device *netdev;
>>  	struct hinic_hwdev *hwdev;
>> +	struct devlink *devlink;
>>  	int err, num_qps;
>>  
>>  	hwdev = hinic_init_hwdev(pdev);
>> @@ -1086,6 +1090,15 @@ 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;
>> +	}
>> +
>> +	devlink_dev = devlink_priv(devlink);
>> +
>>  	num_qps = hinic_hwdev_num_qps(hwdev);
>>  	if (num_qps <= 0) {
>>  		dev_err(&pdev->dev, "Invalid number of QPS\n");
>> @@ -1121,6 +1134,7 @@ static int nic_dev_init(struct pci_dev *pdev)
>>  	nic_dev->sriov_info.hwdev = hwdev;
>>  	nic_dev->sriov_info.pdev = pdev;
>>  	nic_dev->max_qps = num_qps;
>> +	nic_dev->devlink = devlink;
>>  
>>  	hinic_set_ethtool_ops(netdev);
>>  
>> @@ -1146,6 +1160,11 @@ static int nic_dev_init(struct pci_dev *pdev)
>>  		goto err_workq;
>>  	}
>>  
>> +	memcpy(devlink_dev, nic_dev, sizeof(*nic_dev));
> 
> Please create a separate structure for the devlink-level priv.
> This doesn't look right.
> 
>> +	err = hinic_devlink_register(devlink, &pdev->dev);
>> +	if (err)
>> +		goto err_devlink_reg;
>> +
>>  	pci_set_drvdata(pdev, netdev);
>>  
>>  	err = hinic_port_get_mac(nic_dev, netdev->dev_addr);
> 
> .
> 
Will fix all. Thanks for your review.

      reply	other threads:[~2020-07-14  0:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 14:05 Luo bin
2020-07-13 22:42 ` Jakub Kicinski
2020-07-14  0:56   ` luobin (L) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4f47ea5-7696-e8e2-81cd-dc398f383413@huawei.com \
    --to=luobin9@huawei.com \
    --cc=chiqijun@huawei.com \
    --cc=cloud.wangxiaoyun@huawei.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luoxianjun@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=yin.yinshi@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®