diff mbox series

[for-next,7/7] RDMA/rxe: Rename XARRAY as INDEX

Message ID 20211020220549.36145-8-rpearsonhpe@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series Replace red-black tree by xarray | expand

Commit Message

Bob Pearson Oct. 20, 2021, 10:05 p.m. UTC
Rename RXE_POOL_XARRAY as RXE_POOL_INDEX and change several function
names .._index_... from .._xarray_.. which completes the process of
replacing red-black trees by xarrays.

Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_pool.c | 38 +++++++++-------------------
 drivers/infiniband/sw/rxe/rxe_pool.h |  4 +--
 2 files changed, 14 insertions(+), 28 deletions(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 6e51483c0494..6367cf68d19d 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -25,7 +25,7 @@  static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.name		= "rxe-ah",
 		.size		= sizeof(struct rxe_ah),
 		.elem_offset	= offsetof(struct rxe_ah, elem),
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.min_index	= RXE_MIN_AH_INDEX,
 		.max_index	= RXE_MAX_AH_INDEX,
 	},
@@ -34,7 +34,7 @@  static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_srq),
 		.elem_offset	= offsetof(struct rxe_srq, elem),
 		.cleanup	= rxe_srq_cleanup,
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.min_index	= RXE_MIN_SRQ_INDEX,
 		.max_index	= RXE_MAX_SRQ_INDEX,
 	},
@@ -43,7 +43,7 @@  static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_qp),
 		.elem_offset	= offsetof(struct rxe_qp, elem),
 		.cleanup	= rxe_qp_cleanup,
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.min_index	= RXE_MIN_QP_INDEX,
 		.max_index	= RXE_MAX_QP_INDEX,
 	},
@@ -59,7 +59,7 @@  static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_mr),
 		.elem_offset	= offsetof(struct rxe_mr, elem),
 		.cleanup	= rxe_mr_cleanup,
-		.flags		= RXE_POOL_XARRAY,
+		.flags		= RXE_POOL_INDEX,
 		.max_index	= RXE_MAX_MR_INDEX,
 		.min_index	= RXE_MIN_MR_INDEX,
 	},
@@ -68,7 +68,7 @@  static const struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
 		.size		= sizeof(struct rxe_mw),
 		.elem_offset	= offsetof(struct rxe_mw, elem),
 		.cleanup	= rxe_mw_cleanup,
-		.flags		= RXE_POOL_XARRAY | RXE_POOL_NO_ALLOC,
+		.flags		= RXE_POOL_INDEX | RXE_POOL_NO_ALLOC,
 		.max_index	= RXE_MAX_MW_INDEX,
 		.min_index	= RXE_MIN_MW_INDEX,
 	},
@@ -103,7 +103,7 @@  void rxe_pool_init(
 
 	atomic_set(&pool->num_elem, 0);
 
-	if (info->flags & RXE_POOL_XARRAY) {
+	if (info->flags & RXE_POOL_INDEX) {
 		xa_init_flags(&pool->xarray.xa, XA_FLAGS_ALLOC);
 		pool->xarray.limit.max = info->max_index;
 		pool->xarray.limit.min = info->min_index;
@@ -173,7 +173,7 @@  static void *__rxe_alloc_locked(struct rxe_pool *pool)
 	elem->pool = pool;
 	elem->obj = obj;
 
-	if (pool->flags & RXE_POOL_XARRAY) {
+	if (pool->flags & RXE_POOL_INDEX) {
 		err = __xa_alloc_cyclic(&pool->xarray.xa, &elem->index, elem,
 					pool->xarray.limit,
 					&pool->xarray.next, GFP_KERNEL);
@@ -264,7 +264,7 @@  int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem)
 	elem->pool = pool;
 	elem->obj = (u8 *)elem - pool->elem_offset;
 
-	if (pool->flags & RXE_POOL_XARRAY) {
+	if (pool->flags & RXE_POOL_INDEX) {
 		err = __xa_alloc_cyclic(&pool->xarray.xa, &elem->index, elem,
 					pool->xarray.limit,
 					&pool->xarray.next, GFP_KERNEL);
@@ -283,7 +283,7 @@  int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem)
 	return -EINVAL;
 }
 
-static void *__rxe_get_xarray_locked(struct rxe_pool *pool, u32 index)
+void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index)
 {
 	struct rxe_pool_elem *elem;
 	void *obj = NULL;
@@ -295,31 +295,17 @@  static void *__rxe_get_xarray_locked(struct rxe_pool *pool, u32 index)
 	return obj;
 }
 
-static void *__rxe_get_xarray(struct rxe_pool *pool, u32 index)
+void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
 {
 	void *obj;
 
 	xa_lock_bh(&pool->xarray.xa);
-	obj = __rxe_get_xarray_locked(pool, index);
+	obj = rxe_pool_get_index_locked(pool, index);
 	xa_unlock_bh(&pool->xarray.xa);
 
 	return obj;
 }
 
-void *rxe_pool_get_index_locked(struct rxe_pool *pool, u32 index)
-{
-	if (pool->flags & RXE_POOL_XARRAY)
-		return __rxe_get_xarray_locked(pool, index);
-	return NULL;
-}
-
-void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
-{
-	if (pool->flags & RXE_POOL_XARRAY)
-		return __rxe_get_xarray(pool, index);
-	return NULL;
-}
-
 void *rxe_pool_get_key_locked(struct rxe_pool *pool, void *key)
 {
 	struct rb_node *node;
@@ -413,7 +399,7 @@  static int __rxe_fini(struct rxe_pool_elem *elem)
 
 	done = refcount_dec_if_one(&elem->refcnt);
 	if (done) {
-		if (pool->flags & RXE_POOL_XARRAY)
+		if (pool->flags & RXE_POOL_INDEX)
 			__xa_erase(&pool->xarray.xa, elem->index);
 		if (pool->flags & RXE_POOL_KEY)
 			rb_erase(&elem->key_node, &pool->key.tree);
diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h
index 191e5aea454f..95a6b1e5232f 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.h
+++ b/drivers/infiniband/sw/rxe/rxe_pool.h
@@ -14,8 +14,8 @@ 
 #define RXE_POOL_CACHE_FLAGS	(0)
 
 enum rxe_pool_flags {
+	RXE_POOL_INDEX		= BIT(1),
 	RXE_POOL_KEY		= BIT(2),
-	RXE_POOL_XARRAY		= BIT(3),
 	RXE_POOL_NO_ALLOC	= BIT(4),
 };
 
@@ -72,7 +72,7 @@  struct rxe_pool {
 	size_t			elem_size;
 	size_t			elem_offset;
 
-	/* only used if xarray */
+	/* only used if indexed */
 	struct {
 		struct xarray		xa;
 		struct xa_limit		limit;