Skip to content

Commit 6d9f6e6

Browse files
committed
Merge branch 'net-sched-add-Flow-Queue-PIE-packet-scheduler'
Gautam Ramakrishnan says: ==================== net: sched: add Flow Queue PIE packet scheduler Flow Queue PIE packet scheduler This patch series implements the Flow Queue Proportional Integral controller Enhanced (FQ-PIE) active queue Management algorithm. It is an enhancement over the PIE algorithm. It integrates the PIE aqm with a deficit round robin scheme. FQ-PIE is implemented over the latest version of PIE which uses timestamps to calculate queue delay with an additional option of using average dequeue rate to calculate the queue delay. This patch also adds a memory limit of all the packets across all queues to a default value of 32Mb. - Patch #1 - Creates pie.h and moves all small functions and structures common to PIE and FQ-PIE here. The functions are all made inline. - Patch #2 - #8 - Addresses code formatting, indentation, comment changes and rearrangement of structure members. - Patch #9 - Refactors sch_pie.c by changing arguments to calculate_probability(), [pie_]drop_early() and pie_process_dequeue() to make it generic enough to be used by sch_fq_pie.c. These functions are exported to be used by sch_fq_pie.c. - Patch #10 - Adds the FQ-PIE Qdisc. For more information: https://tools.ietf.org/html/rfc8033 Changes from v6 to v7 - Call tcf_block_put() when destroying the Qdisc as suggested by Jakub Kicinski. Changes from v5 to v6 - Rearranged struct members according to their access pattern and to remove holes. Changes from v4 to v5 - This patch series breaks down patch 1 of v4 into separate logical commits as suggested by David Miller. Changes from v3 to v4 - Used non deprecated version of nla_parse_nested - Used SZ_32M macro - Removed an unused variable - Code cleanup All suggested by Jakub and Toke. Changes from v2 to v3 - Exported drop_early, pie_process_dequeue and calculate_probability functions from sch_pie as suggested by Stephen Hemminger. Changes from v1 ( and RFC patch) to v2 - Added timestamp to calculate queue delay as recommended by Dave Taht - Packet memory limit implemented as recommended by Toke. - Added external classifier as recommended by Toke. - Used NET_XMIT_CN instead of NET_XMIT_DROP as the return value in the fq_pie_qdisc_enqueue function. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents fd786fb + ec97ecf commit 6d9f6e6

File tree

6 files changed

+849
-185
lines changed

6 files changed

+849
-185
lines changed

include/net/pie.h

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef __NET_SCHED_PIE_H
3+
#define __NET_SCHED_PIE_H
4+
5+
#include <linux/ktime.h>
6+
#include <linux/skbuff.h>
7+
#include <linux/types.h>
8+
#include <net/inet_ecn.h>
9+
#include <net/pkt_sched.h>
10+
11+
#define MAX_PROB U64_MAX
12+
#define DTIME_INVALID U64_MAX
13+
#define QUEUE_THRESHOLD 16384
14+
#define DQCOUNT_INVALID -1
15+
#define PIE_SCALE 8
16+
17+
/**
18+
* struct pie_params - contains pie parameters
19+
* @target: target delay in pschedtime
20+
* @tudpate: interval at which drop probability is calculated
21+
* @limit: total number of packets that can be in the queue
22+
* @alpha: parameter to control drop probability
23+
* @beta: parameter to control drop probability
24+
* @ecn: is ECN marking of packets enabled
25+
* @bytemode: is drop probability scaled based on pkt size
26+
* @dq_rate_estimator: is Little's law used for qdelay calculation
27+
*/
28+
struct pie_params {
29+
psched_time_t target;
30+
u32 tupdate;
31+
u32 limit;
32+
u32 alpha;
33+
u32 beta;
34+
u8 ecn;
35+
u8 bytemode;
36+
u8 dq_rate_estimator;
37+
};
38+
39+
/**
40+
* struct pie_vars - contains pie variables
41+
* @qdelay: current queue delay
42+
* @qdelay_old: queue delay in previous qdelay calculation
43+
* @burst_time: burst time allowance
44+
* @dq_tstamp: timestamp at which dq rate was last calculated
45+
* @prob: drop probability
46+
* @accu_prob: accumulated drop probability
47+
* @dq_count: number of bytes dequeued in a measurement cycle
48+
* @avg_dq_rate: calculated average dq rate
49+
* @qlen_old: queue length during previous qdelay calculation
50+
* @accu_prob_overflows: number of times accu_prob overflows
51+
*/
52+
struct pie_vars {
53+
psched_time_t qdelay;
54+
psched_time_t qdelay_old;
55+
psched_time_t burst_time;
56+
psched_time_t dq_tstamp;
57+
u64 prob;
58+
u64 accu_prob;
59+
u64 dq_count;
60+
u32 avg_dq_rate;
61+
u32 qlen_old;
62+
u8 accu_prob_overflows;
63+
};
64+
65+
/**
66+
* struct pie_stats - contains pie stats
67+
* @packets_in: total number of packets enqueued
68+
* @dropped: packets dropped due to pie action
69+
* @overlimit: packets dropped due to lack of space in queue
70+
* @ecn_mark: packets marked with ECN
71+
* @maxq: maximum queue size
72+
*/
73+
struct pie_stats {
74+
u32 packets_in;
75+
u32 dropped;
76+
u32 overlimit;
77+
u32 ecn_mark;
78+
u32 maxq;
79+
};
80+
81+
/**
82+
* struct pie_skb_cb - contains private skb vars
83+
* @enqueue_time: timestamp when the packet is enqueued
84+
* @mem_usage: size of the skb during enqueue
85+
*/
86+
struct pie_skb_cb {
87+
psched_time_t enqueue_time;
88+
u32 mem_usage;
89+
};
90+
91+
static inline void pie_params_init(struct pie_params *params)
92+
{
93+
params->target = PSCHED_NS2TICKS(15 * NSEC_PER_MSEC); /* 15 ms */
94+
params->tupdate = usecs_to_jiffies(15 * USEC_PER_MSEC); /* 15 ms */
95+
params->limit = 1000;
96+
params->alpha = 2;
97+
params->beta = 20;
98+
params->ecn = false;
99+
params->bytemode = false;
100+
params->dq_rate_estimator = false;
101+
}
102+
103+
static inline void pie_vars_init(struct pie_vars *vars)
104+
{
105+
vars->burst_time = PSCHED_NS2TICKS(150 * NSEC_PER_MSEC); /* 150 ms */
106+
vars->dq_tstamp = DTIME_INVALID;
107+
vars->accu_prob = 0;
108+
vars->dq_count = DQCOUNT_INVALID;
109+
vars->avg_dq_rate = 0;
110+
vars->accu_prob_overflows = 0;
111+
}
112+
113+
static inline struct pie_skb_cb *get_pie_cb(const struct sk_buff *skb)
114+
{
115+
qdisc_cb_private_validate(skb, sizeof(struct pie_skb_cb));
116+
return (struct pie_skb_cb *)qdisc_skb_cb(skb)->data;
117+
}
118+
119+
static inline psched_time_t pie_get_enqueue_time(const struct sk_buff *skb)
120+
{
121+
return get_pie_cb(skb)->enqueue_time;
122+
}
123+
124+
static inline void pie_set_enqueue_time(struct sk_buff *skb)
125+
{
126+
get_pie_cb(skb)->enqueue_time = psched_get_time();
127+
}
128+
129+
bool pie_drop_early(struct Qdisc *sch, struct pie_params *params,
130+
struct pie_vars *vars, u32 qlen, u32 packet_size);
131+
132+
void pie_process_dequeue(struct sk_buff *skb, struct pie_params *params,
133+
struct pie_vars *vars, u32 qlen);
134+
135+
void pie_calculate_probability(struct pie_params *params, struct pie_vars *vars,
136+
u32 qlen);
137+
138+
#endif

