Skip to content

Commit aa92d83

Browse files
fidomaxdavem330
authored andcommitted
net: mscc: ocelot: extend watermark encoding function
The ocelot_wm_encode function deals with setting thresholds for pause frame start and stop. In Ocelot and Felix the register layout is the same, but for Seville, it isn't. The easiest way to accommodate Seville hardware configuration is to introduce a function pointer for setting this up. Signed-off-by: Maxim Kochetkov <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 541132f commit aa92d83

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

drivers/net/dsa/ocelot/felix_vsc9959.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,21 @@ static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port,
11491149
}
11501150
}
11511151

1152+
/* Watermark encode
1153+
* Bit 8: Unit; 0:1, 1:16
1154+
* Bit 7-0: Value to be multiplied with unit
1155+
*/
1156+
static u16 vsc9959_wm_enc(u16 value)
1157+
{
1158+
if (value >= BIT(8))
1159+
return BIT(8) | (value / 16);
1160+
1161+
return value;
1162+
}
1163+
11521164
static const struct ocelot_ops vsc9959_ops = {
11531165
.reset = vsc9959_reset,
1166+
.wm_enc = vsc9959_wm_enc,
11541167
};
11551168

11561169
static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,6 @@ static void ocelot_vlan_init(struct ocelot *ocelot)
309309
}
310310
}
311311

312-
/* Watermark encode
313-
* Bit 8: Unit; 0:1, 1:16
314-
* Bit 7-0: Value to be multiplied with unit
315-
*/
316-
static u16 ocelot_wm_enc(u16 value)
317-
{
318-
if (value >= BIT(8))
319-
return BIT(8) | (value / 16);
320-
321-
return value;
322-
}
323-
324312
void ocelot_adjust_link(struct ocelot *ocelot, int port,
325313
struct phy_device *phydev)
326314
{
@@ -1284,9 +1272,9 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
12841272
/* Tail dropping watermark */
12851273
atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
12861274
OCELOT_BUFFER_CELL_SZ;
1287-
ocelot_write_rix(ocelot, ocelot_wm_enc(9 * maxlen),
1275+
ocelot_write_rix(ocelot, ocelot->ops->wm_enc(9 * maxlen),
12881276
SYS_ATOP, port);
1289-
ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
1277+
ocelot_write(ocelot, ocelot->ops->wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
12901278
}
12911279
EXPORT_SYMBOL(ocelot_port_set_maxlen);
12921280

drivers/net/ethernet/mscc/ocelot_vsc7514.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,21 @@ static int ocelot_reset(struct ocelot *ocelot)
739739
return 0;
740740
}
741741

742+
/* Watermark encode
743+
* Bit 8: Unit; 0:1, 1:16
744+
* Bit 7-0: Value to be multiplied with unit
745+
*/
746+
static u16 ocelot_wm_enc(u16 value)
747+
{
748+
if (value >= BIT(8))
749+
return BIT(8) | (value / 16);
750+
751+
return value;
752+
}
753+
742754
static const struct ocelot_ops ocelot_ops = {
743755
.reset = ocelot_reset,
756+
.wm_enc = ocelot_wm_enc,
744757
};
745758

746759
static const struct vcap_field vsc7514_vcap_is2_keys[] = {

include/soc/mscc/ocelot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ struct ocelot;
541541

542542
struct ocelot_ops {
543543
int (*reset)(struct ocelot *ocelot);
544+
u16 (*wm_enc)(u16 value);
544545
};
545546

546547
struct ocelot_vcap_block {

0 commit comments

Comments
 (0)