Commit 01cb71d2 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net_sched: restore "overhead xxx" handling

commit 56b765b7 ("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: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Vimalkumar <j.vimal@gmail.com>
Cc: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c87a124a
...@@ -679,22 +679,26 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask, ...@@ -679,22 +679,26 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask,
#endif #endif
struct psched_ratecfg { struct psched_ratecfg {
u64 rate_bps; u64 rate_bps;
u32 mult; u32 mult;
u32 shift; u16 overhead;
u8 shift;
}; };
static inline u64 psched_l2t_ns(const struct psched_ratecfg *r, static inline u64 psched_l2t_ns(const struct psched_ratecfg *r,
unsigned int len) unsigned int len)
{ {
return ((u64)len * r->mult) >> r->shift; return ((u64)(len + r->overhead) * r->mult) >> r->shift;
} }
extern void psched_ratecfg_precompute(struct psched_ratecfg *r, u32 rate); extern void psched_ratecfg_precompute(struct psched_ratecfg *r, const struct tc_ratespec *conf);
static inline u32 psched_ratecfg_getrate(const struct psched_ratecfg *r) static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
const struct psched_ratecfg *r)
{ {
return r->rate_bps >> 3; memset(res, 0, sizeof(*res));
res->rate = r->rate_bps >> 3;
res->overhead = r->overhead;
} }
#endif #endif
...@@ -231,14 +231,14 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla, ...@@ -231,14 +231,14 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
} }
if (R_tab) { if (R_tab) {
police->rate_present = true; police->rate_present = true;
psched_ratecfg_precompute(&police->rate, R_tab->rate.rate); psched_ratecfg_precompute(&police->rate, &R_tab->rate);
qdisc_put_rtab(R_tab); qdisc_put_rtab(R_tab);
} else { } else {
police->rate_present = false; police->rate_present = false;
} }
if (P_tab) { if (P_tab) {
police->peak_present = true; police->peak_present = true;
psched_ratecfg_precompute(&police->peak, P_tab->rate.rate); psched_ratecfg_precompute(&police->peak, &P_tab->rate);
qdisc_put_rtab(P_tab); qdisc_put_rtab(P_tab);
} else { } else {
police->peak_present = false; police->peak_present = false;
...@@ -376,9 +376,9 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) ...@@ -376,9 +376,9 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
}; };
if (police->rate_present) if (police->rate_present)
opt.rate.rate = psched_ratecfg_getrate(&police->rate); psched_ratecfg_getrate(&opt.rate, &police->rate);
if (police->peak_present) if (police->peak_present)
opt.peakrate.rate = psched_ratecfg_getrate(&police->peak); psched_ratecfg_getrate(&opt.peakrate, &police->peak);
if (nla_put(skb, TCA_POLICE_TBF, sizeof(opt), &opt)) if (nla_put(skb, TCA_POLICE_TBF, sizeof(opt), &opt))
goto nla_put_failure; goto nla_put_failure;
if (police->tcfp_result && if (police->tcfp_result &&
......
...@@ -898,14 +898,16 @@ void dev_shutdown(struct net_device *dev) ...@@ -898,14 +898,16 @@ void dev_shutdown(struct net_device *dev)
WARN_ON(timer_pending(&dev->watchdog_timer)); WARN_ON(timer_pending(&dev->watchdog_timer));
} }
void psched_ratecfg_precompute(struct psched_ratecfg *r, u32 rate) void psched_ratecfg_precompute(struct psched_ratecfg *r,
const struct tc_ratespec *conf)
{ {
u64 factor; u64 factor;
u64 mult; u64 mult;
int shift; int shift;
r->rate_bps = (u64)rate << 3; memset(r, 0, sizeof(*r));
r->shift = 0; r->overhead = conf->overhead;
r->rate_bps = (u64)conf->rate << 3;
r->mult = 1; r->mult = 1;
/* /*
* Calibrate mult, shift so that token counting is accurate * Calibrate mult, shift so that token counting is accurate
......
...@@ -1090,9 +1090,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, ...@@ -1090,9 +1090,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
memset(&opt, 0, sizeof(opt)); memset(&opt, 0, sizeof(opt));
opt.rate.rate = psched_ratecfg_getrate(&cl->rate); psched_ratecfg_getrate(&opt.rate, &cl->rate);
opt.buffer = PSCHED_NS2TICKS(cl->buffer); opt.buffer = PSCHED_NS2TICKS(cl->buffer);
opt.ceil.rate = psched_ratecfg_getrate(&cl->ceil); psched_ratecfg_getrate(&opt.ceil, &cl->ceil);
opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer); opt.cbuffer = PSCHED_NS2TICKS(cl->cbuffer);
opt.quantum = cl->quantum; opt.quantum = cl->quantum;
opt.prio = cl->prio; opt.prio = cl->prio;
...@@ -1459,8 +1459,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, ...@@ -1459,8 +1459,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
cl->prio = TC_HTB_NUMPRIO - 1; cl->prio = TC_HTB_NUMPRIO - 1;
} }
psched_ratecfg_precompute(&cl->rate, hopt->rate.rate); psched_ratecfg_precompute(&cl->rate, &hopt->rate);
psched_ratecfg_precompute(&cl->ceil, hopt->ceil.rate); psched_ratecfg_precompute(&cl->ceil, &hopt->ceil);
cl->buffer = PSCHED_TICKS2NS(hopt->buffer); cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
cl->cbuffer = PSCHED_TICKS2NS(hopt->buffer); cl->cbuffer = PSCHED_TICKS2NS(hopt->buffer);
......
...@@ -298,9 +298,9 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt) ...@@ -298,9 +298,9 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
q->tokens = q->buffer; q->tokens = q->buffer;
q->ptokens = q->mtu; q->ptokens = q->mtu;
psched_ratecfg_precompute(&q->rate, rtab->rate.rate); psched_ratecfg_precompute(&q->rate, &rtab->rate);
if (ptab) { if (ptab) {
psched_ratecfg_precompute(&q->peak, ptab->rate.rate); psched_ratecfg_precompute(&q->peak, &ptab->rate);
q->peak_present = true; q->peak_present = true;
} else { } else {
q->peak_present = false; q->peak_present = false;
...@@ -350,9 +350,9 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb) ...@@ -350,9 +350,9 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
goto nla_put_failure; goto nla_put_failure;
opt.limit = q->limit; opt.limit = q->limit;
opt.rate.rate = psched_ratecfg_getrate(&q->rate); psched_ratecfg_getrate(&opt.rate, &q->rate);
if (q->peak_present) if (q->peak_present)
opt.peakrate.rate = psched_ratecfg_getrate(&q->peak); psched_ratecfg_getrate(&opt.peakrate, &q->peak);
else else
memset(&opt.peakrate, 0, sizeof(opt.peakrate)); memset(&opt.peakrate, 0, sizeof(opt.peakrate));
opt.mtu = PSCHED_NS2TICKS(q->mtu); opt.mtu = PSCHED_NS2TICKS(q->mtu);
......
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