netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com,
	claudiu.manoil@nxp.com, alexandru.marginean@nxp.com,
	ioana.ciornei@nxp.com, linux@armlinux.org.uk
Subject: [PATCH v2 net-next 4/6] net: dsa: felix: set proper pause frame timers based on link speed
Date: Sat,  4 Jul 2020 15:45:05 +0300	[thread overview]
Message-ID: <20200704124507.3336497-5-olteanv@gmail.com> (raw)
In-Reply-To: <20200704124507.3336497-1-olteanv@gmail.com>

From: Vladimir Oltean <vladimir.oltean@nxp.com>

state->speed holds a value of 10, 100, 1000 or 2500, but
SYS_MAC_FC_CFG_FC_LINK_SPEED expects a value in the range 0, 1, 2 or 3.

So set the correct speed encoding into this register.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Changes in v2:
None.

Note: this patch is still using state->speed from mac_config(), although
that will be changed in 6/6.

 drivers/net/dsa/ocelot/felix.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 4d819cc45bed..4684339012c5 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -250,10 +250,25 @@ static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
 			   DEV_CLOCK_CFG_LINK_SPEED(OCELOT_SPEED_1000),
 			   DEV_CLOCK_CFG);
 
-	/* Flow control. Link speed is only used here to evaluate the time
-	 * specification in incoming pause frames.
-	 */
-	mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(state->speed);
+	switch (state->speed) {
+	case SPEED_10:
+		mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(3);
+		break;
+	case SPEED_100:
+		mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(2);
+		break;
+	case SPEED_1000:
+	case SPEED_2500:
+		mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(1);
+		break;
+	case SPEED_UNKNOWN:
+		mac_fc_cfg = SYS_MAC_FC_CFG_FC_LINK_SPEED(0);
+		break;
+	default:
+		dev_err(ocelot->dev, "Unsupported speed on port %d: %d\n",
+			port, state->speed);
+		return;
+	}
 
 	/* handle Rx pause in all cases, with 2500base-X this is used for rate
 	 * adaptation.
@@ -265,6 +280,10 @@ static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
 			      SYS_MAC_FC_CFG_PAUSE_VAL_CFG(0xffff) |
 			      SYS_MAC_FC_CFG_FC_LATENCY_CFG(0x7) |
 			      SYS_MAC_FC_CFG_ZERO_PAUSE_ENA;
+
+	/* Flow control. Link speed is only used here to evaluate the time
+	 * specification in incoming pause frames.
+	 */
 	ocelot_write_rix(ocelot, mac_fc_cfg, SYS_MAC_FC_CFG, port);
 
 	ocelot_write_rix(ocelot, 0, ANA_POL_FLOWC, port);
-- 
2.25.1


  parent reply	other threads:[~2020-07-04 12:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 12:45 [PATCH v2 net-next 0/6] PHYLINK integration improvements for Felix DSA driver Vladimir Oltean
2020-07-04 12:45 ` [PATCH v2 net-next 1/6] net: dsa: felix: clarify the intention of writes to MII_BMCR Vladimir Oltean
2020-07-04 12:45 ` [PATCH v2 net-next 2/6] net: dsa: felix: support half-duplex link modes Vladimir Oltean
2020-07-04 12:45 ` [PATCH v2 net-next 3/6] net: dsa: felix: unconditionally configure MAC speed to 1000Mbps Vladimir Oltean
2020-07-04 12:45 ` Vladimir Oltean [this message]
2020-07-04 12:45 ` [PATCH v2 net-next 5/6] net: dsa: felix: delete .phylink_mac_an_restart code Vladimir Oltean
2020-07-04 14:56   ` Russell King - ARM Linux admin
2020-07-04 15:50     ` Vladimir Oltean
2020-07-04 18:14       ` Russell King - ARM Linux admin
2020-07-04 20:29         ` Vladimir Oltean
2020-07-04 21:55           ` Russell King - ARM Linux admin
2020-07-04 12:45 ` [PATCH v2 net-next 6/6] net: dsa: felix: use resolved link config in mac_link_up() Vladimir Oltean
2020-07-05 22:26 ` [PATCH v2 net-next 0/6] PHYLINK integration improvements for Felix DSA driver David Miller
2020-07-06  8:45   ` Russell King - ARM Linux admin
2020-07-06 19:54     ` David Miller
2020-07-06 20:39       ` Russell King - ARM Linux admin
2020-07-06 20:46         ` David Miller
2020-07-06 20:53           ` Florian Fainelli

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=20200704124507.3336497-5-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --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).