DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about protocols defined in ddp profile
       [not found] <4075836-102681-1-git-send-email-kirill.rybalchenko@intel.com>
@ 2017-09-01 16:01 ` Kirill Rybalchenko
  2017-09-01 16:01   ` [dpdk-dev] [PATCH v2 1/2] " Kirill Rybalchenko
                     ` (3 more replies)
  0 siblings, 4 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-01 16:01 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds ability to request information about protocols defined in dynamic
device personalization profile

v2:
Some code style warnings were removed

Kirill Rybalchenko (2):
  net/i40e: get information about protocols defined in ddp profile
  app/testpmd: get information about protocols defined in ddp profile

 app/test-pmd/cmdline.c          |  98 ++++++++++++++++++++++-
 drivers/net/i40e/rte_pmd_i40e.c | 167 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 3 files changed, 289 insertions(+), 1 deletion(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-01 16:01 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
@ 2017-09-01 16:01   ` Kirill Rybalchenko
  2017-09-04 12:36     ` Iremonger, Bernard
  2017-09-11 15:32     ` Ferruh Yigit
  2017-09-01 16:01   ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: " Kirill Rybalchenko
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-01 16:01 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds new package info types to get list of protocols,
pctypes and ptypes defined in a profile

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 167 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 2 files changed, 192 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index d69a472..59b30df 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
 	return status;
 }
 
+/* Get number of tvl records in the section */
+static unsigned
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned int i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (!sec)
+		return nb_tlv;
+
+	/* get number of records in the section */
+	nb_rec = sec->section.size / sizeof(struct i40e_profile_tlv_section_record);
+	for (i = 0; i < nb_rec; ) {
+		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
+		i += tlv->len;
+		nb_tlv++;
+	}
+	return nb_tlv;
+}
+
 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 	uint8_t *info_buff, uint32_t info_size,
 	enum rte_pmd_i40e_package_info type)
@@ -1860,6 +1880,153 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		return I40E_SUCCESS;
 	}
 
+	/* get number of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
+		struct i40e_profile_section_header *proto;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+					(struct i40e_profile_segment *)i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
+		uint32_t i, j, nb_rec;
+		struct rte_pmd_i40e_proto_info *pinfo;
+		struct i40e_profile_section_header *proto;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+					(struct i40e_profile_segment *)i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(proto);
+		if (info_size < nb_rec) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
+		for (i = 0; i < info_size; i++) {
+			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
+			memset(pinfo[i].name, 0, RTE_PMD_I40E_DDP_NAME_SIZE);
+		}
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = proto->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].proto_id = tlv->data[0];
+			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
+				I40E_DDP_NAME_SIZE);
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
+		struct i40e_profile_section_header *pctype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+					(struct i40e_profile_segment *)i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
+		uint32_t i, j, nb_rec;
+
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *pctype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+					(struct i40e_profile_segment *)i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(pctype);
+		if (info_size < nb_rec) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+				sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = pctype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].ptype_id = tlv->data[0];
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
+		struct i40e_profile_section_header *ptype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+					(struct i40e_profile_segment *)i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
+		uint32_t i, nb_rec;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *ptype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+					(struct i40e_profile_segment *)i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(ptype);
+		if (info_size < nb_rec) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = ptype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		for (i = 0; i < nb_rec; ) {
+			tlv = (struct i40e_profile_tlv_section_record *)&ptype[1 + i];
+			pinfo[i].ptype_id = tlv->data[0];
+			memcpy(&pinfo[i], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+		}
+		return I40E_SUCCESS;
+	}
+
 	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
 	return -EINVAL;
 }
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 155b7e8..b631093 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
 	RTE_PMD_I40E_PKG_INFO_HEADER,
 	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
 	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
 	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
 };
 
@@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
 	struct rte_pmd_i40e_profile_info p_info[1];
 };
 
+#define RTE_PMD_I40E_PROTO_NUM 6
+#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
+
+/**
+* Protocols information stored in profile
+*/
+struct rte_pmd_i40e_proto_info {
+	uint8_t proto_id;
+	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
+};
+
+/**
+* Packet classification/ packet type information stored in profile
+*/
+struct rte_pmd_i40e_ptype_info {
+	uint8_t ptype_id;
+	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
+};
+
 /**
  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
  * A ptype with MSB set will be regarded as a user defined ptype.
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-01 16:01 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
  2017-09-01 16:01   ` [dpdk-dev] [PATCH v2 1/2] " Kirill Rybalchenko
@ 2017-09-01 16:01   ` Kirill Rybalchenko
  2017-09-04 12:44     ` Iremonger, Bernard
                       ` (2 more replies)
  2017-09-19 16:46   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-19 17:32   ` [dpdk-dev] [PATCH v4 0/2] net/i40e: " Kirill Rybalchenko
  3 siblings, 3 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-01 16:01 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

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 | 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) {
+			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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-01 16:01   ` [dpdk-dev] [PATCH v2 1/2] " Kirill Rybalchenko
@ 2017-09-04 12:36     ` Iremonger, Bernard
  2017-09-11 15:32     ` Ferruh Yigit
  1 sibling, 0 replies; 30+ messages in thread
From: Iremonger, Bernard @ 2017-09-04 12:36 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev
  Cc: Rybalchenko, Kirill, Chilikin, Andrey, Xing, Beilei, Wu, Jingjing

Hi Kirill,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill Rybalchenko
> Sent: Friday, September 1, 2017 5:01 PM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about
> protocols defined in ddp profile
> 
> This patch adds new package info types to get list of protocols, pctypes and
> ptypes defined in a profile
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> ---
>  drivers/net/i40e/rte_pmd_i40e.c | 167
> ++++++++++++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
>  2 files changed, 192 insertions(+)
> 
> diff --git a/drivers/net/i40e/rte_pmd_i40e.c
> b/drivers/net/i40e/rte_pmd_i40e.c index d69a472..59b30df 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.c
> +++ b/drivers/net/i40e/rte_pmd_i40e.c
> @@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t
> port, uint8_t *buff,
>  	return status;
>  }
> 
> +/* Get number of tvl records in the section */ static unsigned

Better to use static unsigned int instead of static unsigned.

