Skip to content

Commit 100ad4e

Browse files
Awik84Saeed Mahameed
authored andcommitted
net/mlx5e: Offload internal port as encap route device
When pefroming encap action, a route lookup is performed to find the routing device the packet should be forwarded to after the encapsulation. This is the device that has the local tunnel ip address. This change adds support to offload an encap rule where the route device ends up being an ovs internal port. In such case, the driver will add a HW rule that will encapsulate the packet with the tunnel header and will overwrite the vport metadata in reg_c0 to the internal port metadata value. Finally, the packet will be forwarded to the root table to be processed again with the indication that it came from an internal port. 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 27484f7 commit 100ad4e

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
8383
*/
8484
*route_dev = dev;
8585
if (!netdev_port_same_parent_id(priv->netdev, real_dev) ||
86-
dst_is_lag_dev || is_vlan_dev(*route_dev))
86+
dst_is_lag_dev || is_vlan_dev(*route_dev) ||
87+
netif_is_ovs_master(*route_dev))
8788
*out_dev = uplink_dev;
8889
else if (mlx5e_eswitch_rep(dev) &&
8990
mlx5e_is_valid_eswitch_fwd_dev(priv, dev))

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@ enum {
1313
MLX5E_ROUTE_ENTRY_VALID = BIT(0),
1414
};
1515

16+
static int mlx5e_set_int_port_tunnel(struct mlx5e_priv *priv,
17+
struct mlx5_flow_attr *attr,
18+
struct mlx5e_encap_entry *e,
19+
int out_index)
20+
{
21+
struct net_device *route_dev;
22+
int err = 0;
23+
24+
route_dev = dev_get_by_index(dev_net(e->out_dev), e->route_dev_ifindex);
25+
26+
if (!route_dev || !netif_is_ovs_master(route_dev))
27+
goto out;
28+
29+
err = mlx5e_set_fwd_to_int_port_actions(priv, attr, e->route_dev_ifindex,
30+
MLX5E_TC_INT_PORT_EGRESS,
31+
&attr->action, out_index);
32+
33+
out:
34+
if (route_dev)
35+
dev_put(route_dev);
36+
37+
return err;
38+
}
39+
1640
struct mlx5e_route_key {
1741
int ip_version;
1842
union {
@@ -809,6 +833,17 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
809833
if (err)
810834
goto out_err;
811835

836+
err = mlx5e_set_int_port_tunnel(priv, attr, e, out_index);
837+
if (err == -EOPNOTSUPP) {
838+
/* If device doesn't support int port offload,
839+
* redirect to uplink vport.
840+
*/
841+
mlx5_core_dbg(priv->mdev, "attaching int port as encap dev not supported, using uplink\n");
842+
err = 0;
843+
} else if (err) {
844+
goto out_err;
845+
}
846+
812847
flow->encaps[out_index].e = e;
813848
list_add(&flow->encaps[out_index].list, &e->flows);
814849
flow->encaps[out_index].index = out_index;

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
14581458
goto err_out;
14591459

14601460
if (esw_attr->dests[out_index].flags &
1461-
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE)
1461+
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE &&
1462+
!esw_attr->dest_int_port)
14621463
vf_tun = true;
14631464
out_priv = netdev_priv(encap_dev);
14641465
rpriv = out_priv->ppriv;
@@ -1566,7 +1567,8 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
15661567

15671568
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
15681569
if (esw_attr->dests[out_index].flags &
1569-
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE)
1570+
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE &&
1571+
!esw_attr->dest_int_port)
15701572
vf_tun = true;
15711573
if (esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP) {
15721574
mlx5e_detach_encap(priv, flow, out_index);

0 commit comments

Comments
 (0)