[dpdk-dev] [dpdk-dev 12/12] net/ice: add FDIR non-word aligned field support

Yahui Cao yahui.cao at intel.com
Fri Sep 6 14:00:58 CEST 2019


Add IPV4 TOS, TTL and Protocol fields support.
Add IPV6 version of TOS, TTL and Protocol fields support.

Signed-off-by: Yahui Cao <yahui.cao at intel.com>
---
 drivers/net/ice/ice_fdir_filter.c | 41 +++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index b226ea6d2..18e0f5d48 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -9,6 +9,9 @@
 #include "ice_rxtx.h"
 #include "ice_generic_flow.h"
 
+#define ICE_FDIR_IPV6_TC_OFFSET		20
+#define ICE_IPV6_TC_MASK		(0xFF << ICE_FDIR_IPV6_TC_OFFSET)
+
 #define ICE_FDIR_INSET_ETH_IPV4 (\
 	ICE_INSET_DMAC | \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_IPV4_TOS | \
@@ -572,8 +575,14 @@ ice_parse_input_set(uint64_t inset, enum ice_flow_field *field)
 		{ICE_INSET_DMAC, ICE_FLOW_FIELD_IDX_ETH_DA},
 		{ICE_INSET_IPV4_SRC, ICE_FLOW_FIELD_IDX_IPV4_SA},
 		{ICE_INSET_IPV4_DST, ICE_FLOW_FIELD_IDX_IPV4_DA},
+		{ICE_INSET_IPV4_TOS, ICE_FLOW_FIELD_IDX_IPV4_DSCP},
+		{ICE_INSET_IPV4_TTL, ICE_FLOW_FIELD_IDX_IPV4_TTL},
+		{ICE_INSET_IPV4_PROTO, ICE_FLOW_FIELD_IDX_IPV4_PROT},
 		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
 		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
+		{ICE_INSET_IPV6_TC, ICE_FLOW_FIELD_IDX_IPV6_DSCP},
+		{ICE_INSET_IPV6_NEXT_HDR, ICE_FLOW_FIELD_IDX_IPV6_PROT},
+		{ICE_INSET_IPV6_HOP_LIMIT, ICE_FLOW_FIELD_IDX_IPV6_TTL},
 		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
 		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
 		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
@@ -1174,6 +1183,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
 		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
 	};
+	uint32_t vtc_flow_cpu;
 
 
 	for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
@@ -1237,11 +1247,23 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 					input_set |= ICE_INSET_IPV4_SRC;
 				if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
 					input_set |= ICE_INSET_IPV4_DST;
+				if (ipv4_mask->hdr.type_of_service == UINT8_MAX)
+					input_set |= ICE_INSET_IPV4_TOS;
+				if (ipv4_mask->hdr.time_to_live == UINT8_MAX)
+					input_set |= ICE_INSET_IPV4_TTL;
+				if (ipv4_mask->hdr.next_proto_id == UINT8_MAX)
+					input_set |= ICE_INSET_IPV4_PROTO;
 
 				filter->input.ip.v4.dst_ip =
 					ipv4_spec->hdr.src_addr;
 				filter->input.ip.v4.src_ip =
 					ipv4_spec->hdr.dst_addr;
+				filter->input.ip.v4.tos =
+					ipv4_spec->hdr.type_of_service;
+				filter->input.ip.v4.ttl =
+					ipv4_spec->hdr.time_to_live;
+				filter->input.ip.v4.proto =
+					ipv4_spec->hdr.next_proto_id;
 			}
 
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER;
@@ -1271,10 +1293,29 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 					    RTE_DIM(ipv6_mask->hdr.dst_addr)))
 					input_set |= ICE_INSET_IPV6_DST;
 
+				if ((ipv6_mask->hdr.vtc_flow &
+				     rte_cpu_to_be_32(ICE_IPV6_TC_MASK))
+				    == rte_cpu_to_be_32(ICE_IPV6_TC_MASK))
+					input_set |= ICE_INSET_IPV6_TC;
+				if (ipv6_mask->hdr.proto == UINT8_MAX)
+					input_set |= ICE_INSET_IPV6_NEXT_HDR;
+				if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
+					input_set |= ICE_INSET_IPV6_HOP_LIMIT;
+
 				rte_memcpy(filter->input.ip.v6.dst_ip,
 					   ipv6_spec->hdr.src_addr, 16);
 				rte_memcpy(filter->input.ip.v6.src_ip,
 					   ipv6_spec->hdr.dst_addr, 16);
+
+				vtc_flow_cpu =
+				      rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
+				filter->input.ip.v6.tc =
+					(uint8_t)(vtc_flow_cpu >>
+						  ICE_FDIR_IPV6_TC_OFFSET);
+				filter->input.ip.v6.proto =
+					ipv6_spec->hdr.proto;
+				filter->input.ip.v6.hlim =
+					ipv6_spec->hdr.hop_limits;
 			}
 
 			flow_type = ICE_FLTR_PTYPE_NONF_IPV6_OTHER;
-- 
2.17.1



More information about the dev mailing list