[2/8] common/mlx5: glue for default miss and sample action

Message ID 1593102379-400132-3-git-send-email-jiaweiw@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series support the flow-based traffic sampling |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jiawei Wang June 25, 2020, 4:26 p.m. UTC
  rdma-core introduce two new DR action: default miss and sample
action.

Add the rdma-core commands in glue to create these two actions.

Default miss action is used for the sampled packet on FDB domain,
it steering packet to eswitch manager vport.

Sample action is used for creating the sample object to implement
the sampling/mirroring function.

Signed-off-by: Jiawei Wang <jiaweiw@mellanox.com>
---
 drivers/common/mlx5/Makefile          | 10 ++++++++++
 drivers/common/mlx5/linux/meson.build |  4 ++++
 drivers/common/mlx5/linux/mlx5_glue.c | 28 ++++++++++++++++++++++++++++
 drivers/common/mlx5/linux/mlx5_glue.h | 13 +++++++++++++
 4 files changed, 55 insertions(+)
  

Comments

Ori Kam June 30, 2020, 3:25 p.m. UTC | #1
> -----Original Message-----
> From: Jiawei Wang <jiaweiw@mellanox.com>
> Sent: Thursday, June 25, 2020 7:26 PM
> To: Ori Kam <orika@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; Matan Azrad <matan@mellanox.com>
> Cc: dev@dpdk.org; Thomas Monjalon <thomas@monjalon.net>; Raslan
> Darawsheh <rasland@mellanox.com>; ian.stokes@intel.com; fbl@redhat.com;
> Jiawei(Jonny) Wang <jiaweiw@mellanox.com>
> Subject: [PATCH 2/8] common/mlx5: glue for default miss and sample action
> 
> rdma-core introduce two new DR action: default miss and sample
> action.
> 
> Add the rdma-core commands in glue to create these two actions.
> 
> Default miss action is used for the sampled packet on FDB domain,
> it steering packet to eswitch manager vport.
> 
> Sample action is used for creating the sample object to implement
> the sampling/mirroring function.
> 
> Signed-off-by: Jiawei Wang <jiaweiw@mellanox.com>
> ---
>  drivers/common/mlx5/Makefile          | 10 ++++++++++
>  drivers/common/mlx5/linux/meson.build |  4 ++++
>  drivers/common/mlx5/linux/mlx5_glue.c | 28
> ++++++++++++++++++++++++++++
>  drivers/common/mlx5/linux/mlx5_glue.h | 13 +++++++++++++
>  4 files changed, 55 insertions(+)
> 
> diff --git a/drivers/common/mlx5/Makefile b/drivers/common/mlx5/Makefile
> index 622bde4..8db0604 100644
> --- a/drivers/common/mlx5/Makefile
> +++ b/drivers/common/mlx5/Makefile
> @@ -187,6 +187,16 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-
> config-h.sh
>  		func mlx5dv_dump_dr_domain \
>  		$(AUTOCONF_OUTPUT)
>  	$Q sh -- '$<' '$@' \
> +		HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS \
> +		infiniband/mlx5dv.h \
> +		func mlx5dv_dr_action_create_default_miss \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
> +		HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE \
> +		infiniband/mlx5dv.h \
> +		func mlx5dv_dr_action_create_flow_sampler \
> +		$(AUTOCONF_OUTPUT)
> +	$Q sh -- '$<' '$@' \
>  		HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD \
>  		infiniband/mlx5dv.h \
>  		enum MLX5_MMAP_GET_NC_PAGES_CMD \
> diff --git a/drivers/common/mlx5/linux/meson.build
> b/drivers/common/mlx5/linux/meson.build
> index 638bb2b..95f3204 100644
> --- a/drivers/common/mlx5/linux/meson.build
> +++ b/drivers/common/mlx5/linux/meson.build
> @@ -160,6 +160,10 @@ has_sym_args = [
>  	'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
>  	[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
>  	'mlx5dv_dump_dr_domain'],
> +	[ 'HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS',
> 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_default_miss'],
> +	[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE',
> 'infiniband/mlx5dv.h',
> +	'mlx5dv_dr_action_create_flow_sampler'],
>  	[ 'HAVE_MLX5DV_DR_MEM_RECLAIM', 'infiniband/mlx5dv.h',
>  	'mlx5dv_dr_domain_set_reclaim_device_memory'],
>  	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
> diff --git a/drivers/common/mlx5/linux/mlx5_glue.c
> b/drivers/common/mlx5/linux/mlx5_glue.c
> index c91ee33..ea366e2 100644
> --- a/drivers/common/mlx5/linux/mlx5_glue.c
> +++ b/drivers/common/mlx5/linux/mlx5_glue.c
> @@ -1047,6 +1047,30 @@
>  #endif
>  }
> 
> +static void *
> +mlx5_glue_dr_create_flow_action_default_miss(void)
> +{
> +#ifdef HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS
> +	return mlx5dv_dr_action_create_default_miss();
> +#else
> +	errno = ENOTSUP;
> +	return NULL;
> +#endif
> +}
> +
> +static void *
> +mlx5_glue_dr_create_flow_action_sampler(
> +			struct mlx5dv_dr_flow_sampler_attr *attr)
> +{
> +#ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
> +	return mlx5dv_dr_action_create_flow_sampler(attr);
> +#else
> +	(void)attr;
> +	errno = ENOTSUP;
> +	return NULL;
> +#endif
> +}
> +
>  static int
>  mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
>  			 uint32_t *eqn)
> @@ -1294,6 +1318,10 @@
>  	.devx_port_query = mlx5_glue_devx_port_query,
>  	.dr_dump_domain = mlx5_glue_dr_dump_domain,
>  	.dr_reclaim_domain_memory =
> mlx5_glue_dr_reclaim_domain_memory,
> +	.dr_create_flow_action_default_miss =
> +		mlx5_glue_dr_create_flow_action_default_miss,
> +	.dr_create_flow_action_sampler =
> +		mlx5_glue_dr_create_flow_action_sampler,
>  	.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,
> diff --git a/drivers/common/mlx5/linux/mlx5_glue.h
> b/drivers/common/mlx5/linux/mlx5_glue.h
> index 5d238a4..9b1487d 100644
> --- a/drivers/common/mlx5/linux/mlx5_glue.h
> +++ b/drivers/common/mlx5/linux/mlx5_glue.h
> @@ -77,6 +77,7 @@
>  #ifndef HAVE_MLX5DV_DR
>  enum  mlx5dv_dr_domain_type { unused, };
>  struct mlx5dv_dr_domain;
> +struct mlx5dv_dr_action;
>  #endif
> 
>  #ifndef HAVE_MLX5DV_DR_DEVX_PORT
> @@ -87,6 +88,15 @@
>  struct mlx5dv_dr_flow_meter_attr;
>  #endif
> 
> +#ifndef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
> +struct mlx5dv_dr_flow_sampler_attr {
> +	uint32_t sample_ratio;
> +	void *default_next_table;
> +	size_t num_sample_actions;
> +	struct mlx5dv_dr_action **sample_actions;
> +};
> +#endif
> +
>  #ifndef HAVE_IBV_DEVX_EVENT
>  struct mlx5dv_devx_event_channel { int fd; };
>  struct mlx5dv_devx_async_event_hdr;
> @@ -303,6 +313,9 @@ struct mlx5_glue {
>  			 struct mlx5dv_devx_async_event_hdr *event_data,
>  			 size_t event_resp_len);
>  	void (*dr_reclaim_domain_memory)(void *domain, uint32_t enable);
> +	void *(*dr_create_flow_action_default_miss)(void);
> +	void *(*dr_create_flow_action_sampler)
> +			(struct mlx5dv_dr_flow_sampler_attr *attr);
>  };
> 
>  extern const struct mlx5_glue *mlx5_glue;
> --
> 1.8.3.1

