Skip to content

Commit c88c5ed

Browse files
committed
Merge branch 'Fix-tail-dropping-watermarks-for-Ocelot-switches'
Vladimir Oltean says: ==================== Fix tail dropping watermarks for Ocelot switches This series adds a missing division by 60, and a warning to prevent that in the future. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 082bb94 + 0132649 commit c88c5ed

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

drivers/net/dsa/ocelot/felix_vsc9959.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,8 @@ static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port,
11711171
*/
11721172
static u16 vsc9959_wm_enc(u16 value)
11731173
{
1174+
WARN_ON(value >= 16 * BIT(8));
1175+
11741176
if (value >= BIT(8))
11751177
return BIT(8) | (value / 16);
11761178

drivers/net/dsa/ocelot/seville_vsc9953.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,8 @@ static int vsc9953_prevalidate_phy_mode(struct ocelot *ocelot, int port,
911911
*/
912912
static u16 vsc9953_wm_enc(u16 value)
913913
{
914+
WARN_ON(value >= 16 * BIT(9));
915+
914916
if (value >= BIT(9))
915917
return BIT(9) | (value / 16);
916918

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

drivers/net/ethernet/mscc/ocelot_vsc7514.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ static int ocelot_reset(struct ocelot *ocelot)
745745
*/
746746
static u16 ocelot_wm_enc(u16 value)
747747
{
748+
WARN_ON(value >= 16 * BIT(8));
749+
748750
if (value >= BIT(8))
749751
return BIT(8) | (value / 16);
750752

0 commit comments

Comments
 (0)