All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v5 0/2] net/mlx5e: add indr block support in the FT mode
@ 2020-03-23 23:44 wenxu
  2020-03-23 23:44 ` [PATCH net-next v5 1/2] net/mlx5e: refactor indr setup block wenxu
  2020-03-23 23:44 ` [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support wenxu
  0 siblings, 2 replies; 6+ messages in thread
From: wenxu @ 2020-03-23 23:44 UTC (permalink / raw)
  To: saeedm; +Cc: paulb, vladbu, netdev

From: wenxu <wenxu@ucloud.cn>

Indr block supported in FT mode can offload the tunnel device in the
flowtables of nftable.

The netfilter patches:
http://patchwork.ozlabs.org/cover/1242812/

Test with mlx driver as following with nft:

ip link add user1 type vrf table 1
ip l set user1 up 
ip l set dev mlx_pf0vf0 down
ip l set dev mlx_pf0vf0 master user1
ifconfig mlx_pf0vf0 10.0.0.1/24 up

ifconfig mlx_p0 172.168.152.75/24 up

ip l add dev tun1 type gretap key 1000
ip l set dev tun1 master user1
ifconfig tun1 10.0.1.1/24 up

ip r r 10.0.1.241 encap ip id 1000 dst 172.168.152.241 key dev tun1 table 1

nft add table firewall
nft add chain firewall zones { type filter hook prerouting priority - 300 \; }
nft add rule firewall zones counter ct zone set iif map { "tun1" : 1, "mlx_pf0vf0" : 1 }
nft add chain firewall rule-1000-ingress
nft add rule firewall rule-1000-ingress ct zone 1 ct state established,related counter accept
nft add rule firewall rule-1000-ingress ct zone 1 ct state invalid counter drop
nft add rule firewall rule-1000-ingress ct zone 1 tcp dport 5001 ct state new counter accept
nft add rule firewall rule-1000-ingress ct zone 1 udp dport 5001 ct state new counter accept
nft add rule firewall rule-1000-ingress ct zone 1 tcp dport 22 ct state new counter accept
nft add rule firewall rule-1000-ingress ct zone 1 ip protocol icmp ct state new counter accept
nft add rule firewall rule-1000-ingress counter drop
nft add chain firewall rules-all { type filter hook prerouting priority - 150 \; }
nft add rule firewall rules-all meta iifkind "vrf" counter accept
nft add rule firewall rules-all iif vmap { "tun1" : jump rule-1000-ingress }

nft add flowtable firewall fb1 { hook ingress priority 2 \; devices = { tun1, mlx_pf0vf0 } \; }
nft add chain firewall ftb-all {type filter hook forward priority 0 \; policy accept \; }
nft add rule firewall ftb-all ct zone 1 ip protocol tcp flow offload @fb1
nft add rule firewall ftb-all ct zone 1 ip protocol udp flow offload @fb1


wenxu (2):
  net/mlx5e: refactor indr setup block
  net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support

 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 94 ++++++++++++++++++------
 1 file changed, 73 insertions(+), 21 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next v5 1/2] net/mlx5e: refactor indr setup block
  2020-03-23 23:44 [PATCH net-next v5 0/2] net/mlx5e: add indr block support in the FT mode wenxu
@ 2020-03-23 23:44 ` wenxu
  2020-03-23 23:44 ` [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support wenxu
  1 sibling, 0 replies; 6+ messages in thread
From: wenxu @ 2020-03-23 23:44 UTC (permalink / raw)
  To: saeedm; +Cc: paulb, vladbu, netdev

From: wenxu <wenxu@ucloud.cn>

Refactor indr setup block for support ft indr setup in the
next patch. IThe function mlx5e_rep_indr_offload exposes
'flags' in order set additional flag for FT in next patch.
Rename mlx5e_rep_indr_setup_tc_block to mlx5e_rep_indr_setup_block
and add flow_setup_cb_t callback parameters in order set the
specific callback for FT in next patch.

Signed-off-by: wenxu <wenxu@ucloud.cn>
---
v5: change the comments

 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 42 ++++++++++++------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index a33d151..057f5f9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -694,9 +694,9 @@ static void mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv)
 static int
 mlx5e_rep_indr_offload(struct net_device *netdev,
 		       struct flow_cls_offload *flower,
-		       struct mlx5e_rep_indr_block_priv *indr_priv)
+		       struct mlx5e_rep_indr_block_priv *indr_priv,
+		       unsigned long flags)
 {
-	unsigned long flags = MLX5_TC_FLAG(EGRESS) | MLX5_TC_FLAG(ESW_OFFLOAD);
 	struct mlx5e_priv *priv = netdev_priv(indr_priv->rpriv->netdev);
 	int err = 0;
 
@@ -717,20 +717,22 @@ static void mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv)
 	return err;
 }
 
