hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/infiniband/sw/rxe/rxe_pool.h
....@@ -1,34 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
12 /*
23 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
34 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
4
- *
5
- * This software is available to you under a choice of one of two
6
- * licenses. You may choose to be licensed under the terms of the GNU
7
- * General Public License (GPL) Version 2, available from the file
8
- * COPYING in the main directory of this source tree, or the
9
- * OpenIB.org BSD license below:
10
- *
11
- * Redistribution and use in source and binary forms, with or
12
- * without modification, are permitted provided that the following
13
- * conditions are met:
14
- *
15
- * - Redistributions of source code must retain the above
16
- * copyright notice, this list of conditions and the following
17
- * disclaimer.
18
- *
19
- * - Redistributions in binary form must reproduce the above
20
- * copyright notice, this list of conditions and the following
21
- * disclaimer in the documentation and/or other materials
22
- * provided with the distribution.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
325 */
336
347 #ifndef RXE_POOL_H
....@@ -41,6 +14,7 @@
4114 RXE_POOL_ATOMIC = BIT(0),
4215 RXE_POOL_INDEX = BIT(1),
4316 RXE_POOL_KEY = BIT(2),
17
+ RXE_POOL_NO_ALLOC = BIT(4),
4418 };
4519
4620 enum rxe_elem_type {
....@@ -68,14 +42,13 @@
6842 u32 min_index;
6943 size_t key_offset;
7044 size_t key_size;
71
- struct kmem_cache *cache;
7245 };
7346
7447 extern struct rxe_type_info rxe_type_info[];
7548
7649 enum rxe_pool_state {
77
- rxe_pool_invalid,
78
- rxe_pool_valid,
50
+ RXE_POOL_STATE_INVALID,
51
+ RXE_POOL_STATE_VALID,
7952 };
8053
8154 struct rxe_pool_entry {
....@@ -90,7 +63,7 @@
9063
9164 struct rxe_pool {
9265 struct rxe_dev *rxe;
93
- spinlock_t pool_lock; /* pool spinlock */
66
+ rwlock_t pool_lock; /* protects pool add/del/search */
9467 size_t elem_size;
9568 struct kref ref_cnt;
9669 void (*cleanup)(struct rxe_pool_entry *obj);
....@@ -112,12 +85,6 @@
11285 size_t key_size;
11386 };
11487
115
-/* initialize slab caches for managed objects */
116
-int rxe_cache_init(void);
117
-
118
-/* cleanup slab caches for managed objects */
119
-void rxe_cache_exit(void);
120
-
12188 /* initialize a pool of objects with given limit on
12289 * number of elements. gets parameters from rxe_type_info
12390 * pool elements will be allocated out of a slab cache
....@@ -126,11 +93,14 @@
12693 enum rxe_elem_type type, u32 max_elem);
12794
12895 /* free resources from object pool */
129
-int rxe_pool_cleanup(struct rxe_pool *pool);
96
+void rxe_pool_cleanup(struct rxe_pool *pool);
13097
13198 /* allocate an object from pool */
13299 void *rxe_alloc(struct rxe_pool *pool);
133100
101
+/* connect already allocated object to pool */
102
+int rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_entry *elem);
103
+
134104 /* assign an index to an indexed object and insert object into
135105 * pool's rb tree
136106 */