mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
net: dsa: Add support for DSA specific notifiers
In preparation for communicating a given DSA network device's port number and switch index, create a specialized DSA notifier and two events: DSA_PORT_REGISTER and DSA_PORT_UNREGISTER that communicate: the slave network device (slave_dev), port number and switch number in the tree. This will be later used for network device drivers like bcmsysport which needs to cooperate with its DSA network devices to set-up queue mapping and scheduling. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3f7832c26c
commit
60724d4bae
3 changed files with 81 additions and 0 deletions
|
@ -1116,6 +1116,7 @@ int dsa_slave_resume(struct net_device *slave_dev)
|
|||
|
||||
int dsa_slave_create(struct dsa_port *port, const char *name)
|
||||
{
|
||||
struct dsa_notifier_register_info rinfo = { };
|
||||
struct dsa_switch *ds = port->ds;
|
||||
struct net_device *master;
|
||||
struct net_device *slave_dev;
|
||||
|
@ -1177,6 +1178,12 @@ int dsa_slave_create(struct dsa_port *port, const char *name)
|
|||
goto out_free;
|
||||
}
|
||||
|
||||
rinfo.info.dev = slave_dev;
|
||||
rinfo.master = master;
|
||||
rinfo.port_number = p->dp->index;
|
||||
rinfo.switch_number = p->dp->ds->index;
|
||||
call_dsa_notifiers(DSA_PORT_REGISTER, slave_dev, &rinfo.info);
|
||||
|
||||
ret = register_netdev(slave_dev);
|
||||
if (ret) {
|
||||
netdev_err(master, "error %d registering interface %s\n",
|
||||
|
@ -1200,6 +1207,7 @@ out_free:
|
|||
void dsa_slave_destroy(struct net_device *slave_dev)
|
||||
{
|
||||
struct dsa_slave_priv *p = netdev_priv(slave_dev);
|
||||
struct dsa_notifier_register_info rinfo = { };
|
||||
struct device_node *port_dn;
|
||||
|
||||
port_dn = p->dp->dn;
|
||||
|
@ -1211,6 +1219,11 @@ void dsa_slave_destroy(struct net_device *slave_dev)
|
|||
if (of_phy_is_fixed_link(port_dn))
|
||||
of_phy_deregister_fixed_link(port_dn);
|
||||
}
|
||||
rinfo.info.dev = slave_dev;
|
||||
rinfo.master = p->dp->cpu_dp->netdev;
|
||||
rinfo.port_number = p->dp->index;
|
||||
rinfo.switch_number = p->dp->ds->index;
|
||||
call_dsa_notifiers(DSA_PORT_UNREGISTER, slave_dev, &rinfo.info);
|
||||
unregister_netdev(slave_dev);
|
||||
free_percpu(p->stats64);
|
||||
free_netdev(slave_dev);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue