From patchwork Tue Jun 27 08:18:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chilikin, Andrey" X-Patchwork-Id: 25764 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 7BC252BE1; Tue, 27 Jun 2017 10:18:20 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id AB01D2C8 for ; Tue, 27 Jun 2017 10:18:18 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2017 01:18:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,399,1493708400"; d="scan'208";a="117852349" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 27 Jun 2017 01:18:16 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id v5R8IFhw016118; Tue, 27 Jun 2017 09:18:15 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id v5R8IFG5017355; Tue, 27 Jun 2017 09:18:15 +0100 Received: (from achiliki@localhost) by sivswdev01.ir.intel.com with LOCAL id v5R8IF79017351; Tue, 27 Jun 2017 09:18:15 +0100 From: Andrey Chilikin To: dev@dpdk.org Cc: beilei.xing@intel.com, jingjing.wu@intel.com, Andrey Chilikin Date: Tue, 27 Jun 2017 09:18:11 +0100 Message-Id: <1498551492-17214-2-git-send-email-andrey.chilikin@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1498551492-17214-1-git-send-email-andrey.chilikin@intel.com> References: <1498551492-17214-1-git-send-email-andrey.chilikin@intel.com> In-Reply-To: <1495901077-11845-1-git-send-email-andrey.chilikin@intel.com> References: <1495901077-11845-1-git-send-email-andrey.chilikin@intel.com> Subject: [dpdk-dev] [PATCH v2 1/2] net/i40e: extended list of operations for ddp 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" This patch adds ability to remove already loaded profile or write profile without registering it Signed-off-by: Andrey Chilikin --- drivers/net/i40e/rte_pmd_i40e.c | 87 +++++++++++++++++++++++++++++------------ drivers/net/i40e/rte_pmd_i40e.h | 6 ++- 2 files changed, 66 insertions(+), 27 deletions(-) diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c index f7ce62b..e292903 100644 --- a/drivers/net/i40e/rte_pmd_i40e.c +++ b/drivers/net/i40e/rte_pmd_i40e.c @@ -1557,11 +1557,7 @@ i40e_check_profile_info(uint8_t port, uint8_t *profile_info_sec) sizeof(struct i40e_profile_section_header)); for (i = 0; i < p_list->p_count; i++) { p = &p_list->p_info[i]; - if ((pinfo->track_id == p->track_id) && - !memcmp(&pinfo->version, &p->version, - sizeof(struct i40e_ddp_version)) && - !memcmp(&pinfo->name, &p->name, - I40E_DDP_NAME_SIZE)) { + if (pinfo->track_id == p->track_id) { PMD_DRV_LOG(INFO, "Profile exists."); rte_free(buff); return 1; @@ -1587,6 +1583,13 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff, int is_exist; enum i40e_status_code status = I40E_SUCCESS; + if (op != RTE_PMD_I40E_PKG_OP_WR_ADD && + op != RTE_PMD_I40E_PKG_OP_WR_ONLY && + op != RTE_PMD_I40E_PKG_OP_WR_DEL) { + PMD_DRV_LOG(ERR, "Operation not supported."); + return -ENOTSUP; + } + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); dev = &rte_eth_devices[port]; @@ -1623,6 +1626,10 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff, return -EINVAL; } track_id = ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id; + if (track_id == I40E_DDP_TRACKID_INVALID) { + PMD_DRV_LOG(ERR, "Invalid track_id"); + return -EINVAL; + } /* Find profile segment */ profile_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_I40E, @@ -1642,40 +1649,68 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff, return -EINVAL; } + /* Check if the profile already loaded */ + 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, + op == RTE_PMD_I40E_PKG_OP_WR_ADD); + is_exist = i40e_check_profile_info(port, profile_info_sec); + if (is_exist < 0) { + PMD_DRV_LOG(ERR, "Failed to check profile."); + rte_free(profile_info_sec); + return -EINVAL; + } + if (op == 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 = i40e_check_profile_info(port, profile_info_sec); - if (is_exist > 0) { + if (is_exist) { PMD_DRV_LOG(ERR, "Profile already exists."); rte_free(profile_info_sec); - return 1; - } else if (is_exist < 0) { - PMD_DRV_LOG(ERR, "Failed to check profile."); + return -EEXIST; + } + } else if (op == RTE_PMD_I40E_PKG_OP_WR_DEL) { + if (!is_exist) { + PMD_DRV_LOG(ERR, "Profile does not exist."); rte_free(profile_info_sec); - return -EINVAL; + return -EACCES; } + } - /* Write profile to HW */ + if (op == RTE_PMD_I40E_PKG_OP_WR_DEL) { + status = i40e_rollback_profile( + hw, + (struct i40e_profile_segment *)profile_seg_hdr, + track_id); + if (status) { + PMD_DRV_LOG(ERR, "Failed to write profile for delete."); + rte_free(profile_info_sec); + return status; + } + } + else { status = i40e_write_profile( - hw, - (struct i40e_profile_segment *)profile_seg_hdr, - track_id); + hw, + (struct i40e_profile_segment *)profile_seg_hdr, + track_id); if (status) { - PMD_DRV_LOG(ERR, "Failed to write profile."); + if (op == RTE_PMD_I40E_PKG_OP_WR_ADD) + PMD_DRV_LOG(ERR, "Failed to write profile for add."); + else + PMD_DRV_LOG(ERR, "Failed to write profile."); rte_free(profile_info_sec); return status; } + } - /* Add profile info to info list */ + if (track_id && (op != RTE_PMD_I40E_PKG_OP_WR_ONLY)) { + /* Modify loaded profiles info list */ status = i40e_add_rm_profile_info(hw, profile_info_sec); - if (status) - PMD_DRV_LOG(ERR, "Failed to add profile info."); - } else { - PMD_DRV_LOG(ERR, "Operation not supported."); + if (status) { + if (op == RTE_PMD_I40E_PKG_OP_WR_ADD) + PMD_DRV_LOG(ERR, "Failed to add profile to info list."); + else + PMD_DRV_LOG(ERR, "Failed to delete profile from info list."); + } } rte_free(profile_info_sec); diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h index cbe742e..09b2ace 100644 --- a/drivers/net/i40e/rte_pmd_i40e.h +++ b/drivers/net/i40e/rte_pmd_i40e.h @@ -71,6 +71,8 @@ struct rte_pmd_i40e_mb_event_param { enum rte_pmd_i40e_package_op { RTE_PMD_I40E_PKG_OP_UNDEFINED = 0, RTE_PMD_I40E_PKG_OP_WR_ADD, /**< load package and add to info list */ + RTE_PMD_I40E_PKG_OP_WR_DEL, /** load package and delete from info list */ + RTE_PMD_I40E_PKG_OP_WR_ONLY, /**< load package without modifying info list */ RTE_PMD_I40E_PKG_OP_MAX = 32 }; @@ -492,7 +494,9 @@ int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map); * - (0) if successful. * - (-ENODEV) if *port* invalid. * - (-EINVAL) if bad parameter. - * - (1) if profile exists. + * - (-EEXIST) if profile exists. + * - (-EACCES) if profile does not exist. + * - (-ENOTSUP) if operation not supported. */ int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff, uint32_t size,