summaryrefslogtreecommitdiff
path: root/net/dsa/slave.c
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-10-11 10:57:48 -0700
committerDavid S. Miller <davem@davemloft.net>2017-10-12 12:10:01 -0700
commit60724d4bae14cd295b27b1610cad9a2720eb0860 (patch)
treec686c50e92a9d1ffd68c3892732a723a6f127c03 /net/dsa/slave.c
parent3f7832c26cc0cad2245981f777f3ee684399ce93 (diff)
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>
Diffstat (limited to 'net/dsa/slave.c')
-rw-r--r--net/dsa/slave.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index fb2954ff198c..45f4ea845c07 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -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);