-static int mlx5e_rep_indr_setup_block_cb(enum tc_setup_type type,
-					 void *type_data, void *indr_priv)
+static int mlx5e_rep_indr_setup_tc_cb(enum tc_setup_type type,
+				      void *type_data, void *indr_priv)
 {
+	unsigned long flags = MLX5_TC_FLAG(EGRESS) | MLX5_TC_FLAG(ESW_OFFLOAD);
 	struct mlx5e_rep_indr_block_priv *priv = indr_priv;
 
 	switch (type) {
 	case TC_SETUP_CLSFLOWER:
-		return mlx5e_rep_indr_offload(priv->netdev, type_data, priv);
+		return mlx5e_rep_indr_offload(priv->netdev, type_data, priv,
+					      flags);
 	default:
 		return -EOPNOTSUPP;
 	}
 }
 
-static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv)
+static void mlx5e_rep_indr_block_unbind(void *cb_priv)
 {
 	struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv;
 
@@ -741,9 +743,10 @@ static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv)
 static LIST_HEAD(mlx5e_block_cb_list);
 
 static int
-mlx5e_rep_indr_setup_tc_block(struct net_device *netdev,
-			      struct mlx5e_rep_priv *rpriv,
-			      struct flow_block_offload *f)
+mlx5e_rep_indr_setup_block(struct net_device *netdev,
+			   struct mlx5e_rep_priv *rpriv,
+			   struct flow_block_offload *f,
+			   flow_setup_cb_t *setup_cb)
 {
 	struct mlx5e_rep_indr_block_priv *indr_priv;
 	struct flow_block_cb *block_cb;
@@ -769,9 +772,8 @@ static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv)
 		list_add(&indr_priv->list,
 			 &rpriv->uplink_priv.tc_indr_block_priv_list);
 
-		block_cb = flow_block_cb_alloc(mlx5e_rep_indr_setup_block_cb,
-					       indr_priv, indr_priv,
-					       mlx5e_rep_indr_tc_block_unbind);
+		block_cb = flow_block_cb_alloc(setup_cb, indr_priv, indr_priv,
+					       mlx5e_rep_indr_block_unbind);
 		if (IS_ERR(block_cb)) {
 			list_del(&indr_priv->list);
 			kfree(indr_priv);
@@ -786,9 +788,7 @@ static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv)
 		if (!indr_priv)
 			return -ENOENT;
 
-		block_cb = flow_block_cb_lookup(f->block,
-						mlx5e_rep_indr_setup_block_cb,
-						indr_priv);
+		block_cb = flow_block_cb_lookup(f->block, setup_cb, indr_priv);
 		if (!block_cb)
 			return -ENOENT;
 
@@ -802,13 +802,13 @@ static void mlx5e_rep_indr_tc_block_unbind(void *cb_priv)
 }
 
 static
