Skip to content

Commit 01cb71d

Browse files
edumazetdavem330
authored andcommitted
net_sched: restore "overhead xxx" handling
commit 56b765b ("htb: improved accuracy at high rates") broke the "overhead xxx" handling, as well as the "linklayer atm" attribute. tc class add ... htb rate X ceil Y linklayer atm overhead 10 This patch restores the "overhead xxx" handling, for htb, tbf and act_police The "linklayer atm" thing needs a separate fix. Reported-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Cc: Vimalkumar <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c87a124 commit 01cb71d

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

include/net/sch_generic.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -679,22 +679,26 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask,
679679
#endif
680680

681681
struct psched_ratecfg {
682-
u64 rate_bps;
683-
u32 mult;
684-
u32 shift;
682+
u64 rate_bps;
683+
u32 mult;
684+
u16 overhead;
685+
u8 shift;
685686
};
686687

687688
static inline u64 psched_l2t_ns(const struct psched_ratecfg *r,
688689
unsigned int len)
689690
{
690-
return ((u64)len * r->mult) >> r->shift;
691+
return ((u64)(len + r->overhead) * r->mult) >> r->shift;
691692
}
692693

693-
extern void psched_ratecfg_precompute(struct psched_ratecfg *r, u32 rate);
694+
extern void psched_ratecfg_precompute(struct psched_ratecfg *r, const struct tc_ratespec *conf);
694695

695-
static inline u32 psched_ratecfg_getrate(const struct psched_ratecfg *r)
696+
static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
697+
const struct psched_ratecfg *r)
696698
{
697-
return r->rate_bps >> 3;
699+
memset(res, 0, sizeof(*res));
700+
res->rate = r->rate_bps >> 3;
701+
res->overhead = r->overhead;
698702
}
699703

700704
#endif

net/sched/act_police.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
231231
}
232232
if (R_tab) {
233233
police->rate_present = true;
234-
psched_ratecfg_precompute(&police->rate, R_tab->rate.rate);
234+
psched_ratecfg_precompute(&police->rate, &R_tab->rate);
235235
qdisc_put_rtab(R_tab);
236236
} else {
237237
police->rate_present = false;
238238
}
239239
if (P_tab) {
240240
police->peak_present = true;
241-
psched_ratecfg_precompute(&police->peak, P_tab->rate.rate);
241+
psched_ratecfg_precompute(&police->peak, &P_tab->rate);
242242
qdisc_put_rtab(P_tab);
243243
} else {
244244
police->peak_present = false;
@@ -376,9 +376,9 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
376376
};
377377

378378
if (police->rate_present)
379-
opt.rate.rate = psched_ratecfg_getrate(&police->rate);
379+
psched_ratecfg_getrate(&opt.rate, &police->rate);
380380
if (police->peak_present)
381-
opt.peakrate.rate = psched_ratecfg_getrate(&police->peak);
381+
psched_ratecfg_getrate(&opt.peakrate, &police->peak);
382382
if (nla_put(skb, TCA_POLICE_TBF, sizeof(opt), &opt))
383383
goto nla_put_failure;
384384
if (police->tcfp_result &&

net/sched/sch_generic.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,14 +898,16 @@ void dev_shutdown(struct net_device *dev)
898898
WARN_ON(timer_pending(&dev->watchdog_timer));
899899
}
900900

901-
void psched_ratecfg_precompute(struct psched_ratecfg *r, u32 rate)
901+
void psched_ratecfg_precompute(struct psched_ratecfg *r,
902+
const struct tc_ratespec *conf)
902903
{
903904
u64 factor;
904905
u64 mult;
905906
int shift;
906907

907-
r->rate_bps = (u64)rate << 3;
908-
r->shift = 0;
908+
memset(r, 0, sizeof(*r));
909+
r->overhead = conf->overhead;
910+
r->rate_bps = (u64)conf->rate << 3;
909911
r->mult = 1;
910912
/*
911913
* Calibrate mult, shift so that token counting is accurate

net/sched/sch_htb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,9 +1090,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
10901090

10911091
memset(&opt, 0, sizeof(opt));
10921092

1093-
opt.rate.rate = psched_ratecfg_getrate(&cl->rate);
1093+
psched_ratecfg_getrate(&opt.rate, &cl->rate);
10941094
opt.buffer = PSCHED_NS2TICKS(cl->buffer);
1095-
opt.ceil.rate = psched_ratecfg_getrate(&cl->ceil);
1095+
psched_ratecfg_getrate(&opt.ceil, &cl->ceil);
10961096
opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer);
10971097
opt.quantum = cl->quantum;
10981098
opt.prio = cl->prio;
@@ -1459,8 +1459,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
14591459
cl->prio = TC_HTB_NUMPRIO - 1;
14601460
}
14611461

1462-
psched_ratecfg_precompute(&cl->rate, hopt->rate.rate);
1463-
psched_ratecfg_precompute(&cl->ceil, hopt->ceil.rate);
1462+
psched_ratecfg_precompute(&cl->rate, &hopt->rate);
1463+
psched_ratecfg_precompute(&cl->ceil, &hopt->ceil);
14641464

14651465
cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
14661466
cl->cbuffer = PSCHED_TICKS2NS(hopt->buffer);

net/sched/sch_tbf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
298298
q->tokens = q->buffer;
299299
q->ptokens = q->mtu;
300300

301-
psched_ratecfg_precompute(&q->rate, rtab->rate.rate);
301+
psched_ratecfg_precompute(&q->rate, &rtab->rate);
302302
if (ptab) {
303-
psched_ratecfg_precompute(&q->peak, ptab->rate.rate);
303+
psched_ratecfg_precompute(&q->peak, &ptab->rate);
304304
q->peak_present = true;
305305
} else {
306306
q->peak_present = false;
@@ -350,9 +350,9 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
350350
goto nla_put_failure;
351351

352352
opt.limit = q->limit;
353-
opt.rate.rate = psched_ratecfg_getrate(&q->rate);
353+
psched_ratecfg_getrate(&opt.rate, &q->rate);
354354
if (q->peak_present)
355-
opt.peakrate.rate = psched_ratecfg_getrate(&q->peak);
355+
psched_ratecfg_getrate(&opt.peakrate, &q->peak);
356356
else
357357
memset(&opt.peakrate, 0, sizeof(opt.peakrate));
358358
opt.mtu = PSCHED_NS2TICKS(q->mtu);

0 commit comments

Comments
 (0)