src/dpdk/drivers/net/mlx4/mlx4_mr.c
static uint32_t
mr_btree_lookup(struct mlx4_mr_btree *bt, uint16_t *idx, uintptr_t addr)
{
	struct mlx4_mr_cache *lkp_tbl;
	uint16_t n;
	uint16_t base = 0;

	MLX4_ASSERT(bt != NULL);
	lkp_tbl = *bt->table;
	n = bt->len;
	/* First entry must be NULL for comparison. */
	MLX4_ASSERT(bt->len > 0 || (lkp_tbl[0].start == 0 &&
				    lkp_tbl[0].lkey == UINT32_MAX));
	/* Binary search. */
	do {
		register uint16_t delta = n >> 1;

		if (addr < lkp_tbl[base + delta].start) {
			n = delta;
		} else {
			base += delta;
			n -= delta;
		}
	} while (n > 1);
	MLX4_ASSERT(addr >= lkp_tbl[base].start);
	*idx = base;
	if (addr < lkp_tbl[base].end)
		return lkp_tbl[base].lkey;
	/* Not found. */
	return UINT32_MAX;
}
/**
 * Look up LKey from given B-tree lookup table, store the last index and return
 * searched LKey.
 *
 * @param bt
 *   Pointer to B-tree structure.
 * @param[out] idx
 *   Pointer to index. Even on search failure, returns index where it stops
 *   searching so that index can be used when inserting a new entry.
 * @param addr
 *   Search key.
 *
 * @return
 *   Searched LKey on success, UINT32_MAX on no match.
 */
Look up LKey from given B-tree lookup table, store the last index and return
searched LKey.

@param bt
Pointer to B-tree structure.
@param[out] idx
Pointer to index. Even on search failure, returns index where it stops
searching so that index can be used when inserting a new entry.
@param addr
Search key.

@return
Searched LKey on success, UINT32_MAX on no match.
Look up LKey from given B - tree lookup table store the last index and return searched LKey . @param bt Pointer to B - tree structure . @param [ out ] idx Pointer to index . Even on search failure returns index where it stops searching so that index can be used when inserting a new entry . @param addr Search key . @return Searched LKey on success UINT32_MAX on no match .
static uint32_t
mr_btree_lookup(struct mlx4_mr_btree *bt, uint16_t *idx, uintptr_t addr)
{
	struct mlx4_mr_cache *lkp_tbl;
	uint16_t n;
	uint16_t base = 0;
	MLX4_ASSERT(bt != NULL);
	lkp_tbl = *bt->table;
	n = bt->len;
	MLX4_ASSERT(bt->len > 0 || (lkp_tbl[0].start == 0 &&
				    lkp_tbl[0].lkey == UINT32_MAX));
	do {
		register uint16_t delta = n >> 1;
		if (addr < lkp_tbl[base + delta].start) {
			n = delta;
		} else {
			base += delta;
			n -= delta;
		}
	} while (n > 1);
	MLX4_ASSERT(addr >= lkp_tbl[base].start);
	*idx = base;
	if (addr < lkp_tbl[base].end)
		return lkp_tbl[base].lkey;
	return UINT32_MAX;
}
static uint32_t mr_btree_lookup ( struct mlx4_mr_btree * bt , uint16_t * idx , uintptr_t addr ) { struct mlx4_mr_cache * lkp_tbl ; uint16_t n ; uint16_t base = 0 ; MLX4_ASSERT ( bt != NULL ) ; lkp_tbl = * bt -> table ; n = bt -> len ; MLX4_ASSERT ( bt -> len > 0 || ( lkp_tbl [ 0 ] . start == 0 && lkp_tbl [ 0 ] . lkey == UINT32_MAX ) ) ; do { register uint16_t delta = n >> 1 ; if ( addr < lkp_tbl [ base + delta ] . start ) { n = delta ; } else { base += delta ; n -= delta ; } } while ( n > 1 ) ; MLX4_ASSERT ( addr >= lkp_tbl [ base ] . start ) ; * idx = base ; if ( addr < lkp_tbl [ base ] . end ) return lkp_tbl [ base ] . lkey ; return UINT32_MAX ; }
Look up LKey from given B-tree lookup table, store the last index and return
 searched LKey.
Look up LKey from given B - tree lookup table store the last index and return searched LKey .
/* First entry must be NULL for comparison. */ /* Binary search. */ /* Not found. */