diff options
author | Shiraz Saleem <shiraz.saleem@intel.com> | 2019-05-06 08:53:32 -0500 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-05-06 13:08:11 -0300 |
commit | 4a35339958f16d42a4ca06a8da9d4b5ab39ee8ea (patch) | |
tree | 5ac8683e8ff5329f7c5868cf44c0f6cbfa47f24e /include/rdma/ib_verbs.h | |
parent | 4c4b1996b5db688e2dcb8242b0a3bf7b1e845e42 (diff) | |
download | linux-4a35339958f16d42a4ca06a8da9d4b5ab39ee8ea.tar.bz2 |
RDMA/umem: Add API to find best driver supported page size in an MR
This helper iterates through the SG list to find the best page size to use
from a bitmap of HW supported page sizes. Drivers that support multiple
page sizes, but not mixed sizes in an MR can use this API.
Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.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 | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 8f8965f8ffdb..03b07ec6a34b 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -3250,6 +3250,30 @@ static inline bool rdma_cap_read_inv(struct ib_device *dev, u32 port_num) return rdma_protocol_iwarp(dev, port_num); } +/** + * rdma_find_pg_bit - Find page bit given address and HW supported page sizes + * + * @addr: address + * @pgsz_bitmap: bitmap of HW supported page sizes + */ +static inline unsigned int rdma_find_pg_bit(unsigned long addr, + unsigned long pgsz_bitmap) +{ + unsigned long align; + unsigned long pgsz; + + align = addr & -addr; + + /* Find page bit such that addr is aligned to the highest supported + * HW page size + */ + pgsz = pgsz_bitmap & ~(-align << 1); + if (!pgsz) + return __ffs(pgsz_bitmap); + + return __fls(pgsz); +} + int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port, int state); int ib_get_vf_config(struct ib_device *device, int vf, u8 port, |