> +i40e_get_tlv_section_size(struct i40e_profile_section_header *sec) {
> +	unsigned int i, nb_rec, nb_tlv = 0;
> +	struct i40e_profile_tlv_section_record *tlv;
> +
> +	if (!sec)
> +		return nb_tlv;
> +
> +	/* get number of records in the section */
> +	nb_rec = sec->section.size / sizeof(struct
> i40e_profile_tlv_section_record);
> +	for (i = 0; i < nb_rec; ) {
> +		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
> +		i += tlv->len;
> +		nb_tlv++;
> +	}
> +	return nb_tlv;
> +}
> +
>  int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
>  	uint8_t *info_buff, uint32_t info_size,
>  	enum rte_pmd_i40e_package_info type)
> @@ -1860,6 +1880,153 @@ int rte_pmd_i40e_get_ddp_info(uint8_t
> *pkg_buff, uint32_t pkg_size,
>  		return I40E_SUCCESS;
>  	}
> 
> +	/* get number of protocols */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
> +		struct i40e_profile_section_header *proto;
> +
> +		if (info_size < sizeof(uint32_t)) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
> +					(struct i40e_profile_segment
> *)i40e_seg_hdr);
> +		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
> +		return I40E_SUCCESS;
> +	}
> +
> +	/* get list of protocols */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
> +		uint32_t i, j, nb_rec;
> +		struct rte_pmd_i40e_proto_info *pinfo;
> +		struct i40e_profile_section_header *proto;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
> +					(struct i40e_profile_segment
> *)i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(proto);
> +		if (info_size < nb_rec) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
> +		for (i = 0; i < info_size; i++) {
> +			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
> +			memset(pinfo[i].name, 0,
> RTE_PMD_I40E_DDP_NAME_SIZE);
> +		}
> +		if (nb_rec == 0)
> +			return I40E_SUCCESS;
> +		/* get number of records in the section */
> +		nb_rec = proto->section.size /
> +					sizeof(struct
> i40e_profile_tlv_section_record);
> +		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
> +		for (i = j = 0; i < nb_rec; j++) {
> +			pinfo[j].proto_id = tlv->data[0];
> +			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
> +				I40E_DDP_NAME_SIZE);
> +			i += tlv->len;
> +			tlv = &tlv[tlv->len];
> +		}
> +		return I40E_SUCCESS;
> +	}
> +
> +	/* get number of packet classification types */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
> +		struct i40e_profile_section_header *pctype;
> +
> +		if (info_size < sizeof(uint32_t)) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		pctype =
> i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
> +					(struct i40e_profile_segment
> *)i40e_seg_hdr);
> +		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
> +		return I40E_SUCCESS;
> +	}
> +
> +	/* get list of packet classification types */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
> +		uint32_t i, j, nb_rec;
> +
> +		struct rte_pmd_i40e_ptype_info *pinfo;
> +		struct i40e_profile_section_header *pctype;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		pctype =
> i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
> +					(struct i40e_profile_segment
> *)i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(pctype);
> +		if (info_size < nb_rec) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
> +		for (i = 0; i < info_size; i++)
> +			memset(&pinfo[i],
> RTE_PMD_I40E_PROTO_UNUSED,
> +				sizeof(struct rte_pmd_i40e_ptype_info));
> +
> +		if (nb_rec == 0)
> +			return I40E_SUCCESS;
> +		/* get number of records in the section */
> +		nb_rec = pctype->section.size /
> +					sizeof(struct
> i40e_profile_tlv_section_record);
> +		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
> +		for (i = j = 0; i < nb_rec; j++) {
> +			pinfo[j].ptype_id = tlv->data[0];
> +			memcpy(&pinfo[j], tlv->data,
> +			       sizeof(struct rte_pmd_i40e_ptype_info));
> +			i += tlv->len;
> +			tlv = &tlv[tlv->len];
> +		}
> +		return I40E_SUCCESS;
> +	}
> +
> +	/* get number of packet types */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
> +		struct i40e_profile_section_header *ptype;
> +
> +		if (info_size < sizeof(uint32_t)) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
> +					(struct i40e_profile_segment
> *)i40e_seg_hdr);
> +		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
> +		return I40E_SUCCESS;
> +	}
> +
> +	/* get list of packet types */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
> +		uint32_t i, nb_rec;
> +		struct rte_pmd_i40e_ptype_info *pinfo;
> +		struct i40e_profile_section_header *ptype;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
> +					(struct i40e_profile_segment
> *)i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(ptype);
> +		if (info_size < nb_rec) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
> +		for (i = 0; i < info_size; i++)
> +			memset(&pinfo[i],
> RTE_PMD_I40E_PROTO_UNUSED,
> +			       sizeof(struct rte_pmd_i40e_ptype_info));
> +
> +		if (nb_rec == 0)
> +			return I40E_SUCCESS;
> +		/* get number of records in the section */
> +		nb_rec = ptype->section.size /
> +					sizeof(struct
> i40e_profile_tlv_section_record);
> +		for (i = 0; i < nb_rec; ) {
> +			tlv = (struct i40e_profile_tlv_section_record
> *)&ptype[1 + i];
> +			pinfo[i].ptype_id = tlv->data[0];
> +			memcpy(&pinfo[i], tlv->data,
> +			       sizeof(struct rte_pmd_i40e_ptype_info));
> +			i += tlv->len;
> +		}
> +		return I40E_SUCCESS;
> +	}
> +
>  	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
>  	return -EINVAL;
>  }

Checkpatch is showing a lot of warnings in this file.

> diff --git a/drivers/net/i40e/rte_pmd_i40e.h
> b/drivers/net/i40e/rte_pmd_i40e.h index 155b7e8..b631093 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.h
> +++ b/drivers/net/i40e/rte_pmd_i40e.h
> @@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
>  	RTE_PMD_I40E_PKG_INFO_HEADER,
>  	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
>  	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
> +	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
> +	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
> +	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
> +	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
> +	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
> +	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
>  	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF  };
> 
> @@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
>  	struct rte_pmd_i40e_profile_info p_info[1];  };
> 
> +#define RTE_PMD_I40E_PROTO_NUM 6
> +#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
> +
> +/**
> +* Protocols information stored in profile */ struct
> +rte_pmd_i40e_proto_info {
> +	uint8_t proto_id;
> +	char name[RTE_PMD_I40E_DDP_NAME_SIZE]; };
> +
> +/**
> +* Packet classification/ packet type information stored in profile */

Checkpatch is giving a warning with the above line.

> +struct rte_pmd_i40e_ptype_info {
> +	uint8_t ptype_id;
> +	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
> +};
> +
>  /**
>   * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
>   * A ptype with MSB set will be regarded as a user defined ptype.
> --
> 2.5.5

I intended to reply to the v2 email not the v1 email (previous reply).

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-01 16:01   ` [dpdk-dev] [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
  2 siblings, 0 replies; 30+ messages in thread
From: Iremonger, Bernard @ 2017-09-04 12:44 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev
  Cc: Rybalchenko, Kirill, Chilikin, Andrey, Xing, Beilei, Wu, Jingjing



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill Rybalchenko
> Sent: Friday, September 1, 2017 5:01 PM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [dpdk-dev] [PATCH v2 2/2] app/testpmd: get information about
> protocols defined in ddp profile
> 
> 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 | 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) {
> +			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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-01 16:01   ` [dpdk-dev] [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
  2 siblings, 0 replies; 30+ messages in thread
From: Iremonger, Bernard @ 2017-09-04 12:46 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev
  Cc: Rybalchenko, Kirill, Chilikin, Andrey, Xing, Beilei, Wu, Jingjing

Hi Kirill,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill Rybalchenko
> Sent: Friday, September 1, 2017 5:01 PM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [dpdk-dev] [PATCH v2 2/2] app/testpmd: get information about
> protocols defined in ddp profile
> 
> 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 | 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) {
> +			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

There are a lot of checkpatch warnings in this file.

Regards,

Bernard.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-01 16:01   ` [dpdk-dev] [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
  2 siblings, 0 replies; 30+ messages in thread
From: Ferruh Yigit @ 2017-09-11 15:32 UTC (permalink / raw)
  To: Kirill Rybalchenko, dev; +Cc: andrey.chilikin, beilei.xing, jingjing.wu

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 <kirill.rybalchenko@intel.com>
> ---
>  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)
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-01 16:01   ` [dpdk-dev] [PATCH v2 1/2] " Kirill Rybalchenko
  2017-09-04 12:36     ` Iremonger, Bernard
@ 2017-09-11 15:32     ` Ferruh Yigit
  1 sibling, 0 replies; 30+ messages in thread
From: Ferruh Yigit @ 2017-09-11 15:32 UTC (permalink / raw)
  To: Kirill Rybalchenko, dev; +Cc: andrey.chilikin, beilei.xing, jingjing.wu

On 9/1/2017 5:01 PM, Kirill Rybalchenko wrote:
> This patch adds new package info types to get list of protocols,
> pctypes and ptypes defined in a profile
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>

<...>

> +/* Get number of tvl records in the section */
> +static unsigned
> +i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
> +{
> +	unsigned int i, nb_rec, nb_tlv = 0;
> +	struct i40e_profile_tlv_section_record *tlv;
> +
> +	if (!sec)
> +		return nb_tlv;
> +
> +	/* get number of records in the section */
> +	nb_rec = sec->section.size / sizeof(struct i40e_profile_tlv_section_record);
> +	for (i = 0; i < nb_rec; ) {
> +		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
> +		i += tlv->len;

"sec[1 + i]" cast to tlv struct, and "i" increased by tlv->len, can you
please confirm tlv->len is measure of tlv_section_record, not bytes.


> +		nb_tlv++;
> +	}
> +	return nb_tlv;
> +}

<...>

