From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
andrew@lunn.ch, vivien.didelot@gmail.com, davem@davemloft.net,
idosch@mellanox.com, jiri@mellanox.com,
ilias.apalodimas@linaro.org, ivan.khoronzhuk@linaro.org,
roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com
Subject: [PATCH net-next v2 09/12] net: dsa: Make VLAN filtering use DSA notifiers
Date: Tue, 29 Jan 2019 16:55:45 -0800 [thread overview]
Message-ID: <20190130005548.2212-10-f.fainelli@gmail.com> (raw)
In-Reply-To: <20190130005548.2212-1-f.fainelli@gmail.com>
In preparation for allowing for global checks that would apply to the
entire switch and not just on a per-port basis, make the VLAN filtering
attribute follow other switchdev attributes/objects and make it use the
DSA notifier infrastructure.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
net/dsa/dsa_priv.h | 11 ++++++++++-
net/dsa/port.c | 17 +++++++----------
net/dsa/switch.c | 29 +++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 1f4972dab9f2..1e3db5f2a699 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -26,6 +26,7 @@ enum {
DSA_NOTIFIER_MDB_DEL,
DSA_NOTIFIER_VLAN_ADD,
DSA_NOTIFIER_VLAN_DEL,
+ DSA_NOTIFIER_VLAN_FILTERING,
};
/* DSA_NOTIFIER_AGEING_TIME */
@@ -57,7 +58,7 @@ struct dsa_notifier_mdb_info {
int port;
};
-/* DSA_NOTIFIER_VLAN_* */
+/* DSA_NOTIFIER_VLAN_{ADD,DEL} */
struct dsa_notifier_vlan_info {
const struct switchdev_obj_port_vlan *vlan;
struct switchdev_trans *trans;
@@ -65,6 +66,14 @@ struct dsa_notifier_vlan_info {
int port;
};
+/* DSA_NOTIFIER_VLAN_FILTERING */
+struct dsa_notifier_vlan_filtering_info {
+ bool vlan_filtering;
+ struct switchdev_trans *trans;
+ int sw_index;
+ int port;
+};
+
struct dsa_slave_priv {
/* Copy of CPU port xmit for faster access in slave transmit hot path */
struct sk_buff * (*xmit)(struct sk_buff *skb,
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 185e85a4f5f0..d7b057d46460 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -146,17 +146,14 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
struct switchdev_trans *trans)
{
- struct dsa_switch *ds = dp->ds;
-
- /* bridge skips -EOPNOTSUPP, so skip the prepare phase */
- if (switchdev_trans_ph_prepare(trans))
- return 0;
-
- if (ds->ops->port_vlan_filtering)
- return ds->ops->port_vlan_filtering(ds, dp->index,
- vlan_filtering);
+ struct dsa_notifier_vlan_filtering_info info = {
+ .sw_index = dp->ds->index,
+ .port = dp->index,
+ .trans = trans,
+ .vlan_filtering = vlan_filtering,
+ };
- return 0;
+ return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_FILTERING, &info);
}
int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 142b294d3446..831334dc5e79 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -235,6 +235,32 @@ static int dsa_switch_vlan_del(struct dsa_switch *ds,
return 0;
}
+static int dsa_switch_vlan_filtering(struct dsa_switch *ds,
+ struct dsa_notifier_vlan_filtering_info *info)
+{
+ struct switchdev_trans *trans = info->trans;
+ bool vlan_filtering = info->vlan_filtering;
+ int port = info->port;
+ int err;
+
+ /* bridge skips -EOPNOTSUPP, so skip the prepare phase */
+ if (switchdev_trans_ph_prepare(trans))
+ return 0;
+
+ /* Build a mask of port members */
+ bitmap_zero(ds->bitmap, ds->num_ports);
+ if (ds->index == info->sw_index)
+ set_bit(port, ds->bitmap);
+
+ for_each_set_bit(port, ds->bitmap, ds->num_ports) {
+ err = ds->ops->port_vlan_filtering(ds, port, vlan_filtering);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
static int dsa_switch_event(struct notifier_block *nb,
unsigned long event, void *info)
{
@@ -269,6 +295,9 @@ static int dsa_switch_event(struct notifier_block *nb,
case DSA_NOTIFIER_VLAN_DEL:
err = dsa_switch_vlan_del(ds, info);
break;
+ case DSA_NOTIFIER_VLAN_FILTERING:
+ err = dsa_switch_vlan_filtering(ds, info);
+ break;
default:
err = -EOPNOTSUPP;
break;
--
2.17.1
next prev parent reply other threads:[~2019-01-30 0:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-30 0:55 [PATCH net-next v2 00/12] net: dsa: management mode for bcm_sf2 Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 01/12] net: bridge: multicast: Propagate br_mc_disabled_update() return Florian Fainelli
2019-01-30 7:36 ` Ido Schimmel
2019-01-31 1:00 ` Florian Fainelli
2019-01-31 7:50 ` Ido Schimmel
2019-02-01 1:19 ` Florian Fainelli
2019-02-02 15:47 ` Ido Schimmel
2019-02-11 19:05 ` Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 02/12] net: dsa: b53: Fix default VLAN ID Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 03/12] net: dsa: b53: Properly account for VLAN filtering Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 04/12] net: systemport: Fix reception of BPDUs Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 05/12] net: dsa: b53: Define registers for IGMP snooping Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 06/12] net: dsa: b53: Add support for MDB Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 07/12] net: dsa: Add ability to program multicast filter for CPU port Florian Fainelli
2019-01-30 22:28 ` Vivien Didelot
2019-01-30 22:55 ` Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 08/12] net: dsa: Add ndo_vlan_rx_{add,kill}_vid implementation Florian Fainelli
2019-01-30 22:38 ` Vivien Didelot
2019-01-30 0:55 ` Florian Fainelli [this message]
2019-01-30 0:55 ` [PATCH net-next v2 10/12] net: dsa: Wire up multicast IGMP snooping attribute notification Florian Fainelli
2019-01-30 16:06 ` Andrew Lunn
2019-01-30 22:32 ` Florian Fainelli
2019-01-30 22:46 ` Andrew Lunn
2019-01-30 23:02 ` Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 11/12] net: dsa: b53: Add support for toggling IGMP snooping Florian Fainelli
2019-01-30 0:55 ` [PATCH net-next v2 12/12] net: dsa: bcm_sf2: Enable management mode Florian Fainelli
2019-01-30 7:38 ` [PATCH net-next v2 00/12] net: dsa: management mode for bcm_sf2 Ido Schimmel
2019-01-30 22:23 ` David Miller
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=20190130005548.2212-10-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=ilias.apalodimas@linaro.org \
--cc=ivan.khoronzhuk@linaro.org \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
--cc=vivien.didelot@gmail.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).