[v4,1/4] net/mlx5: add flow action functions to glue

Message ID 1539160531-27953-2-git-send-email-dekelp@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Shahaf Shuler
Headers
Series add support of Direct Verbs encap and decap actions |

Checks

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

Commit Message

Dekel Peled Oct. 10, 2018, 8:35 a.m. UTC
  This patch adds glue functions for operations:
- Create packet reformat (encap/decap) flow action.
- Destroy flow action.

The new operations depend on HAVE_IBV_FLOW_ACTION_DV_SUPPORT.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/Makefile    |  5 +++++
 drivers/net/mlx5/meson.build |  2 ++
 drivers/net/mlx5/mlx5_glue.c | 38 ++++++++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_glue.h | 13 +++++++++++++
 4 files changed, 58 insertions(+)
  

Comments

Yongseok Koh Oct. 10, 2018, 9:22 p.m. UTC | #1
On Wed, Oct 10, 2018 at 11:35:28AM +0300, Dekel Peled wrote:
> This patch adds glue functions for operations:
> - Create packet reformat (encap/decap) flow action.
> - Destroy flow action.
> 
> The new operations depend on HAVE_IBV_FLOW_ACTION_DV_SUPPORT.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  drivers/net/mlx5/Makefile    |  5 +++++
>  drivers/net/mlx5/meson.build |  2 ++
>  drivers/net/mlx5/mlx5_glue.c | 38 ++++++++++++++++++++++++++++++++++++++
>  drivers/net/mlx5/mlx5_glue.h | 13 +++++++++++++
>  4 files changed, 58 insertions(+)
> 
> diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
> index 92bae9d..474ad42 100644
> --- a/drivers/net/mlx5/Makefile
> +++ b/drivers/net/mlx5/Makefile
> @@ -142,6 +142,11 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
>  		enum MLX5DV_FLOW_ACTION_TAG \
>  		$(AUTOCONF_OUTPUT)
>  	$Q sh -- '$<' '$@' \
> +		HAVE_IBV_FLOW_ACTION_DV_SUPPORT \
> +		infiniband/mlx5dv.h \
> +		func mlx5dv_create_flow_action_packet_reformat \
> +		$(AUTOCONF_OUTPUT)

I thought you also added this macro to the code in mlx5_flow_dv.c but you
didn't. My original concern was about a case where DV is supported
(HAVE_IBV_FLOW_DV_SUPPORT) but the new flow action
(HAVE_IBV_FLOW_ACTION_DV_SUPPORT) isn't supported. Your code won't be compiled
in such a chase.

There's one more option to consider, which is much simpler. You can change the
HAVE_IBV_FLOW_DV_SUPPORT to check the new function.

	$Q sh -- '$<' '$@' \
		HAVE_IBV_FLOW_DV_SUPPORT \
		infiniband/mlx5dv.h \
		func mlx5dv_create_flow_action_packet_reformat \
		$(AUTOCONF_OUTPUT)

If we don't need to support two different versions of library, (or there could
be only one version supporting both), it isn't necessary to have two separate
macros. Let's take it offline to talk to lib/ker team.


Thanks,
Yongseok

