> -----Original Message----- > From: Chengchang Tang <tangchengch...@huawei.com>
> >> + 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. > > 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. > Oh yes, my bad, I overlooked it. It makes complete sense now.