blob: 2eccbbd2b55958869a6b8d277a6ae20d3cbc1fe3 [file] [log] [blame]
Thomas Gleixnerfb9e53c2019-05-29 07:12:31 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Michal Kazior557fc4a2016-04-22 14:20:13 +02002/*
3 * Copyright (c) 2016 Qualcomm Atheros, Inc
4 *
Michal Kazior557fc4a2016-04-22 14:20:13 +02005 * Based on net/sched/sch_fq_codel.c
6 */
7#ifndef __NET_SCHED_FQ_H
8#define __NET_SCHED_FQ_H
9
10struct fq_tin;
11
12/**
13 * struct fq_flow - per traffic flow queue
14 *
15 * @tin: owner of this flow. Used to manage collisions, i.e. when a packet
16 * hashes to an index which points to a flow that is already owned by a
17 * different tin the packet is destined to. In such case the implementer
18 * must provide a fallback flow
19 * @flowchain: can be linked to fq_tin's new_flows or old_flows. Used for DRR++
20 * (deficit round robin) based round robin queuing similar to the one
21 * found in net/sched/sch_fq_codel.c
Michal Kazior557fc4a2016-04-22 14:20:13 +020022 * @queue: sk_buff queue to hold packets
23 * @backlog: number of bytes pending in the queue. The number of packets can be
24 * found in @queue.qlen
25 * @deficit: used for DRR++
26 */
27struct fq_flow {
28 struct fq_tin *tin;
29 struct list_head flowchain;
Michal Kazior557fc4a2016-04-22 14:20:13 +020030 struct sk_buff_head queue;
31 u32 backlog;
32 int deficit;
33};
34
35/**
36 * struct fq_tin - a logical container of fq_flows
37 *
38 * Used to group fq_flows into a logical aggregate. DRR++ scheme is used to
39 * pull interleaved packets out of the associated flows.
40 *
41 * @new_flows: linked list of fq_flow
42 * @old_flows: linked list of fq_flow
43 */
44struct fq_tin {
45 struct list_head new_flows;
46 struct list_head old_flows;
Felix Fietkaud7b64922020-12-18 19:47:15 +010047 struct list_head tin_list;
Felix Fietkaubf9009b2020-12-18 19:47:14 +010048 struct fq_flow default_flow;
Michal Kazior557fc4a2016-04-22 14:20:13 +020049 u32 backlog_bytes;
50 u32 backlog_packets;
51 u32 overlimit;
52 u32 collisions;
53 u32 flows;
54 u32 tx_bytes;
55 u32 tx_packets;
56};
57
58/**
59 * struct fq - main container for fair queuing purposes
60 *
Michal Kazior557fc4a2016-04-22 14:20:13 +020061 * @limit: max number of packets that can be queued across all flows
62 * @backlog: number of packets queued across all flows
63 */
64struct fq {
65 struct fq_flow *flows;
Felix Fietkaud7b64922020-12-18 19:47:15 +010066 unsigned long *flows_bitmap;
67
68 struct list_head tin_backlog;
Michal Kazior557fc4a2016-04-22 14:20:13 +020069 spinlock_t lock;
70 u32 flows_cnt;
Michal Kazior557fc4a2016-04-22 14:20:13 +020071 u32 limit;
Toke Høiland-Jørgensen097b0652016-09-23 21:59:09 +020072 u32 memory_limit;
73 u32 memory_usage;
Michal Kazior557fc4a2016-04-22 14:20:13 +020074 u32 quantum;
75 u32 backlog;
76 u32 overlimit;
Toke Høiland-Jørgensen097b0652016-09-23 21:59:09 +020077 u32 overmemory;
Michal Kazior557fc4a2016-04-22 14:20:13 +020078 u32 collisions;
79};
80
81typedef struct sk_buff *fq_tin_dequeue_t(struct fq *,
82 struct fq_tin *,
83 struct fq_flow *flow);
84
85typedef void fq_skb_free_t(struct fq *,
86 struct fq_tin *,
87 struct fq_flow *,
88 struct sk_buff *);
89
Johannes Berg8c418b52017-10-06 11:53:32 +020090/* Return %true to filter (drop) the frame. */
91typedef bool fq_skb_filter_t(struct fq *,
92 struct fq_tin *,
93 struct fq_flow *,
94 struct sk_buff *,
95 void *);
96
Michal Kazior557fc4a2016-04-22 14:20:13 +020097typedef struct fq_flow *fq_flow_get_default_t(struct fq *,
98 struct fq_tin *,
99 int idx,
100 struct sk_buff *);
101
102#endif