Acked-by: Ori Kam <orika@mellanox.com>
Thanks,
Ori
  

Patch

diff --git a/drivers/common/mlx5/Makefile b/drivers/common/mlx5/Makefile
index 622bde4..8db0604 100644
--- a/drivers/common/mlx5/Makefile
+++ b/drivers/common/mlx5/Makefile
@@ -187,6 +187,16 @@  mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		func mlx5dv_dump_dr_domain \
 		$(AUTOCONF_OUTPUT)
 	$Q sh -- '$<' '$@' \
+		HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS \
+		infiniband/mlx5dv.h \
+		func mlx5dv_dr_action_create_default_miss \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE \
+		infiniband/mlx5dv.h \
+		func mlx5dv_dr_action_create_flow_sampler \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
 		HAVE_MLX5DV_MMAP_GET_NC_PAGES_CMD \
 		infiniband/mlx5dv.h \
 		enum MLX5_MMAP_GET_NC_PAGES_CMD \
diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 638bb2b..95f3204 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -160,6 +160,10 @@  has_sym_args = [
 	'RDMA_NLDEV_ATTR_NDEV_INDEX' ],
 	[ 'HAVE_MLX5_DR_FLOW_DUMP', 'infiniband/mlx5dv.h',
 	'mlx5dv_dump_dr_domain'],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_default_miss'],
