Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>, Ido Schimmel <idosch@idosch.org>,
	Tobias Waldekranz <tobias@waldekranz.com>,
	Roopa Prabhu <roopa@nvidia.com>,
	Nikolay Aleksandrov <nikolay@nvidia.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	bridge@lists.linux-foundation.org,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: Re: [RFC PATCH v3 net-next 22/24] net: dsa: add support for bridge TX forwarding offload
Date: Thu, 15 Jul 2021 17:49:29 +0300	[thread overview]
Message-ID: <20210715144929.oa3u44is3v6gewr5@skbuf> (raw)
In-Reply-To: <20210712152142.800651-23-vladimir.oltean@nxp.com>

On Mon, Jul 12, 2021 at 06:21:40PM +0300, Vladimir Oltean wrote:
> +static bool dsa_port_bridge_tx_fwd_prepare(struct dsa_port *dp,
> +					   struct net_device *bridge_dev)
> +{
> +	struct dsa_switch *ds = dp->ds;
> +	struct dsa_switch_tree *dst;
> +	int bridge_num, err;
> +
> +	dst = ds->dst;
> +
> +	bridge_num = dsa_tree_find_bridge_num(dst, bridge_dev);
> +	if (bridge_num < 0) {
> +		/* First port that offloads TX forwarding for this bridge */
> +		int bridge_num;

Stupid bug: "bridge_num" is redeclared here as a different variable with
a different scope, shadowing the one from dsa_port_bridge_tx_fwd_prepare().

> +
> +		bridge_num = find_first_zero_bit(&dst->fwd_offloading_bridges,
> +						 DSA_MAX_NUM_OFFLOADING_BRIDGES);
> +		if (bridge_num >= ds->num_fwd_offloading_bridges)
> +			return false;
> +
> +		set_bit(bridge_num, &dst->fwd_offloading_bridges);
> +	}
> +
> +	dp->bridge_num = bridge_num;

and then here, the scope from the "if" block is lost, so the bridge_num
variable is still -1. So dp->bridge_num remains -1.

Deleting the "int bridge_num" declaration from the "if" block fixes the
issue. This got introduced between v2 and v3.

> +
> +	/* Notify the driver */
> +	err = dsa_port_bridge_fwd_offload_add(dp, bridge_dev, bridge_num);
> +	if (err) {
> +		dsa_port_bridge_tx_fwd_unprepare(dp, bridge_dev);
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
>  int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br,
>  			 struct netlink_ext_ack *extack)
>  {
> @@ -241,6 +310,7 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br,
>  	};
>  	struct net_device *dev = dp->slave;
>  	struct net_device *brport_dev;
> +	bool tx_fwd_offload;
>  	int err;
>  
>  	/* Here the interface is already bridged. Reflect the current
> @@ -254,7 +324,10 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br,
>  	if (err)
>  		goto out_rollback;
>  
> -	err = switchdev_bridge_port_offload(brport_dev, dev, dp, false, extack);
> +	tx_fwd_offload = dsa_port_bridge_tx_fwd_prepare(dp, br);
> +
> +	err = switchdev_bridge_port_offload(brport_dev, dev, dp, tx_fwd_offload,
> +					    extack);
>  	if (err)
>  		goto out_rollback_unbridge;
>  
> @@ -279,6 +352,8 @@ int dsa_port_pre_bridge_leave(struct dsa_port *dp, struct net_device *br,
>  	struct net_device *brport_dev = dsa_port_to_bridge_port(dp);
>  	struct net_device *dev = dp->slave;
>  
> +	dsa_port_bridge_tx_fwd_prepare(dp, br);

We are in the pre_bridge_leave path, this should have been _unprepare.

> +
>  	return switchdev_bridge_port_unoffload(brport_dev, dev, dp, extack);
>  }

The patches should work otherwise, if somebody wants to test they should
make these changes.

There are also some more changes that need to be made to mlxsw to
properly handle the unoffload of bridge ports that are LAG devices and
VLAN devices. I have them in my tree now. When net-next reopens I will
first send a series of 7 refactoring patches for dpaa2-switch, mlxsw and
prestera, and then the TX data plane offload in DSA as a 15-patch series.

  reply	other threads:[~2021-07-15 14:49 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 15:21 [RFC PATCH v3 net-next 00/24] Allow forwarding for the software bridge data path to be offloaded to capable devices Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 01/24] net: dpaa2-switch: use extack in dpaa2_switch_port_bridge_join Vladimir Oltean
2021-07-13  2:20   ` Florian Fainelli
2021-07-12 15:21 ` [RFC PATCH v3 net-next 02/24] net: dpaa2-switch: refactor prechangeupper sanity checks Vladimir Oltean
2021-07-13  2:21   ` Florian Fainelli
2021-07-12 15:21 ` [RFC PATCH v3 net-next 03/24] net: mlxsw: " Vladimir Oltean
2021-07-13  2:21   ` Florian Fainelli
2021-07-12 15:21 ` [RFC PATCH v3 net-next 04/24] net: ocelot: fix switchdev objects synced for wrong netdev with LAG offload Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 05/24] net: prestera: if the LAG that we're joining is under a bridge, join it Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 06/24] net: prestera: refactor prechangeupper sanity checks Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 07/24] net: bridge: disambiguate offload_fwd_mark Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 08/24] net: bridge: switchdev: recycle unused hwdoms Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 09/24] net: bridge: switchdev: let drivers inform which bridge ports are offloaded Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 10/24] net: prestera: guard against multiple switchdev obj replays on same bridge port Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 11/24] net: mlxsw: " Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 12/24] net: bridge: drop context pointer from br_fdb_replay Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 13/24] net: bridge: use the public notifier chain for br_fdb_replay Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 14/24] net: bridge: unexport call_switchdev_blocking_notifiers Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 15/24] net: bridge: propagate ctx to switchdev_port_obj_{add,del} Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 16/24] net: bridge: propagate ctx to br_switchdev_port_vlan_{add,del} Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 17/24] net: bridge: replay mdb entries on the public switchdev notifier chain Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 18/24] net: bridge: replay vlan entries on the public switchdev notifier Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 19/24] net: bridge: switchdev object replay helpers for everybody Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 20/24] net: bridge: switchdev: allow the TX data plane forwarding to be offloaded Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 21/24] net: dsa: track the number of switches in a tree Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 22/24] net: dsa: add support for bridge TX forwarding offload Vladimir Oltean
2021-07-15 14:49   ` Vladimir Oltean [this message]
2021-07-12 15:21 ` [RFC PATCH v3 net-next 23/24] net: dsa: mv88e6xxx: map virtual bridges with forwarding offload in the PVT Vladimir Oltean
2021-07-12 15:21 ` [RFC PATCH v3 net-next 24/24] net: dsa: tag_dsa: offload the bridge forwarding process Vladimir Oltean
2021-07-12 15:40 ` [RFC PATCH v3 net-next 00/24] Allow forwarding for the software bridge data path to be offloaded to capable devices Marek Behun
2021-07-12 17:01   ` Vladimir Oltean
2021-07-12 17:27     ` Marek Behun
2021-07-22  9:50       ` 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=20210715144929.oa3u44is3v6gewr5@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=grygorii.strashko@ti.com \
    --cc=idosch@idosch.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=roopa@nvidia.com \
    --cc=stephen@networkplumber.org \
    --cc=tobias@waldekranz.com \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.com \
    --subject='Re: [RFC PATCH v3 net-next 22/24] net: dsa: add support for bridge TX forwarding offload' \
    /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).