Commit aa92d836 authored by Maxim Kochetkov's avatar Maxim Kochetkov Committed by David S. Miller

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: default avatarMaxim Kochetkov <fido_max@inbox.ru>
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 541132f0
...@@ -1149,8 +1149,21 @@ static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port, ...@@ -1149,8 +1149,21 @@ static int vsc9959_prevalidate_phy_mode(struct ocelot *ocelot, int port,
} }
} }
/* Watermark encode
* Bit 8: Unit; 0:1, 1:16
* Bit 7-0: Value to be multiplied with unit
*/
static u16 vsc9959_wm_enc(u16 value)
{
if (value >= BIT(8))
return BIT(8) | (value / 16);
return value;
}
static const struct ocelot_ops vsc9959_ops = { static const struct ocelot_ops vsc9959_ops = {
.reset = vsc9959_reset, .reset = vsc9959_reset,
.wm_enc = vsc9959_wm_enc,
}; };
static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot) static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)
......
...@@ -309,18 +309,6 @@ static void ocelot_vlan_init(struct ocelot *ocelot) ...@@ -309,18 +309,6 @@ static void ocelot_vlan_init(struct ocelot *ocelot)
} }
} }
/* Watermark encode
* Bit 8: Unit; 0:1, 1:16
* Bit 7-0: Value to be multiplied with unit
*/
static u16 ocelot_wm_enc(u16 value)
{
if (value >= BIT(8))
return BIT(8) | (value / 16);
return value;
}
void ocelot_adjust_link(struct ocelot *ocelot, int port, void ocelot_adjust_link(struct ocelot *ocelot, int port,
struct phy_device *phydev) struct phy_device *phydev)
{ {
...@@ -1284,9 +1272,9 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu) ...@@ -1284,9 +1272,9 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
/* Tail dropping watermark */ /* Tail dropping watermark */
atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) / atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
OCELOT_BUFFER_CELL_SZ; OCELOT_BUFFER_CELL_SZ;
ocelot_write_rix(ocelot, ocelot_wm_enc(9 * maxlen), ocelot_write_rix(ocelot, ocelot->ops->wm_enc(9 * maxlen),
SYS_ATOP, port); SYS_ATOP, port);
ocelot_write(ocelot, ocelot_wm_enc(atop_wm), SYS_ATOP_TOT_CFG); ocelot_write(ocelot, ocelot->ops->wm_enc(atop_wm), SYS_ATOP_TOT_CFG);
} }
EXPORT_SYMBOL(ocelot_port_set_maxlen); EXPORT_SYMBOL(ocelot_port_set_maxlen);
......
...@@ -739,8 +739,21 @@ static int ocelot_reset(struct ocelot *ocelot) ...@@ -739,8 +739,21 @@ static int ocelot_reset(struct ocelot *ocelot)
return 0; return 0;
} }
/* Watermark encode
* Bit 8: Unit; 0:1, 1:16
* Bit 7-0: Value to be multiplied with unit
*/
static u16 ocelot_wm_enc(u16 value)
{
if (value >= BIT(8))
return BIT(8) | (value / 16);
return value;
}
static const struct ocelot_ops ocelot_ops = { static const struct ocelot_ops ocelot_ops = {
.reset = ocelot_reset, .reset = ocelot_reset,
.wm_enc = ocelot_wm_enc,
}; };
static const struct vcap_field vsc7514_vcap_is2_keys[] = { static const struct vcap_field vsc7514_vcap_is2_keys[] = {
......
...@@ -541,6 +541,7 @@ struct ocelot; ...@@ -541,6 +541,7 @@ struct ocelot;
struct ocelot_ops { struct ocelot_ops {
int (*reset)(struct ocelot *ocelot); int (*reset)(struct ocelot *ocelot);
u16 (*wm_enc)(u16 value);
}; };
struct ocelot_vcap_block { struct ocelot_vcap_block {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment