netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: [PATCH net-next 4/9] net: dsa: sja1105: don't assign the host port using dsa_upstream_port()
Date: Mon, 24 May 2021 16:14:16 +0300	[thread overview]
Message-ID: <20210524131421.1030789-5-olteanv@gmail.com> (raw)
In-Reply-To: <20210524131421.1030789-1-olteanv@gmail.com>

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

If @port is unused, then dsa_upstream_port(ds, port) returns @port,
which means we cannot assume the CPU port can be retrieved this way.

The sja1105 switches support a single CPU port, so just iterate over the
switch ports and stop at the first CPU port we see.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/sja1105/sja1105_main.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 5d5f6555dbac..4a81b1b1cef3 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -556,7 +556,7 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
 		 * receieved on host_port itself would be dropped, except
 		 * by installing a temporary 'management route'
 		 */
-		.host_port = dsa_upstream_port(priv->ds, 0),
+		.host_port = priv->ds->num_ports,
 		/* Default to an invalid value */
 		.mirr_port = priv->ds->num_ports,
 		/* Link-local traffic received on casc_port will be forwarded
@@ -579,7 +579,16 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
 		.tpid = ETH_P_SJA1105,
 		.tpid2 = ETH_P_SJA1105,
 	};
+	struct dsa_switch *ds = priv->ds;
 	struct sja1105_table *table;
+	int port;
+
+	for (port = 0; port < ds->num_ports; port++) {
+		if (dsa_is_cpu_port(ds, port)) {
+			default_general_params.host_port = port;
+			break;
+		}
+	}
 
 	table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS];
 
-- 
2.25.1


  parent reply	other threads:[~2021-05-24 13:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 13:14 [PATCH net-next 0/9] SJA1105 DSA driver preparation for new switch introduction (SJA1110) Vladimir Oltean
2021-05-24 13:14 ` [PATCH net-next 1/9] net: dsa: sja1105: parameterize the number of ports Vladimir Oltean
2021-05-24 13:14 ` [PATCH net-next 2/9] net: dsa: sja1105: avoid some work for unused ports Vladimir Oltean
2021-05-24 13:14 ` [PATCH net-next 3/9] net: dsa: sja1105: dimension the data structures for a larger port count Vladimir Oltean
2021-05-24 13:14 ` Vladimir Oltean [this message]
2021-05-24 13:14 ` [PATCH net-next 5/9] net: dsa: sja1105: skip CGU configuration if it's unnecessary Vladimir Oltean
2021-05-24 13:14 ` [PATCH net-next 6/9] net: dsa: sja1105: dynamically choose the number of static config table entries Vladimir Oltean
2021-05-24 13:14 ` [PATCH net-next 7/9] net: dsa: sja1105: use sja1105_xfer_u32 for the reset procedure Vladimir Oltean
2021-05-24 13:14 ` [PATCH net-next 8/9] net: dsa: sja1105: configure the multicast policers, if present Vladimir Oltean
2021-05-24 13:14 ` [PATCH net-next 9/9] net: dsa: sja1105: allow the frame buffer size to be customized Vladimir Oltean
2021-05-24 21:10 ` [PATCH net-next 0/9] SJA1105 DSA driver preparation for new switch introduction (SJA1110) patchwork-bot+netdevbpf

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=20210524131421.1030789-5-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.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).