net/mlx5: add devx functions to glue
authorMoti Haimovsky <motih@mellanox.com>
Thu, 3 Jan 2019 15:06:36 +0000 (15:06 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 Jan 2019 16:44:29 +0000 (17:44 +0100)
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>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
drivers/net/mlx5/Makefile
drivers/net/mlx5/meson.build
drivers/net/mlx5/mlx5_glue.c
drivers/net/mlx5/mlx5_glue.h

index 1353c18..8ddad1a 100644 (file)
@@ -147,6 +147,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
                infiniband/mlx5dv.h \
                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 \
index 8ba19e8..e2fc4ea 100644 (file)
@@ -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',
index a806d92..c817d86 100644 (file)
@@ -498,6 +498,98 @@ mlx5_glue_dv_create_flow_action_modify_header
 #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){
@@ -557,4 +649,10 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
                        mlx5_glue_dv_create_flow_action_packet_reformat,
        .dv_create_flow_action_modify_header =
                        mlx5_glue_dv_create_flow_action_modify_header,
+       .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,
 };
index 9cfe836..b118960 100644 (file)
@@ -55,6 +55,10 @@ enum mlx5dv_flow_action_packet_reformat_type { packet_reformat_type = 0, };
 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;
@@ -169,6 +173,21 @@ struct mlx5_glue {
                                         size_t actions_sz,
                                         uint64_t actions[],
                                         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;