DPDK patches and discussions
 help / color / mirror / Atom feed
From: Mordechay Haimovsky <motih@mellanox.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Cc: Mordechay Haimovsky <motih@mellanox.com>
Subject: [dpdk-dev] [PATCH v1 2/3] net/mlx5: add devx functions to glue
Date: Tue, 25 Dec 2018 14:38:43 +0000	[thread overview]
Message-ID: <1545748697-3385-3-git-send-email-motih@mellanox.com> (raw)
In-Reply-To: <1545748697-3385-1-git-send-email-motih@mellanox.com>

This patch adds glue functions for operations:
  - dv_open_device.
  - devx object create, destroy, query and modify.
  - devx general command
The new operations depend on HAVE_IBV_DEVX_OBJ.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx5/Makefile    |  5 +++
 drivers/net/mlx5/meson.build |  2 +
 drivers/net/mlx5/mlx5_glue.c | 99 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_glue.h | 19 +++++++++
 4 files changed, 125 insertions(+)

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index 895cdfe..58e2d15 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -148,6 +148,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		func mlx5dv_create_flow_action_packet_reformat \
 		$(AUTOCONF_OUTPUT)
 	$Q sh -- '$<' '$@' \
+		HAVE_IBV_DEVX_OBJ \
+		infiniband/mlx5dv.h \
+		func mlx5dv_devx_obj_create \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
 		HAVE_ETHTOOL_LINK_MODE_25G \
 		/usr/include/linux/ethtool.h \
 		enum ETHTOOL_LINK_MODE_25000baseCR_Full_BIT \
diff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build
index 28938db..e323c3a 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -104,6 +104,8 @@ if build
 		'IBV_FLOW_SPEC_MPLS' ],
 		[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
 		'IBV_WQ_FLAG_RX_END_PADDING' ],
+		[ 'HAVE_IBV_DEVX_OBJ', 'infiniband/mlx5dv.h',
+		'mlx5dv_devx_obj_create' ],
 		[ 'HAVE_SUPPORTED_40000baseKR4_Full', 'linux/ethtool.h',
 		'SUPPORTED_40000baseKR4_Full' ],
 		[ 'HAVE_SUPPORTED_40000baseCR4_Full', 'linux/ethtool.h',
diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
index dd10ad6..7d3d9d3 100644
--- a/drivers/net/mlx5/mlx5_glue.c
+++ b/drivers/net/mlx5/mlx5_glue.c
@@ -479,6 +479,99 @@
 #endif
 }
 
+static struct ibv_context *
+mlx5_glue_dv_open_device(struct ibv_device *device)
+{
+#ifdef HAVE_IBV_DEVX_OBJ
+	return mlx5dv_open_device(device,
+				  &(struct mlx5dv_context_attr){
+					.flags = MLX5DV_CONTEXT_FLAGS_DEVX,
+				  });
+#else
+	(void)device;
+	return NULL;
+#endif
+}
+
+static struct mlx5dv_devx_obj *
+mlx5_glue_devx_obj_create(struct ibv_context *ctx,
+			  const void *in, size_t inlen,
+			  void *out, size_t outlen)
+{
+#ifdef HAVE_IBV_DEVX_OBJ
+	return mlx5dv_devx_obj_create(ctx, in, inlen, out, outlen);
+#else
+	(void)ctx;
+	(void)in;
+	(void)inlen;
+	(void)out;
+	(void)outlen;
+	return NULL;
+#endif
+}
+
+static int
+mlx5_glue_devx_obj_destroy(struct mlx5dv_devx_obj *obj)
+{
+#ifdef HAVE_IBV_DEVX_OBJ
+	return mlx5dv_devx_obj_destroy(obj);
+#else
+	(void)obj;
+	return -ENOTSUP;
+#endif
+}
+
+static int
+mlx5_glue_devx_obj_query(struct mlx5dv_devx_obj *obj,
+			 const void *in, size_t inlen,
+			 void *out, size_t outlen)
+{
+#ifdef HAVE_IBV_DEVX_OBJ
+	return mlx5dv_devx_obj_query(obj, in, inlen, out, outlen);
+#else
+	(void)obj;
+	(void)in;
+	(void)inlen;
+	(void)out;
+	(void)outlen;
+	return -ENOTSUP;
+#endif
+}
+
+static int
+mlx5_glue_devx_obj_modify(struct mlx5dv_devx_obj *obj,
+			  const void *in, size_t inlen,
+			  void *out, size_t outlen)
+{
+#ifdef HAVE_IBV_DEVX_OBJ
+	return mlx5dv_devx_obj_modify(obj, in, inlen, out, outlen);
+#else
+	(void)obj;
+	(void)in;
+	(void)inlen;
+	(void)out;
+	(void)outlen;
+	return -ENOTSUP;
+#endif
+}
+
+static int
+mlx5_glue_devx_general_cmd(struct ibv_context *ctx,
+			   const void *in, size_t inlen,
+			   void *out, size_t outlen)
+{
+#ifdef HAVE_IBV_DEVX_OBJ
+	return mlx5dv_devx_general_cmd(ctx, in, inlen, out, outlen);
+#else
+	(void)ctx;
+	(void)in;
+	(void)inlen;
+	(void)out;
+	(void)outlen;
+	return -ENOTSUP;
+#endif
+}
+
 alignas(RTE_CACHE_LINE_SIZE)
 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
 	.version = MLX5_GLUE_VERSION,
