From: Richard van Schagen <richard@routerhints.com>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: "arinc9.unal@gmail.com" <arinc9.unal@gmail.com>,
"Sean Wang" <sean.wang@mediatek.com>,
"Landen Chao" <Landen.Chao@mediatek.com>,
"DENG Qingfang" <dqfext@gmail.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Arınç ÜNAL" <arinc.unal@arinc9.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"erkin.bozoglu@xeront.com" <erkin.bozoglu@xeront.com>
Subject: Re: [PATCH net-next] net: dsa: mt7530: add support for changing DSA master
Date: Fri, 10 Feb 2023 21:41:06 +0000 [thread overview]
Message-ID: <42C4F87B-520A-4F43-924D-9CDA577B04C7@routerhints.com> (raw)
In-Reply-To: <20230210185629.gfbaibewnc5u3tgs@skbuf>
> On 10 Feb 2023, at 19:56, Vladimir Oltean <olteanv@gmail.com> wrote:
>
> On Fri, Feb 10, 2023 at 08:29:43PM +0300, arinc9.unal@gmail.com wrote:
>> From: Richard van Schagen <richard@routerhints.com>
>>
>> Add support for changing the master of a port on the MT7530 DSA subdriver.
>>
>> [ arinc.unal@arinc9.com: Wrote subject and changelog ]
>>
>> Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
>> Signed-off-by: Richard van Schagen <richard@routerhints.com>
>> Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
>> ---
>> drivers/net/dsa/mt7530.c | 33 +++++++++++++++++++++++++++++++++
>> 1 file changed, 33 insertions(+)
>>
>> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
>> index b5ad4b4fc00c..04bb4986454e 100644
>> --- a/drivers/net/dsa/mt7530.c
>> +++ b/drivers/net/dsa/mt7530.c
>> @@ -1072,6 +1072,38 @@ mt7530_port_disable(struct dsa_switch *ds, int port)
>> mutex_unlock(&priv->reg_mutex);
>> }
>>
>> +static int
>> +mt7530_port_change_master(struct dsa_switch *ds, int port,
>> + struct net_device *master,
>> + struct netlink_ext_ack *extack)
>
> alignment
>
Will fix
>> +{
>> + struct mt7530_priv *priv = ds->priv;
>> + struct dsa_port *dp = dsa_to_port(ds, port);
>> + struct dsa_port *cpu_dp = master->dsa_ptr;
>> + int old_cpu = dp->cpu_dp->index;
>> + int new_cpu = cpu_dp->index;
>
> I believe you need to reject LAG DSA masters.
>
Not sure what you mean: how is this different from the change_master in the Felix driver when using 8021q tags?
But. Can add a check if you prefer. It might be a good idea anyway to be future proof. The MT7531 has support for LAG in hw.
>> +
>> + mutex_lock(&priv->reg_mutex);
>> +
>> + /* Move old to new cpu on User port */
>> + priv->ports[port].pm &= ~PCR_MATRIX(BIT(old_cpu));
>> + priv->ports[port].pm |= PCR_MATRIX(BIT(new_cpu));
>> +
>> + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
>> + priv->ports[port].pm);
>> +
>> + /* Move user port from old cpu to new cpu */
>> + priv->ports[old_cpu].pm &= ~PCR_MATRIX(BIT(port));
>> + priv->ports[new_cpu].pm |= PCR_MATRIX(BIT(port));
>> +
>> + mt7530_write(priv, MT7530_PCR_P(old_cpu), priv->ports[old_cpu].pm);
>> + mt7530_write(priv, MT7530_PCR_P(new_cpu), priv->ports[new_cpu].pm);
>
> - who writes to the "pm" field of CPU ports?
Nobody actually writes to cpu.pm. I “fixed” that, and dropped that later. This is left over.
> - how does this line up with your other patch which said (AFAIU) that
> the port matrix of CPU ports should be 0 and that should be fine?
Since cpu.pm was never user, and all user ports were added without using this field when enabling
the cpu, I changed that to add user ports belonging to that CPU. Arinc reported that it didn’t work.
Since the cpu.pm (empty) is writing during dsa_enable_port and that worked (for a long time already) the cpu.pm can be dropped.
> - read/modify/write (rmw) using PCR_MATRIX_MASK rather than mt7530_write().
> That overwrites the other PCR fields.
>
Good catch. Will fix.
>> +
>> + mutex_unlock(&priv->reg_mutex);
>> +
>> + return 0;
>> +}
>> +
>> static int
>> mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
>> {
>> @@ -3157,6 +3189,7 @@ static const struct dsa_switch_ops mt7530_switch_ops = {
>> .set_ageing_time = mt7530_set_ageing_time,
>> .port_enable = mt7530_port_enable,
>> .port_disable = mt7530_port_disable,
>> + .port_change_master = mt7530_port_change_master,
>> .port_change_mtu = mt7530_port_change_mtu,
>> .port_max_mtu = mt7530_port_max_mtu,
>> .port_stp_state_set = mt7530_stp_state_set,
>> --
>> 2.37.2
next prev parent reply other threads:[~2023-02-10 21:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 17:29 [PATCH net-next] net: dsa: mt7530: add support for changing DSA master arinc9.unal
2023-02-10 18:56 ` Vladimir Oltean
2023-02-10 21:41 ` Richard van Schagen [this message]
2023-02-10 22:27 ` 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=42C4F87B-520A-4F43-924D-9CDA577B04C7@routerhints.com \
--to=richard@routerhints.com \
--cc=Landen.Chao@mediatek.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=arinc.unal@arinc9.com \
--cc=arinc9.unal@gmail.com \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=edumazet@google.com \
--cc=erkin.bozoglu@xeront.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=sean.wang@mediatek.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).