DPDK patches and discussions
 help / color / mirror / Atom feed
From: Zhirun Yan <zhirun.yan@intel.com>
To: qi.z.zhang@intel.com, dev@dpdk.org
Cc: yahui.cao@intel.com, xiao.w.wang@intel.com, simei.su@intel.com,
	junfeng.guo@intel.com, Zhirun Yan <zhirun.yan@intel.com>
Subject: [dpdk-dev] [PATCH v1 2/2] net/ice: merge inner/outer flow seg info for FDIR
Date: Tue,  8 Sep 2020 15:39:39 +0800	[thread overview]
Message-ID: <20200908073939.4099976-3-zhirun.yan@intel.com> (raw)
In-Reply-To: <20200908073939.4099976-1-zhirun.yan@intel.com>

For tunnel and non-tunnel packets, it can share the same seg_tun info.
seg_tun[1] can be used for supporting inner fields with tunnel flow rule
or for non-tunnel packets, seg_tun[0] only used for tunnel outer part.
Add outer_input_set to distinguish inner/outer input set. So we can
identify different fields in outer or inner part.

Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
---
 drivers/net/ice/ice_ethdev.h      |  1 +
 drivers/net/ice/ice_fdir_filter.c | 65 +++++++++++++++++--------------
 2 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index 393dfeab1..6bc6dfbfb 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -285,6 +285,7 @@ struct ice_fdir_filter_conf {
 	struct rte_flow_action_count act_count;
 
 	uint64_t input_set;
+	uint64_t outer_input_set; /* only for tunnel packets outer fields */
 };
 
 #define ICE_MAX_FDIR_FILTER_NUM		(1024 * 16)
diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 593dfd0e2..24fbcdd60 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -1047,51 +1047,59 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg,
 
 static int
 ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
-			uint64_t input_set, enum ice_fdir_tunnel_type ttype)
+			uint64_t inner_input_set, uint64_t outer_input_set,
+			enum ice_fdir_tunnel_type ttype)
 {
 	struct ice_flow_seg_info *seg;
 	struct ice_flow_seg_info *seg_tun = NULL;
 	enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX];
+	uint64_t input_set;
 	bool is_tunnel;
-	int i, ret;
+	int k, i, ret = 0;
 
-	if (!input_set)
+	if (!(inner_input_set | outer_input_set))
 		return -EINVAL;
 
-	seg = (struct ice_flow_seg_info *)
-		ice_malloc(hw, sizeof(*seg));
-	if (!seg) {
+	seg_tun = (struct ice_flow_seg_info *)
+		ice_malloc(hw, sizeof(*seg_tun) * ICE_FD_HW_SEG_MAX);
+	if (!seg_tun) {
 		PMD_DRV_LOG(ERR, "No memory can be allocated");
 		return -ENOMEM;
 	}
 
-	for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++)
-		field[i] = ICE_FLOW_FIELD_IDX_MAX;
+	/* use seg_tun[1] to record tunnel inner part or non-tunnel */
+	for (k = ICE_FD_HW_SEG_TUN; k >= 0; k--) {
+		seg = &seg_tun[k];
+		if (k == ICE_FD_HW_SEG_TUN) {
+			if (inner_input_set == 0)
+				continue;
+			input_set = inner_input_set;
+		} else {
+			if (outer_input_set == 0)
+				break;
+			input_set = outer_input_set;
+		}
+
+		for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++)
+			field[i] = ICE_FLOW_FIELD_IDX_MAX;
 
-	ice_fdir_input_set_parse(input_set, field);
+		ice_fdir_input_set_parse(input_set, field);
 
-	ice_fdir_input_set_hdrs(flow, seg, ttype);
+		ice_fdir_input_set_hdrs(flow, seg, ttype);
 
