diff mbox series

[RFC,2/2] net/ice: add support of VXLAN in switch filter

Message ID 20210824062854.2775724-2-yuying.zhang@intel.com (mailing list archive)
State Superseded
Headers show
Series [RFC,1/2] net/ice/base: add VXLAN support for switch filter | expand

Checks

Context Check Description
ci/intel-Testing fail Testing issues
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Yuying Zhang Aug. 24, 2021, 6:28 a.m. UTC
Add support of ipv4/ipv6 vxlan any pattern and outer/inner
ipv6 vxlan pattern in switch filter. Pattern ipv4/ipv6_vxlan_any
supports no input set.

+-------------------------------------+---------------------------+
| Pattern                             | Input Set                 |
+-------------------------------------+---------------------------+
| pattern_eth_ipv4_udp_vxlan_any      | dst mac, no input set     |
| pattern_eth_ipv6_udp_vxlan_any      | dst mac, no input set     |
| pattern_eth_ipv4_udp_vxlan_eth_ipv4 | dst mac, inner dst/src ip |
| pattern_eth_ipv4_udp_vxlan_eth_ipv6 | dst mac, inner dst/src ip |
| pattern_eth_ipv6_udp_vxlan_eth_ipv4 | dst mac, inner dst/src ip |
| pattern_eth_ipv6_udp_vxlan_eth_ipv6 | dst mac, inner dst/src ip |
+-------------------------------------+---------------------------+

Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
---
 drivers/net/ice/ice_generic_flow.c  | 33 +++++++++++++++++++++---
 drivers/net/ice/ice_generic_flow.h  |  6 +++++
 drivers/net/ice/ice_switch_filter.c | 40 ++++++++++++++++++++++++++---
 3 files changed, 72 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c
index 66b5743abf..29a5df69cb 100644
--- a/drivers/net/ice/ice_generic_flow.c
+++ b/drivers/net/ice/ice_generic_flow.c
@@ -364,6 +364,26 @@  enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_icmp[] = {
 	RTE_FLOW_ITEM_TYPE_END,
 };
 
