Skip to content

Commit 7d85e9c

Browse files
author
Paolo Abeni
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== ice: PPPoE offload support Marcin Szycik says: Add support for dissecting PPPoE and PPP-specific fields in flow dissector: PPPoE session id and PPP protocol type. Add support for those fields in tc-flower and support offloading PPPoE. Finally, add support for hardware offload of PPPoE packets in switchdev mode in ice driver. Example filter: tc filter add dev $PF1 ingress protocol ppp_ses prio 1 flower pppoe_sid \ 1234 ppp_proto ip skip_sw action mirred egress redirect dev $VF1_PR Changes in iproute2 are required to use the new fields (will be submitted soon). ICE COMMS DDP package is required to create a filter in ice. * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue: ice: Add support for PPPoE hardware offload flow_offload: Introduce flow_match_pppoe net/sched: flower: Add PPPoE filter flow_dissector: Add PPPoE dissectors ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 5f10376 + cd8efee commit 7d85e9c

File tree

13 files changed

+412
-9
lines changed

13 files changed

+412
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <net/udp_tunnel.h>
5353
#include <net/vxlan.h>
5454
#include <net/gtp.h>
55+
#include <linux/ppp_defs.h>
5556
#include "ice_devids.h"
5657
#include "ice_type.h"
5758
#include "ice_txrx.h"

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,8 +1964,11 @@ ice_get_sw_fv_list(struct ice_hw *hw, struct ice_prot_lkup_ext *lkups,
19641964
}
19651965
}
19661966
} while (fv);
1967-
if (list_empty(fv_list))
1967+
if (list_empty(fv_list)) {
1968+
dev_warn(ice_hw_to_dev(hw), "Required profiles not found in currently loaded DDP package");
19681969
return -EIO;
1970+
}
1971+
19691972
return 0;
19701973

