* [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches
@ 2020-10-05 9:09 Vladimir Oltean
2020-10-05 9:09 ` [PATCH net 1/2] net: mscc: ocelot: divide watermark value by 60 when writing to SYS_ATOP Vladimir Oltean
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Vladimir Oltean @ 2020-10-05 9:09 UTC (permalink / raw)
To: davem
Cc: alexandre.belloni, andrew, f.fainelli, vivien.didelot,
alexandru.marginean, claudiu.manoil, xiaoliang.yang_1,
hongbo.wang, netdev, UNGLinuxDriver
This series adds a missing division by 60, and a warning to prevent that
in the future.
Vladimir Oltean (2):
net: mscc: ocelot: divide watermark value by 60 when writing to
SYS_ATOP
net: mscc: ocelot: warn when encoding an out-of-bounds watermark value
drivers/net/dsa/ocelot/felix_vsc9959.c | 2 ++
drivers/net/dsa/ocelot/seville_vsc9953.c | 2 ++
drivers/net/ethernet/mscc/ocelot.c | 12 ++++++------
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 2 ++
4 files changed, 12 insertions(+), 6 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net 1/2] net: mscc: ocelot: divide watermark value by 60 when writing to SYS_ATOP
2020-10-05 9:09 [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches Vladimir Oltean
@ 2020-10-05 9:09 ` Vladimir Oltean
2020-10-05 9:09 ` [PATCH net 2/2] net: mscc: ocelot: warn when encoding an out-of-bounds watermark value Vladimir Oltean
2020-10-06 13:06 ` [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2020-10-05 9:09 UTC (permalink / raw)
To: davem
Cc: alexandre.belloni, andrew, f.fainelli, vivien.didelot,
alexandru.marginean, claudiu.manoil, xiaoliang.yang_1,
hongbo.wang, netdev, UNGLinuxDriver
Tail dropping is enabled for a port when:
1. A source port consumes more packet buffers than the watermark encoded
in SYS:PORT:ATOP_CFG.ATOP.
AND
2. Total memory use exceeds the consumption watermark encoded in
SYS:PAUSE_CFG:ATOP_TOT_CFG.
The unit of these watermarks is a 60 byte memory cell. That unit is
programmed properly into ATOP_TOT_CFG, but not into ATOP. Actually when
written into ATOP, it would get truncated and wrap around.
Fixes: a556c76adc05 ("net: mscc: Add initial Ocelot switch support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/ethernet/mscc/ocelot.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index e026617d6133..f435dc4d5573 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1253,7 +1253,7 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
struct ocelot_port *ocelot_port = ocelot->ports[port];
int maxlen = sdu + ETH_HLEN + ETH_FCS_LEN;
int pause_start, pause_stop;
- int atop_wm;
+ int atop, atop_tot;
if (port == ocelot->npi) {
maxlen += OCELOT_TAG_LEN;
@@ -1274,12 +1274,12 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_STOP,
pause_stop);
- /* Tail dropping watermark */
- atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
+ /* Tail dropping watermarks */
+ atop_tot = (ocelot->shared_queue_sz - 9 * maxlen) /
OCELOT_BUFFER_CELL_SZ;
- ocelot_write_rix(ocelot, ocelot->ops->wm_enc(9 * maxlen),
- SYS_ATOP, port);
- ocelot_write(ocelot, ocelot->ops->wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
+ atop = (9 * maxlen) / OCELOT_BUFFER_CELL_SZ;
+ ocelot_write_rix(ocelot, ocelot->ops->wm_enc(atop), SYS_ATOP, port);
+ ocelot_write(ocelot, ocelot->ops->wm_enc(atop_tot), SYS_ATOP_TOT_CFG);
}
EXPORT_SYMBOL(ocelot_port_set_maxlen);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net 2/2] net: mscc: ocelot: warn when encoding an out-of-bounds watermark value
2020-10-05 9:09 [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches Vladimir Oltean
2020-10-05 9:09 ` [PATCH net 1/2] net: mscc: ocelot: divide watermark value by 60 when writing to SYS_ATOP Vladimir Oltean
@ 2020-10-05 9:09 ` Vladimir Oltean
2020-10-06 13:06 ` [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2020-10-05 9:09 UTC (permalink / raw)
To: davem
Cc: alexandre.belloni, andrew, f.fainelli, vivien.didelot,
alexandru.marginean, claudiu.manoil, xiaoliang.yang_1,
hongbo.wang, netdev, UNGLinuxDriver
There is an upper bound to the value that a watermark may hold. That
upper bound is not immediately obvious during configuration, and it
might be possible to have accidental truncation.
Actually this has happened already, add a warning to prevent it from
happening again.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/dsa/ocelot/felix_vsc9959.c | 2 ++
drivers/net/dsa/ocelot/seville_vsc9953.c | 2 ++
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 4fc67ff212de..cb0f3d28ecac 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -998,6 +998,8 @@ static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port,
*/
static u16 vsc9959_wm_enc(u16 value)
{
+ WARN_ON(value >= 16 * BIT(8));
+
if (value >= BIT(8))
return BIT(8) | (value / 16);
diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c
index e993f3eac3eb..76576cf0ba8a 100644
--- a/drivers/net/dsa/ocelot/seville_vsc9953.c
+++ b/drivers/net/dsa/ocelot/seville_vsc9953.c
@@ -1049,6 +1049,8 @@ static int vsc9953_prevalidate_phy_mode(struct ocelot *ocelot, int port,
*/
static u16 vsc9953_wm_enc(u16 value)
{
+ WARN_ON(value >= 16 * BIT(9));
+
if (value >= BIT(9))
return BIT(9) | (value / 16);
diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
index f3e54589e6d6..79b88bc69c75 100644
--- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
+++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
@@ -754,6 +754,8 @@ static int ocelot_reset(struct ocelot *ocelot)
*/
static u16 ocelot_wm_enc(u16 value)
{
+ WARN_ON(value >= 16 * BIT(8));
+
if (value >= BIT(8))
return BIT(8) | (value / 16);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches
2020-10-05 9:09 [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches Vladimir Oltean
2020-10-05 9:09 ` [PATCH net 1/2] net: mscc: ocelot: divide watermark value by 60 when writing to SYS_ATOP Vladimir Oltean
2020-10-05 9:09 ` [PATCH net 2/2] net: mscc: ocelot: warn when encoding an out-of-bounds watermark value Vladimir Oltean
@ 2020-10-06 13:06 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-10-06 13:06 UTC (permalink / raw)
To: vladimir.oltean
Cc: alexandre.belloni, andrew, f.fainelli, vivien.didelot,
alexandru.marginean, claudiu.manoil, xiaoliang.yang_1,
hongbo.wang, netdev, UNGLinuxDriver
From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: Mon, 5 Oct 2020 12:09:10 +0300
> This series adds a missing division by 60, and a warning to prevent that
> in the future.
Series applied, thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-06 13:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-05 9:09 [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches Vladimir Oltean
2020-10-05 9:09 ` [PATCH net 1/2] net: mscc: ocelot: divide watermark value by 60 when writing to SYS_ATOP Vladimir Oltean
2020-10-05 9:09 ` [PATCH net 2/2] net: mscc: ocelot: warn when encoding an out-of-bounds watermark value Vladimir Oltean
2020-10-06 13:06 ` [PATCH net 0/2] Fix tail dropping watermarks for Ocelot switches David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).