Skip to content

Commit fb80445

Browse files
kjbracey2kuba-moo
authored andcommitted
net_sched: restore "mpu xxx" handling
commit 56b765b ("htb: improved accuracy at high rates") broke "overhead X", "linklayer atm" and "mpu X" attributes. "overhead X" and "linklayer atm" have already been fixed. This restores the "mpu X" handling, as might be used by DOCSIS or Ethernet shaping: tc class add ... htb rate X overhead 4 mpu 64 The code being fixed is used by htb, tbf and act_police. Cake has its own mpu handling. qdisc_calculate_pkt_len still uses the size table containing values adjusted for mpu by user space. iproute2 tc has always passed mpu into the kernel via a tc_ratespec structure, but the kernel never directly acted on it, merely stored it so that it could be read back by `tc class show`. Rather, tc would generate length-to-time tables that included the mpu (and linklayer) in their construction, and the kernel used those tables. Since v3.7, the tables were no longer used. Along with "mpu", this also broke "overhead" and "linklayer" which were fixed in 01cb71d ("net_sched: restore "overhead xxx" handling", v3.10) and 8a8e3d8 ("net_sched: restore "linklayer atm" handling", v3.11). "overhead" was fixed by simply restoring use of tc_ratespec::overhead - this had originally been used by the kernel but was initially omitted from the new non-table-based calculations. "linklayer" had been handled in the table like "mpu", but the mode was not originally passed in tc_ratespec. The new implementation was made to handle it by getting new versions of tc to pass the mode in an extended tc_ratespec, and for older versions of tc the table contents were analysed at load time to deduce linklayer. As "mpu" has always been given to the kernel in tc_ratespec, accompanying the mpu-based table, we can restore system functionality with no userspace change by making the kernel act on the tc_ratespec value. Fixes: 56b765b ("htb: improved accuracy at high rates") Signed-off-by: Kevin Bracey <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Jiri Pirko <[email protected]> Cc: Vimalkumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a6fadfd commit fb80445

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/net/sch_generic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,7 @@ struct psched_ratecfg {
12441244
u64 rate_bytes_ps; /* bytes per second */
12451245
u32 mult;
12461246
u16 overhead;
1247+
u16 mpu;
12471248
u8 linklayer;
12481249
u8 shift;
12491250
};
@@ -1253,6 +1254,9 @@ static inline u64 psched_l2t_ns(const struct psched_ratecfg *r,
12531254
{
12541255
len += r->overhead;
12551256

1257+
if (len < r->mpu)
1258+
len = r->mpu;
1259+
12561260
if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
12571261
return ((u64)(DIV_ROUND_UP(len,48)*53) * r->mult) >> r->shift;
12581262

@@ -1275,6 +1279,7 @@ static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
12751279
res->rate = min_t(u64, r->rate_bytes_ps, ~0U);
12761280

12771281
res->overhead = r->overhead;
1282+
res->mpu = r->mpu;
12781283
res->linklayer = (r->linklayer & TC_LINKLAYER_MASK);
12791284
}
12801285

net/sched/sch_generic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ void psched_ratecfg_precompute(struct psched_ratecfg *r,
15291529
{
15301530
memset(r, 0, sizeof(*r));
15311531
r->overhead = conf->overhead;
1532+
r->mpu = conf->mpu;
15321533
r->rate_bytes_ps = max_t(u64, conf->rate, rate64);
15331534
r->linklayer = (conf->linklayer & TC_LINKLAYER_MASK);
15341535
psched_ratecfg_precompute__(r->rate_bytes_ps, &r->mult, &r->shift);

0 commit comments

Comments
 (0)