On Thu, Sep 26, 2024 at 2:44 PM Jie Hai <haij...@huawei.com> wrote: > diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c > index a0d130302839..2e19add21265 100644 > --- a/drivers/net/hns3/hns3_regs.c > +++ b/drivers/net/hns3/hns3_regs.c
[snip] > @@ -863,21 +891,58 @@ hns3_get_regs_num(struct hns3_hw *hw, uint32_t > *regs_num_32_bit, > return 0; > } > > -static int > -hns3_get_32_64_regs_cnt(struct hns3_hw *hw, uint32_t *count) > +static const char * > +hns3_get_name_by_module(enum hns3_reg_modules module) > { > - uint32_t regs_num_32_bit, regs_num_64_bit; > - int ret; > + size_t i; > > - ret = hns3_get_regs_num(hw, ®s_num_32_bit, ®s_num_64_bit); > - if (ret) { > - hns3_err(hw, "fail to get the number of registers, " > - "ret = %d.", ret); > - return ret; > + for (i = 0; i < RTE_DIM(hns3_module_name_map); i++) { > + if (hns3_module_name_map[i].module && > HNS3_MODULE_MASK(module) != 0) > + return hns3_module_name_map[i].name; > } > + return "unknown"; > +} > > - *count += regs_num_32_bit + regs_num_64_bit * > HNS3_64_BIT_REG_OUTPUT_SIZE; > - return 0; > +static void > +hns3_get_module_names(char *names, uint32_t len) > +{ > + size_t i; > + > + for (i = 0; i < RTE_DIM(hns3_module_name_map); i++) { > + strlcat(names, " ", len); > + strlcat(names, hns3_module_name_map[i].name, len); > + } > +} > + > +static uint32_t > +hns3_parse_modules_by_filter(struct hns3_hw *hw, const char *filter) > +{ > + struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); > + char names[HNS3_MAX_MODULES_LEN] = {0}; > + uint32_t modules = 0; > + size_t i; > + > + if (filter == NULL) { > + modules = (1 << RTE_DIM(hns3_reg_lists)) - 1; > + } else { > + for (i = 0; i < RTE_DIM(hns3_module_name_map); i++) { > + if (strcmp(filter, hns3_module_name_map[i].name) == > 0) { > + modules |= hns3_module_name_map[i].module; > + break; > + } > + } > + } > + > + if (hns->is_vf) > + modules &= HNS3_VF_MODULES; > + else > + modules &= ~HNS3_VF_ONLY_MODULES; > + if (modules == 0) { > + hns3_get_module_names(names, HNS3_MAX_MODULES_LEN); > + hns3_err(hw, "mismatched module name! Available names > are:\n%s.", > + names); No need for \n. Please send a fix against next-net. > + } > + return modules; > } > > static int -- David Marchand