Skip to content

Commit d823265

Browse files
committed
Merge branch 'ice-pfcp-filter'
Alexander Lobakin says: ==================== ice: add PFCP filter support Add support for creating PFCP filters in switchdev mode. Add pfcp module that allows to create a PFCP-type netdev. The netdev then can be passed to tc when creating a filter to indicate that PFCP filter should be created. To add a PFCP filter, a special netdev must be created and passed to tc command: ip link add pfcp0 type pfcp tc filter add dev eth0 ingress prio 1 flower pfcp_opts \ 1:12ab/ff:fffffffffffffff0 skip_hw action mirred egress redirect \ dev pfcp0 Changes in iproute2 [1] are required to use pfcp_opts in tc. ICE COMMS package is required as it contains PFCP profiles. Part of this patchset modifies IP_TUNNEL_*_OPTs, which were previously stored in a __be16. All possible values have already been used, making it impossible to add new ones. * 1-3: add new bitmap_{read,write}(), which is used later in the IP tunnel flags code (from Alexander's ARM64 MTE series[2]); * 4-14: some bitmap code preparations also used later in IP tunnels; * 15-17: convert IP tunnel flags from __be16 to a bitmap; * 18-21: add PFCP module and support for it in ice. [1] https://lore.kernel.org/netdev/20230614091758.11180-1-marcin.szycik@linux.intel.com [2] https://lore.kernel.org/linux-kernel/20231218124033.551770-1-glider@google.com ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents d79b28f + 784feaa commit d823265

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1988
-624
lines changed

drivers/md/dm-clone-metadata.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,6 @@ static void __destroy_persistent_data_structures(struct dm_clone_metadata *cmd)
465465

466466
/*---------------------------------------------------------------------------*/
467467

468-
static size_t bitmap_size(unsigned long nr_bits)
469-
{
470-
return BITS_TO_LONGS(nr_bits) * sizeof(long);
471-
}
472-
473468
static int __dirty_map_init(struct dirty_map *dmap, unsigned long nr_words,
474469
unsigned long nr_regions)
475470
{

drivers/net/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,19 @@ config GTP
290290
To compile this drivers as a module, choose M here: the module
291291
will be called gtp.
292292

293+
config PFCP
294+
tristate "Packet Forwarding Control Protocol (PFCP)"
295+
depends on INET
296+
select NET_UDP_TUNNEL
297+
help
298+
This allows one to create PFCP virtual interfaces that allows to
299+
set up software and hardware offload of PFCP packets.
300+
Note that this module does not support PFCP protocol in the kernel space.
301+
There is no support for parsing any PFCP messages.
302+
303+
To compile this drivers as a module, choose M here: the module
304+
will be called pfcp.
305+
293306
config AMT
294307
tristate "Automatic Multicast Tunneling (AMT)"
295308
depends on INET && IP_MULTICAST

drivers/net/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ obj-$(CONFIG_GENEVE) += geneve.o
3838
obj-$(CONFIG_BAREUDP) += bareudp.o
3939
obj-$(CONFIG_GTP) += gtp.o
4040
obj-$(CONFIG_NLMON) += nlmon.o
41+
obj-$(CONFIG_PFCP) += pfcp.o
4142
obj-$(CONFIG_NET_VRF) += vrf.o
4243
obj-$(CONFIG_VSOCKMON) += vsockmon.o
4344
obj-$(CONFIG_MHI_NET) += mhi_net.o

drivers/net/bareudp.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct bareudp_dev {
6161
static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
6262
{
6363
struct metadata_dst *tun_dst = NULL;
64+
IP_TUNNEL_DECLARE_FLAGS(key) = { };
6465
struct bareudp_dev *bareudp;
6566
unsigned short family;
6667
unsigned int len;
@@ -137,7 +138,10 @@ static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
137138
bareudp->dev->stats.rx_dropped++;
138139
goto drop;
139140
}
140-
tun_dst = udp_tun_rx_dst(skb, family, TUNNEL_KEY, 0, 0);
141+
142+
__set_bit(IP_TUNNEL_KEY_BIT, key);
143+
144+
tun_dst = udp_tun_rx_dst(skb, family, key, 0, 0);
141145
if (!tun_dst) {
142146
bareudp->dev->stats.rx_dropped++;
143147
goto drop;
@@ -285,10 +289,10 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
285289
struct bareudp_dev *bareudp,
286290
const struct ip_tunnel_info *info)
287291
{
292+
bool udp_sum = test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags);
288293
bool xnet = !net_eq(bareudp->net, dev_net(bareudp->dev));
289294
bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
290295
struct socket *sock = rcu_dereference(bareudp->sock);
291-
bool udp_sum = !!(info->key.tun_flags & TUNNEL_CSUM);
292296
const struct ip_tunnel_key *key = &info->key;
293297
struct rtable *rt;
294298
__be16 sport, df;
@@ -316,7 +320,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
316320

317321
tos = ip_tunnel_ecn_encap(key->tos, ip_hdr(skb), skb);
318322
ttl = key->ttl;
319-
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
323+
df = test_bit(IP_TUNNEL_DONT_FRAGMENT_BIT, key->tun_flags) ?
324+
htons(IP_DF) : 0;
320325
skb_scrub_packet(skb, xnet);
321326

322327
err = -ENOSPC;
@@ -338,7 +343,8 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
338343
udp_tunnel_xmit_skb(rt, sock->sk, skb, saddr, info->key.u.ipv4.dst,
339344
tos, ttl, df, sport, bareudp->port,
340345
!net_eq(bareudp->net, dev_net(bareudp->dev)),
341-
!(info->key.tun_flags & TUNNEL_CSUM));
346+
!test_bit(IP_TUNNEL_CSUM_BIT,
347+
info->key.tun_flags));
342348
return 0;
343349

344350
free_dst:
@@ -350,10 +356,10 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
350356
struct bareudp_dev *bareudp,
351357
const struct ip_tunnel_info *info)
352358
{
359+
bool udp_sum = test_bit(IP_TUNNEL_CSUM_BIT, info->key.tun_flags);
353360
bool xnet = !net_eq(bareudp->net, dev_net(bareudp->dev));
354361
bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
355362
struct socket *sock = rcu_dereference(bareudp->sock);
356-
bool udp_sum = !!(info->key.tun_flags & TUNNEL_CSUM);
357363
const struct ip_tunnel_key *key = &info->key;
358364
struct dst_entry *dst = NULL;
359365
struct in6_addr saddr, daddr;
@@ -402,7 +408,8 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
402408
udp_tunnel6_xmit_skb(dst, sock->sk, skb, dev,
403409
&saddr, &daddr, prio, ttl,
404410
info->key.label, sport, bareudp->port,
405-
!(info->key.tun_flags & TUNNEL_CSUM));
411+
!test_bit(IP_TUNNEL_CSUM_BIT,
412+
info->key.tun_flags));
406413
return 0;
407414

408415
free_dst:

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,12 @@ static bool ice_is_gtp_c_profile(u16 prof_idx)
721721
}
722722
}
723723

