linux/include/net/sch_generic.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NET_SCHED_GENERIC_H
#define __NET_SCHED_GENERIC_H

#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/rcupdate.h>
#include <linux/pkt_sched.h>
#include <linux/pkt_cls.h>
#include <linux/percpu.h>
#include <linux/dynamic_queue_limits.h>
#include <linux/list.h>
#include <linux/refcount.h>
#include <linux/workqueue.h>
#include <linux/mutex.h>
#include <linux/rwsem.h>
#include <linux/atomic.h>
#include <linux/hashtable.h>
#include <net/gen_stats.h>
#include <net/rtnetlink.h>
#include <net/flow_offload.h>
#include <linux/xarray.h>

struct Qdisc_ops;
struct qdisc_walker;
struct tcf_walker;
struct module;
struct bpf_flow_keys;

struct qdisc_rate_table {};

enum qdisc_state_t {};

enum qdisc_state2_t {};

#define QDISC_STATE_MISSED
#define QDISC_STATE_DRAINING

#define QDISC_STATE_NON_EMPTY

struct qdisc_size_table {};

/* similar to sk_buff_head, but skb->prev pointer is undefined. */
struct qdisc_skb_head {};

struct Qdisc {};

static inline void qdisc_refcount_inc(struct Qdisc *qdisc)
{}

static inline bool qdisc_refcount_dec_if_one(struct Qdisc *qdisc)
{}

/* Intended to be used by unlocked users, when concurrent qdisc release is
 * possible.
 */

static inline struct Qdisc *qdisc_refcount_inc_nz(struct Qdisc *qdisc)
{}

/* For !TCQ_F_NOLOCK qdisc: callers must either call this within a qdisc
 * root_lock section, or provide their own memory barriers -- ordering
 * against qdisc_run_begin/end() atomic bit operations.
 */
static inline bool qdisc_is_running(struct Qdisc *qdisc)
{}

static inline bool nolock_qdisc_is_empty(const struct Qdisc *qdisc)
{}

static inline bool qdisc_is_percpu_stats(const struct Qdisc *q)
{}

static inline bool qdisc_is_empty(const struct Qdisc *qdisc)
{}

/* For !TCQ_F_NOLOCK qdisc, qdisc_run_begin/end() must be invoked with
 * the qdisc root lock acquired.
 */
static inline bool qdisc_run_begin(struct Qdisc *qdisc)
{}

static inline void qdisc_run_end(struct Qdisc *qdisc)
{}

static inline bool qdisc_may_bulk(const struct Qdisc *qdisc)
{}

static inline int qdisc_avail_bulklimit(const struct netdev_queue *txq)
{}

struct Qdisc_class_ops {};

/* Qdisc_class_ops flag values */

/* Implements API that doesn't require rtnl lock */
enum qdisc_class_ops_flags {};

struct Qdisc_ops {};

struct tcf_result {};

struct tcf_chain;

struct tcf_proto_ops {};

/* Classifiers setting TCF_PROTO_OPS_DOIT_UNLOCKED in tcf_proto_ops->flags
 * are expected to implement tcf_proto_ops->delete_empty(), otherwise race
 * conditions can occur when filters are inserted/deleted simultaneously.
 */
enum tcf_proto_ops_flags {};

struct tcf_proto {};

struct qdisc_skb_cb {};

tcf_chain_head_change_t;

struct tcf_chain {};

struct tcf_block {};

struct tcf_block *tcf_block_lookup(struct net *net, u32 block_index);

static inline bool lockdep_tcf_chain_is_locked(struct tcf_chain *chain)
{}

static inline bool lockdep_tcf_proto_is_locked(struct tcf_proto *tp)
{}

#define tcf_chain_dereference(p, chain)

#define tcf_proto_dereference(p, tp)

static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
{}

static inline int qdisc_qlen(const struct Qdisc *q)
{}