+/* IPv4 VXLAN ANY */
+enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_any[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV4,
+	RTE_FLOW_ITEM_TYPE_UDP,
+	RTE_FLOW_ITEM_TYPE_VXLAN,
+	RTE_FLOW_ITEM_TYPE_ANY,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
+/* IPv6 VXLAN ANY */
+enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_any[] = {
+	RTE_FLOW_ITEM_TYPE_ETH,
+	RTE_FLOW_ITEM_TYPE_IPV6,
+	RTE_FLOW_ITEM_TYPE_UDP,
+	RTE_FLOW_ITEM_TYPE_VXLAN,
+	RTE_FLOW_ITEM_TYPE_ANY,
+	RTE_FLOW_ITEM_TYPE_END,
+};
+
 /* IPv4 VXLAN MAC IPv4 */
 enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4[] = {
 	RTE_FLOW_ITEM_TYPE_ETH,
@@ -2162,14 +2182,19 @@  static struct ice_ptype_match ice_ptype_map[] = {
 	{pattern_eth_qinq_pppoes_ipv6,			ICE_MAC_PPPOE_IPV6_PAY},
 	{pattern_eth_vlan_pppoes_ipv6_tcp,		ICE_MAC_PPPOE_IPV6_TCP},
 	{pattern_eth_vlan_pppoes_ipv6_udp,		ICE_MAC_PPPOE_IPV6_UDP_PAY},
+	{pattern_eth_ipv4_udp_vxlan_any,		ICE_MAC_IPV4_TUN_IPV4_PAY},
+	{pattern_eth_ipv6_udp_vxlan_any,		ICE_MAC_IPV6_TUN_IPV4_PAY},
 	{pattern_eth_ipv4_udp_vxlan_ipv4,		ICE_MAC_IPV4_TUN_IPV4_PAY},
 	{pattern_eth_ipv4_udp_vxlan_ipv4_udp,		ICE_MAC_IPV4_TUN_IPV4_UDP_PAY},
 	{pattern_eth_ipv4_udp_vxlan_ipv4_tcp,		ICE_MAC_IPV4_TUN_IPV4_TCP},
 	{pattern_eth_ipv4_udp_vxlan_ipv4_sctp,		ICE_MAC_IPV4_TUN_IPV4_SCTP},
-	{pattern_eth_ipv4_udp_vxlan_eth_ipv4,		ICE_MAC_IPV4_TUN_IPV4_PAY},
-	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,	ICE_MAC_IPV4_TUN_IPV4_UDP_PAY},
-	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,	ICE_MAC_IPV4_TUN_IPV4_TCP},
-	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,	ICE_MAC_IPV4_TUN_IPV4_SCTP},
+	{pattern_eth_ipv4_udp_vxlan_eth_ipv4,		ICE_MAC_IPV4_TUN_ICE_MAC_IPV4_PAY},
+	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,	ICE_MAC_IPV4_TUN_ICE_MAC_IPV4_UDP_PAY},
+	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,	ICE_MAC_IPV4_TUN_ICE_MAC_IPV4_TCP},
+	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,	ICE_MAC_IPV4_TUN_ICE_MAC_IPV4_SCTP},
+	{pattern_eth_ipv4_udp_vxlan_eth_ipv6,           ICE_MAC_IPV4_TUN_ICE_MAC_IPV6_PAY},
+	{pattern_eth_ipv6_udp_vxlan_eth_ipv4,           ICE_MAC_IPV6_TUN_MAC_IPV4_PAY},
+	{pattern_eth_ipv6_udp_vxlan_eth_ipv6,           ICE_MAC_IPV6_TUN_MAC_IPV6_PAY},
 	{pattern_eth_ipv4_nvgre_eth_ipv4,		ICE_MAC_IPV4_TUN_IPV4_PAY},
 	{pattern_eth_ipv4_nvgre_eth_ipv4_udp,		ICE_MAC_IPV4_TUN_IPV4_UDP_PAY},
 	{pattern_eth_ipv4_nvgre_eth_ipv4_tcp,		ICE_MAC_IPV4_TUN_IPV4_TCP},
diff --git a/drivers/net/ice/ice_generic_flow.h b/drivers/net/ice/ice_generic_flow.h
index 8845a3e156..f998ee7d71 100644
--- a/drivers/net/ice/ice_generic_flow.h
+++ b/drivers/net/ice/ice_generic_flow.h
@@ -176,6 +176,12 @@  extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_tcp[];
 extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_sctp[];
 extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_ipv4_icmp[];
 
+/* IPv4 VXLAN ANY */
+extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_any[];
+
+/* IPv6 VXLAN ANY */
+extern enum rte_flow_item_type pattern_eth_ipv6_udp_vxlan_any[];
+
 /* IPv4 VXLAN MAC IPv4 */
 extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4[];
 extern enum rte_flow_item_type pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp[];
diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c
index f222cb9cb0..399b315bf1 100644
--- a/drivers/net/ice/ice_switch_filter.c
+++ b/drivers/net/ice/ice_switch_filter.c
@@ -72,6 +72,9 @@ 
 #define ICE_SW_INSET_DIST_VXLAN_IPV4 ( \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_DMAC | \
 	ICE_INSET_VXLAN_VNI)
+#define ICE_SW_INSET_DIST_VXLAN_IPV6 ( \
+	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | ICE_INSET_DMAC | \
+	ICE_INSET_VXLAN_VNI)
 #define ICE_SW_INSET_DIST_NVGRE_IPV4_TCP ( \
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
 	ICE_INSET_TCP_SRC_PORT | ICE_INSET_TCP_DST_PORT | \
@@ -99,6 +102,9 @@ 
 	ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
 	ICE_INSET_UDP_SRC_PORT | ICE_INSET_UDP_DST_PORT | \
 	ICE_INSET_IPV4_TOS)
