Skip to content

Commit 601e984

Browse files
vladimirolteandavem330
authored andcommitted
net: mscc: ocelot: divide watermark value by 60 when writing to SYS_ATOP
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: a556c76 ("net: mscc: Add initial Ocelot switch support") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 082bb94 commit 601e984

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
12531253
struct ocelot_port *ocelot_port = ocelot->ports[port];
12541254
int maxlen = sdu + ETH_HLEN + ETH_FCS_LEN;
12551255
int pause_start, pause_stop;
1256-
int atop_wm;
1256+
int atop, atop_tot;
12571257

12581258
if (port == ocelot->npi) {
12591259
maxlen += OCELOT_TAG_LEN;
@@ -1274,12 +1274,12 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
12741274
ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_STOP,
12751275
pause_stop);
12761276

1277-
/* Tail dropping watermark */
1278-
atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
1277+
/* Tail dropping watermarks */
1278+
atop_tot = (ocelot->shared_queue_sz - 9 * maxlen) /
12791279
OCELOT_BUFFER_CELL_SZ;
1280-
ocelot_write_rix(ocelot, ocelot->ops->wm_enc(9 * maxlen),
1281-
SYS_ATOP, port);
1282-
ocelot_write(ocelot, ocelot->ops->wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
1280+
atop = (9 * maxlen) / OCELOT_BUFFER_CELL_SZ;
1281+
ocelot_write_rix(ocelot, ocelot->ops->wm_enc(atop), SYS_ATOP, port);
1282+
ocelot_write(ocelot, ocelot->ops->wm_enc(atop_tot), SYS_ATOP_TOT_CFG);
12831283
}
12841284
EXPORT_SYMBOL(ocelot_port_set_maxlen);
12851285

0 commit comments

Comments
 (0)