netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Vlad Buslov <vladbu@nvidia.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@google.com, netdev@vger.kernel.org,
	Wojciech Drewek <wojciech.drewek@intel.com>,
	jiri@resnulli.us, ivecera@redhat.com, simon.horman@corigine.com,
	Sujai Buvaneswaran <sujai.buvaneswaran@intel.com>
Subject: Re: [PATCH net-next 06/12] ice: Implement basic eswitch bridge setup
Date: Tue, 27 Jun 2023 08:46:38 +0200	[thread overview]
Message-ID: <ZJqFzmzilCHCbqXH@localhost.localdomain> (raw)
In-Reply-To: <871qhyuwa5.fsf@nvidia.com>

On Mon, Jun 26, 2023 at 05:31:14PM +0300, Vlad Buslov wrote:
> On Mon 26 Jun 2023 at 16:26, Michal Swiatkowski <michal.swiatkowski@linux.intel.com> wrote:
> > On Tue, Jun 20, 2023 at 10:44:17AM -0700, Tony Nguyen wrote:
> >> From: Wojciech Drewek <wojciech.drewek@intel.com>
> >> 
> >> With this patch, ice driver is able to track if the port
> >> representors or uplink port were added to the linux bridge in
> >> switchdev mode. Listen for NETDEV_CHANGEUPPER events in order to
> >> detect this. ice_esw_br data structure reflects the linux bridge
> >> and stores all the ports of the bridge (ice_esw_br_port) in
> >> xarray, it's created when the first port is added to the bridge and
> >> freed once the last port is removed. Note that only one bridge is
> >> supported per eswitch.
> >> 
> >> Bridge port (ice_esw_br_port) can be either a VF port representor
> >> port or uplink port (ice_esw_br_port_type). In both cases bridge port
> >> holds a reference to the VSI, VF's VSI in case of the PR and uplink
> >> VSI in case of the uplink. VSI's index is used as an index to the
> >> xarray in which ports are stored.
> >> 
> >> Add a check which prevents configuring switchdev mode if uplink is
> >> already added to any bridge. This is needed because we need to listen
> >> for NETDEV_CHANGEUPPER events to record if the uplink was added to
> >> the bridge. Netdevice notifier is registered after eswitch mode
> >> is changed to switchdev.
> >> 
> >> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> >> Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
> >> Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com>
> >> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> >> ---
> >>  drivers/net/ethernet/intel/ice/Makefile       |   2 +-
> >>  drivers/net/ethernet/intel/ice/ice.h          |   4 +-
> >>  drivers/net/ethernet/intel/ice/ice_eswitch.c  |  26 +-
> >>  .../net/ethernet/intel/ice/ice_eswitch_br.c   | 384 ++++++++++++++++++
> >>  .../net/ethernet/intel/ice/ice_eswitch_br.h   |  42 ++
> >>  drivers/net/ethernet/intel/ice/ice_main.c     |   2 +-
> >>  drivers/net/ethernet/intel/ice/ice_repr.c     |   2 +-
> >>  drivers/net/ethernet/intel/ice/ice_repr.h     |   3 +-
> >>  8 files changed, 456 insertions(+), 9 deletions(-)
> >>  create mode 100644 drivers/net/ethernet/intel/ice/ice_eswitch_br.c
> >>  create mode 100644 drivers/net/ethernet/intel/ice/ice_eswitch_br.h
> >> +
> >> +static int
> >> +ice_eswitch_br_port_changeupper(struct notifier_block *nb, void *ptr)
> >> +{
> >> +	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> >> +	struct netdev_notifier_changeupper_info *info = ptr;
> >> +	struct ice_esw_br_offloads *br_offloads;
> >> +	struct netlink_ext_ack *extack;
> >> +	struct net_device *upper;
> >> +
> >> +	br_offloads = ice_nb_to_br_offloads(nb, netdev_nb);
> >> +
> >> +	if (!ice_eswitch_br_is_dev_valid(dev))
> >> +		return 0;
> >> +
> >> +	upper = info->upper_dev;
> >> +	if (!netif_is_bridge_master(upper))
> >> +		return 0;
> >> +
> >> +	extack = netdev_notifier_info_to_extack(&info->info);
> >> +
> >> +	if (info->linking)
> >> +		return ice_eswitch_br_port_link(br_offloads, dev,
> >> +						upper->ifindex, extack);
> >> +	else
> >> +		return ice_eswitch_br_port_unlink(br_offloads, dev,
> >> +						  upper->ifindex, extack);
> >> +}
> >> +
> >> +static int
> >> +ice_eswitch_br_port_event(struct notifier_block *nb,
> >> +			  unsigned long event, void *ptr)
> >> +{
> >> +	int err = 0;
> >> +
> >> +	switch (event) {
> >> +	case NETDEV_CHANGEUPPER:
> >> +		err = ice_eswitch_br_port_changeupper(nb, ptr);
> >> +		break;
> >> +	}
> >> +
> >> +	return notifier_from_errno(err);
> >> +}
> > Hi Vlad,
> >
> > We found out that adding VF and corresponding port representor to the
> > bridge cause loop in the bridge. Packets are looping through the bridge.
> > I know that it isn't valid configuration, howevere, it can happen and
> > after that the server is quite unstable.
> >
> > Does mellanox validate the port for this scenario? Or we should assume
> > that user will add port wisely? I was looking at your code, but didn't
> > find that. You are using NETDEV_PRECHANGEUPPER, do you think we should
> > validate if user is trying to add VF when his PR is currently added?
> 
> Hmm, no, it is not something we validate. Also, I assume it will be
> quite tricky to properly test for it, since user could try to add some
> other netdevice connected to the VF (VLAN, tunneling dev, bonding, etc.)
> which will probably lead to same result.
> 

