net/mlx5e: Refactor mlx5e_rss_set_rxfh() and mlx5e_rss_get_rxfh()

Initialize indirect table array with memcpy rather than for loop.
This change has made for two reasons:
1) To be consistent with the indirect table array init in
   mlx5e_rss_set_rxfh().
2) In general, prefer to use memcpy for array initializing rather than
   for loop.

Signed-off-by: Adham Faris <afaris@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
Adham Faris 2023-10-12 12:27:46 -07:00 committed by Saeed Mahameed
parent d90ea84375
commit cae8e6dea2

View File

@ -470,11 +470,9 @@ inner_tir:
int mlx5e_rss_get_rxfh(struct mlx5e_rss *rss, u32 *indir, u8 *key, u8 *hfunc)
{
unsigned int i;
if (indir)
for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++)
indir[i] = rss->indir.table[i];
memcpy(indir, rss->indir.table,
MLX5E_INDIR_RQT_SIZE * sizeof(*rss->indir.table));
if (key)
memcpy(key, rss->hash.toeplitz_hash_key,
@ -523,12 +521,10 @@ int mlx5e_rss_set_rxfh(struct mlx5e_rss *rss, const u32 *indir,
}
if (indir) {
unsigned int i;
changed_indir = true;
for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++)
rss->indir.table[i] = indir[i];
memcpy(rss->indir.table, indir,
MLX5E_INDIR_RQT_SIZE * sizeof(*rss->indir.table));
}
if (changed_indir && rss->enabled) {