Skip to content

Commit d1a3138

Browse files
Paul BlakeySaeed Mahameed
authored andcommitted
net/mlx5e: TC, Move flow hashtable to be per rep
To allow shared tc block offload between two or more reps of the same eswitch, move the tc flow hashtable to be per rep, instead of per eswitch. Signed-off-by: Paul Blakey <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent bfbdd77 commit d1a3138

File tree

5 files changed

+43
-32
lines changed

5 files changed

+43
-32
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@ int mlx5e_rep_tc_init(struct mlx5e_rep_priv *rpriv)
263263
INIT_LIST_HEAD(&uplink_priv->unready_flows);
264264

265265
/* init shared tc flow table */
266-
err = mlx5e_tc_esw_init(&uplink_priv->tc_ht);
266+
err = mlx5e_tc_esw_init(uplink_priv);
267267
return err;
268268
}
269269

270270
void mlx5e_rep_tc_cleanup(struct mlx5e_rep_priv *rpriv)
271271
{
272272
/* delete shared tc flow table */
273-
mlx5e_tc_esw_cleanup(&rpriv->uplink_priv.tc_ht);
273+
mlx5e_tc_esw_cleanup(&rpriv->uplink_priv);
274274
mutex_destroy(&rpriv->uplink_priv.unready_flows_lock);
275275
}
276276

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,15 +942,21 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
942942
return err;
943943
}
944944

945+
err = mlx5e_tc_ht_init(&rpriv->tc_ht);
946+
if (err)
947+
goto err_ht_init;
948+
945949
if (rpriv->rep->vport == MLX5_VPORT_UPLINK) {
946950
err = mlx5e_init_uplink_rep_tx(rpriv);
947951
if (err)
948-
goto destroy_tises;
952+
goto err_init_tx;
949953
}
950954

951955
return 0;
952956

953-
destroy_tises:
957+
err_init_tx:
958+
mlx5e_tc_ht_cleanup(&rpriv->tc_ht);
959+
err_ht_init:
954960
mlx5e_destroy_tises(priv);
955961
return err;
956962
}
@@ -970,6 +976,8 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
970976

971977
if (rpriv->rep->vport == MLX5_VPORT_UPLINK)
972978
mlx5e_cleanup_uplink_rep_tx(rpriv);
979+
980+
mlx5e_tc_ht_cleanup(&rpriv->tc_ht);
973981
}
974982

975983
static void mlx5e_rep_enable(struct mlx5e_priv *priv)

drivers/net/ethernet/mellanox/mlx5/core/en_rep.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ struct mlx5e_tc_tun_encap;
6464
struct mlx5e_post_act;
6565

6666
struct mlx5_rep_uplink_priv {
67-
/* Filters DB - instantiated by the uplink representor and shared by
68-
* the uplink's VFs
69-
*/
70-
struct rhashtable tc_ht;
71-
7267
/* indirect block callbacks are invoked on bind/unbind events
7368
* on registered higher level devices (e.g. tunnel devices)
7469
*
@@ -113,6 +108,7 @@ struct mlx5e_rep_priv {
113108
struct list_head vport_sqs_list;
114109
struct mlx5_rep_uplink_priv uplink_priv; /* valid for uplink rep */
115110
struct rtnl_link_stats64 prev_vf_vport_stats;
111+
struct rhashtable tc_ht;
116112
};
117113

118114
static inline

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,12 +3609,11 @@ static const struct rhashtable_params tc_ht_params = {
36093609
static struct rhashtable *get_tc_ht(struct mlx5e_priv *priv,
36103610
unsigned long flags)
36113611
{
3612-
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
3613-
struct mlx5e_rep_priv *uplink_rpriv;
3612+
struct mlx5e_rep_priv *rpriv;
36143613

36153614
if (flags & MLX5_TC_FLAG(ESW_OFFLOAD)) {
3616-
uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
3617-
return &uplink_rpriv->uplink_priv.tc_ht;
3615+
rpriv = priv->ppriv;
3616+
return &rpriv->tc_ht;
36183617
} else /* NIC offload */
36193618
return &priv->fs.tc.ht;
36203619
}
@@ -4447,18 +4446,34 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv)
44474446
mlx5_chains_destroy(tc->chains);
44484447
}
44494448

