diff options
author | 2017-06-19 14:04:56 +0300 | |
---|---|---|
committer | 2017-08-10 13:21:54 +0300 | |
commit | 8030c8357a94ce6397dd8df6296925f0f4b1f9b7 (patch) | |
tree | cf311a3832440d76f745c72842ae03633d18552c /drivers/infiniband/core/device.c | |
parent | RDMA/netlink: Rename netlink callback struct (diff) | |
download | linux-8030c8357a94ce6397dd8df6296925f0f4b1f9b7.tar.gz linux-8030c8357a94ce6397dd8df6296925f0f4b1f9b7.tar.bz2 linux-8030c8357a94ce6397dd8df6296925f0f4b1f9b7.zip |
RDMA/core: Add iterator over ib_devices
The coming nldev needs to iterate over all IB devices in the system
and in order to not expose the ib_devices list outside the devices.c,
it is necessary to provide function iterator.
Current version is written explicitly for nldev callback to avoid
over-engineering at this stage, but it can be easily extended for
other types.
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Diffstat (limited to 'drivers/infiniband/core/device.c')
-rw-r--r-- | drivers/infiniband/core/device.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 33a39518848c..8828f26250a8 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -893,6 +893,31 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter, } /** + * ib_enum_all_devs - enumerate all ib_devices + * @cb: Callback to call for each found ib_device + * + * Enumerates all ib_devices and calls callback() on each device. + */ +int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct ib_device *dev; + unsigned int idx = 0; + int ret = 0; + + down_read(&lists_rwsem); + list_for_each_entry(dev, &device_list, core_list) { + ret = nldev_cb(dev, skb, cb, idx); + if (ret) + break; + idx++; + } + + up_read(&lists_rwsem); + return ret; +} + +/** * ib_query_pkey - Get P_Key table entry * @device:Device to query * @port_num:Port number to query |