Skip to content

Commit cd63454

Browse files
Marcin SzycikPaolo Abeni
authored andcommitted
ice: Add L2TPv3 hardware offload support
Add support for offloading packets based on L2TPv3 session id in switchdev mode. Example filter: tc filter add dev $PF1 ingress prio 1 protocol ip flower ip_proto l2tp \ l2tpv3_sid 1234 skip_sw action mirred egress redirect dev $VF1_PR Changes in iproute2 are required to be able to specify l2tpv3_sid. ICE COMMS DDP package is required to create a filter as it contains L2TPv3 profiles. Reviewed-by: Michal Swiatkowski <[email protected]> Signed-off-by: Marcin Szycik <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 2c1befa commit cd63454

File tree

4 files changed

+109
-2
lines changed

4 files changed

+109
-2
lines changed

drivers/net/ethernet/intel/ice/ice_protocol_type.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ enum ice_protocol_type {
4444
ICE_GTP,
4545
ICE_GTP_NO_PAY,
4646
ICE_PPPOE,
47+
ICE_L2TPV3,
4748
ICE_VLAN_EX,
4849
ICE_VLAN_IN,
4950
ICE_VXLAN_GPE,
@@ -111,6 +112,7 @@ enum ice_prot_id {
111112
#define ICE_UDP_ILOS_HW 53
112113
#define ICE_GRE_OF_HW 64
113114
#define ICE_PPPOE_HW 103
115+
#define ICE_L2TPV3_HW 104
114116

115117
#define ICE_UDP_OF_HW 52 /* UDP Tunnels */
116118
#define ICE_META_DATA_ID_HW 255 /* this is used for tunnel and VLAN type */
@@ -217,6 +219,11 @@ struct ice_pppoe_hdr {
217219
__be16 ppp_prot_id; /* control and data only */
218220
};
219221

222+
struct ice_l2tpv3_sess_hdr {
223+
__be32 session_id;
224+
__be64 cookie;
225+
};
226+
220227
struct ice_nvgre_hdr {
221228
__be16 flags;
222229
__be16 protocol;
@@ -235,6 +242,7 @@ union ice_prot_hdr {
235242
struct ice_nvgre_hdr nvgre_hdr;
236243
struct ice_udp_gtp_hdr gtp_hdr;
237244
struct ice_pppoe_hdr pppoe_hdr;
245+
struct ice_l2tpv3_sess_hdr l2tpv3_sess_hdr;
238246
};
239247

240248
/* This is mapping table entry that maps every word within a given protocol

drivers/net/ethernet/intel/ice/ice_switch.c

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum {
4242
ICE_PKT_GTP_NOPAY = BIT(8),
4343
ICE_PKT_KMALLOC = BIT(9),
4444
ICE_PKT_PPPOE = BIT(10),
45+
ICE_PKT_L2TPV3 = BIT(11),
4546
};
4647

4748
struct ice_dummy_pkt_offsets {
@@ -1258,6 +1259,65 @@ ICE_DECLARE_PKT_TEMPLATE(pppoe_ipv6_udp) = {
12581259
0x00, 0x00, /* 2 bytes for 4 bytes alignment */
12591260
};
12601261

1262+
ICE_DECLARE_PKT_OFFSETS(ipv4_l2tpv3) = {
1263+
{ ICE_MAC_OFOS, 0 },
1264+
{ ICE_ETYPE_OL, 12 },
1265+
{ ICE_IPV4_OFOS, 14 },
1266+
{ ICE_L2TPV3, 34 },
1267+
{ ICE_PROTOCOL_LAST, 0 },
1268+
};
1269+
1270+
ICE_DECLARE_PKT_TEMPLATE(ipv4_l2tpv3) = {
1271+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1272+
0x00, 0x00, 0x00, 0x00,
1273+
0x00, 0x00, 0x00, 0x00,
1274+
1275+
0x08, 0x00, /* ICE_ETYPE_OL 12 */
1276+
1277+
0x45, 0x00, 0x00, 0x20, /* ICE_IPV4_IL 14 */
1278+
0x00, 0x00, 0x40, 0x00,
1279+
0x40, 0x73, 0x00, 0x00,
1280+
0x00, 0x00, 0x00, 0x00,
1281+
0x00, 0x00, 0x00, 0x00,
1282+
1283+
0x00, 0x00, 0x00, 0x00, /* ICE_L2TPV3 34 */
1284+
0x00, 0x00, 0x00, 0x00,
1285+
0x00, 0x00, 0x00, 0x00,
1286+
0x00, 0x00, /* 2 bytes for 4 bytes alignment */
1287+
};
1288+
1289+
ICE_DECLARE_PKT_OFFSETS(ipv6_l2tpv3) = {
1290+
{ ICE_MAC_OFOS, 0 },
1291+
{ ICE_ETYPE_OL, 12 },
1292+
{ ICE_IPV6_OFOS, 14 },
1293+
{ ICE_L2TPV3, 54 },
1294+
{ ICE_PROTOCOL_LAST, 0 },
1295+
};
1296+
1297+
ICE_DECLARE_PKT_TEMPLATE(ipv6_l2tpv3) = {
1298+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1299+
0x00, 0x00, 0x00, 0x00,
1300+
0x00, 0x00, 0x00, 0x00,
1301+
1302+
0x86, 0xDD, /* ICE_ETYPE_OL 12 */
1303+
1304+
0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_IL 14 */
1305+
0x00, 0x0c, 0x73, 0x40,
1306+
0x00, 0x00, 0x00, 0x00,
1307+
0x00, 0x00, 0x00, 0x00,
1308+
0x00, 0x00, 0x00, 0x00,
1309+
0x00, 0x00, 0x00, 0x00,
1310+
0x00, 0x00, 0x00, 0x00,
1311+
0x00, 0x00, 0x00, 0x00,
1312+
0x00, 0x00, 0x00, 0x00,
1313+
0x00, 0x00, 0x00, 0x00,
1314+
1315+
0x00, 0x00, 0x00, 0x00, /* ICE_L2TPV3 54 */
1316+
0x00, 0x00, 0x00, 0x00,
1317+
0x00, 0x00, 0x00, 0x00,
1318+
0x00, 0x00, /* 2 bytes for 4 bytes alignment */
1319+
};
1320+
12611321
static const struct ice_dummy_pkt_profile ice_dummy_pkt_profiles[] = {
12621322
ICE_PKT_PROFILE(ipv6_gtp, ICE_PKT_TUN_GTPU | ICE_PKT_OUTER_IPV6 |
12631323
ICE_PKT_GTP_NOPAY),
@@ -1297,6 +1357,8 @@ static const struct ice_dummy_pkt_profile ice_dummy_pkt_profiles[] = {
12971357
ICE_PKT_PROFILE(udp_tun_ipv6_tcp, ICE_PKT_TUN_UDP |
12981358
ICE_PKT_INNER_IPV6 |
12991359
ICE_PKT_INNER_TCP),
1360+
ICE_PKT_PROFILE(ipv6_l2tpv3, ICE_PKT_L2TPV3 | ICE_PKT_OUTER_IPV6),
1361+
ICE_PKT_PROFILE(ipv4_l2tpv3, ICE_PKT_L2TPV3),
13001362
ICE_PKT_PROFILE(udp_tun_tcp, ICE_PKT_TUN_UDP | ICE_PKT_INNER_TCP),
13011363
ICE_PKT_PROFILE(udp_tun_ipv6_udp, ICE_PKT_TUN_UDP |
13021364
ICE_PKT_INNER_IPV6),
@@ -4490,6 +4552,7 @@ static const struct ice_prot_ext_tbl_entry ice_prot_ext[ICE_PROTOCOL_LAST] = {
44904552
{ ICE_GTP, { 8, 10, 12, 14, 16, 18, 20, 22 } },
44914553
{ ICE_GTP_NO_PAY, { 8, 10, 12, 14 } },
44924554
{ ICE_PPPOE, { 0, 2, 4, 6 } },
4555+
{ ICE_L2TPV3, { 0, 2, 4, 6, 8, 10 } },
44934556
{ ICE_VLAN_EX, { 2, 0 } },
44944557
{ ICE_VLAN_IN, { 2, 0 } },
44954558
};
@@ -4513,6 +4576,7 @@ static struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = {
45134576
{ ICE_GTP, ICE_UDP_OF_HW },
45144577
{ ICE_GTP_NO_PAY, ICE_UDP_ILOS_HW },
45154578
{ ICE_PPPOE, ICE_PPPOE_HW },
4579+
{ ICE_L2TPV3, ICE_L2TPV3_HW },
45164580
{ ICE_VLAN_EX, ICE_VLAN_OF_HW },
45174581
{ ICE_VLAN_IN, ICE_VLAN_OL_HW },
45184582
};
@@ -5596,7 +5660,8 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
55965660
if (lkups[i].h_u.pppoe_hdr.ppp_prot_id ==
55975661
htons(PPP_IPV6))
55985662
match |= ICE_PKT_OUTER_IPV6;
5599-
}
5663+
} else if (lkups[i].type == ICE_L2TPV3)
5664+
match |= ICE_PKT_L2TPV3;
56005665
}
56015666

56025667
while (ret->match && (match & ret->match) != ret->match)
@@ -5697,6 +5762,9 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
56975762
case ICE_PPPOE:
56985763
len = sizeof(struct ice_pppoe_hdr);
56995764
break;
5765+
case ICE_L2TPV3:
5766+
len = sizeof(struct ice_l2tpv3_sess_hdr);
5767+
break;
57005768
default:
57015769
return -EINVAL;
57025770
}