+#define ICE_SW_INSET_PERM_TUNNEL_IPV6 ( \
+	ICE_INSET_IPV6_SRC | ICE_INSET_IPV6_DST | \
+	ICE_INSET_IPV6_NEXT_HDR | ICE_INSET_IPV6_TC)
 #define ICE_SW_INSET_MAC_PPPOE  ( \
 	ICE_INSET_VLAN_OUTER | ICE_INSET_VLAN_INNER | \
 	ICE_INSET_DMAC | ICE_INSET_ETHERTYPE | ICE_INSET_PPPOE_SESSION)
@@ -182,9 +188,14 @@  ice_pattern_match_item ice_switch_pattern_dist_list[] = {
 	{pattern_eth_ipv6,				ICE_SW_INSET_MAC_IPV6,			ICE_INSET_NONE,				ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_SW_INSET_MAC_IPV6_UDP,		ICE_INSET_NONE,				ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_SW_INSET_MAC_IPV6_TCP,		ICE_INSET_NONE,				ICE_INSET_NONE},
+	{pattern_eth_ipv4_udp_vxlan_any,		ICE_INSET_DMAC,				ICE_INSET_NONE,				ICE_INSET_NONE},
+	{pattern_eth_ipv6_udp_vxlan_any,                ICE_INSET_DMAC,				ICE_INSET_NONE,                         ICE_INSET_NONE},
 	{pattern_eth_ipv4_udp_vxlan_eth_ipv4,		ICE_INSET_IPV4_DST,			ICE_SW_INSET_DIST_VXLAN_IPV4,		ICE_INSET_NONE},
 	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,	ICE_INSET_IPV4_DST,			ICE_SW_INSET_DIST_VXLAN_IPV4_UDP,	ICE_INSET_NONE},
 	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,	ICE_INSET_IPV4_DST,			ICE_SW_INSET_DIST_VXLAN_IPV4_TCP,	ICE_INSET_NONE},
+	{pattern_eth_ipv4_udp_vxlan_eth_ipv6,		ICE_INSET_DMAC,				ICE_SW_INSET_DIST_VXLAN_IPV6,		ICE_INSET_NONE},
+	{pattern_eth_ipv6_udp_vxlan_eth_ipv4,           ICE_INSET_DMAC,				ICE_SW_INSET_DIST_VXLAN_IPV4,           ICE_INSET_NONE},
+	{pattern_eth_ipv6_udp_vxlan_eth_ipv6,           ICE_INSET_DMAC,				ICE_SW_INSET_DIST_VXLAN_IPV6,           ICE_INSET_NONE},
 	{pattern_eth_ipv4_nvgre_eth_ipv4,		ICE_INSET_IPV4_DST,			ICE_SW_INSET_DIST_NVGRE_IPV4,		ICE_INSET_NONE},
 	{pattern_eth_ipv4_nvgre_eth_ipv4_udp,		ICE_INSET_IPV4_DST,			ICE_SW_INSET_DIST_NVGRE_IPV4_UDP,	ICE_INSET_NONE},
 	{pattern_eth_ipv4_nvgre_eth_ipv4_tcp,		ICE_INSET_IPV4_DST,			ICE_SW_INSET_DIST_NVGRE_IPV4_TCP,	ICE_INSET_NONE},
@@ -261,9 +272,14 @@  ice_pattern_match_item ice_switch_pattern_perm_list[] = {
 	{pattern_eth_ipv6,				ICE_SW_INSET_MAC_IPV6,			ICE_INSET_NONE,				ICE_INSET_NONE},
 	{pattern_eth_ipv6_udp,				ICE_SW_INSET_MAC_IPV6_UDP,		ICE_INSET_NONE,				ICE_INSET_NONE},
 	{pattern_eth_ipv6_tcp,				ICE_SW_INSET_MAC_IPV6_TCP,		ICE_INSET_NONE,				ICE_INSET_NONE},
+	{pattern_eth_ipv4_udp_vxlan_any,		ICE_INSET_NONE,				ICE_INSET_NONE,				ICE_INSET_NONE},
+	{pattern_eth_ipv6_udp_vxlan_any,		ICE_INSET_NONE,				ICE_INSET_NONE,				ICE_INSET_NONE},
 	{pattern_eth_ipv4_udp_vxlan_eth_ipv4,		ICE_INSET_NONE,				ICE_SW_INSET_PERM_TUNNEL_IPV4,		ICE_INSET_NONE},
 	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_udp,	ICE_INSET_NONE,				ICE_SW_INSET_PERM_TUNNEL_IPV4_UDP,	ICE_INSET_NONE},
 	{pattern_eth_ipv4_udp_vxlan_eth_ipv4_tcp,	ICE_INSET_NONE,				ICE_SW_INSET_PERM_TUNNEL_IPV4_TCP,	ICE_INSET_NONE},
