Skip to content

Commit

Permalink
net/mlx5: Embed mlx5_ttc_table
Browse files Browse the repository at this point in the history
mlx5_ttc_table struct shouldn't be exposed to the users so
this patch make it internal to ttc.

In addition add a getter function to get the TTC flow table for users
that need to add a rule which points on it.

Signed-off-by: Maor Gottlieb <maorg@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
  • Loading branch information
Maor Gottlieb authored and Saeed Mahameed committed Aug 3, 2021
1 parent 371cf74 commit f4b4594
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 89 deletions.
7 changes: 5 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ struct mlx5e_flow_steering {
struct mlx5e_promisc_table promisc;
struct mlx5e_vlan_table *vlan;
struct mlx5e_l2_table l2;
struct mlx5_ttc_table ttc;
struct mlx5_ttc_table inner_ttc;
struct mlx5_ttc_table *ttc;
struct mlx5_ttc_table *inner_ttc;
#ifdef CONFIG_MLX5_EN_ARFS
struct mlx5e_arfs_tables *arfs;
#endif
Expand All @@ -185,6 +185,9 @@ struct mlx5e_flow_steering {
void mlx5e_set_ttc_params(struct mlx5e_priv *priv,
struct ttc_params *ttc_params, bool tunnel);

void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
int mlx5e_create_ttc_table(struct mlx5e_priv *priv);

void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);

void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
Expand Down
13 changes: 6 additions & 7 deletions drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_t = &fs_udp->tables[type];

dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, 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);
if (IS_ERR(rule)) {
err = PTR_ERR(rule);
Expand Down Expand Up @@ -259,7 +259,7 @@ static int fs_udp_disable(struct mlx5e_priv *priv)

for (i = 0; i < FS_UDP_NUM_TYPES; i++) {
/* Modify ttc rules destination to point back to the indir TIRs */
err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, fs_udp2tt(i));
err = mlx5_ttc_fwd_default_dest(priv->fs.ttc, fs_udp2tt(i));
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n",
Expand All @@ -281,8 +281,7 @@ static int fs_udp_enable(struct mlx5e_priv *priv)
dest.ft = priv->fs.udp->tables[i].t;

/* Modify ttc rules destination to point on the accel_fs FTs */
err = mlx5_ttc_fwd_dest(&priv->fs.ttc, fs_udp2tt(i),
&dest);
err = mlx5_ttc_fwd_dest(priv->fs.ttc, fs_udp2tt(i), &dest);
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] destination to accel failed, err(%d)\n",
Expand Down Expand Up @@ -402,7 +401,7 @@ static int fs_any_add_default_rule(struct mlx5e_priv *priv)
fs_any = priv->fs.any;
fs_any_t = &fs_any->table;

dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, 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);
if (IS_ERR(rule)) {
err = PTR_ERR(rule);
Expand Down Expand Up @@ -515,7 +514,7 @@ static int fs_any_disable(struct mlx5e_priv *priv)
int err;

/* Modify ttc rules destination to point back to the indir TIRs */
err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, MLX5_TT_ANY);
err = mlx5_ttc_fwd_default_dest(priv->fs.ttc, MLX5_TT_ANY);
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n",
Expand All @@ -534,7 +533,7 @@ static int fs_any_enable(struct mlx5e_priv *priv)
dest.ft = priv->fs.any->table.t;

/* Modify ttc rules destination to point on the accel_fs FTs */
err = mlx5_ttc_fwd_dest(&priv->fs.ttc, MLX5_TT_ANY, &dest);
err = mlx5_ttc_fwd_dest(priv->fs.ttc, MLX5_TT_ANY, &dest);
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] destination to accel failed, err(%d)\n",
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int accel_fs_tcp_add_default_rule(struct mlx5e_priv *priv,
fs_tcp = priv->fs.accel_tcp;
accel_fs_t = &fs_tcp->tables[type];

dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, 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);
if (IS_ERR(rule)) {
err = PTR_ERR(rule);
Expand Down Expand Up @@ -307,7 +307,7 @@ static int accel_fs_tcp_disable(struct mlx5e_priv *priv)

for (i = 0; i < ACCEL_FS_TCP_NUM_TYPES; i++) {
/* Modify ttc rules destination to point back to the indir TIRs */
err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, fs_accel2tt(i));
err = mlx5_ttc_fwd_default_dest(priv->fs.ttc, fs_accel2tt(i));
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n",
Expand All @@ -329,7 +329,7 @@ static int accel_fs_tcp_enable(struct mlx5e_priv *priv)
dest.ft = priv->fs.accel_tcp->tables[i].t;

/* Modify ttc rules destination to point on the accel_fs FTs */
err = mlx5_ttc_fwd_dest(&priv->fs.ttc, fs_accel2tt(i), &dest);
err = mlx5_ttc_fwd_dest(priv->fs.ttc, fs_accel2tt(i), &dest);
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] destination to accel failed, err(%d)\n",
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ static int rx_create(struct mlx5e_priv *priv, enum accel_fs_esp_type type)
accel_esp = priv->ipsec->rx_fs;
fs_prot = &accel_esp->fs_prot[type];

