Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Cc: 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>,
Marek Behun <kabel@blackhole.sk>,
DENG Qingfang <dqfext@gmail.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: [PATCH v6 net-next 2/7] net: dpaa2-switch: refactor prechangeupper sanity checks
Date: Wed, 21 Jul 2021 19:23:58 +0300 [thread overview]
Message-ID: <20210721162403.1988814-3-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20210721162403.1988814-1-vladimir.oltean@nxp.com>
Make more room for some extra code in the NETDEV_PRECHANGEUPPER handler
by moving what already exists into a dedicated function.
Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
v2->v3: patch is new
v3->v4: fix build error (s/dev/netdev/)
v4->v6: none
.../ethernet/freescale/dpaa2/dpaa2-switch.c | 37 +++++++++++++------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 62d322ebf1f2..23798feb40b2 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -2030,6 +2030,28 @@ static int dpaa2_switch_prevent_bridging_with_8021q_upper(struct net_device *net
return 0;
}
+static int
+dpaa2_switch_prechangeupper_sanity_checks(struct net_device *netdev,
+ struct net_device *upper_dev,
+ struct netlink_ext_ack *extack)
+{
+ int err;
+
+ if (!br_vlan_enabled(upper_dev)) {
+ NL_SET_ERR_MSG_MOD(extack, "Cannot join a VLAN-unaware bridge");
+ return -EOPNOTSUPP;
+ }
+
+ err = dpaa2_switch_prevent_bridging_with_8021q_upper(netdev);
+ if (err) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Cannot join a bridge while VLAN uppers are present");
+ return 0;
+ }
+
+ return 0;
+}
+
static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
unsigned long event, void *ptr)
{
@@ -2050,18 +2072,11 @@ static int dpaa2_switch_port_netdevice_event(struct notifier_block *nb,
if (!netif_is_bridge_master(upper_dev))
break;
- if (!br_vlan_enabled(upper_dev)) {
- NL_SET_ERR_MSG_MOD(extack, "Cannot join a VLAN-unaware bridge");
- err = -EOPNOTSUPP;
- goto out;
- }
-
- err = dpaa2_switch_prevent_bridging_with_8021q_upper(netdev);
- if (err) {
- NL_SET_ERR_MSG_MOD(extack,
- "Cannot join a bridge while VLAN uppers are present");
+ err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
+ upper_dev,
+ extack);
+ if (err)
goto out;
- }
break;
case NETDEV_CHANGEUPPER:
--
2.25.1
next prev parent reply other threads:[~2021-07-21 16:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 16:23 [PATCH v6 net-next 0/7] Let switchdev drivers offload and unoffload bridge ports at their own convenience Vladimir Oltean
2021-07-21 16:23 ` [PATCH v6 net-next 1/7] net: dpaa2-switch: use extack in dpaa2_switch_port_bridge_join Vladimir Oltean
2021-07-21 16:23 ` Vladimir Oltean [this message]
2021-07-21 16:23 ` [PATCH v6 net-next 3/7] net: bridge: disambiguate offload_fwd_mark Vladimir Oltean
2021-07-21 16:24 ` [PATCH v6 net-next 4/7] net: bridge: switchdev: recycle unused hwdoms Vladimir Oltean
2021-07-21 16:24 ` [PATCH v6 net-next 5/7] net: bridge: switchdev: let drivers inform which bridge ports are offloaded Vladimir Oltean
2021-07-26 13:51 ` Naresh Kamboju
2021-07-26 14:08 ` Andrew Lunn
2021-07-26 14:37 ` Vladimir Oltean
2021-07-27 4:03 ` Naresh Kamboju
2021-07-21 16:24 ` [PATCH v6 net-next 6/7] net: bridge: guard the switchdev replay helpers against a NULL notifier block Vladimir Oltean
2021-07-21 16:27 ` Florian Fainelli
2021-07-21 16:24 ` [PATCH v6 net-next 7/7] net: bridge: move the switchdev object replay helpers to "push" mode Vladimir Oltean
2021-07-22 7:40 ` [PATCH v6 net-next 0/7] Let switchdev drivers offload and unoffload bridge ports at their own convenience 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=20210721162403.1988814-3-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=andrew@lunn.ch \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=grygorii.strashko@ti.com \
--cc=idosch@idosch.org \
--cc=ioana.ciornei@nxp.com \
--cc=jiri@resnulli.us \
--cc=kabel@blackhole.sk \
--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 \
--subject='Re: [PATCH v6 net-next 2/7] net: dpaa2-switch: refactor prechangeupper sanity checks' \
/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).