DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ting Xu <ting.xu@intel.com>
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
Subject: [dpdk-dev] [RFC PATCH 3/3] net/ice: enable buildin recipe 10 for custom DDP package
Date: Sat,  6 Jun 2020 13:50:58 +0000	[thread overview]
Message-ID: <20200606135058.112697-4-ting.xu@intel.com> (raw)
In-Reply-To: <20200606135058.112697-1-ting.xu@intel.com>

From: Qi Zhang <qi.z.zhang@intel.com>

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 <qi.z.zhang@intel.com>
---
 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>");
-- 
2.17.1


      parent reply	other threads:[~2020-06-06  5:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-06 13:50 [dpdk-dev] [RFC PATCH 0/3] enable multiple DCF and buildin recipe Ting Xu
2020-06-06 13:50 ` [dpdk-dev] [RFC PATCH 1/3] drivers: add flow flush for DCF Ting Xu
2020-06-06 13:50 ` [dpdk-dev] [RFC PATCH 2/3] drivers/net: support multiple DCF instance Ting Xu
2020-06-06 13:50 ` Ting Xu [this message]

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=20200606135058.112697-4-ting.xu@intel.com \
    --to=ting.xu@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=john.mcnamara@intel.com \
    --cc=marko.kovacevic@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@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).