]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: mscc: ocelot: extend watermark encoding function
authorMaxim Kochetkov <fido_max@inbox.ru>
Mon, 13 Jul 2020 16:57:08 +0000 (19:57 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Oct 2020 09:55:58 +0000 (11:55 +0200)
[ Upstream commit aa92d836d5c40a7e21e563a272ad177f1bfd44dd ]

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 <fido_max@inbox.ru>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/ocelot/felix_vsc9959.c
drivers/net/ethernet/mscc/ocelot.c
drivers/net/ethernet/mscc/ocelot_vsc7514.c
include/soc/mscc/ocelot.h

index a83ecd1c5d6c2fc4ca824afcd00d7c0d276b4174..259a612da0030680e48ba12476ef178f1b05b4ca 100644 (file)
@@ -1105,8 +1105,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 = {
        .reset                  = vsc9959_reset,
+       .wm_enc                 = vsc9959_wm_enc,
 };
 
 static int vsc9959_mdio_bus_alloc(struct ocelot *ocelot)
index 6e68713c0ac6b618d41509dbfea74fb144d57311..1438839e3f6ea34915ea6f330e7ad3097e00a79a 100644 (file)
@@ -396,18 +396,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,
                        struct phy_device *phydev)
 {
@@ -2037,9 +2025,9 @@ void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu)
        /* Tail dropping watermark */
        atop_wm = (ocelot->shared_queue_sz - 9 * maxlen) /
                   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);
-       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);
 
index 4a15d2ff8b7064aad6b7067ee4a168d3653fc4ca..66b58b242f778ab59d32159e8da6a25ab1b3849f 100644 (file)
@@ -240,8 +240,21 @@ static int ocelot_reset(struct ocelot *ocelot)
        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 = {
        .reset                  = ocelot_reset,
+       .wm_enc                 = ocelot_wm_enc,
 };
 
 static const struct vcap_field vsc7514_vcap_is2_keys[] = {
index 4953e9994df34a7e4acd80de9d25001216c360d7..8e174a24c5757611642b2bc15744de8316c607df 100644 (file)
@@ -468,6 +468,7 @@ struct ocelot;
 
 struct ocelot_ops {
        int (*reset)(struct ocelot *ocelot);
+       u16 (*wm_enc)(u16 value);
 };
 
 struct ocelot_acl_block {