static inline int qdisc_qlen_sum(const struct Qdisc *q)
{}

static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
{}

static inline spinlock_t *qdisc_lock(struct Qdisc *qdisc)
{}

static inline struct Qdisc *qdisc_root(const struct Qdisc *qdisc)
{}

static inline struct Qdisc *qdisc_root_bh(const struct Qdisc *qdisc)
{}

static inline struct Qdisc *qdisc_root_sleeping(const struct Qdisc *qdisc)
{}

static inline spinlock_t *qdisc_root_sleeping_lock(const struct Qdisc *qdisc)
{}

static inline struct net_device *qdisc_dev(const struct Qdisc *qdisc)
{}

static inline void sch_tree_lock(struct Qdisc *q)
{}

static inline void sch_tree_unlock(struct Qdisc *q)
{}

extern struct Qdisc noop_qdisc;
extern struct Qdisc_ops noop_qdisc_ops;
extern struct Qdisc_ops pfifo_fast_ops;
extern const u8 sch_default_prio2band[TC_PRIO_MAX + 1];
extern struct Qdisc_ops mq_qdisc_ops;
extern struct Qdisc_ops noqueue_qdisc_ops;
extern const struct Qdisc_ops *default_qdisc_ops;
static inline const struct Qdisc_ops *
get_default_qdisc_ops(const struct net_device *dev, int ntx)
{}

struct Qdisc_class_common {};

struct Qdisc_class_hash {};

static inline unsigned int qdisc_class_hash(u32 id, u32 mask)
{}

static inline struct Qdisc_class_common *
qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id)
{}

static inline bool qdisc_class_in_use(const struct Qdisc_class_common *cl)
{}

static inline void qdisc_class_get(struct Qdisc_class_common *cl)
{}

static inline void qdisc_class_put(struct Qdisc_class_common *cl)
{}

static inline int tc_classid_to_hwtc(struct net_device *dev, u32 classid)
{}

int qdisc_class_hash_init(struct Qdisc_class_hash *);
void qdisc_class_hash_insert(struct Qdisc_class_hash *,
			     struct Qdisc_class_common *);
void qdisc_class_hash_remove(struct Qdisc_class_hash *,
			     struct Qdisc_class_common *);
void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
void qdisc_class_hash_destroy(struct Qdisc_class_hash *);

int dev_qdisc_change_tx_queue_len(struct net_device *dev);
void dev_qdisc_change_real_num_tx(struct net_device *dev,
				  unsigned int new_real_tx);
void dev_init_scheduler(struct net_device *dev);
void dev_shutdown(struct net_device *dev);
void dev_activate(struct net_device *dev);
void dev_deactivate(struct net_device *dev);
void dev_deactivate_many(struct list_head *head);
struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
			      struct Qdisc *qdisc);
void qdisc_reset(struct Qdisc *qdisc);
void qdisc_destroy(struct Qdisc *qdisc);
void qdisc_put(struct Qdisc *qdisc);
void qdisc_put_unlocked(struct Qdisc *qdisc);
void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, int n, int len);
#ifdef CONFIG_NET_SCHED
int qdisc_offload_dump_helper(struct Qdisc *q, enum tc_setup_type type,
			      void *type_data);
void qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch,
				struct Qdisc *new, struct Qdisc *old,
				enum tc_setup_type type, void *type_data,
				struct netlink_ext_ack *extack);
#else
static inline int
qdisc_offload_dump_helper(struct Qdisc *q, enum tc_setup_type type,
			  void *type_data)
{
	q->flags &= ~TCQ_F_OFFLOADED;
	return 0;
}

static inline void
qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch,
			   struct Qdisc *new, struct Qdisc *old,
			   enum tc_setup_type type, void *type_data,
			   struct netlink_ext_ack *extack)
{
}
#endif
void qdisc_offload_query_caps(struct net_device *dev,
			      enum tc_setup_type type,
			      void *caps, size_t caps_len);
struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
			  const struct Qdisc_ops *ops,
			  struct netlink_ext_ack *extack);
void qdisc_free(struct Qdisc *qdisc);
struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
				const struct Qdisc_ops *ops, u32 parentid,
				struct netlink_ext_ack *extack);
void __qdisc_calculate_pkt_len(struct sk_buff *skb,
			       const struct qdisc_size_table *stab);
int skb_do_redirect(struct sk_buff *);

static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
{}

static inline bool skb_skip_tc_classify(struct sk_buff *skb)
{}

/* Reset all TX qdiscs greater than index of a device.  */
static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
{}

/* Are all TX queues of the device empty?  */
static inline bool qdisc_all_tx_empty(const struct net_device *dev)
{}

/* Are any of the TX qdiscs changing?  */
static inline bool qdisc_tx_changing(const struct net_device *dev)
{}

/* Is the device using the noop qdisc on all queues?  */
static inline bool qdisc_tx_is_noop(const struct net_device *dev)
{}

static inline unsigned int qdisc_pkt_len(const struct sk_buff *skb)
{}

/* additional qdisc xmit flags (NET_XMIT_MASK in linux/netdevice.h) */
enum net_xmit_qdisc_t {};

#ifdef CONFIG_NET_CLS_ACT
#define net_xmit_drop_count(e)
#else
#define net_xmit_drop_count
#endif

static inline void qdisc_calculate_pkt_len(struct sk_buff *skb,
					   const struct Qdisc *sch)
{}

static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
				struct sk_buff **to_free)
{}

static inline void _bstats_update(struct gnet_stats_basic_sync *bstats,
				  __u64 bytes, __u32 packets)
{}

static inline void bstats_update(struct gnet_stats_basic_sync *bstats,
				 const struct sk_buff *skb)
{}

static inline void qdisc_bstats_cpu_update(struct Qdisc *sch,
					   const struct sk_buff *skb)
{}

static inline void qdisc_bstats_update(struct Qdisc *sch,
				       const struct sk_buff *skb)
{}

static inline void qdisc_qstats_backlog_dec(struct Qdisc *sch,
					    const struct sk_buff *skb)
{}

static inline void qdisc_qstats_cpu_backlog_dec(struct Qdisc *sch,
						const struct sk_buff *skb)
{}

static inline void qdisc_qstats_backlog_inc(struct Qdisc *sch,
					    const struct sk_buff *skb)
{}

static inline void qdisc_qstats_cpu_backlog_inc(struct Qdisc *sch,
						const struct sk_buff *skb)
{}

static inline void qdisc_qstats_cpu_qlen_inc(struct Qdisc *sch)
{}

static inline void qdisc_qstats_cpu_qlen_dec(struct Qdisc *sch)
{}

static inline void qdisc_qstats_cpu_requeues_inc(struct Qdisc *sch)
{}

static inline void __qdisc_qstats_drop(struct Qdisc *sch, int count)
{}

static inline void qstats_drop_inc(struct gnet_stats_queue *qstats)
{}

static inline void qstats_overlimit_inc(struct gnet_stats_queue *qstats)
{}

static inline void qdisc_qstats_drop(struct Qdisc *sch)
{}

static inline void qdisc_qstats_cpu_drop(struct Qdisc *sch)
{}

static inline void qdisc_qstats_overlimit(struct Qdisc *sch)
{}

static inline int qdisc_qstats_copy(struct gnet_dump *d, struct Qdisc *sch)
{}

static inline void qdisc_qstats_qlen_backlog(struct Qdisc *sch,  __u32 *qlen,
					     __u32 *backlog)
{}

static inline void qdisc_tree_flush_backlog(struct Qdisc *sch)
{}

static inline void qdisc_purge_queue(struct Qdisc *sch)
{}

static inline void __qdisc_enqueue_tail(struct sk_buff *skb,
					struct qdisc_skb_head *qh)
{}

