[v2,1/4] net/mlx5: add flow action functions to glue
Checks
Commit Message
This patch adds glue functions for operations:
- Create packet reformat (encap/decap) flow action.
- Destroy flow action.
Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
drivers/net/mlx5/mlx5_glue.c | 33 +++++++++++++++++++++++++++++++++
drivers/net/mlx5/mlx5_glue.h | 9 +++++++++
2 files changed, 42 insertions(+)
Comments
On Sun, Oct 07, 2018 at 05:25:05PM +0300, Dekel Peled wrote:
> This patch adds glue functions for operations:
> - Create packet reformat (encap/decap) flow action.
> - Destroy flow action.
>
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
I'm not still able to compile this patch on my host, which is RH7.4 with MOFED
MLNX_OFED_LINUX-4.4-2.0.4.0.
> drivers/net/mlx5/mlx5_glue.c | 33 +++++++++++++++++++++++++++++++++
> drivers/net/mlx5/mlx5_glue.h | 9 +++++++++
> 2 files changed, 42 insertions(+)
>
> diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
> index 48590df..caa4c34 100644
> --- a/drivers/net/mlx5/mlx5_glue.c
> +++ b/drivers/net/mlx5/mlx5_glue.c
> @@ -174,6 +174,12 @@
> return ibv_destroy_flow(flow_id);
> }
>
> +static int
> +mlx5_glue_destroy_flow_action(struct ibv_flow_action *action)
> +{
> + return ibv_destroy_flow_action(action);
> +}
Shouldn't this be under HAVE_IBV_FLOW_DV_SUPPORT? My host doesn't have it either
- ibv_destroy_flow_action() and ibv_flow_action.
> +
> static struct ibv_qp *
> mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
> {
> @@ -388,6 +394,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_DV_SUPPORT
I don't think your change can be protected by this. According to the git logs of
rdma-core, HAVE_IBV_FLOW_DV_SUPPORT is to mark the following patch of Yishai
Hadas,
mlx5: Introduce mlx5dv_create_flow
While, the flow action has been added by another patchset of Mark Bloch later,
mlx5: Add packet reformat flow action
So, it seems to need another macro, doesn't it?
E.g. 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 +444,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 +468,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..8ef4fcc 100644
> --- a/drivers/net/mlx5/mlx5_glue.h
> +++ b/drivers/net/mlx5/mlx5_glue.h
> @@ -44,6 +44,8 @@
> struct mlx5dv_flow_matcher_attr;
> struct mlx5dv_flow_action_attr;
> struct mlx5dv_flow_match_parameters;
> +enum mlx5dv_flow_action_packet_reformat_type;
> +enum mlx5dv_flow_table_type;
> #endif
>
> /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
> @@ -85,6 +87,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 +140,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;
> --
> 1.8.3.1
>
Thanks, PSB.
> -----Original Message-----
> From: Yongseok Koh
> Sent: Monday, October 8, 2018 10:43 PM
> To: Dekel Peled <dekelp@mellanox.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>; dev@dpdk.org; Ori Kam
> <orika@mellanox.com>
> Subject: Re: [PATCH v2 1/4] net/mlx5: add flow action functions to glue
>
> On Sun, Oct 07, 2018 at 05:25:05PM +0300, Dekel Peled wrote:
> > This patch adds glue functions for operations:
> > - Create packet reformat (encap/decap) flow action.
> > - Destroy flow action.
> >
> > Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> > ---
>
> I'm not still able to compile this patch on my host, which is RH7.4 with MOFED
> MLNX_OFED_LINUX-4.4-2.0.4.0.
>
> > drivers/net/mlx5/mlx5_glue.c | 33
> +++++++++++++++++++++++++++++++++
> > drivers/net/mlx5/mlx5_glue.h | 9 +++++++++
> > 2 files changed, 42 insertions(+)
> >
> > diff --git a/drivers/net/mlx5/mlx5_glue.c
> > b/drivers/net/mlx5/mlx5_glue.c index 48590df..caa4c34 100644
> > --- a/drivers/net/mlx5/mlx5_glue.c
> > +++ b/drivers/net/mlx5/mlx5_glue.c
> > @@ -174,6 +174,12 @@
> > return ibv_destroy_flow(flow_id);
> > }
> >
> > +static int
> > +mlx5_glue_destroy_flow_action(struct ibv_flow_action *action) {
> > + return ibv_destroy_flow_action(action); }
>
> Shouldn't this be under HAVE_IBV_FLOW_DV_SUPPORT? My host doesn't
> have it either
> - ibv_destroy_flow_action() and ibv_flow_action.
>
> > +
> > static struct ibv_qp *
> > mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr
> > *qp_init_attr) { @@ -388,6 +394,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_DV_SUPPORT
>
> I don't think your change can be protected by this. According to the git logs of
> rdma-core, HAVE_IBV_FLOW_DV_SUPPORT is to mark the following patch of
> Yishai Hadas,
>
> mlx5: Introduce mlx5dv_create_flow
>
> While, the flow action has been added by another patchset of Mark Bloch
> later,
>
> mlx5: Add packet reformat flow action
>
> So, it seems to need another macro, doesn't it?
> E.g. HAVE_IBV_FLOW_ACTION_DV_SUPPORT
Will add it according to your suggestion.
>
> > + 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 +444,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 +468,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..8ef4fcc 100644
> > --- a/drivers/net/mlx5/mlx5_glue.h
> > +++ b/drivers/net/mlx5/mlx5_glue.h
> > @@ -44,6 +44,8 @@
> > struct mlx5dv_flow_matcher_attr;
> > struct mlx5dv_flow_action_attr;
> > struct mlx5dv_flow_match_parameters;
> > +enum mlx5dv_flow_action_packet_reformat_type;
> > +enum mlx5dv_flow_table_type;
> > #endif
> >
> > /* LIB_GLUE_VERSION must be updated every time this structure is
> > modified. */ @@ -85,6 +87,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 +140,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;
> > --
> > 1.8.3.1
> >
@@ -174,6 +174,12 @@
return ibv_destroy_flow(flow_id);
}
+static int
+mlx5_glue_destroy_flow_action(struct ibv_flow_action *action)
+{
+ return ibv_destroy_flow_action(action);
+}
+
static struct ibv_qp *
mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
{
@@ -388,6 +394,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_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 +444,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 +468,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,
};
@@ -44,6 +44,8 @@
struct mlx5dv_flow_matcher_attr;
struct mlx5dv_flow_action_attr;
struct mlx5dv_flow_match_parameters;
+enum mlx5dv_flow_action_packet_reformat_type;
+enum mlx5dv_flow_table_type;
#endif
/* LIB_GLUE_VERSION must be updated every time this structure is modified. */
@@ -85,6 +87,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 +140,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;