fs_prot->default_dest = mlx5_ttc_get_default_dest(&priv->fs.ttc, 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);
if (err)
Expand Down Expand Up @@ -301,7 +302,7 @@ static int rx_ft_get(struct mlx5e_priv *priv, enum accel_fs_esp_type type)
/* connect */
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest.ft = fs_prot->ft;
mlx5_ttc_fwd_dest(&priv->fs.ttc, fs_esp2tt(type), &dest);
mlx5_ttc_fwd_dest(priv->fs.ttc, fs_esp2tt(type), &dest);

out:
mutex_unlock(&fs_prot->prot_mutex);
Expand All @@ -320,7 +321,7 @@ static void rx_ft_put(struct mlx5e_priv *priv, enum accel_fs_esp_type type)
goto out;

/* disconnect */
mlx5_ttc_fwd_default_dest(&priv->fs.ttc, fs_esp2tt(type));
mlx5_ttc_fwd_default_dest(priv->fs.ttc, fs_esp2tt(type));

/* remove FT */
rx_destroy(priv, type);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static int arfs_disable(struct mlx5e_priv *priv)

for (i = 0; i < ARFS_NUM_TYPES; i++) {
/* Modify ttc rules destination back to their default */
err = mlx5_ttc_fwd_default_dest(&priv->fs.ttc, arfs_get_tt(i));
err = mlx5_ttc_fwd_default_dest(priv->fs.ttc, arfs_get_tt(i));
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] default destination failed, err(%d)\n",
Expand Down Expand Up @@ -149,7 +149,7 @@ int mlx5e_arfs_enable(struct mlx5e_priv *priv)
for (i = 0; i < ARFS_NUM_TYPES; i++) {
dest.ft = priv->fs.arfs->arfs_tables[i].ft.t;
/* Modify ttc rules destination to point on the aRFS FTs */
err = mlx5_ttc_fwd_dest(&priv->fs.ttc, arfs_get_tt(i), &dest);
err = mlx5_ttc_fwd_dest(priv->fs.ttc, arfs_get_tt(i), &dest);
if (err) {
netdev_err(priv->netdev,
"%s: modify ttc[%d] dest to arfs, failed err(%d)\n",
Expand Down
74 changes: 52 additions & 22 deletions drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ static int mlx5e_add_promisc_rule(struct mlx5e_priv *priv)
if (!spec)
return -ENOMEM;
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest.ft = priv->fs.ttc.t;
dest.ft = mlx5_get_ttc_flow_table(priv->fs.ttc);

rule_p = &priv->fs.promisc.rule;
*rule_p = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1);
Expand Down Expand Up @@ -904,7 +904,8 @@ void mlx5e_set_ttc_params(struct mlx5e_priv *priv,
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;
ttc_params->tunnel_dests[tt].ft =
mlx5_get_ttc_flow_table(priv->fs.inner_ttc);
}
}

Expand Down Expand Up @@ -938,7 +939,7 @@ static int mlx5e_add_l2_flow_rule(struct mlx5e_priv *priv,
outer_headers.dmac_47_16);

dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest.ft = priv->fs.ttc.t;
dest.ft = mlx5_get_ttc_flow_table(priv->fs.ttc);

switch (type) {
case MLX5E_FULLMATCH:
Expand Down Expand Up @@ -1234,9 +1235,45 @@ static void mlx5e_destroy_vlan_table(struct mlx5e_priv *priv)
kvfree(priv->fs.vlan);
}

int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
static void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv)
{
if (!mlx5_tunnel_inner_ft_supported(priv->mdev))
return;
mlx5_destroy_ttc_table(priv->fs.inner_ttc);
}

