mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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 Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Dave Taht <dave.taht@gmail.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
		
							parent
							
								
									29f834aa32
								
							
						
					
					
						commit
						49e7265fd0
					
				
					 2 changed files with 36 additions and 0 deletions
				
			
		| 
						 | 
					@ -943,12 +943,15 @@ enum {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TCA_FQ_PRIOMAP,		/* prio2band */
 | 
						TCA_FQ_PRIOMAP,		/* prio2band */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TCA_FQ_WEIGHTS,		/* Weights for each band */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__TCA_FQ_MAX
 | 
						__TCA_FQ_MAX
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define TCA_FQ_MAX	(__TCA_FQ_MAX - 1)
 | 
					#define TCA_FQ_MAX	(__TCA_FQ_MAX - 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FQ_BANDS 3
 | 
					#define FQ_BANDS 3
 | 
				
			||||||
 | 
					#define FQ_MIN_WEIGHT 16384
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct tc_fq_qd_stats {
 | 
					struct tc_fq_qd_stats {
 | 
				
			||||||
	__u64	gc_flows;
 | 
						__u64	gc_flows;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -919,6 +919,10 @@ static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = {
 | 
				
			||||||
			.type = NLA_BINARY,
 | 
								.type = NLA_BINARY,
 | 
				
			||||||
			.len = sizeof(struct tc_prio_qopt),
 | 
								.len = sizeof(struct tc_prio_qopt),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
						[TCA_FQ_WEIGHTS]		= {
 | 
				
			||||||
 | 
								.type = NLA_BINARY,
 | 
				
			||||||
 | 
								.len = FQ_BANDS * sizeof(s32),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* compress a u8 array with all elems <= 3 to an array of 2-bit fields */
 | 
					/* 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)
 | 
				
			||||||
		out[i] = fq_prio2band(in, i);
 | 
							out[i] = fq_prio2band(in, i);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int fq_load_weights(struct fq_sched_data *q,
 | 
				
			||||||
 | 
								   const struct nlattr *attr,
 | 
				
			||||||
 | 
								   struct netlink_ext_ack *extack)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						s32 *weights = nla_data(attr);
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i = 0; i < FQ_BANDS; i++) {
 | 
				
			||||||
 | 
							if (weights[i] < FQ_MIN_WEIGHT) {
 | 
				
			||||||
 | 
								NL_SET_ERR_MSG_FMT_MOD(extack, "Weight %d less that minimum allowed %d",
 | 
				
			||||||
 | 
										       weights[i], FQ_MIN_WEIGHT);
 | 
				
			||||||
 | 
								return -EINVAL;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for (i = 0; i < FQ_BANDS; i++)
 | 
				
			||||||
 | 
							q->band_flows[i].quantum = weights[i];
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int fq_load_priomap(struct fq_sched_data *q,
 | 
					static int fq_load_priomap(struct fq_sched_data *q,
 | 
				
			||||||
			   const struct nlattr *attr,
 | 
								   const struct nlattr *attr,
 | 
				
			||||||
			   struct netlink_ext_ack *extack)
 | 
								   struct netlink_ext_ack *extack)
 | 
				
			||||||
| 
						 | 
					@ -1040,6 +1063,9 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	if (!err && tb[TCA_FQ_PRIOMAP])
 | 
						if (!err && tb[TCA_FQ_PRIOMAP])
 | 
				
			||||||
		err = fq_load_priomap(q, tb[TCA_FQ_PRIOMAP], extack);
 | 
							err = fq_load_priomap(q, tb[TCA_FQ_PRIOMAP], extack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!err && tb[TCA_FQ_WEIGHTS])
 | 
				
			||||||
 | 
							err = fq_load_weights(q, tb[TCA_FQ_WEIGHTS], extack);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (tb[TCA_FQ_ORPHAN_MASK])
 | 
						if (tb[TCA_FQ_ORPHAN_MASK])
 | 
				
			||||||
		q->orphan_mask = nla_get_u32(tb[TCA_FQ_ORPHAN_MASK]);
 | 
							q->orphan_mask = nla_get_u32(tb[TCA_FQ_ORPHAN_MASK]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1142,6 +1168,7 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	u64 horizon = q->horizon;
 | 
						u64 horizon = q->horizon;
 | 
				
			||||||
	struct nlattr *opts;
 | 
						struct nlattr *opts;
 | 
				
			||||||
 | 
						s32 weights[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	opts = nla_nest_start_noflag(skb, TCA_OPTIONS);
 | 
						opts = nla_nest_start_noflag(skb, TCA_OPTIONS);
 | 
				
			||||||
	if (opts == NULL)
 | 
						if (opts == NULL)
 | 
				
			||||||
| 
						 | 
					@ -1175,6 +1202,12 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
 | 
				
			||||||
	if (nla_put(skb, TCA_FQ_PRIOMAP, sizeof(prio), &prio))
 | 
						if (nla_put(skb, TCA_FQ_PRIOMAP, sizeof(prio), &prio))
 | 
				
			||||||
		goto nla_put_failure;
 | 
							goto nla_put_failure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						weights[0] = q->band_flows[0].quantum;
 | 
				
			||||||
 | 
						weights[1] = q->band_flows[1].quantum;
 | 
				
			||||||
 | 
						weights[2] = q->band_flows[2].quantum;
 | 
				
			||||||
 | 
						if (nla_put(skb, TCA_FQ_WEIGHTS, sizeof(weights), &weights))
 | 
				
			||||||
 | 
							goto nla_put_failure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nla_nest_end(skb, opts);
 | 
						return nla_nest_end(skb, opts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nla_put_failure:
 | 
					nla_put_failure:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue