net/ice/base: support more PPPoE packet type
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 15 Jun 2020 02:04:52 +0000 (10:04 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jun 2020 17:21:08 +0000 (19:21 +0200)
This patch add more dummy packet type for PPPoE packet,
it enable tcp/udp layer of IPv4/IPv6 for PPPoE payload,
so we can use L4 dst/src port as input set for switch
filter.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@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 964561d..85af751 100644 (file)
@@ -68,6 +68,13 @@ enum ice_sw_tunnel_type {
                         */
        ICE_SW_TUN_GTP,
        ICE_SW_TUN_PPPOE,
+       ICE_SW_TUN_PPPOE_PAY,
+       ICE_SW_TUN_PPPOE_IPV4,
+       ICE_SW_TUN_PPPOE_IPV4_TCP,
+       ICE_SW_TUN_PPPOE_IPV4_UDP,
+       ICE_SW_TUN_PPPOE_IPV6,
+       ICE_SW_TUN_PPPOE_IPV6_TCP,
+       ICE_SW_TUN_PPPOE_IPV6_UDP,
        ICE_SW_TUN_IPV4_ESP,
        ICE_SW_TUN_IPV6_ESP,
        ICE_SW_TUN_IPV4_AH,
index fa3a59e..94268d5 100644 (file)
@@ -542,6 +542,15 @@ static const struct ice_dummy_pkt_offsets dummy_pppoe_packet_offsets[] = {
        { ICE_PROTOCOL_LAST,    0 },
 };
 
+static const struct ice_dummy_pkt_offsets dummy_pppoe_packet_ipv4_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_VLAN_OFOS,        14},
+       { ICE_PPPOE,            18 },
+       { ICE_IPV4_OFOS,        26 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
 static const u8 dummy_pppoe_ipv4_packet[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
        0x00, 0x00, 0x00, 0x00,
@@ -565,6 +574,92 @@ static const u8 dummy_pppoe_ipv4_packet[] = {
        0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
 };
 
+static const
+struct ice_dummy_pkt_offsets dummy_pppoe_ipv4_tcp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_VLAN_OFOS,        14},
+       { ICE_PPPOE,            18 },
+       { ICE_IPV4_OFOS,        26 },
+       { ICE_TCP_IL,           46 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_pppoe_ipv4_tcp_packet[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x81, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x00, 0x00, 0x88, 0x64, /* ICE_VLAN_OFOS 14 */
+
+       0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 18 */
+       0x00, 0x16,
+
+       0x00, 0x21,             /* PPP Link Layer 24 */
+
+       0x45, 0x00, 0x00, 0x28, /* ICE_IPV4_OFOS 26 */
+       0x00, 0x01, 0x00, 0x00,
+       0x00, 0x06, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 46 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x50, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
+};
+
+static const
+struct ice_dummy_pkt_offsets dummy_pppoe_ipv4_udp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_VLAN_OFOS,        14},
+       { ICE_PPPOE,            18 },
+       { ICE_IPV4_OFOS,        26 },
+       { ICE_UDP_ILOS,         46 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_pppoe_ipv4_udp_packet[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x81, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x00, 0x00, 0x88, 0x64, /* ICE_VLAN_OFOS 14 */
+
+       0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 18 */
+       0x00, 0x16,
+
+       0x00, 0x21,             /* PPP Link Layer 24 */
+
+       0x45, 0x00, 0x00, 0x1c, /* ICE_IPV4_OFOS 26 */
+       0x00, 0x01, 0x00, 0x00,
+       0x00, 0x11, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 46 */
+       0x00, 0x08, 0x00, 0x00,
+
+       0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
+};
+
+static const struct ice_dummy_pkt_offsets dummy_pppoe_packet_ipv6_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_VLAN_OFOS,        14},
+       { ICE_PPPOE,            18 },
+       { ICE_IPV6_OFOS,        26 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
 static const u8 dummy_pppoe_ipv6_packet[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
        0x00, 0x00, 0x00, 0x00,
@@ -593,6 +688,93 @@ static const u8 dummy_pppoe_ipv6_packet[] = {
        0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
 };
 
+static const
+struct ice_dummy_pkt_offsets dummy_pppoe_packet_ipv6_tcp_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_VLAN_OFOS,        14},
+       { ICE_PPPOE,            18 },
+       { ICE_IPV6_OFOS,        26 },
+       { ICE_TCP_IL,           66 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_pppoe_ipv6_tcp_packet[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x81, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x00, 0x00, 0x88, 0x64, /* ICE_VLAN_OFOS 14 */
+
+       0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 18 */
+       0x00, 0x2a,
+
+       0x00, 0x57,             /* PPP Link Layer 24 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 26 */
+       0x00, 0x14, 0x06, 0x00, /* Next header is TCP */
+       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 66 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x50, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
+};
+
+static const
+struct ice_dummy_pkt_offsets dummy_pppoe_packet_ipv6_udp_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
+       { ICE_VLAN_OFOS,        14},
+       { ICE_PPPOE,            18 },
+       { ICE_IPV6_OFOS,        26 },
+       { ICE_UDP_ILOS,         66 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_pppoe_ipv6_udp_packet[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x81, 0x00,             /* ICE_ETYPE_OL 12 */
+
+       0x00, 0x00, 0x88, 0x64, /* ICE_VLAN_OFOS 14 */
+
+       0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 18 */
+       0x00, 0x2a,
+
+       0x00, 0x57,             /* PPP Link Layer 24 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 26 */
+       0x00, 0x08, 0x11, 0x00, /* Next header UDP*/
+       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 66 */
+       0x00, 0x08, 0x00, 0x00,
+
+       0x00, 0x00,             /* 2 bytes for 4 bytes alignment */
+};
+
 static const struct ice_dummy_pkt_offsets dummy_ipv4_esp_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
        { ICE_IPV4_OFOS,        14 },
@@ -6123,6 +6305,31 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
        case ICE_SW_TUN_PPPOE:
                prof_type = ICE_PROF_TUN_PPPOE;
                break;
+       case ICE_SW_TUN_PPPOE_PAY:
+               ice_set_bit(ICE_PROFID_PPPOE_PAY, bm);
+               return;
+       case ICE_SW_TUN_PPPOE_IPV4:
+               ice_set_bit(ICE_PROFID_PPPOE_IPV4_OTHER, bm);
+               ice_set_bit(ICE_PROFID_PPPOE_IPV4_UDP, bm);
+               ice_set_bit(ICE_PROFID_PPPOE_IPV4_TCP, bm);
+               return;
+       case ICE_SW_TUN_PPPOE_IPV4_TCP:
+               ice_set_bit(ICE_PROFID_PPPOE_IPV4_TCP, bm);
+               return;
+       case ICE_SW_TUN_PPPOE_IPV4_UDP:
+               ice_set_bit(ICE_PROFID_PPPOE_IPV4_UDP, bm);
+               return;
+       case ICE_SW_TUN_PPPOE_IPV6:
+               ice_set_bit(ICE_PROFID_PPPOE_IPV6_OTHER, bm);
+               ice_set_bit(ICE_PROFID_PPPOE_IPV6_UDP, bm);
+               ice_set_bit(ICE_PROFID_PPPOE_IPV6_TCP, bm);
+               return;
+       case ICE_SW_TUN_PPPOE_IPV6_TCP:
+               ice_set_bit(ICE_PROFID_PPPOE_IPV6_TCP, bm);
+               return;
+       case ICE_SW_TUN_PPPOE_IPV6_UDP:
+               ice_set_bit(ICE_PROFID_PPPOE_IPV6_UDP, bm);
+               return;
        case ICE_SW_TUN_PROFID_IPV6_ESP:
        case ICE_SW_TUN_IPV6_ESP:
                ice_set_bit(ICE_PROFID_IPV6_ESP, bm);
@@ -6527,13 +6734,56 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
                *pkt_len = sizeof(dummy_pppoe_ipv6_packet);
                *offsets = dummy_pppoe_packet_offsets;
                return;
-       } else if (tun_type == ICE_SW_TUN_PPPOE) {
+       } else if (tun_type == ICE_SW_TUN_PPPOE ||
+               tun_type == ICE_SW_TUN_PPPOE_PAY) {
                *pkt = dummy_pppoe_ipv4_packet;
                *pkt_len = sizeof(dummy_pppoe_ipv4_packet);
                *offsets = dummy_pppoe_packet_offsets;
                return;
        }
 
+       if (tun_type == ICE_SW_TUN_PPPOE_IPV4) {
+               *pkt = dummy_pppoe_ipv4_packet;
+               *pkt_len = sizeof(dummy_pppoe_ipv4_packet);
+               *offsets = dummy_pppoe_packet_ipv4_offsets;
+               return;
+       }
+
+       if (tun_type == ICE_SW_TUN_PPPOE_IPV4_TCP) {
+               *pkt = dummy_pppoe_ipv4_tcp_packet;
+               *pkt_len = sizeof(dummy_pppoe_ipv4_tcp_packet);
+               *offsets = dummy_pppoe_ipv4_tcp_packet_offsets;
+               return;
+       }
+
+       if (tun_type == ICE_SW_TUN_PPPOE_IPV4_UDP) {
+               *pkt = dummy_pppoe_ipv4_udp_packet;
+               *pkt_len = sizeof(dummy_pppoe_ipv4_udp_packet);
+               *offsets = dummy_pppoe_ipv4_udp_packet_offsets;
+               return;
+       }
+
+       if (tun_type == ICE_SW_TUN_PPPOE_IPV6) {
+               *pkt = dummy_pppoe_ipv6_packet;
+               *pkt_len = sizeof(dummy_pppoe_ipv6_packet);
+               *offsets = dummy_pppoe_packet_ipv6_offsets;
+               return;
+       }
+
+       if (tun_type == ICE_SW_TUN_PPPOE_IPV6_TCP) {
+               *pkt = dummy_pppoe_ipv6_tcp_packet;
+               *pkt_len = sizeof(dummy_pppoe_ipv6_tcp_packet);
+               *offsets = dummy_pppoe_packet_ipv6_tcp_offsets;
+               return;
+       }
+
+       if (tun_type == ICE_SW_TUN_PPPOE_IPV6_UDP) {
+               *pkt = dummy_pppoe_ipv6_udp_packet;
+               *pkt_len = sizeof(dummy_pppoe_ipv6_udp_packet);
+               *offsets = dummy_pppoe_packet_ipv6_udp_offsets;
+               return;
+       }
+
        if (tun_type == ICE_ALL_TUNNELS) {
                *pkt = dummy_gre_udp_packet;
                *pkt_len = sizeof(dummy_gre_udp_packet);
index 8c7e98b..bd634f9 100644 (file)
 #define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
 
 /* Switch Profile IDs for Profile related switch rules */
+#define ICE_PROFID_PPPOE_PAY           34
+#define ICE_PROFID_PPPOE_IPV4_TCP      35
+#define ICE_PROFID_PPPOE_IPV4_UDP      36
+#define ICE_PROFID_PPPOE_IPV4_OTHER    37
+#define ICE_PROFID_PPPOE_IPV6_TCP      38
+#define ICE_PROFID_PPPOE_IPV6_UDP      39
+#define ICE_PROFID_PPPOE_IPV6_OTHER    40
 #define ICE_PROFID_IPV4_ESP            71
 #define ICE_PROFID_IPV6_ESP            72
 #define ICE_PROFID_IPV4_AH             73