> +	/* get list of protocols */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
> +		uint32_t i, j, nb_rec;
> +		struct rte_pmd_i40e_proto_info *pinfo;
> +		struct i40e_profile_section_header *proto;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
> +					(struct i40e_profile_segment *)i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(proto);
> +		if (info_size < nb_rec) {

Is there an assumption that for this type, info_size is measure of
records instead of input buffer size in bytes as other types? I believe
info_size should be consistent between types.

<...>

> +	/* get list of packet classification types */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
> +		uint32_t i, j, nb_rec;
> +
> +		struct rte_pmd_i40e_ptype_info *pinfo;> +		struct i40e_profile_section_header *pctype;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
> +					(struct i40e_profile_segment *)i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(pctype);
> +		if (info_size < nb_rec) {

Same as above, info_size assumed to number of structs, not size in bytes.

> +			PMD_DRV_LOG(ERR, "Invalid information buffer size");
> +			return -EINVAL;
> +		}
> +		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;

Just to double check, both types PCTYPE_LIST and PTYPE_LIST types are
returning "rte_pmd_i40e_ptype_info"? So no specific struct for pctype?

> +		for (i = 0; i < info_size; i++)
> +			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
> +				sizeof(struct rte_pmd_i40e_ptype_info));
> +
> +		if (nb_rec == 0)
> +			return I40E_SUCCESS;
> +		/* get number of records in the section */
> +		nb_rec = pctype->section.size /
> +					sizeof(struct i40e_profile_tlv_section_record);
> +		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
> +		for (i = j = 0; i < nb_rec; j++) {
> +			pinfo[j].ptype_id = tlv->data[0];
> +			memcpy(&pinfo[j], tlv->data,
> +			       sizeof(struct rte_pmd_i40e_ptype_info));

This overwrites one line above, intentional?

<...>

> +	/* get list of packet types */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
> +		uint32_t i, nb_rec;
> +		struct rte_pmd_i40e_ptype_info *pinfo;
> +		struct i40e_profile_section_header *ptype;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
> +					(struct i40e_profile_segment *)i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(ptype);
> +		if (info_size < nb_rec) {

Same as above.

> +			PMD_DRV_LOG(ERR, "Invalid information buffer size");
> +			return -EINVAL;
> +		}
> +		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
> +		for (i = 0; i < info_size; i++)
> +			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
> +			       sizeof(struct rte_pmd_i40e_ptype_info));
> +
> +		if (nb_rec == 0)
> +			return I40E_SUCCESS;
> +		/* get number of records in the section */
> +		nb_rec = ptype->section.size /
> +					sizeof(struct i40e_profile_tlv_section_record);
> +		for (i = 0; i < nb_rec; ) {
> +			tlv = (struct i40e_profile_tlv_section_record *)&ptype[1 + i];
> +			pinfo[i].ptype_id = tlv->data[0];
> +			memcpy(&pinfo[i], tlv->data,
> +			       sizeof(struct rte_pmd_i40e_ptype_info));

same as above.

<...>

> --- a/drivers/net/i40e/rte_pmd_i40e.h
> +++ b/drivers/net/i40e/rte_pmd_i40e.h
> @@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
>  	RTE_PMD_I40E_PKG_INFO_HEADER,
>  	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
>  	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
> +	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
> +	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
> +	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
> +	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
> +	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
> +	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
>  	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF

This is not part of this patch, but out of curiosity, what is the use
case of defining a max in enum with a fixed number?

>  };
>  
> @@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
>  	struct rte_pmd_i40e_profile_info p_info[1];
>  };
>  
> +#define RTE_PMD_I40E_PROTO_NUM 6
> +#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
> +
> +/**
> +* Protocols information stored in profile
> +*/
> +struct rte_pmd_i40e_proto_info {
> +	uint8_t proto_id;
> +	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
> +};
> +
> +/**
> +* Packet classification/ packet type information stored in profile
> +*/
> +struct rte_pmd_i40e_ptype_info {
> +	uint8_t ptype_id;
> +	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
> +};
> +
>  /**
>   * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
>   * A ptype with MSB set will be regarded as a user defined ptype.
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 0/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-01 16:01 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
  2017-09-01 16:01   ` [dpdk-dev] [PATCH v2 1/2] " Kirill Rybalchenko
  2017-09-01 16:01   ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: " Kirill Rybalchenko
@ 2017-09-19 16:46   ` Kirill Rybalchenko
  2017-09-19 16:46     ` [dpdk-dev] [PATCH v3 1/2] " Kirill Rybalchenko
  2017-09-19 16:46     ` [dpdk-dev] [PATCH v3 2/2] app/testpmd: " Kirill Rybalchenko
  2017-09-19 17:32   ` [dpdk-dev] [PATCH v4 0/2] net/i40e: " Kirill Rybalchenko
  3 siblings, 2 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 16:46 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds ability to request information about protocols defined in dynamic
device personalization profile

v2:
Some code style warnings were removed

v3:
info_size parameter always represents size of the info buffer in bytes;
fix code style;

Kirill Rybalchenko (2):
  net/i40e: get information about protocols defined in ddp profile
  app/testpmd: get information about protocols defined in ddp profile

 app/test-pmd/cmdline.c          | 107 ++++++++++++++++++++++++-
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 3 files changed, 302 insertions(+), 1 deletion(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-19 16:46   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: " Kirill Rybalchenko
@ 2017-09-19 16:46     ` Kirill Rybalchenko
  2017-09-19 16:46     ` [dpdk-dev] [PATCH v3 2/2] app/testpmd: " Kirill Rybalchenko
  1 sibling, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 16:46 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds new package info types to get list of protocols,
pctypes and ptypes defined in a profile

---
v3
info_size parameter always represents size of the info
buffer in bytes
---

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 2 files changed, 196 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index c08e07a..80af18b 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
 	return status;
 }
 
+/* Get number of tvl records in the section */
+static unsigned int
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned int i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (!sec)
+		return nb_tlv;
+
+	/* get number of records in the section */
+	nb_rec = sec->section.size / sizeof(struct i40e_profile_tlv_section_record);
+	for (i = 0; i < nb_rec; ) {
+		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
+		i += tlv->len;
+		nb_tlv++;
+	}
+	return nb_tlv;
+}
+
 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 	uint8_t *info_buff, uint32_t info_size,
 	enum rte_pmd_i40e_package_info type)
@@ -1860,6 +1880,157 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		return I40E_SUCCESS;
 	}
 
+	/* get number of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
+		struct i40e_profile_section_header *proto;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
+		uint32_t i, j, nb_rec;
+		struct rte_pmd_i40e_proto_info *pinfo;
+		struct i40e_profile_section_header *proto;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(proto);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_proto_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
+		for (i = 0; i < info_size; i++) {
+			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
+			memset(pinfo[i].name, 0, RTE_PMD_I40E_DDP_NAME_SIZE);
+		}
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = proto->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].proto_id = tlv->data[0];
+			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
+				I40E_DDP_NAME_SIZE);
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
+		struct i40e_profile_section_header *pctype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
+		uint32_t i, j, nb_rec;
+
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *pctype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(pctype);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_ptype_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = pctype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
+		struct i40e_profile_section_header *ptype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
+		uint32_t i, j, nb_rec;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *ptype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(ptype);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_ptype_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = ptype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		for (i = j = 0; i < nb_rec; j++) {
+			tlv = (struct i40e_profile_tlv_section_record *)&ptype[1 + i];
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+		}
+		return I40E_SUCCESS;
+	}
+
 	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
 	return -EINVAL;
 }
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 155b7e8..b9fd18e 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
 	RTE_PMD_I40E_PKG_INFO_HEADER,
 	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
 	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
 	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
 };
 
@@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
 	struct rte_pmd_i40e_profile_info p_info[1];
 };
 
+#define RTE_PMD_I40E_PROTO_NUM 6
+#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
+
+/**
+ * Protocols information stored in profile
+ */
+struct rte_pmd_i40e_proto_info {
+	uint8_t proto_id;
+	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
+};
+
+/**
+ * Packet classification/ packet type information stored in profile
+ */
+struct rte_pmd_i40e_ptype_info {
+	uint8_t ptype_id;
+	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
+};
+
 /**
  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
  * A ptype with MSB set will be regarded as a user defined ptype.
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v3 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-19 16:46   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-19 16:46     ` [dpdk-dev] [PATCH v3 1/2] " Kirill Rybalchenko
@ 2017-09-19 16:46     ` Kirill Rybalchenko
  1 sibling, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 16:46 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

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

Fix code style

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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4f2d731..608b022 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;
 	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;
+	uint8_t proto_id;
+
 #endif
 
 	pkg = open_ddp_package_file(res->filepath, &pkg_size);
@@ -13506,8 +13514,105 @@ 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;
+
+	proto = (struct rte_pmd_i40e_proto_info *)
+		malloc(proto_num * sizeof(struct rte_pmd_i40e_proto_info));
+	if (!proto)
+		goto no_print_return;
+
+	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) 
+		goto no_print_pctypes;
+
+	pctype = (struct rte_pmd_i40e_ptype_info *)
+		malloc(pctype_num * sizeof(struct rte_pmd_i40e_ptype_info));
+	if (!pctype) 
+		goto no_print_pctypes;
+
+	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);
+
+
+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;
+
+	ptype = (struct rte_pmd_i40e_ptype_info *)
+		malloc(ptype_num *
+		       sizeof(struct rte_pmd_i40e_ptype_info));
+	if (!ptype) 
+		goto no_print_return;
+
+	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
+no_print_return:
 	if (ret == -ENOTSUP)
 		printf("Function not supported in PMD driver\n");
 	close_ddp_package_file(pkg);
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v4 0/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-01 16:01 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
                     ` (2 preceding siblings ...)
  2017-09-19 16:46   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: " Kirill Rybalchenko
@ 2017-09-19 17:32   ` Kirill Rybalchenko
  2017-09-19 17:32     ` [dpdk-dev] [PATCH v4 1/2] " Kirill Rybalchenko
                       ` (2 more replies)
  3 siblings, 3 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 17:32 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds ability to request information about protocols defined in dynamic
device personalization profile

v2:
Some code style warnings were removed

v3:
info_size parameter always represents size of the info buffer in bytes;
fix code style;

v4:
anothe code style fixes

Kirill Rybalchenko (2):
  net/i40e: get information about protocols defined in ddp profile
  app/testpmd: get information about protocols defined in ddp profile

 app/test-pmd/cmdline.c          | 111 +++++++++++++++++++++++++-
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 3 files changed, 306 insertions(+), 1 deletion(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v4 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-19 17:32   ` [dpdk-dev] [PATCH v4 0/2] net/i40e: " Kirill Rybalchenko
@ 2017-09-19 17:32     ` Kirill Rybalchenko
  2017-09-19 17:32     ` [dpdk-dev] [PATCH v4 2/2] app/testpmd: " Kirill Rybalchenko
  2017-09-19 17:53     ` [dpdk-dev] [PATCH v5 0/2] net/i40e: " Kirill Rybalchenko
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 17:32 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds new package info types to get list of protocols,
pctypes and ptypes defined in a profile

---
v3
info_size parameter always represents size of the info buffer in bytes

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 2 files changed, 196 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index c08e07a..80af18b 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
 	return status;
 }
 
+/* Get number of tvl records in the section */
+static unsigned int
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned int i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (!sec)
+		return nb_tlv;
+
+	/* get number of records in the section */
+	nb_rec = sec->section.size / sizeof(struct i40e_profile_tlv_section_record);
+	for (i = 0; i < nb_rec; ) {
+		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
+		i += tlv->len;
+		nb_tlv++;
+	}
+	return nb_tlv;
+}
+
 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 	uint8_t *info_buff, uint32_t info_size,
 	enum rte_pmd_i40e_package_info type)
