Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Alvin Šipraga" <ALSI@bang-olufsen.dk>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"vivien.didelot@gmail.com" <vivien.didelot@gmail.com>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	"olteanv@gmail.com" <olteanv@gmail.com>,
	"arinc.unal@arinc9.com" <arinc.unal@arinc9.com>,
	"frank-w@public-files.de" <frank-w@public-files.de>
Subject: Re: [PATCH net-next v4 11/11] net: dsa: realtek: rtl8365mb: multiple cpu ports, non cpu extint
Date: Mon, 10 Jan 2022 13:39:53 +0000	[thread overview]
Message-ID: <87ee5fd80m.fsf@bang-olufsen.dk> (raw)
In-Reply-To: <20220105031515.29276-12-luizluca@gmail.com> (Luiz Angelo Daros de Luca's message of "Wed, 5 Jan 2022 00:15:15 -0300")

Luiz Angelo Daros de Luca <luizluca@gmail.com> writes:

> Now CPU port is not limited to a single port. Also, extint can be used
> as non-cpu ports, as long as it defines relatek,ext-int. The last cpu
> port will be used as trap_port.
>
> The CPU information was dropped from chip data as it was not used
> outside setup. The only other place it was used is when it wrongly
> checks for CPU port when it should check for extint.
>
> realtek_priv->cpu_port is now only used by rtl8366rb.c

Great work with this series! If I understood correctly from your last
emails, you weren't actually able to test this due to hardware
constraints. While I think this change is not going to introduce any
surprises, I think you should still mention that it is not tested.

Some more comments below but in general the change makes sense to me.

>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> ---
>  drivers/net/dsa/realtek/rtl8365mb.c | 53 +++++++++++++++--------------
>  1 file changed, 27 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
> index 59e08b192c06..6a00a162b2ac 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb.c
> @@ -556,7 +556,6 @@ struct rtl8365mb_port {
>   * @chip_ver: chip silicon revision
>   * @port_mask: mask of all ports
>   * @learn_limit_max: maximum number of L2 addresses the chip can learn
> - * @cpu: CPU tagging and CPU port configuration for this chip
>   * @mib_lock: prevent concurrent reads of MIB counters
>   * @ports: per-port data
>   * @jam_table: chip-specific initialization jam table
> @@ -571,7 +570,6 @@ struct rtl8365mb {
>  	u32 chip_ver;
>  	u32 port_mask;
>  	u32 learn_limit_max;
> -	struct rtl8365mb_cpu cpu;
>  	struct mutex mib_lock;
>  	struct rtl8365mb_port ports[RTL8365MB_MAX_NUM_PORTS];
>  	const struct rtl8365mb_jam_tbl_entry *jam_table;
> @@ -769,17 +767,20 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,
>  	u32 val;
>  	int ret;
>  
> -	if (port != priv->cpu_port) {
> -		dev_err(priv->dev, "only one EXT interface is currently supported\n");
> +	mb = priv->chip_data;
> +	p = &mb->ports[port];
> +	ext_int = p->ext_int;
> +
> +	if (ext_int == RTL8365MB_NOT_EXT) {
> +		dev_err(priv->dev,
> +			"Port %d is not identified as extenal interface.\n",

Maybe just a warning?
also: s/as extenal/as an external/

> +			port);
>  		return -EINVAL;
>  	}
>  
>  	dp = dsa_to_port(priv->ds, port);
>  	dn = dp->dn;
>  
> -	mb = priv->chip_data;
> -	p = &mb->ports[port];
> -	ext_int = p->ext_int;
>  
>  	/* Set the RGMII TX/RX delay
>  	 *
> @@ -859,15 +860,17 @@ static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,
>  	int val;
>  	int ret;
>  
> -	if (port != priv->cpu_port) {
> -		dev_err(priv->dev, "only one EXT interface is currently supported\n");
> -		return -EINVAL;
> -	}
> -
>  	mb = priv->chip_data;
>  	p = &mb->ports[port];
>  	ext_int = p->ext_int;
>  
> +	if (ext_int == RTL8365MB_NOT_EXT) {
> +		dev_err(priv->dev,
> +			"Port %d is not identified as extenal interface.\n",

ditto

> +			port);
> +		return -EINVAL;
> +	}
> +
>  	if (link) {
>  		/* Force the link up with the desired configuration */
>  		r_link = 1;
> @@ -1734,10 +1737,8 @@ static void rtl8365mb_irq_teardown(struct realtek_priv *priv)
>  	}
>  }
>  
> -static int rtl8365mb_cpu_config(struct realtek_priv *priv)
> +static int rtl8365mb_cpu_config(struct realtek_priv *priv, struct rtl8365mb_cpu *cpu)

const struct rtl8365mb_cpu?

>  {
> -	struct rtl8365mb *mb = priv->chip_data;
> -	struct rtl8365mb_cpu *cpu = &mb->cpu;
>  	u32 val;
>  	int ret;
>  
> @@ -1839,11 +1840,17 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
>  		dev_info(priv->dev, "no interrupt support\n");
>  
>  	/* Configure CPU tagging */
> +	cpu.mask = 0;

I guess the unused cpu variable in the earlier patch belongs in this
one, in which case you can just initialize it = { 0 } so that you don't
need to explicitly set cpu.mask = 0.

>  	dsa_switch_for_each_cpu_port(cpu_dp, priv->ds) {
> -		priv->cpu_port = cpu_dp->index;
> -		mb->cpu.mask = BIT(priv->cpu_port);
> -		mb->cpu.trap_port = priv->cpu_port;
> -		ret = rtl8365mb_cpu_config(priv);
> +		cpu.enable = 1;
> +		cpu.insert = RTL8365MB_CPU_INSERT_TO_ALL;
> +		cpu.position = RTL8365MB_CPU_POS_AFTER_SA;
> +		cpu.rx_length = RTL8365MB_CPU_RXLEN_64BYTES;
> +		cpu.format = RTL8365MB_CPU_FORMAT_8BYTES;
> +		cpu.trap_port = cpu_dp->index;

If you are going to do this, perhaps it's better specified as a device
tree property like the external interface index? Making the "last" CPU
port the trap port is not incorrect, but it seems quite arbitrary.

> +		cpu.mask |= BIT(cpu_dp->index);
> +
> +		ret = rtl8365mb_cpu_config(priv, &cpu);

Shouldn't this go outside the loop to avoid potentially calling it twice
in a row?

>  		if (ret)
>  			goto out_teardown_irq;
>  
> @@ -1862,7 +1869,7 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
>  		dn = dsa_to_port(priv->ds, i)->dn;
>  
>  		/* Forward only to the CPU */
> -		ret = rtl8365mb_port_set_isolation(priv, i, BIT(priv->cpu_port));
> +		ret = rtl8365mb_port_set_isolation(priv, i, cpu.mask);
>  		if (ret)
>  			goto out_teardown_irq;
>  
> @@ -2003,12 +2010,6 @@ static int rtl8365mb_detect(struct realtek_priv *priv)
>  		mb->jam_table = rtl8365mb_init_jam_8365mb_vc;
>  		mb->jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc);
>  
> -		mb->cpu.enable = 1;
> -		mb->cpu.insert = RTL8365MB_CPU_INSERT_TO_ALL;
> -		mb->cpu.position = RTL8365MB_CPU_POS_AFTER_SA;
> -		mb->cpu.rx_length = RTL8365MB_CPU_RXLEN_64BYTES;
> -		mb->cpu.format = RTL8365MB_CPU_FORMAT_8BYTES;
> -
>  		break;
>  	default:
>  		dev_err(priv->dev,

  reply	other threads:[~2022-01-10 13:40 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05  3:15 [PATCH net-next v4 00/11] net: dsa: realtek: MDIO interface and RTL8367S Luiz Angelo Daros de Luca
2022-01-05  3:15 ` [PATCH net-next v4 01/11] net: dsa: realtek-smi: move to subdirectory Luiz Angelo Daros de Luca
2022-01-05  3:15 ` [PATCH net-next v4 02/11] net: dsa: realtek: rename realtek_smi to realtek_priv Luiz Angelo Daros de Luca
2022-01-07  3:42   ` Jakub Kicinski
2022-01-10 12:33   ` Alvin Šipraga
2022-01-16  0:04   ` Linus Walleij
2022-01-20 14:37   ` Vladimir Oltean
2022-01-05  3:15 ` [PATCH net-next v4 03/11] net: dsa: realtek: remove direct calls to realtek-smi Luiz Angelo Daros de Luca
2022-01-10 12:38   ` Alvin Šipraga
2022-01-16  0:05   ` Linus Walleij
2022-01-17  3:46   ` Florian Fainelli
2022-01-05  3:15 ` [PATCH net-next v4 04/11] net: dsa: realtek: convert subdrivers into modules Luiz Angelo Daros de Luca
2022-01-10 12:43   ` Alvin Šipraga
2022-01-17  4:02   ` Florian Fainelli
2022-01-05  3:15 ` [PATCH net-next v4 05/11] net: dsa: realtek: use phy_read in ds->ops Luiz Angelo Daros de Luca
2022-01-10 13:09   ` Alvin Šipraga
2022-01-17  4:15   ` Florian Fainelli
2022-01-18  2:55     ` Luiz Angelo Daros de Luca
2022-01-18 13:16       ` Andrew Lunn
2022-01-21 22:13         ` Luiz Angelo Daros de Luca
2022-01-21 23:48           ` Andrew Lunn
2022-01-05  3:15 ` [PATCH net-next v4 06/11] net: dsa: realtek: add new mdio interface for drivers Luiz Angelo Daros de Luca
2022-01-10 13:09   ` Alvin Šipraga
2022-01-17  4:22   ` Florian Fainelli
2022-01-18  4:38     ` Luiz Angelo Daros de Luca
2022-01-05  3:15 ` [PATCH net-next v4 07/11] net: dsa: realtek: rtl8365mb: rename extport to extint, add "realtek,ext-int" Luiz Angelo Daros de Luca
2022-01-10 13:15   ` Alvin Šipraga
2022-01-17  4:25   ` Florian Fainelli
2022-01-05  3:15 ` [PATCH net-next v4 08/11] net: dsa: realtek: rtl8365mb: use GENMASK(n-1,0) instead of BIT(n)-1 Luiz Angelo Daros de Luca
2022-01-10 13:18   ` Alvin Šipraga
2022-01-17  4:25   ` Florian Fainelli
2022-01-05  3:15 ` [PATCH net-next v4 09/11] net: dsa: realtek: rtl8365mb: use DSA CPU port Luiz Angelo Daros de Luca
2022-01-07  3:37   ` Jakub Kicinski
2022-01-10 13:22   ` Alvin Šipraga
2022-01-17  4:26   ` Florian Fainelli
2022-01-05  3:15 ` [PATCH net-next v4 10/11] net: dsa: realtek: rtl8365mb: add RTL8367S support Luiz Angelo Daros de Luca
2022-01-10 13:26   ` Alvin Šipraga
2022-01-17  4:26   ` Florian Fainelli
2022-01-05  3:15 ` [PATCH net-next v4 11/11] net: dsa: realtek: rtl8365mb: multiple cpu ports, non cpu extint Luiz Angelo Daros de Luca
2022-01-10 13:39   ` Alvin Šipraga [this message]
2022-01-10 13:53     ` Aw: " Frank Wunderlich
2022-01-11 18:17       ` Alvin Šipraga
2022-01-11 18:45         ` Aw: " Frank Wunderlich
2022-01-13 12:37           ` Alvin Šipraga
2022-01-13 15:56             ` Aw: " Frank Wunderlich
2022-01-18  4:58               ` Luiz Angelo Daros de Luca
2022-01-18 10:13                 ` Alvin Šipraga
2022-01-18 13:20                 ` Re: Re: " Andrew Lunn
2022-01-20 15:12                   ` Vladimir Oltean
2022-01-20 23:35                     ` Luiz Angelo Daros de Luca
2022-01-21  2:06                       ` Vladimir Oltean
2022-01-21  3:13                         ` Luiz Angelo Daros de Luca
2022-01-21  3:22                           ` Florian Fainelli
2022-01-21  3:42                             ` Luiz Angelo Daros de Luca
2022-01-21  3:50                               ` Florian Fainelli
2022-01-21  4:37                                 ` Luiz Angelo Daros de Luca
2022-01-21  9:07                                 ` Arınç ÜNAL
2022-01-21 18:50                           ` Vladimir Oltean
2022-01-21 21:51                             ` Luiz Angelo Daros de Luca
2022-01-21 22:49                               ` Vladimir Oltean
2022-01-22 20:12                                 ` Luiz Angelo Daros de Luca
2022-01-24 15:31                                   ` Vladimir Oltean
2022-01-24 16:46                                     ` Jakub Kicinski
2022-01-24 16:55                                       ` Vladimir Oltean
2022-01-24 17:01                                         ` Florian Fainelli
2022-01-24 17:21                                           ` Vladimir Oltean
2022-01-24 17:30                                             ` Florian Fainelli
2022-01-24 17:35                                             ` Jakub Kicinski
2022-01-24 18:20                                               ` Jakub Kicinski
2022-01-24 19:08                                                 ` Vladimir Oltean
2022-01-24 19:38                                                   ` Jakub Kicinski
2022-01-24 20:56                                                     ` Vladimir Oltean
2022-01-24 21:42                                                       ` Jakub Kicinski
2022-01-24 22:30                                                         ` Vladimir Oltean
2022-01-25  7:15                                                           ` Luiz Angelo Daros de Luca
2022-01-25  9:47                                                             ` Vladimir Oltean
2022-01-25 22:29                                                               ` Luiz Angelo Daros de Luca
2022-01-25 23:56                                                                 ` Florian Fainelli
2022-01-26 22:49                                                                   ` Luiz Angelo Daros de Luca
2022-01-25  9:44                                                           ` Arınç ÜNAL
2022-01-22 15:51                               ` Andrew Lunn
2022-01-30  1:54                 ` Re: Re: " Luiz Angelo Daros de Luca
2022-01-30  4:42                   ` Luiz Angelo Daros de Luca
2022-01-30 17:24                     ` Florian Fainelli
2022-01-31 17:26                       ` Luiz Angelo Daros de Luca
2022-02-01 14:46                         ` Vladimir Oltean
2022-01-20 14:36 ` [PATCH net-next v4 00/11] net: dsa: realtek: MDIO interface and RTL8367S Vladimir Oltean
2022-01-20 17:46   ` Luiz Angelo Daros de Luca

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=87ee5fd80m.fsf@bang-olufsen.dk \
    --to=alsi@bang-olufsen.dk \
    --cc=andrew@lunn.ch \
    --cc=arinc.unal@arinc9.com \
    --cc=f.fainelli@gmail.com \
    --cc=frank-w@public-files.de \
    --cc=linus.walleij@linaro.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=vivien.didelot@gmail.com \
    --subject='Re: [PATCH net-next v4 11/11] net: dsa: realtek: rtl8365mb: multiple cpu ports, non cpu extint' \
    /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).