net/sched: cbs: fix port_rate miscalculation
authorLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Mon, 8 Apr 2019 17:12:18 +0000 (10:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Apr 2019 02:27:43 +0000 (19:27 -0700)
commite0a7683d30e91e30ee6cf96314ae58a0314a095e
tree53f09e9181d390982ca2de2fd7903e8feb65c08d
parent7b9eba7ba0c1b24df42b70b62d154b284befbccf
net/sched: cbs: fix port_rate miscalculation

The Credit Based Shaper heavily depends on link speed to calculate
the scheduling credits, we can't properly calculate the credits if the
device has failed to report the link speed.

In that case we can't dequeue packets assuming a wrong port rate that will
result into an inconsistent credit distribution.

This patch makes sure we fail to dequeue case:

1) __ethtool_get_link_ksettings() reports error or 2) the ethernet driver
failed to set the ksettings' speed value (setting link speed to
SPEED_UNKNOWN).

Additionally we properly re calculate the port rate whenever the link speed
is changed.

Fixes: 3d0bd028ffb4a ("net/sched: Add support for HW offloading for CBS")
Signed-off-by: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
Reviewed-by: Vedang Patel <vedang.patel@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_cbs.c