From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 224513230 for ; Mon, 4 Sep 2017 14:36:20 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 04 Sep 2017 05:36:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,474,1498546800"; d="scan'208";a="147915654" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga006.fm.intel.com with ESMTP; 04 Sep 2017 05:36:19 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.167]) by IRSMSX101.ger.corp.intel.com ([169.254.1.22]) with mapi id 14.03.0319.002; Mon, 4 Sep 2017 13:36:18 +0100 From: "Iremonger, Bernard" To: "Rybalchenko, Kirill" , "dev@dpdk.org" CC: "Rybalchenko, Kirill" , "Chilikin, Andrey" , "Xing, Beilei" , "Wu, Jingjing" Thread-Topic: [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about protocols defined in ddp profile Thread-Index: AQHTIzu0x/Jmq6UHI0q5hxiUftGU16KkrL/g Date: Mon, 4 Sep 2017 12:36:17 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C24E04428B@IRSMSX108.ger.corp.intel.com> References: <4075836-102681-1-git-send-email-kirill.rybalchenko@intel.com> <1504281685-54502-1-git-send-email-kirill.rybalchenko@intel.com> <1504281685-54502-2-git-send-email-kirill.rybalchenko@intel.com> In-Reply-To: <1504281685-54502-2-git-send-email-kirill.rybalchenko@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2MyMTJmYTAtM2I3OS00YTBkLTkzZTItMDFiYzhhNzk5MTNlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Ilk3VTVoajA3dEpWdWlIV2wrWnlQTUZYZHhUXC8waER0RHoxcHlBNHI0YnJ3PSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about protocols defined in ddp profile X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Sep 2017 12:36:21 -0000 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 ; Chilikin, Andrey > ; Xing, Beilei ; Wu, > Jingjing > Subject: [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about > protocols defined in ddp profile >=20 > This patch adds new package info types to get list of protocols, pctypes = and > ptypes defined in a profile >=20 > Signed-off-by: Kirill Rybalchenko > --- > drivers/net/i40e/rte_pmd_i40e.c | 167 > ++++++++++++++++++++++++++++++++++++++++ > drivers/net/i40e/rte_pmd_i40e.h | 25 ++++++ > 2 files changed, 192 insertions(+) >=20 > 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; > } >=20 > +/* 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 =3D 0; > + struct i40e_profile_tlv_section_record *tlv; > + > + if (!sec) > + return nb_tlv; > + > + /* get number of records in the section */ > + nb_rec =3D sec->section.size / sizeof(struct > i40e_profile_tlv_section_record); > + for (i =3D 0; i < nb_rec; ) { > + tlv =3D (struct i40e_profile_tlv_section_record *)&sec[1 + i]; > + i +=3D 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; > } >=20 > + /* get number of protocols */ > + if (type =3D=3D 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 =3D i40e_find_section_in_profile(SECTION_TYPE_PROTO, > + (struct i40e_profile_segment > *)i40e_seg_hdr); > + *(uint32_t *)info_buff =3D i40e_get_tlv_section_size(proto); > + return I40E_SUCCESS; > + } > + > + /* get list of protocols */ > + if (type =3D=3D 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 =3D i40e_find_section_in_profile(SECTION_TYPE_PROTO, > + (struct i40e_profile_segment > *)i40e_seg_hdr); > + nb_rec =3D i40e_get_tlv_section_size(proto); > + if (info_size < nb_rec) { > + PMD_DRV_LOG(ERR, "Invalid information buffer > size"); > + return -EINVAL; > + } > + pinfo =3D (struct rte_pmd_i40e_proto_info *)info_buff; > + for (i =3D 0; i < info_size; i++) { > + pinfo[i].proto_id =3D RTE_PMD_I40E_PROTO_UNUSED; > + memset(pinfo[i].name, 0, > RTE_PMD_I40E_DDP_NAME_SIZE); > + } > + if (nb_rec =3D=3D 0) > + return I40E_SUCCESS; > + /* get number of records in the section */ > + nb_rec =3D proto->section.size / > + sizeof(struct > i40e_profile_tlv_section_record); > + tlv =3D (struct i40e_profile_tlv_section_record *)&proto[1]; > + for (i =3D j =3D 0; i < nb_rec; j++) { > + pinfo[j].proto_id =3D tlv->data[0]; > + strncpy(pinfo[j].name, (const char *)&tlv->data[1], > + I40E_DDP_NAME_SIZE); > + i +=3D tlv->len; > + tlv =3D &tlv[tlv->len]; > + } > + return I40E_SUCCESS; > + } > + > + /* get number of packet classification types */ > + if (type =3D=3D 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 =3D > i40e_find_section_in_profile(SECTION_TYPE_PCTYPE, > + (struct i40e_profile_segment > *)i40e_seg_hdr); > + *(uint32_t *)info_buff =3D i40e_get_tlv_section_size(pctype); > + return I40E_SUCCESS; > + } > + > + /* get list of packet classification types */ > + if (type =3D=3D 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 =3D > i40e_find_section_in_profile(SECTION_TYPE_PCTYPE, > + (struct i40e_profile_segment > *)i40e_seg_hdr); > + nb_rec =3D i40e_get_tlv_section_size(pctype); > + if (info_size < nb_rec) { > + PMD_DRV_LOG(ERR, "Invalid information buffer > size"); > + return -EINVAL; > + } > + pinfo =3D (struct rte_pmd_i40e_ptype_info *)info_buff; > + for (i =3D 0; i < info_size; i++) > + memset(&pinfo[i], > RTE_PMD_I40E_PROTO_UNUSED, > + sizeof(struct rte_pmd_i40e_ptype_info)); > + > + if (nb_rec =3D=3D 0) > + return I40E_SUCCESS; > + /* get number of records in the section */ > + nb_rec =3D pctype->section.size / > + sizeof(struct > i40e_profile_tlv_section_record); > + tlv =3D (struct i40e_profile_tlv_section_record *)&pctype[1]; > + for (i =3D j =3D 0; i < nb_rec; j++) { > + pinfo[j].ptype_id =3D tlv->data[0]; > + memcpy(&pinfo[j], tlv->data, > + sizeof(struct rte_pmd_i40e_ptype_info)); > + i +=3D tlv->len; > + tlv =3D &tlv[tlv->len]; > + } > + return I40E_SUCCESS; > + } > + > + /* get number of packet types */ > + if (type =3D=3D 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 =3D i40e_find_section_in_profile(SECTION_TYPE_PTYPE, > + (struct i40e_profile_segment > *)i40e_seg_hdr); > + *(uint32_t *)info_buff =3D i40e_get_tlv_section_size(ptype); > + return I40E_SUCCESS; > + } > + > + /* get list of packet types */ > + if (type =3D=3D 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 =3D i40e_find_section_in_profile(SECTION_TYPE_PTYPE, > + (struct i40e_profile_segment > *)i40e_seg_hdr); > + nb_rec =3D i40e_get_tlv_section_size(ptype); > + if (info_size < nb_rec) { > + PMD_DRV_LOG(ERR, "Invalid information buffer > size"); > + return -EINVAL; > + } > + pinfo =3D (struct rte_pmd_i40e_ptype_info *)info_buff; > + for (i =3D 0; i < info_size; i++) > + memset(&pinfo[i], > RTE_PMD_I40E_PROTO_UNUSED, > + sizeof(struct rte_pmd_i40e_ptype_info)); > + > + if (nb_rec =3D=3D 0) > + return I40E_SUCCESS; > + /* get number of records in the section */ > + nb_rec =3D ptype->section.size / > + sizeof(struct > i40e_profile_tlv_section_record); > + for (i =3D 0; i < nb_rec; ) { > + tlv =3D (struct i40e_profile_tlv_section_record > *)&ptype[1 + i]; > + pinfo[i].ptype_id =3D tlv->data[0]; > + memcpy(&pinfo[i], tlv->data, > + sizeof(struct rte_pmd_i40e_ptype_info)); > + i +=3D 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 =3D 0xFFFFFFFF }; >=20 > @@ -133,6 +139,25 @@ struct rte_pmd_i40e_profile_list { > struct rte_pmd_i40e_profile_info p_info[1]; }; >=20 > +#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.