@@ -1860,6 +1880,157 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		return I40E_SUCCESS;
 	}
 
+	/* get number of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
+		struct i40e_profile_section_header *proto;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
+		uint32_t i, j, nb_rec;
+		struct rte_pmd_i40e_proto_info *pinfo;
+		struct i40e_profile_section_header *proto;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(proto);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_proto_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
+		for (i = 0; i < info_size; i++) {
+			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
+			memset(pinfo[i].name, 0, RTE_PMD_I40E_DDP_NAME_SIZE);
+		}
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = proto->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].proto_id = tlv->data[0];
+			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
+				I40E_DDP_NAME_SIZE);
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
+		struct i40e_profile_section_header *pctype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
+		uint32_t i, j, nb_rec;
+
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *pctype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(pctype);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_ptype_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = pctype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
+		struct i40e_profile_section_header *ptype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
+		uint32_t i, j, nb_rec;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *ptype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(ptype);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_ptype_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = ptype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		for (i = j = 0; i < nb_rec; j++) {
+			tlv = (struct i40e_profile_tlv_section_record *)&ptype[1 + i];
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+		}
+		return I40E_SUCCESS;
+	}
+
 	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
 	return -EINVAL;
 }
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 155b7e8..b9fd18e 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
 	RTE_PMD_I40E_PKG_INFO_HEADER,
 	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
 	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
 	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
 };
 
@@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
 	struct rte_pmd_i40e_profile_info p_info[1];
 };
 
+#define RTE_PMD_I40E_PROTO_NUM 6
+#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
+
+/**
+ * Protocols information stored in profile
+ */
+struct rte_pmd_i40e_proto_info {
+	uint8_t proto_id;
+	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
+};
+
+/**
+ * Packet classification/ packet type information stored in profile
+ */
+struct rte_pmd_i40e_ptype_info {
+	uint8_t ptype_id;
+	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
+};
+
 /**
  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
  * A ptype with MSB set will be regarded as a user defined ptype.
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v4 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-19 17:32   ` [dpdk-dev] [PATCH v4 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-19 17:32     ` [dpdk-dev] [PATCH v4 1/2] " Kirill Rybalchenko
@ 2017-09-19 17:32     ` Kirill Rybalchenko
  2017-09-19 17:53     ` [dpdk-dev] [PATCH v5 0/2] net/i40e: " Kirill Rybalchenko
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 17:32 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

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 | 111 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4f2d731..e9970a3 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;
 	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;
+	uint8_t proto_id;
+
 #endif
 
 	pkg = open_ddp_package_file(res->filepath, &pkg_size);
@@ -13506,8 +13514,109 @@ 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;
+
+	proto = (struct rte_pmd_i40e_proto_info *)
+		malloc(proto_num * sizeof(struct rte_pmd_i40e_proto_info));
+	if (!proto)
+		goto no_print_return;
+
+	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)
+		goto no_print_pctypes;
+
+	pctype = (struct rte_pmd_i40e_ptype_info *)
+		malloc(pctype_num * sizeof(struct rte_pmd_i40e_ptype_info));
+	if (!pctype)
+		goto no_print_pctypes;
+
+	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, pctype_num,
+					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;
+
+	ptype = (struct rte_pmd_i40e_ptype_info *)
+		malloc(ptype_num *
+		       sizeof(struct rte_pmd_i40e_ptype_info));
+	if (!ptype)
+		goto no_print_return;
+
+	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, ptype_num,
+					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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v5 0/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-19 17:32   ` [dpdk-dev] [PATCH v4 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-19 17:32     ` [dpdk-dev] [PATCH v4 1/2] " Kirill Rybalchenko
  2017-09-19 17:32     ` [dpdk-dev] [PATCH v4 2/2] app/testpmd: " Kirill Rybalchenko
@ 2017-09-19 17:53     ` Kirill Rybalchenko
  2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 1/2] " Kirill Rybalchenko
                         ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 17:53 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds ability to request information about protocols defined in dynamic
device personalization profile

v2:
Some code style warnings were removed

v3:
info_size parameter always represents size of the info buffer in bytes;
fix code style;

v4:
another code style fixes

v5:
in testpmd buff_size parameter in rte_pmd_i40e_get_ddp_info function call
always represents buffer size in bytes

Kirill Rybalchenko (2):
  net/i40e: get information about protocols defined in ddp profile
  app/testpmd: get information about protocols defined in ddp profile

 app/test-pmd/cmdline.c          | 110 +++++++++++++++++++++++++-
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 3 files changed, 305 insertions(+), 1 deletion(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v5 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-19 17:53     ` [dpdk-dev] [PATCH v5 0/2] net/i40e: " Kirill Rybalchenko
@ 2017-09-19 17:53       ` Kirill Rybalchenko
  2017-09-26  3:35         ` Xing, Beilei
  2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: " Kirill Rybalchenko
  2017-09-28 13:33       ` [dpdk-dev] [PATCH v6 0/2] net/i40e: " Kirill Rybalchenko
  2 siblings, 1 reply; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 17:53 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds new package info types to get list of protocols,
pctypes and ptypes defined in a profile

---
v3
info_size parameter always represents size of the info buffer in bytes

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 2 files changed, 196 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index c08e07a..80af18b 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
 	return status;
 }
 
+/* Get number of tvl records in the section */
+static unsigned int
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned int i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (!sec)
+		return nb_tlv;
+
+	/* get number of records in the section */
+	nb_rec = sec->section.size / sizeof(struct i40e_profile_tlv_section_record);
+	for (i = 0; i < nb_rec; ) {
+		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
+		i += tlv->len;
+		nb_tlv++;
+	}
+	return nb_tlv;
+}
+
 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 	uint8_t *info_buff, uint32_t info_size,
 	enum rte_pmd_i40e_package_info type)
@@ -1860,6 +1880,157 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		return I40E_SUCCESS;
 	}
 
