All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
To: dev@dpdk.org
Cc: kirill.rybalchenko@intel.com, andrey.chilikin@intel.com
Subject: [PATCH 2/2] app/testpmd: get information about protocols defined in ddp profile
Date: Wed, 30 Aug 2017 07:50:36 +0100	[thread overview]
Message-ID: <1504075836-102681-3-git-send-email-kirill.rybalchenko@intel.com> (raw)
In-Reply-To: <1504075836-102681-1-git-send-email-kirill.rybalchenko@intel.com>

Update 'ddp get info' command to display protocols defined in  a profile

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 app/test-pmd/cmdline.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 93 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0144191..335e635 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,92 @@ 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) {
+			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)
-- 
2.5.5

      parent reply	other threads:[~2017-08-30  6:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30  6:50 [PATCH 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
2017-08-30  6:50 ` [PATCH 1/2] " Kirill Rybalchenko
2017-09-04 11:34   ` Iremonger, Bernard
2017-08-30  6:50 ` Kirill Rybalchenko [this message]

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=1504075836-102681-3-git-send-email-kirill.rybalchenko@intel.com \
    --to=kirill.rybalchenko@intel.com \
    --cc=andrey.chilikin@intel.com \
    --cc=dev@dpdk.org \
    /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.