1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
13 #include "mlx5_autoconf.h"
14 #include <mlx5_glue.h>
15 #include <mlx5_common.h>
16 #include <mlx5_common_mr.h>
19 * Register mr. Given protection domain pointer, pointer to addr and length
20 * register the memory region.
23 * Pointer to protection domain context.
25 * Pointer to memory start address.
27 * Length of the memory to register.
29 * pmd_mr struct set with lkey, address, length and pointer to mr object
32 * 0 on successful registration, -1 otherwise
35 mlx5_common_verbs_reg_mr(void *pd, void *addr, size_t length,
36 struct mlx5_pmd_mr *pmd_mr)
38 struct ibv_mr *ibv_mr;
40 memset(pmd_mr, 0, sizeof(*pmd_mr));
41 ibv_mr = mlx5_glue->reg_mr(pd, addr, length,
42 IBV_ACCESS_LOCAL_WRITE |
43 (haswell_broadwell_cpu ? 0 :
44 IBV_ACCESS_RELAXED_ORDERING));
48 *pmd_mr = (struct mlx5_pmd_mr){
51 .len = ibv_mr->length,
52 .obj = (void *)ibv_mr,
58 * Deregister mr. Given the mlx5 pmd MR - deregister the MR
61 * pmd_mr struct set with lkey, address, length and pointer to mr object
65 mlx5_common_verbs_dereg_mr(struct mlx5_pmd_mr *pmd_mr)
67 if (pmd_mr && pmd_mr->obj != NULL) {
68 claim_zero(mlx5_glue->dereg_mr(pmd_mr->obj));
69 memset(pmd_mr, 0, sizeof(*pmd_mr));