@@ -535,4 +628,10 @@
 	.dv_create_flow = mlx5_glue_dv_create_flow,
 	.dv_create_flow_action_packet_reformat =
 			mlx5_glue_dv_create_flow_action_packet_reformat,
+	.dv_open_device = mlx5_glue_dv_open_device,
+	.devx_obj_create = mlx5_glue_devx_obj_create,
+	.devx_obj_destroy = mlx5_glue_devx_obj_destroy,
+	.devx_obj_query = mlx5_glue_devx_obj_query,
+	.devx_obj_modify = mlx5_glue_devx_obj_modify,
+	.devx_general_cmd = mlx5_glue_devx_general_cmd,
 };
diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h
index 2d92ba8..a6cd2cd 100644
--- a/drivers/net/mlx5/mlx5_glue.h
+++ b/drivers/net/mlx5/mlx5_glue.h
@@ -55,6 +55,10 @@
 enum mlx5dv_flow_table_type { flow_table_type = 0, };
 #endif
 
+#ifndef HAVE_IBV_DEVX_OBJ
+struct mlx5dv_devx_obj;
+#endif
+
 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
 struct mlx5_glue {
 	const char *version;
@@ -164,6 +168,21 @@ struct mlx5_glue {
 		 void *data,
 		 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
 		 enum mlx5dv_flow_table_type ft_type);
+	struct ibv_context *(*dv_open_device)(struct ibv_device *device);
+	struct mlx5dv_devx_obj *(*devx_obj_create)
+					(struct ibv_context *ctx,
+					 const void *in, size_t inlen,
+					 void *out, size_t outlen);
+	int (*devx_obj_destroy)(struct mlx5dv_devx_obj *obj);
+	int (*devx_obj_query)(struct mlx5dv_devx_obj *obj,
+			      const void *in, size_t inlen,
+			      void *out, size_t outlen);
+	int (*devx_obj_modify)(struct mlx5dv_devx_obj *obj,
+			       const void *in, size_t inlen,
+			       void *out, size_t outlen);
+	int (*devx_general_cmd)(struct ibv_context *context,
+				const void *in, size_t inlen,
+				void *out, size_t outlen);
 };
 
 const struct mlx5_glue *mlx5_glue;
-- 
1.8.3.1

  parent reply	other threads:[~2018-12-25 14:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-25 14:38 [dpdk-dev] [PATCH v1 0/3] support flow counters using devx Mordechay Haimovsky
2018-12-25 14:38 ` [dpdk-dev] [PATCH v1 1/3] net/mlx5: modify shared counter allocation logic Mordechay Haimovsky
2018-12-27  8:12   ` Shahaf Shuler
2018-12-25 14:38 ` Mordechay Haimovsky [this message]
2018-12-27  8:12   ` [dpdk-dev] [PATCH v1 2/3] net/mlx5: add devx functions to glue Shahaf Shuler
2018-12-25 14:38 ` [dpdk-dev] [PATCH v1 3/3] net/mlx5: support flow counters using devx Mordechay Haimovsky
2018-12-27  8:15   ` Shahaf Shuler
2018-12-27 22:20   ` [dpdk-dev] [PATCH v2 0/3] " Mordechay Haimovsky
2018-12-27 22:20   ` [dpdk-dev] [PATCH v2 1/3] net/mlx5: fix shared counter allocation logic Mordechay Haimovsky
2018-12-29 20:12     ` Slava Ovsiienko
2018-12-31  7:23       ` Shahaf Shuler
2019-01-02  6:58       ` Mordechay Haimovsky
2018-12-27 22:20   ` [dpdk-dev] [PATCH v2 2/3] net/mlx5: add devx functions to glue Mordechay Haimovsky
2018-12-27 22:20   ` [dpdk-dev] [PATCH v2 3/3] net/mlx5: support flow counters using devx Mordechay Haimovsky
2019-01-02  9:43     ` [dpdk-dev] [PATCH v3 0/3] " Mordechay Haimovsky
2019-01-02  9:43     ` [dpdk-dev] [PATCH v3 2/3] net/mlx5: add devx functions to glue Mordechay Haimovsky
2019-01-02  9:43     ` [dpdk-dev] [PATCH v3 1/3] net/mlx5: fix shared counter allocation logic Mordechay Haimovsky
2019-01-02  9:43     ` [dpdk-dev] [PATCH v3 3/3] net/mlx5: support flow counters using devx Mordechay Haimovsky
2019-01-03  8:29       ` Shahaf Shuler
2019-01-03 15:06       ` [dpdk-dev] [PATCH v4 0/3] " Mordechay Haimovsky
2019-01-06  7:43         ` Shahaf Shuler
2019-01-03 15:06       ` [dpdk-dev] [PATCH v4 1/3] net/mlx5: fix shared counter allocation logic Mordechay Haimovsky
2019-01-03 15:06       ` [dpdk-dev] [PATCH v4 2/3] net/mlx5: add devx functions to glue Mordechay Haimovsky
2019-01-03 15:06       ` [dpdk-dev] [PATCH v4 3/3] net/mlx5: support flow counters using devx Mordechay Haimovsky

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=1545748697-3385-3-git-send-email-motih@mellanox.com \
    --to=motih@mellanox.com \
    --cc=dev@dpdk.org \
    /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).