1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <uapi/linux/if_ether.h>
6 #include <net/dst_metadata.h>
7 #include <linux/netdevice.h>
8 #include <uapi/linux/ipv6.h>
9 #include <net/udp_tunnel.h>
10 #include <uapi/linux/udp.h>
11 #include <uapi/linux/ip.h>
12 #include <linux/string.h>
13 #include <linux/types.h>
14 #include <linux/bits.h>
16 #define PFCP_PORT 8805
18 /* PFCP protocol header */
22 __be16 message_length
;
25 /* PFCP header flags */
26 #define PFCP_SEID_FLAG BIT(0)
27 #define PFCP_MP_FLAG BIT(1)
29 #define PFCP_VERSION_MASK GENMASK(4, 0)
31 #define PFCP_HLEN (sizeof(struct udphdr) + sizeof(struct pfcphdr))
33 /* PFCP node related messages */
39 /* PFCP session related messages */
40 struct pfcphdr_session
{
43 #ifdef __LITTLE_ENDIAN_BITFIELD
44 u8 message_priority
:4,
46 #elif defined(__BIG_ENDIAN_BITFIELD)
50 #error "Please fix <asm/byteorder>"
54 struct pfcp_metadata
{
61 PFCP_TYPE_SESSION
= 1,
64 #define PFCP_HEADROOM (sizeof(struct iphdr) + sizeof(struct udphdr) + \
65 sizeof(struct pfcphdr) + sizeof(struct ethhdr))
66 #define PFCP6_HEADROOM (sizeof(struct ipv6hdr) + sizeof(struct udphdr) + \
67 sizeof(struct pfcphdr) + sizeof(struct ethhdr))
69 static inline struct pfcphdr
*pfcp_hdr(struct sk_buff
*skb
)
71 return (struct pfcphdr
*)(udp_hdr(skb
) + 1);
74 static inline struct pfcphdr_node
*pfcp_hdr_node(struct sk_buff
*skb
)
76 return (struct pfcphdr_node
*)(pfcp_hdr(skb
) + 1);
79 static inline struct pfcphdr_session
*pfcp_hdr_session(struct sk_buff
*skb
)
81 return (struct pfcphdr_session
*)(pfcp_hdr(skb
) + 1);
84 static inline bool netif_is_pfcp(const struct net_device
*dev
)
86 return dev
->rtnl_link_ops
&&
87 !strcmp(dev
->rtnl_link_ops
->kind
, "pfcp");