net: mscc: ocelot: add ops for decoding watermark threshold and occupancy
We'll need to read back the watermark thresholds and occupancy from hardware (for devlink-sb integration), not only to write them as we did so far in ocelot_port_set_maxlen. So introduce 2 new functions in struct ocelot_ops, similar to wm_enc, and implement them for the 3 supported mscc_ocelot switches. Remove the INUSE and MAXUSE unpacking helpers for the QSYS_RES_STAT register, because that doesn't scale with the number of switches that mscc_ocelot supports now. They have different bit widths for the watermarks, and we need function pointers to abstract that difference away. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
f6fe01d6fa
commit
703b762190
@@ -763,9 +763,25 @@ static u16 ocelot_wm_enc(u16 value)
|
||||
return value;
|
||||
}
|
||||
|
||||
static u16 ocelot_wm_dec(u16 wm)
|
||||
{
|
||||
if (wm & BIT(8))
|
||||
return (wm & GENMASK(7, 0)) * 16;
|
||||
|
||||
return wm;
|
||||
}
|
||||
|
||||
static void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
|
||||
{
|
||||
*inuse = (val & GENMASK(23, 12)) >> 12;
|
||||
*maxuse = val & GENMASK(11, 0);
|
||||
}
|
||||
|
||||
static const struct ocelot_ops ocelot_ops = {
|
||||
.reset = ocelot_reset,
|
||||
.wm_enc = ocelot_wm_enc,
|
||||
.wm_dec = ocelot_wm_dec,
|
||||
.wm_stat = ocelot_wm_stat,
|
||||
.port_to_netdev = ocelot_port_to_netdev,
|
||||
.netdev_to_port = ocelot_netdev_to_port,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user