aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Feldman <sfeldma@gmail.com>2014-11-28 08:34:20 -0500
committerDavid S. Miller <davem@davemloft.net>2014-12-02 23:01:22 -0500
commit38dcf357aed299186ecb090cc2f5290cc17d637d (patch)
treea5fa0ef8464099c4aad79bd67d1e23759ad8e6c4
parentaecbe01e7410ad2de022796472f531ae6941f15e (diff)
bridge: call netdev_sw_port_stp_update when bridge port STP status changes
To notify switch driver of change in STP state of bridge port, add new .ndo op and provide switchdev wrapper func to call ndo op. Use it in bridge code then. Signed-off-by: Scott Feldman <sfeldma@gmail.com> Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Andy Gospodarek <gospo@cumulusnetworks.com> Acked-by: Thomas Graf <tgraf@suug.ch> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h5
-rw-r--r--include/net/switchdev.h7
-rw-r--r--net/bridge/br_stp.c7
-rw-r--r--net/switchdev/switchdev.c19
4 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3603f31e78f3..29c92ee9ed56 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1024,6 +1024,9 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
1024 * Called to get an ID of the switch chip this port is part of. 1024 * Called to get an ID of the switch chip this port is part of.
1025 * If driver implements this, it indicates that it represents a port 1025 * If driver implements this, it indicates that it represents a port
1026 * of a switch chip. 1026 * of a switch chip.
1027 * int (*ndo_switch_port_stp_update)(struct net_device *dev, u8 state);
1028 * Called to notify switch device port of bridge port STP
1029 * state change.
1027 */ 1030 */
1028struct net_device_ops { 1031struct net_device_ops {
1029 int (*ndo_init)(struct net_device *dev); 1032 int (*ndo_init)(struct net_device *dev);
@@ -1180,6 +1183,8 @@ struct net_device_ops {
1180#ifdef CONFIG_NET_SWITCHDEV 1183#ifdef CONFIG_NET_SWITCHDEV
1181 int (*ndo_switch_parent_id_get)(struct net_device *dev, 1184 int (*ndo_switch_parent_id_get)(struct net_device *dev,
1182 struct netdev_phys_item_id *psid); 1185 struct netdev_phys_item_id *psid);
1186 int (*ndo_switch_port_stp_update)(struct net_device *dev,
1187 u8 state);
1183#endif 1188#endif
1184}; 1189};
1185 1190
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 7a52360a1446..8a6d1641fd9b 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -16,6 +16,7 @@
16 16
17int netdev_switch_parent_id_get(struct net_device *dev, 17int netdev_switch_parent_id_get(struct net_device *dev,
18 struct netdev_phys_item_id *psid); 18 struct netdev_phys_item_id *psid);
19int netdev_switch_port_stp_update(struct net_device *dev, u8 state);
19 20
20#else 21#else
21 22
@@ -25,6 +26,12 @@ static inline int netdev_switch_parent_id_get(struct net_device *dev,
25 return -EOPNOTSUPP; 26 return -EOPNOTSUPP;
26} 27}
27 28
29static inline int netdev_switch_port_stp_update(struct net_device *dev,
30 u8 state)
31{
32 return -EOPNOTSUPP;
33}
34
28#endif 35#endif
29 36
30#endif /* _LINUX_SWITCHDEV_H_ */ 37#endif /* _LINUX_SWITCHDEV_H_ */
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
index 2b047bcf42a4..fb3ebe615513 100644
--- a/net/bridge/br_stp.c
+++ b/net/bridge/br_stp.c
@@ -12,6 +12,7 @@
12 */ 12 */
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/rculist.h> 14#include <linux/rculist.h>
15#include <net/switchdev.h>
15 16
16#include "br_private.h" 17#include "br_private.h"
17#include "br_private_stp.h" 18#include "br_private_stp.h"
@@ -38,7 +39,13 @@ void br_log_state(const struct net_bridge_port *p)
38 39
39void br_set_state(struct net_bridge_port *p, unsigned int state) 40void br_set_state(struct net_bridge_port *p, unsigned int state)
40{ 41{
42 int err;
43
41 p->state = state; 44 p->state = state;
45 err = netdev_switch_port_stp_update(p->dev, state);
46 if (err && err != -EOPNOTSUPP)
47 br_warn(p->br, "error setting offload STP state on port %u(%s)\n",
48 (unsigned int) p->port_no, p->dev->name);
42} 49}
43 50
44/* called under bridge lock */ 51/* called under bridge lock */
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 66973deaae56..d162b21b14bd 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -31,3 +31,22 @@ int netdev_switch_parent_id_get(struct net_device *dev,
31 return ops->ndo_switch_parent_id_get(dev, psid); 31 return ops->ndo_switch_parent_id_get(dev, psid);
32} 32}
33EXPORT_SYMBOL(netdev_switch_parent_id_get); 33EXPORT_SYMBOL(netdev_switch_parent_id_get);
34
35/**
36 * netdev_switch_port_stp_update - Notify switch device port of STP
37 * state change
38 * @dev: port device
39 * @state: port STP state
40 *
41 * Notify switch device port of bridge port STP state change.
42 */
43int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
44{
45 const struct net_device_ops *ops = dev->netdev_ops;
46
47 if (!ops->ndo_switch_port_stp_update)
48 return -EOPNOTSUPP;
49 WARN_ON(!ops->ndo_switch_parent_id_get);
50 return ops->ndo_switch_port_stp_update(dev, state);
51}
52EXPORT_SYMBOL(netdev_switch_port_stp_update);