History

net_sched: sch_fq: add TCA_FQ_WEIGHTS attribute

This attribute can be used to tune the per band weight and report them in "tc qdisc show" output: qdisc fq 802f: parent 1:9 limit 100000p flow_limit 500p buckets 1024 orphan_mask 1023 quantum 8364b initial_quantum 41820b low_rate_threshold 550Kbit refill_delay 40ms timer_slack 10us horizon 10s horizon_drop bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 weights 589824 196608 65536 Sent 236460814 bytes 792991 pkt (dropped 0, overlimits 0 requeues 0) rate 25816bit 10pps backlog 0b 0p requeues 0 flows 4 (inactive 4 throttled 0) gc 0 throttled 19 latency 17.6us fastpath 773882

Eric Dumazet committed 3 years ago

Commit 49e72651 parent 29f834a2 files · +36 −0Browse files

Unified · Split

2 files
  1. include/uapi/linux/pkt_sched.h +3 −0
  2. net/sched/sch_fq.c +33 −0
include/uapi/linux/pkt_sched.h+3−0
@@ -943,12 +943,15 @@ enum { · 942 unmodified lines
943943
944944 TCA_FQ_PRIOMAP, /* prio2band */
945945
946+ TCA_FQ_WEIGHTS, /* Weights for each band */
947+
946948 __TCA_FQ_MAX
947949 };
948950
949951 #define TCA_FQ_MAX (__TCA_FQ_MAX - 1)
950952
951953 #define FQ_BANDS 3
954+#define FQ_MIN_WEIGHT 16384
952955
953956 struct tc_fq_qd_stats {
954957 __u64 gc_flows;
net/sched/sch_fq.c+33−0
@@ -919,6 +919,10 @@ static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = { · 918 unmodified lines
919919 .type = NLA_BINARY,
920920 .len = sizeof(struct tc_prio_qopt),
921921 },
922+ [TCA_FQ_WEIGHTS] = {
923+ .type = NLA_BINARY,
924+ .len = FQ_BANDS * sizeof(s32),
925+ },
922926 };
923927
924928 /* compress a u8 array with all elems <= 3 to an array of 2-bit fields */
@@ -941,6 +945,25 @@ static void fq_prio2band_decompress_crumb(const u8 *in, u8 *out) · 16 unmodified lines
941945 out[i] = fq_prio2band(in, i);
942946 }
943947
948+static int fq_load_weights(struct fq_sched_data *q,
949+ const struct nlattr *attr,
950+ struct netlink_ext_ack *extack)
951+{
952+ s32 *weights = nla_data(attr);
953+ int i;
954+
955+ for (i = 0; i < FQ_BANDS; i++) {
956+ if (weights[i] < FQ_MIN_WEIGHT) {
957+ NL_SET_ERR_MSG_FMT_MOD(extack, "Weight %d less that minimum allowed %d",
958+ weights[i], FQ_MIN_WEIGHT);
959+ return -EINVAL;
960+ }
961+ }
962+ for (i = 0; i < FQ_BANDS; i++)
963+ q->band_flows[i].quantum = weights[i];
964+ return 0;
965+}
966+
944967 static int fq_load_priomap(struct fq_sched_data *q,
945968 const struct nlattr *attr,
946969 struct netlink_ext_ack *extack)
@@ -1040,6 +1063,9 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt, · 93 unmodified lines
10401063 if (!err && tb[TCA_FQ_PRIOMAP])
10411064 err = fq_load_priomap(q, tb[TCA_FQ_PRIOMAP], extack);
10421065
1066+ if (!err && tb[TCA_FQ_WEIGHTS])
1067+ err = fq_load_weights(q, tb[TCA_FQ_WEIGHTS], extack);
1068+
10431069 if (tb[TCA_FQ_ORPHAN_MASK])
10441070 q->orphan_mask = nla_get_u32(tb[TCA_FQ_ORPHAN_MASK]);
10451071
@@ -1142,6 +1168,7 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb) · 96 unmodified lines
11421168 };
11431169 u64 horizon = q->horizon;
11441170 struct nlattr *opts;
1171+ s32 weights[3];
11451172
11461173 opts = nla_nest_start_noflag(skb, TCA_OPTIONS);
11471174 if (opts == NULL)
@@ -1175,6 +1202,12 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb) · 27 unmodified lines
11751202 if (nla_put(skb, TCA_FQ_PRIOMAP, sizeof(prio), &prio))
11761203 goto nla_put_failure;
11771204
1205+ weights[0] = q->band_flows[0].quantum;
1206+ weights[1] = q->band_flows[1].quantum;
1207+ weights[2] = q->band_flows[2].quantum;
1208+ if (nla_put(skb, TCA_FQ_WEIGHTS, sizeof(weights), &weights))
1209+ goto nla_put_failure;
1210+
11781211 return nla_nest_end(skb, opts);
11791212
11801213 nla_put_failure:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t