Skip to content

Commit

Permalink
net/mlx5e: TC, refactor access to hash key
Browse files Browse the repository at this point in the history
Currently, a temp object is filled and used as a key for rhashtable_lookup.
Lookups will only works while key remains the first attribute in the
relevant rhashtable node object.

Fix this by passing a key, instead of a object containing the key.

Signed-off-by: Oz Shlomo <ozsh@nvidia.com>
Reviewed-by: Paul Blakey <paulb@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Oz Shlomo authored and Saeed Mahameed committed Jun 7, 2023
1 parent f4692ab commit de1f0a6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en/tc/act_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ struct mlx5e_tc_act_stats {

static const struct rhashtable_params act_counters_ht_params = {
.head_offset = offsetof(struct mlx5e_tc_act_stats, hash),
.key_offset = 0,
.key_len = offsetof(struct mlx5e_tc_act_stats, counter),
.key_offset = offsetof(struct mlx5e_tc_act_stats, tc_act_cookie),
.key_len = sizeof_field(struct mlx5e_tc_act_stats, tc_act_cookie),
.automatic_shrinking = true,
};

Expand Down Expand Up @@ -169,14 +169,11 @@ mlx5e_tc_act_stats_fill_stats(struct mlx5e_tc_act_stats_handle *handle,
{
struct rhashtable *ht = &handle->ht;
struct mlx5e_tc_act_stats *item;
struct mlx5e_tc_act_stats key;
u64 pkts, bytes, lastused;
int err = 0;

key.tc_act_cookie = fl_act->cookie;

rcu_read_lock();
item = rhashtable_lookup(ht, &key, act_counters_ht_params);
item = rhashtable_lookup(ht, &fl_act->cookie, act_counters_ht_params);
if (!item) {
rcu_read_unlock();
err = -ENOENT;
Expand Down

0 comments on commit de1f0a6

Please sign in to comment.