void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv)
{
mlx5_destroy_ttc_table(priv->fs.ttc);
}

static int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv)
{
struct ttc_params ttc_params = {};

if (!mlx5_tunnel_inner_ft_supported(priv->mdev))
return 0;

mlx5e_set_inner_ttc_params(priv, &ttc_params);
priv->fs.inner_ttc = mlx5_create_ttc_table(priv->mdev, &ttc_params);
if (IS_ERR(priv->fs.inner_ttc))
return PTR_ERR(priv->fs.inner_ttc);
return 0;
}

int mlx5e_create_ttc_table(struct mlx5e_priv *priv)
{
struct ttc_params ttc_params = {};

mlx5e_set_ttc_params(priv, &ttc_params, true);
priv->fs.ttc = mlx5_create_ttc_table(priv->mdev, &ttc_params);
if (IS_ERR(priv->fs.ttc))
return PTR_ERR(priv->fs.ttc);
return 0;
}

int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
{
int err;

priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
Expand All @@ -1252,20 +1289,15 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
}

if (mlx5_tunnel_inner_ft_supported(priv->mdev)) {
mlx5e_set_inner_ttc_params(priv, &ttc_params);
err = mlx5_create_inner_ttc_table(priv->mdev, &ttc_params,
&priv->fs.inner_ttc);
if (err) {
netdev_err(priv->netdev,
"Failed to create inner ttc table, err=%d\n",
err);
goto err_destroy_arfs_tables;
}
err = mlx5e_create_inner_ttc_table(priv);
if (err) {
netdev_err(priv->netdev,
"Failed to create inner ttc table, err=%d\n",
err);
goto err_destroy_arfs_tables;
}

mlx5e_set_ttc_params(priv, &ttc_params, true);
err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &priv->fs.ttc);
err = mlx5e_create_ttc_table(priv);
if (err) {
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
err);
Expand Down Expand Up @@ -1299,10 +1331,9 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv)
err_destroy_l2_table:
mlx5e_destroy_l2_table(priv);
err_destroy_ttc_table:
mlx5_destroy_ttc_table(&priv->fs.ttc);
mlx5e_destroy_ttc_table(priv);
err_destroy_inner_ttc_table:
if (mlx5_tunnel_inner_ft_supported(priv->mdev))
mlx5_destroy_inner_ttc_table(&priv->fs.inner_ttc);
mlx5e_destroy_inner_ttc_table(priv);
err_destroy_arfs_tables:
mlx5e_arfs_destroy_tables(priv);

Expand All @@ -1314,9 +1345,8 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv)
mlx5e_ptp_free_rx_fs(priv);
mlx5e_destroy_vlan_table(priv);
mlx5e_destroy_l2_table(priv);
mlx5_destroy_ttc_table(&priv->fs.ttc);
if (mlx5_tunnel_inner_ft_supported(priv->mdev))
mlx5_destroy_inner_ttc_table(&priv->fs.inner_ttc);
mlx5e_destroy_ttc_table(priv);
mlx5e_destroy_inner_ttc_table(priv);
mlx5e_arfs_destroy_tables(priv);
mlx5e_ethtool_cleanup_steering(priv);
}
14 changes: 8 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,11 @@ static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
/* To give uplik rep TTC a lower level for chaining from root ft */
ttc_params.ft_attr.level = MLX5E_TTC_FT_LEVEL + 1;

err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &priv->fs.ttc);
if (err) {
netdev_err(priv->netdev, "Failed to create rep ttc table, err=%d\n", err);
priv->fs.ttc = mlx5_create_ttc_table(priv->mdev, &ttc_params);
if (IS_ERR(priv->fs.ttc)) {
err = PTR_ERR(priv->fs.ttc);
netdev_err(priv->netdev, "Failed to create rep ttc table, err=%d\n",
err);
return err;
}
return 0;
Expand All @@ -680,7 +682,7 @@ static int mlx5e_create_rep_root_ft(struct mlx5e_priv *priv)
/* non uplik reps will skip any bypass tables and go directly to
* their own ttc
*/
rpriv->root_ft = priv->fs.ttc.t;
rpriv->root_ft = mlx5_get_ttc_flow_table(priv->fs.ttc);
return 0;
}

