diff mbox series

[RFC,1/2] net/ice/base: add VXLAN support for switch filter

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Yuying Zhang Aug. 24, 2021, 7:02 a.m. UTC
Add ipv4/ipv6 vxlan any support in switch filter. Add inner ipv6 and
outer ipv6 support of vxlan protocol in switch filter.

Signed-off-by: Yuying Zhang <yuying.zhang@intel.com>
---
 drivers/net/ice/base/ice_protocol_type.h |   6 +
 drivers/net/ice/base/ice_switch.c        | 212 ++++++++++++++++++++++-
 drivers/net/ice/base/ice_switch.h        |  12 ++
 3 files changed, 229 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/ice/base/ice_protocol_type.h b/drivers/net/ice/base/ice_protocol_type.h
index cef8354f77..599b4baba6 100644
--- a/drivers/net/ice/base/ice_protocol_type.h
+++ b/drivers/net/ice/base/ice_protocol_type.h
@@ -112,6 +112,12 @@  enum ice_sw_tunnel_type {
 	ICE_SW_TUN_IPV6_NAT_T,
 	ICE_SW_TUN_IPV4_L2TPV3,
 	ICE_SW_TUN_IPV6_L2TPV3,
+	ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4,
+	ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6,
+	ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4,
+	ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6,
+	ICE_SW_TUN_PROFID_IPV4_VXLAN,
+	ICE_SW_TUN_PROFID_IPV6_VXLAN,
 	ICE_SW_TUN_PROFID_IPV6_ESP,
 	ICE_SW_TUN_PROFID_IPV6_AH,
 	ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3,
diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c
index 9179f66c20..6a278c1bbb 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -180,6 +180,62 @@  static const u8 dummy_udp_tun_tcp_packet[] = {
 	0x00, 0x00, 0x00, 0x00
 };
 
+static const struct ice_dummy_pkt_offsets dummy_udp_tun_ipv6_tcp_packet_offsets[] = {
+	{ ICE_MAC_OFOS,		0 },
+	{ ICE_ETYPE_OL,         12 },
+	{ ICE_IPV4_OFOS,        14 },
+	{ ICE_UDP_OF,           34 },
+	{ ICE_VXLAN,            42 },
+	{ ICE_GENEVE,           42 },
+	{ ICE_VXLAN_GPE,        42 },
+	{ ICE_MAC_IL,           50 },
+	{ ICE_IPV6_IL,          64 },
+	{ ICE_TCP_IL,           104 },
+	{ ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_udp_tun_ipv6_tcp_packet[] = {
+	0x00, 0x00, 0x00, 0x00,  /* ICE_MAC_OFOS 0 */
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+
+	0x08, 0x00,             /* ICE_ETYPE_OL 12 */
+
+	0x45, 0x00, 0x00, 0x5a, /* ICE_IPV4_OFOS 14 */
+	0x00, 0x01, 0x00, 0x00,
+	0x40, 0x11, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+
+	0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */
+	0x00, 0x46, 0x00, 0x00,
+
+	0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */
+	0x00, 0x00, 0x00, 0x00,
+
+	0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x86, 0xdd,
+
+	0x60, 0x00, 0x00, 0x00, /* ICE_IPV4_IL 64 */
+	0x00, 0x00, 0x06, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+
+	0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 104 */
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x50, 0x02, 0x20, 0x00,
+	0x00, 0x00, 0x00, 0x00
+};
+
 static const struct ice_dummy_pkt_offsets dummy_udp_tun_udp_packet_offsets[] = {
 	{ ICE_MAC_OFOS,		0 },
 	{ ICE_ETYPE_OL,		12 },
@@ -228,6 +284,59 @@  static const u8 dummy_udp_tun_udp_packet[] = {
 	0x00, 0x08, 0x00, 0x00,
 };
 
+static const struct ice_dummy_pkt_offsets dummy_udp_tun_ipv6_udp_packet_offsets[] = {
+	{ ICE_MAC_OFOS,         0 },
+	{ ICE_ETYPE_OL,         12 },
+	{ ICE_IPV4_OFOS,        14 },
+	{ ICE_UDP_OF,           34 },
+	{ ICE_VXLAN,            42 },
+	{ ICE_GENEVE,           42 },
+	{ ICE_VXLAN_GPE,        42 },
+	{ ICE_MAC_IL,           50 },
+	{ ICE_IPV6_IL,          64 },
+	{ ICE_UDP_ILOS,         104 },
+	{ ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_udp_tun_ipv6_udp_packet[] = {
+	0x00, 0x00, 0x00, 0x00,  /* ICE_MAC_OFOS 0 */
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+
+	0x08, 0x00,             /* ICE_ETYPE_OL 12 */
+
+	0x45, 0x00, 0x00, 0x4e, /* ICE_IPV4_OFOS 14 */
+	0x00, 0x01, 0x00, 0x00,
+	0x00, 0x11, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+
+	0x00, 0x00, 0x12, 0xb5, /* ICE_UDP_OF 34 */
+	0x00, 0x3a, 0x00, 0x00,
+
+	0x00, 0x00, 0x65, 0x58, /* ICE_VXLAN 42 */
+	0x00, 0x00, 0x00, 0x00,
+
+	0x00, 0x00, 0x00, 0x00, /* ICE_MAC_IL 50 */
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x86, 0xdd,
+
+	0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 64 */
+	0x00, 0x58, 0x11, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+
+	0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 104 */
+	0x00, 0x08, 0x00, 0x00,
+};
+
 /* offset info for MAC + IPv4 + UDP dummy packet */
 static const struct ice_dummy_pkt_offsets dummy_udp_packet_offsets[] = {
 	{ ICE_MAC_OFOS,		0 },
@@ -1871,6 +1980,10 @@  static enum ice_sw_tunnel_type ice_get_tun_type_for_recipe(u8 rid, bool vlan)
 	bool non_tun_valid = false;
 	bool pppoe_valid = false;
 	bool vxlan_valid = false;
+	bool ipv4_vxlan_ipv4_valid = false;
+	bool ipv4_vxlan_ipv6_valid = false;
+	bool ipv6_vxlan_ipv4_valid = false;
+	bool ipv6_vxlan_ipv6_valid = false;
 	bool gre_valid = false;
 	bool gtp_valid = false;
 	bool flag_valid = false;
@@ -1887,8 +2000,17 @@  static enum ice_sw_tunnel_type ice_get_tun_type_for_recipe(u8 rid, bool vlan)
 		}
 
 		for (i = 0; i < 12; i++) {
-			if (vxlan_profile[i] == j)
+			if (vxlan_profile[i] == j) {
 				vxlan_valid = true;
+				if (i < 3)
+					ipv4_vxlan_ipv4_valid = true;
+				else if (i < 6)
+					ipv6_vxlan_ipv4_valid = true;
+				else if (i < 9)
+					ipv4_vxlan_ipv6_valid = true;
+				else if (i < 12)
+					ipv6_vxlan_ipv6_valid = true;
+			}
 		}
 
 		for (i = 0; i < 7; i++) {
@@ -1949,6 +2071,21 @@  static enum ice_sw_tunnel_type ice_get_tun_type_for_recipe(u8 rid, bool vlan)
 			}
 	}
 
+	if (tun_type == ICE_SW_TUN_VXLAN) {
+		if (ipv4_vxlan_ipv4_valid && ipv4_vxlan_ipv6_valid)
+			tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN;
+		else if (ipv6_vxlan_ipv4_valid && ipv6_vxlan_ipv6_valid)
+			tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN;
+		else if (ipv4_vxlan_ipv4_valid)
+			tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4;
+		else if (ipv4_vxlan_ipv6_valid)
+			tun_type = ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6;
+		else if (ipv6_vxlan_ipv4_valid)
+			tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4;
+		else if (ipv6_vxlan_ipv6_valid)
+			tun_type = ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6;
+	}
+
 	if (profile_num == 1 && (flag_valid || non_tun_valid || pppoe_valid)) {
 		for (j = 0; j < ICE_MAX_NUM_PROFILES; j++) {
 			if (ice_is_bit_set(recipe_to_profile[rid], j)) {
@@ -7357,6 +7494,12 @@  static bool ice_tun_type_match_word(enum ice_sw_tunnel_type tun_type, u16 *mask)
 	case ICE_SW_TUN_VXLAN_GPE:
 	case ICE_SW_TUN_GENEVE:
 	case ICE_SW_TUN_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6:
 	case ICE_SW_TUN_NVGRE:
 	case ICE_SW_TUN_UDP:
 	case ICE_ALL_TUNNELS:
@@ -7620,6 +7763,42 @@  ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
 	case ICE_SW_TUN_IPV6_GTPU_EH_IPV6_TCP:
 		ice_set_bit(ICE_PROFID_IPV6_GTPU_EH_IPV6_TCP, bm);
 		return;
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN:
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_OTHER, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_OTHER, bm);
+		return;
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN:
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_OTHER, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_OTHER, bm);
+		return;
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4:
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV4_OTHER, bm);
+		return;
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4:
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV4_OTHER, bm);
+		return;
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6:
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV4_TUN_M_IPV6_OTHER, bm);
+		return;
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6:
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_TCP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_UDP, bm);
+		ice_set_bit(ICE_PROFID_IPV6_TUN_M_IPV6_OTHER, bm);
+		return;
 	case ICE_SW_TUN_AND_NON_TUN:
 	case ICE_SW_TUN_AND_NON_TUN_QINQ:
 	default:
@@ -7640,6 +7819,12 @@  ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
 bool ice_is_prof_rule(enum ice_sw_tunnel_type type)
 {
 	switch (type) {
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6:
 	case ICE_SW_TUN_PROFID_IPV6_ESP:
 	case ICE_SW_TUN_PROFID_IPV6_AH:
 	case ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3:
@@ -8228,8 +8413,27 @@  ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
 		return;
 	}
 
+	if (tun_type == ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6 ||
+	    tun_type == ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6) {
+		if (tcp) {
+			*pkt = dummy_udp_tun_ipv6_tcp_packet;
+			*pkt_len = sizeof(dummy_udp_tun_ipv6_tcp_packet);
+			*offsets = dummy_udp_tun_ipv6_tcp_packet_offsets;
+			return;
+		}
+
+		*pkt = dummy_udp_tun_ipv6_udp_packet;
+		*pkt_len = sizeof(dummy_udp_tun_ipv6_udp_packet);
+		*offsets = dummy_udp_tun_ipv6_udp_packet_offsets;
+		return;
+	}
+
 	if (tun_type == ICE_SW_TUN_VXLAN || tun_type == ICE_SW_TUN_GENEVE ||
 	    tun_type == ICE_SW_TUN_VXLAN_GPE || tun_type == ICE_SW_TUN_UDP ||
+	    tun_type == ICE_SW_TUN_PROFID_IPV4_VXLAN ||
+	    tun_type == ICE_SW_TUN_PROFID_IPV6_VXLAN ||
+	    tun_type == ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4 ||
+	    tun_type == ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4 ||
 	    tun_type == ICE_SW_TUN_GENEVE_VLAN ||
 	    tun_type == ICE_SW_TUN_VXLAN_VLAN) {
 		if (tcp) {
@@ -8445,6 +8649,12 @@  ice_fill_adv_packet_tun(struct ice_hw *hw, enum ice_sw_tunnel_type tun_type,
 	case ICE_SW_TUN_AND_NON_TUN:
 	case ICE_SW_TUN_VXLAN_GPE:
 	case ICE_SW_TUN_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV4:
+	case ICE_SW_TUN_PROFID_IPV4_VXLAN_IPV6:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV4:
+	case ICE_SW_TUN_PROFID_IPV6_VXLAN_IPV6:
 	case ICE_SW_TUN_VXLAN_VLAN:
 	case ICE_SW_TUN_UDP:
 		if (!ice_get_open_tunnel_port(hw, TNL_VXLAN, &open_port))
diff --git a/drivers/net/ice/base/ice_switch.h b/drivers/net/ice/base/ice_switch.h
index 980bae5806..8258d06e6d 100644
--- a/drivers/net/ice/base/ice_switch.h
+++ b/drivers/net/ice/base/ice_switch.h
@@ -20,6 +20,18 @@ 
 #define ICE_PROFID_IPV4_UDP		5
 #define ICE_PROFID_IPV6_TCP		7
 #define ICE_PROFID_IPV6_UDP		8
+#define ICE_PROFID_IPV4_TUN_M_IPV4_TCP		10
+#define ICE_PROFID_IPV4_TUN_M_IPV4_UDP		11
+#define ICE_PROFID_IPV4_TUN_M_IPV4_OTHER	12
+#define ICE_PROFID_IPV6_TUN_M_IPV4_TCP		16
+#define ICE_PROFID_IPV6_TUN_M_IPV4_UDP		17
+#define ICE_PROFID_IPV6_TUN_M_IPV4_OTHER	18
+#define ICE_PROFID_IPV4_TUN_M_IPV6_TCP		22
+#define ICE_PROFID_IPV4_TUN_M_IPV6_UDP		23
+#define ICE_PROFID_IPV4_TUN_M_IPV6_OTHER	24
+#define ICE_PROFID_IPV6_TUN_M_IPV6_TCP		25
+#define ICE_PROFID_IPV6_TUN_M_IPV6_UDP		26
+#define ICE_PROFID_IPV6_TUN_M_IPV6_OTHER	27
 #define ICE_PROFID_PPPOE_PAY		34
 #define ICE_PROFID_PPPOE_IPV4_TCP	35
 #define ICE_PROFID_PPPOE_IPV4_UDP	36