xref: /linux/include/net/psp/functions.h (revision 659a2899a57da59f433182eba571881884d6323e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __NET_PSP_HELPERS_H
4 #define __NET_PSP_HELPERS_H
5 
6 #include <linux/skbuff.h>
7 #include <net/sock.h>
8 #include <net/psp/types.h>
9 
10 struct inet_timewait_sock;
11 
12 /* Driver-facing API */
13 struct psp_dev *
14 psp_dev_create(struct net_device *netdev, struct psp_dev_ops *psd_ops,
15 	       struct psp_dev_caps *psd_caps, void *priv_ptr);
16 void psp_dev_unregister(struct psp_dev *psd);
17 
18 /* Kernel-facing API */
19 #if IS_ENABLED(CONFIG_INET_PSP)
20 static inline void psp_sk_assoc_free(struct sock *sk) { }
21 static inline void
22 psp_twsk_init(struct inet_timewait_sock *tw, const struct sock *sk) { }
23 static inline void psp_twsk_assoc_free(struct inet_timewait_sock *tw) { }
24 static inline void
25 psp_reply_set_decrypted(struct sk_buff *skb) { }
26 
27 static inline void
28 psp_enqueue_set_decrypted(struct sock *sk, struct sk_buff *skb)
29 {
30 }
31 
32 static inline unsigned long
33 __psp_skb_coalesce_diff(const struct sk_buff *one, const struct sk_buff *two,
34 			unsigned long diffs)
35 {
36 	return diffs;
37 }
38 
39 static inline enum skb_drop_reason
40 psp_sk_rx_policy_check(struct sock *sk, struct sk_buff *skb)
41 {
42 	return 0;
43 }
44 
45 static inline enum skb_drop_reason
46 psp_twsk_rx_policy_check(struct inet_timewait_sock *tw, struct sk_buff *skb)
47 {
48 	return 0;
49 }
50 
51 static inline struct psp_assoc *psp_skb_get_assoc_rcu(struct sk_buff *skb)
52 {
53 	return NULL;
54 }
55 #else
56 static inline void psp_sk_assoc_free(struct sock *sk) { }
57 static inline void
58 psp_twsk_init(struct inet_timewait_sock *tw, const struct sock *sk) { }
59 static inline void psp_twsk_assoc_free(struct inet_timewait_sock *tw) { }
60 static inline void
61 psp_reply_set_decrypted(struct sk_buff *skb) { }
62 
63 static inline void
64 psp_enqueue_set_decrypted(struct sock *sk, struct sk_buff *skb) { }
65 
66 static inline unsigned long
67 __psp_skb_coalesce_diff(const struct sk_buff *one, const struct sk_buff *two,
68 			unsigned long diffs)
69 {
70 	return diffs;
71 }
72 
73 static inline enum skb_drop_reason
74 psp_sk_rx_policy_check(struct sock *sk, struct sk_buff *skb)
75 {
76 	return 0;
77 }
78 
79 static inline enum skb_drop_reason
80 psp_twsk_rx_policy_check(struct inet_timewait_sock *tw, struct sk_buff *skb)
81 {
82 	return 0;
83 }
84 
85 static inline struct psp_assoc *psp_skb_get_assoc_rcu(struct sk_buff *skb)
86 {
87 	return NULL;
88 }
89 #endif
90 
91 static inline unsigned long
92 psp_skb_coalesce_diff(const struct sk_buff *one, const struct sk_buff *two)
93 {
94 	return __psp_skb_coalesce_diff(one, two, 0);
95 }
96 
97 #endif /* __NET_PSP_HELPERS_H */
98