Skip to content

Commit 2c24a9a

Browse files
Chris Migregkh
authored andcommitted
net/mlx5e: Extract remaining tunnel encap code to dedicated file
[ Upstream commit e2ab5aa ] Move set_encap_dests() and clean_encap_dests() to the tunnel encap dedicated file. And rename them to mlx5e_tc_tun_encap_dests_set() and mlx5e_tc_tun_encap_dests_unset(). No functional change in this patch. It is needed in the next patch. Signed-off-by: Chris Mi <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Stable-dep-of: 37c3b9f ("net/mlx5e: Prevent encap offload when neigh update is running") Signed-off-by: Sasha Levin <[email protected]>
1 parent 4350910 commit 2c24a9a

File tree

3 files changed

+94
-87
lines changed

3 files changed

+94
-87
lines changed

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

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,89 @@ int mlx5e_attach_decap(struct mlx5e_priv *priv,
985985
return err;
986986
}
987987

988+
int mlx5e_tc_tun_encap_dests_set(struct mlx5e_priv *priv,
989+
struct mlx5e_tc_flow *flow,
990+
struct mlx5_flow_attr *attr,
991+
struct netlink_ext_ack *extack,
992+
bool *vf_tun)
993+
{
994+
struct mlx5e_tc_flow_parse_attr *parse_attr;
995+
struct mlx5_esw_flow_attr *esw_attr;
996+
struct net_device *encap_dev = NULL;
997+
struct mlx5e_rep_priv *rpriv;
998+
struct mlx5e_priv *out_priv;
999+
int out_index;
1000+
int err = 0;
1001+
1002+
if (!mlx5e_is_eswitch_flow(flow))
1003+
return 0;
1004+
1005+
parse_attr = attr->parse_attr;
1006+
esw_attr = attr->esw_attr;
1007+
*vf_tun = false;
1008+
1009+
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1010+
struct net_device *out_dev;
1011+
int mirred_ifindex;
1012+
1013+
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1014+
continue;
1015+
1016+
mirred_ifindex = parse_attr->mirred_ifindex[out_index];
1017+
out_dev = dev_get_by_index(dev_net(priv->netdev), mirred_ifindex);
1018+
if (!out_dev) {
1019+
NL_SET_ERR_MSG_MOD(extack, "Requested mirred device not found");
1020+
err = -ENODEV;
1021+
goto out;
1022+
}
1023+
err = mlx5e_attach_encap(priv, flow, attr, out_dev, out_index,
1024+
extack, &encap_dev);
1025+
dev_put(out_dev);
1026+
if (err)
1027+
goto out;
1028+
1029+
if (esw_attr->dests[out_index].flags &
1030+
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE &&
1031+
!esw_attr->dest_int_port)
1032+
*vf_tun = true;
1033+
1034+
out_priv = netdev_priv(encap_dev);
1035+
rpriv = out_priv->ppriv;
1036+
esw_attr->dests[out_index].rep = rpriv->rep;
1037+
esw_attr->dests[out_index].mdev = out_priv->mdev;
1038+
}
1039+
1040+
if (*vf_tun && esw_attr->out_count > 1) {
1041+
NL_SET_ERR_MSG_MOD(extack, "VF tunnel encap with mirroring is not supported");
1042+
err = -EOPNOTSUPP;
1043+
goto out;
1044+
}
1045+
1046+
out:
1047+
return err;
1048+
}
1049+
1050+
void mlx5e_tc_tun_encap_dests_unset(struct mlx5e_priv *priv,
1051+
struct mlx5e_tc_flow *flow,
1052+
struct mlx5_flow_attr *attr)
1053+
{
1054+
struct mlx5_esw_flow_attr *esw_attr;
1055+
int out_index;
1056+
1057+
if (!mlx5e_is_eswitch_flow(flow))
1058+
return;
1059+
1060+
esw_attr = attr->esw_attr;
1061+
1062+
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1063+
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1064+
continue;
1065+
1066+
mlx5e_detach_encap(flow->priv, flow, attr, out_index);
1067+
kfree(attr->parse_attr->tun_info[out_index]);
1068+
}
1069+
}
1070+
9881071
static int cmp_route_info(struct mlx5e_route_key *a,
9891072
struct mlx5e_route_key *b)
9901073
{

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ int mlx5e_attach_decap_route(struct mlx5e_priv *priv,
3030
void mlx5e_detach_decap_route(struct mlx5e_priv *priv,
3131
struct mlx5e_tc_flow *flow);
3232

33+
int mlx5e_tc_tun_encap_dests_set(struct mlx5e_priv *priv,
34+
struct mlx5e_tc_flow *flow,
35+
struct mlx5_flow_attr *attr,
36+
struct netlink_ext_ack *extack,
37+
bool *vf_tun);
38+
void mlx5e_tc_tun_encap_dests_unset(struct mlx5e_priv *priv,
39+
struct mlx5e_tc_flow *flow,
40+
struct mlx5_flow_attr *attr);
41+
3342
struct ip_tunnel_info *mlx5e_dup_tun_info(const struct ip_tunnel_info *tun_info);
3443

3544
int mlx5e_tc_set_attr_rx_tun(struct mlx5e_tc_flow *flow,

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

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,91 +1727,6 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
17271727
return mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
17281728
}
17291729

1730-
static int
1731-
set_encap_dests(struct mlx5e_priv *priv,
1732-
struct mlx5e_tc_flow *flow,
1733-
struct mlx5_flow_attr *attr,
1734-
struct netlink_ext_ack *extack,
1735-
bool *vf_tun)
1736-
{
1737-
struct mlx5e_tc_flow_parse_attr *parse_attr;
1738-
struct mlx5_esw_flow_attr *esw_attr;
1739-
struct net_device *encap_dev = NULL;
1740-
struct mlx5e_rep_priv *rpriv;
1741-
struct mlx5e_priv *out_priv;
1742-
int out_index;
1743-
int err = 0;
1744-
1745-
if (!mlx5e_is_eswitch_flow(flow))
1746-
return 0;
1747-
1748-
parse_attr = attr->parse_attr;
1749-
esw_attr = attr->esw_attr;
1750-
*vf_tun = false;
1751-
1752-
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1753-
struct net_device *out_dev;
1754-
int mirred_ifindex;
1755-
1756-
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1757-
continue;
1758-
1759-
mirred_ifindex = parse_attr->mirred_ifindex[out_index];
1760-
out_dev = dev_get_by_index(dev_net(priv->netdev), mirred_ifindex);
1761-
if (!out_dev) {
1762-
NL_SET_ERR_MSG_MOD(extack, "Requested mirred device not found");
1763-
err = -ENODEV;
1764-
goto out;
1765-
}
1766-
err = mlx5e_attach_encap(priv, flow, attr, out_dev, out_index,
1767-
extack, &encap_dev);
1768-
dev_put(out_dev);
1769-
if (err)
1770-
goto out;
1771-
1772-
if (esw_attr->dests[out_index].flags &
1773-
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE &&
1774-
!esw_attr->dest_int_port)
1775-
*vf_tun = true;
1776-
1777-
out_priv = netdev_priv(encap_dev);
1778-
rpriv = out_priv->ppriv;
1779-
esw_attr->dests[out_index].rep = rpriv->rep;
1780-
esw_attr->dests[out_index].mdev = out_priv->mdev;
1781-
}
1782-
1783-
if (*vf_tun && esw_attr->out_count > 1) {
1784-
NL_SET_ERR_MSG_MOD(extack, "VF tunnel encap with mirroring is not supported");
1785-
err = -EOPNOTSUPP;
1786-
goto out;
1787-
}
1788-
1789-
out:
1790-
return err;
1791-
}
1792-
1793-
static void
1794-
clean_encap_dests(struct mlx5e_priv *priv,
1795-
struct mlx5e_tc_flow *flow,
1796-
struct mlx5_flow_attr *attr)
1797-
{
1798-
struct mlx5_esw_flow_attr *esw_attr;
1799-
int out_index;
1800-
1801-
if (!mlx5e_is_eswitch_flow(flow))
1802-
return;
1803-
1804-
esw_attr = attr->esw_attr;
1805-
1806-
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1807-
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1808-
continue;
1809-
1810-
mlx5e_detach_encap(priv, flow, attr, out_index);
1811-
kfree(attr->parse_attr->tun_info[out_index]);
1812-
}
1813-
}
1814-
18151730
static int
18161731
verify_attr_actions(u32 actions, struct netlink_ext_ack *extack)
18171732
{
@@ -1848,7 +1763,7 @@ post_process_attr(struct mlx5e_tc_flow *flow,
18481763
if (err)
18491764
goto err_out;
18501765

1851-
err = set_encap_dests(flow->priv, flow, attr, extack, &vf_tun);
1766+
err = mlx5e_tc_tun_encap_dests_set(flow->priv, flow, attr, extack, &vf_tun);
18521767
if (err)
18531768
goto err_out;
18541769

@@ -4439,7 +4354,7 @@ mlx5_free_flow_attr_actions(struct mlx5e_tc_flow *flow, struct mlx5_flow_attr *a
44394354
if (attr->post_act_handle)
44404355
mlx5e_tc_post_act_del(get_post_action(flow->priv), attr->post_act_handle);
44414356

4442-
clean_encap_dests(flow->priv, flow, attr);
4357+
mlx5e_tc_tun_encap_dests_unset(flow->priv, flow, attr);
44434358

44444359
if (attr->action & MLX5_FLOW_CONTEXT_ACTION_COUNT)
44454360
mlx5_fc_destroy(counter_dev, attr->counter);

0 commit comments

Comments
 (0)