drivers/net/ethernet/intel/ice/ice_tc_lib.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ ice_tc_count_lkups(u32 flags, struct ice_tc_flower_lyr_2_4_hdrs *headers,
7171
if (flags & (ICE_TC_FLWR_FIELD_IP_TOS | ICE_TC_FLWR_FIELD_IP_TTL))
7272
lkups_cnt++;
7373

74+
/* are L2TPv3 options specified? */
75+
if (flags & ICE_TC_FLWR_FIELD_L2TPV3_SESSID)
76+
lkups_cnt++;
77+
7478
/* is L4 (TCP/UDP/any other L4 protocol fields) specified? */
7579
if (flags & (ICE_TC_FLWR_FIELD_DEST_L4_PORT |
7680
ICE_TC_FLWR_FIELD_SRC_L4_PORT))
@@ -515,6 +519,17 @@ ice_tc_fill_rules(struct ice_hw *hw, u32 flags,
515519
i++;
516520
}
517521

522+
if (flags & ICE_TC_FLWR_FIELD_L2TPV3_SESSID) {
523+
list[i].type = ICE_L2TPV3;
524+
525+
list[i].h_u.l2tpv3_sess_hdr.session_id =
526+
headers->l2tpv3_hdr.session_id;
527+
list[i].m_u.l2tpv3_sess_hdr.session_id =
528+
cpu_to_be32(0xFFFFFFFF);
529+
530+
i++;
531+
}
532+
518533
/* copy L4 (src, dest) port */
519534
if (flags & (ICE_TC_FLWR_FIELD_DEST_L4_PORT |
520535
ICE_TC_FLWR_FIELD_SRC_L4_PORT)) {
@@ -1168,7 +1183,8 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,
11681183
BIT(FLOW_DISSECTOR_KEY_IP) |
11691184
BIT(FLOW_DISSECTOR_KEY_ENC_IP) |
11701185
BIT(FLOW_DISSECTOR_KEY_PORTS) |
1171-
BIT(FLOW_DISSECTOR_KEY_PPPOE))) {
1186+
BIT(FLOW_DISSECTOR_KEY_PPPOE) |
1187+
BIT(FLOW_DISSECTOR_KEY_L2TPV3))) {
11721188
NL_SET_ERR_MSG_MOD(fltr->extack, "Unsupported key used");
11731189
return -EOPNOTSUPP;
11741190
}
@@ -1351,6 +1367,15 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,
13511367
ice_tc_set_tos_ttl(&match, fltr, headers, false);
13521368
}
13531369

