DPDK patches and discussions
 help / color / mirror / Atom feed
From: Zhirun Yan <zhirun.yan@intel.com>
To: dev@dpdk.org, qi.z.zhang@intel.com, xiao.w.wang@intel.com
Cc: yahui.cao@intel.com, junfeng.guo@intel.com, ting.xu@intel.com,
	Zhirun Yan <zhirun.yan@intel.com>
Subject: [dpdk-dev] [PATCH v1] net/ice: support VXLAN VNI field in FDIR
Date: Wed, 24 Mar 2021 16:25:21 +0800	[thread overview]
Message-ID: <20210324082521.3862163-1-zhirun.yan@intel.com> (raw)

Add support for VNI field in FDIR. Treat VXLAN flow type as
ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN to align with shared code. It
allows to match outer L2/L3, VNI and inner L2/L3 fields with VXLAN
pattern.
VNI takes 24 bits in VXLAN header, but uses 32 bits for matching in
shared code. The 8 bits reserved field adjacent should always be 0.

Signed-off-by: Zhirun Yan <zhirun.yan@intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index 3af5812660..91638909c4 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -71,8 +71,8 @@
 	ICE_INSET_SCTP_SRC_PORT | ICE_INSET_SCTP_DST_PORT)
 
 #define ICE_FDIR_INSET_ETH_IPV4_VXLAN (\
-	ICE_FDIR_INSET_ETH | \
-	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST)
+	ICE_FDIR_INSET_ETH | ICE_FDIR_INSET_ETH_IPV4 | \
+	ICE_INSET_TUN_VXLAN_VNI)
 
 #define ICE_FDIR_INSET_IPV4_GTPU (\
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID)
@@ -903,6 +903,7 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_TUN_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT},
 		{ICE_INSET_GTPU_TEID, ICE_FLOW_FIELD_IDX_GTPU_IP_TEID},
 		{ICE_INSET_GTPU_QFI, ICE_FLOW_FIELD_IDX_GTPU_EH_QFI},
+		{ICE_INSET_TUN_VXLAN_VNI, ICE_FLOW_FIELD_IDX_VXLAN_VNI},
 	};
 
 	for (i = 0, j = 0; i < RTE_DIM(ice_inset_map); i++) {
@@ -954,6 +955,12 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg)
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 |
 				  ICE_FLOW_SEG_HDR_IPV_OTHER);
 		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
+				ICE_FLOW_SEG_HDR_IPV4 |
+				ICE_FLOW_SEG_HDR_VXLAN |
+				ICE_FLOW_SEG_HDR_IPV_OTHER);
+		break;
 	case ICE_FLTR_PTYPE_NONF_IPV4_GTPU:
 		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_GTPU_IP |
 				  ICE_FLOW_SEG_HDR_IPV4 |
@@ -1897,13 +1904,14 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			vxlan_mask = item->mask;
 			is_outer = false;
 
-			if (vxlan_spec || vxlan_mask) {
-				rte_flow_error_set(error, EINVAL,
-						   RTE_FLOW_ERROR_TYPE_ITEM,
-						   item,
-						   "Invalid vxlan field");
-				return -rte_errno;
-			}
+			if (!(vxlan_spec && vxlan_mask))
+				break;
+
+			if (vxlan_mask->vni)
+				*input_set |= ICE_INSET_TUN_VXLAN_VNI;
+
+			filter->input.vxlan_data.vni = vxlan_spec->vni[2] << 24 |
+				vxlan_spec->vni[1] << 16 | vxlan_spec->vni[0] << 8;
 
 			break;
 		case RTE_FLOW_ITEM_TYPE_GTPU:
@@ -1965,6 +1973,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 	else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU_EH &&
 		flow_type == ICE_FLTR_PTYPE_NONF_IPV6_UDP)
 		flow_type = ICE_FLTR_PTYPE_NONF_IPV6_GTPU_EH;
+	else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN)
+		flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN;
 
 	filter->tunnel_type = tunnel_type;
 	filter->input.flow_type = flow_type;
-- 
2.25.1


             reply	other threads:[~2021-03-24  8:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24  8:25 Zhirun Yan [this message]
2021-04-01  1:33 ` [dpdk-dev] [PATCH v3] " Zhirun Yan
2021-04-01 12:10   ` 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=20210324082521.3862163-1-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=ting.xu@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).