DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chengchang Tang <tangchengchang@huawei.com>
To: "Pattan, Reshma" <reshma.pattan@intel.com>,
	"Min Hu (Connor)" <humin29@huawei.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "Tahhan, Maryam" <maryam.tahhan@intel.com>
Subject: Re: [dpdk-dev] [PATCH] app/procinfo: add device registers dump
Date: Sat, 5 Jun 2021 11:15:09 +0800	[thread overview]
Message-ID: <0add2988-b4d1-0773-d075-8d51055d9cc2@huawei.com> (raw)
In-Reply-To: <BYAPR11MB3366C95082104AAC11704771FF3B9@BYAPR11MB3366.namprd11.prod.outlook.com>


On 2021/6/4 23:04, Pattan, Reshma wrote:
> 
> 
>> -----Original Message-----
>> From: Min Hu (Connor) <humin29@huawei.com>
> 
> <snip> 
> 
>> +		ret = rte_eth_dev_get_reg_info(i, &reg_info);
>> +		if (ret) {
>> +			printf("Error getting device reg info: %d\n", ret);
>> +			continue;
>> +		}
>> +
>> +		buf_size = reg_info.length * reg_info.width;
> 
> 
> If it is to get the regs length, you can directly call  "rte_ethtool_get_regs_len(uint16_t port_id)" API , instead of  again writing the above logic.
> And use the returned length in below malloc.

This logic is indeed identical to the logic of the "rte_ethtool_get_regs_len" API of Ethtool,
but the method of using the "rte_eth_dev_get_reg_info" API is the case. All users will have
similar code logic when using this API.

And use "rte_ethtool_get_regs_len" API here only reduces "buf_size = reg_info.length * reg_info.width;"
this logic. But at the same time, it introduces the dependence of example/ethtool in procinfo. The code in
example is not compiled by default, which seems not appropriate to import it in app/procinfo.

So, I think it is fine to keep this.
>
> 
>> +		fp_regs = fopen(file_name, "wb");
>> +		if (fp_regs == NULL) {
>> +			printf("Error during opening '%s' for writing\n",
>> +					file_name);
> 
> Better to print error string from fopen() errno on failure , to indicate the exact error.

Agree, I will fix it in the next version.

> 
>> +		} else {
>> +			if ((int)fwrite(buf_data, 1, buf_size, fp_regs) !=
> 
> Better have "((int)fwrite(buf_data, 1, buf_size, fp_regs)" In separate line and use the returned value inside if check.

Agree, I will fix it in the next version.

>
>> +					buf_size)
>> +				printf("Error during writing %s\n",
>> +						file_prefix);
> 
> Better to print error string from fwrite errno on failure , to indicate the exact error.
> 
>> +			else
>> +				printf("dump device (%s) regs successfully, "
> 
> Reframe the sente to "Device regs dumped successfully"
> 

Agree, I will fix it in the next version.
> .
> 


  reply	other threads:[~2021-06-05  3:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-25 13:02 Min Hu (Connor)
2021-05-19 10:16 ` Thomas Monjalon
2021-06-04 15:04 ` Pattan, Reshma
2021-06-05  3:15   ` Chengchang Tang [this message]
2021-06-10 16:25     ` Pattan, Reshma
2021-06-21  2:17 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
2021-07-09 21:55   ` Thomas Monjalon
2021-07-17  2:16     ` Min Hu (Connor)
2021-07-17 17:51 ` [dpdk-dev] [PATCH] " Stephen Hemminger
2021-07-19  6:40   ` Chengchang Tang
2021-07-17 17:53 ` Stephen Hemminger
2021-07-19  7:00   ` Chengchang Tang
2021-07-22 10:58 ` [dpdk-dev] [PATCH v3] " Min Hu (Connor)
2021-07-29 14:14   ` Pattan, Reshma
2021-07-30 16:46     ` Thomas Monjalon

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=0add2988-b4d1-0773-d075-8d51055d9cc2@huawei.com \
    --to=tangchengchang@huawei.com \
    --cc=dev@dpdk.org \
    --cc=humin29@huawei.com \
    --cc=maryam.tahhan@intel.com \
    --cc=reshma.pattan@intel.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;
as well as URLs for NNTP newsgroup(s).