All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] net/i40e: get information about protocols defined in ddp profile
@ 2017-08-30  6:50 Kirill Rybalchenko
  2017-08-30  6:50 ` [PATCH 1/2] " Kirill Rybalchenko
  2017-08-30  6:50 ` [PATCH 2/2] app/testpmd: " Kirill Rybalchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Kirill Rybalchenko @ 2017-08-30  6:50 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin

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

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          |  94 +++++++++++++++++++++++-
 drivers/net/i40e/rte_pmd_i40e.c | 155 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 +++++++
 3 files changed, 273 insertions(+), 1 deletion(-)

-- 
2.5.5

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

* [PATCH 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-08-30  6:50 [PATCH 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
@ 2017-08-30  6:50 ` Kirill Rybalchenko
  2017-09-04 11:34   ` Iremonger, Bernard
  2017-08-30  6:50 ` [PATCH 2/2] app/testpmd: " Kirill Rybalchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Kirill Rybalchenko @ 2017-08-30  6:50 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin

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 | 155 ++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  25 +++++++
 2 files changed, 180 insertions(+)

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index d69a472..f232d09 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
+i40e_get_tlv_section_size(struct i40e_profile_section_header *sec)
+{
+	unsigned i, nb_rec, nb_tlv = 0;
+	struct i40e_profile_tlv_section_record *tlv;
+
+	if (sec == NULL)
+		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,140 @@ 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 related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] app/testpmd: get information about protocols defined in ddp profile
  2017-08-30  6:50 [PATCH 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
  2017-08-30  6:50 ` [PATCH 1/2] " Kirill Rybalchenko
@ 2017-08-30  6:50 ` Kirill Rybalchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Kirill Rybalchenko @ 2017-08-30  6:50 UTC (permalink / raw)
  To: dev; +Cc: kirill.rybalchenko, andrey.chilikin

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

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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0144191..335e635 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -13423,12 +13423,18 @@ cmd_ddp_info_parsed(
 	uint32_t pkg_size;
 	int ret = -ENOTSUP;
 #ifdef RTE_LIBRTE_I40E_PMD
-	uint32_t i;
+	uint32_t i, j, n;
 	uint8_t *buff;
 	uint32_t buff_size;
 	struct rte_pmd_i40e_profile_info info;
 	uint32_t dev_num;
 	struct rte_pmd_i40e_ddp_device_id *devs;
+	uint32_t proto_num;
+	struct rte_pmd_i40e_proto_info *proto;
+	uint32_t pctype_num;
+	struct rte_pmd_i40e_ptype_info *pctype;
+	uint32_t ptype_num;
+	struct rte_pmd_i40e_ptype_info *ptype;
 #endif
 
 	pkg = open_ddp_package_file(res->filepath, &pkg_size);
@@ -13502,6 +13508,92 @@ cmd_ddp_info_parsed(
 			free(devs);
 		}
 	}
+
+	/* get information about protocols and packet types */
+	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+		(uint8_t *)&proto_num, sizeof(proto_num),
+		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
+	if (!ret && proto_num) {
+		uint8_t proto_id;
+		proto = (struct rte_pmd_i40e_proto_info *)
+			malloc(proto_num * sizeof(struct rte_pmd_i40e_proto_info));
+		if (proto) {
+			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+				(uint8_t *)proto, proto_num,
+				RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
+			if (!ret) {
+				printf("List of used protocols:\n");
+				for (i = 0; i < proto_num; i++)
+					printf("  %2u: %s\n", proto[i].proto_id, proto[i].name);
+				printf("\n");
+			}
+			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+				(uint8_t *)&pctype_num, sizeof(pctype_num),
+				RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
+			if (!ret && pctype_num) {
+				pctype = (struct rte_pmd_i40e_ptype_info *)
+					malloc(pctype_num * sizeof(struct rte_pmd_i40e_ptype_info));
+				if (pctype) {
+					ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+						(uint8_t *)pctype, pctype_num,
+						RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
+					if (!ret) {
+						printf("List of defined packet classification types:\n");
+						for (i = 0; i < pctype_num; i++) {
+							printf("  %2u:", pctype[i].ptype_id);
+							for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
+								proto_id = pctype[i].protocols[j];
+								if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
+									for (n = 0; n < proto_num; n++) {
+										if (proto[n].proto_id == proto_id) {
+											printf(" %s", proto[n].name);
+											break;
+										}
+									}
+								}
+							}
+							printf("\n");
+						}
+						printf("\n");
+					}
+					free(pctype);
+				}
+			}
+			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+				(uint8_t *)&ptype_num, sizeof(ptype_num),
+				RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
+			if (!ret && ptype_num) {
+				ptype = (struct rte_pmd_i40e_ptype_info *)
+					malloc(ptype_num * sizeof(struct rte_pmd_i40e_ptype_info));
+				if (ptype) {
+					ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+						(uint8_t *)ptype, ptype_num,
+						RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
+					if (!ret) {
+						printf("List of defined packet types:\n");
+						for (i = 0; i < ptype_num; i++) {
+							printf("  %2u:", ptype[i].ptype_id);
+							for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
+								proto_id = ptype[i].protocols[j];
+								if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
+									for (n = 0; n < proto_num; n++) {
+										if (proto[n].proto_id == proto_id) {
+											printf(" %s", proto[n].name);
+											break;
+										}
+									}
+								}
+							}
+							printf("\n");
+						}
+					}
+					free(ptype);
+				}
+				printf("\n");
+			}
+			free(proto);
+		}
+	}
 	ret = 0;
 #endif
 	if (ret == -ENOTSUP)
-- 
2.5.5

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

* Re: [PATCH 1/2] net/i40e: get information about protocols defined in ddp profile
  2017-08-30  6:50 ` [PATCH 1/2] " Kirill Rybalchenko
@ 2017-09-04 11:34   ` Iremonger, Bernard
  0 siblings, 0 replies; 4+ messages in thread
From: Iremonger, Bernard @ 2017-09-04 11:34 UTC (permalink / raw)
  To: Rybalchenko, Kirill, dev; +Cc: Rybalchenko, Kirill, Chilikin, Andrey

Hi Kirill,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kirill Rybalchenko
> Sent: Wednesday, August 30, 2017 7:51 AM
> To: dev@dpdk.org
> Cc: Rybalchenko, Kirill <kirill.rybalchenko@intel.com>; Chilikin, Andrey
> <andrey.chilikin@intel.com>
> Subject: [dpdk-dev] [PATCH 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 | 155
> ++++++++++++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h |  25 +++++++
>  2 files changed, 180 insertions(+)
> 
> diff --git a/drivers/net/i40e/rte_pmd_i40e.c
> b/drivers/net/i40e/rte_pmd_i40e.c index d69a472..f232d09 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

Better to use static unsigned int  instead of static unsigned

> +i40e_get_tlv_section_size(struct i40e_profile_section_header *sec) {
> +	unsigned i, nb_rec, nb_tlv = 0;
> +	struct i40e_profile_tlv_section_record *tlv;
> +
> +	if (sec == NULL)
> +		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,140 @@ 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

Regards,

Bernard.

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

end of thread, other threads:[~2017-09-04 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30  6:50 [PATCH 0/2] net/i40e: get information about protocols defined in ddp profile Kirill Rybalchenko
2017-08-30  6:50 ` [PATCH 1/2] " Kirill Rybalchenko
2017-09-04 11:34   ` Iremonger, Bernard
2017-08-30  6:50 ` [PATCH 2/2] app/testpmd: " Kirill Rybalchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.