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