Agree, thanks. As Jakub wrote, STP should be turned on to prevent this kind
of problem.

  reply	other threads:[~2023-06-27  6:46 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 17:44 [PATCH net-next 00/12][pull request] ice: switchdev bridge offload Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 01/12] ice: Skip adv rules removal upon switchdev release Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 02/12] ice: Prohibit rx mode change in switchdev mode Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 03/12] ice: Don't tx before switchdev is fully configured Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 04/12] ice: Disable vlan pruning for uplink VSI Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 05/12] ice: Unset src prune on " Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 06/12] ice: Implement basic eswitch bridge setup Tony Nguyen
2023-06-26 14:26   ` Michal Swiatkowski
2023-06-26 14:31     ` Vlad Buslov
2023-06-27  6:46       ` Michal Swiatkowski [this message]
2023-06-26 17:35     ` Jakub Kicinski
2023-06-27  6:41       ` Michal Swiatkowski
2023-06-20 17:44 ` [PATCH net-next 07/12] ice: Switchdev FDB events support Tony Nguyen
2023-06-21 13:55   ` Simon Horman
2023-06-22 11:53   ` Vlad Buslov
2023-06-22 12:55     ` Drewek, Wojciech
2023-06-20 17:44 ` [PATCH net-next 08/12] ice: Add guard rule when creating FDB in switchdev Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 09/12] ice: Add VLAN FDB support in switchdev mode Tony Nguyen
2023-06-21 13:59   ` Simon Horman
2023-06-22 12:03   ` Vlad Buslov
2023-06-22 13:06     ` Drewek, Wojciech
2023-06-20 17:44 ` [PATCH net-next 10/12] ice: implement bridge port vlan Tony Nguyen
2023-06-22 12:07   ` Vlad Buslov
2023-06-22 17:07     ` Drewek, Wojciech
2023-06-20 17:44 ` [PATCH net-next 11/12] ice: implement static version of aging Tony Nguyen
2023-06-20 17:44 ` [PATCH net-next 12/12] ice: add tracepoints for the switchdev bridge Tony Nguyen
2023-06-20 18:12 ` [PATCH net-next 00/12][pull request] ice: switchdev bridge offload Jakub Kicinski
2023-06-21 19:25   ` Vlad Buslov
2023-06-22 17:13     ` Jakub Kicinski

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=ZJqFzmzilCHCbqXH@localhost.localdomain \
    --to=michal.swiatkowski@linux.intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=simon.horman@corigine.com \
    --cc=sujai.buvaneswaran@intel.com \
    --cc=vladbu@nvidia.com \
    --cc=wojciech.drewek@intel.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).