linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadym Kochan <vadym.kochan@plvision.eu>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Oleksandr Mazur <oleksandr.mazur@plvision.eu>,
	Serhiy Boiko <serhiy.boiko@plvision.eu>,
	Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
	Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
	Taras Chornyi <taras.chornyi@plvision.eu>,
	netdev@vger.kernel.org
Cc: Mickey Rachamim <mickeyr@marvell.com>,
	Vadym Kochan <vadym.kochan@plvision.eu>,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 4/7] net: marvell: prestera: move netdev topology validation to prestera_main
Date: Wed,  3 Feb 2021 18:54:55 +0200	[thread overview]
Message-ID: <20210203165458.28717-5-vadym.kochan@plvision.eu> (raw)
In-Reply-To: <20210203165458.28717-1-vadym.kochan@plvision.eu>

Move handling of PRECHANGEUPPER event from prestera_switchdev to
prestera_main which is responsible for basic netdev events handling
and routing them to related module.

Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
---
 .../ethernet/marvell/prestera/prestera_main.c | 29 +++++++++++++++++--
 .../marvell/prestera/prestera_switchdev.c     | 20 -------------
 2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index 25dd903a3e92..53c7628a3938 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -510,13 +510,36 @@ struct prestera_port *prestera_port_dev_lower_find(struct net_device *dev)
 static int prestera_netdev_port_event(struct net_device *dev,
 				      unsigned long event, void *ptr)
 {
+	struct netdev_notifier_changeupper_info *info = ptr;
+	struct netlink_ext_ack *extack;
+	struct net_device *upper;
+
+	extack = netdev_notifier_info_to_extack(&info->info);
+	upper = info->upper_dev;
+
 	switch (event) {
 	case NETDEV_PRECHANGEUPPER:
+		if (!netif_is_bridge_master(upper)) {
+			NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
+			return -EINVAL;
+		}
+
+		if (!info->linking)
+			break;
+
+		if (netdev_has_any_upper_dev(upper)) {
+			NL_SET_ERR_MSG_MOD(extack, "Upper device is already enslaved");
+			return -EINVAL;
+		}
+		break;
+
 	case NETDEV_CHANGEUPPER:
-		return prestera_bridge_port_event(dev, event, ptr);
-	default:
-		return 0;
+		if (netif_is_bridge_master(upper))
+			return prestera_bridge_port_event(dev, event, ptr);
+		break;
 	}
+
+	return 0;
 }
 
 static int prestera_netdev_event_handler(struct notifier_block *nb,
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
index 8c2b03151736..7736d5f498c9 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
@@ -537,35 +537,15 @@ int prestera_bridge_port_event(struct net_device *dev, unsigned long event,
 			       void *ptr)
 {
 	struct netdev_notifier_changeupper_info *info = ptr;
-	struct netlink_ext_ack *extack;
 	struct prestera_port *port;
 	struct net_device *upper;
 	int err;
 
-	extack = netdev_notifier_info_to_extack(&info->info);
 	port = netdev_priv(dev);
 	upper = info->upper_dev;
 
 	switch (event) {
-	case NETDEV_PRECHANGEUPPER:
-		if (!netif_is_bridge_master(upper)) {
-			NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
-			return -EINVAL;
-		}
-
-		if (!info->linking)
-			break;
-
-		if (netdev_has_any_upper_dev(upper)) {
-			NL_SET_ERR_MSG_MOD(extack, "Upper device is already enslaved");
-			return -EINVAL;
-		}
-		break;
-
 	case NETDEV_CHANGEUPPER:
-		if (!netif_is_bridge_master(upper))
-			break;
-
 		if (info->linking) {
 			err = prestera_port_bridge_join(port, upper);
 			if (err)
-- 
2.17.1


  parent reply	other threads:[~2021-02-03 16:58 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03 16:54 [PATCH net-next 0/7] Marvell Prestera Switchdev misc updates Vadym Kochan
2021-02-03 16:54 ` [PATCH net-next 1/7] net: marvell: prestera: bump supported firmware version to 2.5 Vadym Kochan
2021-02-03 16:54 ` [PATCH net-next 2/7] net: marvell: prestera: disable events interrupt while handling Vadym Kochan
2021-02-05  5:10   ` Jakub Kicinski
2021-02-05 11:28     ` Vadym Kochan
2021-02-03 16:54 ` [PATCH net-next 3/7] net: marvell: prestera: add support for AC3X 98DX3265 device Vadym Kochan
2021-02-03 16:54 ` Vadym Kochan [this message]
2021-02-05 14:09   ` [PATCH net-next 4/7] net: marvell: prestera: move netdev topology validation to prestera_main Vladimir Oltean
2021-02-03 16:54 ` [PATCH net-next 5/7] net: marvell: prestera: add LAG support Vadym Kochan
2021-02-05  5:16   ` Jakub Kicinski
2021-02-08 19:54     ` Tobias Waldekranz
2021-02-08 21:05       ` Jakub Kicinski
2021-02-08 22:30         ` Andrew Lunn
2021-02-09 12:37           ` Tobias Waldekranz
2021-02-09 11:56         ` Tobias Waldekranz
2021-02-09 17:48           ` Jakub Kicinski
2021-02-09 13:58         ` Andrew Lunn
2021-02-09 17:35           ` Jakub Kicinski
2021-02-09 20:31             ` [EXT] " Mickey Rachamim
2021-02-09 21:34               ` Tobias Waldekranz
2021-02-10 10:41                 ` Mickey Rachamim
2021-02-10 21:44                   ` Tobias Waldekranz
2021-02-10  0:28               ` Andrew Lunn
2021-02-10 10:42                 ` Mickey Rachamim
2021-02-10 19:25               ` Jakub Kicinski
2021-02-10 20:52             ` Taras Chornyi
2021-02-05 15:24   ` Vladimir Oltean
2021-02-03 16:54 ` [PATCH net-next 6/7] net: marvell: prestera: align flood setting according to latest firmware version Vadym Kochan
2021-02-03 16:54 ` [PATCH net-next 7/7] net: marvell: prestera: fix port event handling on init Vadym Kochan
2021-02-05  5:19   ` Jakub Kicinski
2021-02-05 12:31     ` Vadym Kochan

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=20210203165458.28717-5-vadym.kochan@plvision.eu \
    --to=vadym.kochan@plvision.eu \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mickeyr@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=oleksandr.mazur@plvision.eu \
    --cc=serhiy.boiko@plvision.eu \
    --cc=serhiy.pshyk@plvision.eu \
    --cc=taras.chornyi@plvision.eu \
    --cc=volodymyr.mytnyk@plvision.eu \
    --subject='Re: [PATCH net-next 4/7] net: marvell: prestera: move netdev topology validation to prestera_main' \
    /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).