diff options
author | Leon Romanovsky <leonro@mellanox.com> | 2019-02-18 23:25:43 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-02-19 07:04:36 +0300 |
commit | fd47c2f99f04249d1ba82c422d1818dcbe193908 (patch) | |
tree | ba51844cae66a900a3c8ceeda5fb973417a5aef7 /include/rdma/restrack.h | |
parent | 5f8f5499005c51656645a011bca81ffb66fcaaca (diff) | |
download | linux-fd47c2f99f04249d1ba82c422d1818dcbe193908.tar.xz |
RDMA/restrack: Convert internal DB from hash to XArray
The additions of .doit callbacks posses new access pattern to the resource
entries by some user visible index. Back then, the legacy DB was
implemented as hash because per-index access wasn't needed and XArray
wasn't accepted yet.
Acceptance of XArray together with per-index access requires the refresh
of DB implementation.
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'include/rdma/restrack.h')
-rw-r--r-- | include/rdma/restrack.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h index cc66cc7a11d3..16e11b4c3ec3 100644 --- a/include/rdma/restrack.h +++ b/include/rdma/restrack.h @@ -13,6 +13,7 @@ #include <linux/completion.h> #include <linux/sched/task.h> #include <uapi/rdma/rdma_netlink.h> +#include <linux/xarray.h> /** * enum rdma_restrack_type - HW objects to track @@ -48,7 +49,6 @@ enum rdma_restrack_type { RDMA_RESTRACK_MAX }; -#define RDMA_RESTRACK_HASH_BITS 8 struct ib_device; struct rdma_restrack_entry; @@ -62,9 +62,17 @@ struct rdma_restrack_root { */ struct rw_semaphore rwsem; /** - * @hash: global database for all resources per-device + * @xa: Array of XArray structures to hold restrack entries. + * We want to use array of XArrays because insertion is type + * dependent. For types with xisiting unique ID (like QPN), + * we will insert to that unique index. For other types, + * we insert based on pointers and auto-allocate unique index. */ - DECLARE_HASHTABLE(hash, RDMA_RESTRACK_HASH_BITS); + struct xarray xa[RDMA_RESTRACK_MAX]; + /** + * @next_id: Next ID to support cyclic allocation + */ + u32 next_id[RDMA_RESTRACK_MAX]; }; /** @@ -103,10 +111,6 @@ struct rdma_restrack_entry { */ const char *kern_name; /** - * @node: hash table entry - */ - struct hlist_node node; - /** * @type: various objects in restrack database */ enum rdma_restrack_type type; @@ -114,6 +118,10 @@ struct rdma_restrack_entry { * @user: user resource */ bool user; + /** + * @id: ID to expose to users + */ + u32 id; }; void rdma_restrack_init(struct ib_device *dev); |