netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/mlx5e: Support accept action on nic table
@ 2019-12-10 14:49 xiangxia.m.yue
  2019-12-10 23:11 ` Mark Bloch
  2019-12-17 19:50 ` Saeed Mahameed
  0 siblings, 2 replies; 3+ messages in thread
From: xiangxia.m.yue @ 2019-12-10 14:49 UTC (permalink / raw)
  To: markb, saeedm; +Cc: netdev, Tonghao Zhang

From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

In one case, we may forward packets from one vport
to others, but only one packets flow will be accepted,
which destination ip was assign to VF.

+-----+     +-----+            +-----+
| VFn |     | VF1 |            | VF0 | accept
+--+--+     +--+--+  hairpin   +--^--+
   |           | <--------------- |
   |           |                  |
+--+-----------v-+             +--+-------------+
|   eswitch PF1  |             |   eswitch PF0  |
+----------------+             +----------------+

tc filter add dev $PF0 protocol all parent ffff: prio 1 handle 1 \
	flower skip_sw action mirred egress redirect dev $VF0_REP
tc filter add dev $VF0 protocol ip  parent ffff: prio 1 handle 1 \
	flower skip_sw dst_ip $VF0_IP action pass
tc filter add dev $VF0 protocol all parent ffff: prio 2 handle 2 \
	flower skip_sw action mirred egress redirect dev $VF1

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 0d5d84b..f91e057e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -2839,6 +2839,10 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
 
 	flow_action_for_each(i, act, flow_action) {
 		switch (act->id) {
+		case FLOW_ACTION_ACCEPT:
+			action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
+				  MLX5_FLOW_CONTEXT_ACTION_COUNT;
+			break;
 		case FLOW_ACTION_DROP:
 			action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
 			if (MLX5_CAP_FLOWTABLE(priv->mdev,
-- 
1.8.3.1


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

* Re: [PATCH net-next] net/mlx5e: Support accept action on nic table
  2019-12-10 14:49 [PATCH net-next] net/mlx5e: Support accept action on nic table xiangxia.m.yue
@ 2019-12-10 23:11 ` Mark Bloch
  2019-12-17 19:50 ` Saeed Mahameed
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Bloch @ 2019-12-10 23:11 UTC (permalink / raw)
  To: xiangxia.m.yue, saeedm, Roi Dayan; +Cc: netdev



On 12/10/19 6:49 AM, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> In one case, we may forward packets from one vport
> to others, but only one packets flow will be accepted,
> which destination ip was assign to VF.
> 
> +-----+     +-----+            +-----+
> | VFn |     | VF1 |            | VF0 | accept
> +--+--+     +--+--+  hairpin   +--^--+
>    |           | <--------------- |
>    |           |                  |
> +--+-----------v-+             +--+-------------+
> |   eswitch PF1  |             |   eswitch PF0  |
> +----------------+             +----------------+
> 
> tc filter add dev $PF0 protocol all parent ffff: prio 1 handle 1 \
> 	flower skip_sw action mirred egress redirect dev $VF0_REP
> tc filter add dev $VF0 protocol ip  parent ffff: prio 1 handle 1 \
> 	flower skip_sw dst_ip $VF0_IP action pass
> tc filter add dev $VF0 protocol all parent ffff: prio 2 handle 2 \
> 	flower skip_sw action mirred egress redirect dev $VF1
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 0d5d84b..f91e057e 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -2839,6 +2839,10 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
>  
>  	flow_action_for_each(i, act, flow_action) {
>  		switch (act->id) {
> +		case FLOW_ACTION_ACCEPT:
> +			action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
> +				  MLX5_FLOW_CONTEXT_ACTION_COUNT;
> +			break;
>  		case FLOW_ACTION_DROP:
>  			action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
>  			if (MLX5_CAP_FLOWTABLE(priv->mdev,
> 

Roi once Saeed takes it, can you please make sure we are adding a test for this flow?
a (very) simple (basic) way to verify this flow is to do something like this:

1) move both PFs into switchdev

VF0_PF0=ens4f2
VF0_PF0_REP=ens4f0_0
VF0_PF1=ens4f5
VF0_PF1_REP=ens4f1_0

ethtool -K VF0_PF0 hw-tc-offload on
tc filter add dev VF0_PF0 protocol ip parent ffff: prio 1 handle 1 flower skip_sw dst_ip 1.1.1.1 action pass
tc filter add dev VF0_PF0 protocol ip parent ffff: prio 2 handle 2 flower skip_sw action mirred egress redirect dev VF0_PF1
ifconfig VF0_PF0_REP 1.1.1.2
arp -s 1.1.1.1 ec:0d:9a:d4:2e:14
arp -s 1.1.1.3 ec:0d:9a:d4:2e:24

Now if you try to ping 1.1.1.1 you should see packets on VF0_PF0
if you try to ping 1.1.1.3 you should see packets on VF0_PF1_REP

Reviewed-by: Mark Bloch <markb@mellanox.com>

Mark

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

* Re: [PATCH net-next] net/mlx5e: Support accept action on nic table
  2019-12-10 14:49 [PATCH net-next] net/mlx5e: Support accept action on nic table xiangxia.m.yue
  2019-12-10 23:11 ` Mark Bloch
@ 2019-12-17 19:50 ` Saeed Mahameed
  1 sibling, 0 replies; 3+ messages in thread
From: Saeed Mahameed @ 2019-12-17 19:50 UTC (permalink / raw)
  To: saeedm, Mark Bloch, xiangxia.m.yue; +Cc: netdev

On Tue, 2019-12-10 at 22:49 +0800, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> In one case, we may forward packets from one vport
> to others, but only one packets flow will be accepted,
> which destination ip was assign to VF.
> 
> +-----+     +-----+            +-----+
> > VFn |     | VF1 |            | VF0 | accept
> +--+--+     +--+--+  hairpin   +--^--+
>    |           | <--------------- |
>    |           |                  |
> +--+-----------v-+             +--+-------------+
> >   eswitch PF1  |             |   eswitch PF0  |
> +----------------+             +----------------+
> 
> tc filter add dev $PF0 protocol all parent ffff: prio 1 handle 1 \
> 	flower skip_sw action mirred egress redirect dev $VF0_REP
> tc filter add dev $VF0 protocol ip  parent ffff: prio 1 handle 1 \
> 	flower skip_sw dst_ip $VF0_IP action pass
> tc filter add dev $VF0 protocol all parent ffff: prio 2 handle 2 \
> 	flower skip_sw action mirred egress redirect dev $VF1
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 0d5d84b..f91e057e 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -2839,6 +2839,10 @@ static int parse_tc_nic_actions(struct
> mlx5e_priv *priv,
>  
>  	flow_action_for_each(i, act, flow_action) {
>  		switch (act->id) {
> +		case FLOW_ACTION_ACCEPT:
> +			action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
> +				  MLX5_FLOW_CONTEXT_ACTION_COUNT;
> +			break;
>  		case FLOW_ACTION_DROP:
>  			action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
>  			if (MLX5_CAP_FLOWTABLE(priv->mdev,

Applied to net-next-mlx5, will submit to net-next soon.
thanks a lot

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

end of thread, other threads:[~2019-12-17 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 14:49 [PATCH net-next] net/mlx5e: Support accept action on nic table xiangxia.m.yue
2019-12-10 23:11 ` Mark Bloch
2019-12-17 19:50 ` Saeed Mahameed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).