1370+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_L2TPV3)) {
1371+
struct flow_match_l2tpv3 match;
1372+
1373+
flow_rule_match_l2tpv3(rule, &match);
1374+
1375+
fltr->flags |= ICE_TC_FLWR_FIELD_L2TPV3_SESSID;
1376+
headers->l2tpv3_hdr.session_id = match.key->session_id;
1377+
}
1378+
13541379
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
13551380
struct flow_match_ports match;
13561381

drivers/net/ethernet/intel/ice/ice_tc_lib.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define ICE_TC_FLWR_FIELD_IP_TTL BIT(23)
3131
#define ICE_TC_FLWR_FIELD_ENC_IP_TOS BIT(24)
3232
#define ICE_TC_FLWR_FIELD_ENC_IP_TTL BIT(25)
33+
#define ICE_TC_FLWR_FIELD_L2TPV3_SESSID BIT(26)
3334

3435
#define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF
3536

@@ -86,6 +87,10 @@ struct ice_tc_l3_hdr {
8687
u8 ttl;
8788
};
8889

90+
struct ice_tc_l2tpv3_hdr {
91+
__be32 session_id;
92+
};
93+
8994
struct ice_tc_l4_hdr {
9095
__be16 dst_port;
9196
__be16 src_port;
@@ -98,6 +103,7 @@ struct ice_tc_flower_lyr_2_4_hdrs {
98103
struct ice_tc_vlan_hdr vlan_hdr;
99104
struct ice_tc_vlan_hdr cvlan_hdr;
100105
struct ice_tc_pppoe_hdr pppoe_hdr;
106+
struct ice_tc_l2tpv3_hdr l2tpv3_hdr;
101107
/* L3 (IPv4[6]) layer fields with their mask */
102108
struct ice_tc_l3_hdr l3_key;
103109
struct ice_tc_l3_hdr l3_mask;

0 commit comments

Comments
 (0)