From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 87B3127D for ; Mon, 11 Sep 2017 17:32:18 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2017 08:32:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,378,1500966000"; d="scan'208";a="899147381" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.57]) ([10.237.220.57]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2017 08:32:16 -0700 To: Kirill Rybalchenko , dev@dpdk.org Cc: andrey.chilikin@intel.com, beilei.xing@intel.com, jingjing.wu@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> From: Ferruh Yigit Message-ID: <53af3906-009a-474c-e191-3f8dc52b080a@intel.com> Date: Mon, 11 Sep 2017 16:32:15 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1504281685-54502-2-git-send-email-kirill.rybalchenko@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit 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, 11 Sep 2017 15:32:19 -0000 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 <...> > +/* 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. >