18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __NET_PSAMPLE_H
38c2ecf20Sopenharmony_ci#define __NET_PSAMPLE_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <uapi/linux/psample.h>
68c2ecf20Sopenharmony_ci#include <linux/list.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cistruct psample_group {
98c2ecf20Sopenharmony_ci	struct list_head list;
108c2ecf20Sopenharmony_ci	struct net *net;
118c2ecf20Sopenharmony_ci	u32 group_num;
128c2ecf20Sopenharmony_ci	u32 refcount;
138c2ecf20Sopenharmony_ci	u32 seq;
148c2ecf20Sopenharmony_ci	struct rcu_head rcu;
158c2ecf20Sopenharmony_ci};
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistruct psample_group *psample_group_get(struct net *net, u32 group_num);
188c2ecf20Sopenharmony_civoid psample_group_take(struct psample_group *group);
198c2ecf20Sopenharmony_civoid psample_group_put(struct psample_group *group);
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct sk_buff;
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_PSAMPLE)
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_civoid psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
268c2ecf20Sopenharmony_ci			   u32 trunc_size, int in_ifindex, int out_ifindex,
278c2ecf20Sopenharmony_ci			   u32 sample_rate);
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#else
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistatic inline void psample_sample_packet(struct psample_group *group,
328c2ecf20Sopenharmony_ci					 struct sk_buff *skb, u32 trunc_size,
338c2ecf20Sopenharmony_ci					 int in_ifindex, int out_ifindex,
348c2ecf20Sopenharmony_ci					 u32 sample_rate)
358c2ecf20Sopenharmony_ci{
368c2ecf20Sopenharmony_ci}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#endif
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#endif /* __NET_PSAMPLE_H */
41