From patchwork Fri Mar 3 07:26:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xing, Beilei" X-Patchwork-Id: 21234 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id ACD23F962; Fri, 3 Mar 2017 08:28:07 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id DAE4C2B93 for ; Fri, 3 Mar 2017 08:27:33 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2017 23:27:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,235,1484035200"; d="scan'208";a="830442006" Received: from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31]) by FMSMGA003.fm.intel.com with ESMTP; 02 Mar 2017 23:27:32 -0800 From: Beilei Xing To: jingjing.wu@intel.com Cc: helin.zhang@intel.com, dev@dpdk.org Date: Fri, 3 Mar 2017 15:26:14 +0800 Message-Id: <1488525977-15321-10-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1488525977-15321-1-git-send-email-beilei.xing@intel.com> References: <1488525977-15321-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH 3/6] net/i40e: add ppp 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add loading profile function. Signed-off-by: Beilei Xing --- drivers/net/i40e/i40e_ethdev.c | 59 +++++++++++++++++++++++++++++++++++++++++ drivers/net/i40e/rte_pmd_i40e.h | 7 +++++ 2 files changed, 66 insertions(+) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index ca4a87d..dae4b97 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11456,3 +11456,62 @@ i40e_add_pinfo_to_list(struct i40e_hw *hw, return status; } + +int +i40e_process_package(uint8_t port, uint8_t *buff) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port]; + struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + 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; + enum i40e_status_code status; + + pkg_hdr = (struct i40e_package_header *)buff; + + if (!pkg_hdr) { + PMD_DRV_LOG(ERR, "Failed to fill the package structure"); + return -EINVAL; + } + + /* Find metadata segment */ + metadata_seg_hdr = 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 = ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id; + + /* Find profile segment */ + profile_seg_hdr = 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; + } + + /* Write profile to HW */ + status = i40e_write_profile(hw, + (struct i40e_profile_segment *)profile_seg_hdr, + track_id); + if (!status) + printf("Write profile successfully.\n"); + + /* Add the profile info to the list of loaded profiles */ + profile_info_sec = rte_zmalloc("i40e_profile_info", + sizeof(struct i40e_profile_section_header) + + sizeof(struct i40e_profile_info), + 0); + status = i40e_add_pinfo_to_list(hw, + (struct i40e_profile_segment *)profile_seg_hdr, + profile_info_sec, track_id); + if (!status) + printf("Add profile info successfully.\n"); + + rte_free(profile_info_sec); + + return status; +} diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h index a0ad88c..7bd444c 100644 --- a/drivers/net/i40e/rte_pmd_i40e.h +++ b/drivers/net/i40e/rte_pmd_i40e.h @@ -332,4 +332,11 @@ int rte_pmd_i40e_get_vf_stats(uint8_t port, int rte_pmd_i40e_reset_vf_stats(uint8_t port, uint16_t vf_id); +/** + * i40e_process_package - Load package + * @port: port id + * @buff: buffer of package + **/ +int i40e_process_package(uint8_t port, uint8_t *buff); + #endif /* _PMD_I40E_H_ */