From: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
To: dev@dpdk.org
Cc: kirill.rybalchenko@intel.com, andrey.chilikin@intel.com,
beilei.xing@intel.com, jingjing.wu@intel.com
Subject: [PATCH v8 2/2] app/testpmd: get information about protocols defined in ddp profile
Date: Wed, 4 Oct 2017 15:00:04 +0100 [thread overview]
Message-ID: <1507125604-32117-3-git-send-email-kirill.rybalchenko@intel.com> (raw)
In-Reply-To: <1507125604-32117-1-git-send-email-kirill.rybalchenko@intel.com>
Update 'ddp get info' command to display protocols defined in a profile
v5
buff_size parameter in rte_pmd_i40e_get_ddp_info function call
always represents buffer size in bytes
v6
fix bug with wrong usage of buff_size parameter
v8
Fix code style warnings.
Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
app/test-pmd/cmdline.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 116 insertions(+), 7 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4f2d731..71f37f1 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -13427,12 +13427,20 @@ 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;
+ uint32_t buff_size = 0;
struct rte_pmd_i40e_profile_info info;
- uint32_t dev_num;
+ uint32_t dev_num = 0;
struct rte_pmd_i40e_ddp_device_id *devs;
+ uint32_t proto_num = 0;
+ struct rte_pmd_i40e_proto_info *proto;
+ uint32_t pctype_num = 0;
+ struct rte_pmd_i40e_ptype_info *pctype;
+ uint32_t ptype_num = 0;
+ struct rte_pmd_i40e_ptype_info *ptype;
+ uint8_t proto_id;
+
#endif
pkg = open_ddp_package_file(res->filepath, &pkg_size);
@@ -13485,12 +13493,11 @@ cmd_ddp_info_parsed(
(uint8_t *)&dev_num, sizeof(dev_num),
RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
if (!ret && dev_num) {
- devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
- sizeof(struct rte_pmd_i40e_ddp_device_id));
+ buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
+ devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
if (devs) {
ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
- (uint8_t *)devs, dev_num *
- sizeof(struct rte_pmd_i40e_ddp_device_id),
+ (uint8_t *)devs, buff_size,
RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
if (!ret) {
printf("List of supported devices:\n");
@@ -13506,8 +13513,110 @@ 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)
+ goto no_print_return;
+
+ buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
+ proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
+ if (!proto)
+ goto no_print_return;
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
+ buff_size,
+ 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)
+ goto no_print_pctypes;
+
+ buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
+ pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
+ if (!pctype)
+ goto no_print_pctypes;
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
+ buff_size,
+ RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
+ if (ret) {
+ free(pctype);
+ goto no_print_pctypes;
+ }
+
+ 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);
+
+no_print_pctypes:
+
+ 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)
+ goto no_print_return;
+
+ buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
+ ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
+ if (!ptype)
+ goto no_print_return;
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
+ buff_size,
+ RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
+ if (ret) {
+ free(ptype);
+ goto no_print_return;
+ }
+ 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
+no_print_return:
if (ret == -ENOTSUP)
printf("Function not supported in PMD driver\n");
close_ddp_package_file(pkg);
--
2.5.5
next prev parent reply other threads:[~2017-10-04 14:00 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4075836-102681-1-git-send-email-kirill.rybalchenko@intel.com>
2017-09-01 16:01 ` [PATCH v2 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
2017-09-01 16:01 ` [PATCH v2 1/2] " Kirill Rybalchenko
2017-09-04 12:36 ` Iremonger, Bernard
2017-09-11 15:32 ` Ferruh Yigit
2017-09-01 16:01 ` [PATCH v2 2/2] app/testpmd: " Kirill Rybalchenko
2017-09-04 12:44 ` Iremonger, Bernard
2017-09-04 12:46 ` Iremonger, Bernard
2017-09-11 15:32 ` Ferruh Yigit
2017-09-19 16:46 ` [PATCH v3 0/2] net/i40e: " Kirill Rybalchenko
2017-09-19 16:46 ` [PATCH v3 1/2] " Kirill Rybalchenko
2017-09-19 16:46 ` [PATCH v3 2/2] app/testpmd: " Kirill Rybalchenko
2017-09-19 17:32 ` [PATCH v4 0/2] net/i40e: " Kirill Rybalchenko
2017-09-19 17:32 ` [PATCH v4 1/2] " Kirill Rybalchenko
2017-09-19 17:32 ` [PATCH v4 2/2] app/testpmd: " Kirill Rybalchenko
2017-09-19 17:53 ` [PATCH v5 0/2] net/i40e: " Kirill Rybalchenko
2017-09-19 17:53 ` [PATCH v5 1/2] " Kirill Rybalchenko
2017-09-26 3:35 ` Xing, Beilei
2017-09-19 17:53 ` [PATCH v5 2/2] app/testpmd: " Kirill Rybalchenko
2017-09-28 13:33 ` [PATCH v6 0/2] net/i40e: " Kirill Rybalchenko
2017-09-28 13:33 ` [PATCH v6 1/2] " Kirill Rybalchenko
2017-09-29 7:30 ` Xing, Beilei
2017-09-28 13:33 ` [PATCH v6 2/2] app/testpmd: " Kirill Rybalchenko
2017-10-02 9:39 ` [PATCH v7 0/2] net/i40e: " Kirill Rybalchenko
2017-10-02 9:39 ` [PATCH v7 1/2] " Kirill Rybalchenko
2017-10-02 9:39 ` [PATCH v7 2/2] app/testpmd: " Kirill Rybalchenko
2017-10-04 14:00 ` [PATCH v8 0/2] et/i40e: " Kirill Rybalchenko
2017-10-04 14:00 ` [PATCH v8 1/2] net/i40e: " Kirill Rybalchenko
2017-10-04 14:00 ` Kirill Rybalchenko [this message]
2017-10-04 22:00 ` [PATCH v8 0/2] et/i40e: " Ferruh Yigit
2017-10-05 1:11 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1507125604-32117-3-git-send-email-kirill.rybalchenko@intel.com \
--to=kirill.rybalchenko@intel.com \
--cc=andrey.chilikin@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.