+	[ 'HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE', 'infiniband/mlx5dv.h',
+	'mlx5dv_dr_action_create_flow_sampler'],
 	[ 'HAVE_MLX5DV_DR_MEM_RECLAIM', 'infiniband/mlx5dv.h',
 	'mlx5dv_dr_domain_set_reclaim_device_memory'],
 	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index c91ee33..ea366e2 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -1047,6 +1047,30 @@ 
 #endif
 }
 
+static void *
+mlx5_glue_dr_create_flow_action_default_miss(void)
+{
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS
+	return mlx5dv_dr_action_create_default_miss();
+#else
+	errno = ENOTSUP;
+	return NULL;
+#endif
+}
+
+static void *
+mlx5_glue_dr_create_flow_action_sampler(
+			struct mlx5dv_dr_flow_sampler_attr *attr)
+{
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
+	return mlx5dv_dr_action_create_flow_sampler(attr);
+#else
+	(void)attr;
+	errno = ENOTSUP;
+	return NULL;
+#endif
+}
+
 static int
 mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
 			 uint32_t *eqn)
@@ -1294,6 +1318,10 @@ 
 	.devx_port_query = mlx5_glue_devx_port_query,
 	.dr_dump_domain = mlx5_glue_dr_dump_domain,
 	.dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
+	.dr_create_flow_action_default_miss =
+		mlx5_glue_dr_create_flow_action_default_miss,
+	.dr_create_flow_action_sampler =
+		mlx5_glue_dr_create_flow_action_sampler,
 	.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,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index 5d238a4..9b1487d 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -77,6 +77,7 @@ 
 #ifndef HAVE_MLX5DV_DR
 enum  mlx5dv_dr_domain_type { unused, };
 struct mlx5dv_dr_domain;
+struct mlx5dv_dr_action;
 #endif
 
 #ifndef HAVE_MLX5DV_DR_DEVX_PORT
@@ -87,6 +88,15 @@ 
 struct mlx5dv_dr_flow_meter_attr;
 #endif
 
+#ifndef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
+struct mlx5dv_dr_flow_sampler_attr {
+	uint32_t sample_ratio;
+	void *default_next_table;
+	size_t num_sample_actions;
+	struct mlx5dv_dr_action **sample_actions;
+};
+#endif
+
 #ifndef HAVE_IBV_DEVX_EVENT
 struct mlx5dv_devx_event_channel { int fd; };
 struct mlx5dv_devx_async_event_hdr;
@@ -303,6 +313,9 @@  struct mlx5_glue {
 			 struct mlx5dv_devx_async_event_hdr *event_data,
 			 size_t event_resp_len);
 	void (*dr_reclaim_domain_memory)(void *domain, uint32_t enable);
+	void *(*dr_create_flow_action_default_miss)(void);
+	void *(*dr_create_flow_action_sampler)
+			(struct mlx5dv_dr_flow_sampler_attr *attr);
 };
 
 extern const struct mlx5_glue *mlx5_glue;