static inline int qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch)
{}

static inline void __qdisc_enqueue_head(struct sk_buff *skb,
					struct qdisc_skb_head *qh)
{}

static inline struct sk_buff *__qdisc_dequeue_head(struct qdisc_skb_head *qh)
{}

static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch)
{}

struct tc_skb_cb {};

static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb)
{}

static inline enum skb_drop_reason
tcf_get_drop_reason(const struct sk_buff *skb)
{}

static inline void tcf_set_drop_reason(const struct sk_buff *skb,
				       enum skb_drop_reason reason)
{}

/* Instead of calling kfree_skb() while root qdisc lock is held,
 * queue the skb for future freeing at end of __dev_xmit_skb()
 */
static inline void __qdisc_drop(struct sk_buff *skb, struct sk_buff **to_free)
{}

static inline void __qdisc_drop_all(struct sk_buff *skb,
				    struct sk_buff **to_free)
{}

static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch,
						   struct qdisc_skb_head *qh,
						   struct sk_buff **to_free)
{}

static inline struct sk_buff *qdisc_peek_head(struct Qdisc *sch)
{}

/* generic pseudo peek method for non-work-conserving qdisc */
static inline struct sk_buff *qdisc_peek_dequeued(struct Qdisc *sch)
{}

static inline void qdisc_update_stats_at_dequeue(struct Qdisc *sch,
						 struct sk_buff *skb)
{}

static inline void qdisc_update_stats_at_enqueue(struct Qdisc *sch,
						 unsigned int pkt_len)
{}

/* use instead of qdisc->dequeue() for all qdiscs queried with ->peek() */
static inline struct sk_buff *qdisc_dequeue_peeked(struct Qdisc *sch)
{}

static inline void __qdisc_reset_queue(struct qdisc_skb_head *qh)
{}

static inline void qdisc_reset_queue(struct Qdisc *sch)
{}

static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new,
					  struct Qdisc **pold)
{}

static inline void rtnl_qdisc_drop(struct sk_buff *skb, struct Qdisc *sch)
{}

static inline int qdisc_drop_cpu(struct sk_buff *skb, struct Qdisc *sch,
				 struct sk_buff **to_free)
{}

static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch,
			     struct sk_buff **to_free)
{}

static inline int qdisc_drop_all(struct sk_buff *skb, struct Qdisc *sch,
				 struct sk_buff **to_free)
{}

struct psched_ratecfg {};

static inline u64 psched_l2t_ns(const struct psched_ratecfg *r,
				unsigned int len)
{}

void psched_ratecfg_precompute(struct psched_ratecfg *r,
			       const struct tc_ratespec *conf,
			       u64 rate64);

static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
					  const struct psched_ratecfg *r)
{}

struct psched_pktrate {};

static inline u64 psched_pkt2t_ns(const struct psched_pktrate *r,
				  unsigned int pkt_num)
{}

void psched_ppscfg_precompute(struct psched_pktrate *r, u64 pktrate64);

/* Mini Qdisc serves for specific needs of ingress/clsact Qdisc.
 * The fast path only needs to access filter list and to update stats
 */
struct mini_Qdisc {};

static inline void mini_qdisc_bstats_cpu_update(struct mini_Qdisc *miniq,
						const struct sk_buff *skb)
{}

static inline void mini_qdisc_qstats_cpu_drop(struct mini_Qdisc *miniq)
{}

struct mini_Qdisc_pair {};

void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp,
			  struct tcf_proto *tp_head);
void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc,
			  struct mini_Qdisc __rcu **p_miniq);
void mini_qdisc_pair_block_init(struct mini_Qdisc_pair *miniqp,
				struct tcf_block *block);

void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx);

int sch_frag_xmit_hook(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb));

/* Make sure qdisc is no longer in SCHED state. */
static inline void qdisc_synchronize(const struct Qdisc *q)
{}

#endif