Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef __NET_ACT_API_H |
| 3 | #define __NET_ACT_API_H |
| 4 | |
| 5 | /* |
Jamal Hadi Salim | 0b0f43f | 2016-06-05 10:41:32 -0400 | [diff] [blame] | 6 | * Public action API for classifiers/qdiscs |
| 7 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Vlad Buslov | 036bb44 | 2018-07-05 17:24:24 +0300 | [diff] [blame] | 9 | #include <linux/refcount.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <net/sch_generic.h> |
| 11 | #include <net/pkt_sched.h> |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 12 | #include <net/net_namespace.h> |
| 13 | #include <net/netns/generic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 15 | struct tcf_idrinfo { |
Cong Wang | 95278dd | 2018-10-02 12:50:19 -0700 | [diff] [blame] | 16 | struct mutex lock; |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 17 | struct idr action_idr; |
Cong Wang | 981471bd | 2019-08-25 10:01:32 -0700 | [diff] [blame] | 18 | struct net *net; |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | struct tc_action_ops; |
| 22 | |
| 23 | struct tc_action { |
| 24 | const struct tc_action_ops *ops; |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 25 | __u32 type; /* for backward compat(TCA_OLD_COMPAT) */ |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 26 | struct tcf_idrinfo *idrinfo; |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 27 | |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 28 | u32 tcfa_index; |
Vlad Buslov | 036bb44 | 2018-07-05 17:24:24 +0300 | [diff] [blame] | 29 | refcount_t tcfa_refcnt; |
| 30 | atomic_t tcfa_bindcnt; |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 31 | int tcfa_action; |
| 32 | struct tcf_t tcfa_tm; |
| 33 | struct gnet_stats_basic_packed tcfa_bstats; |
Eelco Chaudron | 28169ab | 2018-09-21 07:14:02 -0400 | [diff] [blame] | 34 | struct gnet_stats_basic_packed tcfa_bstats_hw; |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 35 | struct gnet_stats_queue tcfa_qstats; |
Eric Dumazet | 1c0d32f | 2016-12-04 09:48:16 -0800 | [diff] [blame] | 36 | struct net_rate_estimator __rcu *tcfa_rate_est; |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 37 | spinlock_t tcfa_lock; |
Eric Dumazet | 519c818 | 2015-07-06 05:18:04 -0700 | [diff] [blame] | 38 | struct gnet_stats_basic_cpu __percpu *cpu_bstats; |
Eelco Chaudron | 28169ab | 2018-09-21 07:14:02 -0400 | [diff] [blame] | 39 | struct gnet_stats_basic_cpu __percpu *cpu_bstats_hw; |
Eric Dumazet | 519c818 | 2015-07-06 05:18:04 -0700 | [diff] [blame] | 40 | struct gnet_stats_queue __percpu *cpu_qstats; |
Vlad Buslov | eec94fd | 2018-07-05 17:24:23 +0300 | [diff] [blame] | 41 | struct tc_cookie __rcu *act_cookie; |
Davide Caratti | ee3bbfe | 2019-03-20 15:00:16 +0100 | [diff] [blame] | 42 | struct tcf_chain __rcu *goto_chain; |
Vlad Buslov | e382267 | 2019-10-30 16:09:06 +0200 | [diff] [blame] | 43 | u32 tcfa_flags; |
Jakub Kicinski | 0dfb2d8 | 2020-03-19 16:26:23 -0700 | [diff] [blame] | 44 | u8 hw_stats; |
Jiri Pirko | 93a129e | 2020-03-28 16:37:43 +0100 | [diff] [blame] | 45 | u8 used_hw_stats; |
| 46 | bool used_hw_stats_valid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | }; |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 48 | #define tcf_index common.tcfa_index |
| 49 | #define tcf_refcnt common.tcfa_refcnt |
| 50 | #define tcf_bindcnt common.tcfa_bindcnt |
WANG Cong | ec0595c | 2016-07-25 16:09:42 -0700 | [diff] [blame] | 51 | #define tcf_action common.tcfa_action |
| 52 | #define tcf_tm common.tcfa_tm |
| 53 | #define tcf_bstats common.tcfa_bstats |
| 54 | #define tcf_qstats common.tcfa_qstats |
| 55 | #define tcf_rate_est common.tcfa_rate_est |
| 56 | #define tcf_lock common.tcfa_lock |
David S. Miller | e9ce1cd | 2006-08-21 23:54:55 -0700 | [diff] [blame] | 57 | |
Jakub Kicinski | 0dfb2d8 | 2020-03-19 16:26:23 -0700 | [diff] [blame] | 58 | #define TCA_ACT_HW_STATS_ANY (TCA_ACT_HW_STATS_IMMEDIATE | \ |
| 59 | TCA_ACT_HW_STATS_DELAYED) |
Jiri Pirko | 44f8658 | 2020-03-07 12:40:20 +0100 | [diff] [blame] | 60 | |
Eric Dumazet | 56e5d1c | 2015-07-06 05:18:08 -0700 | [diff] [blame] | 61 | /* Update lastuse only if needed, to avoid dirtying a cache line. |
| 62 | * We use a temp variable to avoid fetching jiffies twice. |
| 63 | */ |
| 64 | static inline void tcf_lastuse_update(struct tcf_t *tm) |
| 65 | { |
| 66 | unsigned long now = jiffies; |
| 67 | |
| 68 | if (tm->lastuse != now) |
| 69 | tm->lastuse = now; |
Jamal Hadi Salim | 53eb440 | 2016-06-06 06:32:54 -0400 | [diff] [blame] | 70 | if (unlikely(!tm->firstuse)) |
| 71 | tm->firstuse = now; |
Eric Dumazet | 56e5d1c | 2015-07-06 05:18:08 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Jamal Hadi Salim | 48d8ee1 | 2016-06-06 06:32:55 -0400 | [diff] [blame] | 74 | static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm) |
| 75 | { |
| 76 | dtm->install = jiffies_to_clock_t(jiffies - stm->install); |
| 77 | dtm->lastuse = jiffies_to_clock_t(jiffies - stm->lastuse); |
Roman Mashak | b15e626 | 2020-05-17 08:46:31 -0400 | [diff] [blame] | 78 | dtm->firstuse = stm->firstuse ? |
| 79 | jiffies_to_clock_t(jiffies - stm->firstuse) : 0; |
Jamal Hadi Salim | 48d8ee1 | 2016-06-06 06:32:55 -0400 | [diff] [blame] | 80 | dtm->expires = jiffies_to_clock_t(stm->expires); |
| 81 | } |
| 82 | |
Amir Vadai | 00175ae | 2016-03-08 12:42:31 +0200 | [diff] [blame] | 83 | #ifdef CONFIG_NET_CLS_ACT |
| 84 | |
| 85 | #define ACT_P_CREATED 1 |
| 86 | #define ACT_P_DELETED 1 |
| 87 | |
Vlad Buslov | 4a5da47 | 2019-09-13 18:28:40 +0300 | [diff] [blame] | 88 | typedef void (*tc_action_priv_destructor)(void *priv); |
| 89 | |
David S. Miller | e9ce1cd | 2006-08-21 23:54:55 -0700 | [diff] [blame] | 90 | struct tc_action_ops { |
WANG Cong | 1f747c2 | 2013-12-15 20:15:10 -0800 | [diff] [blame] | 91 | struct list_head head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | char kind[IFNAMSIZ]; |
Eli Cohen | eddd2cf | 2019-02-10 14:25:00 +0200 | [diff] [blame] | 93 | enum tca_id id; /* identifier should match kind */ |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 94 | size_t size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | struct module *owner; |
Jamal Hadi Salim | 0b0f43f | 2016-06-05 10:41:32 -0400 | [diff] [blame] | 96 | int (*act)(struct sk_buff *, const struct tc_action *, |
Paolo Abeni | 7fd4b28 | 2018-07-30 14:30:43 +0200 | [diff] [blame] | 97 | struct tcf_result *); /* called under RCU BH lock*/ |
David S. Miller | e9ce1cd | 2006-08-21 23:54:55 -0700 | [diff] [blame] | 98 | int (*dump)(struct sk_buff *, struct tc_action *, int, int); |
Cong Wang | 9a63b25 | 2017-12-05 12:53:07 -0800 | [diff] [blame] | 99 | void (*cleanup)(struct tc_action *); |
Cong Wang | f061b48 | 2018-08-29 10:15:35 -0700 | [diff] [blame] | 100 | int (*lookup)(struct net *net, struct tc_action **a, u32 index); |
Benjamin LaHaise | c1b5273 | 2013-01-14 05:15:39 +0000 | [diff] [blame] | 101 | int (*init)(struct net *net, struct nlattr *nla, |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 102 | struct nlattr *est, struct tc_action **act, int ovr, |
Davide Caratti | 85d0966 | 2019-03-20 14:59:59 +0100 | [diff] [blame] | 103 | int bind, bool rtnl_held, struct tcf_proto *tp, |
Vlad Buslov | abbb0d3 | 2019-10-30 16:09:05 +0200 | [diff] [blame] | 104 | u32 flags, struct netlink_ext_ack *extack); |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 105 | int (*walk)(struct net *, struct sk_buff *, |
Alexander Aring | 1af851558 | 2018-02-15 10:54:53 -0500 | [diff] [blame] | 106 | struct netlink_callback *, int, |
Alexander Aring | 4178010 | 2018-02-15 10:54:58 -0500 | [diff] [blame] | 107 | const struct tc_action_ops *, |
| 108 | struct netlink_ext_ack *); |
Po Liu | 4b61d3e | 2020-06-19 14:01:07 +0800 | [diff] [blame] | 109 | void (*stats_update)(struct tc_action *, u64, u64, u64, u64, bool); |
Roman Mashak | a03b91b | 2018-03-08 16:59:18 -0500 | [diff] [blame] | 110 | size_t (*get_fill_size)(const struct tc_action *act); |
Vlad Buslov | 470d506 | 2019-09-13 18:28:41 +0300 | [diff] [blame] | 111 | struct net_device *(*get_dev)(const struct tc_action *a, |
| 112 | tc_action_priv_destructor *destructor); |
Vlad Buslov | 4a5da47 | 2019-09-13 18:28:40 +0300 | [diff] [blame] | 113 | struct psample_group * |
| 114 | (*get_psample_group)(const struct tc_action *a, |
| 115 | tc_action_priv_destructor *destructor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 118 | struct tc_action_net { |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 119 | struct tcf_idrinfo *idrinfo; |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 120 | const struct tc_action_ops *ops; |
| 121 | }; |
| 122 | |
| 123 | static inline |
Cong Wang | 981471bd | 2019-08-25 10:01:32 -0700 | [diff] [blame] | 124 | int tc_action_net_init(struct net *net, struct tc_action_net *tn, |
Cong Wang | c7e460c | 2017-11-06 13:47:18 -0800 | [diff] [blame] | 125 | const struct tc_action_ops *ops) |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 126 | { |
| 127 | int err = 0; |
| 128 | |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 129 | tn->idrinfo = kmalloc(sizeof(*tn->idrinfo), GFP_KERNEL); |
| 130 | if (!tn->idrinfo) |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 131 | return -ENOMEM; |
| 132 | tn->ops = ops; |
Cong Wang | 981471bd | 2019-08-25 10:01:32 -0700 | [diff] [blame] | 133 | tn->idrinfo->net = net; |
Cong Wang | 95278dd | 2018-10-02 12:50:19 -0700 | [diff] [blame] | 134 | mutex_init(&tn->idrinfo->lock); |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 135 | idr_init(&tn->idrinfo->action_idr); |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 136 | return err; |
| 137 | } |
| 138 | |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 139 | void tcf_idrinfo_destroy(const struct tc_action_ops *ops, |
| 140 | struct tcf_idrinfo *idrinfo); |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 141 | |
Cong Wang | 039af9c | 2017-12-11 15:35:03 -0800 | [diff] [blame] | 142 | static inline void tc_action_net_exit(struct list_head *net_list, |
| 143 | unsigned int id) |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 144 | { |
Cong Wang | 039af9c | 2017-12-11 15:35:03 -0800 | [diff] [blame] | 145 | struct net *net; |
| 146 | |
Cong Wang | a159d3c | 2017-11-01 10:23:49 -0700 | [diff] [blame] | 147 | rtnl_lock(); |
Cong Wang | 039af9c | 2017-12-11 15:35:03 -0800 | [diff] [blame] | 148 | list_for_each_entry(net, net_list, exit_list) { |
| 149 | struct tc_action_net *tn = net_generic(net, id); |
| 150 | |
| 151 | tcf_idrinfo_destroy(tn->ops, tn->idrinfo); |
| 152 | kfree(tn->idrinfo); |
| 153 | } |
Cong Wang | a159d3c | 2017-11-01 10:23:49 -0700 | [diff] [blame] | 154 | rtnl_unlock(); |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb, |
| 158 | struct netlink_callback *cb, int type, |
Alexander Aring | b362014 | 2018-02-15 10:54:59 -0500 | [diff] [blame] | 159 | const struct tc_action_ops *ops, |
| 160 | struct netlink_ext_ack *extack); |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 161 | int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index); |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 162 | int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, |
| 163 | struct tc_action **a, const struct tc_action_ops *ops, |
Vlad Buslov | e382267 | 2019-10-30 16:09:06 +0200 | [diff] [blame] | 164 | int bind, bool cpustats, u32 flags); |
| 165 | int tcf_idr_create_from_flags(struct tc_action_net *tn, u32 index, |
| 166 | struct nlattr *est, struct tc_action **a, |
| 167 | const struct tc_action_ops *ops, int bind, |
| 168 | u32 flags); |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 169 | void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a); |
David S. Miller | e9ce1cd | 2006-08-21 23:54:55 -0700 | [diff] [blame] | 170 | |
Vlad Buslov | 0190c1d | 2018-07-05 17:24:32 +0300 | [diff] [blame] | 171 | void tcf_idr_cleanup(struct tc_action_net *tn, u32 index); |
| 172 | int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index, |
| 173 | struct tc_action **a, int bind); |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 174 | int __tcf_idr_release(struct tc_action *a, bool bind, bool strict); |
Daniel Borkmann | 28e6b67 | 2015-07-29 23:35:25 +0200 | [diff] [blame] | 175 | |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 176 | static inline int tcf_idr_release(struct tc_action *a, bool bind) |
Daniel Borkmann | 28e6b67 | 2015-07-29 23:35:25 +0200 | [diff] [blame] | 177 | { |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 178 | return __tcf_idr_release(a, bind, false); |
Daniel Borkmann | 28e6b67 | 2015-07-29 23:35:25 +0200 | [diff] [blame] | 179 | } |
| 180 | |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 181 | int tcf_register_action(struct tc_action_ops *a, struct pernet_operations *ops); |
Jamal Hadi Salim | 0b0f43f | 2016-06-05 10:41:32 -0400 | [diff] [blame] | 182 | int tcf_unregister_action(struct tc_action_ops *a, |
| 183 | struct pernet_operations *ops); |
Vlad Buslov | 90b73b7 | 2018-07-05 17:24:33 +0300 | [diff] [blame] | 184 | int tcf_action_destroy(struct tc_action *actions[], int bind); |
WANG Cong | 22dc13c | 2016-08-13 22:35:00 -0700 | [diff] [blame] | 185 | int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, |
| 186 | int nr_actions, struct tcf_result *res); |
Jiri Pirko | 9fb9f25 | 2017-05-17 11:08:02 +0200 | [diff] [blame] | 187 | int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla, |
| 188 | struct nlattr *est, char *name, int ovr, int bind, |
Vlad Buslov | 90b73b7 | 2018-07-05 17:24:33 +0300 | [diff] [blame] | 189 | struct tc_action *actions[], size_t *attr_size, |
Vlad Buslov | 789871b | 2018-07-05 17:24:25 +0300 | [diff] [blame] | 190 | bool rtnl_held, struct netlink_ext_ack *extack); |
Jiri Pirko | 9fb9f25 | 2017-05-17 11:08:02 +0200 | [diff] [blame] | 191 | struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, |
| 192 | struct nlattr *nla, struct nlattr *est, |
Alexander Aring | aea0d72 | 2018-02-15 10:54:54 -0500 | [diff] [blame] | 193 | char *name, int ovr, int bind, |
Vlad Buslov | 789871b | 2018-07-05 17:24:25 +0300 | [diff] [blame] | 194 | bool rtnl_held, |
Alexander Aring | aea0d72 | 2018-02-15 10:54:54 -0500 | [diff] [blame] | 195 | struct netlink_ext_ack *extack); |
Vlad Buslov | 90b73b7 | 2018-07-05 17:24:33 +0300 | [diff] [blame] | 196 | int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int bind, |
Vlad Buslov | ca44b73 | 2020-05-15 14:40:12 +0300 | [diff] [blame] | 197 | int ref, bool terse); |
Joe Perches | 5c15257 | 2013-07-30 22:47:13 -0700 | [diff] [blame] | 198 | int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); |
| 199 | int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); |
Vlad Buslov | 5e1ad95 | 2019-10-30 16:09:01 +0200 | [diff] [blame] | 200 | |
| 201 | static inline void tcf_action_update_bstats(struct tc_action *a, |
| 202 | struct sk_buff *skb) |
| 203 | { |
Vlad Buslov | 5e174d5 | 2019-10-30 16:09:04 +0200 | [diff] [blame] | 204 | if (likely(a->cpu_bstats)) { |
| 205 | bstats_cpu_update(this_cpu_ptr(a->cpu_bstats), skb); |
| 206 | return; |
| 207 | } |
| 208 | spin_lock(&a->tcfa_lock); |
| 209 | bstats_update(&a->tcfa_bstats, skb); |
| 210 | spin_unlock(&a->tcfa_lock); |
Vlad Buslov | 26b537a | 2019-10-30 16:09:02 +0200 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | static inline void tcf_action_inc_drop_qstats(struct tc_action *a) |
| 214 | { |
Vlad Buslov | 5e174d5 | 2019-10-30 16:09:04 +0200 | [diff] [blame] | 215 | if (likely(a->cpu_qstats)) { |
| 216 | qstats_drop_inc(this_cpu_ptr(a->cpu_qstats)); |
| 217 | return; |
| 218 | } |
| 219 | spin_lock(&a->tcfa_lock); |
| 220 | qstats_drop_inc(&a->tcfa_qstats); |
| 221 | spin_unlock(&a->tcfa_lock); |
Vlad Buslov | 26b537a | 2019-10-30 16:09:02 +0200 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a) |
| 225 | { |
Vlad Buslov | 5e174d5 | 2019-10-30 16:09:04 +0200 | [diff] [blame] | 226 | if (likely(a->cpu_qstats)) { |
| 227 | qstats_overlimit_inc(this_cpu_ptr(a->cpu_qstats)); |
| 228 | return; |
| 229 | } |
| 230 | spin_lock(&a->tcfa_lock); |
| 231 | qstats_overlimit_inc(&a->tcfa_qstats); |
| 232 | spin_unlock(&a->tcfa_lock); |
Vlad Buslov | 26b537a | 2019-10-30 16:09:02 +0200 | [diff] [blame] | 233 | } |
| 234 | |
Po Liu | 4b61d3e | 2020-06-19 14:01:07 +0800 | [diff] [blame] | 235 | void tcf_action_update_stats(struct tc_action *a, u64 bytes, u64 packets, |
| 236 | u64 drops, bool hw); |
Joe Perches | 5c15257 | 2013-07-30 22:47:13 -0700 | [diff] [blame] | 237 | int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); |
Amir Vadai | 00175ae | 2016-03-08 12:42:31 +0200 | [diff] [blame] | 238 | |
Davide Caratti | 85d0966 | 2019-03-20 14:59:59 +0100 | [diff] [blame] | 239 | int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, |
| 240 | struct tcf_chain **handle, |
| 241 | struct netlink_ext_ack *newchain); |
| 242 | struct tcf_chain *tcf_action_set_ctrlact(struct tc_action *a, int action, |
| 243 | struct tcf_chain *newchain); |
WANG Cong | 2734437e | 2016-08-13 22:34:59 -0700 | [diff] [blame] | 244 | #endif /* CONFIG_NET_CLS_ACT */ |
Ido Schimmel | 86cb13e | 2016-07-25 13:12:33 +0300 | [diff] [blame] | 245 | |
Amir Vadai | 3804070 | 2016-05-13 12:55:35 +0000 | [diff] [blame] | 246 | static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, |
Po Liu | 4b61d3e | 2020-06-19 14:01:07 +0800 | [diff] [blame] | 247 | u64 packets, u64 drops, |
| 248 | u64 lastuse, bool hw) |
Amir Vadai | 3804070 | 2016-05-13 12:55:35 +0000 | [diff] [blame] | 249 | { |
WANG Cong | 2734437e | 2016-08-13 22:34:59 -0700 | [diff] [blame] | 250 | #ifdef CONFIG_NET_CLS_ACT |
Amir Vadai | 3804070 | 2016-05-13 12:55:35 +0000 | [diff] [blame] | 251 | if (!a->ops->stats_update) |
| 252 | return; |
| 253 | |
Po Liu | 4b61d3e | 2020-06-19 14:01:07 +0800 | [diff] [blame] | 254 | a->ops->stats_update(a, bytes, packets, drops, lastuse, hw); |
WANG Cong | 2734437e | 2016-08-13 22:34:59 -0700 | [diff] [blame] | 255 | #endif |
Amir Vadai | 3804070 | 2016-05-13 12:55:35 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Jiri Pirko | b3f55bd | 2017-10-11 09:41:08 +0200 | [diff] [blame] | 258 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | #endif |