common/mlx5: glue event interrupt commands
authorMatan Azrad <matan@mellanox.com>
Wed, 29 Jan 2020 12:38:36 +0000 (12:38 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 5 Feb 2020 08:51:20 +0000 (09:51 +0100)
Add the next commands to glue in order to support interrupt event
channel operations associated to events in the EQ:
devx_create_event_channel,
devx_destroy_event_channel,
devx_subscribe_devx_event,
devx_subscribe_devx_event_fd,
devx_get_event.

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/common/mlx5/Makefile
drivers/common/mlx5/meson.build
drivers/common/mlx5/mlx5_glue.c
drivers/common/mlx5/mlx5_glue.h

index 66585b2..7110231 100644 (file)
@@ -153,6 +153,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
                infiniband/mlx5dv.h \
                func mlx5dv_dr_action_create_dest_devx_tir \
                $(AUTOCONF_OUTPUT)
+       $Q sh -- '$<' '$@' \
+               HAVE_IBV_DEVX_EVENT \
+               infiniband/mlx5dv.h \
+               func mlx5dv_devx_get_event \
+               $(AUTOCONF_OUTPUT)
        $Q sh -- '$<' '$@' \
                HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER \
                infiniband/mlx5dv.h \
index 718cef2..76ca7d7 100644 (file)
@@ -108,6 +108,8 @@ if build
                'mlx5dv_devx_obj_query_async' ],
                [ 'HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR', 'infiniband/mlx5dv.h',
                'mlx5dv_dr_action_create_dest_devx_tir' ],
+               [ 'HAVE_IBV_DEVX_EVENT', 'infiniband/mlx5dv.h',
+               'mlx5dv_devx_get_event' ],
                [ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER', 'infiniband/mlx5dv.h',
                'mlx5dv_dr_action_create_flow_meter' ],
                [ 'HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD', 'infiniband/mlx5dv.h',
index fedce77..e4eabdb 100644 (file)
@@ -1063,6 +1063,80 @@ mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
 #endif
 }
 
+static struct mlx5dv_devx_event_channel *
+mlx5_glue_devx_create_event_channel(struct ibv_context *ctx, int flags)
+{
+#ifdef HAVE_IBV_DEVX_EVENT
+       return mlx5dv_devx_create_event_channel(ctx, flags);
+#else
+       (void)ctx;
+       (void)flags;
+       errno = ENOTSUP;
+       return NULL;
+#endif
+}
+
+static void
+mlx5_glue_devx_destroy_event_channel(struct mlx5dv_devx_event_channel *eventc)
+{
+#ifdef HAVE_IBV_DEVX_EVENT
+       mlx5dv_devx_destroy_event_channel(eventc);
+#else
+       (void)eventc;
+#endif
+}
+
+static int
+mlx5_glue_devx_subscribe_devx_event(struct mlx5dv_devx_event_channel *eventc,
+                                   struct mlx5dv_devx_obj *obj,
+                                   uint16_t events_sz, uint16_t events_num[],
+                                   uint64_t cookie)
+{
+#ifdef HAVE_IBV_DEVX_EVENT
+       return mlx5dv_devx_subscribe_devx_event(eventc, obj, events_sz,
+                                               events_num, cookie);
+#else
+       (void)eventc;
+       (void)obj;
+       (void)events_sz;
+       (void)events_num;
+       (void)cookie;
+       return -ENOTSUP;
+#endif
+}
+
+static int
+mlx5_glue_devx_subscribe_devx_event_fd(struct mlx5dv_devx_event_channel *eventc,
+                                      int fd, struct mlx5dv_devx_obj *obj,
+                                      uint16_t event_num)
+{
+#ifdef HAVE_IBV_DEVX_EVENT
+       return mlx5dv_devx_subscribe_devx_event_fd(eventc, fd, obj, event_num);
+#else
+       (void)eventc;
+       (void)fd;
+       (void)obj;
+       (void)event_num;
+       return -ENOTSUP;
+#endif
+}
+
+static ssize_t
+mlx5_glue_devx_get_event(struct mlx5dv_devx_event_channel *eventc,
+                        struct mlx5dv_devx_async_event_hdr *event_data,
+                        size_t event_resp_len)
+{
+#ifdef HAVE_IBV_DEVX_EVENT
+       return mlx5dv_devx_get_event(eventc, event_data, event_resp_len);
+#else
+       (void)eventc;
+       (void)event_data;
+       (void)event_resp_len;
+       errno = ENOTSUP;
+       return -1;
+#endif
+}
+
 alignas(RTE_CACHE_LINE_SIZE)
 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
        .version = MLX5_GLUE_VERSION,
@@ -1163,4 +1237,9 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
        .devx_port_query = mlx5_glue_devx_port_query,
        .dr_dump_domain = mlx5_glue_dr_dump_domain,
        .devx_query_eqn = mlx5_glue_devx_query_eqn,
+       .devx_create_event_channel = mlx5_glue_devx_create_event_channel,
+       .devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
+       .devx_subscribe_devx_event = mlx5_glue_devx_subscribe_devx_event,
+       .devx_subscribe_devx_event_fd = mlx5_glue_devx_subscribe_devx_event_fd,
+       .devx_get_event = mlx5_glue_devx_get_event,
 };
index fe51f97..6fc00dd 100644 (file)
@@ -86,6 +86,12 @@ struct mlx5dv_devx_port;
 struct mlx5dv_dr_flow_meter_attr;
 #endif
 
+#ifndef HAVE_IBV_DEVX_EVENT
+struct mlx5dv_devx_event_channel { int fd; };
+struct mlx5dv_devx_async_event_hdr;
+#define MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA 1
+#endif
+
 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
 struct mlx5_glue {
        const char *version;
@@ -261,6 +267,25 @@ struct mlx5_glue {
        int (*dr_dump_domain)(FILE *file, void *domain);
        int (*devx_query_eqn)(struct ibv_context *context, uint32_t cpus,
                              uint32_t *eqn);
+       struct mlx5dv_devx_event_channel *(*devx_create_event_channel)
+                               (struct ibv_context *context, int flags);
+       void (*devx_destroy_event_channel)
+                       (struct mlx5dv_devx_event_channel *event_channel);
+       int (*devx_subscribe_devx_event)
+                       (struct mlx5dv_devx_event_channel *event_channel,
+                        struct mlx5dv_devx_obj *obj,
+                        uint16_t events_sz,
+                        uint16_t events_num[],
+                        uint64_t cookie);
+       int (*devx_subscribe_devx_event_fd)
+                       (struct mlx5dv_devx_event_channel *event_channel,
+                        int fd,
+                        struct mlx5dv_devx_obj *obj,
+                        uint16_t event_num);
+       ssize_t (*devx_get_event)
+                       (struct mlx5dv_devx_event_channel *event_channel,
+                        struct mlx5dv_devx_async_event_hdr *event_data,
+                        size_t event_resp_len);
 };
 
 const struct mlx5_glue *mlx5_glue;