LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch,
	davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vladimir Oltean <olteanv@gmail.com>
Subject: [PATCH v4 net-next 10/12] net: dsa: sja1105: Reject unsupported link modes for AN
Date: Mon, 29 Apr 2019 03:17:04 +0300	[thread overview]
Message-ID: <20190429001706.7449-11-olteanv@gmail.com> (raw)
In-Reply-To: <20190429001706.7449-1-olteanv@gmail.com>

Ethernet flow control:

The switch MAC does not consume, nor does it emit pause frames. It
simply forwards them as any other Ethernet frame (and since the DMAC is,
per IEEE spec, 01-80-C2-00-00-01, it means they are filtered as
link-local traffic and forwarded to the CPU, which can't do anything
useful with them).

Duplex:

There is no duplex setting in the SJA1105 MAC. It is known to forward
traffic at line rate on the same port in both directions. Therefore it
must be that it only supports full duplex.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v4:
None.

Changes in v3:
None.

Changes in v2:
Patch is new.

 drivers/net/dsa/sja1105/sja1105_main.c | 31 ++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index f5205ce85dbe..74f8ff9e17e0 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -11,6 +11,7 @@
 #include <linux/spi/spi.h>
 #include <linux/errno.h>
 #include <linux/gpio/consumer.h>
+#include <linux/phylink.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
 #include <linux/of_mdio.h>
@@ -726,6 +727,35 @@ static void sja1105_adjust_link(struct dsa_switch *ds, int port,
 		sja1105_adjust_port_config(priv, port, phydev->speed, true);
 }
 
+static void sja1105_phylink_validate(struct dsa_switch *ds, int port,
+				     unsigned long *supported,
+				     struct phylink_link_state *state)
+{
+	/* Construct a new mask which exhaustively contains all link features
+	 * supported by the MAC, and then apply that (logical AND) to what will
+	 * be sent to the PHY for "marketing".
+	 */
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
+	struct sja1105_private *priv = ds->priv;
+	struct sja1105_xmii_params_entry *mii;
+
+	mii = priv->static_config.tables[BLK_IDX_XMII_PARAMS].entries;
+
+	/* The MAC does not support pause frames, and also doesn't
+	 * support half-duplex traffic modes.
+	 */
+	phylink_set(mask, Autoneg);
+	phylink_set(mask, MII);
+	phylink_set(mask, 10baseT_Full);
+	phylink_set(mask, 100baseT_Full);
+	if (mii->xmii_mode[port] == XMII_MODE_RGMII)
+		phylink_set(mask, 1000baseT_Full);
+
+	bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
+	bitmap_and(state->advertising, state->advertising, mask,
+		   __ETHTOOL_LINK_MODE_MASK_NBITS);
+}
+
 /* First-generation switches have a 4-way set associative TCAM that
  * holds the FDB entries. An FDB index spans from 0 to 1023 and is comprised of
  * a "bin" (grouping of 4 entries) and a "way" (an entry within a bin).
@@ -1278,6 +1308,7 @@ static const struct dsa_switch_ops sja1105_switch_ops = {
 	.setup			= sja1105_setup,
 	.adjust_link		= sja1105_adjust_link,
 	.set_ageing_time	= sja1105_set_ageing_time,
+	.phylink_validate	= sja1105_phylink_validate,
 	.get_strings		= sja1105_get_strings,
 	.get_ethtool_stats	= sja1105_get_ethtool_stats,
 	.get_sset_count		= sja1105_get_sset_count,
-- 
2.17.1


  parent reply	other threads:[~2019-04-29  0:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29  0:16 [PATCH v4 net-next 00/12] NXP SJA1105 DSA driver Vladimir Oltean
2019-04-29  0:16 ` [PATCH v4 net-next 01/12] lib: Add support for generic packing operations Vladimir Oltean
2019-04-29  0:16 ` [PATCH v4 net-next 02/12] net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch Vladimir Oltean
2019-04-29  0:16 ` [PATCH v4 net-next 03/12] net: dsa: sja1105: Add support for FDB and MDB management Vladimir Oltean
2019-04-29  0:16 ` [PATCH v4 net-next 04/12] net: dsa: sja1105: Error out if RGMII delays are requested in DT Vladimir Oltean
2019-04-29  0:16 ` [PATCH v4 net-next 05/12] ether: Add dedicated Ethertype for pseudo-802.1Q DSA tagging Vladimir Oltean
2019-04-29 22:18   ` Andrew Lunn
2019-04-29  0:17 ` [PATCH v4 net-next 06/12] net: dsa: sja1105: Add support for VLAN operations Vladimir Oltean
2019-04-29  0:17 ` [PATCH v4 net-next 07/12] net: dsa: sja1105: Add support for ethtool port counters Vladimir Oltean
2019-04-29  0:17 ` [PATCH v4 net-next 08/12] net: dsa: sja1105: Add support for configuring address aging time Vladimir Oltean
2019-04-29 22:21   ` Andrew Lunn
2019-04-29  0:17 ` [PATCH v4 net-next 09/12] net: dsa: sja1105: Prevent PHY jabbering during switch reset Vladimir Oltean
2019-04-29  0:17 ` Vladimir Oltean [this message]
2019-04-29  0:17 ` [PATCH v4 net-next 11/12] Documentation: net: dsa: Add details about NXP SJA1105 driver Vladimir Oltean
2019-04-29  0:17 ` [PATCH v4 net-next 12/12] dt-bindings: net: dsa: Add documentation for " Vladimir Oltean
2019-05-01  3:44 ` [PATCH v4 net-next 00/12] NXP SJA1105 DSA driver David Miller
2019-05-02 16:31   ` Vladimir Oltean
2019-05-02 16:55     ` Andrew Lunn
2019-05-02 17:05       ` Vladimir Oltean
2019-05-02 19:44     ` David Miller
2019-05-02 16:25 ` Vladimir Oltean

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=20190429001706.7449-11-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --subject='Re: [PATCH v4 net-next 10/12] net: dsa: sja1105: Reject unsupported link modes for AN' \
    /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

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).