return err;
}
-static int dsa_slave_bridge_port_join(struct net_device *dev,
- struct net_device *br)
+static int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br)
{
- struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_notifier_bridge_info info = {
- .sw_index = p->dp->ds->index,
- .port = p->dp->index,
+ .sw_index = dp->ds->index,
+ .port = dp->index,
.br = br,
};
int err;
/* Here the port is already bridged. Reflect the current configuration
* so that drivers can program their chips accordingly.
*/
- p->dp->bridge_dev = br;
+ dp->bridge_dev = br;
- err = dsa_port_notify(p->dp, DSA_NOTIFIER_BRIDGE_JOIN, &info);
+ err = dsa_port_notify(dp, DSA_NOTIFIER_BRIDGE_JOIN, &info);
/* The bridging is rolled back on error */
if (err)
- p->dp->bridge_dev = NULL;
+ dp->bridge_dev = NULL;
return err;
}
-static void dsa_slave_bridge_port_leave(struct net_device *dev,
- struct net_device *br)
+static void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
{
- struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_notifier_bridge_info info = {
- .sw_index = p->dp->ds->index,
- .port = p->dp->index,
+ .sw_index = dp->ds->index,
+ .port = dp->index,
.br = br,
};
int err;
/* Here the port is already unbridged. Reflect the current configuration
* so that drivers can program their chips accordingly.
*/
- p->dp->bridge_dev = NULL;
+ dp->bridge_dev = NULL;
- err = dsa_port_notify(p->dp, DSA_NOTIFIER_BRIDGE_LEAVE, &info);
+ err = dsa_port_notify(dp, DSA_NOTIFIER_BRIDGE_LEAVE, &info);
if (err)
- netdev_err(dev, "failed to notify DSA_NOTIFIER_BRIDGE_LEAVE\n");
+ pr_err("DSA: failed to notify DSA_NOTIFIER_BRIDGE_LEAVE\n");
/* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer,
* so allow it to be in BR_STATE_FORWARDING to be kept functional
*/
- dsa_port_set_state_now(p->dp, BR_STATE_FORWARDING);
+ dsa_port_set_state_now(dp, BR_STATE_FORWARDING);
}
static int dsa_slave_port_attr_get(struct net_device *dev,
static int dsa_slave_changeupper(struct net_device *dev,
struct netdev_notifier_changeupper_info *info)
{
+ struct dsa_slave_priv *p = netdev_priv(dev);
+ struct dsa_port *dp = p->dp;
int err = NOTIFY_DONE;
if (netif_is_bridge_master(info->upper_dev)) {
if (info->linking) {
- err = dsa_slave_bridge_port_join(dev, info->upper_dev);
+ err = dsa_port_bridge_join(dp, info->upper_dev);
err = notifier_from_errno(err);
} else {
- dsa_slave_bridge_port_leave(dev, info->upper_dev);
+ dsa_port_bridge_leave(dp, info->upper_dev);
err = NOTIFY_OK;
}
}