> +	$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 6966248..d555c3c 100644
> --- a/drivers/net/mlx5/meson.build
> +++ b/drivers/net/mlx5/meson.build
> @@ -96,6 +96,8 @@ if build
>  		'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
>  		[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
>  		'MLX5DV_FLOW_ACTION_TAG' ],
> +		[ 'HAVE_IBV_FLOW_ACTION_DV_SUPPORT', 'infiniband/mlx5dv.h',
> +		'mlx5dv_create_flow_action_packet_reformat' ],
>  		[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
>  		'IBV_FLOW_SPEC_MPLS' ],
>  		[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
  

Patch

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index 92bae9d..474ad42 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -142,6 +142,11 @@  mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		enum MLX5DV_FLOW_ACTION_TAG \
 		$(AUTOCONF_OUTPUT)
 	$Q sh -- '$<' '$@' \
+		HAVE_IBV_FLOW_ACTION_DV_SUPPORT \
+		infiniband/mlx5dv.h \
+		func mlx5dv_create_flow_action_packet_reformat \
+		$(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 6966248..d555c3c 100644
--- a/drivers/net/mlx5/meson.build
+++ b/drivers/net/mlx5/meson.build
@@ -96,6 +96,8 @@  if build
 		'MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP' ],
 		[ 'HAVE_IBV_FLOW_DV_SUPPORT', 'infiniband/mlx5dv.h',
 		'MLX5DV_FLOW_ACTION_TAG' ],
+		[ 'HAVE_IBV_FLOW_ACTION_DV_SUPPORT', 'infiniband/mlx5dv.h',
+		'mlx5dv_create_flow_action_packet_reformat' ],
 		[ 'HAVE_IBV_DEVICE_MPLS_SUPPORT', 'infiniband/verbs.h',
 		'IBV_FLOW_SPEC_MPLS' ],
 		[ 'HAVE_IBV_WQ_FLAG_RX_END_PADDING', 'infiniband/verbs.h',
diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
index 48590df..c9b747e 100644
--- a/drivers/net/mlx5/mlx5_glue.c
+++ b/drivers/net/mlx5/mlx5_glue.c
@@ -174,6 +174,17 @@ 
 	return ibv_destroy_flow(flow_id);
 }
 
+static int
+mlx5_glue_destroy_flow_action(struct ibv_flow_action *action)
+{
+#ifdef HAVE_IBV_FLOW_ACTION_DV_SUPPORT
+	return ibv_destroy_flow_action(action);
+#else
+	(void)action;
+	return ENOTSUP;
+#endif
+}
+
 static struct ibv_qp *
 mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
 {
@@ -388,6 +399,30 @@ 
 #endif
 }
 
+static struct ibv_flow_action *
+mlx5_glue_dv_create_flow_action_packet_reformat
+		(struct ibv_context *ctx,
+		 size_t data_sz,
+		 void *data,
+		 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
+		 enum mlx5dv_flow_table_type ft_type)
+{
+#ifdef HAVE_IBV_FLOW_ACTION_DV_SUPPORT
+	return mlx5dv_create_flow_action_packet_reformat(ctx,
+							 data_sz,
+							 data,
+							 reformat_type,
+							 ft_type);
+#else
+	(void)ctx;
+	(void)data_sz;
+	(void)data;
+	(void)reformat_type;
+	(void)ft_type;
+	return NULL;
+#endif
+}
+
 alignas(RTE_CACHE_LINE_SIZE)
 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
 	.version = MLX5_GLUE_VERSION,
@@ -414,6 +449,7 @@ 
 	.modify_wq = mlx5_glue_modify_wq,
 	.create_flow = mlx5_glue_create_flow,
 	.destroy_flow = mlx5_glue_destroy_flow,
+	.destroy_flow_action = mlx5_glue_destroy_flow_action,
 	.create_qp = mlx5_glue_create_qp,
 	.create_qp_ex = mlx5_glue_create_qp_ex,
 	.destroy_qp = mlx5_glue_destroy_qp,
@@ -437,4 +473,6 @@ 
 	.dv_create_flow_matcher = mlx5_glue_dv_create_flow_matcher,
 	.dv_destroy_flow_matcher = mlx5_glue_dv_destroy_flow_matcher,
 	.dv_create_flow = mlx5_glue_dv_create_flow,
+	.dv_create_flow_action_packet_reformat =
+			mlx5_glue_dv_create_flow_action_packet_reformat,
 };
diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h
index f6e4e38..dce6bb4 100644
--- a/drivers/net/mlx5/mlx5_glue.h
+++ b/drivers/net/mlx5/mlx5_glue.h
@@ -46,6 +46,12 @@ 
 struct mlx5dv_flow_match_parameters;
 #endif
 
+#ifndef HAVE_IBV_FLOW_ACTION_DV_SUPPORT
+struct ibv_flow_action;
+enum mlx5dv_flow_action_packet_reformat_type { packet_reformat_type = 0, };
+enum mlx5dv_flow_table_type { flow_table_type = 0, };
+#endif
+
 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
 struct mlx5_glue {
 	const char *version;
@@ -85,6 +91,7 @@  struct mlx5_glue {
 	struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
 					struct ibv_flow_attr *flow);
 	int (*destroy_flow)(struct ibv_flow *flow_id);
+	int (*destroy_flow_action)(struct ibv_flow_action *action);
 	struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
 				    struct ibv_qp_init_attr *qp_init_attr);
 	struct ibv_qp *(*create_qp_ex)
@@ -137,6 +144,12 @@  struct mlx5_glue {
 			  struct mlx5dv_flow_match_parameters *match_value,
 			  size_t num_actions,
 			  struct mlx5dv_flow_action_attr *actions_attr);
+	struct ibv_flow_action *(*dv_create_flow_action_packet_reformat)
+		(struct ibv_context *ctx,
+		 size_t data_sz,
+		 void *data,
+		 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
+		 enum mlx5dv_flow_table_type ft_type);
 };
 
 const struct mlx5_glue *mlx5_glue;