+	{pattern_eth_ipv4_udp_vxlan_eth_ipv6,		ICE_INSET_NONE,                         ICE_SW_INSET_PERM_TUNNEL_IPV6,		ICE_INSET_NONE},
+	{pattern_eth_ipv6_udp_vxlan_eth_ipv4,		ICE_INSET_NONE,                         ICE_SW_INSET_PERM_TUNNEL_IPV4,		ICE_INSET_NONE},
+	{pattern_eth_ipv6_udp_vxlan_eth_ipv6,		ICE_INSET_NONE,                         ICE_SW_INSET_PERM_TUNNEL_IPV6,		ICE_INSET_NONE},
 	{pattern_eth_ipv4_nvgre_eth_ipv4,		ICE_INSET_NONE,				ICE_SW_INSET_PERM_TUNNEL_IPV4,		ICE_INSET_NONE},
 	{pattern_eth_ipv4_nvgre_eth_ipv4_udp,		ICE_INSET_NONE,				ICE_SW_INSET_PERM_TUNNEL_IPV4_UDP,	ICE_INSET_NONE},
 	{pattern_eth_ipv4_nvgre_eth_ipv4_tcp,		ICE_INSET_NONE,				ICE_SW_INSET_PERM_TUNNEL_IPV4_TCP,	ICE_INSET_NONE},
@@ -480,6 +496,7 @@  ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 	bool inner_ipv6_valid = 0;
 	bool inner_tcp_valid = 0;
 	bool inner_udp_valid = 0;
+	bool any_valid = 0;
 	uint16_t j, k, t = 0;
 
 	if (*tun_type == ICE_SW_TUN_AND_NON_TUN_QINQ ||
@@ -1371,6 +1388,10 @@  ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 			gtpu_psc_valid = 1;
 			break;
 
+		case RTE_FLOW_ITEM_TYPE_ANY:
+			any_valid = 1;
+			break;
+
 		case RTE_FLOW_ITEM_TYPE_VOID:
 			break;
 
@@ -1486,10 +1507,23 @@  ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 		}
 	}
 
+	if (vxlan_valid) {
+		if (ipv4_valid && inner_ipv4_valid)
+			*tun_type = ICE_SW_TUN_IPV4_VXLAN_IPV4;
+		if (ipv4_valid && inner_ipv6_valid)
+			*tun_type = ICE_SW_TUN_IPV4_VXLAN_IPV6;
+		if (ipv6_valid && inner_ipv4_valid)
+			*tun_type = ICE_SW_TUN_IPV6_VXLAN_IPV4;
+		if (ipv6_valid && inner_ipv6_valid)
+			*tun_type = ICE_SW_TUN_IPV6_VXLAN_IPV6;
+		if (ipv6_valid && any_valid)
+			*tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN;
+		if (ipv4_valid && any_valid)
+			*tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN;
+	}
+
 	if (*tun_type == ICE_NON_TUN) {
-		if (vxlan_valid)
-			*tun_type = ICE_SW_TUN_VXLAN;
-		else if (nvgre_valid)
+		if (nvgre_valid)
 			*tun_type = ICE_SW_TUN_NVGRE;
 		else if (ipv4_valid && tcp_valid)
 			*tun_type = ICE_SW_IPV4_TCP;