19711974
err:

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum ice_protocol_type {
4343
ICE_NVGRE,
4444
ICE_GTP,
4545
ICE_GTP_NO_PAY,
46+
ICE_PPPOE,
4647
ICE_VLAN_EX,
4748
ICE_VLAN_IN,
4849
ICE_VXLAN_GPE,
@@ -109,6 +110,7 @@ enum ice_prot_id {
109110
#define ICE_TCP_IL_HW 49
110111
#define ICE_UDP_ILOS_HW 53
111112
#define ICE_GRE_OF_HW 64
113+
#define ICE_PPPOE_HW 103
112114

113115
#define ICE_UDP_OF_HW 52 /* UDP Tunnels */
114116
#define ICE_META_DATA_ID_HW 255 /* this is used for tunnel and VLAN type */
@@ -207,6 +209,14 @@ struct ice_udp_gtp_hdr {
207209
u8 rsvrd;
208210
};
209211

212+
struct ice_pppoe_hdr {
213+
u8 rsrvd_ver_type;
214+
u8 rsrvd_code;
215+
__be16 session_id;
216+
__be16 length;
217+
__be16 ppp_prot_id; /* control and data only */
218+
};
219+
210220
struct ice_nvgre_hdr {
211221
__be16 flags;
212222
__be16 protocol;
@@ -224,6 +234,7 @@ union ice_prot_hdr {
224234
struct ice_udp_tnl_hdr tnl_hdr;
225235
struct ice_nvgre_hdr nvgre_hdr;
226236
struct ice_udp_gtp_hdr gtp_hdr;
237+
struct ice_pppoe_hdr pppoe_hdr;
227238
};
228239

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

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

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ enum {
4141
ICE_PKT_INNER_UDP = BIT(7),
4242
ICE_PKT_GTP_NOPAY = BIT(8),
4343
ICE_PKT_KMALLOC = BIT(9),
44+
ICE_PKT_PPPOE = BIT(10),
4445
};
4546

4647
struct ice_dummy_pkt_offsets {
@@ -1109,6 +1110,154 @@ ICE_DECLARE_PKT_TEMPLATE(ipv6_gtp) = {
11091110
0x00, 0x00,
11101111
};
11111112

1113+
ICE_DECLARE_PKT_OFFSETS(pppoe_ipv4_tcp) = {
1114+
{ ICE_MAC_OFOS, 0 },
1115+
{ ICE_ETYPE_OL, 12 },
1116+
{ ICE_PPPOE, 14 },
1117+
{ ICE_IPV4_OFOS, 22 },
1118+
{ ICE_TCP_IL, 42 },
1119+
{ ICE_PROTOCOL_LAST, 0 },
1120+
};
1121+
1122+
ICE_DECLARE_PKT_TEMPLATE(pppoe_ipv4_tcp) = {
1123+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1124+
0x00, 0x00, 0x00, 0x00,
1125+
0x00, 0x00, 0x00, 0x00,
1126+
1127+
0x88, 0x64, /* ICE_ETYPE_OL 12 */
1128+
1129+
0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 14 */
1130+
0x00, 0x16,
1131+
1132+
0x00, 0x21, /* PPP Link Layer 20 */
1133+
1134+
0x45, 0x00, 0x00, 0x28, /* ICE_IPV4_OFOS 22 */
1135+
0x00, 0x01, 0x00, 0x00,
1136+
0x00, 0x06, 0x00, 0x00,
1137+
0x00, 0x00, 0x00, 0x00,
1138+
0x00, 0x00, 0x00, 0x00,
1139+
1140+
0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 42 */
1141+
0x00, 0x00, 0x00, 0x00,
1142+
0x00, 0x00, 0x00, 0x00,
1143+
0x50, 0x00, 0x00, 0x00,
1144+
0x00, 0x00, 0x00, 0x00,
1145+
1146+
0x00, 0x00, /* 2 bytes for 4 bytes alignment */
1147+
};
1148+
1149+
ICE_DECLARE_PKT_OFFSETS(pppoe_ipv4_udp) = {
1150+
{ ICE_MAC_OFOS, 0 },
1151+
{ ICE_ETYPE_OL, 12 },
1152+
{ ICE_PPPOE, 14 },
1153+
{ ICE_IPV4_OFOS, 22 },
1154+
{ ICE_UDP_ILOS, 42 },
1155+
{ ICE_PROTOCOL_LAST, 0 },
1156+
};
1157+
1158+
ICE_DECLARE_PKT_TEMPLATE(pppoe_ipv4_udp) = {
1159+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1160+
0x00, 0x00, 0x00, 0x00,
1161+
0x00, 0x00, 0x00, 0x00,
1162+
1163+
0x88, 0x64, /* ICE_ETYPE_OL 12 */
1164+
1165+
0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 14 */
1166+
0x00, 0x16,
1167+
1168+
0x00, 0x21, /* PPP Link Layer 20 */
1169+
1170+
0x45, 0x00, 0x00, 0x1c, /* ICE_IPV4_OFOS 22 */
1171+
0x00, 0x01, 0x00, 0x00,
1172+
0x00, 0x11, 0x00, 0x00,
1173+
0x00, 0x00, 0x00, 0x00,
1174+
0x00, 0x00, 0x00, 0x00,
1175+
1176+
0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 42 */
1177+
0x00, 0x08, 0x00, 0x00,
1178+
1179+
0x00, 0x00, /* 2 bytes for 4 bytes alignment */
1180+
};
1181+
1182+
ICE_DECLARE_PKT_OFFSETS(pppoe_ipv6_tcp) = {
1183+
{ ICE_MAC_OFOS, 0 },
1184+
{ ICE_ETYPE_OL, 12 },
1185+
{ ICE_PPPOE, 14 },
1186+
{ ICE_IPV6_OFOS, 22 },
1187+
{ ICE_TCP_IL, 62 },
1188+
{ ICE_PROTOCOL_LAST, 0 },
1189+
};
1190+
1191+
ICE_DECLARE_PKT_TEMPLATE(pppoe_ipv6_tcp) = {
1192+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1193+
0x00, 0x00, 0x00, 0x00,
1194+
0x00, 0x00, 0x00, 0x00,
1195+
1196+
0x88, 0x64, /* ICE_ETYPE_OL 12 */
1197+
1198+
0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 14 */
1199+
0x00, 0x2a,
1200+
1201+
0x00, 0x57, /* PPP Link Layer 20 */
1202+
1203+
0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 22 */
1204+
0x00, 0x14, 0x06, 0x00, /* Next header is TCP */
1205+
0x00, 0x00, 0x00, 0x00,
1206+
0x00, 0x00, 0x00, 0x00,
1207+
0x00, 0x00, 0x00, 0x00,
1208+
0x00, 0x00, 0x00, 0x00,
1209+
0x00, 0x00, 0x00, 0x00,
1210+
0x00, 0x00, 0x00, 0x00,
1211+
0x00, 0x00, 0x00, 0x00,
1212+
0x00, 0x00, 0x00, 0x00,
1213+
1214+
0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 62 */
1215+
0x00, 0x00, 0x00, 0x00,
1216+
0x00, 0x00, 0x00, 0x00,
1217+
0x50, 0x00, 0x00, 0x00,
1218+
0x00, 0x00, 0x00, 0x00,
1219+
1220+
0x00, 0x00, /* 2 bytes for 4 bytes alignment */
1221+
};
1222+
1223+
ICE_DECLARE_PKT_OFFSETS(pppoe_ipv6_udp) = {
1224+
{ ICE_MAC_OFOS, 0 },
1225+
{ ICE_ETYPE_OL, 12 },
1226+
{ ICE_PPPOE, 14 },
1227+
{ ICE_IPV6_OFOS, 22 },
1228+
{ ICE_UDP_ILOS, 62 },
1229+
{ ICE_PROTOCOL_LAST, 0 },
1230+
};
1231+
1232+
ICE_DECLARE_PKT_TEMPLATE(pppoe_ipv6_udp) = {
1233+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1234+
0x00, 0x00, 0x00, 0x00,
1235+
0x00, 0x00, 0x00, 0x00,
1236+
1237+
0x88, 0x64, /* ICE_ETYPE_OL 12 */
1238+
1239+
0x11, 0x00, 0x00, 0x00, /* ICE_PPPOE 14 */
1240+
0x00, 0x2a,
1241+
1242+
0x00, 0x57, /* PPP Link Layer 20 */
1243+
1244+
0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 22 */
1245+
0x00, 0x08, 0x11, 0x00, /* Next header UDP*/
1246+
0x00, 0x00, 0x00, 0x00,
1247+
0x00, 0x00, 0x00, 0x00,
1248+
0x00, 0x00, 0x00, 0x00,
1249+
0x00, 0x00, 0x00, 0x00,
1250+
0x00, 0x00, 0x00, 0x00,
1251+
0x00, 0x00, 0x00, 0x00,
1252+
0x00, 0x00, 0x00, 0x00,
1253+
0x00, 0x00, 0x00, 0x00,
1254+
1255+
0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 62 */
1256+
0x00, 0x08, 0x00, 0x00,
1257+
1258+
0x00, 0x00, /* 2 bytes for 4 bytes alignment */
1259+
};
1260+
11121261
static const struct ice_dummy_pkt_profile ice_dummy_pkt_profiles[] = {
11131262
ICE_PKT_PROFILE(ipv6_gtp, ICE_PKT_TUN_GTPU | ICE_PKT_OUTER_IPV6 |
11141263
ICE_PKT_GTP_NOPAY),
@@ -1135,6 +1284,11 @@ static const struct ice_dummy_pkt_profile ice_dummy_pkt_profiles[] = {
11351284
ICE_PKT_PROFILE(ipv4_gtpu_ipv4_tcp, ICE_PKT_TUN_GTPU),
11361285
ICE_PKT_PROFILE(ipv6_gtp, ICE_PKT_TUN_GTPC | ICE_PKT_OUTER_IPV6),
11371286
ICE_PKT_PROFILE(ipv4_gtpu_ipv4, ICE_PKT_TUN_GTPC),
1287+
ICE_PKT_PROFILE(pppoe_ipv6_udp, ICE_PKT_PPPOE | ICE_PKT_OUTER_IPV6 |
1288+
ICE_PKT_INNER_UDP),
1289+
ICE_PKT_PROFILE(pppoe_ipv6_tcp, ICE_PKT_PPPOE | ICE_PKT_OUTER_IPV6),
1290+
ICE_PKT_PROFILE(pppoe_ipv4_udp, ICE_PKT_PPPOE | ICE_PKT_INNER_UDP),
1291+
ICE_PKT_PROFILE(pppoe_ipv4_tcp, ICE_PKT_PPPOE),
11381292
ICE_PKT_PROFILE(gre_ipv6_tcp, ICE_PKT_TUN_NVGRE | ICE_PKT_INNER_IPV6 |
11391293
ICE_PKT_INNER_TCP),
11401294
ICE_PKT_PROFILE(gre_tcp, ICE_PKT_TUN_NVGRE | ICE_PKT_INNER_TCP),
@@ -4480,6 +4634,7 @@ static const struct ice_prot_ext_tbl_entry ice_prot_ext[ICE_PROTOCOL_LAST] = {
44804634
{ ICE_NVGRE, { 0, 2, 4, 6 } },
44814635
{ ICE_GTP, { 8, 10, 12, 14, 16, 18, 20, 22 } },
44824636
{ ICE_GTP_NO_PAY, { 8, 10, 12, 14 } },
4637+
{ ICE_PPPOE, { 0, 2, 4, 6 } },
44834638
{ ICE_VLAN_EX, { 2, 0 } },
44844639
{ ICE_VLAN_IN, { 2, 0 } },
44854640
};
@@ -4502,6 +4657,7 @@ static struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = {
45024657
{ ICE_NVGRE, ICE_GRE_OF_HW },
45034658
{ ICE_GTP, ICE_UDP_OF_HW },
45044659
{ ICE_GTP_NO_PAY, ICE_UDP_ILOS_HW },
4660+
{ ICE_PPPOE, ICE_PPPOE_HW },
45054661
{ ICE_VLAN_EX, ICE_VLAN_OF_HW },
45064662
{ ICE_VLAN_IN, ICE_VLAN_OL_HW },
45074663
};
@@ -5580,6 +5736,12 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
55805736
match |= ICE_PKT_INNER_IPV6;
55815737
else if (lkups[i].type == ICE_GTP_NO_PAY)
55825738
match |= ICE_PKT_GTP_NOPAY;
5739+
else if (lkups[i].type == ICE_PPPOE) {
5740+
match |= ICE_PKT_PPPOE;
5741+
if (lkups[i].h_u.pppoe_hdr.ppp_prot_id ==
5742+
htons(PPP_IPV6))
5743+
match |= ICE_PKT_OUTER_IPV6;
5744+
}
55835745
}
55845746

55855747
while (ret->match && (match & ret->match) != ret->match)
@@ -5677,6 +5839,9 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
56775839
case ICE_GTP:
56785840
len = sizeof(struct ice_udp_gtp_hdr);
56795841
break;
5842+
case ICE_PPPOE:
5843+
len = sizeof(struct ice_pppoe_hdr);
5844+
break;
56805845
default:
56815846
return -EINVAL;
56825847
}

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

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ ice_tc_count_lkups(u32 flags, struct ice_tc_flower_lyr_2_4_hdrs *headers,
5454
if (flags & ICE_TC_FLWR_FIELD_CVLAN)
5555
lkups_cnt++;
5656

57+
/* are PPPoE options specified? */
58+
if (flags & (ICE_TC_FLWR_FIELD_PPPOE_SESSID |
59+
ICE_TC_FLWR_FIELD_PPP_PROTO))
60+
lkups_cnt++;
61+
5762
/* are IPv[4|6] fields specified? */
5863
if (flags & (ICE_TC_FLWR_FIELD_DEST_IPV4 | ICE_TC_FLWR_FIELD_SRC_IPV4 |
5964
ICE_TC_FLWR_FIELD_DEST_IPV6 | ICE_TC_FLWR_FIELD_SRC_IPV6))
@@ -350,6 +355,28 @@ ice_tc_fill_rules(struct ice_hw *hw, u32 flags,
350355
i++;
351356
}
352357

358+
if (flags & (ICE_TC_FLWR_FIELD_PPPOE_SESSID |
359+
ICE_TC_FLWR_FIELD_PPP_PROTO)) {
360+
struct ice_pppoe_hdr *vals, *masks;
361+
362+
vals = &list[i].h_u.pppoe_hdr;
363+
masks = &list[i].m_u.pppoe_hdr;
364+
365+
list[i].type = ICE_PPPOE;
366+
367+
if (flags & ICE_TC_FLWR_FIELD_PPPOE_SESSID) {
368+
vals->session_id = headers->pppoe_hdr.session_id;
369+
masks->session_id = cpu_to_be16(0xFFFF);
370+
}
371+
372+
if (flags & ICE_TC_FLWR_FIELD_PPP_PROTO) {
373+
vals->ppp_prot_id = headers->pppoe_hdr.ppp_proto;
374+
masks->ppp_prot_id = cpu_to_be16(0xFFFF);
375+
}
376+
377+
i++;
378+
}
379+
353380
/* copy L3 (IPv[4|6]: src, dest) address */
354381
if (flags & (ICE_TC_FLWR_FIELD_DEST_IPV4 |
355382
ICE_TC_FLWR_FIELD_SRC_IPV4)) {
@@ -693,6 +720,31 @@ ice_add_tc_flower_adv_fltr(struct ice_vsi *vsi,
693720
return ret;
694721
}
695722

723+
/**
724+
* ice_tc_set_pppoe - Parse PPPoE fields from TC flower filter
725+
* @match: Pointer to flow match structure
726+
* @fltr: Pointer to filter structure
727+
* @headers: Pointer to outer header fields
728+
* @returns PPP protocol used in filter (ppp_ses or ppp_disc)
729+
*/
730+
static u16
731+
ice_tc_set_pppoe(struct flow_match_pppoe *match,
732+
struct ice_tc_flower_fltr *fltr,
733+
struct ice_tc_flower_lyr_2_4_hdrs *headers)
734+
{
735+
if (match->mask->session_id) {
736+
fltr->flags |= ICE_TC_FLWR_FIELD_PPPOE_SESSID;
737+
headers->pppoe_hdr.session_id = match->key->session_id;
738+
}
739+
740+
if (match->mask->ppp_proto) {
741+
fltr->flags |= ICE_TC_FLWR_FIELD_PPP_PROTO;
742+
headers->pppoe_hdr.ppp_proto = match->key->ppp_proto;
743+
}
744+
745+
return be16_to_cpu(match->key->type);
746+
}
747+
696748
/**
697749
* ice_tc_set_ipv4 - Parse IPv4 addresses from TC flower filter
698750
* @match: Pointer to flow match structure
@@ -988,7 +1040,8 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,
9881040
BIT(FLOW_DISSECTOR_KEY_ENC_PORTS) |
9891041
BIT(FLOW_DISSECTOR_KEY_ENC_OPTS) |
9901042
BIT(FLOW_DISSECTOR_KEY_ENC_IP) |
991-
BIT(FLOW_DISSECTOR_KEY_PORTS))) {
1043+
BIT(FLOW_DISSECTOR_KEY_PORTS) |
1044+
BIT(FLOW_DISSECTOR_KEY_PPPOE))) {
9921045
NL_SET_ERR_MSG_MOD(fltr->extack, "Unsupported key used");
9931046
return -EOPNOTSUPP;
9941047
}
@@ -1124,6 +1177,22 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,
11241177
headers->cvlan_hdr.vlan_prio = match.key->vlan_priority;
11251178
}
11261179

1180+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PPPOE)) {
1181+
struct flow_match_pppoe match;
1182+
1183+
flow_rule_match_pppoe(rule, &match);
1184+
n_proto_key = ice_tc_set_pppoe(&match, fltr, headers);
1185+
1186+
/* If ethertype equals ETH_P_PPP_SES, n_proto might be
1187+
* overwritten by encapsulated protocol (ppp_proto field) or set
1188+
* to 0. To correct this, flow_match_pppoe provides the type
1189+
* field, which contains the actual ethertype (ETH_P_PPP_SES).
1190+
*/
1191+
headers->l2_key.n_proto = cpu_to_be16(n_proto_key);
1192+
headers->l2_mask.n_proto = cpu_to_be16(0xFFFF);
1193+
fltr->flags |= ICE_TC_FLWR_FIELD_ETH_TYPE_ID;
1194+
}
1195+
11271196
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
11281197
struct flow_match_control match;
11291198

0 commit comments

Comments
 (0)