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 80775D48C for ; Wed, 29 Mar 2017 15:17:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490793441; x=1522329441; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=zucrsGBK2UBXjAbiQrU0cUR8HnfoCRIuh1mlSQ+HNHM=; b=abOp1CK5y4X9Ui5pPRNrLegaN3/XRLplu2j9NoPd2JAWBlGjjzAcmnwG 7t6qQdZK/AiVQLpTxH+GNGDwRui1oA==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2017 06:17:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,241,1486454400"; d="scan'208";a="82281790" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 29 Mar 2017 06:17:20 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Mar 2017 06:17:19 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 29 Mar 2017 06:17:19 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.253]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.42]) with mapi id 14.03.0248.002; Wed, 29 Mar 2017 21:17:18 +0800 From: "Wu, Jingjing" To: "Xing, Beilei" CC: "Zhang, Helin" , "Iremonger, Bernard" , "dev@dpdk.org" Thread-Topic: [PATCH v6 2/6] net/i40e: add dynamic device profile processing Thread-Index: AQHSqIfhUIySg5KRr0278pPrqlH5+aGryYeA Date: Wed, 29 Mar 2017 13:17:18 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810D1A10A@SHSMSX103.ccr.corp.intel.com> References: <1490595475-139869-1-git-send-email-beilei.xing@intel.com> <1490790397-81848-1-git-send-email-beilei.xing@intel.com> <1490790397-81848-3-git-send-email-beilei.xing@intel.com> In-Reply-To: <1490790397-81848-3-git-send-email-beilei.xing@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 v6 2/6] net/i40e: add dynamic device profile processing 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: Wed, 29 Mar 2017 13:17:22 -0000 Looks good to me, only minor comments like below: > -----Original Message----- > From: Xing, Beilei > Sent: Wednesday, March 29, 2017 8:27 PM > To: Wu, Jingjing > Cc: Zhang, Helin ; Iremonger, Bernard > ; dev@dpdk.org > Subject: [PATCH v6 2/6] net/i40e: add dynamic device profile processing >=20 > Add support for adding a dynamic device profile. >=20 > Signed-off-by: Beilei Xing > --- > drivers/net/i40e/i40e_ethdev.c | 199 > ++++++++++++++++++++++++++++++ > drivers/net/i40e/rte_pmd_i40e.h | 58 +++++++++ > drivers/net/i40e/rte_pmd_i40e_version.map | 1 + > 3 files changed, 258 insertions(+) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index 2063603..764764f 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -11708,3 +11708,202 @@ rte_pmd_i40e_set_tc_strict_prio(uint8_t port, > uint8_t tc_map) >=20 > return ret; > } > + > +static void > +i40e_generate_profile_info_sec(char *name, struct i40e_ddp_version *vers= ion, > + uint32_t track_id, uint8_t *profile_info_sec, > + bool add) > +{ > + struct i40e_profile_section_header *sec =3D NULL; > + struct i40e_profile_info *pinfo; > + > + sec =3D (struct i40e_profile_section_header *)profile_info_sec; > + sec->tbl_size =3D 1; > + sec->data_end =3D sizeof(struct i40e_profile_section_header) + > + sizeof(struct i40e_profile_info); > + sec->section.type =3D SECTION_TYPE_INFO; > + sec->section.offset =3D sizeof(struct i40e_profile_section_header); > + sec->section.size =3D sizeof(struct i40e_profile_info); > + pinfo =3D (struct i40e_profile_info *)(profile_info_sec + > + sec->section.offset); > + pinfo->track_id =3D track_id; > + memcpy(pinfo->name, name, I40E_DDP_NAME_SIZE); > + memcpy(&pinfo->version, version, sizeof(struct i40e_ddp_version)); > + if (add) > + pinfo->op =3D I40E_DDP_ADD_TRACKID; > + else > + pinfo->op =3D I40E_DDP_REMOVE_TRACKID; > +} > + > +static enum i40e_status_code > +i40e_add_rm_profile_info(struct i40e_hw *hw, uint8_t *profile_info_sec) > +{ > + enum i40e_status_code status =3D I40E_SUCCESS; > + struct i40e_profile_section_header *sec; > + uint32_t track_id; > + uint32_t offset =3D 0, info =3D 0; Cannot set more than one vars in one line according to the coding style. uint32_t offset =3D 0; uint32_t info =3D 0; > +/* Check if the profile info exists */ > +static int > +i40e_check_profile_info(uint8_t port, uint8_t *profile_info_sec) { > + struct rte_eth_dev *dev =3D &rte_eth_devices[port]; > + struct i40e_hw *hw =3D I40E_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > + uint8_t *buff; > + struct rte_pmd_i40e_profile_list *p_list; > + struct rte_pmd_i40e_profile_info *pinfo, *p; > + uint32_t i; > + int ret; > + > + buff =3D rte_zmalloc("pinfo_list", > + (I40E_PROFILE_INFO_SIZE * > I40E_MAX_PROFILE_NUM + 4), > + 0); > + if (!buff) { > + PMD_DRV_LOG(ERR, "failed to allocate memory"); > + return -1; > + } > + > + ret =3D i40e_aq_get_ddp_list(hw, (void *)buff, > + (I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4), > + 0, NULL); > + if (ret) { > + PMD_DRV_LOG(ERR, "Failed to get profile info list."); > + rte_free(buff); > + return -1; > + } > + p_list =3D (struct rte_pmd_i40e_profile_list *)buff; > + pinfo =3D (struct rte_pmd_i40e_profile_info *)(profile_info_sec + > + sizeof(struct i40e_profile_section_header)); > + for (i =3D 0; i < p_list->p_count; i++) { > + p =3D &p_list->p_info[i]; > + if ((pinfo->track_id =3D=3D p->track_id) && > + !memcmp(&pinfo->version, &p->version, > + sizeof(struct i40e_ddp_version)) && > + !memcmp(&pinfo->name, &p->name, > + I40E_DDP_NAME_SIZE)) { > + PMD_DRV_LOG(INFO, "Profile exists."); > + rte_free(buff); > + return 1; > + } > + } > + > + rte_free(buff); > + return 0; > +} > + > +int > +rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff, > + uint32_t size, > + enum rte_pmd_i40e_package_op op) > +{ > + struct rte_eth_dev *dev; > + struct i40e_hw *hw; > + struct i40e_package_header *pkg_hdr; > + struct i40e_generic_seg_header *profile_seg_hdr; > + struct i40e_generic_seg_header *metadata_seg_hdr; > + uint32_t track_id; > + uint8_t *profile_info_sec; > + int is_exist; > + enum i40e_status_code status =3D I40E_SUCCESS; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); > + > + dev =3D &rte_eth_devices[port]; > + > + if (!is_device_supported(dev, &rte_i40e_pmd)) > + return -ENOTSUP; > + > + hw =3D I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + > + if (size < (sizeof(struct i40e_package_header) + > + sizeof(struct i40e_metadata_segment) + > + sizeof(uint32_t) * 2)) { > + PMD_DRV_LOG(ERR, "Buff is invalid."); > + return -EINVAL; > + } > + > + pkg_hdr =3D (struct i40e_package_header *)buff; > + > + if (!pkg_hdr) { > + PMD_DRV_LOG(ERR, "Failed to fill the package structure"); > + return -EINVAL; > + } > + > + if (pkg_hdr->segment_count < 2) { > + PMD_DRV_LOG(ERR, "Segment_count should be 2 at least."); > + return -EINVAL; > + } > + > + /* Find metadata segment */ > + metadata_seg_hdr =3D > i40e_find_segment_in_package(SEGMENT_TYPE_METADATA, > + pkg_hdr); > + if (!metadata_seg_hdr) { > + PMD_DRV_LOG(ERR, "Failed to find metadata segment > header"); > + return -EINVAL; > + } > + track_id =3D ((struct i40e_metadata_segment > +*)metadata_seg_hdr)->track_id; > + > + /* Find profile segment */ > + profile_seg_hdr =3D i40e_find_segment_in_package(SEGMENT_TYPE_I40E, > + pkg_hdr); > + if (!profile_seg_hdr) { > + PMD_DRV_LOG(ERR, "Failed to find profile segment header"); > + return -EINVAL; > + } > + > + profile_info_sec =3D rte_zmalloc("i40e_profile_info", > + sizeof(struct i40e_profile_section_header) + > + sizeof(struct i40e_profile_info), > + 0); > + if (!profile_info_sec) { > + PMD_DRV_LOG(ERR, "Failed to allocate memory"); > + return -EINVAL; > + } > + > + if (op =3D=3D RTE_PMD_I40E_PKG_OP_WR_ADD) { > + /* Check if the profile exists */ > + i40e_generate_profile_info_sec( > + ((struct i40e_profile_segment *)profile_seg_hdr)->name, > + &((struct i40e_profile_segment *)profile_seg_hdr)->version, > + track_id, profile_info_sec, 1); > + is_exist =3D i40e_check_profile_info(port, profile_info_sec); > + if (is_exist) { The i40e_check_profile_info also has a return value like "-1". It doesn't mean profile exists, right? > + PMD_DRV_LOG(ERR, "Profile already exists."); > + rte_free(profile_info_sec); > + return 1; > + } > + > + /* Write profile to HW */ > + status =3D i40e_write_profile(hw, > + (struct i40e_profile_segment *)profile_seg_hdr, > + track_id); > + if (status) > + PMD_DRV_LOG(ERR, "Failed to write profile."); > + > + /* Add profile info to info list */ > + status =3D i40e_add_rm_profile_info(hw, profile_info_sec); If i40e_write_profile failed, do we still need to add profile info?