From patchwork Sat Jun 6 13:50:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xu, Ting" X-Patchwork-Id: 70920 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6A7B4A0350; Sat, 6 Jun 2020 07:52:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 47C1F1D55E; Sat, 6 Jun 2020 07:51:59 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 03B3C1D533 for ; Sat, 6 Jun 2020 07:51:57 +0200 (CEST) IronPort-SDR: 3kn5VtfBdCDcZfjD91vtwo1C8NDwbT0C/3NRW11AorCXP9wXkA5Ov59/x9DK5hqsR8sPckpW6y +un4ZTrcIN7g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2020 22:51:57 -0700 IronPort-SDR: kgDbotmYb3loEq48zjtG1jmLgPECNnvCjwEYnhJaPwYn5HIOgbFk8Z7k8YEqOb6VTTUs3aAj6d Xxha0IjcO+LQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,479,1583222400"; d="scan'208";a="446140832" Received: from dpdk-xuting-main.sh.intel.com ([10.67.117.84]) by orsmga005.jf.intel.com with ESMTP; 05 Jun 2020 22:51:55 -0700 From: Ting Xu To: dev@dpdk.org Cc: qi.z.zhang@intel.com, qiming.yang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com, marko.kovacevic@intel.com, john.mcnamara@intel.com Date: Sat, 6 Jun 2020 13:50:58 +0000 Message-Id: <20200606135058.112697-4-ting.xu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200606135058.112697-1-ting.xu@intel.com> References: <20200606135058.112697-1-ting.xu@intel.com> Subject: [dpdk-dev] [RFC PATCH 3/3] net/ice: enable buildin recipe 10 for custom DDP package 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" From: Qi Zhang Enable buildin recipe to accelerate DCF start and specific flow rules creating speed with custom DDP package. Use dev_args "br=1" to turn on buildin recipe. Signed-off-by: Qi Zhang --- doc/guides/nics/ice.rst | 3 ++ drivers/net/ice/base/ice_common.c | 25 ++++++++++++++ drivers/net/ice/base/ice_switch.c | 55 +++++++++++++++++++++++++++++-- drivers/net/ice/base/ice_type.h | 2 ++ drivers/net/ice/ice_dcf_ethdev.c | 38 ++++++++++++++++++--- 5 files changed, 117 insertions(+), 6 deletions(-) diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst index 26f02f6bc..c517ef195 100644 --- a/doc/guides/nics/ice.rst +++ b/doc/guides/nics/ice.rst @@ -275,6 +275,9 @@ is required to support multiple instances co-exist. When two DPDK DCF instances are probed, the later one will take over the DCF capability from the first one. This is hinted by devargs "cap=mdcf". +To accelerate the creation of specific flow, a buildin recipe for custom DDP +package is added. Enable this by running testpmd with devargs 'br=1'. + Sample Application Notes ------------------------ diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c index 17ffdee00..406d4ed36 100644 --- a/drivers/net/ice/base/ice_common.c +++ b/drivers/net/ice/base/ice_common.c @@ -459,6 +459,28 @@ ice_aq_set_mac_cfg(struct ice_hw *hw, u16 max_frame_size, struct ice_sq_cd *cd) return ice_aq_send_cmd(hw, &desc, NULL, 0, cd); } +static int ice_buildin_recipe_init(struct ice_hw *hw) +{ + struct ice_switch_info *sw = hw->switch_info; + struct ice_sw_recipe *recipe; + + sw->buildin_recipes = ice_malloc(hw, + sizeof(sw->buildin_recipes[0]) * ICE_MAX_NUM_RECIPES); + + if (!sw->buildin_recipes) + return ICE_ERR_NO_MEMORY; + + recipe = &sw->buildin_recipes[10]; + recipe->is_root = 1; + + recipe->lkup_exts.n_val_words = 1; + recipe->lkup_exts.field_mask[0] = 0x00ff; + recipe->lkup_exts.fv_words[0].off = 8; + recipe->lkup_exts.fv_words[0].prot_id = 32; + + return ICE_SUCCESS; +} + /** * ice_init_fltr_mgmt_struct - initializes filter management list and locks * @hw: pointer to the HW struct @@ -477,6 +499,8 @@ enum ice_status ice_init_fltr_mgmt_struct(struct ice_hw *hw) INIT_LIST_HEAD(&sw->vsi_list_map_head); + ice_buildin_recipe_init(hw); + return ice_init_def_sw_recp(hw, &hw->switch_info->recp_list); } @@ -538,6 +562,7 @@ void ice_cleanup_fltr_mgmt_struct(struct ice_hw *hw) ice_free(hw, recps[i].root_buf); } ice_rm_all_sw_replay_rule_info(hw); + ice_free(hw, sw->buildin_recipes); ice_free(hw, sw->recp_list); ice_free(hw, sw); } diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 5b968b7ce..463edefb9 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -5220,6 +5220,48 @@ static const struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = { { ICE_NAT_T, ICE_UDP_ILOS_HW }, }; + +static u16 buildin_recipe_get(struct ice_switch_info *sw, + struct ice_prot_lkup_ext *lkup_exts) +{ + int i; + + if (!sw->buildin_recipes) + return ICE_MAX_NUM_RECIPES; + + for (i = 10; i < ICE_MAX_NUM_RECIPES; i++) { + struct ice_sw_recipe *recp = &sw->buildin_recipes[i]; + struct ice_fv_word *a = lkup_exts->fv_words; + struct ice_fv_word *b = recp->lkup_exts.fv_words; + u16 *c = recp->lkup_exts.field_mask; + u16 *d = lkup_exts->field_mask; + bool found = true; + u8 p, q; + + if (!recp->is_root) + continue; + + if (recp->lkup_exts.n_val_words != lkup_exts->n_val_words) + continue; + + for (p = 0; p < lkup_exts->n_val_words; p++) { + for (q = 0; q < recp->lkup_exts.n_val_words; q++) { + if (a[p].off == b[q].off && + a[p].prot_id == b[q].prot_id && + d[p] == c[q]) + break; + } + if (q >= recp->lkup_exts.n_val_words) { + found = false; + break; + } + } + if (found) + return i; + } + return ICE_MAX_NUM_RECIPES; +} + /** * ice_find_recp - find a recipe * @hw: pointer to the hardware structure @@ -5232,8 +5274,15 @@ static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts, { bool refresh_required = true; struct ice_sw_recipe *recp; + u16 buildin_rid; u8 i; + if (hw->use_buildin_recipe) { + buildin_rid = buildin_recipe_get(hw->switch_info, lkup_exts); + if (buildin_rid < ICE_MAX_NUM_RECIPES) + return buildin_rid; + } + /* Walk through existing recipes to find a match */ recp = hw->switch_info->recp_list; for (i = 0; i < ICE_MAX_NUM_RECIPES; i++) { @@ -7296,8 +7345,10 @@ ice_rem_adv_rule_by_id(struct ice_hw *hw, struct ice_switch_info *sw; sw = hw->switch_info; - if (!sw->recp_list[remove_entry->rid].recp_created) - return ICE_ERR_PARAM; + + if (!sw->buildin_recipes[remove_entry->rid].is_root) + if (!sw->recp_list[remove_entry->rid].recp_created) + return ICE_ERR_PARAM; list_head = &sw->recp_list[remove_entry->rid].filt_rules; LIST_FOR_EACH_ENTRY(list_itr, list_head, ice_adv_fltr_mgmt_list_entry, list_entry) { diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h index 94ea44265..8a131024a 100644 --- a/drivers/net/ice/base/ice_type.h +++ b/drivers/net/ice/base/ice_type.h @@ -769,6 +769,7 @@ struct ice_switch_info { u16 prof_res_bm_init; ice_declare_bitmap(prof_res_bm[ICE_MAX_NUM_PROFILES], ICE_MAX_FV_WORDS); + struct ice_sw_recipe *buildin_recipes; }; /* Port hardware description */ @@ -914,6 +915,7 @@ struct ice_hw { ice_declare_bitmap(fdir_perfect_fltr, ICE_FLTR_PTYPE_MAX); struct ice_lock rss_locks; /* protect RSS configuration */ struct LIST_HEAD_TYPE rss_list_head; + u8 use_buildin_recipe; }; /* Statistics collected by each port, VSI, VEB, and S-channel */ diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index 0ec9bd5c1..89433f39a 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -897,12 +897,34 @@ ice_dcf_cap_check_handler(__rte_unused const char *key, return -1; } +static int +parse_bool(const char *key, const char *value, void *args) +{ + int *i = (int *)args; + char *end; + int num; + + num = strtoul(value, &end, 10); + + if (num != 0 && num != 1) { + PMD_DRV_LOG(WARNING, "invalid value:\"%s\" for key:\"%s\", " + "value must be 0 or 1", + value, key); + return -1; + } + + *i = num; + return 0; +} + static int ice_dcf_cap_selected(struct ice_dcf_adapter *adapter, struct rte_devargs *devargs) { + struct ice_adapter *ad = &adapter->parent; struct rte_kvargs *kvlist; - const char *key = "cap"; + const char *key_cap = "cap"; + const char *key_br = "br"; int ret = 0; if (devargs == NULL) @@ -912,15 +934,21 @@ ice_dcf_cap_selected(struct ice_dcf_adapter *adapter, if (kvlist == NULL) return 0; - if (!rte_kvargs_count(kvlist, key)) + if (!rte_kvargs_count(kvlist, key_cap)) goto exit; /* dcf capability selected when there's a key-value pair: cap=dcf */ - if (rte_kvargs_process(kvlist, key, + if (rte_kvargs_process(kvlist, key_cap, ice_dcf_cap_check_handler, &adapter->real_hw.multi_inst) < 0) goto exit; + /* dcf capability selected when there's a key-value pair: cap=dcf */ + if (rte_kvargs_process(kvlist, key_br, + &parse_bool, + &ad->hw.use_buildin_recipe) < 0) + goto exit; + ret = 1; exit: @@ -997,4 +1025,6 @@ static struct rte_pci_driver rte_ice_dcf_pmd = { RTE_PMD_REGISTER_PCI(net_ice_dcf, rte_ice_dcf_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_ice_dcf, pci_id_ice_dcf_map); RTE_PMD_REGISTER_KMOD_DEP(net_ice_dcf, "* igb_uio | vfio-pci"); -RTE_PMD_REGISTER_PARAM_STRING(net_ice_dcf, "cap=dcf|mdcf"); +RTE_PMD_REGISTER_PARAM_STRING(net_ice_dcf, + "cap=dcf|mdcf " + "br=<1|0>");