diff options
author | Jiri Pirko <jiri@mellanox.com> | 2019-04-25 15:59:53 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-26 07:52:02 +0200 |
commit | 8320d145912738655cf631d27aa1829d8b17804e (patch) | |
tree | 6e7f4ea830549254a04ee3028d6b97f4d60f30dc /drivers/net/netdevsim/bus.c | |
parent | netdevsim: change debugfs tree topology (diff) | |
download | linux-8320d145912738655cf631d27aa1829d8b17804e.tar.xz linux-8320d145912738655cf631d27aa1829d8b17804e.zip |
netdevsim: implement dev probe/remove skeleton with port initialization
Implement netdevsim bus probing of netdevsim devices. For every probed
device create a devlink instance. According to the user-passed value,
create a number of ports represented by devlink port instances.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netdevsim/bus.c')
-rw-r--r-- | drivers/net/netdevsim/bus.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c index c30692f17374..1ee14e1bb12d 100644 --- a/drivers/net/netdevsim/bus.c +++ b/drivers/net/netdevsim/bus.c @@ -194,6 +194,21 @@ static struct attribute *nsim_bus_attrs[] = { }; ATTRIBUTE_GROUPS(nsim_bus); +static int nsim_bus_probe(struct device *dev) +{ + struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); + + return nsim_dev_probe(nsim_bus_dev); +} + +static int nsim_bus_remove(struct device *dev) +{ + struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); + + nsim_dev_remove(nsim_bus_dev); + return 0; +} + int nsim_num_vf(struct device *dev) { struct nsim_bus_dev *nsim_bus_dev = to_nsim_bus_dev(dev); @@ -205,6 +220,8 @@ static struct bus_type nsim_bus = { .name = DRV_NAME, .dev_name = DRV_NAME, .bus_groups = nsim_bus_groups, + .probe = nsim_bus_probe, + .remove = nsim_bus_remove, .num_vf = nsim_num_vf, }; @@ -238,6 +255,18 @@ err_nsim_bus_dev_free: return ERR_PTR(err); } +struct nsim_bus_dev *nsim_bus_dev_new_with_ns(struct netdevsim *ns) +{ + struct nsim_bus_dev *nsim_bus_dev; + + dev_hold(ns->netdev); + rtnl_unlock(); + nsim_bus_dev = nsim_bus_dev_new(~0, 0); + rtnl_lock(); + dev_put(ns->netdev); + return nsim_bus_dev; +} + void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev) { device_unregister(&nsim_bus_dev->dev); |