diff options
Diffstat (limited to 'net/dsa/legacy.c')
| -rw-r--r-- | net/dsa/legacy.c | 80 | 
1 files changed, 50 insertions, 30 deletions
| diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c index 7281098df04e..91e6f7981d39 100644 --- a/net/dsa/legacy.c +++ b/net/dsa/legacy.c @@ -22,7 +22,7 @@  #include <linux/sysfs.h>  #include <linux/phy_fixed.h>  #include <linux/etherdevice.h> -#include <net/dsa.h> +  #include "dsa_priv.h"  /* switch driver registration ***********************************************/ @@ -78,24 +78,23 @@ dsa_switch_probe(struct device *parent, struct device *host_dev, int sw_addr,  }  /* basic switch operations **************************************************/ -static int dsa_cpu_dsa_setups(struct dsa_switch *ds, struct device *dev) +static int dsa_cpu_dsa_setups(struct dsa_switch *ds)  { -	struct dsa_port *dport;  	int ret, port;  	for (port = 0; port < ds->num_ports; port++) {  		if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))  			continue; -		dport = &ds->ports[port]; -		ret = dsa_cpu_dsa_setup(ds, dev, dport, port); +		ret = dsa_cpu_dsa_setup(&ds->ports[port]);  		if (ret)  			return ret;  	}  	return 0;  } -static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) +static int dsa_switch_setup_one(struct dsa_switch *ds, +				struct net_device *master)  {  	const struct dsa_switch_ops *ops = ds->ops;  	struct dsa_switch_tree *dst = ds->dst; @@ -115,13 +114,13 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)  			continue;  		if (!strcmp(name, "cpu")) { -			if (dst->cpu_switch) { -				netdev_err(dst->master_netdev, +			if (dst->cpu_dp) { +				netdev_err(master,  					   "multiple cpu ports?!\n");  				return -EINVAL;  			} -			dst->cpu_switch = ds; -			dst->cpu_port = i; +			dst->cpu_dp = &ds->ports[i]; +			dst->cpu_dp->netdev = master;  			ds->cpu_port_mask |= 1 << i;  		} else if (!strcmp(name, "dsa")) {  			ds->dsa_port_mask |= 1 << i; @@ -144,7 +143,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)  	 * tagging protocol to the preferred tagging format of this  	 * switch.  	 */ -	if (dst->cpu_switch == ds) { +	if (dst->cpu_dp->ds == ds) {  		enum dsa_tag_protocol tag_protocol;  		tag_protocol = ops->get_tag_protocol(ds); @@ -169,13 +168,13 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)  		return ret;  	if (ops->set_addr) { -		ret = ops->set_addr(ds, dst->master_netdev->dev_addr); +		ret = ops->set_addr(ds, master->dev_addr);  		if (ret < 0)  			return ret;  	}  	if (!ds->slave_mii_bus && ops->phy_read) { -		ds->slave_mii_bus = devm_mdiobus_alloc(parent); +		ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);  		if (!ds->slave_mii_bus)  			return -ENOMEM;  		dsa_slave_mii_bus_init(ds); @@ -190,23 +189,24 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)  	 */  	for (i = 0; i < ds->num_ports; i++) {  		ds->ports[i].dn = cd->port_dn[i]; +		ds->ports[i].cpu_dp = dst->cpu_dp;  		if (!(ds->enabled_port_mask & (1 << i)))  			continue; -		ret = dsa_slave_create(ds, parent, i, cd->port_names[i]); +		ret = dsa_slave_create(&ds->ports[i], cd->port_names[i]);  		if (ret < 0) -			netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s): %d\n", +			netdev_err(master, "[%d]: can't create dsa slave device for port %d(%s): %d\n",  				   index, i, cd->port_names[i], ret);  	}  	/* Perform configuration of the CPU and DSA ports */ -	ret = dsa_cpu_dsa_setups(ds, parent); +	ret = dsa_cpu_dsa_setups(ds);  	if (ret < 0) -		netdev_err(dst->master_netdev, "[%d] : can't configure CPU and DSA ports\n", +		netdev_err(master, "[%d] : can't configure CPU and DSA ports\n",  			   index); -	ret = dsa_cpu_port_ethtool_setup(ds); +	ret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp);  	if (ret)  		return ret; @@ -214,8 +214,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)  }  static struct dsa_switch * -dsa_switch_setup(struct dsa_switch_tree *dst, int index, -		 struct device *parent, struct device *host_dev) +dsa_switch_setup(struct dsa_switch_tree *dst, struct net_device *master, +		 int index, struct device *parent, struct device *host_dev)  {  	struct dsa_chip_data *cd = dst->pd->chip + index;  	const struct dsa_switch_ops *ops; @@ -229,11 +229,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,  	 */  	ops = dsa_switch_probe(parent, host_dev, cd->sw_addr, &name, &priv);  	if (!ops) { -		netdev_err(dst->master_netdev, "[%d]: could not detect attached switch\n", +		netdev_err(master, "[%d]: could not detect attached switch\n",  			   index);  		return ERR_PTR(-EINVAL);  	} -	netdev_info(dst->master_netdev, "[%d]: detected a %s switch\n", +	netdev_info(master, "[%d]: detected a %s switch\n",  		    index, name); @@ -250,7 +250,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,  	ds->ops = ops;  	ds->priv = priv; -	ret = dsa_switch_setup_one(ds, parent); +	ret = dsa_switch_setup_one(ds, master);  	if (ret)  		return ERR_PTR(ret); @@ -576,13 +576,11 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,  	unsigned configured = 0;  	dst->pd = pd; -	dst->master_netdev = dev; -	dst->cpu_port = -1;  	for (i = 0; i < pd->nr_chips; i++) {  		struct dsa_switch *ds; -		ds = dsa_switch_setup(dst, i, parent, pd->chip[i].host_dev); +		ds = dsa_switch_setup(dst, dev, i, parent, pd->chip[i].host_dev);  		if (IS_ERR(ds)) {  			netdev_err(dev, "[%d]: couldn't create dsa switch instance (error %ld)\n",  				   i, PTR_ERR(ds)); @@ -606,7 +604,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,  	 * sent to the tag format's receive function.  	 */  	wmb(); -	dev->dsa_ptr = (void *)dst; +	dev->dsa_ptr = dst;  	return 0;  } @@ -673,7 +671,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)  {  	int i; -	dst->master_netdev->dsa_ptr = NULL; +	dst->cpu_dp->netdev->dsa_ptr = NULL;  	/* If we used a tagging format that doesn't have an ethertype  	 * field, make sure that all packets from this point get sent @@ -688,9 +686,9 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)  			dsa_switch_destroy(ds);  	} -	dsa_cpu_port_ethtool_restore(dst->cpu_switch); +	dsa_cpu_port_ethtool_restore(dst->cpu_dp); -	dev_put(dst->master_netdev); +	dev_put(dst->cpu_dp->netdev);  }  static int dsa_remove(struct platform_device *pdev) @@ -741,6 +739,28 @@ static int dsa_resume(struct device *d)  }  #endif +/* legacy way, bypassing the bridge *****************************************/ +int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], +		       struct net_device *dev, +		       const unsigned char *addr, u16 vid, +		       u16 flags) +{ +	struct dsa_slave_priv *p = netdev_priv(dev); +	struct dsa_port *dp = p->dp; + +	return dsa_port_fdb_add(dp, addr, vid); +} + +int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], +		       struct net_device *dev, +		       const unsigned char *addr, u16 vid) +{ +	struct dsa_slave_priv *p = netdev_priv(dev); +	struct dsa_port *dp = p->dp; + +	return dsa_port_fdb_del(dp, addr, vid); +} +  static SIMPLE_DEV_PM_OPS(dsa_pm_ops, dsa_suspend, dsa_resume);  static const struct of_device_id dsa_of_match_table[] = { |