From: Michael Baum <michaelba@nvidia.com>
To: <dev@dpdk.org>
Cc: Matan Azrad <matan@nvidia.com>,
Raslan Darawsheh <rasland@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH 1/6] common/mlx5: glue device and PD importation
Date: Tue, 22 Feb 2022 23:04:11 +0200 [thread overview]
Message-ID: <20220222210416.2669519-2-michaelba@nvidia.com> (raw)
In-Reply-To: <20220222210416.2669519-1-michaelba@nvidia.com>
Add support for rdma-core API to import device.
The API gets ibv_context file descriptor and returns an ibv_context
pointer that is associated with the given file descriptor.
Add also support for rdma-core API to import PD.
The API gets ibv_context and PD handle and returns a protection domain
(PD) that is associated with the given handle in the given context.
Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
drivers/common/mlx5/linux/meson.build | 2 ++
drivers/common/mlx5/linux/mlx5_glue.c | 41 +++++++++++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.h | 4 +++
3 files changed, 47 insertions(+)
diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 4c7b53b9bd..ed48245c67 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -202,6 +202,8 @@ has_sym_args = [
'mlx5dv_dr_domain_allow_duplicate_rules' ],
[ 'HAVE_MLX5_IBV_REG_MR_IOVA', 'infiniband/verbs.h',
'ibv_reg_mr_iova' ],
+ [ 'HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR', 'infiniband/verbs.h',
+ 'ibv_import_device' ],
]
config = configuration_data()
foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index bc6622053f..450dd6a06a 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -34,6 +34,32 @@ mlx5_glue_dealloc_pd(struct ibv_pd *pd)
return ibv_dealloc_pd(pd);
}
+static struct ibv_pd *
+mlx5_glue_import_pd(struct ibv_context *context, uint32_t pd_handle)
+{
+#ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
+ return ibv_import_pd(context, pd_handle);
+#else
+ (void)context;
+ (void)pd_handle;
+ errno = ENOTSUP;
+ return NULL;
+#endif
+}
+
+static int
+mlx5_glue_unimport_pd(struct ibv_pd *pd)
+{
+#ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
+ ibv_unimport_pd(pd);
+ return 0;
+#else
+ (void)pd;
+ errno = ENOTSUP;
+ return -errno;
+#endif
+}
+
static struct ibv_device **
mlx5_glue_get_device_list(int *num_devices)
{
@@ -52,6 +78,18 @@ mlx5_glue_open_device(struct ibv_device *device)
return ibv_open_device(device);
}
+static struct ibv_context *
+mlx5_glue_import_device(int cmd_fd)
+{
+#ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
+ return ibv_import_device(cmd_fd);
+#else
+ (void)cmd_fd;
+ errno = ENOTSUP;
+ return NULL;
+#endif
+}
+
static int
mlx5_glue_close_device(struct ibv_context *context)
{
@@ -1402,9 +1440,12 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
.fork_init = mlx5_glue_fork_init,
.alloc_pd = mlx5_glue_alloc_pd,
.dealloc_pd = mlx5_glue_dealloc_pd,
+ .import_pd = mlx5_glue_import_pd,
+ .unimport_pd = mlx5_glue_unimport_pd,
.get_device_list = mlx5_glue_get_device_list,
.free_device_list = mlx5_glue_free_device_list,
.open_device = mlx5_glue_open_device,
+ .import_device = mlx5_glue_import_device,
.close_device = mlx5_glue_close_device,
.query_device = mlx5_glue_query_device,
.query_device_ex = mlx5_glue_query_device_ex,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 4e6d31f263..c4903a6dce 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -151,9 +151,13 @@ struct mlx5_glue {
int (*fork_init)(void);
struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
int (*dealloc_pd)(struct ibv_pd *pd);
+ struct ibv_pd *(*import_pd)(struct ibv_context *context,
+ uint32_t pd_handle);
+ int (*unimport_pd)(struct ibv_pd *pd);
struct ibv_device **(*get_device_list)(int *num_devices);
void (*free_device_list)(struct ibv_device **list);
struct ibv_context *(*open_device)(struct ibv_device *device);
+ struct ibv_context *(*import_device)(int cmd_fd);
int (*close_device)(struct ibv_context *context);
int (*query_device)(struct ibv_context *context,
struct ibv_device_attr *device_attr);
--
2.25.1
next prev parent reply other threads:[~2022-02-22 21:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 21:04 [PATCH 0/6] mlx5: external RxQ support Michael Baum
2022-02-22 21:04 ` Michael Baum [this message]
2022-02-22 21:04 ` [PATCH 2/6] common/mlx5: add remote PD and CTX support Michael Baum
2022-02-22 21:04 ` [PATCH 3/6] net/mlx5: optimize RxQ/TxQ control structure Michael Baum
2022-02-22 21:04 ` [PATCH 4/6] net/mlx5: add external RxQ mapping API Michael Baum
2022-02-22 21:04 ` [PATCH 5/6] net/mlx5: support queue/RSS action for external RxQ Michael Baum
2022-02-22 21:04 ` [PATCH 6/6] app/testpmd: add test " Michael Baum
2022-02-23 18:48 ` [PATCH v2 0/6] mlx5: external RxQ support Michael Baum
2022-02-23 18:48 ` [PATCH v2 1/6] common/mlx5: consider local functions as internal Michael Baum
2022-02-23 18:48 ` [PATCH v2 2/6] common/mlx5: glue device and PD importation Michael Baum
2022-02-23 18:48 ` [PATCH v2 3/6] common/mlx5: add remote PD and CTX support Michael Baum
2022-02-23 18:48 ` [PATCH v2 4/6] net/mlx5: optimize RxQ/TxQ control structure Michael Baum
2022-02-23 18:48 ` [PATCH v2 5/6] net/mlx5: add external RxQ mapping API Michael Baum
2022-02-23 18:48 ` [PATCH v2 6/6] net/mlx5: support queue/RSS action for external RxQ Michael Baum
2022-02-24 8:38 ` [PATCH v2 0/6] mlx5: external RxQ support Matan Azrad
2022-02-24 23:25 ` [PATCH v3 " Michael Baum
2022-02-24 23:25 ` [PATCH v3 1/6] common/mlx5: consider local functions as internal Michael Baum
2022-02-25 18:01 ` Ferruh Yigit
2022-02-25 18:38 ` Thomas Monjalon
2022-02-25 19:13 ` Ferruh Yigit
2022-02-24 23:25 ` [PATCH v3 2/6] common/mlx5: glue device and PD importation Michael Baum
2022-02-24 23:25 ` [PATCH v3 3/6] common/mlx5: add remote PD and CTX support Michael Baum
2022-02-24 23:25 ` [PATCH v3 4/6] net/mlx5: optimize RxQ/TxQ control structure Michael Baum
2022-02-24 23:25 ` [PATCH v3 5/6] net/mlx5: add external RxQ mapping API Michael Baum
2022-02-24 23:25 ` [PATCH v3 6/6] net/mlx5: support queue/RSS action for external RxQ Michael Baum
2022-02-25 17:39 ` [PATCH v3 0/6] mlx5: external RxQ support Thomas Monjalon
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=20220222210416.2669519-2-michaelba@nvidia.com \
--to=michaelba@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=rasland@nvidia.com \
--cc=viacheslavo@nvidia.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).