include/uapi/linux/pkt_sched.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,37 @@ struct tc_pie_xstats {
971971
__u32 ecn_mark; /* packets marked with ecn*/
972972
};
973973

974+
/* FQ PIE */
975+
enum {
976+
TCA_FQ_PIE_UNSPEC,
977+
TCA_FQ_PIE_LIMIT,
978+
TCA_FQ_PIE_FLOWS,
979+
TCA_FQ_PIE_TARGET,
980+
TCA_FQ_PIE_TUPDATE,
981+
TCA_FQ_PIE_ALPHA,
982+
TCA_FQ_PIE_BETA,
983+
TCA_FQ_PIE_QUANTUM,
984+
TCA_FQ_PIE_MEMORY_LIMIT,
985+
TCA_FQ_PIE_ECN_PROB,
986+
TCA_FQ_PIE_ECN,
987+
TCA_FQ_PIE_BYTEMODE,
988+
TCA_FQ_PIE_DQ_RATE_ESTIMATOR,
989+
__TCA_FQ_PIE_MAX
990+
};
991+
#define TCA_FQ_PIE_MAX (__TCA_FQ_PIE_MAX - 1)
992+
993+
struct tc_fq_pie_xstats {
994+
__u32 packets_in; /* total number of packets enqueued */
995+
__u32 dropped; /* packets dropped due to fq_pie_action */
996+
__u32 overlimit; /* dropped due to lack of space in queue */
997+
__u32 overmemory; /* dropped due to lack of memory in queue */
998+
__u32 ecn_mark; /* packets marked with ecn */
999+
__u32 new_flow_count; /* count of new flows created by packets */
1000+
__u32 new_flows_len; /* count of flows in new list */
1001+
__u32 old_flows_len; /* count of flows in old list */
1002+
__u32 memory_usage; /* total memory across all queues */
1003+
};
1004+
9741005
/* CBS */
9751006
struct tc_cbs_qopt {
9761007
__u8 offload;

net/sched/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,19 @@ config NET_SCH_PIE
366366

367367
If unsure, say N.
368368

369+
config NET_SCH_FQ_PIE
370+
depends on NET_SCH_PIE
371+
tristate "Flow Queue Proportional Integral controller Enhanced (FQ-PIE)"
372+
help
373+
Say Y here if you want to use the Flow Queue Proportional Integral
374+
controller Enhanced (FQ-PIE) packet scheduling algorithm.
375+
For more information, please see https://tools.ietf.org/html/rfc8033
376+
377+
To compile this driver as a module, choose M here: the module
378+
will be called sch_fq_pie.
379+
380+
If unsure, say N.
381+
369382
config NET_SCH_INGRESS
370383
tristate "Ingress/classifier-action Qdisc"
371384
depends on NET_CLS_ACT

net/sched/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ obj-$(CONFIG_NET_SCH_CAKE) += sch_cake.o
5959
obj-$(CONFIG_NET_SCH_FQ) += sch_fq.o
6060
obj-$(CONFIG_NET_SCH_HHF) += sch_hhf.o
6161
obj-$(CONFIG_NET_SCH_PIE) += sch_pie.o
62+
obj-$(CONFIG_NET_SCH_FQ_PIE) += sch_fq_pie.o
6263
obj-$(CONFIG_NET_SCH_CBS) += sch_cbs.o
6364
obj-$(CONFIG_NET_SCH_ETF) += sch_etf.o
6465
obj-$(CONFIG_NET_SCH_TAPRIO) += sch_taprio.o

0 commit comments

Comments
 (0)