Skip to content

Commit 58747f6

Browse files
Chris MiBrian Maly
Chris Mi
authored and
Brian Maly
committed
net/mlx5e: Extract remaining tunnel encap code to dedicated file
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]> Orabug: 35383105 (cherry picked from commit e2ab5aa) cherry-pick-repo=kernel/git/torvalds/linux.git unmodified-from-upstream: e2ab5aa Signed-off-by: Mikhael Goikhman <[email protected]> Signed-off-by: Qing Huang <[email protected]> Reviewed-by: Devesh Sharma <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 29598a2 commit 58747f6

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

+83
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,89 @@ int mlx5e_attach_decap(struct mlx5e_priv *priv,
10161016
return err;
10171017
}
10181018

1019+
int mlx5e_tc_tun_encap_dests_set(struct mlx5e_priv *priv,
1020+
struct mlx5e_tc_flow *flow,
1021+
struct mlx5_flow_attr *attr,
1022+
struct netlink_ext_ack *extack,
1023+
bool *vf_tun)
1024+
{
1025+
struct mlx5e_tc_flow_parse_attr *parse_attr;
1026+
struct mlx5_esw_flow_attr *esw_attr;
1027+
struct net_device *encap_dev = NULL;
1028+
struct mlx5e_rep_priv *rpriv;
1029+
struct mlx5e_priv *out_priv;
1030+
int out_index;
1031+
int err = 0;
1032+
1033+
if (!mlx5e_is_eswitch_flow(flow))
1034+
return 0;
1035+
1036+
parse_attr = attr->parse_attr;
1037+
esw_attr = attr->esw_attr;
1038+
*vf_tun = false;
1039+
1040+
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1041+
struct net_device *out_dev;
1042+
int mirred_ifindex;
1043+
1044+
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1045+
continue;
1046+
1047+
mirred_ifindex = parse_attr->mirred_ifindex[out_index];
1048+
out_dev = dev_get_by_index(dev_net(priv->netdev), mirred_ifindex);
1049+
if (!out_dev) {
1050+
NL_SET_ERR_MSG_MOD(extack, "Requested mirred device not found");
1051+
err = -ENODEV;
1052+
goto out;
1053+
}
1054+
err = mlx5e_attach_encap(priv, flow, attr, out_dev, out_index,
1055+
extack, &encap_dev);
1056+
dev_put(out_dev);
1057+
if (err)
1058+
goto out;
1059+
1060+
if (esw_attr->dests[out_index].flags &
1061+
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE &&
1062+
!esw_attr->dest_int_port)
1063+
*vf_tun = true;
1064+
1065+
out_priv = netdev_priv(encap_dev);
1066+
rpriv = out_priv->ppriv;
1067+
esw_attr->dests[out_index].rep = rpriv->rep;
1068+
esw_attr->dests[out_index].mdev = out_priv->mdev;
1069+
}
1070+
1071+
if (*vf_tun && esw_attr->out_count > 1) {
1072+
NL_SET_ERR_MSG_MOD(extack, "VF tunnel encap with mirroring is not supported");
1073+
err = -EOPNOTSUPP;
1074+
goto out;
1075+
}
1076+
1077+
out:
1078+
return err;
1079+
}
1080+
1081+
void mlx5e_tc_tun_encap_dests_unset(struct mlx5e_priv *priv,
1082+
struct mlx5e_tc_flow *flow,
1083+
struct mlx5_flow_attr *attr)
1084+
{
1085+
struct mlx5_esw_flow_attr *esw_attr;
1086+
int out_index;
1087+
1088+
if (!mlx5e_is_eswitch_flow(flow))
1089+
return;
1090+
1091+
esw_attr = attr->esw_attr;
1092+
1093+
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1094+
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1095+
continue;
1096+
1097+
mlx5e_detach_encap(flow->priv, flow, attr, out_index);
1098+
kfree(attr->parse_attr->tun_info[out_index]);
1099+
}
1100+
}
1101+
10191102
static int cmp_route_info(struct mlx5e_route_key *a,
10201103
struct mlx5e_route_key *b)
10211104
{

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

+9
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

+2-87
Original file line numberDiff line numberDiff line change
@@ -1700,91 +1700,6 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
17001700
return mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
17011701
}
17021702

