net/ice/base: support L2TP on switch
authorWei Zhao <wei.zhao1@intel.com>
Mon, 20 Apr 2020 05:18:54 +0000 (13:18 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 22 Apr 2020 10:31:12 +0000 (12:31 +0200)
Add dummy packet and tunnel type to support
L2TP on switch, now we can use session id as
input set for switch rule.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/ice/base/ice_protocol_type.h
drivers/net/ice/base/ice_switch.c
drivers/net/ice/base/ice_switch.h

index 2ca7cd8..46cd77e 100644 (file)
@@ -72,6 +72,8 @@ enum ice_sw_tunnel_type {
        ICE_SW_TUN_IPV6_AH,
        ICE_SW_TUN_IPV4_NAT_T,
        ICE_SW_TUN_IPV6_NAT_T,
+       ICE_SW_TUN_IPV4_L2TPV3,
+       ICE_SW_TUN_IPV6_L2TPV3,
        ICE_SW_TUN_PROFID_IPV6_ESP,
        ICE_SW_TUN_PROFID_IPV6_AH,
        ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3,
index b6a6d02..e64b031 100644 (file)
@@ -760,6 +760,61 @@ static const u8 dummy_ipv6_nat_pkt[] = {
 
 };
 
+static const struct ice_dummy_pkt_offsets dummy_ipv4_l2tpv3_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_IPV4_OFOS,        14 },
+       { ICE_L2TPV3,           34 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_ipv4_l2tpv3_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x08, 0x00,
+
+       0x45, 0x00, 0x00, 0x20, /* ICE_IPV4_IL 14 */
+       0x00, 0x00, 0x40, 0x00,
+       0x40, 0x73, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_L2TPV3 34 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
+};
+
+static const struct ice_dummy_pkt_offsets dummy_ipv6_l2tpv3_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_IPV6_OFOS,        14 },
+       { ICE_L2TPV3,           54 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_ipv6_l2tpv3_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x86, 0xDD,
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 14 */
+       0x00, 0x0c, 0x73, 0x40,
+       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_L2TPV3 54 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
+};
+
 /* this is a recipe to profile association bitmap */
 static ice_declare_bitmap(recipe_to_profile[ICE_MAX_NUM_RECIPES],
                          ICE_MAX_NUM_PROFILES);
@@ -5949,6 +6004,7 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
                ice_set_bit(ICE_PROFID_IPV6_AH, bm);
                return;
        case ICE_SW_TUN_PROFID_MAC_IPV6_L2TPV3:
+       case ICE_SW_TUN_IPV6_L2TPV3:
                ice_set_bit(ICE_PROFID_MAC_IPV6_L2TPV3, bm);
                return;
        case ICE_SW_TUN_PROFID_IPV6_NAT_T:
@@ -5970,6 +6026,9 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
        case ICE_SW_TUN_IPV4_NAT_T:
                ice_set_bit(ICE_PROFID_IPV4_NAT_T, bm);
                return;
+       case ICE_SW_TUN_IPV4_L2TPV3:
+               ice_set_bit(ICE_PROFID_MAC_IPV4_L2TPV3, bm);
+               return;
        case ICE_SW_TUN_AND_NON_TUN:
        default:
                prof_type = ICE_PROF_ALL;
@@ -6308,6 +6367,20 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
                return;
        }
 
+       if (tun_type == ICE_SW_TUN_IPV4_L2TPV3) {
+               *pkt = dummy_ipv4_l2tpv3_pkt;
+               *pkt_len = sizeof(dummy_ipv4_l2tpv3_pkt);
+               *offsets = dummy_ipv4_l2tpv3_packet_offsets;
+               return;
+       }
+
+       if (tun_type == ICE_SW_TUN_IPV6_L2TPV3) {
+               *pkt = dummy_ipv6_l2tpv3_pkt;
+               *pkt_len = sizeof(dummy_ipv6_l2tpv3_pkt);
+               *offsets = dummy_ipv6_l2tpv3_packet_offsets;
+               return;
+       }
+
        if (tun_type == ICE_SW_TUN_GTP) {
                *pkt = dummy_udp_gtp_packet;
                *pkt_len = sizeof(dummy_udp_gtp_packet);
@@ -6506,6 +6579,9 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
                case ICE_AH:
                        len = sizeof(struct ice_ah_hdr);
                        break;
+               case ICE_L2TPV3:
+                       len = sizeof(struct ice_l2tpv3_sess_hdr);
+                       break;
                default:
                        return ICE_ERR_PARAM;
                }
index 48d93dc..09dc1f2 100644 (file)
@@ -20,6 +20,7 @@
 #define ICE_PROFID_IPV6_AH             74
 #define ICE_PROFID_IPV4_NAT_T          75
 #define ICE_PROFID_IPV6_NAT_T          76
+#define ICE_PROFID_MAC_IPV4_L2TPV3     77
 #define ICE_PROFID_MAC_IPV6_L2TPV3     78
 #define ICE_PROFID_IPV4_PFCP_NODE      79
 #define ICE_PROFID_IPV4_PFCP_SESSION   80