Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / net / pfcp.h
blobaf14f970b80e1fae59082777cc6878f62232ee81
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _PFCP_H_
3 #define _PFCP_H_
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 */
19 struct pfcphdr {
20 u8 flags;
21 u8 message_type;
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 */
34 struct pfcphdr_node {
35 u8 seq_number[3];
36 u8 reserved;
39 /* PFCP session related messages */
40 struct pfcphdr_session {
41 __be64 seid;
42 u8 seq_number[3];
43 #ifdef __LITTLE_ENDIAN_BITFIELD
44 u8 message_priority:4,
45 reserved:4;
46 #elif defined(__BIG_ENDIAN_BITFIELD)
47 u8 reserved:4,
48 message_priprity:4;
49 #else
50 #error "Please fix <asm/byteorder>"
51 #endif
54 struct pfcp_metadata {
55 u8 type;
56 __be64 seid;
57 } __packed;
59 enum {
60 PFCP_TYPE_NODE = 0,
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");
90 #endif