+	/* get number of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
+		struct i40e_profile_section_header *proto;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
+		uint32_t i, j, nb_rec;
+		struct rte_pmd_i40e_proto_info *pinfo;
+		struct i40e_profile_section_header *proto;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(proto);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_proto_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
+		for (i = 0; i < info_size; i++) {
+			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
+			memset(pinfo[i].name, 0, RTE_PMD_I40E_DDP_NAME_SIZE);
+		}
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = proto->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].proto_id = tlv->data[0];
+			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
+				I40E_DDP_NAME_SIZE);
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
+		struct i40e_profile_section_header *pctype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
+		uint32_t i, j, nb_rec;
+
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *pctype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(pctype);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_ptype_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = pctype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
+		struct i40e_profile_section_header *ptype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
+		uint32_t i, j, nb_rec;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *ptype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(ptype);
+		if (info_size < nb_rec * sizeof(struct rte_pmd_i40e_ptype_info)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < info_size; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = ptype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		for (i = j = 0; i < nb_rec; j++) {
+			tlv = (struct i40e_profile_tlv_section_record *)&ptype[1 + i];
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+		}
+		return I40E_SUCCESS;
+	}
+
 	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
 	return -EINVAL;
 }
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 155b7e8..b9fd18e 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
 	RTE_PMD_I40E_PKG_INFO_HEADER,
 	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
 	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
 	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
 };
 
@@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
 	struct rte_pmd_i40e_profile_info p_info[1];
 };
 
+#define RTE_PMD_I40E_PROTO_NUM 6
+#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
+
+/**
+ * Protocols information stored in profile
+ */
+struct rte_pmd_i40e_proto_info {
+	uint8_t proto_id;
+	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
+};
+
+/**
+ * Packet classification/ packet type information stored in profile
+ */
+struct rte_pmd_i40e_ptype_info {
+	uint8_t ptype_id;
+	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
+};
+
 /**
  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
  * A ptype with MSB set will be regarded as a user defined ptype.
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v5 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-19 17:53     ` [dpdk-dev] [PATCH v5 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 1/2] " Kirill Rybalchenko
@ 2017-09-19 17:53       ` Kirill Rybalchenko
  2017-09-28 13:33       ` [dpdk-dev] [PATCH v6 0/2] net/i40e: " Kirill Rybalchenko
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-19 17:53 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

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

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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4f2d731..87eb2cd 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;
 	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;
+	uint8_t proto_id;
+
 #endif
 
 	pkg = open_ddp_package_file(res->filepath, &pkg_size);
@@ -13506,8 +13514,108 @@ 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;
+
+	proto = (struct rte_pmd_i40e_proto_info *)
+		malloc(proto_num * sizeof(struct rte_pmd_i40e_proto_info));
+	if (!proto)
+		goto no_print_return;
+
+	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)
+		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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v5 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 1/2] " Kirill Rybalchenko
@ 2017-09-26  3:35         ` Xing, Beilei
  0 siblings, 0 replies; 30+ messages in thread
From: Xing, Beilei @ 2017-09-26  3:35 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev; +Cc: Chilikin, Andrey, Wu, Jingjing



> -----Original Message-----
> From: Rybalchenko, Kirill
> Sent: Wednesday, September 20, 2017 1:54 AM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [PATCH v5 1/2] net/i40e: get information about protocols defined in
> ddp profile
> 
> This patch adds new package info types to get list of protocols, pctypes and
> ptypes defined in a profile
> 
> ---
> v3
> info_size parameter always represents size of the info buffer in bytes
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> ---
>  drivers/net/i40e/rte_pmd_i40e.c | 171
> ++++++++++++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
>  2 files changed, 196 insertions(+)
> 
> diff --git a/drivers/net/i40e/rte_pmd_i40e.c
> b/drivers/net/i40e/rte_pmd_i40e.c index c08e07a..80af18b 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.c
> +++ b/drivers/net/i40e/rte_pmd_i40e.c
> @@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t
> port, uint8_t *buff,
>  	return status;
>  }
> 
> +/* Get number of tvl records in the section */ static unsigned int
> +i40e_get_tlv_section_size(struct i40e_profile_section_header *sec) {
> +	unsigned int i, nb_rec, nb_tlv = 0;
> +	struct i40e_profile_tlv_section_record *tlv;
> +
> +	if (!sec)
> +		return nb_tlv;
> +
> +	/* get number of records in the section */
> +	nb_rec = sec->section.size / sizeof(struct
> i40e_profile_tlv_section_record);
> +	for (i = 0; i < nb_rec; ) {
> +		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
> +		i += tlv->len;
> +		nb_tlv++;
> +	}
> +	return nb_tlv;

In my opinion, nb_rec should be the same with nb_tlv, why need the for loop to get and return nb_tlv? Please correct me if I'm wrong.

<snip>

> +
> +	/* get list of protocols */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
> +		uint32_t i, j, nb_rec;
> +		struct rte_pmd_i40e_proto_info *pinfo;
> +		struct i40e_profile_section_header *proto;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
> +						     (struct
> i40e_profile_segment *)
> +						     i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(proto);
> +		if (info_size < nb_rec * sizeof(struct
> rte_pmd_i40e_proto_info)) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
> +		for (i = 0; i < info_size; i++) {

You changed info_size represents the size of the info buffer, then should use 'i < nb_rec' instead of ' i < info_size ' in for loop, otherwise there will be unexpected issue.

> +			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
> +			memset(pinfo[i].name, 0,
> RTE_PMD_I40E_DDP_NAME_SIZE);
> +		}
> +		if (nb_rec == 0)
> +			return I40E_SUCCESS;

Why not adding the condition just after 'nb_rec = i40e_get_tlv_section_size(proto);' ?

> +		/* get number of records in the section */
> +		nb_rec = proto->section.size /
> +					sizeof(struct
> i40e_profile_tlv_section_record);

Why do we need to get the nb_rec again? I think the value should be the same as the last value.

> +		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
> +		for (i = j = 0; i < nb_rec; j++) {
> +			pinfo[j].proto_id = tlv->data[0];
> +			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
> +				I40E_DDP_NAME_SIZE);
> +			i += tlv->len;
> +			tlv = &tlv[tlv->len];
> +		}
> +		return I40E_SUCCESS;
> +	}
> +

<snip>

Same comments for get RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST and RTE_PMD_I40E_PKG_INFO_PTYPE_LIST.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v6 0/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-19 17:53     ` [dpdk-dev] [PATCH v5 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 1/2] " Kirill Rybalchenko
  2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: " Kirill Rybalchenko
@ 2017-09-28 13:33       ` Kirill Rybalchenko
  2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 1/2] " Kirill Rybalchenko
                           ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-28 13:33 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds ability to request information about protocols defined in dynamic
device personalization profile

v2:
Some code style warnings were removed

v3:
info_size parameter always represents size of the info buffer in bytes;
fix code style;

v4:
another code style fixes

v5:
in testpmd 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

Kirill Rybalchenko (2):
  net/i40e: get information about protocols defined in ddp profile
  app/testpmd: get information about protocols defined in ddp profile

 app/test-pmd/cmdline.c          | 120 +++++++++++++++++++++++++--
 drivers/net/i40e/rte_pmd_i40e.c | 174 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 3 files changed, 312 insertions(+), 7 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v6 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-28 13:33       ` [dpdk-dev] [PATCH v6 0/2] net/i40e: " Kirill Rybalchenko
@ 2017-09-28 13:33         ` Kirill Rybalchenko
  2017-09-29  7:30           ` Xing, Beilei
  2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: " Kirill Rybalchenko
  2017-10-02  9:39         ` [dpdk-dev] [PATCH v7 0/2] net/i40e: " Kirill Rybalchenko
  2 siblings, 1 reply; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-28 13:33 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds new package info types to get list of protocols,
pctypes and ptypes defined in a profile

---
v3
info_size parameter always represents size of the info buffer in bytes

v6
fix bug with wrong usage of info_size parameter

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 174 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 2 files changed, 199 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index c08e07a..f57e59b 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
 	return status;
 }
 
+/* Get number of tvl records in the section */
+static unsigned int
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned int i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (!sec)
+		return nb_tlv;
+
+	/* get number of records in the section */
+	nb_rec = sec->section.size / sizeof(struct i40e_profile_tlv_section_record);
+	for (i = 0; i < nb_rec; ) {
+		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
+		i += tlv->len;
+		nb_tlv++;
+	}
+	return nb_tlv;
+}
+
 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 	uint8_t *info_buff, uint32_t info_size,
 	enum rte_pmd_i40e_package_info type)
@@ -1860,6 +1880,160 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		return I40E_SUCCESS;
 	}
 
+	/* get number of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
+		struct i40e_profile_section_header *proto;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
+		uint32_t i, j, nb_rec, nb_rec_buf;
+		struct rte_pmd_i40e_proto_info *pinfo;
+		struct i40e_profile_section_header *proto;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(proto);
+		nb_rec_buf = info_size / sizeof(struct rte_pmd_i40e_proto_info);
+		if (nb_rec_buf < nb_rec) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
+		for (i = 0; i < nb_rec_buf; i++) {
+			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
+			memset(pinfo[i].name, 0, RTE_PMD_I40E_DDP_NAME_SIZE);
+		}
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = proto->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].proto_id = tlv->data[0];
+			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
+				I40E_DDP_NAME_SIZE);
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
+		struct i40e_profile_section_header *pctype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
+		uint32_t i, j, nb_rec, nb_rec_buf;
+
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *pctype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(pctype);
+		nb_rec_buf = info_size / sizeof(struct rte_pmd_i40e_ptype_info);
+		if (nb_rec_buf < nb_rec) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < nb_rec_buf; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = pctype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
+		struct i40e_profile_section_header *ptype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
+		uint32_t i, j, nb_rec, nb_rec_buf;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *ptype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_rec = i40e_get_tlv_section_size(ptype);
+		nb_rec_buf = info_size / sizeof(struct rte_pmd_i40e_ptype_info);
+		if (nb_rec_buf < nb_rec) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		for (i = 0; i < nb_rec_buf; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+
+		if (nb_rec == 0)
+			return I40E_SUCCESS;
+		/* get number of records in the section */
+		nb_rec = ptype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		for (i = j = 0; i < nb_rec; j++) {
+			tlv = (struct i40e_profile_tlv_section_record *)&ptype[1 + i];
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+		}
+		return I40E_SUCCESS;
+	}
+
 	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
 	return -EINVAL;
 }
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 155b7e8..b9fd18e 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
 	RTE_PMD_I40E_PKG_INFO_HEADER,
 	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
 	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
 	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
 };
 
