0001
0002 #ifndef __NET_TC_SAMPLE_H
0003 #define __NET_TC_SAMPLE_H
0004
0005 #include <net/act_api.h>
0006 #include <linux/tc_act/tc_sample.h>
0007 #include <net/psample.h>
0008
0009 struct tcf_sample {
0010 struct tc_action common;
0011 u32 rate;
0012 bool truncate;
0013 u32 trunc_size;
0014 struct psample_group __rcu *psample_group;
0015 u32 psample_group_num;
0016 struct list_head tcfm_list;
0017 };
0018 #define to_sample(a) ((struct tcf_sample *)a)
0019
0020 static inline bool is_tcf_sample(const struct tc_action *a)
0021 {
0022 #ifdef CONFIG_NET_CLS_ACT
0023 return a->ops && a->ops->id == TCA_ID_SAMPLE;
0024 #else
0025 return false;
0026 #endif
0027 }
0028
0029 static inline __u32 tcf_sample_rate(const struct tc_action *a)
0030 {
0031 return to_sample(a)->rate;
0032 }
0033
0034 static inline bool tcf_sample_truncate(const struct tc_action *a)
0035 {
0036 return to_sample(a)->truncate;
0037 }
0038
0039 static inline int tcf_sample_trunc_size(const struct tc_action *a)
0040 {
0041 return to_sample(a)->trunc_size;
0042 }
0043
0044 #endif