-	for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) {
-		ice_flow_set_fld(seg, field[i],
-				 ICE_FLOW_FLD_OFF_INVAL,
-				 ICE_FLOW_FLD_OFF_INVAL,
-				 ICE_FLOW_FLD_OFF_INVAL, false);
+		for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) {
+			ice_flow_set_fld(seg, field[i],
+					 ICE_FLOW_FLD_OFF_INVAL,
+					 ICE_FLOW_FLD_OFF_INVAL,
+					 ICE_FLOW_FLD_OFF_INVAL, false);
+		}
 	}
 
 	is_tunnel = ice_fdir_is_tunnel_profile(ttype);
 	if (!is_tunnel) {
 		ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
-					   seg, flow, false);
+					   seg_tun + 1, flow, false);
 	} else {
-		seg_tun = (struct ice_flow_seg_info *)
-			ice_malloc(hw, sizeof(*seg) * ICE_FD_HW_SEG_MAX);
-		if (!seg_tun) {
-			PMD_DRV_LOG(ERR, "No memory can be allocated");
-			rte_free(seg);
-			return -ENOMEM;
-		}
-		rte_memcpy(&seg_tun[1], seg, sizeof(*seg));
 		ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
 					   seg_tun, flow, true);
 	}
@@ -1099,9 +1107,7 @@ ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
 	if (!ret) {
 		return ret;
 	} else if (ret < 0) {
-		rte_free(seg);
-		if (is_tunnel)
-			rte_free(seg_tun);
+		rte_free(seg_tun);
 		return (ret == -EEXIST) ? 0 : ret;
 	} else {
 		return ret;
@@ -1311,7 +1317,8 @@ ice_fdir_create_filter(struct ice_adapter *ad,
 	is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
 
 	ret = ice_fdir_input_set_conf(pf, filter->input.flow_type,
-			filter->input_set, filter->tunnel_type);
+				      filter->input_set, filter->outer_input_set,
+				      filter->tunnel_type);
 	if (ret) {
 		rte_flow_error_set(error, -ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -2106,7 +2113,7 @@ ice_fdir_parse(struct ice_adapter *ad,
 	ret = ice_fdir_parse_pattern(ad, pattern, error, filter);
 	if (ret)
 		goto error;
-	input_set = filter->input_set;
+	input_set = filter->input_set | filter->outer_input_set;
 	if (!input_set || input_set & ~item->input_set_mask) {
 		rte_flow_error_set(error, EINVAL,
 				   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
-- 
2.25.1


  parent reply	other threads:[~2020-09-08  7:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  7:39 [dpdk-dev] [PATCH v1 0/2] refactor and clean FDIR Zhirun Yan
2020-09-08  7:39 ` [dpdk-dev] [PATCH v1 1/2] net/ice: refactor FDIR set conf function Zhirun Yan
2020-09-08  7:39 ` Zhirun Yan [this message]
2020-09-11  5:53   ` [dpdk-dev] [PATCH v1 2/2] net/ice: merge inner/outer flow seg info for FDIR Zhang, Qi Z
2020-09-14  3:05 ` [dpdk-dev] [PATCH v1 0/2] refactor and clean FDIR Zhirun Yan
2020-09-14  3:05   ` [dpdk-dev] [PATCH v2 1/2] net/ice: refactor FDIR set conf function Zhirun Yan
2020-09-14 10:54     ` Ferruh Yigit
2020-09-15  5:30       ` Yan, Zhirun
2020-09-14  3:05   ` [dpdk-dev] [PATCH v2 2/2] net/ice: merge inner/outer flow seg info for FDIR Zhirun Yan
2020-09-14  5:23   ` [dpdk-dev] [PATCH v1 0/2] refactor and clean FDIR Zhang, Qi Z
2020-09-15  5:27 ` [dpdk-dev] [PATCH v3 " Zhirun Yan
2020-09-15  5:27   ` [dpdk-dev] [PATCH v3 1/2] net/ice: refactor FDIR set conf function Zhirun Yan
2020-09-18  9:28     ` Cao, Yahui
2020-09-15  5:27   ` [dpdk-dev] [PATCH v3 2/2] net/ice: merge inner/outer flow seg info for FDIR Zhirun Yan
2020-09-18  9:30     ` Cao, Yahui
2020-09-15  5:38   ` [dpdk-dev] [PATCH v3 0/2] refactor and clean FDIR Zhang, Qi Z

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=20200908073939.4099976-3-zhirun.yan@intel.com \
    --to=zhirun.yan@intel.com \
    --cc=dev@dpdk.org \
    --cc=junfeng.guo@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=simei.su@intel.com \
    --cc=xiao.w.wang@intel.com \
    --cc=yahui.cao@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).