@@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
 	struct rte_pmd_i40e_profile_info p_info[1];
 };
 
+#define RTE_PMD_I40E_PROTO_NUM 6
+#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
+
+/**
+ * Protocols information stored in profile
+ */
+struct rte_pmd_i40e_proto_info {
+	uint8_t proto_id;
+	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
+};
+
+/**
+ * Packet classification/ packet type information stored in profile
+ */
+struct rte_pmd_i40e_ptype_info {
+	uint8_t ptype_id;
+	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
+};
+
 /**
  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
  * A ptype with MSB set will be regarded as a user defined ptype.
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v6 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-09-28 13:33       ` [dpdk-dev] [PATCH v6 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 1/2] " Kirill Rybalchenko
@ 2017-09-28 13:33         ` Kirill Rybalchenko
  2017-10-02  9:39         ` [dpdk-dev] [PATCH v7 0/2] net/i40e: " Kirill Rybalchenko
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-09-28 13:33 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

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

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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4f2d731..dfca164 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,107 @@ 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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v6 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 1/2] " Kirill Rybalchenko
@ 2017-09-29  7:30           ` Xing, Beilei
  0 siblings, 0 replies; 30+ messages in thread
From: Xing, Beilei @ 2017-09-29  7:30 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev; +Cc: Chilikin, Andrey, Wu, Jingjing

Seems you didn't address my questions except the memory access error in your last version.

> -----Original Message-----
> From: Rybalchenko, Kirill
> Sent: Thursday, September 28, 2017 9:33 PM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>
> Subject: [PATCH v6 1/2] net/i40e: get information about protocols defined in
> ddp profile
> 
> This patch adds new package info types to get list of protocols, pctypes and
> ptypes defined in a profile
> 
> ---
> v3
> info_size parameter always represents size of the info buffer in bytes
> 
> v6
> fix bug with wrong usage of info_size parameter
> 
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
> ---
>  drivers/net/i40e/rte_pmd_i40e.c | 174
> ++++++++++++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
>  2 files changed, 199 insertions(+)
> 
> diff --git a/drivers/net/i40e/rte_pmd_i40e.c
> b/drivers/net/i40e/rte_pmd_i40e.c index c08e07a..f57e59b 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.c
> +++ b/drivers/net/i40e/rte_pmd_i40e.c
> @@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t
> port, uint8_t *buff,
>  	return status;
>  }
> 
> +/* Get number of tvl records in the section */ static unsigned int
> +i40e_get_tlv_section_size(struct i40e_profile_section_header *sec) {
> +	unsigned int i, nb_rec, nb_tlv = 0;
> +	struct i40e_profile_tlv_section_record *tlv;
> +
> +	if (!sec)
> +		return nb_tlv;
> +
> +	/* get number of records in the section */
> +	nb_rec = sec->section.size / sizeof(struct
> i40e_profile_tlv_section_record);
> +	for (i = 0; i < nb_rec; ) {
> +		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
> +		i += tlv->len;
> +		nb_tlv++;
> +	}
> +	return nb_tlv;
> +}
> +
>  int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
>  	uint8_t *info_buff, uint32_t info_size,
>  	enum rte_pmd_i40e_package_info type)
> @@ -1860,6 +1880,160 @@ int rte_pmd_i40e_get_ddp_info(uint8_t
> *pkg_buff, uint32_t pkg_size,
>  		return I40E_SUCCESS;
>  	}
> 
> +	/* get number of protocols */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
> +		struct i40e_profile_section_header *proto;
> +
> +		if (info_size < sizeof(uint32_t)) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
> +						     (struct
> i40e_profile_segment *)
> +						     i40e_seg_hdr);
> +		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
> +		return I40E_SUCCESS;
> +	}
> +
> +	/* get list of protocols */
> +	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
> +		uint32_t i, j, nb_rec, nb_rec_buf;
> +		struct rte_pmd_i40e_proto_info *pinfo;
> +		struct i40e_profile_section_header *proto;
> +		struct i40e_profile_tlv_section_record *tlv;
> +
> +		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
> +						     (struct
> i40e_profile_segment *)
> +						     i40e_seg_hdr);
> +		nb_rec = i40e_get_tlv_section_size(proto);

If number of records is different with number of TLV, I think it's better to change nb_rec with nb_tlv, a little confused here.

> +		nb_rec_buf = info_size / sizeof(struct
> rte_pmd_i40e_proto_info);

How about changing nb_rec_buf with nb_proto_info?

> +		if (nb_rec_buf < nb_rec) {
> +			PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> +			return -EINVAL;
> +		}
> +		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
> +		for (i = 0; i < nb_rec_buf; i++) {
> +			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
> +			memset(pinfo[i].name, 0,
> RTE_PMD_I40E_DDP_NAME_SIZE);
> +		}
> +		if (nb_rec == 0)
> +			return I40E_SUCCESS;


Why not check nb_rec just when getting the value?  

<...>

Same comments for RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST and RTE_PMD_I40E_PKG_INFO_PTYPE_LIST.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v7 0/2] net/i40e: get information about protocols defined in ddp profile
  2017-09-28 13:33       ` [dpdk-dev] [PATCH v6 0/2] net/i40e: " Kirill Rybalchenko
  2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 1/2] " Kirill Rybalchenko
  2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: " Kirill Rybalchenko
@ 2017-10-02  9:39         ` Kirill Rybalchenko
  2017-10-02  9:39           ` [dpdk-dev] [PATCH v7 1/2] " Kirill Rybalchenko
                             ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-10-02  9:39 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds ability to request information about protocols defined in dynamic
device personalization profile

v2:
Some code style warnings were removed

v3:
info_size parameter always represents size of the info buffer in bytes;
fix code style;

v4:
another code style fixes

v5:
in testpmd 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

v7:
change misleading variable names, change order of checking variable
for zero value

Kirill Rybalchenko (2):
  net/i40e: get information about protocols defined in ddp profile
  app/testpmd: get information about protocols defined in ddp profile

 app/test-pmd/cmdline.c          | 120 ++++++++++++++++++++++++++--
 drivers/net/i40e/rte_pmd_i40e.c | 172 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 3 files changed, 310 insertions(+), 7 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v7 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-10-02  9:39         ` [dpdk-dev] [PATCH v7 0/2] net/i40e: " Kirill Rybalchenko
