With psched_ratecfg_precompute(), tbf can deal with 64bit rates. Add two new attributes so that tc can use them to break the 32bit limit.
Unified · Split
| @@ -171,6 +171,8 @@ enum { · 170 unmodified lines | ||
| 171 | 171 | TCA_TBF_PARMS, |
| 172 | 172 | TCA_TBF_RTAB, |
| 173 | 173 | TCA_TBF_PTAB, |
| 174 | + TCA_TBF_RATE64, | |
| 175 | + TCA_TBF_PRATE64, | |
| 174 | 176 | __TCA_TBF_MAX, |
| 175 | 177 | }; |
| 176 | 178 | |
| @@ -266,20 +266,23 @@ static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = { · 265 unmodified lines | ||
| 266 | 266 | [TCA_TBF_PARMS] = { .len = sizeof(struct tc_tbf_qopt) }, |
| 267 | 267 | [TCA_TBF_RTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, |
| 268 | 268 | [TCA_TBF_PTAB] = { .type = NLA_BINARY, .len = TC_RTAB_SIZE }, |
| 269 | + [TCA_TBF_RATE64] = { .type = NLA_U64 }, | |
| 270 | + [TCA_TBF_PRATE64] = { .type = NLA_U64 }, | |
| 269 | 271 | }; |
| 270 | 272 | |
| 271 | 273 | static int tbf_change(struct Qdisc *sch, struct nlattr *opt) |
| 272 | 274 | { |
| 273 | 275 | int err; |
| 274 | 276 | struct tbf_sched_data *q = qdisc_priv(sch); |
| 275 | − struct nlattr *tb[TCA_TBF_PTAB + 1]; | |
| 277 | + struct nlattr *tb[TCA_TBF_MAX + 1]; | |
| 276 | 278 | struct tc_tbf_qopt *qopt; |
| 277 | 279 | struct qdisc_rate_table *rtab = NULL; |
| 278 | 280 | struct qdisc_rate_table *ptab = NULL; |
| 279 | 281 | struct Qdisc *child = NULL; |
| 280 | 282 | int max_size, n; |
| 283 | + u64 rate64 = 0, prate64 = 0; | |
| 281 | 284 | |
| 282 | − err = nla_parse_nested(tb, TCA_TBF_PTAB, opt, tbf_policy); | |
| 285 | + err = nla_parse_nested(tb, TCA_TBF_MAX, opt, tbf_policy); | |
| 283 | 286 | if (err < 0) |
| 284 | 287 | return err; |
| 285 | 288 | |
| @@ -341,9 +344,13 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) · 55 unmodified lines | ||
| 341 | 344 | q->tokens = q->buffer; |
| 342 | 345 | q->ptokens = q->mtu; |
| 343 | 346 | |
| 344 | − psched_ratecfg_precompute(&q->rate, &rtab->rate, 0); | |
| 347 | + if (tb[TCA_TBF_RATE64]) | |
| 348 | + rate64 = nla_get_u64(tb[TCA_TBF_RATE64]); | |
| 349 | + psched_ratecfg_precompute(&q->rate, &rtab->rate, rate64); | |
| 345 | 350 | if (ptab) { |
| 346 | − psched_ratecfg_precompute(&q->peak, &ptab->rate, 0); | |
| 351 | + if (tb[TCA_TBF_PRATE64]) | |
| 352 | + prate64 = nla_get_u64(tb[TCA_TBF_PRATE64]); | |
| 353 | + psched_ratecfg_precompute(&q->peak, &ptab->rate, prate64); | |
| 347 | 354 | q->peak_present = true; |
| 348 | 355 | } else { |
| 349 | 356 | q->peak_present = false; |
| @@ -402,6 +409,13 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb) · 52 unmodified lines | ||
| 402 | 409 | opt.buffer = PSCHED_NS2TICKS(q->buffer); |
| 403 | 410 | if (nla_put(skb, TCA_TBF_PARMS, sizeof(opt), &opt)) |
| 404 | 411 | goto nla_put_failure; |
| 412 | + if (q->rate.rate_bytes_ps >= (1ULL << 32) && | |
| 413 | + nla_put_u64(skb, TCA_TBF_RATE64, q->rate.rate_bytes_ps)) | |
| 414 | + goto nla_put_failure; | |
| 415 | + if (q->peak_present && | |
| 416 | + q->peak.rate_bytes_ps >= (1ULL << 32) && | |
| 417 | + nla_put_u64(skb, TCA_TBF_PRATE64, q->peak.rate_bytes_ps)) | |
| 418 | + goto nla_put_failure; | |
| 405 | 419 | |
| 406 | 420 | nla_nest_end(skb, nest); |
| 407 | 421 | return skb->len; |