* Insert a MR to the global B-tree cache. It may fail due to low-on-memory. * Then, this entry will have to be searched by mr_lookup_list() in * mlx5_mr_create() on miss. * * @param share_cache * Pointer to a global shared MR cache. * @param mr * Pointer to MR to insert. * * @return * 0 on success, -1 on failure. */
| 391 | * 0 on success, -1 on failure. |
| 392 | */ |
| 393 | int |
| 394 | mlx5_mr_insert_cache(struct mlx5_mr_share_cache *share_cache, |
| 395 | struct mlx5_mr *mr) |
| 396 | { |
| 397 | unsigned int n; |
| 398 | |
| 399 | DRV_LOG(DEBUG, "Inserting MR(%p) to global cache(%p)", |
| 400 | (void *)mr, (void *)share_cache); |
| 401 | for (n = 0; n < mr->ms_bmp_n; ) { |
| 402 | struct mr_cache_entry entry; |
| 403 | |
| 404 | memset(&entry, 0, sizeof(entry)); |
| 405 | /* Find a contiguous chunk and advance the index. */ |
| 406 | n = mr_find_next_chunk(mr, &entry, n); |
| 407 | if (!entry.end) |
| 408 | break; |
| 409 | if (mr_btree_insert(&share_cache->cache, &entry) < 0) |
| 410 | return -1; |
| 411 | } |
| 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Look up address in the original global MR list. |
no test coverage detected