Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef __NET_SCHED_GENERIC_H |
| 3 | #define __NET_SCHED_GENERIC_H |
| 4 | |
| 5 | #include <linux/netdevice.h> |
| 6 | #include <linux/types.h> |
| 7 | #include <linux/rcupdate.h> |
| 8 | #include <linux/pkt_sched.h> |
| 9 | #include <linux/pkt_cls.h> |
| 10 | #include <linux/percpu.h> |
| 11 | #include <linux/dynamic_queue_limits.h> |
| 12 | #include <linux/list.h> |
| 13 | #include <linux/refcount.h> |
| 14 | #include <linux/workqueue.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 15 | #include <linux/mutex.h> |
| 16 | #include <linux/rwsem.h> |
| 17 | #include <linux/atomic.h> |
| 18 | #include <linux/hashtable.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 19 | #include <net/gen_stats.h> |
| 20 | #include <net/rtnetlink.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 21 | #include <net/flow_offload.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 22 | |
| 23 | struct Qdisc_ops; |
| 24 | struct qdisc_walker; |
| 25 | struct tcf_walker; |
| 26 | struct module; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 27 | struct bpf_flow_keys; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 28 | |
| 29 | struct qdisc_rate_table { |
| 30 | struct tc_ratespec rate; |
| 31 | u32 data[256]; |
| 32 | struct qdisc_rate_table *next; |
| 33 | int refcnt; |
| 34 | }; |
| 35 | |
| 36 | enum qdisc_state_t { |
| 37 | __QDISC_STATE_SCHED, |
| 38 | __QDISC_STATE_DEACTIVATED, |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 39 | __QDISC_STATE_MISSED, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | struct qdisc_size_table { |
| 43 | struct rcu_head rcu; |
| 44 | struct list_head list; |
| 45 | struct tc_sizespec szopts; |
| 46 | int refcnt; |
| 47 | u16 data[]; |
| 48 | }; |
| 49 | |
| 50 | /* similar to sk_buff_head, but skb->prev pointer is undefined. */ |
| 51 | struct qdisc_skb_head { |
| 52 | struct sk_buff *head; |
| 53 | struct sk_buff *tail; |
| 54 | __u32 qlen; |
| 55 | spinlock_t lock; |
| 56 | }; |
| 57 | |
| 58 | struct Qdisc { |
| 59 | int (*enqueue)(struct sk_buff *skb, |
| 60 | struct Qdisc *sch, |
| 61 | struct sk_buff **to_free); |
| 62 | struct sk_buff * (*dequeue)(struct Qdisc *sch); |
| 63 | unsigned int flags; |
| 64 | #define TCQ_F_BUILTIN 1 |
| 65 | #define TCQ_F_INGRESS 2 |
| 66 | #define TCQ_F_CAN_BYPASS 4 |
| 67 | #define TCQ_F_MQROOT 8 |
| 68 | #define TCQ_F_ONETXQUEUE 0x10 /* dequeue_skb() can assume all skbs are for |
| 69 | * q->dev_queue : It can test |
| 70 | * netif_xmit_frozen_or_stopped() before |
| 71 | * dequeueing next packet. |
| 72 | * Its true for MQ/MQPRIO slaves, or non |
| 73 | * multiqueue device. |
| 74 | */ |
| 75 | #define TCQ_F_WARN_NONWC (1 << 16) |
| 76 | #define TCQ_F_CPUSTATS 0x20 /* run using percpu statistics */ |
| 77 | #define TCQ_F_NOPARENT 0x40 /* root of its hierarchy : |
| 78 | * qdisc_tree_decrease_qlen() should stop. |
| 79 | */ |
| 80 | #define TCQ_F_INVISIBLE 0x80 /* invisible by default in dump */ |
| 81 | #define TCQ_F_NOLOCK 0x100 /* qdisc does not require locking */ |
| 82 | #define TCQ_F_OFFLOADED 0x200 /* qdisc is offloaded to HW */ |
| 83 | u32 limit; |
| 84 | const struct Qdisc_ops *ops; |
| 85 | struct qdisc_size_table __rcu *stab; |
| 86 | struct hlist_node hash; |
| 87 | u32 handle; |
| 88 | u32 parent; |
| 89 | |
| 90 | struct netdev_queue *dev_queue; |
| 91 | |
| 92 | struct net_rate_estimator __rcu *rate_est; |
| 93 | struct gnet_stats_basic_cpu __percpu *cpu_bstats; |
| 94 | struct gnet_stats_queue __percpu *cpu_qstats; |
| 95 | int padded; |
| 96 | refcount_t refcnt; |
| 97 | |
| 98 | /* |
| 99 | * For performance sake on SMP, we put highly modified fields at the end |
| 100 | */ |
| 101 | struct sk_buff_head gso_skb ____cacheline_aligned_in_smp; |
| 102 | struct qdisc_skb_head q; |
| 103 | struct gnet_stats_basic_packed bstats; |
| 104 | seqcount_t running; |
| 105 | struct gnet_stats_queue qstats; |
| 106 | unsigned long state; |
| 107 | struct Qdisc *next_sched; |
| 108 | struct sk_buff_head skb_bad_txq; |
| 109 | |
| 110 | spinlock_t busylock ____cacheline_aligned_in_smp; |
| 111 | spinlock_t seqlock; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 112 | |
| 113 | /* for NOLOCK qdisc, true if there are no enqueued skbs */ |
| 114 | bool empty; |
| 115 | struct rcu_head rcu; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | static inline void qdisc_refcount_inc(struct Qdisc *qdisc) |
| 119 | { |
| 120 | if (qdisc->flags & TCQ_F_BUILTIN) |
| 121 | return; |
| 122 | refcount_inc(&qdisc->refcnt); |
| 123 | } |
| 124 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 125 | /* Intended to be used by unlocked users, when concurrent qdisc release is |
| 126 | * possible. |
| 127 | */ |
| 128 | |
| 129 | static inline struct Qdisc *qdisc_refcount_inc_nz(struct Qdisc *qdisc) |
| 130 | { |
| 131 | if (qdisc->flags & TCQ_F_BUILTIN) |
| 132 | return qdisc; |
| 133 | if (refcount_inc_not_zero(&qdisc->refcnt)) |
| 134 | return qdisc; |
| 135 | return NULL; |
| 136 | } |
| 137 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 138 | static inline bool qdisc_is_running(struct Qdisc *qdisc) |
| 139 | { |
| 140 | if (qdisc->flags & TCQ_F_NOLOCK) |
| 141 | return spin_is_locked(&qdisc->seqlock); |
| 142 | return (raw_read_seqcount(&qdisc->running) & 1) ? true : false; |
| 143 | } |
| 144 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 145 | static inline bool qdisc_is_percpu_stats(const struct Qdisc *q) |
| 146 | { |
| 147 | return q->flags & TCQ_F_CPUSTATS; |
| 148 | } |
| 149 | |
| 150 | static inline bool qdisc_is_empty(const struct Qdisc *qdisc) |
| 151 | { |
| 152 | if (qdisc_is_percpu_stats(qdisc)) |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 153 | return READ_ONCE(qdisc->empty); |
| 154 | return !READ_ONCE(qdisc->q.qlen); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 157 | static inline bool qdisc_run_begin(struct Qdisc *qdisc) |
| 158 | { |
| 159 | if (qdisc->flags & TCQ_F_NOLOCK) { |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 160 | if (spin_trylock(&qdisc->seqlock)) |
| 161 | goto nolock_empty; |
| 162 | |
| 163 | /* Paired with smp_mb__after_atomic() to make sure |
| 164 | * STATE_MISSED checking is synchronized with clearing |
| 165 | * in pfifo_fast_dequeue(). |
| 166 | */ |
| 167 | smp_mb__before_atomic(); |
| 168 | |
| 169 | /* If the MISSED flag is set, it means other thread has |
| 170 | * set the MISSED flag before second spin_trylock(), so |
| 171 | * we can return false here to avoid multi cpus doing |
| 172 | * the set_bit() and second spin_trylock() concurrently. |
| 173 | */ |
| 174 | if (test_bit(__QDISC_STATE_MISSED, &qdisc->state)) |
| 175 | return false; |
| 176 | |
| 177 | /* Set the MISSED flag before the second spin_trylock(), |
| 178 | * if the second spin_trylock() return false, it means |
| 179 | * other cpu holding the lock will do dequeuing for us |
| 180 | * or it will see the MISSED flag set after releasing |
| 181 | * lock and reschedule the net_tx_action() to do the |
| 182 | * dequeuing. |
| 183 | */ |
| 184 | set_bit(__QDISC_STATE_MISSED, &qdisc->state); |
| 185 | |
| 186 | /* spin_trylock() only has load-acquire semantic, so use |
| 187 | * smp_mb__after_atomic() to ensure STATE_MISSED is set |
| 188 | * before doing the second spin_trylock(). |
| 189 | */ |
| 190 | smp_mb__after_atomic(); |
| 191 | |
| 192 | /* Retry again in case other CPU may not see the new flag |
| 193 | * after it releases the lock at the end of qdisc_run_end(). |
| 194 | */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 195 | if (!spin_trylock(&qdisc->seqlock)) |
| 196 | return false; |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 197 | |
| 198 | nolock_empty: |
| 199 | WRITE_ONCE(qdisc->empty, false); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 200 | } else if (qdisc_is_running(qdisc)) { |
| 201 | return false; |
| 202 | } |
| 203 | /* Variant of write_seqcount_begin() telling lockdep a trylock |
| 204 | * was attempted. |
| 205 | */ |
| 206 | raw_write_seqcount_begin(&qdisc->running); |
| 207 | seqcount_acquire(&qdisc->running.dep_map, 0, 1, _RET_IP_); |
| 208 | return true; |
| 209 | } |
| 210 | |
| 211 | static inline void qdisc_run_end(struct Qdisc *qdisc) |
| 212 | { |
| 213 | write_seqcount_end(&qdisc->running); |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 214 | if (qdisc->flags & TCQ_F_NOLOCK) { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 215 | spin_unlock(&qdisc->seqlock); |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 216 | |
| 217 | if (unlikely(test_bit(__QDISC_STATE_MISSED, |
| 218 | &qdisc->state))) { |
| 219 | clear_bit(__QDISC_STATE_MISSED, &qdisc->state); |
| 220 | __netif_schedule(qdisc); |
| 221 | } |
| 222 | } |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | static inline bool qdisc_may_bulk(const struct Qdisc *qdisc) |
| 226 | { |
| 227 | return qdisc->flags & TCQ_F_ONETXQUEUE; |
| 228 | } |
| 229 | |
| 230 | static inline int qdisc_avail_bulklimit(const struct netdev_queue *txq) |
| 231 | { |
| 232 | #ifdef CONFIG_BQL |
| 233 | /* Non-BQL migrated drivers will return 0, too. */ |
| 234 | return dql_avail(&txq->dql); |
| 235 | #else |
| 236 | return 0; |
| 237 | #endif |
| 238 | } |
| 239 | |
| 240 | struct Qdisc_class_ops { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 241 | unsigned int flags; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 242 | /* Child qdisc manipulation */ |
| 243 | struct netdev_queue * (*select_queue)(struct Qdisc *, struct tcmsg *); |
| 244 | int (*graft)(struct Qdisc *, unsigned long cl, |
| 245 | struct Qdisc *, struct Qdisc **, |
| 246 | struct netlink_ext_ack *extack); |
| 247 | struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); |
| 248 | void (*qlen_notify)(struct Qdisc *, unsigned long); |
| 249 | |
| 250 | /* Class manipulation routines */ |
| 251 | unsigned long (*find)(struct Qdisc *, u32 classid); |
| 252 | int (*change)(struct Qdisc *, u32, u32, |
| 253 | struct nlattr **, unsigned long *, |
| 254 | struct netlink_ext_ack *); |
| 255 | int (*delete)(struct Qdisc *, unsigned long); |
| 256 | void (*walk)(struct Qdisc *, struct qdisc_walker * arg); |
| 257 | |
| 258 | /* Filter manipulation */ |
| 259 | struct tcf_block * (*tcf_block)(struct Qdisc *sch, |
| 260 | unsigned long arg, |
| 261 | struct netlink_ext_ack *extack); |
| 262 | unsigned long (*bind_tcf)(struct Qdisc *, unsigned long, |
| 263 | u32 classid); |
| 264 | void (*unbind_tcf)(struct Qdisc *, unsigned long); |
| 265 | |
| 266 | /* rtnetlink specific */ |
| 267 | int (*dump)(struct Qdisc *, unsigned long, |
| 268 | struct sk_buff *skb, struct tcmsg*); |
| 269 | int (*dump_stats)(struct Qdisc *, unsigned long, |
| 270 | struct gnet_dump *); |
| 271 | }; |
| 272 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 273 | /* Qdisc_class_ops flag values */ |
| 274 | |
| 275 | /* Implements API that doesn't require rtnl lock */ |
| 276 | enum qdisc_class_ops_flags { |
| 277 | QDISC_CLASS_OPS_DOIT_UNLOCKED = 1, |
| 278 | }; |
| 279 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 280 | struct Qdisc_ops { |
| 281 | struct Qdisc_ops *next; |
| 282 | const struct Qdisc_class_ops *cl_ops; |
| 283 | char id[IFNAMSIZ]; |
| 284 | int priv_size; |
| 285 | unsigned int static_flags; |
| 286 | |
| 287 | int (*enqueue)(struct sk_buff *skb, |
| 288 | struct Qdisc *sch, |
| 289 | struct sk_buff **to_free); |
| 290 | struct sk_buff * (*dequeue)(struct Qdisc *); |
| 291 | struct sk_buff * (*peek)(struct Qdisc *); |
| 292 | |
| 293 | int (*init)(struct Qdisc *sch, struct nlattr *arg, |
| 294 | struct netlink_ext_ack *extack); |
| 295 | void (*reset)(struct Qdisc *); |
| 296 | void (*destroy)(struct Qdisc *); |
| 297 | int (*change)(struct Qdisc *sch, |
| 298 | struct nlattr *arg, |
| 299 | struct netlink_ext_ack *extack); |
| 300 | void (*attach)(struct Qdisc *sch); |
| 301 | int (*change_tx_queue_len)(struct Qdisc *, unsigned int); |
| 302 | |
| 303 | int (*dump)(struct Qdisc *, struct sk_buff *); |
| 304 | int (*dump_stats)(struct Qdisc *, struct gnet_dump *); |
| 305 | |
| 306 | void (*ingress_block_set)(struct Qdisc *sch, |
| 307 | u32 block_index); |
| 308 | void (*egress_block_set)(struct Qdisc *sch, |
| 309 | u32 block_index); |
| 310 | u32 (*ingress_block_get)(struct Qdisc *sch); |
| 311 | u32 (*egress_block_get)(struct Qdisc *sch); |
| 312 | |
| 313 | struct module *owner; |
| 314 | }; |
| 315 | |
| 316 | |
| 317 | struct tcf_result { |
| 318 | union { |
| 319 | struct { |
| 320 | unsigned long class; |
| 321 | u32 classid; |
| 322 | }; |
| 323 | const struct tcf_proto *goto_tp; |
| 324 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 325 | /* used in the skb_tc_reinsert function */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 326 | struct { |
| 327 | bool ingress; |
| 328 | struct gnet_stats_queue *qstats; |
| 329 | }; |
| 330 | }; |
| 331 | }; |
| 332 | |
| 333 | struct tcf_chain; |
| 334 | |
| 335 | struct tcf_proto_ops { |
| 336 | struct list_head head; |
| 337 | char kind[IFNAMSIZ]; |
| 338 | |
| 339 | int (*classify)(struct sk_buff *, |
| 340 | const struct tcf_proto *, |
| 341 | struct tcf_result *); |
| 342 | int (*init)(struct tcf_proto*); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 343 | void (*destroy)(struct tcf_proto *tp, bool rtnl_held, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 344 | struct netlink_ext_ack *extack); |
| 345 | |
| 346 | void* (*get)(struct tcf_proto*, u32 handle); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 347 | void (*put)(struct tcf_proto *tp, void *f); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 348 | int (*change)(struct net *net, struct sk_buff *, |
| 349 | struct tcf_proto*, unsigned long, |
| 350 | u32 handle, struct nlattr **, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 351 | void **, bool, bool, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 352 | struct netlink_ext_ack *); |
| 353 | int (*delete)(struct tcf_proto *tp, void *arg, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 354 | bool *last, bool rtnl_held, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 355 | struct netlink_ext_ack *); |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 356 | bool (*delete_empty)(struct tcf_proto *tp); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 357 | void (*walk)(struct tcf_proto *tp, |
| 358 | struct tcf_walker *arg, bool rtnl_held); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 359 | int (*reoffload)(struct tcf_proto *tp, bool add, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 360 | flow_setup_cb_t *cb, void *cb_priv, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 361 | struct netlink_ext_ack *extack); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 362 | void (*hw_add)(struct tcf_proto *tp, |
| 363 | void *type_data); |
| 364 | void (*hw_del)(struct tcf_proto *tp, |
| 365 | void *type_data); |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 366 | void (*bind_class)(void *, u32, unsigned long, |
| 367 | void *, unsigned long); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 368 | void * (*tmplt_create)(struct net *net, |
| 369 | struct tcf_chain *chain, |
| 370 | struct nlattr **tca, |
| 371 | struct netlink_ext_ack *extack); |
| 372 | void (*tmplt_destroy)(void *tmplt_priv); |
| 373 | |
| 374 | /* rtnetlink specific */ |
| 375 | int (*dump)(struct net*, struct tcf_proto*, void *, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 376 | struct sk_buff *skb, struct tcmsg*, |
| 377 | bool); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 378 | int (*tmplt_dump)(struct sk_buff *skb, |
| 379 | struct net *net, |
| 380 | void *tmplt_priv); |
| 381 | |
| 382 | struct module *owner; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 383 | int flags; |
| 384 | }; |
| 385 | |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 386 | /* Classifiers setting TCF_PROTO_OPS_DOIT_UNLOCKED in tcf_proto_ops->flags |
| 387 | * are expected to implement tcf_proto_ops->delete_empty(), otherwise race |
| 388 | * conditions can occur when filters are inserted/deleted simultaneously. |
| 389 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 390 | enum tcf_proto_ops_flags { |
| 391 | TCF_PROTO_OPS_DOIT_UNLOCKED = 1, |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 392 | }; |
| 393 | |
| 394 | struct tcf_proto { |
| 395 | /* Fast access part */ |
| 396 | struct tcf_proto __rcu *next; |
| 397 | void __rcu *root; |
| 398 | |
| 399 | /* called under RCU BH lock*/ |
| 400 | int (*classify)(struct sk_buff *, |
| 401 | const struct tcf_proto *, |
| 402 | struct tcf_result *); |
| 403 | __be16 protocol; |
| 404 | |
| 405 | /* All the rest */ |
| 406 | u32 prio; |
| 407 | void *data; |
| 408 | const struct tcf_proto_ops *ops; |
| 409 | struct tcf_chain *chain; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 410 | /* Lock protects tcf_proto shared state and can be used by unlocked |
| 411 | * classifiers to protect their private data. |
| 412 | */ |
| 413 | spinlock_t lock; |
| 414 | bool deleting; |
| 415 | refcount_t refcnt; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 416 | struct rcu_head rcu; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 417 | struct hlist_node destroy_ht_node; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 418 | }; |
| 419 | |
| 420 | struct qdisc_skb_cb { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 421 | struct { |
| 422 | unsigned int pkt_len; |
| 423 | u16 slave_dev_queue_mapping; |
| 424 | u16 tc_classid; |
| 425 | }; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 426 | #define QDISC_CB_PRIV_LEN 20 |
| 427 | unsigned char data[QDISC_CB_PRIV_LEN]; |
| 428 | }; |
| 429 | |
| 430 | typedef void tcf_chain_head_change_t(struct tcf_proto *tp_head, void *priv); |
| 431 | |
| 432 | struct tcf_chain { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 433 | /* Protects filter_chain. */ |
| 434 | struct mutex filter_chain_lock; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 435 | struct tcf_proto __rcu *filter_chain; |
| 436 | struct list_head list; |
| 437 | struct tcf_block *block; |
| 438 | u32 index; /* chain index */ |
| 439 | unsigned int refcnt; |
| 440 | unsigned int action_refcnt; |
| 441 | bool explicitly_created; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 442 | bool flushing; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 443 | const struct tcf_proto_ops *tmplt_ops; |
| 444 | void *tmplt_priv; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 445 | struct rcu_head rcu; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 446 | }; |
| 447 | |
| 448 | struct tcf_block { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 449 | /* Lock protects tcf_block and lifetime-management data of chains |
| 450 | * attached to the block (refcnt, action_refcnt, explicitly_created). |
| 451 | */ |
| 452 | struct mutex lock; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 453 | struct list_head chain_list; |
| 454 | u32 index; /* block index for shared blocks */ |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 455 | u32 classid; /* which class this block belongs to */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 456 | refcount_t refcnt; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 457 | struct net *net; |
| 458 | struct Qdisc *q; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 459 | struct rw_semaphore cb_lock; /* protects cb_list and offload counters */ |
| 460 | struct flow_block flow_block; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 461 | struct list_head owner_list; |
| 462 | bool keep_dst; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 463 | atomic_t offloadcnt; /* Number of oddloaded filters */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 464 | unsigned int nooffloaddevcnt; /* Number of devs unable to do offload */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 465 | unsigned int lockeddevcnt; /* Number of devs that require rtnl lock. */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 466 | struct { |
| 467 | struct tcf_chain *chain; |
| 468 | struct list_head filter_chain_list; |
| 469 | } chain0; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 470 | struct rcu_head rcu; |
| 471 | DECLARE_HASHTABLE(proto_destroy_ht, 7); |
| 472 | struct mutex proto_destroy_lock; /* Lock for proto_destroy hashtable. */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 473 | }; |
| 474 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 475 | #ifdef CONFIG_PROVE_LOCKING |
| 476 | static inline bool lockdep_tcf_chain_is_locked(struct tcf_chain *chain) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 477 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 478 | return lockdep_is_held(&chain->filter_chain_lock); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 479 | } |
| 480 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 481 | static inline bool lockdep_tcf_proto_is_locked(struct tcf_proto *tp) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 482 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 483 | return lockdep_is_held(&tp->lock); |
| 484 | } |
| 485 | #else |
| 486 | static inline bool lockdep_tcf_chain_is_locked(struct tcf_block *chain) |
| 487 | { |
| 488 | return true; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 489 | } |
| 490 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 491 | static inline bool lockdep_tcf_proto_is_locked(struct tcf_proto *tp) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 492 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 493 | return true; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 494 | } |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 495 | #endif /* #ifdef CONFIG_PROVE_LOCKING */ |
| 496 | |
| 497 | #define tcf_chain_dereference(p, chain) \ |
| 498 | rcu_dereference_protected(p, lockdep_tcf_chain_is_locked(chain)) |
| 499 | |
| 500 | #define tcf_proto_dereference(p, tp) \ |
| 501 | rcu_dereference_protected(p, lockdep_tcf_proto_is_locked(tp)) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 502 | |
| 503 | static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) |
| 504 | { |
| 505 | struct qdisc_skb_cb *qcb; |
| 506 | |
| 507 | BUILD_BUG_ON(sizeof(skb->cb) < offsetof(struct qdisc_skb_cb, data) + sz); |
| 508 | BUILD_BUG_ON(sizeof(qcb->data) < sz); |
| 509 | } |
| 510 | |
| 511 | static inline int qdisc_qlen_cpu(const struct Qdisc *q) |
| 512 | { |
| 513 | return this_cpu_ptr(q->cpu_qstats)->qlen; |
| 514 | } |
| 515 | |
| 516 | static inline int qdisc_qlen(const struct Qdisc *q) |
| 517 | { |
| 518 | return q->q.qlen; |
| 519 | } |
| 520 | |
| 521 | static inline int qdisc_qlen_sum(const struct Qdisc *q) |
| 522 | { |
| 523 | __u32 qlen = q->qstats.qlen; |
| 524 | int i; |
| 525 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 526 | if (qdisc_is_percpu_stats(q)) { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 527 | for_each_possible_cpu(i) |
| 528 | qlen += per_cpu_ptr(q->cpu_qstats, i)->qlen; |
| 529 | } else { |
| 530 | qlen += q->q.qlen; |
| 531 | } |
| 532 | |
| 533 | return qlen; |
| 534 | } |
| 535 | |
| 536 | static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb) |
| 537 | { |
| 538 | return (struct qdisc_skb_cb *)skb->cb; |
| 539 | } |
| 540 | |
| 541 | static inline spinlock_t *qdisc_lock(struct Qdisc *qdisc) |
| 542 | { |
| 543 | return &qdisc->q.lock; |
| 544 | } |
| 545 | |
| 546 | static inline struct Qdisc *qdisc_root(const struct Qdisc *qdisc) |
| 547 | { |
| 548 | struct Qdisc *q = rcu_dereference_rtnl(qdisc->dev_queue->qdisc); |
| 549 | |
| 550 | return q; |
| 551 | } |
| 552 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 553 | static inline struct Qdisc *qdisc_root_bh(const struct Qdisc *qdisc) |
| 554 | { |
| 555 | return rcu_dereference_bh(qdisc->dev_queue->qdisc); |
| 556 | } |
| 557 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 558 | static inline struct Qdisc *qdisc_root_sleeping(const struct Qdisc *qdisc) |
| 559 | { |
| 560 | return qdisc->dev_queue->qdisc_sleeping; |
| 561 | } |
| 562 | |
| 563 | /* The qdisc root lock is a mechanism by which to top level |
| 564 | * of a qdisc tree can be locked from any qdisc node in the |
| 565 | * forest. This allows changing the configuration of some |
| 566 | * aspect of the qdisc tree while blocking out asynchronous |
| 567 | * qdisc access in the packet processing paths. |
| 568 | * |
| 569 | * It is only legal to do this when the root will not change |
| 570 | * on us. Otherwise we'll potentially lock the wrong qdisc |
| 571 | * root. This is enforced by holding the RTNL semaphore, which |
| 572 | * all users of this lock accessor must do. |
| 573 | */ |
| 574 | static inline spinlock_t *qdisc_root_lock(const struct Qdisc *qdisc) |
| 575 | { |
| 576 | struct Qdisc *root = qdisc_root(qdisc); |
| 577 | |
| 578 | ASSERT_RTNL(); |
| 579 | return qdisc_lock(root); |
| 580 | } |
| 581 | |
| 582 | static inline spinlock_t *qdisc_root_sleeping_lock(const struct Qdisc *qdisc) |
| 583 | { |
| 584 | struct Qdisc *root = qdisc_root_sleeping(qdisc); |
| 585 | |
| 586 | ASSERT_RTNL(); |
| 587 | return qdisc_lock(root); |
| 588 | } |
| 589 | |
| 590 | static inline seqcount_t *qdisc_root_sleeping_running(const struct Qdisc *qdisc) |
| 591 | { |
| 592 | struct Qdisc *root = qdisc_root_sleeping(qdisc); |
| 593 | |
| 594 | ASSERT_RTNL(); |
| 595 | return &root->running; |
| 596 | } |
| 597 | |
| 598 | static inline struct net_device *qdisc_dev(const struct Qdisc *qdisc) |
| 599 | { |
| 600 | return qdisc->dev_queue->dev; |
| 601 | } |
| 602 | |
| 603 | static inline void sch_tree_lock(const struct Qdisc *q) |
| 604 | { |
| 605 | spin_lock_bh(qdisc_root_sleeping_lock(q)); |
| 606 | } |
| 607 | |
| 608 | static inline void sch_tree_unlock(const struct Qdisc *q) |
| 609 | { |
| 610 | spin_unlock_bh(qdisc_root_sleeping_lock(q)); |
| 611 | } |
| 612 | |
| 613 | extern struct Qdisc noop_qdisc; |
| 614 | extern struct Qdisc_ops noop_qdisc_ops; |
| 615 | extern struct Qdisc_ops pfifo_fast_ops; |
| 616 | extern struct Qdisc_ops mq_qdisc_ops; |
| 617 | extern struct Qdisc_ops noqueue_qdisc_ops; |
| 618 | extern const struct Qdisc_ops *default_qdisc_ops; |
| 619 | static inline const struct Qdisc_ops * |
| 620 | get_default_qdisc_ops(const struct net_device *dev, int ntx) |
| 621 | { |
| 622 | return ntx < dev->real_num_tx_queues ? |
| 623 | default_qdisc_ops : &pfifo_fast_ops; |
| 624 | } |
| 625 | |
| 626 | struct Qdisc_class_common { |
| 627 | u32 classid; |
| 628 | struct hlist_node hnode; |
| 629 | }; |
| 630 | |
| 631 | struct Qdisc_class_hash { |
| 632 | struct hlist_head *hash; |
| 633 | unsigned int hashsize; |
| 634 | unsigned int hashmask; |
| 635 | unsigned int hashelems; |
| 636 | }; |
| 637 | |
| 638 | static inline unsigned int qdisc_class_hash(u32 id, u32 mask) |
| 639 | { |
| 640 | id ^= id >> 8; |
| 641 | id ^= id >> 4; |
| 642 | return id & mask; |
| 643 | } |
| 644 | |
| 645 | static inline struct Qdisc_class_common * |
| 646 | qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id) |
| 647 | { |
| 648 | struct Qdisc_class_common *cl; |
| 649 | unsigned int h; |
| 650 | |
| 651 | if (!id) |
| 652 | return NULL; |
| 653 | |
| 654 | h = qdisc_class_hash(id, hash->hashmask); |
| 655 | hlist_for_each_entry(cl, &hash->hash[h], hnode) { |
| 656 | if (cl->classid == id) |
| 657 | return cl; |
| 658 | } |
| 659 | return NULL; |
| 660 | } |
| 661 | |
| 662 | static inline int tc_classid_to_hwtc(struct net_device *dev, u32 classid) |
| 663 | { |
| 664 | u32 hwtc = TC_H_MIN(classid) - TC_H_MIN_PRIORITY; |
| 665 | |
| 666 | return (hwtc < netdev_get_num_tc(dev)) ? hwtc : -EINVAL; |
| 667 | } |
| 668 | |
| 669 | int qdisc_class_hash_init(struct Qdisc_class_hash *); |
| 670 | void qdisc_class_hash_insert(struct Qdisc_class_hash *, |
| 671 | struct Qdisc_class_common *); |
| 672 | void qdisc_class_hash_remove(struct Qdisc_class_hash *, |
| 673 | struct Qdisc_class_common *); |
| 674 | void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *); |
| 675 | void qdisc_class_hash_destroy(struct Qdisc_class_hash *); |
| 676 | |
| 677 | int dev_qdisc_change_tx_queue_len(struct net_device *dev); |
| 678 | void dev_init_scheduler(struct net_device *dev); |
| 679 | void dev_shutdown(struct net_device *dev); |
| 680 | void dev_activate(struct net_device *dev); |
| 681 | void dev_deactivate(struct net_device *dev); |
| 682 | void dev_deactivate_many(struct list_head *head); |
| 683 | struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, |
| 684 | struct Qdisc *qdisc); |
| 685 | void qdisc_reset(struct Qdisc *qdisc); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 686 | void qdisc_put(struct Qdisc *qdisc); |
| 687 | void qdisc_put_unlocked(struct Qdisc *qdisc); |
| 688 | void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, int n, int len); |
| 689 | #ifdef CONFIG_NET_SCHED |
| 690 | int qdisc_offload_dump_helper(struct Qdisc *q, enum tc_setup_type type, |
| 691 | void *type_data); |
| 692 | void qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch, |
| 693 | struct Qdisc *new, struct Qdisc *old, |
| 694 | enum tc_setup_type type, void *type_data, |
| 695 | struct netlink_ext_ack *extack); |
| 696 | #else |
| 697 | static inline int |
| 698 | qdisc_offload_dump_helper(struct Qdisc *q, enum tc_setup_type type, |
| 699 | void *type_data) |
| 700 | { |
| 701 | q->flags &= ~TCQ_F_OFFLOADED; |
| 702 | return 0; |
| 703 | } |
| 704 | |
| 705 | static inline void |
| 706 | qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch, |
| 707 | struct Qdisc *new, struct Qdisc *old, |
| 708 | enum tc_setup_type type, void *type_data, |
| 709 | struct netlink_ext_ack *extack) |
| 710 | { |
| 711 | } |
| 712 | #endif |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 713 | struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, |
| 714 | const struct Qdisc_ops *ops, |
| 715 | struct netlink_ext_ack *extack); |
| 716 | void qdisc_free(struct Qdisc *qdisc); |
| 717 | struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, |
| 718 | const struct Qdisc_ops *ops, u32 parentid, |
| 719 | struct netlink_ext_ack *extack); |
| 720 | void __qdisc_calculate_pkt_len(struct sk_buff *skb, |
| 721 | const struct qdisc_size_table *stab); |
| 722 | int skb_do_redirect(struct sk_buff *); |
| 723 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 724 | static inline bool skb_at_tc_ingress(const struct sk_buff *skb) |
| 725 | { |
| 726 | #ifdef CONFIG_NET_CLS_ACT |
| 727 | return skb->tc_at_ingress; |
| 728 | #else |
| 729 | return false; |
| 730 | #endif |
| 731 | } |
| 732 | |
| 733 | static inline bool skb_skip_tc_classify(struct sk_buff *skb) |
| 734 | { |
| 735 | #ifdef CONFIG_NET_CLS_ACT |
| 736 | if (skb->tc_skip_classify) { |
| 737 | skb->tc_skip_classify = 0; |
| 738 | return true; |
| 739 | } |
| 740 | #endif |
| 741 | return false; |
| 742 | } |
| 743 | |
| 744 | /* Reset all TX qdiscs greater than index of a device. */ |
| 745 | static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i) |
| 746 | { |
| 747 | struct Qdisc *qdisc; |
| 748 | |
| 749 | for (; i < dev->num_tx_queues; i++) { |
| 750 | qdisc = rtnl_dereference(netdev_get_tx_queue(dev, i)->qdisc); |
| 751 | if (qdisc) { |
| 752 | spin_lock_bh(qdisc_lock(qdisc)); |
| 753 | qdisc_reset(qdisc); |
| 754 | spin_unlock_bh(qdisc_lock(qdisc)); |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | static inline void qdisc_reset_all_tx(struct net_device *dev) |
| 760 | { |
| 761 | qdisc_reset_all_tx_gt(dev, 0); |
| 762 | } |
| 763 | |
| 764 | /* Are all TX queues of the device empty? */ |
| 765 | static inline bool qdisc_all_tx_empty(const struct net_device *dev) |
| 766 | { |
| 767 | unsigned int i; |
| 768 | |
| 769 | rcu_read_lock(); |
| 770 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 771 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 772 | const struct Qdisc *q = rcu_dereference(txq->qdisc); |
| 773 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 774 | if (!qdisc_is_empty(q)) { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 775 | rcu_read_unlock(); |
| 776 | return false; |
| 777 | } |
| 778 | } |
| 779 | rcu_read_unlock(); |
| 780 | return true; |
| 781 | } |
| 782 | |
| 783 | /* Are any of the TX qdiscs changing? */ |
| 784 | static inline bool qdisc_tx_changing(const struct net_device *dev) |
| 785 | { |
| 786 | unsigned int i; |
| 787 | |
| 788 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 789 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 790 | if (rcu_access_pointer(txq->qdisc) != txq->qdisc_sleeping) |
| 791 | return true; |
| 792 | } |
| 793 | return false; |
| 794 | } |
| 795 | |
| 796 | /* Is the device using the noop qdisc on all queues? */ |
| 797 | static inline bool qdisc_tx_is_noop(const struct net_device *dev) |
| 798 | { |
| 799 | unsigned int i; |
| 800 | |
| 801 | for (i = 0; i < dev->num_tx_queues; i++) { |
| 802 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
| 803 | if (rcu_access_pointer(txq->qdisc) != &noop_qdisc) |
| 804 | return false; |
| 805 | } |
| 806 | return true; |
| 807 | } |
| 808 | |
| 809 | static inline unsigned int qdisc_pkt_len(const struct sk_buff *skb) |
| 810 | { |
| 811 | return qdisc_skb_cb(skb)->pkt_len; |
| 812 | } |
| 813 | |
| 814 | /* additional qdisc xmit flags (NET_XMIT_MASK in linux/netdevice.h) */ |
| 815 | enum net_xmit_qdisc_t { |
| 816 | __NET_XMIT_STOLEN = 0x00010000, |
| 817 | __NET_XMIT_BYPASS = 0x00020000, |
| 818 | }; |
| 819 | |
| 820 | #ifdef CONFIG_NET_CLS_ACT |
| 821 | #define net_xmit_drop_count(e) ((e) & __NET_XMIT_STOLEN ? 0 : 1) |
| 822 | #else |
| 823 | #define net_xmit_drop_count(e) (1) |
| 824 | #endif |
| 825 | |
| 826 | static inline void qdisc_calculate_pkt_len(struct sk_buff *skb, |
| 827 | const struct Qdisc *sch) |
| 828 | { |
| 829 | #ifdef CONFIG_NET_SCHED |
| 830 | struct qdisc_size_table *stab = rcu_dereference_bh(sch->stab); |
| 831 | |
| 832 | if (stab) |
| 833 | __qdisc_calculate_pkt_len(skb, stab); |
| 834 | #endif |
| 835 | } |
| 836 | |
| 837 | static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, |
| 838 | struct sk_buff **to_free) |
| 839 | { |
| 840 | qdisc_calculate_pkt_len(skb, sch); |
| 841 | return sch->enqueue(skb, sch, to_free); |
| 842 | } |
| 843 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 844 | static inline void _bstats_update(struct gnet_stats_basic_packed *bstats, |
| 845 | __u64 bytes, __u32 packets) |
| 846 | { |
| 847 | bstats->bytes += bytes; |
| 848 | bstats->packets += packets; |
| 849 | } |
| 850 | |
| 851 | static inline void bstats_update(struct gnet_stats_basic_packed *bstats, |
| 852 | const struct sk_buff *skb) |
| 853 | { |
| 854 | _bstats_update(bstats, |
| 855 | qdisc_pkt_len(skb), |
| 856 | skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1); |
| 857 | } |
| 858 | |
| 859 | static inline void _bstats_cpu_update(struct gnet_stats_basic_cpu *bstats, |
| 860 | __u64 bytes, __u32 packets) |
| 861 | { |
| 862 | u64_stats_update_begin(&bstats->syncp); |
| 863 | _bstats_update(&bstats->bstats, bytes, packets); |
| 864 | u64_stats_update_end(&bstats->syncp); |
| 865 | } |
| 866 | |
| 867 | static inline void bstats_cpu_update(struct gnet_stats_basic_cpu *bstats, |
| 868 | const struct sk_buff *skb) |
| 869 | { |
| 870 | u64_stats_update_begin(&bstats->syncp); |
| 871 | bstats_update(&bstats->bstats, skb); |
| 872 | u64_stats_update_end(&bstats->syncp); |
| 873 | } |
| 874 | |
| 875 | static inline void qdisc_bstats_cpu_update(struct Qdisc *sch, |
| 876 | const struct sk_buff *skb) |
| 877 | { |
| 878 | bstats_cpu_update(this_cpu_ptr(sch->cpu_bstats), skb); |
| 879 | } |
| 880 | |
| 881 | static inline void qdisc_bstats_update(struct Qdisc *sch, |
| 882 | const struct sk_buff *skb) |
| 883 | { |
| 884 | bstats_update(&sch->bstats, skb); |
| 885 | } |
| 886 | |
| 887 | static inline void qdisc_qstats_backlog_dec(struct Qdisc *sch, |
| 888 | const struct sk_buff *skb) |
| 889 | { |
| 890 | sch->qstats.backlog -= qdisc_pkt_len(skb); |
| 891 | } |
| 892 | |
| 893 | static inline void qdisc_qstats_cpu_backlog_dec(struct Qdisc *sch, |
| 894 | const struct sk_buff *skb) |
| 895 | { |
| 896 | this_cpu_sub(sch->cpu_qstats->backlog, qdisc_pkt_len(skb)); |
| 897 | } |
| 898 | |
| 899 | static inline void qdisc_qstats_backlog_inc(struct Qdisc *sch, |
| 900 | const struct sk_buff *skb) |
| 901 | { |
| 902 | sch->qstats.backlog += qdisc_pkt_len(skb); |
| 903 | } |
| 904 | |
| 905 | static inline void qdisc_qstats_cpu_backlog_inc(struct Qdisc *sch, |
| 906 | const struct sk_buff *skb) |
| 907 | { |
| 908 | this_cpu_add(sch->cpu_qstats->backlog, qdisc_pkt_len(skb)); |
| 909 | } |
| 910 | |
| 911 | static inline void qdisc_qstats_cpu_qlen_inc(struct Qdisc *sch) |
| 912 | { |
| 913 | this_cpu_inc(sch->cpu_qstats->qlen); |
| 914 | } |
| 915 | |
| 916 | static inline void qdisc_qstats_cpu_qlen_dec(struct Qdisc *sch) |
| 917 | { |
| 918 | this_cpu_dec(sch->cpu_qstats->qlen); |
| 919 | } |
| 920 | |
| 921 | static inline void qdisc_qstats_cpu_requeues_inc(struct Qdisc *sch) |
| 922 | { |
| 923 | this_cpu_inc(sch->cpu_qstats->requeues); |
| 924 | } |
| 925 | |
| 926 | static inline void __qdisc_qstats_drop(struct Qdisc *sch, int count) |
| 927 | { |
| 928 | sch->qstats.drops += count; |
| 929 | } |
| 930 | |
| 931 | static inline void qstats_drop_inc(struct gnet_stats_queue *qstats) |
| 932 | { |
| 933 | qstats->drops++; |
| 934 | } |
| 935 | |
| 936 | static inline void qstats_overlimit_inc(struct gnet_stats_queue *qstats) |
| 937 | { |
| 938 | qstats->overlimits++; |
| 939 | } |
| 940 | |
| 941 | static inline void qdisc_qstats_drop(struct Qdisc *sch) |
| 942 | { |
| 943 | qstats_drop_inc(&sch->qstats); |
| 944 | } |
| 945 | |
| 946 | static inline void qdisc_qstats_cpu_drop(struct Qdisc *sch) |
| 947 | { |
| 948 | this_cpu_inc(sch->cpu_qstats->drops); |
| 949 | } |
| 950 | |
| 951 | static inline void qdisc_qstats_overlimit(struct Qdisc *sch) |
| 952 | { |
| 953 | sch->qstats.overlimits++; |
| 954 | } |
| 955 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 956 | static inline int qdisc_qstats_copy(struct gnet_dump *d, struct Qdisc *sch) |
| 957 | { |
| 958 | __u32 qlen = qdisc_qlen_sum(sch); |
| 959 | |
| 960 | return gnet_stats_copy_queue(d, sch->cpu_qstats, &sch->qstats, qlen); |
| 961 | } |
| 962 | |
| 963 | static inline void qdisc_qstats_qlen_backlog(struct Qdisc *sch, __u32 *qlen, |
| 964 | __u32 *backlog) |
| 965 | { |
| 966 | struct gnet_stats_queue qstats = { 0 }; |
| 967 | __u32 len = qdisc_qlen_sum(sch); |
| 968 | |
| 969 | __gnet_stats_copy_queue(&qstats, sch->cpu_qstats, &sch->qstats, len); |
| 970 | *qlen = qstats.qlen; |
| 971 | *backlog = qstats.backlog; |
| 972 | } |
| 973 | |
| 974 | static inline void qdisc_tree_flush_backlog(struct Qdisc *sch) |
| 975 | { |
| 976 | __u32 qlen, backlog; |
| 977 | |
| 978 | qdisc_qstats_qlen_backlog(sch, &qlen, &backlog); |
| 979 | qdisc_tree_reduce_backlog(sch, qlen, backlog); |
| 980 | } |
| 981 | |
| 982 | static inline void qdisc_purge_queue(struct Qdisc *sch) |
| 983 | { |
| 984 | __u32 qlen, backlog; |
| 985 | |
| 986 | qdisc_qstats_qlen_backlog(sch, &qlen, &backlog); |
| 987 | qdisc_reset(sch); |
| 988 | qdisc_tree_reduce_backlog(sch, qlen, backlog); |
| 989 | } |
| 990 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 991 | static inline void qdisc_skb_head_init(struct qdisc_skb_head *qh) |
| 992 | { |
| 993 | qh->head = NULL; |
| 994 | qh->tail = NULL; |
| 995 | qh->qlen = 0; |
| 996 | } |
| 997 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 998 | static inline void __qdisc_enqueue_tail(struct sk_buff *skb, |
| 999 | struct qdisc_skb_head *qh) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1000 | { |
| 1001 | struct sk_buff *last = qh->tail; |
| 1002 | |
| 1003 | if (last) { |
| 1004 | skb->next = NULL; |
| 1005 | last->next = skb; |
| 1006 | qh->tail = skb; |
| 1007 | } else { |
| 1008 | qh->tail = skb; |
| 1009 | qh->head = skb; |
| 1010 | } |
| 1011 | qh->qlen++; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | static inline int qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch) |
| 1015 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1016 | __qdisc_enqueue_tail(skb, &sch->q); |
| 1017 | qdisc_qstats_backlog_inc(sch, skb); |
| 1018 | return NET_XMIT_SUCCESS; |
| 1019 | } |
| 1020 | |
| 1021 | static inline void __qdisc_enqueue_head(struct sk_buff *skb, |
| 1022 | struct qdisc_skb_head *qh) |
| 1023 | { |
| 1024 | skb->next = qh->head; |
| 1025 | |
| 1026 | if (!qh->head) |
| 1027 | qh->tail = skb; |
| 1028 | qh->head = skb; |
| 1029 | qh->qlen++; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | static inline struct sk_buff *__qdisc_dequeue_head(struct qdisc_skb_head *qh) |
| 1033 | { |
| 1034 | struct sk_buff *skb = qh->head; |
| 1035 | |
| 1036 | if (likely(skb != NULL)) { |
| 1037 | qh->head = skb->next; |
| 1038 | qh->qlen--; |
| 1039 | if (qh->head == NULL) |
| 1040 | qh->tail = NULL; |
| 1041 | skb->next = NULL; |
| 1042 | } |
| 1043 | |
| 1044 | return skb; |
| 1045 | } |
| 1046 | |
| 1047 | static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch) |
| 1048 | { |
| 1049 | struct sk_buff *skb = __qdisc_dequeue_head(&sch->q); |
| 1050 | |
| 1051 | if (likely(skb != NULL)) { |
| 1052 | qdisc_qstats_backlog_dec(sch, skb); |
| 1053 | qdisc_bstats_update(sch, skb); |
| 1054 | } |
| 1055 | |
| 1056 | return skb; |
| 1057 | } |
| 1058 | |
| 1059 | /* Instead of calling kfree_skb() while root qdisc lock is held, |
| 1060 | * queue the skb for future freeing at end of __dev_xmit_skb() |
| 1061 | */ |
| 1062 | static inline void __qdisc_drop(struct sk_buff *skb, struct sk_buff **to_free) |
| 1063 | { |
| 1064 | skb->next = *to_free; |
| 1065 | *to_free = skb; |
| 1066 | } |
| 1067 | |
| 1068 | static inline void __qdisc_drop_all(struct sk_buff *skb, |
| 1069 | struct sk_buff **to_free) |
| 1070 | { |
| 1071 | if (skb->prev) |
| 1072 | skb->prev->next = *to_free; |
| 1073 | else |
| 1074 | skb->next = *to_free; |
| 1075 | *to_free = skb; |
| 1076 | } |
| 1077 | |
| 1078 | static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch, |
| 1079 | struct qdisc_skb_head *qh, |
| 1080 | struct sk_buff **to_free) |
| 1081 | { |
| 1082 | struct sk_buff *skb = __qdisc_dequeue_head(qh); |
| 1083 | |
| 1084 | if (likely(skb != NULL)) { |
| 1085 | unsigned int len = qdisc_pkt_len(skb); |
| 1086 | |
| 1087 | qdisc_qstats_backlog_dec(sch, skb); |
| 1088 | __qdisc_drop(skb, to_free); |
| 1089 | return len; |
| 1090 | } |
| 1091 | |
| 1092 | return 0; |
| 1093 | } |
| 1094 | |
| 1095 | static inline unsigned int qdisc_queue_drop_head(struct Qdisc *sch, |
| 1096 | struct sk_buff **to_free) |
| 1097 | { |
| 1098 | return __qdisc_queue_drop_head(sch, &sch->q, to_free); |
| 1099 | } |
| 1100 | |
| 1101 | static inline struct sk_buff *qdisc_peek_head(struct Qdisc *sch) |
| 1102 | { |
| 1103 | const struct qdisc_skb_head *qh = &sch->q; |
| 1104 | |
| 1105 | return qh->head; |
| 1106 | } |
| 1107 | |
| 1108 | /* generic pseudo peek method for non-work-conserving qdisc */ |
| 1109 | static inline struct sk_buff *qdisc_peek_dequeued(struct Qdisc *sch) |
| 1110 | { |
| 1111 | struct sk_buff *skb = skb_peek(&sch->gso_skb); |
| 1112 | |
| 1113 | /* we can reuse ->gso_skb because peek isn't called for root qdiscs */ |
| 1114 | if (!skb) { |
| 1115 | skb = sch->dequeue(sch); |
| 1116 | |
| 1117 | if (skb) { |
| 1118 | __skb_queue_head(&sch->gso_skb, skb); |
| 1119 | /* it's still part of the queue */ |
| 1120 | qdisc_qstats_backlog_inc(sch, skb); |
| 1121 | sch->q.qlen++; |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | return skb; |
| 1126 | } |
| 1127 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1128 | static inline void qdisc_update_stats_at_dequeue(struct Qdisc *sch, |
| 1129 | struct sk_buff *skb) |
| 1130 | { |
| 1131 | if (qdisc_is_percpu_stats(sch)) { |
| 1132 | qdisc_qstats_cpu_backlog_dec(sch, skb); |
| 1133 | qdisc_bstats_cpu_update(sch, skb); |
| 1134 | qdisc_qstats_cpu_qlen_dec(sch); |
| 1135 | } else { |
| 1136 | qdisc_qstats_backlog_dec(sch, skb); |
| 1137 | qdisc_bstats_update(sch, skb); |
| 1138 | sch->q.qlen--; |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | static inline void qdisc_update_stats_at_enqueue(struct Qdisc *sch, |
| 1143 | unsigned int pkt_len) |
| 1144 | { |
| 1145 | if (qdisc_is_percpu_stats(sch)) { |
| 1146 | qdisc_qstats_cpu_qlen_inc(sch); |
| 1147 | this_cpu_add(sch->cpu_qstats->backlog, pkt_len); |
| 1148 | } else { |
| 1149 | sch->qstats.backlog += pkt_len; |
| 1150 | sch->q.qlen++; |
| 1151 | } |
| 1152 | } |
| 1153 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1154 | /* use instead of qdisc->dequeue() for all qdiscs queried with ->peek() */ |
| 1155 | static inline struct sk_buff *qdisc_dequeue_peeked(struct Qdisc *sch) |
| 1156 | { |
| 1157 | struct sk_buff *skb = skb_peek(&sch->gso_skb); |
| 1158 | |
| 1159 | if (skb) { |
| 1160 | skb = __skb_dequeue(&sch->gso_skb); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1161 | if (qdisc_is_percpu_stats(sch)) { |
| 1162 | qdisc_qstats_cpu_backlog_dec(sch, skb); |
| 1163 | qdisc_qstats_cpu_qlen_dec(sch); |
| 1164 | } else { |
| 1165 | qdisc_qstats_backlog_dec(sch, skb); |
| 1166 | sch->q.qlen--; |
| 1167 | } |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1168 | } else { |
| 1169 | skb = sch->dequeue(sch); |
| 1170 | } |
| 1171 | |
| 1172 | return skb; |
| 1173 | } |
| 1174 | |
| 1175 | static inline void __qdisc_reset_queue(struct qdisc_skb_head *qh) |
| 1176 | { |
| 1177 | /* |
| 1178 | * We do not know the backlog in bytes of this list, it |
| 1179 | * is up to the caller to correct it |
| 1180 | */ |
| 1181 | ASSERT_RTNL(); |
| 1182 | if (qh->qlen) { |
| 1183 | rtnl_kfree_skbs(qh->head, qh->tail); |
| 1184 | |
| 1185 | qh->head = NULL; |
| 1186 | qh->tail = NULL; |
| 1187 | qh->qlen = 0; |
| 1188 | } |
| 1189 | } |
| 1190 | |
| 1191 | static inline void qdisc_reset_queue(struct Qdisc *sch) |
| 1192 | { |
| 1193 | __qdisc_reset_queue(&sch->q); |
| 1194 | sch->qstats.backlog = 0; |
| 1195 | } |
| 1196 | |
| 1197 | static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new, |
| 1198 | struct Qdisc **pold) |
| 1199 | { |
| 1200 | struct Qdisc *old; |
| 1201 | |
| 1202 | sch_tree_lock(sch); |
| 1203 | old = *pold; |
| 1204 | *pold = new; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1205 | if (old != NULL) |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame^] | 1206 | qdisc_purge_queue(old); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1207 | sch_tree_unlock(sch); |
| 1208 | |
| 1209 | return old; |
| 1210 | } |
| 1211 | |
| 1212 | static inline void rtnl_qdisc_drop(struct sk_buff *skb, struct Qdisc *sch) |
| 1213 | { |
| 1214 | rtnl_kfree_skbs(skb, skb); |
| 1215 | qdisc_qstats_drop(sch); |
| 1216 | } |
| 1217 | |
| 1218 | static inline int qdisc_drop_cpu(struct sk_buff *skb, struct Qdisc *sch, |
| 1219 | struct sk_buff **to_free) |
| 1220 | { |
| 1221 | __qdisc_drop(skb, to_free); |
| 1222 | qdisc_qstats_cpu_drop(sch); |
| 1223 | |
| 1224 | return NET_XMIT_DROP; |
| 1225 | } |
| 1226 | |
| 1227 | static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch, |
| 1228 | struct sk_buff **to_free) |
| 1229 | { |
| 1230 | __qdisc_drop(skb, to_free); |
| 1231 | qdisc_qstats_drop(sch); |
| 1232 | |
| 1233 | return NET_XMIT_DROP; |
| 1234 | } |
| 1235 | |
| 1236 | static inline int qdisc_drop_all(struct sk_buff *skb, struct Qdisc *sch, |
| 1237 | struct sk_buff **to_free) |
| 1238 | { |
| 1239 | __qdisc_drop_all(skb, to_free); |
| 1240 | qdisc_qstats_drop(sch); |
| 1241 | |
| 1242 | return NET_XMIT_DROP; |
| 1243 | } |
| 1244 | |
| 1245 | /* Length to Time (L2T) lookup in a qdisc_rate_table, to determine how |
| 1246 | long it will take to send a packet given its size. |
| 1247 | */ |
| 1248 | static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen) |
| 1249 | { |
| 1250 | int slot = pktlen + rtab->rate.cell_align + rtab->rate.overhead; |
| 1251 | if (slot < 0) |
| 1252 | slot = 0; |
| 1253 | slot >>= rtab->rate.cell_log; |
| 1254 | if (slot > 255) |
| 1255 | return rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF]; |
| 1256 | return rtab->data[slot]; |
| 1257 | } |
| 1258 | |
| 1259 | struct psched_ratecfg { |
| 1260 | u64 rate_bytes_ps; /* bytes per second */ |
| 1261 | u32 mult; |
| 1262 | u16 overhead; |
| 1263 | u8 linklayer; |
| 1264 | u8 shift; |
| 1265 | }; |
| 1266 | |
| 1267 | static inline u64 psched_l2t_ns(const struct psched_ratecfg *r, |
| 1268 | unsigned int len) |
| 1269 | { |
| 1270 | len += r->overhead; |
| 1271 | |
| 1272 | if (unlikely(r->linklayer == TC_LINKLAYER_ATM)) |
| 1273 | return ((u64)(DIV_ROUND_UP(len,48)*53) * r->mult) >> r->shift; |
| 1274 | |
| 1275 | return ((u64)len * r->mult) >> r->shift; |
| 1276 | } |
| 1277 | |
| 1278 | void psched_ratecfg_precompute(struct psched_ratecfg *r, |
| 1279 | const struct tc_ratespec *conf, |
| 1280 | u64 rate64); |
| 1281 | |
| 1282 | static inline void psched_ratecfg_getrate(struct tc_ratespec *res, |
| 1283 | const struct psched_ratecfg *r) |
| 1284 | { |
| 1285 | memset(res, 0, sizeof(*res)); |
| 1286 | |
| 1287 | /* legacy struct tc_ratespec has a 32bit @rate field |
| 1288 | * Qdisc using 64bit rate should add new attributes |
| 1289 | * in order to maintain compatibility. |
| 1290 | */ |
| 1291 | res->rate = min_t(u64, r->rate_bytes_ps, ~0U); |
| 1292 | |
| 1293 | res->overhead = r->overhead; |
| 1294 | res->linklayer = (r->linklayer & TC_LINKLAYER_MASK); |
| 1295 | } |
| 1296 | |
| 1297 | /* Mini Qdisc serves for specific needs of ingress/clsact Qdisc. |
| 1298 | * The fast path only needs to access filter list and to update stats |
| 1299 | */ |
| 1300 | struct mini_Qdisc { |
| 1301 | struct tcf_proto *filter_list; |
| 1302 | struct gnet_stats_basic_cpu __percpu *cpu_bstats; |
| 1303 | struct gnet_stats_queue __percpu *cpu_qstats; |
| 1304 | struct rcu_head rcu; |
| 1305 | }; |
| 1306 | |
| 1307 | static inline void mini_qdisc_bstats_cpu_update(struct mini_Qdisc *miniq, |
| 1308 | const struct sk_buff *skb) |
| 1309 | { |
| 1310 | bstats_cpu_update(this_cpu_ptr(miniq->cpu_bstats), skb); |
| 1311 | } |
| 1312 | |
| 1313 | static inline void mini_qdisc_qstats_cpu_drop(struct mini_Qdisc *miniq) |
| 1314 | { |
| 1315 | this_cpu_inc(miniq->cpu_qstats->drops); |
| 1316 | } |
| 1317 | |
| 1318 | struct mini_Qdisc_pair { |
| 1319 | struct mini_Qdisc miniq1; |
| 1320 | struct mini_Qdisc miniq2; |
| 1321 | struct mini_Qdisc __rcu **p_miniq; |
| 1322 | }; |
| 1323 | |
| 1324 | void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp, |
| 1325 | struct tcf_proto *tp_head); |
| 1326 | void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc, |
| 1327 | struct mini_Qdisc __rcu **p_miniq); |
| 1328 | |
| 1329 | static inline void skb_tc_reinsert(struct sk_buff *skb, struct tcf_result *res) |
| 1330 | { |
| 1331 | struct gnet_stats_queue *stats = res->qstats; |
| 1332 | int ret; |
| 1333 | |
| 1334 | if (res->ingress) |
| 1335 | ret = netif_receive_skb(skb); |
| 1336 | else |
| 1337 | ret = dev_queue_xmit(skb); |
| 1338 | if (ret && stats) |
| 1339 | qstats_overlimit_inc(res->qstats); |
| 1340 | } |
| 1341 | |
| 1342 | #endif |