From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3EF0D1B1AF for ; Tue, 26 Sep 2017 05:35:10 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2017 20:35:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,439,1500966000"; d="scan'208";a="153313422" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 25 Sep 2017 20:35:09 -0700 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 25 Sep 2017 20:35:09 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 25 Sep 2017 20:35:08 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.159]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Tue, 26 Sep 2017 11:35:07 +0800 From: "Xing, Beilei" To: "Rybalchenko, Kirill" , "dev@dpdk.org" CC: "Chilikin, Andrey" , "Wu, Jingjing" Thread-Topic: [PATCH v5 1/2] net/i40e: get information about protocols defined in ddp profile Thread-Index: AQHTMXA7h0a1rCiu+kS1j9xAXGgC3aLGiSzA Date: Tue, 26 Sep 2017 03:35:05 +0000 Message-ID: <94479800C636CB44BD422CB454846E013203780F@SHSMSX101.ccr.corp.intel.com> References: <1505842335-11462-1-git-send-email-kirill.rybalchenko@intel.com> <1505843612-40976-1-git-send-email-kirill.rybalchenko@intel.com> <1505843612-40976-2-git-send-email-kirill.rybalchenko@intel.com> In-Reply-To: <1505843612-40976-2-git-send-email-kirill.rybalchenko@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 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: Tue, 26 Sep 2017 03:35:11 -0000 > -----Original Message----- > From: Rybalchenko, Kirill > Sent: Wednesday, September 20, 2017 1:54 AM > To: dev@dpdk.org > Cc: Rybalchenko, Kirill ; Chilikin, Andrey > ; Xing, Beilei ; Wu, > Jingjing > Subject: [PATCH v5 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 > --- > v3 > info_size parameter always represents size of the info buffer in bytes >=20 > Signed-off-by: Kirill Rybalchenko > --- > drivers/net/i40e/rte_pmd_i40e.c | 171 > ++++++++++++++++++++++++++++++++++++++++ > drivers/net/i40e/rte_pmd_i40e.h | 25 ++++++ > 2 files changed, 196 insertions(+) >=20 > 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; > } >=20 > +/* 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 =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; 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. > + > + /* 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 * sizeof(struct > rte_pmd_i40e_proto_info)) { > + 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++) { You changed info_size represents the size of the info buffer, then should u= se 'i < nb_rec' instead of ' i < info_size ' in for loop, otherwise there w= ill be unexpected issue. > + 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; Why not adding the condition just after 'nb_rec =3D i40e_get_tlv_section_si= ze(proto);' ? > + /* get number of records in the section */ > + nb_rec =3D 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 sam= e as the last value. > + 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; > + } > + Same comments for get RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST and RTE_PMD_I40E_PK= G_INFO_PTYPE_LIST.