mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
net: dsa: Add new binding implementation
The existing DSA binding has a number of limitations and problems. The main problem is that it cannot represent a switch as a linux device, hanging off some bus. It is limited to one CPU port. The DSA platform device is artificial, and does not really represent hardware. Implement a new binding which can be embedded into any type of node on a bus to represent one switch device, and its links to other switches. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
b516d45323
commit
83c0afaec7
@@ -3748,6 +3748,12 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev)
|
||||
|
||||
dev_set_drvdata(dev, ds);
|
||||
|
||||
err = dsa_register_switch(ds, mdiodev->dev.of_node);
|
||||
if (err) {
|
||||
mv88e6xxx_mdio_unregister(ps);
|
||||
return err;
|
||||
}
|
||||
|
||||
dev_info(dev, "switch 0x%x probed: %s, revision %u\n",
|
||||
prod_num, ps->info->name, rev);
|
||||
|
||||
@@ -3759,6 +3765,7 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev)
|
||||
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
||||
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
|
||||
|
||||
dsa_unregister_switch(ds);
|
||||
put_device(&ps->bus->dev);
|
||||
|
||||
mv88e6xxx_mdio_unregister(ps);
|
||||
|
||||
@@ -85,6 +85,17 @@ struct dsa_platform_data {
|
||||
struct packet_type;
|
||||
|
||||
struct dsa_switch_tree {
|
||||
struct list_head list;
|
||||
|
||||
/* Tree identifier */
|
||||
u32 tree;
|
||||
|
||||
/* Number of switches attached to this tree */
|
||||
struct kref refcount;
|
||||
|
||||
/* Has this tree been applied to the hardware? */
|
||||
bool applied;
|
||||
|
||||
/*
|
||||
* Configuration data for the platform device that owns
|
||||
* this dsa switch tree instance.
|
||||
@@ -169,10 +180,16 @@ struct dsa_switch {
|
||||
struct device *hwmon_dev;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The lower device this switch uses to talk to the host
|
||||
*/
|
||||
struct net_device *master_netdev;
|
||||
|
||||
/*
|
||||
* Slave mii_bus and devices for the individual ports.
|
||||
*/
|
||||
u32 dsa_port_mask;
|
||||
u32 cpu_port_mask;
|
||||
u32 enabled_port_mask;
|
||||
u32 phys_mii_mask;
|
||||
struct dsa_port ports[DSA_MAX_PORTS];
|
||||
@@ -361,4 +378,7 @@ static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
|
||||
{
|
||||
return dst->rcv != NULL;
|
||||
}
|
||||
|
||||
void dsa_unregister_switch(struct dsa_switch *ds);
|
||||
int dsa_register_switch(struct dsa_switch *ds, struct device_node *np);
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# the core
|
||||
obj-$(CONFIG_NET_DSA) += dsa_core.o
|
||||
dsa_core-y += dsa.o slave.o
|
||||
dsa_core-y += dsa.o slave.o dsa2.o
|
||||
|
||||
# tagging formats
|
||||
dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
|
||||
|
||||
@@ -294,6 +294,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
|
||||
}
|
||||
dst->cpu_switch = index;
|
||||
dst->cpu_port = i;
|
||||
ds->cpu_port_mask |= 1 << i;
|
||||
} else if (!strcmp(name, "dsa")) {
|
||||
ds->dsa_port_mask |= 1 << i;
|
||||
} else {
|
||||
@@ -492,6 +493,10 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
|
||||
if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
|
||||
continue;
|
||||
dsa_cpu_dsa_destroy(ds->ports[port].dn);
|
||||
|
||||
/* Clearing a bit which is not set does no harm */
|
||||
ds->cpu_port_mask |= ~(1 << port);
|
||||
ds->dsa_port_mask |= ~(1 << port);
|
||||
}
|
||||
|
||||
if (ds->slave_mii_bus && ds->drv->phy_read)
|
||||
|
||||
654
net/dsa/dsa2.c
Normal file
654
net/dsa/dsa2.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -59,7 +59,7 @@ const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
|
||||
extern const struct dsa_device_ops notag_netdev_ops;
|
||||
void dsa_slave_mii_bus_init(struct dsa_switch *ds);
|
||||
int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
|
||||
int port, char *name);
|
||||
int port, const char *name);
|
||||
void dsa_slave_destroy(struct net_device *slave_dev);
|
||||
int dsa_slave_suspend(struct net_device *slave_dev);
|
||||
int dsa_slave_resume(struct net_device *slave_dev);
|
||||
|
||||
@@ -1099,14 +1099,18 @@ int dsa_slave_resume(struct net_device *slave_dev)
|
||||
}
|
||||
|
||||
int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
|
||||
int port, char *name)
|
||||
int port, const char *name)
|
||||
{
|
||||
struct net_device *master = ds->dst->master_netdev;
|
||||
struct dsa_switch_tree *dst = ds->dst;
|
||||
struct net_device *master;
|
||||
struct net_device *slave_dev;
|
||||
struct dsa_slave_priv *p;
|
||||
int ret;
|
||||
|
||||
master = ds->dst->master_netdev;
|
||||
if (ds->master_netdev)
|
||||
master = ds->master_netdev;
|
||||
|
||||
slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
|
||||
NET_NAME_UNKNOWN, ether_setup);
|
||||
if (slave_dev == NULL)
|
||||
|
||||
Reference in New Issue
Block a user