[v2,13/13] net/mlx5: add source vport match to the ingress rules

Message ID 1553533414-9911-14-git-send-email-viacheslavo@mellanox.com
State Changes Requested, archived
Delegated to: Shahaf Shuler
Headers show
Series
  • net/mlx5: add support for multiport IB devices
Related show

Checks

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

Commit Message

Viacheslav Ovsiienko March 25, 2019, 5:03 p.m.
For E-Switch configurations over multiport Infiniband devices
we should add source vport match to correctly distribute
traffic between representors.

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

Shahaf Shuler March 26, 2019, 12:21 p.m. | #1
Monday, March 25, 2019 7:04 PM, Viacheslav Ovsiienko:
> Subject: [PATCH v2 13/13] net/mlx5: add source vport match to the ingress
> rules
> 
> For E-Switch configurations over multiport Infiniband devices we should add
> source vport match to correctly distribute traffic between representors.
> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow_dv.c | 36
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c index b8943da..67b359f 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -3095,6 +3095,29 @@ struct field_modify_info modify_tcp[] = {  }
> 
>  /**
> + * Add source vport match to the specified matcher.
> + *
> + * @param[in, out] matcher
> + *   Flow matcher.
> + * @param[in, out] key
> + *   Flow matcher value.
> + * @param[in] port
> + *   Source vport value to match
> + * @param[in] mask
> + *   Mask
> + */
> +static void
> +flow_dv_translate_source_vport(void *matcher, void *key,
> +			      int16_t port, uint16_t mask)
> +{
> +	void *misc_m = MLX5_ADDR_OF(fte_match_param, matcher,
> misc_parameters);
> +	void *misc_v = MLX5_ADDR_OF(fte_match_param, key,
> misc_parameters);
> +
> +	MLX5_SET(fte_match_set_misc, misc_m, source_port, mask);
> +	MLX5_SET(fte_match_set_misc, misc_v, source_port, port); }
> +
> +/**
>   * Fill the flow with DV spec.
>   *
>   * @param[in] dev
> @@ -3389,6 +3412,19 @@ struct field_modify_info modify_tcp[] = {
>  	}
>  	dev_flow->dv.actions_n = actions_n;
>  	flow->actions = action_flags;
> +	if (attr->ingress && !attr->transfer &&
> +	    (priv->representor || priv->master)) {
> +		/* It was validated - we support unidirections flows only. */
> +		assert(!attr->egress);
> +		/*
> +		 * Add matching on source vport index only
> +		 * for ingress rules in E-Switch configurations.
> +		 */
> +		flow_dv_translate_source_vport(matcher.mask.buf,
> +					       dev_flow->dv.value.buf,
> +					       priv->representor_id,

Overall looks OK apart from the override of the representor_id. 

> +					       0xffff);
> +	}
>  	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
>  		int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
>  		void *match_mask = matcher.mask.buf;
> --
> 1.8.3.1

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index b8943da..67b359f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -3095,6 +3095,29 @@  struct field_modify_info modify_tcp[] = {
 }
 
 /**
+ * Add source vport match to the specified matcher.
+ *
+ * @param[in, out] matcher
+ *   Flow matcher.
+ * @param[in, out] key
+ *   Flow matcher value.
+ * @param[in] port
+ *   Source vport value to match
+ * @param[in] mask
+ *   Mask
+ */
+static void
+flow_dv_translate_source_vport(void *matcher, void *key,
+			      int16_t port, uint16_t mask)
+{
+	void *misc_m = MLX5_ADDR_OF(fte_match_param, matcher, misc_parameters);
+	void *misc_v = MLX5_ADDR_OF(fte_match_param, key, misc_parameters);
+
+	MLX5_SET(fte_match_set_misc, misc_m, source_port, mask);
+	MLX5_SET(fte_match_set_misc, misc_v, source_port, port);
+}
+
+/**
  * Fill the flow with DV spec.
  *
  * @param[in] dev
@@ -3389,6 +3412,19 @@  struct field_modify_info modify_tcp[] = {
 	}
 	dev_flow->dv.actions_n = actions_n;
 	flow->actions = action_flags;
+	if (attr->ingress && !attr->transfer &&
+	    (priv->representor || priv->master)) {
+		/* It was validated - we support unidirections flows only. */
+		assert(!attr->egress);
+		/*
+		 * Add matching on source vport index only
+		 * for ingress rules in E-Switch configurations.
+		 */
+		flow_dv_translate_source_vport(matcher.mask.buf,
+					       dev_flow->dv.value.buf,
+					       priv->representor_id,
+					       0xffff);
+	}
 	for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
 		int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
 		void *match_mask = matcher.mask.buf;