diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2019-02-12 21:12:47 -0700 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-02-19 10:13:39 -0700 |
commit | ea1075edcbab7d92f4e4ccf5490043f796bf78be (patch) | |
tree | 618fb95aa42e446d18020d6851bab321be2c3b4b /include/rdma/ib_verbs.h | |
parent | f2a0e45f36b0a210ff2388ed5fa89f81019c07a1 (diff) | |
download | linux-stable-ea1075edcbab7d92f4e4ccf5490043f796bf78be.tar.gz linux-stable-ea1075edcbab7d92f4e4ccf5490043f796bf78be.tar.bz2 linux-stable-ea1075edcbab7d92f4e4ccf5490043f796bf78be.zip |
RDMA: Add and use rdma_for_each_port
We have many loops iterating over all of the end port numbers on a struct
ib_device, simplify them with a for_each helper.
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'include/rdma/ib_verbs.h')
-rw-r--r-- | include/rdma/ib_verbs.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 2a17c2b30073..fa0edd6ae33c 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2828,6 +2828,16 @@ static inline u8 rdma_start_port(const struct ib_device *device) } /** + * rdma_for_each_port - Iterate over all valid port numbers of the IB device + * @device - The struct ib_device * to iterate over + * @iter - The unsigned int to store the port number + */ +#define rdma_for_each_port(device, iter) \ + for (iter = rdma_start_port(device + BUILD_BUG_ON_ZERO(!__same_type( \ + unsigned int, iter))); \ + iter <= rdma_end_port(device); (iter)++) + +/** * rdma_end_port - Return the last valid port number for the device * specified * |