Skip to content

Commit 4f4edcc

Browse files
Awik84Saeed Mahameed
authored andcommitted
net/mlx5: E-Switch, Add ovs internal port mapping to metadata support
Adding infrastructure to map ovs internal port device to vport match metadata to support offload of rules with internal port as the filter device or as the destination device. The infrastructure allows adding and removing internal port device to an eswitch database and getting a unique vport metadata value to be placed and match on in reg_c0 when offloading rules that are coming from or going to an internal port. The new int port metadata can be written to the source port register in HW to indicate that current source port of the packet is the internal port and not one of the actual HW vports (uplink or VF). Using this method, it is possible to offload TC rules with an OVS internal port as their destination port (overwriting the src vport register) or as the filter port (matching on the value of the src vport register and making sure it matches to the internal port's value). There is also a need to handle a miss case where the packet's src port value was changed in HW to an internal port but a following rule which matches on this new src port value wasn't found in HW. In such case, the packet will be forwarded to the driver with metadata which allows driver to restore the info of the internal port's netdevice. Once this info is restored, the uplink driver can forward the packet to the relevant netdevice in SW. Signed-off-by: Ariel Levkovich <lariel@nvidia.com> Reviewed-by: Vlad Buslov <vladbu@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 189ce08 commit 4f4edcc

File tree

11 files changed

+607
-9
lines changed

11 files changed

+607
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \
4545
esw/indir_table.o en/tc_tun_encap.o \
4646
en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \
4747
en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o \
48-
en/tc/post_act.o
48+
en/tc/post_act.o en/tc/int_port.o
4949
mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o
5050
mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
5151

drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "lib/port_tun.h"
2121
#include "en/tc/sample.h"
2222
#include "en_accel/ipsec_rxtx.h"
23+
#include "en/tc/int_port.h"
2324

2425
struct mlx5e_rep_indr_block_priv {
2526
struct net_device *netdev;
@@ -672,12 +673,43 @@ static void mlx5e_restore_skb_sample(struct mlx5e_priv *priv, struct sk_buff *sk
672673
mlx5_rep_tc_post_napi_receive(tc_priv);
673674
}
674675

676+
static bool mlx5e_restore_skb_int_port(struct mlx5e_priv *priv, struct sk_buff *skb,
677+
struct mlx5_mapped_obj *mapped_obj,
678+
struct mlx5e_tc_update_priv *tc_priv,
679+
bool *forward_tx,
680+
u32 reg_c1)
681+
{
682+
u32 tunnel_id = (reg_c1 >> ESW_TUN_OFFSET) & TUNNEL_ID_MASK;
683+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
684+
struct mlx5_rep_uplink_priv *uplink_priv;
685+
struct mlx5e_rep_priv *uplink_rpriv;
686+
687+
/* Tunnel restore takes precedence over int port restore */
688+
if (tunnel_id)
689+
return mlx5e_restore_tunnel(priv, skb, tc_priv, tunnel_id);
690+
691+
uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
692+
uplink_priv = &uplink_rpriv->uplink_priv;
693+
694+
if (mlx5e_tc_int_port_dev_fwd(uplink_priv->int_port_priv, skb,
695+
mapped_obj->int_port_metadata, forward_tx)) {
696+
/* Set fwd_dev for future dev_put */
697+
tc_priv->fwd_dev = skb->dev;
698+
699+
return true;
700+
}
701+
702+
return false;
703+
}
704+
675705
void mlx5e_rep_tc_receive(struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq,
676706
struct sk_buff *skb)
677707
{
708+
u32 reg_c1 = be32_to_cpu(cqe->ft_metadata);
678709
struct mlx5e_tc_update_priv tc_priv = {};
679710
struct mlx5_mapped_obj mapped_obj;
680711
struct mlx5_eswitch *esw;
712+
bool forward_tx = false;
681713
struct mlx5e_priv *priv;
682714
u32 reg_c0;
683715
int err;
@@ -702,21 +734,26 @@ void mlx5e_rep_tc_receive(struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq,
702734
}
703735

704736
if (mapped_obj.type == MLX5_MAPPED_OBJ_CHAIN) {
705-
u32 reg_c1 = be32_to_cpu(cqe->ft_metadata);
706-
707737
if (!mlx5e_restore_skb_chain(skb, mapped_obj.chain, reg_c1, &tc_priv) &&
708738
!mlx5_ipsec_is_rx_flow(cqe))
709739
goto free_skb;
710740
} else if (mapped_obj.type == MLX5_MAPPED_OBJ_SAMPLE) {
711741
mlx5e_restore_skb_sample(priv, skb, &mapped_obj, &tc_priv);
712742
goto free_skb;
743+
} else if (mapped_obj.type == MLX5_MAPPED_OBJ_INT_PORT_METADATA) {
744+
if (!mlx5e_restore_skb_int_port(priv, skb, &mapped_obj, &tc_priv,
745+
&forward_tx, reg_c1))
746+
goto free_skb;
713747
} else {
714748
netdev_dbg(priv->netdev, "Invalid mapped object type: %d\n", mapped_obj.type);
715749
goto free_skb;
716750
}
717751

718752
forward:
719-
napi_gro_receive(rq->cq.napi, skb);
753+
if (forward_tx)
754+
dev_queue_xmit(skb);
755+
else
756+
napi_gro_receive(rq->cq.napi, skb);
720757

721758
mlx5_rep_tc_post_napi_receive(&tc_priv);
722759

drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static inline int
6464
mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
6565
void *type_data) { return -EOPNOTSUPP; }
6666

67-
struct mlx5e_tc_update_priv;
6867
static inline void
6968
mlx5e_rep_tc_receive(struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq,
7069
struct sk_buff *skb) {}

0 commit comments

Comments
 (0)