src/dpdk/drivers/net/mlx4/mlx4_mr.c
static uint32_t
mlx4_mr_lookup_dev(struct rte_eth_dev *dev, struct mlx4_mr_ctrl *mr_ctrl,
		   struct mlx4_mr_cache *entry, uintptr_t addr)
{
	struct mlx4_priv *priv = dev->data->dev_private;
	struct mlx4_mr_btree *bt = &mr_ctrl->cache_bh;
	uint16_t idx;
	uint32_t lkey;

	/* If local cache table is full, try to double it. */
	if (unlikely(bt->len == bt->size))
		mr_btree_expand(bt, bt->size << 1);
	/* Look up in the global cache. */
	rte_rwlock_read_lock(&priv->mr.rwlock);
	lkey = mr_btree_lookup(&priv->mr.cache, &idx, addr);
	if (lkey != UINT32_MAX) {
		/* Found. */
		*entry = (*priv->mr.cache.table)[idx];
		rte_rwlock_read_unlock(&priv->mr.rwlock);
		/*
		 * Update local cache. Even if it fails, return the found entry
		 * to update top-half cache. Next time, this entry will be found
		 * in the global cache.
		 */
		mr_btree_insert(bt, entry);
		return lkey;
	}
	rte_rwlock_read_unlock(&priv->mr.rwlock);
	/* First time to see the address? Create a new MR. */
	lkey = mlx4_mr_create(dev, entry, addr);
	/*
	 * Update the local cache if successfully created a new global MR. Even
	 * if failed to create one, there's no action to take in this datapath
	 * code. As returning LKey is invalid, this will eventually make HW
	 * fail.
	 */
	if (lkey != UINT32_MAX)
		mr_btree_insert(bt, entry);
	return lkey;
}
/**
 * Look up address in the global MR cache table. If not found, create a new MR.
 * Insert the found/created entry to local bottom-half cache table.
 *
 * @param dev
 *   Pointer to Ethernet device.
 * @param mr_ctrl
 *   Pointer to per-queue MR control structure.
 * @param[out] entry
 *   Pointer to returning MR cache entry, found in the global cache or newly
 *   created. If failed to create one, this is not written.
 * @param addr
 *   Search key.
 *
 * @return
 *   Searched LKey on success, UINT32_MAX on no match.
 */
Look up address in the global MR cache table. If not found, create a new MR.
Insert the found/created entry to local bottom-half cache table.

@param dev
Pointer to Ethernet device.
@param mr_ctrl
Pointer to per-queue MR control structure.
@param[out] entry
Pointer to returning MR cache entry, found in the global cache or newly
created. If failed to create one, this is not written.
@param addr
Search key.

@return
Searched LKey on success, UINT32_MAX on no match.
Look up address in the global MR cache table . If not found create a new MR . Insert the found / created entry to local bottom - half cache table . @param dev Pointer to Ethernet device . @param mr_ctrl Pointer to per - queue MR control structure . @param [ out ] entry Pointer to returning MR cache entry found in the global cache or newly created . If failed to create one this is not written . @param addr Search key . @return Searched LKey on success UINT32_MAX on no match .
static uint32_t
mlx4_mr_lookup_dev(struct rte_eth_dev *dev, struct mlx4_mr_ctrl *mr_ctrl,
		   struct mlx4_mr_cache *entry, uintptr_t addr)
{
	struct mlx4_priv *priv = dev->data->dev_private;
	struct mlx4_mr_btree *bt = &mr_ctrl->cache_bh;
	uint16_t idx;
	uint32_t lkey;
	if (unlikely(bt->len == bt->size))
		mr_btree_expand(bt, bt->size << 1);
	rte_rwlock_read_lock(&priv->mr.rwlock);
	lkey = mr_btree_lookup(&priv->mr.cache, &idx, addr);
	if (lkey != UINT32_MAX) {
		*entry = (*priv->mr.cache.table)[idx];
		rte_rwlock_read_unlock(&priv->mr.rwlock);
		mr_btree_insert(bt, entry);
		return lkey;
	}
	rte_rwlock_read_unlock(&priv->mr.rwlock);
	lkey = mlx4_mr_create(dev, entry, addr);
	if (lkey != UINT32_MAX)
		mr_btree_insert(bt, entry);
	return lkey;
}
static uint32_t mlx4_mr_lookup_dev ( struct rte_eth_dev * dev , struct mlx4_mr_ctrl * mr_ctrl , struct mlx4_mr_cache * entry , uintptr_t addr ) { struct mlx4_priv * priv = dev -> data -> dev_private ; struct mlx4_mr_btree * bt = & mr_ctrl -> cache_bh ; uint16_t idx ; uint32_t lkey ; if ( unlikely ( bt -> len == bt -> size ) ) mr_btree_expand ( bt , bt -> size << 1 ) ; rte_rwlock_read_lock ( & priv -> mr . rwlock ) ; lkey = mr_btree_lookup ( & priv -> mr . cache , & idx , addr ) ; if ( lkey != UINT32_MAX ) { * entry = ( * priv -> mr . cache . table ) [ idx ] ; rte_rwlock_read_unlock ( & priv -> mr . rwlock ) ; mr_btree_insert ( bt , entry ) ; return lkey ; } rte_rwlock_read_unlock ( & priv -> mr . rwlock ) ; lkey = mlx4_mr_create ( dev , entry , addr ) ; if ( lkey != UINT32_MAX ) mr_btree_insert ( bt , entry ) ; return lkey ; }
Look up address in the global MR cache table.
Look up address in the global MR cache table .
/* If local cache table is full, try to double it. */ /* Look up in the global cache. */ /* Found. */ /*
		 * Update local cache. Even if it fails, return the found entry
		 * to update top-half cache. Next time, this entry will be found
		 * in the global cache.
		 */ /* First time to see the address? Create a new MR. */ /*
	 * Update the local cache if successfully created a new global MR. Even
	 * if failed to create one, there's no action to take in this datapath
	 * code. As returning LKey is invalid, this will eventually make HW
	 * fail.
	 */