@ 2017-10-02  9:39           ` Kirill Rybalchenko
  2017-10-02  9:39           ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: " Kirill Rybalchenko
  2017-10-04 14:00           ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Kirill Rybalchenko
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-10-02  9:39 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds new package info types to get list of protocols,
pctypes and ptypes defined in a profile

---
v3
info_size parameter always represents size of the info buffer in bytes

v6
fix bug with wrong usage of info_size parameter

v7
change misleading variable names, change order of checking variable
for zero value

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 172 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 2 files changed, 197 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index c08e07a..8289a43 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1706,6 +1706,26 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
 	return status;
 }
 
+/* Get number of tvl records in the section */
+static unsigned int
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned int i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (!sec)
+		return nb_tlv;
+
+	/* get number of records in the section */
+	nb_rec = sec->section.size / sizeof(struct i40e_profile_tlv_section_record);
+	for (i = 0; i < nb_rec; ) {
+		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
+		i += tlv->len;
+		nb_tlv++;
+	}
+	return nb_tlv;
+}
+
 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 	uint8_t *info_buff, uint32_t info_size,
 	enum rte_pmd_i40e_package_info type)
@@ -1860,6 +1880,158 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		return I40E_SUCCESS;
 	}
 
+	/* get number of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
+		struct i40e_profile_section_header *proto;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
+		uint32_t i, j, nb_tlv, nb_rec, nb_proto_info;
+		struct rte_pmd_i40e_proto_info *pinfo;
+		struct i40e_profile_section_header *proto;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
+		nb_proto_info = info_size / sizeof(struct rte_pmd_i40e_proto_info);
+		for (i = 0; i < nb_proto_info; i++) {
+			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
+			memset(pinfo[i].name, 0, RTE_PMD_I40E_DDP_NAME_SIZE);
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_tlv = i40e_get_tlv_section_size(proto);
+		if (nb_tlv == 0)
+			return I40E_SUCCESS;
+		if (nb_proto_info < nb_tlv) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		/* get number of records in the section */
+		nb_rec = proto->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].proto_id = tlv->data[0];
+			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
+				I40E_DDP_NAME_SIZE);
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
+		struct i40e_profile_section_header *pctype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
+		uint32_t i, j, nb_tlv, nb_rec, nb_proto_info;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *pctype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		nb_proto_info = info_size / sizeof(struct rte_pmd_i40e_ptype_info);
+		for (i = 0; i < nb_proto_info; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+						      (struct i40e_profile_segment *)
+						      i40e_seg_hdr);
+		nb_tlv = i40e_get_tlv_section_size(pctype);
+		if (nb_tlv == 0)
+			return I40E_SUCCESS;
+		if (nb_proto_info < nb_tlv) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+
+		/* get number of records in the section */
+		nb_rec = pctype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
+		struct i40e_profile_section_header *ptype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
+		uint32_t i, j, nb_tlv, nb_rec, nb_proto_info;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *ptype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		nb_proto_info = info_size / sizeof(struct rte_pmd_i40e_ptype_info);
+		for (i = 0; i < nb_proto_info; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+						     (struct i40e_profile_segment *)
+						     i40e_seg_hdr);
+		nb_tlv = i40e_get_tlv_section_size(ptype);
+		if (nb_tlv == 0)
+			return I40E_SUCCESS;
+		if (nb_proto_info < nb_tlv) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		/* get number of records in the section */
+		nb_rec = ptype->section.size /
+					sizeof(struct i40e_profile_tlv_section_record);
+		for (i = j = 0; i < nb_rec; j++) {
+			tlv = (struct i40e_profile_tlv_section_record *)&ptype[1 + i];
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+		}
+		return I40E_SUCCESS;
+	}
+
 	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
 	return -EINVAL;
 }
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 155b7e8..b9fd18e 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
 	RTE_PMD_I40E_PKG_INFO_HEADER,
 	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
 	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
 	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
 };
 
@@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
 	struct rte_pmd_i40e_profile_info p_info[1];
 };
 
+#define RTE_PMD_I40E_PROTO_NUM 6
+#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
+
+/**
+ * Protocols information stored in profile
+ */
+struct rte_pmd_i40e_proto_info {
+	uint8_t proto_id;
+	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
+};
+
+/**
+ * Packet classification/ packet type information stored in profile
+ */
+struct rte_pmd_i40e_ptype_info {
+	uint8_t ptype_id;
+	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
+};
+
 /**
  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
  * A ptype with MSB set will be regarded as a user defined ptype.
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v7 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-10-02  9:39         ` [dpdk-dev] [PATCH v7 0/2] net/i40e: " Kirill Rybalchenko
  2017-10-02  9:39           ` [dpdk-dev] [PATCH v7 1/2] " Kirill Rybalchenko
@ 2017-10-02  9:39           ` Kirill Rybalchenko
  2017-10-04 14:00           ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Kirill Rybalchenko
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-10-02  9:39 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

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

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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4f2d731..dfca164 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,107 @@ 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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v8 0/2] et/i40e: get information about protocols defined in ddp profile
  2017-10-02  9:39         ` [dpdk-dev] [PATCH v7 0/2] net/i40e: " Kirill Rybalchenko
  2017-10-02  9:39           ` [dpdk-dev] [PATCH v7 1/2] " Kirill Rybalchenko
  2017-10-02  9:39           ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: " Kirill Rybalchenko
@ 2017-10-04 14:00           ` Kirill Rybalchenko
  2017-10-04 14:00             ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Kirill Rybalchenko
                               ` (2 more replies)
  2 siblings, 3 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-10-04 14:00 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds ability to request information about protocols defined in dynamic
device personalization profile

v2:
Some code style warnings were removed

v3:
info_size parameter always represents size of the info buffer in bytes;
fix code style;

v4:
another code style fixes

v5:
in testpmd 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

v7:
change misleading variable names, change order of checking variable
for zero value

v8:
Fix code style warnings.

Kirill Rybalchenko (2):
  net/i40e: get information about protocols defined in ddp profile
  app/testpmd: get information about protocols defined in ddp profile

 app/test-pmd/cmdline.c          | 123 +++++++++++++++++++++++++++--
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 3 files changed, 312 insertions(+), 7 deletions(-)

-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v8 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-10-04 14:00           ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Kirill Rybalchenko
@ 2017-10-04 14:00             ` Kirill Rybalchenko
  2017-10-04 14:00             ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: " Kirill Rybalchenko
  2017-10-04 22:00             ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Ferruh Yigit
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-10-04 14:00 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

This patch adds new package info types to get list of protocols,
pctypes and ptypes defined in a profile

---
v3
info_size parameter always represents size of the info buffer in bytes

v6
fix bug with wrong usage of info_size parameter

v7
change misleading variable names, change order of checking variable
for zero value

v8
Fix code style warnings.

Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c | 171 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 ++++++
 2 files changed, 196 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index c08e07a..56a2235 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1706,6 +1706,27 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
 	return status;
 }
 
+/* Get number of tvl records in the section */
+static unsigned int
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned int i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (!sec)
+		return nb_tlv;
+
+	/* get number of records in the section */
+	nb_rec = sec->section.size /
+				sizeof(struct i40e_profile_tlv_section_record);
+	for (i = 0; i < nb_rec; ) {
+		tlv = (struct i40e_profile_tlv_section_record *)&sec[1 + i];
+		i += tlv->len;
+		nb_tlv++;
+	}
+	return nb_tlv;
+}
+
 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 	uint8_t *info_buff, uint32_t info_size,
 	enum rte_pmd_i40e_package_info type)
@@ -1860,6 +1881,156 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
 		return I40E_SUCCESS;
 	}
 
+	/* get number of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM) {
+		struct i40e_profile_section_header *proto;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+				(struct i40e_profile_segment *)i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(proto);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of protocols */
+	if (type == RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST) {
+		uint32_t i, j, nb_tlv, nb_rec, nb_proto_info;
+		struct rte_pmd_i40e_proto_info *pinfo;
+		struct i40e_profile_section_header *proto;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pinfo = (struct rte_pmd_i40e_proto_info *)info_buff;
+		nb_proto_info = info_size /
+					sizeof(struct rte_pmd_i40e_proto_info);
+		for (i = 0; i < nb_proto_info; i++) {
+			pinfo[i].proto_id = RTE_PMD_I40E_PROTO_UNUSED;
+			memset(pinfo[i].name, 0, RTE_PMD_I40E_DDP_NAME_SIZE);
+		}
+		proto = i40e_find_section_in_profile(SECTION_TYPE_PROTO,
+				(struct i40e_profile_segment *)i40e_seg_hdr);
+		nb_tlv = i40e_get_tlv_section_size(proto);
+		if (nb_tlv == 0)
+			return I40E_SUCCESS;
+		if (nb_proto_info < nb_tlv) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		/* get number of records in the section */
+		nb_rec = proto->section.size /
+				sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&proto[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			pinfo[j].proto_id = tlv->data[0];
+			strncpy(pinfo[j].name, (const char *)&tlv->data[1],
+				I40E_DDP_NAME_SIZE);
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM) {
+		struct i40e_profile_section_header *pctype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+				(struct i40e_profile_segment *)i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(pctype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet classification types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST) {
+		uint32_t i, j, nb_tlv, nb_rec, nb_proto_info;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *pctype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		nb_proto_info = info_size /
+					sizeof(struct rte_pmd_i40e_ptype_info);
+		for (i = 0; i < nb_proto_info; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+		pctype = i40e_find_section_in_profile(SECTION_TYPE_PCTYPE,
+				(struct i40e_profile_segment *)i40e_seg_hdr);
+		nb_tlv = i40e_get_tlv_section_size(pctype);
+		if (nb_tlv == 0)
+			return I40E_SUCCESS;
+		if (nb_proto_info < nb_tlv) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+
+		/* get number of records in the section */
+		nb_rec = pctype->section.size /
+				sizeof(struct i40e_profile_tlv_section_record);
+		tlv = (struct i40e_profile_tlv_section_record *)&pctype[1];
+		for (i = j = 0; i < nb_rec; j++) {
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+			tlv = &tlv[tlv->len];
+		}
+		return I40E_SUCCESS;
+	}
+
+	/* get number of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_NUM) {
+		struct i40e_profile_section_header *ptype;
+
+		if (info_size < sizeof(uint32_t)) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+				(struct i40e_profile_segment *)i40e_seg_hdr);
+		*(uint32_t *)info_buff = i40e_get_tlv_section_size(ptype);
+		return I40E_SUCCESS;
+	}
+
+	/* get list of packet types */
+	if (type == RTE_PMD_I40E_PKG_INFO_PTYPE_LIST) {
+		uint32_t i, j, nb_tlv, nb_rec, nb_proto_info;
+		struct rte_pmd_i40e_ptype_info *pinfo;
+		struct i40e_profile_section_header *ptype;
+		struct i40e_profile_tlv_section_record *tlv;
+
+		pinfo = (struct rte_pmd_i40e_ptype_info *)info_buff;
+		nb_proto_info = info_size /
+					sizeof(struct rte_pmd_i40e_ptype_info);
+		for (i = 0; i < nb_proto_info; i++)
+			memset(&pinfo[i], RTE_PMD_I40E_PROTO_UNUSED,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+		ptype = i40e_find_section_in_profile(SECTION_TYPE_PTYPE,
+				(struct i40e_profile_segment *)i40e_seg_hdr);
+		nb_tlv = i40e_get_tlv_section_size(ptype);
+		if (nb_tlv == 0)
+			return I40E_SUCCESS;
+		if (nb_proto_info < nb_tlv) {
+			PMD_DRV_LOG(ERR, "Invalid information buffer size");
+			return -EINVAL;
+		}
+		/* get number of records in the section */
+		nb_rec = ptype->section.size /
+				sizeof(struct i40e_profile_tlv_section_record);
+		for (i = j = 0; i < nb_rec; j++) {
+			tlv = (struct i40e_profile_tlv_section_record *)
+								&ptype[1 + i];
+			memcpy(&pinfo[j], tlv->data,
+			       sizeof(struct rte_pmd_i40e_ptype_info));
+			i += tlv->len;
+		}
+		return I40E_SUCCESS;
+	}
+
 	PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
 	return -EINVAL;
 }
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 155b7e8..b9fd18e 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -88,6 +88,12 @@ enum rte_pmd_i40e_package_info {
 	RTE_PMD_I40E_PKG_INFO_HEADER,
 	RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
 	RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
+	RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
+	RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
 	RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
 };
 
@@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list {
 	struct rte_pmd_i40e_profile_info p_info[1];
 };
 
+#define RTE_PMD_I40E_PROTO_NUM 6
+#define RTE_PMD_I40E_PROTO_UNUSED 0xFF
+
+/**
+ * Protocols information stored in profile
+ */
+struct rte_pmd_i40e_proto_info {
+	uint8_t proto_id;
+	char name[RTE_PMD_I40E_DDP_NAME_SIZE];
+};
+
+/**
+ * Packet classification/ packet type information stored in profile
+ */
+struct rte_pmd_i40e_ptype_info {
+	uint8_t ptype_id;
+	uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
+};
+
 /**
  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
  * A ptype with MSB set will be regarded as a user defined ptype.
-- 
2.5.5

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [dpdk-dev] [PATCH v8 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-10-04 14:00           ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Kirill Rybalchenko
  2017-10-04 14:00             ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Kirill Rybalchenko
@ 2017-10-04 14:00             ` Kirill Rybalchenko
  2017-10-04 22:00             ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Ferruh Yigit
  2 siblings, 0 replies; 30+ messages in thread