-int mlx5e_rep_indr_setup_tc_cb(struct net_device *netdev, void *cb_priv,
-			       enum tc_setup_type type, void *type_data)
+int mlx5e_rep_indr_setup_cb(struct net_device *netdev, void *cb_priv,
+			    enum tc_setup_type type, void *type_data)
 {
 	switch (type) {
 	case TC_SETUP_BLOCK:
-		return mlx5e_rep_indr_setup_tc_block(netdev, cb_priv,
-						      type_data);
+		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
+						  mlx5e_rep_indr_setup_tc_cb);
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -820,7 +820,7 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv,
 	int err;
 
 	err = __flow_indr_block_cb_register(netdev, rpriv,
-					    mlx5e_rep_indr_setup_tc_cb,
+					    mlx5e_rep_indr_setup_cb,
 					    rpriv);
 	if (err) {
 		struct mlx5e_priv *priv = netdev_priv(rpriv->netdev);
@@ -834,7 +834,7 @@ static int mlx5e_rep_indr_register_block(struct mlx5e_rep_priv *rpriv,
 static void mlx5e_rep_indr_unregister_block(struct mlx5e_rep_priv *rpriv,
 					    struct net_device *netdev)
 {
-	__flow_indr_block_cb_unregister(netdev, mlx5e_rep_indr_setup_tc_cb,
+	__flow_indr_block_cb_unregister(netdev, mlx5e_rep_indr_setup_cb,
 					rpriv);
 }
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support
  2020-03-23 23:44 [PATCH net-next v5 0/2] net/mlx5e: add indr block support in the FT mode wenxu
  2020-03-23 23:44 ` [PATCH net-next v5 1/2] net/mlx5e: refactor indr setup block wenxu
@ 2020-03-23 23:44 ` wenxu
  2020-03-24 12:05   ` Vlad Buslov
  1 sibling, 1 reply; 6+ messages in thread
From: wenxu @ 2020-03-23 23:44 UTC (permalink / raw)
  To: saeedm; +Cc: paulb, vladbu, netdev

From: wenxu <wenxu@ucloud.cn>

Add mlx5e_rep_indr_setup_ft_cb to support indr block setup
in FT mode.

Signed-off-by: wenxu <wenxu@ucloud.cn>
---
v5: no change

 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 52 ++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 057f5f9..30c81c3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -732,6 +732,55 @@ static int mlx5e_rep_indr_setup_tc_cb(enum tc_setup_type type,
 	}
 }
 
+static int mlx5e_rep_indr_setup_ft_cb(enum tc_setup_type type,
+				      void *type_data, void *indr_priv)
+{
+	struct mlx5e_rep_indr_block_priv *priv = indr_priv;
+	struct flow_cls_offload *f = type_data;
+	struct flow_cls_offload tmp;
+	struct mlx5e_priv *mpriv;
+	struct mlx5_eswitch *esw;
+	unsigned long flags;
+	int err;
+
+	mpriv = netdev_priv(priv->rpriv->netdev);
+	esw = mpriv->mdev->priv.eswitch;
+
+	flags = MLX5_TC_FLAG(EGRESS) |
+		MLX5_TC_FLAG(ESW_OFFLOAD) |
+		MLX5_TC_FLAG(FT_OFFLOAD);
+
+	switch (type) {
+	case TC_SETUP_CLSFLOWER:
+		memcpy(&tmp, f, sizeof(*f));
+
+		if (!mlx5_esw_chains_prios_supported(esw))
+			return -EOPNOTSUPP;
+
+		/* Re-use tc offload path by moving the ft flow to the
+		 * reserved ft chain.
+		 *
+		 * FT offload can use prio range [0, INT_MAX], so we normalize
+		 * it to range [1, mlx5_esw_chains_get_prio_range(esw)]
+		 * as with tc, where prio 0 isn't supported.
+		 *
+		 * We only support chain 0 of FT offload.
+		 */
+		if (tmp.common.prio >= mlx5_esw_chains_get_prio_range(esw))
+			return -EOPNOTSUPP;
+		if (tmp.common.chain_index != 0)
+			return -EOPNOTSUPP;
+
+		tmp.common.chain_index = mlx5_esw_chains_get_ft_chain(esw);
+		tmp.common.prio++;
+		err = mlx5e_rep_indr_offload(priv->netdev, &tmp, priv, flags);
+		memcpy(&f->stats, &tmp.stats, sizeof(f->stats));
+		return err;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static void mlx5e_rep_indr_block_unbind(void *cb_priv)
 {
 	struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv;
@@ -809,6 +858,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, void *cb_priv,
 	case TC_SETUP_BLOCK:
 		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
 						  mlx5e_rep_indr_setup_tc_cb);
+	case TC_SETUP_FT:
+		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
+						  mlx5e_rep_indr_setup_ft_cb);
 	default:
 		return -EOPNOTSUPP;
 	}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support
  2020-03-23 23:44 ` [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support wenxu
@ 2020-03-24 12:05   ` Vlad Buslov
  2020-03-24 12:49     ` wenxu
  0 siblings, 1 reply; 6+ messages in thread
From: Vlad Buslov @ 2020-03-24 12:05 UTC (permalink / raw)
  To: wenxu; +Cc: saeedm, paulb, vladbu, netdev


On Tue 24 Mar 2020 at 01:44, wenxu@ucloud.cn wrote:
> From: wenxu <wenxu@ucloud.cn>
>
> Add mlx5e_rep_indr_setup_ft_cb to support indr block setup
> in FT mode.
>
> Signed-off-by: wenxu <wenxu@ucloud.cn>
> ---
> v5: no change
>
>  drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 52 ++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> index 057f5f9..30c81c3 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
> @@ -732,6 +732,55 @@ static int mlx5e_rep_indr_setup_tc_cb(enum tc_setup_type type,
>  	}
>  }
>
> +static int mlx5e_rep_indr_setup_ft_cb(enum tc_setup_type type,
> +				      void *type_data, void *indr_priv)
> +{
> +	struct mlx5e_rep_indr_block_priv *priv = indr_priv;
> +	struct flow_cls_offload *f = type_data;
> +	struct flow_cls_offload tmp;
> +	struct mlx5e_priv *mpriv;
> +	struct mlx5_eswitch *esw;
> +	unsigned long flags;
> +	int err;
> +
> +	mpriv = netdev_priv(priv->rpriv->netdev);
> +	esw = mpriv->mdev->priv.eswitch;
> +
> +	flags = MLX5_TC_FLAG(EGRESS) |
> +		MLX5_TC_FLAG(ESW_OFFLOAD) |
> +		MLX5_TC_FLAG(FT_OFFLOAD);
> +
> +	switch (type) {
> +	case TC_SETUP_CLSFLOWER:
> +		memcpy(&tmp, f, sizeof(*f));
> +
> +		if (!mlx5_esw_chains_prios_supported(esw))
> +			return -EOPNOTSUPP;
> +
> +		/* Re-use tc offload path by moving the ft flow to the
> +		 * reserved ft chain.
> +		 *
> +		 * FT offload can use prio range [0, INT_MAX], so we normalize
> +		 * it to range [1, mlx5_esw_chains_get_prio_range(esw)]
> +		 * as with tc, where prio 0 isn't supported.
> +		 *
> +		 * We only support chain 0 of FT offload.
> +		 */
> +		if (tmp.common.prio >= mlx5_esw_chains_get_prio_range(esw))
> +			return -EOPNOTSUPP;
> +		if (tmp.common.chain_index != 0)
> +			return -EOPNOTSUPP;
> +
> +		tmp.common.chain_index = mlx5_esw_chains_get_ft_chain(esw);
> +		tmp.common.prio++;
> +		err = mlx5e_rep_indr_offload(priv->netdev, &tmp, priv, flags);
> +		memcpy(&f->stats, &tmp.stats, sizeof(f->stats));

Why do you need to create temporary copy of flow_cls_offload struct and
then copy parts of tmp back to the original? Again, this info should
probably be in the commit message.

> +		return err;
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +}
> +
>  static void mlx5e_rep_indr_block_unbind(void *cb_priv)
>  {
>  	struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv;
> @@ -809,6 +858,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, void *cb_priv,
>  	case TC_SETUP_BLOCK:
>  		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
>  						  mlx5e_rep_indr_setup_tc_cb);
> +	case TC_SETUP_FT:
> +		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
> +						  mlx5e_rep_indr_setup_ft_cb);
>  	default:
>  		return -EOPNOTSUPP;
>  	}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support
  2020-03-24 12:05   ` Vlad Buslov
@ 2020-03-24 12:49     ` wenxu
  2020-03-24 14:36       ` Vlad Buslov
  0 siblings, 1 reply; 6+ messages in thread
From: wenxu @ 2020-03-24 12:49 UTC (permalink / raw)
  To: Vlad Buslov; +Cc: saeedm, paulb, netdev


在 2020/3/24 20:05, Vlad Buslov 写道:
> On Tue 24 Mar 2020 at 01:44, wenxu@ucloud.cn wrote:
>> From: wenxu <wenxu@ucloud.cn>
>>
>> Add mlx5e_rep_indr_setup_ft_cb to support indr block setup
>> in FT mode.
>>
>> Signed-off-by: wenxu <wenxu@ucloud.cn>
>> ---
>> v5: no change
>>
>>   drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 52 ++++++++++++++++++++++++
>>   1 file changed, 52 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
>> index 057f5f9..30c81c3 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
>> @@ -732,6 +732,55 @@ static int mlx5e_rep_indr_setup_tc_cb(enum tc_setup_type type,
>>   	}
>>   }
>>
>> +static int mlx5e_rep_indr_setup_ft_cb(enum tc_setup_type type,
>> +				      void *type_data, void *indr_priv)
>> +{
>> +	struct mlx5e_rep_indr_block_priv *priv = indr_priv;
>> +	struct flow_cls_offload *f = type_data;
>> +	struct flow_cls_offload tmp;
>> +	struct mlx5e_priv *mpriv;
>> +	struct mlx5_eswitch *esw;
>> +	unsigned long flags;
>> +	int err;
>> +
>> +	mpriv = netdev_priv(priv->rpriv->netdev);
>> +	esw = mpriv->mdev->priv.eswitch;
>> +
>> +	flags = MLX5_TC_FLAG(EGRESS) |
>> +		MLX5_TC_FLAG(ESW_OFFLOAD) |
>> +		MLX5_TC_FLAG(FT_OFFLOAD);
>> +
>> +	switch (type) {
>> +	case TC_SETUP_CLSFLOWER:
>> +		memcpy(&tmp, f, sizeof(*f));
>> +
>> +		if (!mlx5_esw_chains_prios_supported(esw))
>> +			return -EOPNOTSUPP;
>> +
>> +		/* Re-use tc offload path by moving the ft flow to the
>> +		 * reserved ft chain.
>> +		 *
>> +		 * FT offload can use prio range [0, INT_MAX], so we normalize
>> +		 * it to range [1, mlx5_esw_chains_get_prio_range(esw)]
>> +		 * as with tc, where prio 0 isn't supported.
>> +		 *
>> +		 * We only support chain 0 of FT offload.
>> +		 */
>> +		if (tmp.common.prio >= mlx5_esw_chains_get_prio_range(esw))
>> +			return -EOPNOTSUPP;
>> +		if (tmp.common.chain_index != 0)
>> +			return -EOPNOTSUPP;
>> +
>> +		tmp.common.chain_index = mlx5_esw_chains_get_ft_chain(esw);
>> +		tmp.common.prio++;
>> +		err = mlx5e_rep_indr_offload(priv->netdev, &tmp, priv, flags);
>> +		memcpy(&f->stats, &tmp.stats, sizeof(f->stats));
> Why do you need to create temporary copy of flow_cls_offload struct and
> then copy parts of tmp back to the original? Again, this info should
> probably be in the commit message.

This FT mode using the specficed chain_index which changed by driver adnd

using only in driver. It will move the flow table rules to their 
steering domain.

This scenario just follow the mlx5e_rep_setup_ft_cb which did offload in 
FT mode.

So it's an old scenario, Is it necessary to add to the commit message?

>
>> +		return err;
>> +	default:
>> +		return -EOPNOTSUPP;
>> +	}
>> +}
>> +
>>   static void mlx5e_rep_indr_block_unbind(void *cb_priv)
>>   {
>>   	struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv;
>> @@ -809,6 +858,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, void *cb_priv,
>>   	case TC_SETUP_BLOCK:
>>   		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
>>   						  mlx5e_rep_indr_setup_tc_cb);
>> +	case TC_SETUP_FT:
>> +		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
>> +						  mlx5e_rep_indr_setup_ft_cb);
>>   	default:
>>   		return -EOPNOTSUPP;
>>   	}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support
  2020-03-24 12:49     ` wenxu
@ 2020-03-24 14:36       ` Vlad Buslov
  0 siblings, 0 replies; 6+ messages in thread
From: Vlad Buslov @ 2020-03-24 14:36 UTC (permalink / raw)
  To: wenxu; +Cc: Vlad Buslov, saeedm, paulb, netdev


On Tue 24 Mar 2020 at 14:49, wenxu <wenxu@ucloud.cn> wrote:
> 在 2020/3/24 20:05, Vlad Buslov 写道:
>> On Tue 24 Mar 2020 at 01:44, wenxu@ucloud.cn wrote:
>>> From: wenxu <wenxu@ucloud.cn>
>>>
>>> Add mlx5e_rep_indr_setup_ft_cb to support indr block setup
>>> in FT mode.
>>>
>>> Signed-off-by: wenxu <wenxu@ucloud.cn>
>>> ---
>>> v5: no change
>>>
>>>   drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 52 ++++++++++++++++++++++++
>>>   1 file changed, 52 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
>>> index 057f5f9..30c81c3 100644
>>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
>>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
>>> @@ -732,6 +732,55 @@ static int mlx5e_rep_indr_setup_tc_cb(enum tc_setup_type type,
>>>   	}
>>>   }
>>>
>>> +static int mlx5e_rep_indr_setup_ft_cb(enum tc_setup_type type,
>>> +				      void *type_data, void *indr_priv)
>>> +{
>>> +	struct mlx5e_rep_indr_block_priv *priv = indr_priv;
>>> +	struct flow_cls_offload *f = type_data;
>>> +	struct flow_cls_offload tmp;
>>> +	struct mlx5e_priv *mpriv;
>>> +	struct mlx5_eswitch *esw;
>>> +	unsigned long flags;
>>> +	int err;
>>> +
>>> +	mpriv = netdev_priv(priv->rpriv->netdev);
>>> +	esw = mpriv->mdev->priv.eswitch;
>>> +
>>> +	flags = MLX5_TC_FLAG(EGRESS) |
>>> +		MLX5_TC_FLAG(ESW_OFFLOAD) |
>>> +		MLX5_TC_FLAG(FT_OFFLOAD);
>>> +
>>> +	switch (type) {
>>> +	case TC_SETUP_CLSFLOWER:
>>> +		memcpy(&tmp, f, sizeof(*f));
>>> +
>>> +		if (!mlx5_esw_chains_prios_supported(esw))
>>> +			return -EOPNOTSUPP;
>>> +
>>> +		/* Re-use tc offload path by moving the ft flow to the
>>> +		 * reserved ft chain.
>>> +		 *
>>> +		 * FT offload can use prio range [0, INT_MAX], so we normalize
>>> +		 * it to range [1, mlx5_esw_chains_get_prio_range(esw)]
>>> +		 * as with tc, where prio 0 isn't supported.
>>> +		 *
>>> +		 * We only support chain 0 of FT offload.
>>> +		 */
>>> +		if (tmp.common.prio >= mlx5_esw_chains_get_prio_range(esw))
>>> +			return -EOPNOTSUPP;
>>> +		if (tmp.common.chain_index != 0)
>>> +			return -EOPNOTSUPP;
>>> +
>>> +		tmp.common.chain_index = mlx5_esw_chains_get_ft_chain(esw);
>>> +		tmp.common.prio++;
>>> +		err = mlx5e_rep_indr_offload(priv->netdev, &tmp, priv, flags);
>>> +		memcpy(&f->stats, &tmp.stats, sizeof(f->stats));
>> Why do you need to create temporary copy of flow_cls_offload struct and
>> then copy parts of tmp back to the original? Again, this info should
>> probably be in the commit message.
>
> This FT mode using the specficed chain_index which changed by driver adnd
>
> using only in driver. It will move the flow table rules to their steering
> domain.
>
> This scenario just follow the mlx5e_rep_setup_ft_cb which did offload in FT
> mode.
>
> So it's an old scenario, Is it necessary to add to the commit message?

Well, without knowing the reasoning it is hard to understand if the
original scenario is applicable in this case.

>
>>
>>> +		return err;
>>> +	default:
>>> +		return -EOPNOTSUPP;
>>> +	}
>>> +}
>>> +
>>>   static void mlx5e_rep_indr_block_unbind(void *cb_priv)
>>>   {
>>>   	struct mlx5e_rep_indr_block_priv *indr_priv = cb_priv;
>>> @@ -809,6 +858,9 @@ int mlx5e_rep_indr_setup_cb(struct net_device *netdev, void *cb_priv,
>>>   	case TC_SETUP_BLOCK:
>>>   		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
>>>   						  mlx5e_rep_indr_setup_tc_cb);
>>> +	case TC_SETUP_FT:
>>> +		return mlx5e_rep_indr_setup_block(netdev, cb_priv, type_data,
>>> +						  mlx5e_rep_indr_setup_ft_cb);
>>>   	default:
>>>   		return -EOPNOTSUPP;
>>>   	}


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-24 14:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 23:44 [PATCH net-next v5 0/2] net/mlx5e: add indr block support in the FT mode wenxu
2020-03-23 23:44 ` [PATCH net-next v5 1/2] net/mlx5e: refactor indr setup block wenxu
2020-03-23 23:44 ` [PATCH net-next v5 2/2] net/mlx5e: add mlx5e_rep_indr_setup_ft_cb support wenxu
2020-03-24 12:05   ` Vlad Buslov
2020-03-24 12:49     ` wenxu
2020-03-24 14:36       ` Vlad Buslov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.