From: "Xing, Beilei" <beilei.xing@intel.com>
To: "Rybalchenko, Kirill" <kirill.rybalchenko@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>
Cc: "Chilikin, Andrey" <andrey.chilikin@intel.com>,
"Wu, Jingjing" <jingjing.wu@intel.com>
Subject: Re: [dpdk-dev] [PATCH v6 1/2] net/i40e: get information about protocols defined in ddp profile
Date: Fri, 29 Sep 2017 07:30:36 +0000 [thread overview]
Message-ID: <94479800C636CB44BD422CB454846E0132038CC5@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <1506605599-31693-2-git-send-email-kirill.rybalchenko@intel.com>
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.
next prev parent reply other threads:[~2017-09-29 7:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4075836-102681-1-git-send-email-kirill.rybalchenko@intel.com>
2017-09-01 16:01 ` [dpdk-dev] [PATCH v2 0/2] " 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=94479800C636CB44BD422CB454846E0132038CC5@SHSMSX101.ccr.corp.intel.com \
--to=beilei.xing@intel.com \
--cc=andrey.chilikin@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
--cc=kirill.rybalchenko@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).