DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ophir Munk <ophirmu@mellanox.com>
To: dev@dpdk.org, Matan Azrad <matan@mellanox.com>,
	Raslan Darawsheh <rasland@mellanox.com>
Cc: Ophir Munk <ophirmu@mellanox.com>
Subject: [dpdk-dev] [PATCH v1 4/4] mlx5/linux: add MR callbacks to verbs operations struct
Date: Tue, 16 Jun 2020 09:44:46 +0000	[thread overview]
Message-ID: <20200616094446.7152-5-ophirmu@mellanox.com> (raw)
In-Reply-To: <20200616094446.7152-1-ophirmu@mellanox.com>

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>
---
 drivers/net/mlx5/Makefile           |  1 +
 drivers/net/mlx5/linux/meson.build  |  1 +
 drivers/net/mlx5/linux/mlx5_os.c    |  5 ++-
 drivers/net/mlx5/linux/mlx5_verbs.c | 78 +++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/linux/mlx5_verbs.h | 15 +++++++
 5 files changed, 98 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/mlx5/linux/mlx5_verbs.c
 create mode 100644 drivers/net/mlx5/linux/mlx5_verbs.h

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index fada6fb..a458402 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -34,6 +34,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_socket.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_os.c
 SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_ethdev_os.c
+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += linux/mlx5_verbs.c
 
 # Basic CFLAGS.
 CFLAGS += -O3
diff --git a/drivers/net/mlx5/linux/meson.build b/drivers/net/mlx5/linux/meson.build
index ad908c4..14eed03 100644
--- a/drivers/net/mlx5/linux/meson.build
+++ b/drivers/net/mlx5/linux/meson.build
@@ -6,5 +6,6 @@ sources += files(
 	'mlx5_socket.c',
 	'mlx5_os.c',
 	'mlx5_ethdev_os.c',
+	'mlx5_verbs.c',
 )
 
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index f498d00..3792371 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -52,6 +52,7 @@
 #include "mlx5_mr.h"
 #include "mlx5_flow.h"
 #include "rte_pmd_mlx5.h"
+#include "mlx5_verbs.h"
 
 #define MLX5_TAGS_HLIST_ARRAY_SIZE 8192
 
@@ -2335,8 +2336,8 @@ void
 mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
 		      mlx5_dereg_mr_t *dereg_mr_cb)
 {
-	*reg_mr_cb = mlx5_common_verbs_reg_mr;
-	*dereg_mr_cb = mlx5_common_verbs_dereg_mr;
+	*reg_mr_cb = mlx5_verbs_ops.reg_mr;
+	*dereg_mr_cb = mlx5_verbs_ops.dereg_mr;
 }
 
 const struct eth_dev_ops mlx5_os_dev_ops = {
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c
new file mode 100644
index 0000000..8e42ec8
--- /dev/null
+++ b/drivers/net/mlx5/linux/mlx5_verbs.c
@@ -0,0 +1,78 @@
+/* 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 doamin 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] lentgh
+ *   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,
+};
diff --git a/drivers/net/mlx5/linux/mlx5_verbs.h b/drivers/net/mlx5/linux/mlx5_verbs.h
new file mode 100644
index 0000000..4f0b637
--- /dev/null
+++ b/drivers/net/mlx5/linux/mlx5_verbs.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#ifndef RTE_PMD_MLX5_VERBS_H_
+#define RTE_PMD_MLX5_VERBS_H_
+
+struct mlx5_verbs_ops {
+	mlx5_reg_mr_t reg_mr;
+	mlx5_dereg_mr_t dereg_mr;
+};
+
+/* Verbs ops struct */
+extern const struct mlx5_verbs_ops mlx5_verbs_ops;
+#endif /* RTE_PMD_MLX5_VERBS_H_ */
-- 
2.8.4


  parent reply	other threads:[~2020-06-16  9:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16  9:44 [dpdk-dev] [PATCH v1 0/4] mlx5 MR refactor Ophir Munk
2020-06-16  9:44 ` [dpdk-dev] [PATCH v1 1/4] common/mlx5: remove MR struct dependency on ibv Ophir Munk
2020-06-16  9:44 ` [dpdk-dev] [PATCH v1 2/4] common/mlx5: export MR verbs operations Ophir Munk
2020-06-16  9:44 ` [dpdk-dev] [PATCH v1 3/4] net/mlx5: add MR callbacks in per-device cache Ophir Munk
2020-06-16  9:44 ` Ophir Munk [this message]
2020-06-17 10:13 ` [dpdk-dev] [PATCH v1 0/4] mlx5 MR refactor Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200616094446.7152-5-ophirmu@mellanox.com \
    --to=ophirmu@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=rasland@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).