diff mbox series

[v4,net-next,04/15] net: bridge: mst: Notify switchdev drivers of MST mode changes

Message ID 20220315002543.190587-5-tobias@waldekranz.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: bridge: Multiple Spanning Trees | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 115 this patch: 63
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang fail Errors and warnings before: 24 this patch: 14
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 134 this patch: 77
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Tobias Waldekranz March 15, 2022, 12:25 a.m. UTC
Trigger a switchdev event whenever the bridge's MST mode is
enabled/disabled. This allows constituent ports to either perform any
required hardware config, or refuse the change if it not supported.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
 include/net/switchdev.h |  2 ++
 net/bridge/br_mst.c     | 10 ++++++++++
 2 files changed, 12 insertions(+)

Comments

Jakub Kicinski March 15, 2022, 5:32 a.m. UTC | #1
On Tue, 15 Mar 2022 01:25:32 +0100 Tobias Waldekranz wrote:
> Trigger a switchdev event whenever the bridge's MST mode is
> enabled/disabled. This allows constituent ports to either perform any
> required hardware config, or refuse the change if it not supported.
> 
> Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>

../net/bridge/br_mst.c: In function ‘br_mst_set_enabled’:
../net/bridge/br_mst.c:102:16: error: variable ‘attr’ has initializer but incomplete type
  102 |         struct switchdev_attr attr = {
      |                ^~~~~~~~~~~~~~
../net/bridge/br_mst.c:103:18: error: ‘struct switchdev_attr’ has no member named ‘id’
  103 |                 .id = SWITCHDEV_ATTR_ID_BRIDGE_MST,
      |                  ^~
../net/bridge/br_mst.c:103:23: error: ‘SWITCHDEV_ATTR_ID_BRIDGE_MST’ undeclared (first use in this function)
  103 |                 .id = SWITCHDEV_ATTR_ID_BRIDGE_MST,
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../net/bridge/br_mst.c:103:23: note: each undeclared identifier is reported only once for each function it appears in
../net/bridge/br_mst.c:103:23: warning: excess elements in struct initializer
../net/bridge/br_mst.c:103:23: note: (near initialization for ‘attr’)
../net/bridge/br_mst.c:104:18: error: ‘struct switchdev_attr’ has no member named ‘orig_dev’
  104 |                 .orig_dev = br->dev,
      |                  ^~~~~~~~
../net/bridge/br_mst.c:104:29: warning: excess elements in struct initializer
  104 |                 .orig_dev = br->dev,
      |                             ^~
../net/bridge/br_mst.c:104:29: note: (near initialization for ‘attr’)
../net/bridge/br_mst.c:105:18: error: ‘struct switchdev_attr’ has no member named ‘u’
  105 |                 .u.mst = on,
      |                  ^
../net/bridge/br_mst.c:105:26: warning: excess elements in struct initializer
  105 |                 .u.mst = on,
      |                          ^~
../net/bridge/br_mst.c:105:26: note: (near initialization for ‘attr’)
../net/bridge/br_mst.c:102:31: error: storage size of ‘attr’ isn’t known
  102 |         struct switchdev_attr attr = {
      |                               ^~~~
../net/bridge/br_mst.c:125:15: error: implicit declaration of function ‘switchdev_port_attr_set’; did you mean ‘br_switchdev_port_vlan_del’? [-Werror=implicit-function-declaration]
  125 |         err = switchdev_port_attr_set(br->dev, &attr, extack);
      |               ^~~~~~~~~~~~~~~~~~~~~~~
      |               br_switchdev_port_vlan_del
../net/bridge/br_mst.c:102:31: warning: unused variable ‘attr’ [-Wunused-variable]
  102 |         struct switchdev_attr attr = {
      |                               ^~~~
Tobias Waldekranz March 15, 2022, 10:28 p.m. UTC | #2
On Mon, Mar 14, 2022 at 22:32, Jakub Kicinski <kuba@kernel.org> wrote:
> On Tue, 15 Mar 2022 01:25:32 +0100 Tobias Waldekranz wrote:
>> Trigger a switchdev event whenever the bridge's MST mode is
>> enabled/disabled. This allows constituent ports to either perform any
>> required hardware config, or refuse the change if it not supported.
>> 
>> Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
>
> ../net/bridge/br_mst.c: In function ‘br_mst_set_enabled’:
> ../net/bridge/br_mst.c:102:16: error: variable ‘attr’ has initializer but incomplete type
>   102 |         struct switchdev_attr attr = {
>       |                ^~~~~~~~~~~~~~
> ../net/bridge/br_mst.c:103:18: error: ‘struct switchdev_attr’ has no member named ‘id’
>   103 |                 .id = SWITCHDEV_ATTR_ID_BRIDGE_MST,
>       |                  ^~
> ../net/bridge/br_mst.c:103:23: error: ‘SWITCHDEV_ATTR_ID_BRIDGE_MST’ undeclared (first use in this function)
>   103 |                 .id = SWITCHDEV_ATTR_ID_BRIDGE_MST,
>       |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../net/bridge/br_mst.c:103:23: note: each undeclared identifier is reported only once for each function it appears in
> ../net/bridge/br_mst.c:103:23: warning: excess elements in struct initializer
> ../net/bridge/br_mst.c:103:23: note: (near initialization for ‘attr’)
> ../net/bridge/br_mst.c:104:18: error: ‘struct switchdev_attr’ has no member named ‘orig_dev’
>   104 |                 .orig_dev = br->dev,
>       |                  ^~~~~~~~
> ../net/bridge/br_mst.c:104:29: warning: excess elements in struct initializer
>   104 |                 .orig_dev = br->dev,
>       |                             ^~
> ../net/bridge/br_mst.c:104:29: note: (near initialization for ‘attr’)
> ../net/bridge/br_mst.c:105:18: error: ‘struct switchdev_attr’ has no member named ‘u’
>   105 |                 .u.mst = on,
>       |                  ^
> ../net/bridge/br_mst.c:105:26: warning: excess elements in struct initializer
>   105 |                 .u.mst = on,
>       |                          ^~
> ../net/bridge/br_mst.c:105:26: note: (near initialization for ‘attr’)
> ../net/bridge/br_mst.c:102:31: error: storage size of ‘attr’ isn’t known
>   102 |         struct switchdev_attr attr = {
>       |                               ^~~~
> ../net/bridge/br_mst.c:125:15: error: implicit declaration of function ‘switchdev_port_attr_set’; did you mean ‘br_switchdev_port_vlan_del’? [-Werror=implicit-function-declaration]
>   125 |         err = switchdev_port_attr_set(br->dev, &attr, extack);
>       |               ^~~~~~~~~~~~~~~~~~~~~~~
>       |               br_switchdev_port_vlan_del
> ../net/bridge/br_mst.c:102:31: warning: unused variable ‘attr’ [-Wunused-variable]
>   102 |         struct switchdev_attr attr = {
>       |                               ^~~~

Sorry about that. Forgot to run the incremental build after the
rebase. Will be fixed in v5.
diff mbox series

Patch

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 3e424d40fae3..85dd004dc9ad 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -27,6 +27,7 @@  enum switchdev_attr_id {
 	SWITCHDEV_ATTR_ID_BRIDGE_VLAN_PROTOCOL,
 	SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED,
 	SWITCHDEV_ATTR_ID_BRIDGE_MROUTER,
+	SWITCHDEV_ATTR_ID_BRIDGE_MST,
 	SWITCHDEV_ATTR_ID_MRP_PORT_ROLE,
 };
 
@@ -48,6 +49,7 @@  struct switchdev_attr {
 		clock_t ageing_time;			/* BRIDGE_AGEING_TIME */
 		bool vlan_filtering;			/* BRIDGE_VLAN_FILTERING */
 		u16 vlan_protocol;			/* BRIDGE_VLAN_PROTOCOL */
+		bool mst;				/* BRIDGE_MST */
 		bool mc_disabled;			/* MC_DISABLED */
 		u8 mrp_port_role;			/* MRP_PORT_ROLE */
 	} u;
diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c
index 355ad102d6b1..051b9358946b 100644
--- a/net/bridge/br_mst.c
+++ b/net/bridge/br_mst.c
@@ -99,8 +99,14 @@  void br_mst_vlan_init_state(struct net_bridge_vlan *v)
 int br_mst_set_enabled(struct net_bridge *br, bool on,
 		       struct netlink_ext_ack *extack)
 {
+	struct switchdev_attr attr = {
+		.id = SWITCHDEV_ATTR_ID_BRIDGE_MST,
+		.orig_dev = br->dev,
+		.u.mst = on,
+	};
 	struct net_bridge_vlan_group *vg;
 	struct net_bridge_port *p;
+	int err;
 
 	list_for_each_entry(p, &br->port_list, list) {
 		vg = nbp_vlan_group(p);
@@ -116,6 +122,10 @@  int br_mst_set_enabled(struct net_bridge *br, bool on,
 	if (br_opt_get(br, BROPT_MST_ENABLED) == on)
 		return 0;
 
+	err = switchdev_port_attr_set(br->dev, &attr, extack);
+	if (err && err != -EOPNOTSUPP)
+		return err;
+
 	if (on)
 		static_branch_enable(&br_mst_used);
 	else