netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Rakesh Sankaranarayanan <rakesh.sankaranarayanan@microchip.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
	linux@armlinux.org.uk
Subject: Re: [RFC PATCH net-next 03/11] net: dsa: microchip: lan937x: enable cascade port
Date: Sat, 4 Feb 2023 01:24:42 +0200	[thread overview]
Message-ID: <20230203232442.hhfgebj4rppmh5nn@skbuf> (raw)
In-Reply-To: <20230202125930.271740-4-rakesh.sankaranarayanan@microchip.com> <20230202125930.271740-4-rakesh.sankaranarayanan@microchip.com>

On Thu, Feb 02, 2023 at 06:29:22PM +0530, Rakesh Sankaranarayanan wrote:
> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> index aab60f2587bf..c3c3eee178f4 100644
> --- a/drivers/net/dsa/microchip/ksz_common.h
> +++ b/drivers/net/dsa/microchip/ksz_common.h
> @@ -147,6 +147,7 @@ struct ksz_device {
>  	u32 chip_id;
>  	u8 chip_rev;
>  	int cpu_port;			/* port connected to CPU */
> +	int dsa_port;                   /* Port used as cascaded port */

nitpick: since "dsa_port" is typically a keyword that I use for the DSA
framework's generic port structure (struct dsa_port *dp), I would appreciate
if you could name this in some other way, like "cascade_port". I don't
believe the explanatory comment would even be necessary in that case.
And btw, the comment is inconsistent in alignment (tabs vs spaces) with
the line immediately above it.

>  	u32 smi_index;
>  	int phy_port_cnt;
>  	phy_interface_t compat_interface;
> @@ -358,6 +359,7 @@ struct ksz_dev_ops {
>  	void (*setup_rgmii_delay)(struct ksz_device *dev, int port);
>  	int (*tc_cbs_set_cinc)(struct ksz_device *dev, int port, u32 val);
>  	void (*config_cpu_port)(struct dsa_switch *ds);
> +	void (*config_dsa_port)(struct dsa_switch *ds);
>  	int (*enable_stp_addr)(struct ksz_device *dev);
>  	int (*reset)(struct ksz_device *dev);
>  	int (*init)(struct ksz_device *dev);
> diff --git a/drivers/net/dsa/microchip/lan937x.h b/drivers/net/dsa/microchip/lan937x.h
> index 3388d91dbc44..ef84abc31556 100644
> --- a/drivers/net/dsa/microchip/lan937x.h
> +++ b/drivers/net/dsa/microchip/lan937x.h
> @@ -11,6 +11,7 @@ int lan937x_setup(struct dsa_switch *ds);
>  void lan937x_teardown(struct dsa_switch *ds);
>  void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port);
>  void lan937x_config_cpu_port(struct dsa_switch *ds);
> +void lan937x_config_dsa_port(struct dsa_switch *ds);
>  int lan937x_switch_init(struct ksz_device *dev);
>  void lan937x_switch_exit(struct ksz_device *dev);
>  int lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
> diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
> index 399a3905e6ca..5108a3f4bf76 100644
> --- a/drivers/net/dsa/microchip/lan937x_main.c
> +++ b/drivers/net/dsa/microchip/lan937x_main.c
> @@ -205,11 +205,42 @@ void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port)
>  	dev->dev_ops->cfg_port_member(dev, port, member);
>  }
>  
> +void lan937x_config_dsa_port(struct dsa_switch *ds)
> +{
> +	struct ksz_device *dev = ds->priv;
> +	struct dsa_port *dp;
> +
> +	dev->dsa_port = 0xFF;
> +
> +	dsa_switch_for_each_port(dp, ds) {
> +		if (dsa_is_dsa_port(ds, dp->index)) {

Would be good if you introduced dsa_switch_for_each_dsa_port() as a
separate patch, and used it here first.

Not sure if you realize this, but dsa_is_dsa_port() contains a list
iteration hidden in it, in dsa_to_port(). So dsa_switch_for_each_port()
-> dsa_is_dsa_port() effectively does an O(n^2) list walk (apart from
uselessly increasing the code indentation).

> +			ksz_rmw32(dev, REG_SW_CASCADE_MODE_CTL,
> +				  CASCADE_PORT_SEL, dp->index);
> +			dev->dsa_port = dp->index;
> +
> +			/* Tail tag should be enabled for switch 0
> +			 * in cascaded connection.
> +			 */
> +			if (dev->smi_index == 0) {
> +				lan937x_port_cfg(dev, dp->index, REG_PORT_CTRL_0,
> +						 PORT_TAIL_TAG_ENABLE, true);
> +			}
> +
> +			/* Frame check length should be disabled for cascaded ports */
> +			lan937x_port_cfg(dev, dp->index, REG_PORT_MAC_CTRL_0,
> +					 PORT_CHECK_LENGTH, false);

break?

> +		}
> +	}
> +}
> +
>  void lan937x_config_cpu_port(struct dsa_switch *ds)
>  {
>  	struct ksz_device *dev = ds->priv;
>  	struct dsa_port *dp;
>  
> +	/* Initializing cpu_port parameter into invalid value */
> +	dev->cpu_port = 0xFF;
> +
>  	dsa_switch_for_each_cpu_port(dp, ds) {
>  		if (dev->info->cpu_ports & (1 << dp->index)) {
>  			dev->cpu_port = dp->index;
> diff --git a/drivers/net/dsa/microchip/lan937x_reg.h b/drivers/net/dsa/microchip/lan937x_reg.h
> index 45b606b6429f..4f30bc12f7a9 100644
> --- a/drivers/net/dsa/microchip/lan937x_reg.h
> +++ b/drivers/net/dsa/microchip/lan937x_reg.h
> @@ -32,6 +32,9 @@
>  #define REG_SW_PORT_INT_STATUS__4	0x0018
>  #define REG_SW_PORT_INT_MASK__4		0x001C
>  
> +#define REG_SW_CASCADE_MODE_CTL         0x0030
> +#define CASCADE_PORT_SEL                7
> +
>  /* 1 - Global */
>  #define REG_SW_GLOBAL_OUTPUT_CTRL__1	0x0103
>  #define SW_CLK125_ENB			BIT(1)
> -- 
> 2.34.1
> 


  reply	other threads:[~2023-02-03 23:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 12:59 [RFC PATCH net-next 00/11] net: dsa: microchip: lan937x: add switch cascade support Rakesh Sankaranarayanan
2023-02-02 12:59 ` [RFC PATCH net-next 01/11] net: dsa: microchip: lan937x: add cascade tailtag Rakesh Sankaranarayanan
2023-02-03 23:10   ` Vladimir Oltean
2023-02-02 12:59 ` [RFC PATCH net-next 02/11] net: dsa: microchip: lan937x: update SMI index Rakesh Sankaranarayanan
2023-02-03 23:18   ` Vladimir Oltean
2023-02-02 12:59 ` [RFC PATCH net-next 03/11] net: dsa: microchip: lan937x: enable cascade port Rakesh Sankaranarayanan
2023-02-03 23:24   ` Vladimir Oltean [this message]
2023-02-02 12:59 ` [RFC PATCH net-next 04/11] net: dsa: microchip: lan937x: update port number for LAN9373 Rakesh Sankaranarayanan
2023-02-02 15:19   ` Andrew Lunn
2023-02-03 10:43     ` Rakesh.Sankaranarayanan
2023-02-03 23:26       ` Vladimir Oltean
2023-02-06 14:38         ` Arun.Ramadoss
2023-02-02 12:59 ` [RFC PATCH net-next 05/11] net: dsa: microchip: lan937x: add shared global interrupt Rakesh Sankaranarayanan
2023-02-02 15:25   ` Andrew Lunn
2023-02-02 12:59 ` [RFC PATCH net-next 06/11] net: dsa: microchip: lan937x: get cascade tag protocol Rakesh Sankaranarayanan
2023-02-03 23:30   ` Vladimir Oltean
2023-02-02 12:59 ` [RFC PATCH net-next 07/11] net: dsa: microchip: lan937x: update switch register Rakesh Sankaranarayanan
2023-02-02 15:40   ` Andrew Lunn
2023-02-03 10:48     ` Rakesh.Sankaranarayanan
2023-02-03 23:37     ` Vladimir Oltean
2023-02-02 12:59 ` [RFC PATCH net-next 08/11] net: dsa: microchip: lan937x: avoid mib read for cascaded port Rakesh Sankaranarayanan
2023-02-02 15:45   ` Andrew Lunn
2023-02-02 12:59 ` [RFC PATCH net-next 09/11] net: dsa: microchip: lan937x: update port membership with dsa port Rakesh Sankaranarayanan
2023-02-03 23:47   ` Vladimir Oltean
2023-02-02 12:59 ` [RFC PATCH net-next 10/11] net: dsa: microchip: lan937x: update vlan untag membership Rakesh Sankaranarayanan
2023-02-03 23:48   ` Vladimir Oltean
2023-02-02 12:59 ` [RFC PATCH net-next 11/11] net: dsa: microchip: lan937x: update multicast table Rakesh Sankaranarayanan

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=20230203232442.hhfgebj4rppmh5nn@skbuf \
    --to=olteanv@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rakesh.sankaranarayanan@microchip.com \
    --cc=woojung.huh@microchip.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).