1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 25c5670faSYotam Gigi #ifndef __NET_TC_SAMPLE_H 35c5670faSYotam Gigi #define __NET_TC_SAMPLE_H 45c5670faSYotam Gigi 55c5670faSYotam Gigi #include <net/act_api.h> 65c5670faSYotam Gigi #include <linux/tc_act/tc_sample.h> 75c5670faSYotam Gigi #include <net/psample.h> 85c5670faSYotam Gigi 95c5670faSYotam Gigi struct tcf_sample { 105c5670faSYotam Gigi struct tc_action common; 115c5670faSYotam Gigi u32 rate; 125c5670faSYotam Gigi bool truncate; 135c5670faSYotam Gigi u32 trunc_size; 145c5670faSYotam Gigi struct psample_group __rcu *psample_group; 155c5670faSYotam Gigi u32 psample_group_num; 165c5670faSYotam Gigi struct list_head tcfm_list; 175c5670faSYotam Gigi }; 185c5670faSYotam Gigi #define to_sample(a) ((struct tcf_sample *)a) 195c5670faSYotam Gigi is_tcf_sample(const struct tc_action * a)205c5670faSYotam Gigistatic inline bool is_tcf_sample(const struct tc_action *a) 215c5670faSYotam Gigi { 225c5670faSYotam Gigi #ifdef CONFIG_NET_CLS_ACT 23*eddd2cf1SEli Cohen return a->ops && a->ops->id == TCA_ID_SAMPLE; 245c5670faSYotam Gigi #else 255c5670faSYotam Gigi return false; 265c5670faSYotam Gigi #endif 275c5670faSYotam Gigi } 285c5670faSYotam Gigi tcf_sample_rate(const struct tc_action * a)295c5670faSYotam Gigistatic inline __u32 tcf_sample_rate(const struct tc_action *a) 305c5670faSYotam Gigi { 315c5670faSYotam Gigi return to_sample(a)->rate; 325c5670faSYotam Gigi } 335c5670faSYotam Gigi tcf_sample_truncate(const struct tc_action * a)345c5670faSYotam Gigistatic inline bool tcf_sample_truncate(const struct tc_action *a) 355c5670faSYotam Gigi { 365c5670faSYotam Gigi return to_sample(a)->truncate; 375c5670faSYotam Gigi } 385c5670faSYotam Gigi tcf_sample_trunc_size(const struct tc_action * a)395c5670faSYotam Gigistatic inline int tcf_sample_trunc_size(const struct tc_action *a) 405c5670faSYotam Gigi { 415c5670faSYotam Gigi return to_sample(a)->trunc_size; 425c5670faSYotam Gigi } 435c5670faSYotam Gigi 445c5670faSYotam Gigi #endif /* __NET_TC_SAMPLE_H */ 45