Lines Matching +full:function +full:- +full:mask
1 /*-
45 * This function removes the element at the given index and returns
55 retval = radix_tree_delete(&xa->xa_head, index); in __xa_erase()
75 * This function returns the element pointer at the given index. A
84 retval = radix_tree_lookup(&xa->xa_head, index); in xa_load()
94 * This is an internal function used to sleep until more memory
106 * This function iterates the xarray until it finds a free slot where
109 * "mask" argument defines the maximum index allowed, inclusivly, and
112 * or not. This function returns zero upon success or a negative error
113 * code on failure. A typical error code is -ENOMEM which means either
118 __xa_alloc(struct xarray *xa, uint32_t *pindex, void *ptr, uint32_t mask, gfp_t gfp) in __xa_alloc() argument
124 /* mask should allow to allocate at least one item */ in __xa_alloc()
125 MPASS(mask > ((xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0)); in __xa_alloc()
127 /* mask can be any power of two value minus one */ in __xa_alloc()
128 MPASS((mask & (mask + 1)) == 0); in __xa_alloc()
130 *pindex = (xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0; in __xa_alloc()
134 retval = radix_tree_insert(&xa->xa_head, *pindex, ptr); in __xa_alloc()
137 case -EEXIST: in __xa_alloc()
138 if (likely(*pindex != mask)) { in __xa_alloc()
142 retval = -ENOMEM; in __xa_alloc()
144 case -ENOMEM: in __xa_alloc()
157 xa_alloc(struct xarray *xa, uint32_t *pindex, void *ptr, uint32_t mask, gfp_t gfp) in xa_alloc() argument
165 retval = __xa_alloc(xa, pindex, ptr, mask, gfp); in xa_alloc()
172 * This function works the same like the "xa_alloc" function, except
175 * beginning of the array. If the xarray is full -ENOMEM is returned.
178 __xa_alloc_cyclic(struct xarray *xa, uint32_t *pindex, void *ptr, uint32_t mask, in __xa_alloc_cyclic() argument
186 /* mask should allow to allocate at least one item */ in __xa_alloc_cyclic()
187 MPASS(mask > ((xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0)); in __xa_alloc_cyclic()
189 /* mask can be any power of two value minus one */ in __xa_alloc_cyclic()
190 MPASS((mask & (mask + 1)) == 0); in __xa_alloc_cyclic()
192 *pnext_index = (xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0; in __xa_alloc_cyclic()
196 retval = radix_tree_insert(&xa->xa_head, *pnext_index, ptr); in __xa_alloc_cyclic()
199 case -EEXIST: in __xa_alloc_cyclic()
200 if (unlikely(*pnext_index == mask) && !timeout--) { in __xa_alloc_cyclic()
201 retval = -ENOMEM; in __xa_alloc_cyclic()
205 (*pnext_index) &= mask; in __xa_alloc_cyclic()
206 if (*pnext_index == 0 && (xa->xa_flags & XA_FLAGS_ALLOC1) != 0) in __xa_alloc_cyclic()
209 case -ENOMEM: in __xa_alloc_cyclic()
224 xa_alloc_cyclic(struct xarray *xa, uint32_t *pindex, void *ptr, uint32_t mask, in xa_alloc_cyclic() argument
230 retval = __xa_alloc_cyclic(xa, pindex, ptr, mask, pnext_index, gfp); in xa_alloc_cyclic()
238 uint32_t mask, uint32_t *pnext_index, gfp_t gfp) in xa_alloc_cyclic_irq() argument
243 retval = __xa_alloc_cyclic(xa, pindex, ptr, mask, pnext_index, gfp); in xa_alloc_cyclic_irq()
250 * This function tries to insert an element at the given index. The
251 * "gfp" argument basically decides of this function can sleep or not
253 * function returns an error code upon failure. Typical error codes
254 * are element exists (-EEXIST) or out of memory (-ENOMEM).
265 retval = radix_tree_insert(&xa->xa_head, index, ptr); in __xa_insert()
268 case -ENOMEM: in __xa_insert()
293 * This function updates the element at the given index and returns a
295 * this function can sleep or not trying to allocate internal memory
296 * for its radix tree. The function returns an XA_ERROR() pointer code
297 * upon failure. Code using this function must always check if the
309 retval = radix_tree_store(&xa->xa_head, index, &ptr); in __xa_store()
316 case -ENOMEM: in __xa_store()
343 * This function initialize an xarray structure.
350 mtx_init(&xa->xa_lock, "lkpi-xarray", NULL, MTX_DEF | MTX_RECURSE); in xa_init_flags()
351 xa->xa_head.gfp_mask = GFP_NOWAIT; in xa_init_flags()
352 xa->xa_flags = flags; in xa_init_flags()
356 * This function destroys an xarray structure and all its internal
366 radix_tree_for_each_slot(ppslot, &xa->xa_head, &iter, 0) in xa_destroy()
367 radix_tree_iter_delete(&xa->xa_head, &iter, ppslot); in xa_destroy()
381 * This function checks if an xarray is empty or not.
392 return (!radix_tree_iter_find(&xa->xa_head, &iter, &temp)); in __xa_empty()
408 * This function returns the next valid xarray entry based on the
429 found = radix_tree_iter_find(&xa->xa_head, &iter, &ppslot); in __xa_next()