[dpdk-dev] [PATCH] app/procinfo: add device registers dump
    Pattan, Reshma 
    reshma.pattan at intel.com
       
    Fri Jun  4 17:04:41 CEST 2021
    
    
  
> -----Original Message-----
> From: Min Hu (Connor) <humin29 at huawei.com>
<snip> 
> +		ret = rte_eth_dev_get_reg_info(i, ®_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.
> +		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.
> +		} 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.
> +					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"
    
    
More information about the dev
mailing list