netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, andrew@lunn.ch, vivien.didelot@gmail.com,
	f.fainelli@gmail.com, antoine.tenart@bootlin.com,
	alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com,
	alexandru.marginean@nxp.com, claudiu.manoil@nxp.com,
	madalin.bucur@oss.nxp.com, radu-andrei.bulie@nxp.com,
	fido_max@inbox.ru, broonie@kernel.org
Subject: [PATCH v3 net-next 10/13] net: mscc: ocelot: extend watermark encoding function
Date: Sun, 31 May 2020 15:26:37 +0300	[thread overview]
Message-ID: <20200531122640.1375715-11-olteanv@gmail.com> (raw)
In-Reply-To: <20200531122640.1375715-1-olteanv@gmail.com>

From: Maxim Kochetkov <fido_max@inbox.ru>

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>
---
Changes in v3:
None.

Changes in v2:
None.

 drivers/net/dsa/ocelot/felix_vsc9959.c   | 13 +++++++++++++
 drivers/net/ethernet/mscc/ocelot.c       | 16 ++--------------
 drivers/net/ethernet/mscc/ocelot_board.c | 13 +++++++++++++
 include/soc/mscc/ocelot.h                |  1 +
 4 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 81cc21d4d404..e722b58a714f 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -1163,8 +1163,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)
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index a76c68481ee3..ad9bb551a843 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -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)
 {
@@ -2038,9 +2026,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);
 
diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index 68d3be32217f..620f1c4974ff 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -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[] = {
diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
index a97cc1796b5e..8a2cb5ea17e7 100644
--- a/include/soc/mscc/ocelot.h
+++ b/include/soc/mscc/ocelot.h
@@ -526,6 +526,7 @@ struct ocelot;
 
 struct ocelot_ops {
 	int (*reset)(struct ocelot *ocelot);
+	u16 (*wm_enc)(u16 value);
 };
 
 struct ocelot_acl_block {
-- 
2.25.1


  parent reply	other threads:[~2020-05-31 12:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 12:26 [PATCH v3 net-next 00/13] New DSA driver for VSC9953 Seville switch Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 01/13] regmap: add helper for per-port regfield initialization Vladimir Oltean
2020-06-01 10:54   ` Mark Brown
2020-06-01 11:12     ` Vladimir Oltean
2020-06-01 11:51       ` Alexandre Belloni
2020-06-01 12:50         ` Mark Brown
2020-05-31 12:26 ` [PATCH v3 net-next 02/13] net: dsa: felix: set proper link speed in felix_phylink_mac_config Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 03/13] net: mscc: ocelot: convert port registers to regmap Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 04/13] soc/mscc: ocelot: add MII registers description Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 05/13] net: mscc: ocelot: convert QSYS_SWITCH_PORT_MODE and SYS_PORT_MODE to regfields Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 06/13] net: dsa: felix: create a template for the DSA tags on xmit Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 07/13] net: mscc: ocelot: split writes to pause frame enable bit and to thresholds Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 08/13] net: mscc: ocelot: disable flow control on NPI interface Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 09/13] net: mscc: ocelot: convert SYS_PAUSE_CFG register access to regfield Vladimir Oltean
2020-05-31 12:26 ` Vladimir Oltean [this message]
2020-05-31 12:26 ` [PATCH v3 net-next 11/13] net: dsa: felix: support half-duplex link modes Vladimir Oltean
2020-05-31 12:26 ` [PATCH v3 net-next 12/13] net: dsa: felix: move probing to felix_vsc9959.c Vladimir Oltean
2020-06-01 21:14   ` Jakub Kicinski
2020-05-31 12:26 ` [PATCH v3 net-next 13/13] net: dsa: felix: introduce support for Seville VSC9953 switch Vladimir Oltean
2020-06-01 21:14   ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200531122640.1375715-11-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=antoine.tenart@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=fido_max@inbox.ru \
    --cc=madalin.bucur@oss.nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=radu-andrei.bulie@nxp.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).