summaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2019-02-18 22:25:43 +0200
committerJason Gunthorpe <jgg@mellanox.com>2019-02-18 21:04:36 -0700
commitfd47c2f99f04249d1ba82c422d1818dcbe193908 (patch)
treeba51844cae66a900a3c8ceeda5fb973417a5aef7 /include/rdma
parent5f8f5499005c51656645a011bca81ffb66fcaaca (diff)
downloadlinux-fd47c2f99f04249d1ba82c422d1818dcbe193908.tar.gz
linux-fd47c2f99f04249d1ba82c422d1818dcbe193908.tar.bz2
linux-fd47c2f99f04249d1ba82c422d1818dcbe193908.zip
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')
-rw-r--r--include/rdma/restrack.h22
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);