Expand Down Expand Up @@ -794,7 +796,7 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
err_destroy_root_ft:
mlx5e_destroy_rep_root_ft(priv);
err_destroy_ttc_table:
mlx5_destroy_ttc_table(&priv->fs.ttc);
mlx5_destroy_ttc_table(priv->fs.ttc);
err_destroy_rx_res:
mlx5e_rx_res_destroy(priv->rx_res);
err_close_drop_rq:
Expand All @@ -809,7 +811,7 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
mlx5e_ethtool_cleanup_steering(priv);
rep_vport_rx_rule_destroy(priv);
mlx5e_destroy_rep_root_ft(priv);
mlx5_destroy_ttc_table(&priv->fs.ttc);
mlx5_destroy_ttc_table(priv->fs.ttc);
mlx5e_rx_res_destroy(priv->rx_res);
mlx5e_close_drop_rq(&priv->drop_rq);
mlx5e_rx_res_free(priv->rx_res);
Expand Down
16 changes: 10 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ struct mlx5e_hairpin {
int num_channels;
struct mlx5e_rqt indir_rqt;
struct mlx5e_tir indir_tir[MLX5E_NUM_INDIR_TIRS];
struct mlx5_ttc_table ttc;
struct mlx5_ttc_table *ttc;
};

struct mlx5e_hairpin_entry {
Expand Down Expand Up @@ -624,12 +624,15 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)
goto err_create_indirect_tirs;

mlx5e_hairpin_set_ttc_params(hp, &ttc_params);
err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &hp->ttc);
if (err)
hp->ttc = mlx5_create_ttc_table(priv->mdev, &ttc_params);
if (IS_ERR(hp->ttc)) {
err = PTR_ERR(hp->ttc);
goto err_create_ttc_table;
}

netdev_dbg(priv->netdev, "add hairpin: using %d channels rss ttc table id %x\n",
hp->num_channels, hp->ttc.t->id);
hp->num_channels,
mlx5_get_ttc_flow_table(priv->fs.ttc)->id);

return 0;

Expand All @@ -643,7 +646,7 @@ static int mlx5e_hairpin_rss_init(struct mlx5e_hairpin *hp)

static void mlx5e_hairpin_rss_cleanup(struct mlx5e_hairpin *hp)
{
mlx5_destroy_ttc_table(&hp->ttc);
mlx5_destroy_ttc_table(hp->ttc);
mlx5e_hairpin_destroy_indirect_tirs(hp);
mlx5e_rqt_destroy(&hp->indir_rqt);
}
Expand Down Expand Up @@ -887,7 +890,8 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
attach_flow:
if (hpe->hp->num_channels > 1) {
flow_flag_set(flow, HAIRPIN_RSS);
flow->attr->nic_attr->hairpin_ft = hpe->hp->ttc.t;
flow->attr->nic_attr->hairpin_ft =
mlx5_get_ttc_flow_table(hpe->hp->ttc);
} else {
flow->attr->nic_attr->hairpin_tirn = mlx5e_tir_get_tirn(&hpe->hp->direct_tir);
}
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)

static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
{
struct ttc_params ttc_params = {};
int err;

priv->fs.ns = mlx5_get_flow_namespace(priv->mdev,
Expand All @@ -330,8 +329,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)
priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
}

mlx5e_set_ttc_params(priv, &ttc_params, true);
err = mlx5_create_ttc_table(priv->mdev, &ttc_params, &priv->fs.ttc);
err = mlx5e_create_ttc_table(priv);
if (err) {
netdev_err(priv->netdev, "Failed to create ttc table, err=%d\n",
err);
Expand All @@ -348,7 +346,7 @@ static int mlx5i_create_flow_steering(struct mlx5e_priv *priv)

static void mlx5i_destroy_flow_steering(struct mlx5e_priv *priv)
{
mlx5_destroy_ttc_table(&priv->fs.ttc);
mlx5e_destroy_ttc_table(priv);
mlx5e_arfs_destroy_tables(priv);
}

Expand Down
Loading

0 comments on commit f4b4594

Please sign in to comment.