1703-
static int
1704-
set_encap_dests(struct mlx5e_priv *priv,
1705-
struct mlx5e_tc_flow *flow,
1706-
struct mlx5_flow_attr *attr,
1707-
struct netlink_ext_ack *extack,
1708-
bool *vf_tun)
1709-
{
1710-
struct mlx5e_tc_flow_parse_attr *parse_attr;
1711-
struct mlx5_esw_flow_attr *esw_attr;
1712-
struct net_device *encap_dev = NULL;
1713-
struct mlx5e_rep_priv *rpriv;
1714-
struct mlx5e_priv *out_priv;
1715-
int out_index;
1716-
int err = 0;
1717-
1718-
if (!mlx5e_is_eswitch_flow(flow))
1719-
return 0;
1720-
1721-
parse_attr = attr->parse_attr;
1722-
esw_attr = attr->esw_attr;
1723-
*vf_tun = false;
1724-
1725-
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1726-
struct net_device *out_dev;
1727-
int mirred_ifindex;
1728-
1729-
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1730-
continue;
1731-
1732-
mirred_ifindex = parse_attr->mirred_ifindex[out_index];
1733-
out_dev = dev_get_by_index(dev_net(priv->netdev), mirred_ifindex);
1734-
if (!out_dev) {
1735-
NL_SET_ERR_MSG_MOD(extack, "Requested mirred device not found");
1736-
err = -ENODEV;
1737-
goto out;
1738-
}
1739-
err = mlx5e_attach_encap(priv, flow, attr, out_dev, out_index,
1740-
extack, &encap_dev);
1741-
dev_put(out_dev);
1742-
if (err)
1743-
goto out;
1744-
1745-
if (esw_attr->dests[out_index].flags &
1746-
MLX5_ESW_DEST_CHAIN_WITH_SRC_PORT_CHANGE &&
1747-
!esw_attr->dest_int_port)
1748-
*vf_tun = true;
1749-
1750-
out_priv = netdev_priv(encap_dev);
1751-
rpriv = out_priv->ppriv;
1752-
esw_attr->dests[out_index].rep = rpriv->rep;
1753-
esw_attr->dests[out_index].mdev = out_priv->mdev;
1754-
}
1755-
1756-
if (*vf_tun && esw_attr->out_count > 1) {
1757-
NL_SET_ERR_MSG_MOD(extack, "VF tunnel encap with mirroring is not supported");
1758-
err = -EOPNOTSUPP;
1759-
goto out;
1760-
}
1761-
1762-
out:
1763-
return err;
1764-
}
1765-
1766-
static void
1767-
clean_encap_dests(struct mlx5e_priv *priv,
1768-
struct mlx5e_tc_flow *flow,
1769-
struct mlx5_flow_attr *attr)
1770-
{
1771-
struct mlx5_esw_flow_attr *esw_attr;
1772-
int out_index;
1773-
1774-
if (!mlx5e_is_eswitch_flow(flow))
1775-
return;
1776-
1777-
esw_attr = attr->esw_attr;
1778-
1779-
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++) {
1780-
if (!(esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP))
1781-
continue;
1782-
1783-
mlx5e_detach_encap(priv, flow, attr, out_index);
1784-
kfree(attr->parse_attr->tun_info[out_index]);
1785-
}
1786-
}
1787-
17881703
static int
17891704
verify_attr_actions(u32 actions, struct netlink_ext_ack *extack)
17901705
{
@@ -1821,7 +1736,7 @@ post_process_attr(struct mlx5e_tc_flow *flow,
18211736
if (err)
18221737
goto err_out;
18231738

1824-
err = set_encap_dests(flow->priv, flow, attr, extack, &vf_tun);
1739+
err = mlx5e_tc_tun_encap_dests_set(flow->priv, flow, attr, extack, &vf_tun);
18251740
if (err)
18261741
goto err_out;
18271742

@@ -4328,7 +4243,7 @@ mlx5_free_flow_attr_actions(struct mlx5e_tc_flow *flow, struct mlx5_flow_attr *a
43284243
if (attr->post_act_handle)
43294244
mlx5e_tc_post_act_del(get_post_action(flow->priv), attr->post_act_handle);
43304245

4331-
clean_encap_dests(flow->priv, flow, attr);
4246+
mlx5e_tc_tun_encap_dests_unset(flow->priv, flow, attr);
43324247

43334248
if (attr->action & MLX5_FLOW_CONTEXT_ACTION_COUNT)
43344249
mlx5_fc_destroy(counter_dev, attr->counter);

0 commit comments

Comments
 (0)