From: Kirill Rybalchenko @ 2017-10-04 14:00 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v8 0/2] et/i40e: get information about protocols defined in ddp profile
  2017-10-04 14:00           ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Kirill Rybalchenko
  2017-10-04 14:00             ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Kirill Rybalchenko
  2017-10-04 14:00             ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: " Kirill Rybalchenko
@ 2017-10-04 22:00             ` Ferruh Yigit
  2017-10-05  1:11               ` Ferruh Yigit
  2 siblings, 1 reply; 30+ messages in thread
From: Ferruh Yigit @ 2017-10-04 22:00 UTC (permalink / raw)
  To: Kirill Rybalchenko, dev; +Cc: andrey.chilikin, beilei.xing, jingjing.wu

On 10/4/2017 3:00 PM, Kirill Rybalchenko wrote:
> This patch adds ability to request information about protocols defined in dynamic
> device personalization profile
> 
> v2:
> Some code style warnings were removed
> 
> v3:
> info_size parameter always represents size of the info buffer in bytes;
> fix code style;
> 
> v4:
> another code style fixes
> 
> v5:
> in testpmd 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
> 
> v7:
> change misleading variable names, change order of checking variable
> for zero value
> 
> v8:
> Fix code style warnings.
> 
> Kirill Rybalchenko (2):
>   net/i40e: get information about protocols defined in ddp profile
>   app/testpmd: get information about protocols defined in ddp profile

Series Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [dpdk-dev] [PATCH v8 0/2] et/i40e: get information about protocols defined in ddp profile
  2017-10-04 22:00             ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Ferruh Yigit
@ 2017-10-05  1:11               ` Ferruh Yigit
  0 siblings, 0 replies; 30+ messages in thread
From: Ferruh Yigit @ 2017-10-05  1:11 UTC (permalink / raw)
  To: Kirill Rybalchenko, dev; +Cc: andrey.chilikin, beilei.xing, jingjing.wu

On 10/4/2017 11:00 PM, Ferruh Yigit wrote:
> On 10/4/2017 3:00 PM, Kirill Rybalchenko wrote:
>> This patch adds ability to request information about protocols defined in dynamic
>> device personalization profile
>>
>> v2:
>> Some code style warnings were removed
>>
>> v3:
>> info_size parameter always represents size of the info buffer in bytes;
>> fix code style;
>>
>> v4:
>> another code style fixes
>>
>> v5:
>> in testpmd 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
>>
>> v7:
>> change misleading variable names, change order of checking variable
>> for zero value
>>
>> v8:
>> Fix code style warnings.
>>
>> Kirill Rybalchenko (2):
>>   net/i40e: get information about protocols defined in ddp profile
>>   app/testpmd: get information about protocols defined in ddp profile
> 
> Series Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2017-10-05  1:11 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4075836-102681-1-git-send-email-kirill.rybalchenko@intel.com>
2017-09-01 16:01 ` [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
2017-09-01 16:01   ` [dpdk-dev] [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   ` [dpdk-dev] [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   ` [dpdk-dev] [PATCH v3 0/2] net/i40e: " Kirill Rybalchenko
2017-09-19 16:46     ` [dpdk-dev] [PATCH v3 1/2] " Kirill Rybalchenko
2017-09-19 16:46     ` [dpdk-dev] [PATCH v3 2/2] app/testpmd: " Kirill Rybalchenko
2017-09-19 17:32   ` [dpdk-dev] [PATCH v4 0/2] net/i40e: " Kirill Rybalchenko
2017-09-19 17:32     ` [dpdk-dev] [PATCH v4 1/2] " Kirill Rybalchenko
2017-09-19 17:32     ` [dpdk-dev] [PATCH v4 2/2] app/testpmd: " Kirill Rybalchenko
2017-09-19 17:53     ` [dpdk-dev] [PATCH v5 0/2] net/i40e: " Kirill Rybalchenko
2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 1/2] " Kirill Rybalchenko
2017-09-26  3:35         ` Xing, Beilei
2017-09-19 17:53       ` [dpdk-dev] [PATCH v5 2/2] app/testpmd: " Kirill Rybalchenko
2017-09-28 13:33       ` [dpdk-dev] [PATCH v6 0/2] net/i40e: " Kirill Rybalchenko
2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 1/2] " Kirill Rybalchenko
2017-09-29  7:30           ` Xing, Beilei
2017-09-28 13:33         ` [dpdk-dev] [PATCH v6 2/2] app/testpmd: " Kirill Rybalchenko
2017-10-02  9:39         ` [dpdk-dev] [PATCH v7 0/2] net/i40e: " Kirill Rybalchenko
2017-10-02  9:39           ` [dpdk-dev] [PATCH v7 1/2] " Kirill Rybalchenko
2017-10-02  9:39           ` [dpdk-dev] [PATCH v7 2/2] app/testpmd: " Kirill Rybalchenko
2017-10-04 14:00           ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Kirill Rybalchenko
2017-10-04 14:00             ` [dpdk-dev] [PATCH v8 1/2] net/i40e: " Kirill Rybalchenko
2017-10-04 14:00             ` [dpdk-dev] [PATCH v8 2/2] app/testpmd: " Kirill Rybalchenko
2017-10-04 22:00             ` [dpdk-dev] [PATCH v8 0/2] et/i40e: " Ferruh Yigit
2017-10-05  1:11               ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).