4450-
int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
4449+
int mlx5e_tc_ht_init(struct rhashtable *tc_ht)
4450+
{
4451+
int err;
4452+
4453+
err = rhashtable_init(tc_ht, &tc_ht_params);
4454+
if (err)
4455+
return err;
4456+
4457+
lockdep_set_class(&tc_ht->mutex, &tc_ht_lock_key);
4458+
4459+
return 0;
4460+
}
4461+
4462+
void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht)
4463+
{
4464+
rhashtable_free_and_destroy(tc_ht, _mlx5e_tc_del_flow, NULL);
4465+
}
4466+
4467+
int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
44514468
{
44524469
const size_t sz_enc_opts = sizeof(struct tunnel_match_enc_opts);
4453-
struct mlx5_rep_uplink_priv *uplink_priv;
44544470
struct mlx5e_rep_priv *rpriv;
44554471
struct mapping_ctx *mapping;
44564472
struct mlx5_eswitch *esw;
44574473
struct mlx5e_priv *priv;
44584474
u64 mapping_id;
44594475
int err = 0;
44604476

4461-
uplink_priv = container_of(tc_ht, struct mlx5_rep_uplink_priv, tc_ht);
44624477
rpriv = container_of(uplink_priv, struct mlx5e_rep_priv, uplink_priv);
44634478
priv = netdev_priv(rpriv->netdev);
44644479
esw = priv->mdev->priv.eswitch;
@@ -4498,12 +4513,6 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
44984513
}
44994514
uplink_priv->tunnel_enc_opts_mapping = mapping;
45004515

4501-
err = rhashtable_init(tc_ht, &tc_ht_params);
4502-
if (err)
4503-
goto err_ht_init;
4504-
4505-
lockdep_set_class(&tc_ht->mutex, &tc_ht_lock_key);
4506-
45074516
uplink_priv->encap = mlx5e_tc_tun_init(priv);
45084517
if (IS_ERR(uplink_priv->encap)) {
45094518
err = PTR_ERR(uplink_priv->encap);
@@ -4513,8 +4522,6 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
45134522
return 0;
45144523

45154524
err_register_fib_notifier:
4516-
rhashtable_destroy(tc_ht);
4517-
err_ht_init:
45184525
mapping_destroy(uplink_priv->tunnel_enc_opts_mapping);
45194526
err_enc_opts_mapping:
45204527
mapping_destroy(uplink_priv->tunnel_mapping);
@@ -4528,13 +4535,8 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
45284535
return err;
45294536
}
45304537

4531-
void mlx5e_tc_esw_cleanup(struct rhashtable *tc_ht)
4538+
void mlx5e_tc_esw_cleanup(struct mlx5_rep_uplink_priv *uplink_priv)
45324539
{
4533-
struct mlx5_rep_uplink_priv *uplink_priv;
4534-
4535-
uplink_priv = container_of(tc_ht, struct mlx5_rep_uplink_priv, tc_ht);
4536-
4537-
rhashtable_free_and_destroy(tc_ht, _mlx5e_tc_del_flow, NULL);
45384540
mlx5e_tc_tun_cleanup(uplink_priv->encap);
45394541

45404542
mapping_destroy(uplink_priv->tunnel_enc_opts_mapping);

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ enum {
167167

168168
#define MLX5_TC_FLAG(flag) BIT(MLX5E_TC_FLAG_##flag##_BIT)
169169

170-
int mlx5e_tc_esw_init(struct rhashtable *tc_ht);
171-
void mlx5e_tc_esw_cleanup(struct rhashtable *tc_ht);
170+
int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv);
171+
void mlx5e_tc_esw_cleanup(struct mlx5_rep_uplink_priv *uplink_priv);
172+
173+
int mlx5e_tc_ht_init(struct rhashtable *tc_ht);
174+
void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht);
172175

173176
int mlx5e_configure_flower(struct net_device *dev, struct mlx5e_priv *priv,
174177
struct flow_cls_offload *f, unsigned long flags);
@@ -304,6 +307,8 @@ int mlx5e_set_fwd_to_int_port_actions(struct mlx5e_priv *priv,
304307
#else /* CONFIG_MLX5_CLS_ACT */
305308
static inline int mlx5e_tc_nic_init(struct mlx5e_priv *priv) { return 0; }
306309
static inline void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) {}
310+
static inline int mlx5e_tc_ht_init(struct rhashtable *tc_ht) { return 0; }
311+
static inline void mlx5e_tc_ht_cleanup(struct rhashtable *tc_ht) {}
307312
static inline int
308313
mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv)
309314
{ return -EOPNOTSUPP; }

0 commit comments

Comments
 (0)