Skip to content

Commit c6a9321

Browse files
colin-foster-in-advantagekuba-moo
authored andcommitted
net: mscc: ocelot: expose ocelot wm functions
Expose ocelot_wm functions so they can be shared with other drivers. Signed-off-by: Colin Foster <colin.foster@in-advantage.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com> # regression Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3c1dc22 commit c6a9321

3 files changed

Lines changed: 36 additions & 28 deletions

File tree

drivers/net/ethernet/mscc/ocelot_devlink.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,37 @@ static void ocelot_watermark_init(struct ocelot *ocelot)
487487
ocelot_setup_sharing_watermarks(ocelot);
488488
}
489489

490+
/* Watermark encode
491+
* Bit 8: Unit; 0:1, 1:16
492+
* Bit 7-0: Value to be multiplied with unit
493+
*/
494+
u16 ocelot_wm_enc(u16 value)
495+
{
496+
WARN_ON(value >= 16 * BIT(8));
497+
498+
if (value >= BIT(8))
499+
return BIT(8) | (value / 16);
500+
501+
return value;
502+
}
503+
EXPORT_SYMBOL(ocelot_wm_enc);
504+
505+
u16 ocelot_wm_dec(u16 wm)
506+
{
507+
if (wm & BIT(8))
508+
return (wm & GENMASK(7, 0)) * 16;
509+
510+
return wm;
511+
}
512+
EXPORT_SYMBOL(ocelot_wm_dec);
513+
514+
void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
515+
{
516+
*inuse = (val & GENMASK(23, 12)) >> 12;
517+
*maxuse = val & GENMASK(11, 0);
518+
}
519+
EXPORT_SYMBOL(ocelot_wm_stat);
520+
490521
/* Pool size and type are fixed up at runtime. Keeping this structure to
491522
* look up the cell size multipliers.
492523
*/

drivers/net/ethernet/mscc/ocelot_vsc7514.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -229,34 +229,6 @@ static int ocelot_reset(struct ocelot *ocelot)
229229
return regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1);
230230
}
231231

232-
/* Watermark encode
233-
* Bit 8: Unit; 0:1, 1:16
234-
* Bit 7-0: Value to be multiplied with unit
235-
*/
236-
static u16 ocelot_wm_enc(u16 value)
237-
{
238-
WARN_ON(value >= 16 * BIT(8));
239-
240-
if (value >= BIT(8))
241-
return BIT(8) | (value / 16);
242-
243-
return value;
244-
}
245-
246-
static u16 ocelot_wm_dec(u16 wm)
247-
{
248-
if (wm & BIT(8))
249-
return (wm & GENMASK(7, 0)) * 16;
250-
251-
return wm;
252-
}
253-
254-
static void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse)
255-
{
256-
*inuse = (val & GENMASK(23, 12)) >> 12;
257-
*maxuse = val & GENMASK(11, 0);
258-
}
259-
260232
static const struct ocelot_ops ocelot_ops = {
261233
.reset = ocelot_reset,
262234
.wm_enc = ocelot_wm_enc,

include/soc/mscc/ocelot.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,11 @@ void ocelot_port_assign_dsa_8021q_cpu(struct ocelot *ocelot, int port, int cpu);
978978
void ocelot_port_unassign_dsa_8021q_cpu(struct ocelot *ocelot, int port);
979979
u32 ocelot_port_assigned_dsa_8021q_cpu_mask(struct ocelot *ocelot, int port);
980980

981+
/* Watermark interface */
982+
u16 ocelot_wm_enc(u16 value);
983+
u16 ocelot_wm_dec(u16 wm);
984+
void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse);
985+
981986
/* DSA callbacks */
982987
void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
983988
void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);

0 commit comments

Comments
 (0)