Commit bc29764e authored by Maor Gottlieb's avatar Maor Gottlieb Committed by Saeed Mahameed

net/mlx5e: Decouple TTC logic from mlx5e

Remove dependency in the mlx5e driver from the TTC implementation
by changing the TTC related functions to receive mlx5 generic arguments.
It allows to decouple TTC logic from mlx5e and reused by other parts of
mlx5 driver.
Signed-off-by: default avatarMaor Gottlieb <maorg@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 5fba089e
...@@ -106,15 +106,17 @@ enum mlx5_tunnel_types { ...@@ -106,15 +106,17 @@ enum mlx5_tunnel_types {
bool mlx5_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev); bool mlx5_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev);
struct mlx5e_ttc_rule { struct mlx5_ttc_rule {
struct mlx5_flow_handle *rule; struct mlx5_flow_handle *rule;
struct mlx5_flow_destination default_dest; struct mlx5_flow_destination default_dest;
}; };
/* L3/L4 traffic type classifier */ /* L3/L4 traffic type classifier */
struct mlx5e_ttc_table { struct mlx5_ttc_table {
struct mlx5e_flow_table ft; int num_groups;
struct mlx5e_ttc_rule rules[MLX5_NUM_TT]; struct mlx5_flow_table *t;
struct mlx5_flow_group **g;
struct mlx5_ttc_rule rules[MLX5_NUM_TT];
struct mlx5_flow_handle *tunnel_rules[MLX5_NUM_TUNNEL_TT]; struct mlx5_flow_handle *tunnel_rules[MLX5_NUM_TUNNEL_TT];
}; };
...@@ -223,8 +225,8 @@ struct mlx5e_flow_steering { ...@@ -223,8 +225,8 @@ struct mlx5e_flow_steering {
struct mlx5e_promisc_table promisc; struct mlx5e_promisc_table promisc;
struct mlx5e_vlan_table *vlan; struct mlx5e_vlan_table *vlan;
struct mlx5e_l2_table l2; struct mlx5e_l2_table l2;
struct mlx5e_ttc_table ttc; struct mlx5_ttc_table ttc;
struct mlx5e_ttc_table inner_ttc; struct mlx5_ttc_table inner_ttc;
#ifdef CONFIG_MLX5_EN_ARFS #ifdef CONFIG_MLX5_EN_ARFS
struct mlx5e_arfs_tables *arfs; struct mlx5e_arfs_tables *arfs;
#endif #endif
...@@ -237,28 +239,28 @@ struct mlx5e_flow_steering { ...@@ -237,28 +239,28 @@ struct mlx5e_flow_steering {
}; };
struct ttc_params { struct ttc_params {
struct mlx5_flow_namespace *ns;
struct mlx5_flow_table_attr ft_attr; struct mlx5_flow_table_attr ft_attr;
u32 any_tt_tirn; struct mlx5_flow_destination dests[MLX5_NUM_TT];
u32 indir_tirn[MLX5E_NUM_INDIR_TIRS]; bool inner_ttc;
struct mlx5e_ttc_table *inner_ttc; struct mlx5_flow_destination tunnel_dests[MLX5_NUM_TUNNEL_TT];
}; };
void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params); void mlx5e_set_ttc_params(struct mlx5e_priv *priv,
void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params); struct ttc_params *ttc_params, bool tunnel);
int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params, int mlx5_create_ttc_table(struct mlx5_core_dev *dev, struct ttc_params *params,
struct mlx5e_ttc_table *ttc); struct mlx5_ttc_table *ttc);
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv, void mlx5_destroy_ttc_table(struct mlx5_ttc_table *ttc);
struct mlx5e_ttc_table *ttc);
void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft); void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
int mlx5e_ttc_fwd_dest(struct mlx5e_priv *priv, enum mlx5_traffic_types type, int mlx5_ttc_fwd_dest(struct mlx5_ttc_table *ttc, enum mlx5_traffic_types type,
struct mlx5_flow_destination *new_dest); struct mlx5_flow_destination *new_dest);
struct mlx5_flow_destination struct mlx5_flow_destination
mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, mlx5_ttc_get_default_dest(struct mlx5_ttc_table *ttc,
enum mlx5_traffic_types type); enum mlx5_traffic_types type);
int mlx5e_ttc_fwd_default_dest(struct mlx5e_priv *priv, int mlx5_ttc_fwd_default_dest(struct mlx5_ttc_table *ttc,
enum mlx5_traffic_types type); enum mlx5_traffic_types type);
void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv); void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv); void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
......
...@@ -124,7 +124,7 @@ static int fs_udp_add_default_rule(struct mlx5e_priv *priv, enum fs_udp_type typ ...@@ -124,7 +124,7 @@ static int fs_udp_add_default_rule(struct mlx5e_priv *priv, enum fs_udp_type typ
fs_udp = priv->fs.udp; fs_udp = priv->fs.udp;
fs_udp_t = &fs_udp->tables[type]; fs_udp_t = &fs_udp->tables[type];
dest = mlx5e_ttc_get_default_dest(priv, fs_udp2tt(type)); dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, fs_udp2tt(type));
rule = mlx5_add_flow_rules(fs_udp_t->t, NULL, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(fs_udp_t->t, NULL, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
...@@ -259,7 +259,7 @@ static int fs_udp_disable(struct mlx5e_priv *priv) ...@@ -259,7 +259,7 @@ static int fs_udp_disable(struct mlx5e_priv *priv)
for (i = 0; i < FS_UDP_NUM_TYPES; i++) { for (i = 0; i < FS_UDP_NUM_TYPES; i++) {
/* Modify ttc rules destination to point back to the indir TIRs */ /* Modify ttc rules destination to point back to the indir TIRs */
err = mlx5e_ttc_fwd_default_dest(priv, fs_udp2tt(i)); err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, fs_udp2tt(i));
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n", "%s: modify ttc[%d] default destination failed, err(%d)\n",
...@@ -281,7 +281,8 @@ static int fs_udp_enable(struct mlx5e_priv *priv) ...@@ -281,7 +281,8 @@ static int fs_udp_enable(struct mlx5e_priv *priv)
dest.ft = priv->fs.udp->tables[i].t; dest.ft = priv->fs.udp->tables[i].t;
/* Modify ttc rules destination to point on the accel_fs FTs */ /* Modify ttc rules destination to point on the accel_fs FTs */
err = mlx5e_ttc_fwd_dest(priv, fs_udp2tt(i), &dest); err = mlx5_ttc_fwd_dest(&priv->fs.ttc, fs_udp2tt(i),
&dest);
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] destination to accel failed, err(%d)\n", "%s: modify ttc[%d] destination to accel failed, err(%d)\n",
...@@ -401,7 +402,7 @@ static int fs_any_add_default_rule(struct mlx5e_priv *priv) ...@@ -401,7 +402,7 @@ static int fs_any_add_default_rule(struct mlx5e_priv *priv)
fs_any = priv->fs.any; fs_any = priv->fs.any;
fs_any_t = &fs_any->table; fs_any_t = &fs_any->table;
dest = mlx5e_ttc_get_default_dest(priv, MLX5_TT_ANY); dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, MLX5_TT_ANY);
rule = mlx5_add_flow_rules(fs_any_t->t, NULL, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(fs_any_t->t, NULL, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
...@@ -514,7 +515,7 @@ static int fs_any_disable(struct mlx5e_priv *priv) ...@@ -514,7 +515,7 @@ static int fs_any_disable(struct mlx5e_priv *priv)
int err; int err;
/* Modify ttc rules destination to point back to the indir TIRs */ /* Modify ttc rules destination to point back to the indir TIRs */
err = mlx5e_ttc_fwd_default_dest(priv, MLX5_TT_ANY); err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, MLX5_TT_ANY);
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n", "%s: modify ttc[%d] default destination failed, err(%d)\n",
...@@ -533,7 +534,7 @@ static int fs_any_enable(struct mlx5e_priv *priv) ...@@ -533,7 +534,7 @@ static int fs_any_enable(struct mlx5e_priv *priv)
dest.ft = priv->fs.any->table.t; dest.ft = priv->fs.any->table.t;
/* Modify ttc rules destination to point on the accel_fs FTs */ /* Modify ttc rules destination to point on the accel_fs FTs */
err = mlx5e_ttc_fwd_dest(priv, MLX5_TT_ANY, &dest); err = mlx5_ttc_fwd_dest(&priv->fs.ttc, MLX5_TT_ANY, &dest);
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] destination to accel failed, err(%d)\n", "%s: modify ttc[%d] destination to accel failed, err(%d)\n",
......
...@@ -161,7 +161,7 @@ static int accel_fs_tcp_add_default_rule(struct mlx5e_priv *priv, ...@@ -161,7 +161,7 @@ static int accel_fs_tcp_add_default_rule(struct mlx5e_priv *priv,
fs_tcp = priv->fs.accel_tcp; fs_tcp = priv->fs.accel_tcp;
accel_fs_t = &fs_tcp->tables[type]; accel_fs_t = &fs_tcp->tables[type];
dest = mlx5e_ttc_get_default_dest(priv, fs_accel2tt(type)); dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, fs_accel2tt(type));
rule = mlx5_add_flow_rules(accel_fs_t->t, NULL, &flow_act, &dest, 1); rule = mlx5_add_flow_rules(accel_fs_t->t, NULL, &flow_act, &dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
...@@ -307,7 +307,7 @@ static int accel_fs_tcp_disable(struct mlx5e_priv *priv) ...@@ -307,7 +307,7 @@ static int accel_fs_tcp_disable(struct mlx5e_priv *priv)
for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++) { for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++) {
/* Modify ttc rules destination to point back to the indir TIRs */ /* Modify ttc rules destination to point back to the indir TIRs */
err = mlx5e_ttc_fwd_default_dest(priv, fs_accel2tt(i)); err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, fs_accel2tt(i));
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n", "%s: modify ttc[%d] default destination failed, err(%d)\n",
...@@ -329,7 +329,7 @@ static int accel_fs_tcp_enable(struct mlx5e_priv *priv) ...@@ -329,7 +329,7 @@ static int accel_fs_tcp_enable(struct mlx5e_priv *priv)
dest.ft = priv->fs.accel_tcp->tables[i].t; dest.ft = priv->fs.accel_tcp->tables[i].t;
/* Modify ttc rules destination to point on the accel_fs FTs */ /* Modify ttc rules destination to point on the accel_fs FTs */
err = mlx5e_ttc_fwd_dest(priv, fs_accel2tt(i), &dest); err = mlx5_ttc_fwd_dest(&priv->fs.ttc, fs_accel2tt(i), &dest);
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] destination to accel failed, err(%d)\n", "%s: modify ttc[%d] destination to accel failed, err(%d)\n",
......
...@@ -265,7 +265,7 @@ static int rx_create(struct mlx5e_priv *priv, enum accel_fs_esp_type type) ...@@ -265,7 +265,7 @@ static int rx_create(struct mlx5e_priv *priv, enum accel_fs_esp_type type)
accel_esp = priv->ipsec->rx_fs; accel_esp = priv->ipsec->rx_fs;
fs_prot = &accel_esp->fs_prot[type]; fs_prot = &accel_esp->fs_prot[type];
fs_prot->default_dest = mlx5e_ttc_get_default_dest(priv, fs_esp2tt(type)); fs_prot->default_dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, fs_esp2tt(type));
err = rx_err_create_ft(priv, fs_prot, &fs_prot->rx_err); err = rx_err_create_ft(priv, fs_prot, &fs_prot->rx_err);
if (err) if (err)
...@@ -301,7 +301,7 @@ static int rx_ft_get(struct mlx5e_priv *priv, enum accel_fs_esp_type type) ...@@ -301,7 +301,7 @@ static int rx_ft_get(struct mlx5e_priv *priv, enum accel_fs_esp_type type)
/* connect */ /* connect */
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest.ft = fs_prot->ft; dest.ft = fs_prot->ft;
mlx5e_ttc_fwd_dest(priv, fs_esp2tt(type), &dest); mlx5_ttc_fwd_dest(&priv->fs.ttc, fs_esp2tt(type), &dest);
out: out:
mutex_unlock(&fs_prot->prot_mutex); mutex_unlock(&fs_prot->prot_mutex);
...@@ -320,7 +320,7 @@ static void rx_ft_put(struct mlx5e_priv *priv, enum accel_fs_esp_type type) ...@@ -320,7 +320,7 @@ static void rx_ft_put(struct mlx5e_priv *priv, enum accel_fs_esp_type type)
goto out; goto out;
/* disconnect */ /* disconnect */
mlx5e_ttc_fwd_default_dest(priv, fs_esp2tt(type)); mlx5_ttc_fwd_default_dest(&priv->fs.ttc, fs_esp2tt(type));
/* remove FT */ /* remove FT */
rx_destroy(priv, type); rx_destroy(priv, type);
......
...@@ -120,7 +120,7 @@ static int arfs_disable(struct mlx5e_priv *priv) ...@@ -120,7 +120,7 @@ static int arfs_disable(struct mlx5e_priv *priv)
for (i = 0; i < ARFS_NUM_TYPES; i++) { for (i = 0; i < ARFS_NUM_TYPES; i++) {
/* Modify ttc rules destination back to their default */ /* Modify ttc rules destination back to their default */
err = mlx5e_ttc_fwd_default_dest(priv, arfs_get_tt(i)); err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, arfs_get_tt(i));
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n", "%s: modify ttc[%d] default destination failed, err(%d)\n",
...@@ -149,7 +149,7 @@ int mlx5e_arfs_enable(struct mlx5e_priv *priv) ...@@ -149,7 +149,7 @@ int mlx5e_arfs_enable(struct mlx5e_priv *priv)
for (i = 0; i < ARFS_NUM_TYPES; i++) { for (i = 0; i < ARFS_NUM_TYPES; i++) {
dest.ft = priv->fs.arfs->arfs_tables[i].ft.t; dest.ft = priv->fs.arfs->arfs_tables[i].ft.t;
/* Modify ttc rules destination to point on the aRFS FTs */ /* Modify ttc rules destination to point on the aRFS FTs */
err = mlx5e_ttc_fwd_dest(priv, arfs_get_tt(i), &dest); err = mlx5_ttc_fwd_dest(&priv->fs.ttc, arfs_get_tt(i), &dest);
if (err) { if (err) {
netdev_err(priv->netdev, netdev_err(priv->netdev,
"%s: modify ttc[%d] dest to arfs, failed err(%d)\n", "%s: modify ttc[%d] dest to arfs, failed err(%d)\n",
...@@ -205,7 +205,7 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv, ...@@ -205,7 +205,7 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv,
return -EINVAL; return -EINVAL;
} }
/* FIXME: Must use mlx5e_ttc_get_default_dest(), /* FIXME: Must use mlx5_ttc_get_default_dest(),
* but can't since TTC default is not setup yet ! * but can't since TTC default is not setup yet !
*/ */
dest.tir_num = mlx5e_rx_res_get_tirn_rss(priv->rx_res, tt); dest.tir_num = mlx5e_rx_res_get_tirn_rss(priv->rx_res, tt);
......
...@@ -718,7 +718,7 @@ static int mlx5e_add_promisc_rule(struct mlx5e_priv *priv) ...@@ -718,7 +718,7 @@ static int mlx5e_add_promisc_rule(struct mlx5e_priv *priv)
if (!spec) if (!spec)
return -ENOMEM; return -ENOMEM;
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest.ft = priv->fs.ttc.ft.t; dest.ft = priv->fs.ttc.t;
rule_p = &priv->fs.promisc.rule; rule_p = &priv->fs.promisc.rule;
*rule_p = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); *rule_p = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1);
...@@ -854,7 +854,7 @@ void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft) ...@@ -854,7 +854,7 @@ void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft)
ft->t = NULL; ft->t = NULL;
} }
static void mlx5e_cleanup_ttc_rules(struct mlx5e_ttc_table *ttc) static void mlx5_cleanup_ttc_rules(struct mlx5_ttc_table *ttc)
{ {
int i; int i;
...@@ -1004,13 +1004,12 @@ static u8 mlx5_etype_to_ipv(u16 ethertype) ...@@ -1004,13 +1004,12 @@ static u8 mlx5_etype_to_ipv(u16 ethertype)
} }
static struct mlx5_flow_handle * static struct mlx5_flow_handle *
mlx5e_generate_ttc_rule(struct mlx5e_priv *priv, mlx5_generate_ttc_rule(struct mlx5_core_dev *dev, struct mlx5_flow_table *ft,
struct mlx5_flow_table *ft, struct mlx5_flow_destination *dest, u16 etype, u8 proto)
struct mlx5_flow_destination *dest,
u16 etype,
u8 proto)
{ {
int match_ipv_outer = MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ft_field_support.outer_ip_version); int match_ipv_outer =
MLX5_CAP_FLOWTABLE_NIC_RX(dev,
ft_field_support.outer_ip_version);
MLX5_DECLARE_FLOW_ACT(flow_act); MLX5_DECLARE_FLOW_ACT(flow_act);
struct mlx5_flow_handle *rule; struct mlx5_flow_handle *rule;
struct mlx5_flow_spec *spec; struct mlx5_flow_spec *spec;
...@@ -1041,60 +1040,51 @@ mlx5e_generate_ttc_rule(struct mlx5e_priv *priv, ...@@ -1041,60 +1040,51 @@ mlx5e_generate_ttc_rule(struct mlx5e_priv *priv,
rule = mlx5_add_flow_rules(ft, spec, &flow_act, dest, 1); rule = mlx5_add_flow_rules(ft, spec, &flow_act, dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(priv->netdev, "%s: add rule failed\n", __func__); mlx5_core_err(dev, "%s: add rule failed\n", __func__);
} }
kvfree(spec); kvfree(spec);
return err ? ERR_PTR(err) : rule; return err ? ERR_PTR(err) : rule;
} }
static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv, static int mlx5_generate_ttc_table_rules(struct mlx5_core_dev *dev,
struct ttc_params *params, struct ttc_params *params,
struct mlx5e_ttc_table *ttc) struct mlx5_ttc_table *ttc)
{ {
struct mlx5_flow_destination dest = {};
struct mlx5_flow_handle **trules; struct mlx5_flow_handle **trules;
struct mlx5e_ttc_rule *rules; struct mlx5_ttc_rule *rules;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
int tt; int tt;
int err; int err;
ft = ttc->ft.t; ft = ttc->t;
rules = ttc->rules; rules = ttc->rules;
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
for (tt = 0; tt < MLX5_NUM_TT; tt++) { for (tt = 0; tt < MLX5_NUM_TT; tt++) {
struct mlx5e_ttc_rule *rule = &rules[tt]; struct mlx5_ttc_rule *rule = &rules[tt];
if (tt == MLX5_TT_ANY)
dest.tir_num = params->any_tt_tirn;
else
dest.tir_num = params->indir_tirn[tt];
rule->rule = mlx5e_generate_ttc_rule(priv, ft, &dest, rule->rule = mlx5_generate_ttc_rule(dev, ft, &params->dests[tt],
ttc_rules[tt].etype, ttc_rules[tt].etype,
ttc_rules[tt].proto); ttc_rules[tt].proto);
if (IS_ERR(rule->rule)) { if (IS_ERR(rule->rule)) {
err = PTR_ERR(rule->rule); err = PTR_ERR(rule->rule);
rule->rule = NULL; rule->rule = NULL;
goto del_rules; goto del_rules;
} }
rule->default_dest = dest; rule->default_dest = params->dests[tt];
} }
if (!params->inner_ttc || !mlx5_tunnel_inner_ft_supported(priv->mdev)) if (!params->inner_ttc || !mlx5_tunnel_inner_ft_supported(dev))
return 0; return 0;
trules = ttc->tunnel_rules; trules = ttc->tunnel_rules;
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest.ft = params->inner_ttc->ft.t;
for (tt = 0; tt < MLX5_NUM_TUNNEL_TT; tt++) { for (tt = 0; tt < MLX5_NUM_TUNNEL_TT; tt++) {
if (!mlx5_tunnel_proto_supported_rx(priv->mdev, if (!mlx5_tunnel_proto_supported_rx(dev,
ttc_tunnel_rules[tt].proto)) ttc_tunnel_rules[tt].proto))
continue; continue;
trules[tt] = mlx5e_generate_ttc_rule(priv, ft, &dest, trules[tt] = mlx5_generate_ttc_rule(dev, ft,
ttc_tunnel_rules[tt].etype, &params->tunnel_dests[tt],
ttc_tunnel_rules[tt].proto); ttc_tunnel_rules[tt].etype,
ttc_tunnel_rules[tt].proto);
if (IS_ERR(trules[tt])) { if (IS_ERR(trules[tt])) {
err = PTR_ERR(trules[tt]); err = PTR_ERR(trules[tt]);
trules[tt] = NULL; trules[tt] = NULL;
...@@ -1105,28 +1095,26 @@ static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv, ...@@ -1105,28 +1095,26 @@ static int mlx5e_generate_ttc_table_rules(struct mlx5e_priv *priv,
return 0; return 0;
del_rules: del_rules:
mlx5e_cleanup_ttc_rules(ttc); mlx5_cleanup_ttc_rules(ttc);
return err; return err;
} }
static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc, static int mlx5_create_ttc_table_groups(struct mlx5_ttc_table *ttc,
bool use_ipv) bool use_ipv)
{ {
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
struct mlx5e_flow_table *ft = &ttc->ft;
int ix = 0; int ix = 0;
u32 *in; u32 *in;
int err; int err;
u8 *mc; u8 *mc;
ft->g = kcalloc(MLX5_TTC_NUM_GROUPS, ttc->g = kcalloc(MLX5_TTC_NUM_GROUPS, sizeof(*ttc->g), GFP_KERNEL);
sizeof(*ft->g), GFP_KERNEL); if (!ttc->g)
if (!ft->g)
return -ENOMEM; return -ENOMEM;
in = kvzalloc(inlen, GFP_KERNEL); in = kvzalloc(inlen, GFP_KERNEL);
if (!in) { if (!in) {
kfree(ft->g); kfree(ttc->g);
ft->g = NULL; ttc->g = NULL;
return -ENOMEM; return -ENOMEM;
} }
...@@ -1141,47 +1129,47 @@ static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc, ...@@ -1141,47 +1129,47 @@ static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc,
MLX5_SET_CFG(in, start_flow_index, ix); MLX5_SET_CFG(in, start_flow_index, ix);
ix += MLX5_TTC_GROUP1_SIZE; ix += MLX5_TTC_GROUP1_SIZE;
MLX5_SET_CFG(in, end_flow_index, ix - 1); MLX5_SET_CFG(in, end_flow_index, ix - 1);
ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in); ttc->g[ttc->num_groups] = mlx5_create_flow_group(ttc->t, in);
if (IS_ERR(ft->g[ft->num_groups])) if (IS_ERR(ttc->g[ttc->num_groups]))
goto err; goto err;
ft->num_groups++; ttc->num_groups++;
/* L3 Group */ /* L3 Group */
MLX5_SET(fte_match_param, mc, outer_headers.ip_protocol, 0); MLX5_SET(fte_match_param, mc, outer_headers.ip_protocol, 0);
MLX5_SET_CFG(in, start_flow_index, ix); MLX5_SET_CFG(in, start_flow_index, ix);
ix += MLX5_TTC_GROUP2_SIZE; ix += MLX5_TTC_GROUP2_SIZE;
MLX5_SET_CFG(in, end_flow_index, ix - 1); MLX5_SET_CFG(in, end_flow_index, ix - 1);
ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in); ttc->g[ttc->num_groups] = mlx5_create_flow_group(ttc->t, in);
if (IS_ERR(ft->g[ft->num_groups])) if (IS_ERR(ttc->g[ttc->num_groups]))
goto err; goto err;
ft->num_groups++; ttc->num_groups++;
/* Any Group */ /* Any Group */
memset(in, 0, inlen); memset(in, 0, inlen);
MLX5_SET_CFG(in, start_flow_index, ix); MLX5_SET_CFG(in, start_flow_index, ix);
ix += MLX5_TTC_GROUP3_SIZE; ix += MLX5_TTC_GROUP3_SIZE;
MLX5_SET_CFG(in, end_flow_index, ix - 1); MLX5_SET_CFG(in, end_flow_index, ix - 1);
ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in); ttc->g[ttc->num_groups] = mlx5_create_flow_group(ttc->t, in);
if (IS_ERR(ft->g[ft->num_groups])) if (IS_ERR(ttc->g[ttc->num_groups]))
goto err; goto err;
ft->num_groups++; ttc->num_groups++;
kvfree(in); kvfree(in);
return 0; return 0;
err: err:
err = PTR_ERR(ft->g[ft->num_groups]); err = PTR_ERR(ttc->g[ttc->num_groups]);
ft->g[ft->num_groups] = NULL; ttc->g[ttc->num_groups] = NULL;
kvfree(in); kvfree(in);
return err; return err;
} }
static struct mlx5_flow_handle * static struct mlx5_flow_handle *
mlx5e_generate_inner_ttc_rule(struct mlx5e_priv *priv, mlx5_generate_inner_ttc_rule(struct mlx5_core_dev *dev,
struct mlx5_flow_table *ft, struct mlx5_flow_table *ft,
struct mlx5_flow_destination *dest, struct mlx5_flow_destination *dest,
u16 etype, u8 proto) u16 etype, u8 proto)
{ {
MLX5_DECLARE_FLOW_ACT(flow_act); MLX5_DECLARE_FLOW_ACT(flow_act);
struct mlx5_flow_handle *rule; struct mlx5_flow_handle *rule;
...@@ -1209,70 +1197,64 @@ mlx5e_generate_inner_ttc_rule(struct mlx5e_priv *priv, ...@@ -1209,70 +1197,64 @@ mlx5e_generate_inner_ttc_rule(struct mlx5e_priv *priv,
rule = mlx5_add_flow_rules(ft, spec, &flow_act, dest, 1); rule = mlx5_add_flow_rules(ft, spec, &flow_act, dest, 1);
if (IS_ERR(rule)) { if (IS_ERR(rule)) {
err = PTR_ERR(rule); err = PTR_ERR(rule);
netdev_err(priv->netdev, "%s: add rule failed\n", __func__); mlx5_core_err(dev, "%s: add inner TTC rule failed\n", __func__);
} }
kvfree(spec); kvfree(spec);
return err ? ERR_PTR(err) : rule; return err ? ERR_PTR(err) : rule;
} }
static int mlx5e_generate_inner_ttc_table_rules(struct mlx5e_priv *priv, static int mlx5_generate_inner_ttc_table_rules(struct mlx5_core_dev *dev,
struct ttc_params *params, struct ttc_params *params,
struct mlx5e_ttc_table *ttc) struct mlx5_ttc_table *ttc)
{ {
struct mlx5_flow_destination dest = {}; struct mlx5_ttc_rule *rules;
struct mlx5e_ttc_rule *rules;
struct mlx5_flow_table *ft; struct mlx5_flow_table *ft;
int err; int err;
int tt; int tt;
ft = ttc->ft.t; ft = ttc->t;
rules = ttc->rules; rules = ttc->rules;
dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR;
for (tt = 0; tt < MLX5_NUM_TT; tt++) { for (tt = 0; tt < MLX5_NUM_TT; tt++) {
struct mlx5e_ttc_rule *rule = &rules[tt]; struct mlx5_ttc_rule *rule = &rules[tt];
if (tt == MLX5_TT_ANY)
dest.tir_num = params->any_tt_tirn;
else
dest.tir_num = params->indir_tirn[tt];
rule->rule = mlx5e_generate_inner_ttc_rule(priv, ft, &dest, rule->rule = mlx5_generate_inner_ttc_rule(dev, ft,
ttc_rules[tt].etype, &params->dests[tt],
ttc_rules[tt].proto); ttc_rules[tt].etype,
ttc_rules[tt].proto);
if (IS_ERR(rule->rule)) { if (IS_ERR(rule->rule)) {
err = PTR_ERR(rule->rule); err = PTR_ERR(rule->rule);
rule->rule = NULL; rule->rule = NULL;
goto del_rules; goto del_rules;
} }
rule->default_dest = dest; rule->default_dest = params->dests[tt];
} }
return 0; return 0;
del_rules: del_rules:
mlx5e_cleanup_ttc_rules(ttc); mlx5_cleanup_ttc_rules(ttc);
return err; return err;
} }
static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc) static int mlx5_create_inner_ttc_table_groups(struct mlx5_ttc_table *ttc)
{ {
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
struct mlx5e_flow_table *ft = &ttc->ft;
int ix = 0; int ix = 0;
u32 *in; u32 *in;
int err; int err;
u8 *mc; u8 *mc;
ft->g = kcalloc(MLX5_INNER_TTC_NUM_GROUPS, sizeof(*ft->g), GFP_KERNEL); ttc->g = kcalloc(MLX5_INNER_TTC_NUM_GROUPS, sizeof(*ttc->g),
if (!ft->g) GFP_KERNEL);
if (!ttc->g)
return -ENOMEM; return -ENOMEM;
in = kvzalloc(inlen, GFP_KERNEL); in = kvzalloc(inlen, GFP_KERNEL);
if (!in) { if (!in) {
kfree(ft->g); kfree(ttc->g);
ft->g = NULL; ttc->g = NULL;
return -ENOMEM; return -ENOMEM;
} }
...@@ -1284,148 +1266,191 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc) ...@@ -1284,148 +1266,191 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc)
MLX5_SET_CFG(in, start_flow_index, ix); MLX5_SET_CFG(in, start_flow_index, ix);
ix += MLX5_INNER_TTC_GROUP1_SIZE; ix += MLX5_INNER_TTC_GROUP1_SIZE;
MLX5_SET_CFG(in, end_flow_index, ix - 1); MLX5_SET_CFG(in, end_flow_index, ix - 1);
ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in); ttc->g[ttc->num_groups] = mlx5_create_flow_group(ttc->t, in);
if (IS_ERR(ft->g[ft->num_groups])) if (IS_ERR(ttc->g[ttc->num_groups]))
goto err; goto err;
ft->num_groups++; ttc->num_groups++;
/* L3 Group */ /* L3 Group */
MLX5_SET(fte_match_param, mc, inner_headers.ip_protocol, 0); MLX5_SET(fte_match_param, mc, inner_headers.ip_protocol, 0);
MLX5_SET_CFG(in, start_flow_index, ix); MLX5_SET_CFG(in, start_flow_index, ix);
ix += MLX5_INNER_TTC_GROUP2_SIZE; ix += MLX5_INNER_TTC_GROUP2_SIZE;
MLX5_SET_CFG(in, end_flow_index, ix - 1); MLX5_SET_CFG(in, end_flow_index, ix - 1);
ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in); ttc->g[ttc->num_groups] = mlx5_create_flow_group(ttc->t, in);
if (IS_ERR(ft->g[ft->num_groups])) if (IS_ERR(ttc->g[ttc->num_groups]))
goto err; goto err;
ft->num_groups++; ttc->num_groups++;
/* Any Group */ /* Any Group */
memset(in, 0, inlen); memset(in, 0, inlen);
MLX5_SET_CFG(in, start_flow_index, ix); MLX5_SET_CFG(in, start_flow_index, ix);
ix += MLX5_INNER_TTC_GROUP3_SIZE; ix += MLX5_INNER_TTC_GROUP3_SIZE;
MLX5_SET_CFG(in, end_flow_index, ix - 1); MLX5_SET_CFG(in, end_flow_index, ix - 1);
ft->g[ft->num_groups] = mlx5_create_flow_group(ft->t, in); ttc->g[ttc->num_groups] = mlx5_create_flow_group(ttc->t, in);
if (IS_ERR(ft->g[ft->num_groups])) if (IS_ERR(ttc->g[ttc->num_groups]))
goto err; goto err;
ft->num_groups++; ttc->num_groups++;
kvfree(in); kvfree(in);
return 0; return 0;
err: err:
err = PTR_ERR(ft->g[ft->num_groups]); err = PTR_ERR(ttc->g[ttc->num_groups]);
ft->g[ft->num_groups] = NULL; ttc->g[ttc->num_groups] = NULL;
kvfree(in); kvfree(in);
return err; return err;
} }
void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, static void mlx5e_set_inner_ttc_params(struct mlx5e_priv *priv,
struct ttc_params *ttc_params) struct ttc_params *ttc_params)
{
ttc_params->any_tt_tirn = mlx5e_rx_res_get_tirn_direct(priv->rx_res, 0);
ttc_params->inner_ttc = &priv->fs.inner_ttc;
}
static void mlx5e_set_inner_ttc_ft_params(struct ttc_params *ttc_params)
{ {
struct mlx5_flow_table_attr *ft_attr = &ttc_params->ft_attr; struct mlx5_flow_table_attr *ft_attr = &ttc_params->ft_attr;
int tt;
ft_attr->max_fte = MLX5_INNER_TTC_TABLE_SIZE; memset(ttc_params, 0, sizeof(*ttc_params));
ttc_params->ns = mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_KERNEL);
ft_attr->level = MLX5E_INNER_TTC_FT_LEVEL; ft_attr->level = MLX5E_INNER_TTC_FT_LEVEL;
ft_attr->prio = MLX5E_NIC_PRIO; ft_attr->prio = MLX5E_NIC_PRIO;
for (tt = 0; tt < MLX5_NUM_TT; tt++) {
ttc_params->dests[tt].type = MLX5_FLOW_DESTINATION_TYPE_TIR;
ttc_params->dests[tt].tir_num =
tt == MLX5_TT_ANY ?
mlx5e_rx_res_get_tirn_direct(priv->rx_res, 0) :
mlx5e_rx_res_get_tirn_rss_inner(priv->rx_res,
tt);
}
} }
void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params) void mlx5e_set_ttc_params(struct mlx5e_priv *priv,
struct ttc_params *ttc_params, bool tunnel)
{ {
struct mlx5_flow_table_attr *ft_attr = &ttc_params->ft_attr; struct mlx5_flow_table_attr *ft_attr = &ttc_params->ft_attr;
int tt;
ft_attr->max_fte = MLX5_TTC_TABLE_SIZE; memset(ttc_params, 0, sizeof(*ttc_params));
ttc_params->ns = mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_KERNEL);
ft_attr->level = MLX5E_TTC_FT_LEVEL; ft_attr->level = MLX5E_TTC_FT_LEVEL;
ft_attr->prio = MLX5E_NIC_PRIO; ft_attr->prio = MLX5E_NIC_PRIO;
for (tt = 0; tt < MLX5_NUM_TT; tt++) {
ttc_params->dests[tt].type = MLX5_FLOW_DESTINATION_TYPE_TIR;
ttc_params->dests[tt].tir_num =
tt == MLX5_TT_ANY ?
mlx5e_rx_res_get_tirn_direct(priv->rx_res, 0) :
mlx5e_rx_res_get_tirn_rss(priv->rx_res, tt);
}
ttc_params->inner_ttc = tunnel;
if (!tunnel || !mlx5_tunnel_inner_ft_supported(priv->mdev))
return;
for (tt = 0; tt < MLX5_NUM_TUNNEL_TT; tt++) {
ttc_params->tunnel_dests[tt].type =
MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
ttc_params->tunnel_dests[tt].ft = priv->fs.inner_ttc.t;
}
} }
static int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params, static int mlx5_create_inner_ttc_table(struct mlx5_core_dev *dev,
struct mlx5e_ttc_table *ttc) struct ttc_params *params,
struct mlx5_ttc_table *ttc)
{ {
struct mlx5e_flow_table *ft = &ttc->ft;
int err; int err;
ft->t = mlx5_create_flow_table(priv->fs.ns, &params->ft_attr); WARN_ON_ONCE(params->ft_attr.max_fte);
if (IS_ERR(ft->t)) { params->ft_attr.max_fte = MLX5_INNER_TTC_TABLE_SIZE;
err = PTR_ERR(ft->t); ttc->t = mlx5_create_flow_table(params->ns, &params->ft_attr);
ft->t = NULL; if (IS_ERR(ttc->t)) {
err = PTR_ERR(ttc->t);
ttc->t = NULL;
return err; return err;
} }
err = mlx5e_create_inner_ttc_table_groups(ttc); err = mlx5_create_inner_ttc_table_groups(ttc);
if (err) if (err)
goto err; goto destroy_ttc;
err = mlx5e_generate_inner_ttc_table_rules(priv, params, ttc); err = mlx5_generate_inner_ttc_table_rules(dev, params, ttc);
if (err) if (err)
goto err; goto destroy_ttc;
return 0; return 0;
err: destroy_ttc:
mlx5e_destroy_flow_table(ft); mlx5_destroy_ttc_table(ttc);
return err; return err;
} }
static void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv, void mlx5_destroy_ttc_table(struct mlx5_ttc_table *ttc)
struct mlx5e_ttc_table *ttc)
{ {
mlx5e_cleanup_ttc_rules(ttc); int i;
mlx5e_destroy_flow_table(&ttc->ft);
mlx5_cleanup_ttc_rules(ttc);
for (i = ttc->num_groups - 1; i >= 0; i--) {
if (!IS_ERR_OR_NULL(ttc->g[i]))
mlx5_destroy_flow_group(ttc->g[i]);
ttc->g[i] = NULL;
}
ttc->num_groups = 0;
kfree(ttc->g);
mlx5_destroy_flow_table(ttc->t);
ttc->t = NULL;
} }
void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv, static void mlx5_destroy_inner_ttc_table(struct mlx5_ttc_table *ttc)
struct mlx5e_ttc_table *ttc)
{ {
mlx5e_cleanup_ttc_rules(ttc); mlx5_destroy_ttc_table(ttc);
mlx5e_destroy_flow_table(&ttc->ft);
} }
int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params, int mlx5_create_ttc_table(struct mlx5_core_dev *dev, struct ttc_params *params,
struct mlx5e_ttc_table *ttc) struct mlx5_ttc_table *ttc)
{ {
bool match_ipv_outer = MLX5_CAP_FLOWTABLE_NIC_RX(priv->mdev, ft_field_support.outer_ip_version); bool match_ipv_outer =
struct mlx5e_flow_table *ft = &ttc->ft; MLX5_CAP_FLOWTABLE_NIC_RX(dev,
ft_field_support.outer_ip_version);
int err; int err;
ft->t = mlx5_create_flow_table(priv->fs.ns, &params->ft_attr); WARN_ON_ONCE(params->ft_attr.max_fte);
if (IS_ERR(ft->t)) { params->ft_attr.max_fte = MLX5_TTC_TABLE_SIZE;
err = PTR_ERR(ft->t); ttc->t = mlx5_create_flow_table(params->ns, &params->ft_attr);
ft->t = NULL; if (IS_ERR(ttc->t)) {
err = PTR_ERR(ttc->t);
ttc->t = NULL;
return err; return err;
} }
err = mlx5e_create_ttc_table_groups(ttc, match_ipv_outer); err = mlx5_create_ttc_table_groups(ttc, match_ipv_outer);
if (err) if (err)
goto err; goto destroy_ttc;
err = mlx5e_generate_ttc_table_rules(priv, params, ttc); err = mlx5_generate_ttc_table_rules(dev, params, ttc);
if (err) if (err)
goto err; goto destroy_ttc;
return 0; return 0;
err: destroy_ttc:
mlx5e_destroy_flow_table(ft); mlx5_destroy_ttc_table(ttc);
return err; return err;
} }
int mlx5e_ttc_fwd_dest(struct mlx5e_priv *priv, enum mlx5_traffic_types type, int mlx5_ttc_fwd_dest(struct mlx5_ttc_table *ttc, enum mlx5_traffic_types type,
struct mlx5_flow_destination *new_dest) struct mlx5_flow_destination *new_dest)
{ {
return mlx5_modify_rule_destination(priv->fs.ttc.rules[type].rule, new_dest, NULL); return mlx5_modify_rule_destination(ttc->rules[type].rule, new_dest,
NULL);
} }
struct mlx5_flow_destination struct mlx5_flow_destination
mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, enum mlx5_traffic_types type) mlx5_ttc_get_default_dest(struct mlx5_ttc_table *ttc,
enum mlx5_traffic_types type)
{ {
struct mlx5_flow_destination *dest = &priv->fs.ttc.rules[type].default_dest; struct mlx5_flow_destination *dest = &ttc->rules[type].default_dest;
WARN_ONCE(dest->type != MLX5_FLOW_DESTINATION_TYPE_TIR, WARN_ONCE(dest->type != MLX5_FLOW_DESTINATION_TYPE_TIR,
"TTC[%d] default dest is not setup yet", type); "TTC[%d] default dest is not setup yet", type);
...@@ -1433,11 +1458,12 @@ mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, enum mlx5_traffic_types type ...@@ -1433,11 +1458,12 @@ mlx5e_ttc_get_default_dest(struct mlx5e_priv *priv, enum mlx5_traffic_types type
return *dest; return *dest;
} }
int mlx5e_ttc_fwd_default_dest(struct mlx5e_priv *priv, enum mlx5_traffic_types type) int mlx5_ttc_fwd_default_dest(struct mlx5_ttc_table *ttc,
enum mlx5_traffic_types type)
{ {
struct mlx5_flow_destination dest = mlx5e_ttc_get_default_dest(priv, type); struct mlx5_flow_destination dest = mlx5_ttc_get_default_dest(ttc, type);
return mlx5e_ttc_fwd_dest(priv, type, &dest); return mlx5_ttc_fwd_dest(ttc, type, &dest);
} }
static void mlx5e_del_l2_flow_rule(struct mlx5e_priv *priv, static void mlx5e_del_l2_flow_rule(struct mlx5e_priv *priv,
...@@ -1470,7 +1496,7 @@ static int mlx5e_add_l2_flow_rule(struct mlx5e_priv *priv, ...@@ -1470,7 +1496,7 @@ static int mlx5e_add_l2_flow_rule(struct mlx5e_priv *priv,
outer_headers.dmac_47_16); outer_headers.dmac_47_16);
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest.ft = priv->fs.ttc.ft.t; dest.ft = priv->fs.ttc.t;
switch (type) { switch (type) {
case MLX5E_FULLMATCH: case MLX5E_FULLMATCH:
...@@ -1769,7 +1795,7 @@ static void mlx5e_destroy_vlan_table(struct mlx5e_priv *priv) ...@@ -1769,7 +1795,7 @@ static void mlx5e_destroy_vlan_table(struct mlx5e_priv *priv)
int mlx5e_create_flow_steering(struct mlx5e_priv *priv) int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
{ {
struct ttc_params ttc_params = {}; struct ttc_params ttc_params = {};
int tt, err; int err;
priv->fs.ns = mlx5_get_flow_namespace(priv->mdev, priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_KERNEL); MLX5_FLOW_NAMESPACE_KERNEL);
...@@ -1784,27 +1810,20 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) ...@@ -1784,27 +1810,20 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
priv->netdev->hw_features &= ~NETIF_F_NTUPLE; priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
} }
mlx5e_set_ttc_basic_params(priv, &ttc_params);
if (mlx5_tunnel_inner_ft_supported(priv->mdev)) { if (mlx5_tunnel_inner_ft_supported(priv->mdev)) {
mlx5e_set_inner_ttc_ft_params(&ttc_params); mlx5e_set_inner_ttc_params(priv, &ttc_params);
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) err = mlx5_create_inner_ttc_table(priv->mdev, &ttc_params,
ttc_params.indir_tirn[tt] = &priv->fs.inner_ttc);
mlx5e_rx_res_get_tirn_rss_inner(priv->rx_res, tt);
err = mlx5e_create_inner_ttc_table(priv, &ttc_params, &priv->fs.inner_ttc);
if (err) { if (err) {
netdev_err(priv->netdev, "Failed to create inner ttc table, err=%d\n", netdev_err(priv->netdev,
"Failed to create inner ttc table, err=%d\n",
err); err);
goto err_destroy_arfs_tables; goto err_destroy_arfs_tables;
} }
} }
mlx5e_set_ttc_ft_params(&ttc_params); mlx5e_set_ttc_params(priv, &ttc_params, true);
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &priv->fs.ttc);
ttc_params.indir_tirn[tt] = mlx5e_rx_res_get_tirn_rss(priv->rx_res, tt);
err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc);
if (err) { if (err) {
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n", netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
err); err);
...@@ -1838,10 +1857,10 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv) ...@@ -1838,10 +1857,10 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
err_destroy_l2_table: err_destroy_l2_table:
mlx5e_destroy_l2_table(priv); mlx5e_destroy_l2_table(priv);
err_destroy_ttc_table: err_destroy_ttc_table:
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); mlx5_destroy_ttc_table(&priv->fs.ttc);
err_destroy_inner_ttc_table: err_destroy_inner_ttc_table:
if (mlx5_tunnel_inner_ft_supported(priv->mdev)) if (mlx5_tunnel_inner_ft_supported(priv->mdev))
mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc); mlx5_destroy_inner_ttc_table(&priv->fs.inner_ttc);
err_destroy_arfs_tables: err_destroy_arfs_tables:
mlx5e_arfs_destroy_tables(priv); mlx5e_arfs_destroy_tables(priv);
...@@ -1853,9 +1872,9 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv) ...@@ -1853,9 +1872,9 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv)
mlx5e_ptp_free_rx_fs(priv); mlx5e_ptp_free_rx_fs(priv);
mlx5e_destroy_vlan_table(priv); mlx5e_destroy_vlan_table(priv);
mlx5e_destroy_l2_table(priv); mlx5e_destroy_l2_table(priv);
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); mlx5_destroy_ttc_table(&priv->fs.ttc);
if (mlx5_tunnel_inner_ft_supported(priv->mdev)) if (mlx5_tunnel_inner_ft_supported(priv->mdev))
mlx5e_destroy_inner_ttc_table(priv, &priv->fs.inner_ttc); mlx5_destroy_inner_ttc_table(&priv->fs.inner_ttc);
mlx5e_arfs_destroy_tables(priv); mlx5e_arfs_destroy_tables(priv);
mlx5e_ethtool_cleanup_steering(priv); mlx5e_ethtool_cleanup_steering(priv);
} }
...@@ -647,25 +647,20 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv) ...@@ -647,25 +647,20 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
{ {
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep; struct mlx5_eswitch_rep *rep = rpriv->rep;
struct mlx5e_rx_res *res = priv->rx_res;
struct ttc_params ttc_params = {}; struct ttc_params ttc_params = {};
int tt, err; int err;
priv->fs.ns = mlx5_get_flow_namespace(priv->mdev, priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_KERNEL); MLX5_FLOW_NAMESPACE_KERNEL);
/* The inner_ttc in the ttc params is intentionally not set */ /* The inner_ttc in the ttc params is intentionally not set */
ttc_params.any_tt_tirn = mlx5e_rx_res_get_tirn_direct(res, 0); mlx5e_set_ttc_params(priv, &ttc_params, false);
mlx5e_set_ttc_ft_params(&ttc_params);
if (rep->vport != MLX5_VPORT_UPLINK) if (rep->vport != MLX5_VPORT_UPLINK)
/* To give uplik rep TTC a lower level for chaining from root ft */ /* To give uplik rep TTC a lower level for chaining from root ft */
ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1; ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1;
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &priv->fs.ttc);
ttc_params.indir_tirn[tt] = mlx5e_rx_res_get_tirn_rss(res, tt);
err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc);
if (err) { if (err) {
netdev_err(priv->netdev, "Failed to create rep ttc table, err=%d\n", err); netdev_err(priv->netdev, "Failed to create rep ttc table, err=%d\n", err);
return err; return err;
...@@ -685,7 +680,7 @@ static int mlx5e_create_rep_root_ft(struct mlx5e_priv *priv) ...@@ -685,7 +680,7 @@ static int mlx5e_create_rep_root_ft(struct mlx5e_priv *priv)
/* non uplik reps will skip any bypass tables and go directly to /* non uplik reps will skip any bypass tables and go directly to
* their own ttc * their own ttc
*/ */
rpriv->root_ft = priv->fs.ttc.ft.t; rpriv->root_ft = priv->fs.ttc.t;
return 0; return 0;
} }
...@@ -799,7 +794,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv) ...@@ -799,7 +794,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
err_destroy_root_ft: err_destroy_root_ft:
mlx5e_destroy_rep_root_ft(priv); mlx5e_destroy_rep_root_ft(priv);
err_destroy_ttc_table: err_destroy_ttc_table:
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); mlx5_destroy_ttc_table(&priv->fs.ttc);
err_destroy_rx_res: err_destroy_rx_res:
mlx5e_rx_res_destroy(priv->rx_res); mlx5e_rx_res_destroy(priv->rx_res);
err_close_drop_rq: err_close_drop_rq:
...@@ -814,7 +809,7 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv) ...@@ -814,7 +809,7 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
mlx5e_ethtool_cleanup_steering(priv); mlx5e_ethtool_cleanup_steering(priv);
rep_vport_rx_rule_destroy(priv); rep_vport_rx_rule_destroy(priv);
mlx5e_destroy_rep_root_ft(priv); mlx5e_destroy_rep_root_ft(priv);
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); mlx5_destroy_ttc_table(&priv->fs.ttc);
mlx5e_rx_res_destroy(priv->rx_res); mlx5e_rx_res_destroy(priv->rx_res);
mlx5e_close_drop_rq(&priv->drop_rq); mlx5e_close_drop_rq(&priv->drop_rq);
mlx5e_rx_res_free(priv->rx_res); mlx5e_rx_res_free(priv->rx_res);
......
...@@ -345,7 +345,7 @@ struct mlx5e_hairpin { ...@@ -345,7 +345,7 @@ struct mlx5e_hairpin {
int num_channels; int num_channels;
struct mlx5e_rqt indir_rqt; struct mlx5e_rqt indir_rqt;
struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS]; struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS];
struct mlx5e_ttc_table ttc; struct mlx5_ttc_table ttc;
}; };
struct mlx5e_hairpin_entry { struct mlx5e_hairpin_entry {
...@@ -595,12 +595,16 @@ static void mlx5e_hairpin_set_ttc_params(struct mlx5e_hairpin *hp, ...@@ -595,12 +595,16 @@ static void mlx5e_hairpin_set_ttc_params(struct mlx5e_hairpin *hp,
memset(ttc_params, 0, sizeof(*ttc_params)); memset(ttc_params, 0, sizeof(*ttc_params));
ttc_params->any_tt_tirn = mlx5e_tir_get_tirn(&hp->direct_tir); ttc_params->ns = mlx5_get_flow_namespace(hp->func_mdev,
MLX5_FLOW_NAMESPACE_KERNEL);
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) for (tt = 0; tt < MLX5_NUM_TT; tt++) {
ttc_params->indir_tirn[tt] = mlx5e_tir_get_tirn(&hp->indir_tir[tt]); ttc_params->dests[tt].type = MLX5_FLOW_DESTINATION_TYPE_TIR;
ttc_params->dests[tt].tir_num =
tt == MLX5_TT_ANY ?
mlx5e_tir_get_tirn(&hp->direct_tir) :
mlx5e_tir_get_tirn(&hp->indir_tir[tt]);
}
ft_attr->max_fte = MLX5_TTC_TABLE_SIZE;
ft_attr->level = MLX5E_TC_TTC_FT_LEVEL; ft_attr->level = MLX5E_TC_TTC_FT_LEVEL;
ft_attr->prio = MLX5E_TC_PRIO; ft_attr->prio = MLX5E_TC_PRIO;
} }
...@@ -620,12 +624,12 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp) ...@@ -620,12 +624,12 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
goto err_create_indirect_tirs; goto err_create_indirect_tirs;
mlx5e_hairpin_set_ttc_params(hp, &ttc_params); mlx5e_hairpin_set_ttc_params(hp, &ttc_params);
err = mlx5e_create_ttc_table(priv, &ttc_params, &hp->ttc); err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &hp->ttc);
if (err) if (err)
goto err_create_ttc_table; goto err_create_ttc_table;
netdev_dbg(priv->netdev, "add hairpin: using %d channels rss ttc table id %x\n", netdev_dbg(priv->netdev, "add hairpin: using %d channels rss ttc table id %x\n",
hp->num_channels, hp->ttc.ft.t->id); hp->num_channels, hp->ttc.t->id);
return 0; return 0;
...@@ -639,9 +643,7 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp) ...@@ -639,9 +643,7 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
static void mlx5e_hairpin_rss_cleanup(struct mlx5e_hairpin *hp) static void mlx5e_hairpin_rss_cleanup(struct mlx5e_hairpin *hp)
{ {
struct mlx5e_priv *priv = hp->func_priv; mlx5_destroy_ttc_table(&hp->ttc);
mlx5e_destroy_ttc_table(priv, &hp->ttc);
mlx5e_hairpin_destroy_indirect_tirs(hp); mlx5e_hairpin_destroy_indirect_tirs(hp);
mlx5e_rqt_destroy(&hp->indir_rqt); mlx5e_rqt_destroy(&hp->indir_rqt);
} }
...@@ -885,7 +887,7 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv, ...@@ -885,7 +887,7 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
attach_flow: attach_flow:
if (hpe->hp->num_channels > 1) { if (hpe->hp->num_channels > 1) {
flow_flag_set(flow, HAIRPIN_RSS); flow_flag_set(flow, HAIRPIN_RSS);
flow->attr->nic_attr->hairpin_ft = hpe->hp->ttc.ft.t; flow->attr->nic_attr->hairpin_ft = hpe->hp->ttc.t;
} else { } else {
flow->attr->nic_attr->hairpin_tirn = mlx5e_tir_get_tirn(&hpe->hp->direct_tir); flow->attr->nic_attr->hairpin_tirn = mlx5e_tir_get_tirn(&hpe->hp->direct_tir);
} }
......
...@@ -315,7 +315,7 @@ static void mlx5i_cleanup_tx(struct mlx5e_priv *priv) ...@@ -315,7 +315,7 @@ static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)
static int mlx5i_create_flow_steering(struct mlx5e_priv *priv) static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
{ {
struct ttc_params ttc_params = {}; struct ttc_params ttc_params = {};
int tt, err; int err;
priv->fs.ns = mlx5_get_flow_namespace(priv->mdev, priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
MLX5_FLOW_NAMESPACE_KERNEL); MLX5_FLOW_NAMESPACE_KERNEL);
...@@ -330,12 +330,8 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv) ...@@ -330,12 +330,8 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
priv->netdev->hw_features &= ~NETIF_F_NTUPLE; priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
} }
mlx5e_set_ttc_basic_params(priv, &ttc_params); mlx5e_set_ttc_params(priv, &ttc_params, true);
mlx5e_set_ttc_ft_params(&ttc_params); err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &priv->fs.ttc);
for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
ttc_params.indir_tirn[tt] = mlx5e_rx_res_get_tirn_rss(priv->rx_res, tt);
err = mlx5e_create_ttc_table(priv, &ttc_params, &priv->fs.ttc);
if (err) { if (err) {
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n", netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
err); err);
...@@ -352,7 +348,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv) ...@@ -352,7 +348,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv) static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv)
{ {
mlx5e_destroy_ttc_table(priv, &priv->fs.ttc); mlx5_destroy_ttc_table(&priv->fs.ttc);
mlx5e_arfs_destroy_tables(priv); mlx5e_arfs_destroy_tables(priv);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment