Commit 565af7b8 authored by Phil Sutter's avatar Phil Sutter Committed by Stephen Hemminger

tc: fq: allow setting and retrieving flow refill delay

Code to parse and export this tuneable via netlink is already present in
sched_fq.c of the kernel, so not making it accessible for users would be
a waste of resources.
Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
parent f171b858
...@@ -54,7 +54,7 @@ static void explain(void) ...@@ -54,7 +54,7 @@ static void explain(void)
fprintf(stderr, "Usage: ... fq [ limit PACKETS ] [ flow_limit PACKETS ]\n"); fprintf(stderr, "Usage: ... fq [ limit PACKETS ] [ flow_limit PACKETS ]\n");
fprintf(stderr, " [ quantum BYTES ] [ initial_quantum BYTES ]\n"); fprintf(stderr, " [ quantum BYTES ] [ initial_quantum BYTES ]\n");
fprintf(stderr, " [ maxrate RATE ] [ buckets NUMBER ]\n"); fprintf(stderr, " [ maxrate RATE ] [ buckets NUMBER ]\n");
fprintf(stderr, " [ [no]pacing ]\n"); fprintf(stderr, " [ [no]pacing ] [ refill_delay TIME ]\n");
} }
static unsigned int ilog2(unsigned int val) static unsigned int ilog2(unsigned int val)
...@@ -79,12 +79,14 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv, ...@@ -79,12 +79,14 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
unsigned int buckets = 0; unsigned int buckets = 0;
unsigned int maxrate; unsigned int maxrate;
unsigned int defrate; unsigned int defrate;
unsigned int refill_delay;
bool set_plimit = false; bool set_plimit = false;
bool set_flow_plimit = false; bool set_flow_plimit = false;
bool set_quantum = false; bool set_quantum = false;
bool set_initial_quantum = false; bool set_initial_quantum = false;
bool set_maxrate = false; bool set_maxrate = false;
bool set_defrate = false; bool set_defrate = false;
bool set_refill_delay = false;
int pacing = -1; int pacing = -1;
struct rtattr *tail; struct rtattr *tail;
...@@ -137,6 +139,13 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv, ...@@ -137,6 +139,13 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
return -1; return -1;
} }
set_initial_quantum = true; set_initial_quantum = true;
} else if (strcmp(*argv, "refill_delay") == 0) {
NEXT_ARG();
if (get_time(&refill_delay, *argv)) {
fprintf(stderr, "Illegal \"refill_delay\"\n");
return -1;
}
set_refill_delay = true;
} else if (strcmp(*argv, "pacing") == 0) { } else if (strcmp(*argv, "pacing") == 0) {
pacing = 1; pacing = 1;
} else if (strcmp(*argv, "nopacing") == 0) { } else if (strcmp(*argv, "nopacing") == 0) {
...@@ -180,6 +189,9 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv, ...@@ -180,6 +189,9 @@ static int fq_parse_opt(struct qdisc_util *qu, int argc, char **argv,
if (set_defrate) if (set_defrate)
addattr_l(n, 1024, TCA_FQ_FLOW_DEFAULT_RATE, addattr_l(n, 1024, TCA_FQ_FLOW_DEFAULT_RATE,
&defrate, sizeof(defrate)); &defrate, sizeof(defrate));
if (set_refill_delay)
addattr_l(n, 1024, TCA_FQ_FLOW_REFILL_DELAY,
&refill_delay, sizeof(refill_delay));
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
return 0; return 0;
} }
...@@ -191,6 +203,7 @@ static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) ...@@ -191,6 +203,7 @@ static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
unsigned int buckets_log; unsigned int buckets_log;
int pacing; int pacing;
unsigned int rate, quantum; unsigned int rate, quantum;
unsigned int refill_delay;
SPRINT_BUF(b1); SPRINT_BUF(b1);
if (opt == NULL) if (opt == NULL)
...@@ -243,6 +256,11 @@ static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) ...@@ -243,6 +256,11 @@ static int fq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
if (rate != 0) if (rate != 0)
fprintf(f, "defrate %s ", sprint_rate(rate, b1)); fprintf(f, "defrate %s ", sprint_rate(rate, b1));
} }
if (tb[TCA_FQ_FLOW_REFILL_DELAY] &&
RTA_PAYLOAD(tb[TCA_FQ_FLOW_REFILL_DELAY]) >= sizeof(__u32)) {
refill_delay = rta_getattr_u32(tb[TCA_FQ_FLOW_REFILL_DELAY]);
fprintf(f, "refill_delay %s ", sprint_time(refill_delay, b1));
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment