From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 7EB2127D for ; Mon, 11 Sep 2017 17:32:14 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2017 08:32:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,378,1500966000"; d="scan'208";a="899147357" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.57]) ([10.237.220.57]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2017 08:32:11 -0700 To: Kirill Rybalchenko , dev@dpdk.org Cc: andrey.chilikin@intel.com, beilei.xing@intel.com, jingjing.wu@intel.com References: <4075836-102681-1-git-send-email-kirill.rybalchenko@intel.com> <1504281685-54502-1-git-send-email-kirill.rybalchenko@intel.com> <1504281685-54502-3-git-send-email-kirill.rybalchenko@intel.com> From: Ferruh Yigit Message-ID: <4f29573b-8760-ab56-1cc1-67a9ed8b3677@intel.com> Date: Mon, 11 Sep 2017 16:32:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1504281685-54502-3-git-send-email-kirill.rybalchenko@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: get information about protocols defined in ddp profile X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Sep 2017 15:32:15 -0000 On 9/1/2017 5:01 PM, Kirill Rybalchenko wrote: > Update 'ddp get info' command to display protocols defined in a profile > > Signed-off-by: Kirill Rybalchenko > --- > app/test-pmd/cmdline.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 97 insertions(+), 1 deletion(-) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index 0144191..1402c6d 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -13423,12 +13423,18 @@ cmd_ddp_info_parsed( > uint32_t pkg_size; > int ret = -ENOTSUP; > #ifdef RTE_LIBRTE_I40E_PMD > - uint32_t i; > + uint32_t i, j, n; > uint8_t *buff; > uint32_t buff_size; > struct rte_pmd_i40e_profile_info info; > uint32_t dev_num; > struct rte_pmd_i40e_ddp_device_id *devs; > + uint32_t proto_num; > + struct rte_pmd_i40e_proto_info *proto; > + uint32_t pctype_num; > + struct rte_pmd_i40e_ptype_info *pctype; > + uint32_t ptype_num; > + struct rte_pmd_i40e_ptype_info *ptype; > #endif > > pkg = open_ddp_package_file(res->filepath, &pkg_size); > @@ -13502,6 +13508,96 @@ cmd_ddp_info_parsed( > free(devs); > } > } > + > + /* get information about protocols and packet types */ > + ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, > + (uint8_t *)&proto_num, sizeof(proto_num), > + RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); > + if (!ret && proto_num) { > + uint8_t proto_id; > + > + proto = (struct rte_pmd_i40e_proto_info *) > + malloc(proto_num * sizeof(struct rte_pmd_i40e_proto_info)); > + if (proto) { This function is hard to trace, can you please reduce indentation, either: - Extract protocol_list, pctype_list, ptype_list into their own functions, or - by using logic something like: if (!proto) goto xyz; > + ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, > + (uint8_t *)proto, proto_num, > + RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); > + if (!ret) { > + printf("List of used protocols:\n"); > + for (i = 0; i < proto_num; i++) > + printf(" %2u: %s\n", proto[i].proto_id, > + proto[i].name); > + printf("\n"); > + } > + ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, > + (uint8_t *)&pctype_num, sizeof(pctype_num), > + RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); > + if (!ret && pctype_num) { > + pctype = (struct rte_pmd_i40e_ptype_info *) > + malloc(pctype_num * > + sizeof(struct rte_pmd_i40e_ptype_info)); > + if (pctype) { > + ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, > + (uint8_t *)pctype, pctype_num, > + RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); > + if (!ret) { > + printf("List of defined packet classification types:\n"); > + for (i = 0; i < pctype_num; i++) { > + printf(" %2u:", pctype[i].ptype_id); > + for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { > + proto_id = pctype[i].protocols[j]; > + if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { > + for (n = 0; n < proto_num; n++) { > + if (proto[n].proto_id == proto_id) { > + printf(" %s", proto[n].name); > + break; > + } > + } > + } > + } > + printf("\n"); > + } > + printf("\n"); > + } > + free(pctype); > + } > + } > + ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, > + (uint8_t *)&ptype_num, sizeof(ptype_num), > + RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); > + if (!ret && ptype_num) { > + ptype = (struct rte_pmd_i40e_ptype_info *) > + malloc(ptype_num * > + sizeof(struct rte_pmd_i40e_ptype_info)); > + if (ptype) { > + ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, > + (uint8_t *)ptype, ptype_num, > + RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); > + if (!ret) { > + printf("List of defined packet types:\n"); > + for (i = 0; i < ptype_num; i++) { > + printf(" %2u:", ptype[i].ptype_id); > + for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { > + proto_id = ptype[i].protocols[j]; > + if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { > + for (n = 0; n < proto_num; n++) { > + if (proto[n].proto_id == proto_id) { > + printf(" %s", proto[n].name); > + break; > + } > + } > + } > + } > + printf("\n"); > + } > + } > + free(ptype); > + } > + printf("\n"); > + } > + free(proto); > + } > + } > ret = 0; > #endif > if (ret == -ENOTSUP) >