724+
static bool ice_is_pfcp_profile(u16 prof_idx)
725+
{
726+
return prof_idx >= ICE_PROFID_IPV4_PFCP_NODE &&
727+
prof_idx <= ICE_PROFID_IPV6_PFCP_SESSION;
728+
}
729+
724730
/**
725731
* ice_get_sw_prof_type - determine switch profile type
726732
* @hw: pointer to the HW structure
@@ -738,6 +744,9 @@ static enum ice_prof_type ice_get_sw_prof_type(struct ice_hw *hw,
738744
if (ice_is_gtp_u_profile(prof_idx))
739745
return ICE_PROF_TUN_GTPU;
740746

747+
if (ice_is_pfcp_profile(prof_idx))
748+
return ICE_PROF_TUN_PFCP;
749+
741750
for (i = 0; i < hw->blk[ICE_BLK_SW].es.fvw; i++) {
742751
/* UDP tunnel will have UDP_OF protocol ID and VNI offset */
743752
if (fv->ew[i].prot_id == (u8)ICE_PROT_UDP_OF &&

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ enum ice_tunnel_type {
9393
TNL_GRETAP,
9494
TNL_GTPC,
9595
TNL_GTPU,
96+
TNL_PFCP,
9697
__TNL_TYPE_CNT,
9798
TNL_LAST = 0xFF,
9899
TNL_ALL = 0xFF,
@@ -358,7 +359,8 @@ enum ice_prof_type {
358359
ICE_PROF_TUN_GRE = 0x4,
359360
ICE_PROF_TUN_GTPU = 0x8,
360361
ICE_PROF_TUN_GTPC = 0x10,
361-
ICE_PROF_TUN_ALL = 0x1E,
362+
ICE_PROF_TUN_PFCP = 0x20,
363+
ICE_PROF_TUN_ALL = 0x3E,
362364
ICE_PROF_ALL = 0xFF,
363365
};
364366

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

Lines changed: 12 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_PFCP,
4647
ICE_PPPOE,
4748
ICE_L2TPV3,
4849
ICE_VLAN_EX,
@@ -61,6 +62,7 @@ enum ice_sw_tunnel_type {
6162
ICE_SW_TUN_NVGRE,
6263
ICE_SW_TUN_GTPU,
6364
ICE_SW_TUN_GTPC,
65+
ICE_SW_TUN_PFCP,
6466
ICE_ALL_TUNNELS /* All tunnel types including NVGRE */
6567
};
6668

@@ -202,6 +204,15 @@ struct ice_udp_gtp_hdr {
202204
u8 rsvrd;
203205
};
204206

207+
struct ice_pfcp_hdr {
208+
u8 flags;
209+
u8 msg_type;
210+
__be16 length;
211+
__be64 seid;
212+
__be32 seq;
213+
u8 spare;
214+
} __packed __aligned(__alignof__(u16));
215+
205216
struct ice_pppoe_hdr {
206217
u8 rsrvd_ver_type;
207218
u8 rsrvd_code;
@@ -418,6 +429,7 @@ union ice_prot_hdr {
418429
struct ice_udp_tnl_hdr tnl_hdr;
419430
struct ice_nvgre_hdr nvgre_hdr;
420431
struct ice_udp_gtp_hdr gtp_hdr;
432+
struct ice_pfcp_hdr pfcp_hdr;
421433
struct ice_pppoe_hdr pppoe_hdr;
422434
struct ice_l2tpv3_sess_hdr l2tpv3_sess_hdr;
423435
struct ice_hw_metadata metadata;

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

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum {
4242
ICE_PKT_KMALLOC = BIT(9),
4343
ICE_PKT_PPPOE = BIT(10),
4444
ICE_PKT_L2TPV3 = BIT(11),
45+
ICE_PKT_PFCP = BIT(12),
4546
};
4647

4748
struct ice_dummy_pkt_offsets {
@@ -1110,6 +1111,77 @@ ICE_DECLARE_PKT_TEMPLATE(ipv6_gtp) = {
11101111
0x00, 0x00,
11111112
};
11121113

1114+
ICE_DECLARE_PKT_OFFSETS(pfcp_session_ipv4) = {
1115+
{ ICE_MAC_OFOS, 0 },
1116+
{ ICE_ETYPE_OL, 12 },
1117+
{ ICE_IPV4_OFOS, 14 },
1118+
{ ICE_UDP_ILOS, 34 },
1119+
{ ICE_PFCP, 42 },
1120+
{ ICE_PROTOCOL_LAST, 0 },
1121+
};
1122+
1123+
ICE_DECLARE_PKT_TEMPLATE(pfcp_session_ipv4) = {
1124+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1125+
0x00, 0x00, 0x00, 0x00,
1126+
0x00, 0x00, 0x00, 0x00,
1127+
1128+
0x08, 0x00, /* ICE_ETYPE_OL 12 */
1129+
1130+
0x45, 0x00, 0x00, 0x2c, /* ICE_IPV4_OFOS 14 */
1131+
0x00, 0x01, 0x00, 0x00,
1132+
0x00, 0x11, 0x00, 0x00,
1133+
0x00, 0x00, 0x00, 0x00,
1134+
0x00, 0x00, 0x00, 0x00,
1135+
1136+
0x00, 0x00, 0x22, 0x65, /* ICE_UDP_ILOS 34 */
1137+
0x00, 0x18, 0x00, 0x00,
1138+
1139+
0x21, 0x01, 0x00, 0x0c, /* ICE_PFCP 42 */
1140+
0x00, 0x00, 0x00, 0x00,
1141+
0x00, 0x00, 0x00, 0x00,
1142+
0x00, 0x00, 0x00, 0x00,
1143+
1144+
0x00, 0x00, /* 2 bytes for 4 byte alignment */
1145+
};
1146+
1147+
ICE_DECLARE_PKT_OFFSETS(pfcp_session_ipv6) = {
1148+
{ ICE_MAC_OFOS, 0 },
1149+
{ ICE_ETYPE_OL, 12 },
1150+
{ ICE_IPV6_OFOS, 14 },
1151+
{ ICE_UDP_ILOS, 54 },
1152+
{ ICE_PFCP, 62 },
1153+
{ ICE_PROTOCOL_LAST, 0 },
1154+
};
1155+
1156+
ICE_DECLARE_PKT_TEMPLATE(pfcp_session_ipv6) = {
1157+
0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
1158+
0x00, 0x00, 0x00, 0x00,
1159+
0x00, 0x00, 0x00, 0x00,
1160+
1161+
0x86, 0xdd, /* ICE_ETYPE_OL 12 */
1162+
1163+
0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 14 */
1164+
0x00, 0x10, 0x11, 0x00, /* Next header UDP */
1165+
0x00, 0x00, 0x00, 0x00,
1166+
0x00, 0x00, 0x00, 0x00,
1167+
0x00, 0x00, 0x00, 0x00,
1168+
0x00, 0x00, 0x00, 0x00,
1169+
0x00, 0x00, 0x00, 0x00,
1170+
0x00, 0x00, 0x00, 0x00,
1171+
0x00, 0x00, 0x00, 0x00,
1172+
0x00, 0x00, 0x00, 0x00,
1173+
1174+
0x00, 0x00, 0x22, 0x65, /* ICE_UDP_ILOS 54 */
1175+
0x00, 0x18, 0x00, 0x00,
1176+
1177+
0x21, 0x01, 0x00, 0x0c, /* ICE_PFCP 62 */
1178+
0x00, 0x00, 0x00, 0x00,
1179+
0x00, 0x00, 0x00, 0x00,
1180+
0x00, 0x00, 0x00, 0x00,
1181+
1182+
0x00, 0x00, /* 2 bytes for 4 byte alignment */
1183+
};
1184+
11131185
ICE_DECLARE_PKT_OFFSETS(pppoe_ipv4_tcp) = {
11141186
{ ICE_MAC_OFOS, 0 },
11151187
{ ICE_ETYPE_OL, 12 },
@@ -1343,6 +1415,8 @@ static const struct ice_dummy_pkt_profile ice_dummy_pkt_profiles[] = {
13431415
ICE_PKT_PROFILE(ipv4_gtpu_ipv4_tcp, ICE_PKT_TUN_GTPU),
13441416
ICE_PKT_PROFILE(ipv6_gtp, ICE_PKT_TUN_GTPC | ICE_PKT_OUTER_IPV6),
13451417
ICE_PKT_PROFILE(ipv4_gtpu_ipv4, ICE_PKT_TUN_GTPC),
1418+
ICE_PKT_PROFILE(pfcp_session_ipv6, ICE_PKT_PFCP | ICE_PKT_OUTER_IPV6),
1419+
ICE_PKT_PROFILE(pfcp_session_ipv4, ICE_PKT_PFCP),
13461420
ICE_PKT_PROFILE(pppoe_ipv6_udp, ICE_PKT_PPPOE | ICE_PKT_OUTER_IPV6 |
13471421
ICE_PKT_INNER_UDP),
13481422
ICE_PKT_PROFILE(pppoe_ipv6_tcp, ICE_PKT_PPPOE | ICE_PKT_OUTER_IPV6),
@@ -4532,6 +4606,7 @@ static const struct ice_prot_ext_tbl_entry ice_prot_ext[ICE_PROTOCOL_LAST] = {
45324606
ICE_PROTOCOL_ENTRY(ICE_NVGRE, 0, 2, 4, 6),
45334607
ICE_PROTOCOL_ENTRY(ICE_GTP, 8, 10, 12, 14, 16, 18, 20, 22),
45344608
ICE_PROTOCOL_ENTRY(ICE_GTP_NO_PAY, 8, 10, 12, 14),
4609+
ICE_PROTOCOL_ENTRY(ICE_PFCP, 8, 10, 12, 14, 16, 18, 20, 22),
45354610
ICE_PROTOCOL_ENTRY(ICE_PPPOE, 0, 2, 4, 6),
45364611
ICE_PROTOCOL_ENTRY(ICE_L2TPV3, 0, 2, 4, 6, 8, 10),
45374612
ICE_PROTOCOL_ENTRY(ICE_VLAN_EX, 2, 0),
@@ -4565,6 +4640,7 @@ static struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = {
45654640
{ ICE_NVGRE, ICE_GRE_OF_HW },
45664641
{ ICE_GTP, ICE_UDP_OF_HW },
45674642
{ ICE_GTP_NO_PAY, ICE_UDP_ILOS_HW },
4643+
{ ICE_PFCP, ICE_UDP_ILOS_HW },
45684644
{ ICE_PPPOE, ICE_PPPOE_HW },
45694645
{ ICE_L2TPV3, ICE_L2TPV3_HW },
45704646
{ ICE_VLAN_EX, ICE_VLAN_OF_HW },
@@ -5272,6 +5348,9 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
52725348
case ICE_SW_TUN_GTPC:
52735349
prof_type = ICE_PROF_TUN_GTPC;
52745350
break;
5351+
case ICE_SW_TUN_PFCP:
5352+
prof_type = ICE_PROF_TUN_PFCP;
5353+
break;
52755354
case ICE_SW_TUN_AND_NON_TUN:
52765355
default:
52775356
prof_type = ICE_PROF_ALL;
@@ -5556,6 +5635,9 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
55565635
case ICE_SW_TUN_VXLAN:
55575636
match |= ICE_PKT_TUN_UDP;
55585637
break;
5638+
case ICE_SW_TUN_PFCP:
5639+
match |= ICE_PKT_PFCP;
5640+
break;
55595641
default:
55605642
break;
55615643
}
@@ -5696,6 +5778,9 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
56965778
case ICE_GTP:
56975779
len = sizeof(struct ice_udp_gtp_hdr);
56985780
break;
5781+
case ICE_PFCP:
5782+
len = sizeof(struct ice_pfcp_hdr);
5783+
break;
56995784
case ICE_PPPOE:
57005785
len = sizeof(struct ice_pppoe_hdr);
57015786
break;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define ICE_PROFID_IPV6_GTPC_NO_TEID 45
2323
#define ICE_PROFID_IPV6_GTPU_TEID 46
2424
#define ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER 70
25+
#define ICE_PROFID_IPV4_PFCP_NODE 79
26+
#define ICE_PROFID_IPV6_PFCP_SESSION 82
2527

2628
#define ICE_SW_RULE_VSI_LIST_SIZE(s, n) struct_size((s), vsi, (n))
2729
#define ICE_SW_RULE_RX_TX_HDR_SIZE(s, l) struct_size((s), hdr_data, (l))

0 commit comments

Comments
 (0)