netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wojciech Drewek <wojciech.drewek@intel.com>
To: Matthias Schiffer <mschiffer@universe-factory.net>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 3/3] net: dsa: qca8k: add support for bridge port isolation
Date: Fri, 21 Jun 2024 12:54:34 +0200	[thread overview]
Message-ID: <b9481bf5-c36e-45da-a718-0c7a254ff3d9@intel.com> (raw)
In-Reply-To: <78b4bbb3644e1fabae9cc53501d0842ccd1a1c5d.1718899575.git.mschiffer@universe-factory.net>



On 20.06.2024 19:25, Matthias Schiffer wrote:
> Remove a pair of ports from the port matrix when both ports have the
> isolated flag set.
> 
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
> ---

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/dsa/qca/qca8k-common.c | 22 ++++++++++++++++++++--
>  drivers/net/dsa/qca/qca8k.h        |  1 +
>  2 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c
> index 09108fa99dbe..560c74c4ac3d 100644
> --- a/drivers/net/dsa/qca/qca8k-common.c
> +++ b/drivers/net/dsa/qca/qca8k-common.c
> @@ -618,6 +618,7 @@ static int qca8k_update_port_member(struct qca8k_priv *priv, int port,
>  				    const struct net_device *bridge_dev,
>  				    bool join)
>  {
> +	bool isolated = !!(priv->port_isolated_map & BIT(port)), other_isolated;
>  	struct dsa_port *dp = dsa_to_port(priv->ds, port), *other_dp;
>  	u32 port_mask = BIT(dp->cpu_dp->index);
>  	int i, ret;
> @@ -632,10 +633,12 @@ static int qca8k_update_port_member(struct qca8k_priv *priv, int port,
>  		if (!dsa_port_offloads_bridge_dev(other_dp, bridge_dev))
>  			continue;
>  
> +		other_isolated = !!(priv->port_isolated_map & BIT(i));
> +
>  		/* Add/remove this port to/from the portvlan mask of the other
>  		 * ports in the bridge
>  		 */
> -		if (join) {
> +		if (join && !(isolated && other_isolated)) {
>  			port_mask |= BIT(i);
>  			ret = regmap_set_bits(priv->regmap,
>  					      QCA8K_PORT_LOOKUP_CTRL(i),
> @@ -661,7 +664,7 @@ int qca8k_port_pre_bridge_flags(struct dsa_switch *ds, int port,
>  				struct switchdev_brport_flags flags,
>  				struct netlink_ext_ack *extack)
>  {
> -	if (flags.mask & ~BR_LEARNING)
> +	if (flags.mask & ~(BR_LEARNING | BR_ISOLATED))
>  		return -EINVAL;
>  
>  	return 0;
> @@ -671,6 +674,7 @@ int qca8k_port_bridge_flags(struct dsa_switch *ds, int port,
>  			    struct switchdev_brport_flags flags,
>  			    struct netlink_ext_ack *extack)
>  {
> +	struct qca8k_priv *priv = ds->priv;
>  	int ret;
>  
>  	if (flags.mask & BR_LEARNING) {
> @@ -680,6 +684,20 @@ int qca8k_port_bridge_flags(struct dsa_switch *ds, int port,
>  			return ret;
>  	}
>  
> +	if (flags.mask & BR_ISOLATED) {
> +		struct dsa_port *dp = dsa_to_port(ds, port);
> +		struct net_device *bridge_dev = dsa_port_bridge_dev_get(dp);
> +
> +		if (flags.val & BR_ISOLATED)
> +			priv->port_isolated_map |= BIT(port);
> +		else
> +			priv->port_isolated_map &= ~BIT(port);
> +
> +		ret = qca8k_update_port_member(priv, port, bridge_dev, true);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h
> index 2184d8d2d5a9..3664a2e2f1f6 100644
> --- a/drivers/net/dsa/qca/qca8k.h
> +++ b/drivers/net/dsa/qca/qca8k.h
> @@ -451,6 +451,7 @@ struct qca8k_priv {
>  	 * Bit 1: port enabled. Bit 0: port disabled.
>  	 */
>  	u8 port_enabled_map;
> +	u8 port_isolated_map;
>  	struct qca8k_ports_config ports_config;
>  	struct regmap *regmap;
>  	struct mii_bus *bus;

  reply	other threads:[~2024-06-21 10:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 17:25 [PATCH net-next 0/3] net: dsa: qca8k: cleanup and port isolation Matthias Schiffer
2024-06-20 17:25 ` [PATCH net-next 1/3] net: dsa: qca8k: do not write port mask twice in bridge join/leave Matthias Schiffer
2024-06-21 10:48   ` Wojciech Drewek
2024-06-20 17:25 ` [PATCH net-next 2/3] net: dsa: qca8k: factor out bridge join/leave logic Matthias Schiffer
2024-06-21 10:51   ` Wojciech Drewek
2024-06-21 16:48   ` Vladimir Oltean
2024-06-20 17:25 ` [PATCH net-next 3/3] net: dsa: qca8k: add support for bridge port isolation Matthias Schiffer
2024-06-21 10:54   ` Wojciech Drewek [this message]
2024-06-21 16:46   ` Vladimir Oltean
2024-06-21 11:30 ` [PATCH net-next 0/3] net: dsa: qca8k: cleanup and " 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=b9481bf5-c36e-45da-a718-0c7a254ff3d9@intel.com \
    --to=wojciech.drewek@intel.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mschiffer@universe-factory.net \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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).