1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2020 Mellanox Technologies, Ltd 3 */ 4 5 #include <stddef.h> 6 #include <errno.h> 7 #include <string.h> 8 #include <stdint.h> 9 #include <unistd.h> 10 #include <sys/mman.h> 11 #include <inttypes.h> 12 13 /* Verbs header. */ 14 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */ 15 #include "mlx5_autoconf.h" 16 #ifdef PEDANTIC 17 #pragma GCC diagnostic ignored "-Wpedantic" 18 #endif 19 #ifdef HAVE_INFINIBAND_VERBS_H 20 #include <infiniband/verbs.h> 21 #endif 22 #ifdef HAVE_INFINIBAND_MLX5DV_H 23 #include <infiniband/mlx5dv.h> 24 #endif 25 #ifdef PEDANTIC 26 #pragma GCC diagnostic error "-Wpedantic" 27 #endif 28 29 #include <rte_mbuf.h> 30 #include <rte_malloc.h> 31 #include <rte_ethdev_driver.h> 32 #include <rte_common.h> 33 34 #include <mlx5_glue.h> 35 #include <mlx5_common.h> 36 #include <mlx5_common_mr.h> 37 #include <mlx5_verbs.h> 38 /** 39 * Register mr. Given protection domain pointer, pointer to addr and length 40 * register the memory region. 41 * 42 * @param[in] pd 43 * Pointer to protection domain context. 44 * @param[in] addr 45 * Pointer to memory start address. 46 * @param[in] length 47 * Length of the memory to register. 48 * @param[out] pmd_mr 49 * pmd_mr struct set with lkey, address, length and pointer to mr object 50 * 51 * @return 52 * 0 on successful registration, -1 otherwise 53 */ 54 static int 55 mlx5_reg_mr(void *pd, void *addr, size_t length, 56 struct mlx5_pmd_mr *pmd_mr) 57 { 58 return mlx5_common_verbs_reg_mr(pd, addr, length, pmd_mr); 59 } 60 61 /** 62 * Deregister mr. Given the mlx5 pmd MR - deregister the MR 63 * 64 * @param[in] pmd_mr 65 * pmd_mr struct set with lkey, address, length and pointer to mr object 66 * 67 */ 68 static void 69 mlx5_dereg_mr(struct mlx5_pmd_mr *pmd_mr) 70 { 71 mlx5_common_verbs_dereg_mr(pmd_mr); 72 } 73 74 /* verbs operations. */ 75 const struct mlx5_verbs_ops mlx5_verbs_ops = { 76 .reg_mr = mlx5_reg_mr, 77 .dereg_mr = mlx5_dereg_mr, 78 }; 79