提交 38dcf357 编写于 作者: S Scott Feldman 提交者: David S. Miller

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: NScott Feldman <sfeldma@gmail.com>
Signed-off-by: NJiri Pirko <jiri@resnulli.us>
Signed-off-by: NAndy Gospodarek <gospo@cumulusnetworks.com>
Acked-by: NThomas Graf <tgraf@suug.ch>
Acked-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 aecbe01e
...@@ -1024,6 +1024,9 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, ...@@ -1024,6 +1024,9 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
* Called to get an ID of the switch chip this port is part of. * Called to get an ID of the switch chip this port is part of.
* If driver implements this, it indicates that it represents a port * If driver implements this, it indicates that it represents a port
* of a switch chip. * of a switch chip.
* int (*ndo_switch_port_stp_update)(struct net_device *dev, u8 state);
* Called to notify switch device port of bridge port STP
* state change.
*/ */
struct net_device_ops { struct net_device_ops {
int (*ndo_init)(struct net_device *dev); int (*ndo_init)(struct net_device *dev);
...@@ -1180,6 +1183,8 @@ struct net_device_ops { ...@@ -1180,6 +1183,8 @@ struct net_device_ops {
#ifdef CONFIG_NET_SWITCHDEV #ifdef CONFIG_NET_SWITCHDEV
int (*ndo_switch_parent_id_get)(struct net_device *dev, int (*ndo_switch_parent_id_get)(struct net_device *dev,
struct netdev_phys_item_id *psid); struct netdev_phys_item_id *psid);
int (*ndo_switch_port_stp_update)(struct net_device *dev,
u8 state);
#endif #endif
}; };
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
int netdev_switch_parent_id_get(struct net_device *dev, int netdev_switch_parent_id_get(struct net_device *dev,
struct netdev_phys_item_id *psid); struct netdev_phys_item_id *psid);
int netdev_switch_port_stp_update(struct net_device *dev, u8 state);
#else #else
...@@ -25,6 +26,12 @@ static inline int netdev_switch_parent_id_get(struct net_device *dev, ...@@ -25,6 +26,12 @@ static inline int netdev_switch_parent_id_get(struct net_device *dev,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int netdev_switch_port_stp_update(struct net_device *dev,
u8 state)
{
return -EOPNOTSUPP;
}
#endif #endif
#endif /* _LINUX_SWITCHDEV_H_ */ #endif /* _LINUX_SWITCHDEV_H_ */
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/rculist.h> #include <linux/rculist.h>
#include <net/switchdev.h>
#include "br_private.h" #include "br_private.h"
#include "br_private_stp.h" #include "br_private_stp.h"
...@@ -38,7 +39,13 @@ void br_log_state(const struct net_bridge_port *p) ...@@ -38,7 +39,13 @@ void br_log_state(const struct net_bridge_port *p)
void br_set_state(struct net_bridge_port *p, unsigned int state) void br_set_state(struct net_bridge_port *p, unsigned int state)
{ {
int err;
p->state = state; p->state = state;
err = netdev_switch_port_stp_update(p->dev, state);
if (err && err != -EOPNOTSUPP)
br_warn(p->br, "error setting offload STP state on port %u(%s)\n",
(unsigned int) p->port_no, p->dev->name);
} }
/* called under bridge lock */ /* called under bridge lock */
......
...@@ -31,3 +31,22 @@ int netdev_switch_parent_id_get(struct net_device *dev, ...@@ -31,3 +31,22 @@ int netdev_switch_parent_id_get(struct net_device *dev,
return ops->ndo_switch_parent_id_get(dev, psid); return ops->ndo_switch_parent_id_get(dev, psid);
} }
EXPORT_SYMBOL(netdev_switch_parent_id_get); EXPORT_SYMBOL(netdev_switch_parent_id_get);
/**
* netdev_switch_port_stp_update - Notify switch device port of STP
* state change
* @dev: port device
* @state: port STP state
*
* Notify switch device port of bridge port STP state change.
*/
int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
{
const struct net_device_ops *ops = dev->netdev_ops;
if (!ops->ndo_switch_port_stp_update)
return -EOPNOTSUPP;
WARN_ON(!ops->ndo_switch_parent_id_get);
return ops->ndo_switch_port_stp_update(dev, state);
}
EXPORT_SYMBOL(netdev_switch_port_stp_update);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册