From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B359145AAE; Fri, 4 Oct 2024 15:59:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5ECE2410FC; Fri, 4 Oct 2024 15:59:54 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id AFC4540E34 for ; Fri, 4 Oct 2024 15:59:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728050392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nRC6FiKApBZYDynZtWUMsJWMZDMAAARRLL8yrg+xFQg=; b=Svvh2cL6R2kPvHAAchjiJWc2f0GZRDg2Uv39ywAiNMf9lsAuHKsMCXsqleErAXN+i30Awr aOekQDoLjs1L6+57VsHsHbdXaV+f0BLqtXkIJT56Mkp/ooXfgfxaKjCBTeL5Qdp8nCiRq4 xMX0k/cl87fpP6LQKvqB1pr/gAS4Xrk= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-h1RydItwOJa9UcCT2WkqmA-1; Fri, 04 Oct 2024 09:59:39 -0400 X-MC-Unique: h1RydItwOJa9UcCT2WkqmA-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-53995187384so2187519e87.2 for ; Fri, 04 Oct 2024 06:59:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728050378; x=1728655178; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nRC6FiKApBZYDynZtWUMsJWMZDMAAARRLL8yrg+xFQg=; b=Q6wmKCMKQoa9wlOuwII3shl9OGvzLkWrEKBTLCl1oHFU4cbgTn1/lz3eSlZJcHFmC3 98PDej/474AJYzDRSDII4pC1pDcyD1JXn5wN/pS245WOk7UkiQwaGKDdDspnFOKE+Axp faKIuoumf9+exysoC+1G90HctL7qOvlROetMmrx6ZLbz2IFcY+uSrnh2zwdR1poUnhmU P20g4/lZQwhfDTE337quXJn2cCiB6qonrj7LXElqtY249uCWRFTTRJ/1oqhjDwLXRrPY rsVdbdP0dP84eBs1+/4lb/mk9IQdrEwNYdzDu1b9ai4bU1CkgRL76QSUKbJHVCSHno1x gjag== X-Gm-Message-State: AOJu0YwtXDckpcIwqS6I1Tb8K/dP+12UFMXkEpTkZ2C+wTG9vQARwKje Kp4NTMJfsXyaEpmdiz12aTkz2TcDtrPuByDxyq1pJEPLFf3IXQbj+/jWJ78V5ZUfgtnghKWA5j8 +JB5BaGeU9PfAJ7WV3YAsBCuYJSHMa89V9Tr/jKRs588H0INAfT9d9X8kb/enVIxidBVZHw35Wh 8hZIxEj+Gkap3rIVk= X-Received: by 2002:a05:6512:10d1:b0:538:9e40:94b with SMTP id 2adb3069b0e04-539ab878669mr2125674e87.19.1728050377583; Fri, 04 Oct 2024 06:59:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtt2cf7E6i/1ws3CUbL5n29pGGMYBEIPfl/o/bGmOg3mOp7NyfBYlzJhzlR0ZYvnkZu1TrfzKdYncs0C0x+fk= X-Received: by 2002:a05:6512:10d1:b0:538:9e40:94b with SMTP id 2adb3069b0e04-539ab878669mr2125657e87.19.1728050377153; Fri, 04 Oct 2024 06:59:37 -0700 (PDT) MIME-Version: 1.0 References: <20231214015650.3738578-1-haijie1@huawei.com> <20240926124249.81679-1-haijie1@huawei.com> <20240926124249.81679-9-haijie1@huawei.com> In-Reply-To: <20240926124249.81679-9-haijie1@huawei.com> From: David Marchand Date: Fri, 4 Oct 2024 15:59:26 +0200 Message-ID: Subject: Re: [PATCH v9 8/8] net/hns3: support filter registers by module names To: Jie Hai Cc: dev@dpdk.org, thomas@monjalon.net, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru, lihuisong@huawei.com, fengchengwen@huawei.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Sep 26, 2024 at 2:44=E2=80=AFPM Jie Hai 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 *reg= s_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 =3D 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 =3D %d.", ret); > - return ret; > + for (i =3D 0; i < RTE_DIM(hns3_module_name_map); i++) { > + if (hns3_module_name_map[i].module && HNS3_MODULE_MASK(mo= dule) !=3D 0) > + return hns3_module_name_map[i].name; > } > + return "unknown"; > +} > > - *count +=3D regs_num_32_bit + regs_num_64_bit * HNS3_64_BIT_REG_O= UTPUT_SIZE; > - return 0; > +static void > +hns3_get_module_names(char *names, uint32_t len) > +{ > + size_t i; > + > + for (i =3D 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 =3D HNS3_DEV_HW_TO_ADAPTER(hw); > + char names[HNS3_MAX_MODULES_LEN] =3D {0}; > + uint32_t modules =3D 0; > + size_t i; > + > + if (filter =3D=3D NULL) { > + modules =3D (1 << RTE_DIM(hns3_reg_lists)) - 1; > + } else { > + for (i =3D 0; i < RTE_DIM(hns3_module_name_map); i++) { > + if (strcmp(filter, hns3_module_name_map[i].name) = =3D=3D 0) { > + modules |=3D hns3_module_name_map[i].modu= le; > + break; > + } > + } > + } > + > + if (hns->is_vf) > + modules &=3D HNS3_VF_MODULES; > + else > + modules &=3D ~HNS3_VF_ONLY_MODULES; > + if (modules =3D=3D 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 --=20 David Marchand