numam-dpdk/drivers/net/mlx5/linux/mlx5_verbs.c
Ophir Munk 4f96d91396 net/mlx5/linux: add memory region callbacks to Verbs
Create a set of verbs callbacks in 'struct mlx5_verbs_ops'
and add MR operations to it (file net/mlx5/linux/mlx5_verbs.c).

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
2020-06-17 16:32:01 +02:00

79 lines
1.8 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2020 Mellanox Technologies, Ltd
*/
#include <stddef.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/mman.h>
#include <inttypes.h>
/* Verbs header. */
/* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
#include "mlx5_autoconf.h"
#ifdef PEDANTIC
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#ifdef HAVE_INFINIBAND_VERBS_H
#include <infiniband/verbs.h>
#endif
#ifdef HAVE_INFINIBAND_MLX5DV_H
#include <infiniband/mlx5dv.h>
#endif
#ifdef PEDANTIC
#pragma GCC diagnostic error "-Wpedantic"
#endif
#include <rte_mbuf.h>
#include <rte_malloc.h>
#include <rte_ethdev_driver.h>
#include <rte_common.h>
#include <mlx5_glue.h>
#include <mlx5_common.h>
#include <mlx5_common_mr.h>
#include <mlx5_verbs.h>
/**
* Register mr. Given protection domain pointer, pointer to addr and length
* register the memory region.
*
* @param[in] pd
* Pointer to protection domain context.
* @param[in] addr
* Pointer to memory start address.
* @param[in] length
* Length of the memory to register.
* @param[out] pmd_mr
* pmd_mr struct set with lkey, address, length and pointer to mr object
*
* @return
* 0 on successful registration, -1 otherwise
*/
static int
mlx5_reg_mr(void *pd, void *addr, size_t length,
struct mlx5_pmd_mr *pmd_mr)
{
return mlx5_common_verbs_reg_mr(pd, addr, length, pmd_mr);
}
/**
* Deregister mr. Given the mlx5 pmd MR - deregister the MR
*
* @param[in] pmd_mr
* pmd_mr struct set with lkey, address, length and pointer to mr object
*
*/
static void
mlx5_dereg_mr(struct mlx5_pmd_mr *pmd_mr)
{
mlx5_common_verbs_dereg_mr(pmd_mr);
}
/* verbs operations. */
const struct mlx5_verbs_ops mlx5_verbs_ops = {
.reg_mr = mlx5_reg_mr,
.dereg_mr = mlx5_dereg_mr,
};