-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'mlx5-updates-2021-07-24' of git://git.kernel.org/pub/scm/l…
…inux/kernel/git/saeed/linux mlx5-updates-2021-07-24 This series aims to reduce coupling in mlx5e, particularly between RX resources (TIRs, RQTs) and numerous code units that use them. This refactoring is required for upcoming features, ADQ and TX lag hashing. The issue with the current code is that TIRs and RQTs are unmanaged, different places all over the driver create, destroy, track and configure them, often in an uncoordinated way. The responsibilities of different units become vague, leading to a lot of hidden dependencies between numerous units and tight coupling between them, which is prone to bugs and hard to maintain. The result of this refactoring is: 1. Creating a manager for RX resources, that controls their lifecycle and provides a clear API, which restricts the set of actions that other units can do. 2. Using object-oriented approach for TIRs, RQTs and RX resource manager (struct mlx5e_rx_res). 3. Fixing a few bugs and misbehaviors found during the refactoring. 4. Reducing the amount of dependencies, removing hidden dependencies, making them one-directional and organizing the code in clear abstraction layers. 5. Explicitly exposing the remaining weird dependencies. 6. Simplifying and organizing code that creates and modifies TIRs and RQTs. Saeed Mahameed says: ==================== mlx5 updates 2021-07-24 This series provides some refactoring to mlx5e RX resource management, it is required for upcoming ADQ and TX lag hashing features. The first two patches in this series : net/mlx5e: Prohibit inner indir TIRs in IPoIB net/mlx5e: Block LRO if firmware asks for tunneled LRO Were supposed to go to net, but due to dependency and timing they were included here. I would appreciate it if you'd apply them to net and mark for -stable. For more information please see tag log below. Please pull and let me know if there is any problem. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
25 changed files
with
1,106 additions
and
811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | ||
/* Copyright (c) 2021, Mellanox Technologies inc. All rights reserved. */ | ||
|
||
#include "rqt.h" | ||
#include <linux/mlx5/transobj.h> | ||
|
||
static int mlx5e_rqt_init(struct mlx5e_rqt *rqt, struct mlx5_core_dev *mdev, | ||
u16 max_size, u32 *init_rqns, u16 init_size) | ||
{ | ||
void *rqtc; | ||
int inlen; | ||
int err; | ||
u32 *in; | ||
int i; | ||
|
||
rqt->mdev = mdev; | ||
rqt->size = max_size; | ||
|
||
inlen = MLX5_ST_SZ_BYTES(create_rqt_in) + sizeof(u32) * init_size; | ||
in = kvzalloc(inlen, GFP_KERNEL); | ||
if (!in) | ||
return -ENOMEM; | ||
|
||
rqtc = MLX5_ADDR_OF(create_rqt_in, in, rqt_context); | ||
|
||
MLX5_SET(rqtc, rqtc, rqt_max_size, rqt->size); | ||
|
||
MLX5_SET(rqtc, rqtc, rqt_actual_size, init_size); | ||
for (i = 0; i < init_size; i++) | ||
MLX5_SET(rqtc, rqtc, rq_num[i], init_rqns[i]); | ||
|
||
err = mlx5_core_create_rqt(rqt->mdev, in, inlen, &rqt->rqtn); | ||
|
||
kvfree(in); | ||
return err; | ||
} | ||
|
||
int mlx5e_rqt_init_direct(struct mlx5e_rqt *rqt, struct mlx5_core_dev *mdev, | ||
bool indir_enabled, u32 init_rqn) | ||
{ | ||
u16 max_size = indir_enabled ? MLX5E_INDIR_RQT_SIZE : 1; | ||
|
||
return mlx5e_rqt_init(rqt, mdev, max_size, &init_rqn, 1); | ||
} | ||
|
||
static int mlx5e_bits_invert(unsigned long a, int size) | ||
{ | ||
int inv = 0; | ||
int i; | ||
|
||
for (i = 0; i < size; i++) | ||
inv |= (test_bit(size - i - 1, &a) ? 1 : 0) << i; | ||
|
||
return inv; | ||
} | ||
|
||
static int mlx5e_calc_indir_rqns(u32 *rss_rqns, u32 *rqns, unsigned int num_rqns, | ||
u8 hfunc, struct mlx5e_rss_params_indir *indir) | ||
{ | ||
unsigned int i; | ||
|
||
for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++) { | ||
unsigned int ix = i; | ||
|
||
if (hfunc == ETH_RSS_HASH_XOR) | ||
ix = mlx5e_bits_invert(ix, ilog2(MLX5E_INDIR_RQT_SIZE)); | ||
|
||
ix = indir->table[ix]; | ||
|
||
if (WARN_ON(ix >= num_rqns)) | ||
/* Could be a bug in the driver or in the kernel part of | ||
* ethtool: indir table refers to non-existent RQs. | ||
*/ | ||
return -EINVAL; | ||
rss_rqns[i] = rqns[ix]; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int mlx5e_rqt_init_indir(struct mlx5e_rqt *rqt, struct mlx5_core_dev *mdev, | ||
u32 *rqns, unsigned int num_rqns, | ||
u8 hfunc, struct mlx5e_rss_params_indir *indir) | ||
{ | ||
u32 *rss_rqns; | ||
int err; | ||
|
||
rss_rqns = kvmalloc_array(MLX5E_INDIR_RQT_SIZE, sizeof(*rss_rqns), GFP_KERNEL); | ||
if (!rss_rqns) | ||
return -ENOMEM; | ||
|
||
err = mlx5e_calc_indir_rqns(rss_rqns, rqns, num_rqns, hfunc, indir); | ||
if (err) | ||
goto out; | ||
|
||
err = mlx5e_rqt_init(rqt, mdev, MLX5E_INDIR_RQT_SIZE, rss_rqns, MLX5E_INDIR_RQT_SIZE); | ||
|
||
out: | ||
kvfree(rss_rqns); | ||
return err; | ||
} | ||
|
||
void mlx5e_rqt_destroy(struct mlx5e_rqt *rqt) | ||
{ | ||
mlx5_core_destroy_rqt(rqt->mdev, rqt->rqtn); | ||
} | ||
|
||
static int mlx5e_rqt_redirect(struct mlx5e_rqt *rqt, u32 *rqns, unsigned int size) | ||
{ | ||
unsigned int i; | ||
void *rqtc; | ||
int inlen; | ||
u32 *in; | ||
int err; | ||
|
||
inlen = MLX5_ST_SZ_BYTES(modify_rqt_in) + sizeof(u32) * size; | ||
in = kvzalloc(inlen, GFP_KERNEL); | ||
if (!in) | ||
return -ENOMEM; | ||
|
||
rqtc = MLX5_ADDR_OF(modify_rqt_in, in, ctx); | ||
|
||
MLX5_SET(modify_rqt_in, in, bitmask.rqn_list, 1); | ||
MLX5_SET(rqtc, rqtc, rqt_actual_size, size); | ||
for (i = 0; i < size; i++) | ||
MLX5_SET(rqtc, rqtc, rq_num[i], rqns[i]); | ||
|
||
err = mlx5_core_modify_rqt(rqt->mdev, rqt->rqtn, in, inlen); | ||
|
||
kvfree(in); | ||
return err; | ||
} | ||
|
||
int mlx5e_rqt_redirect_direct(struct mlx5e_rqt *rqt, u32 rqn) | ||
{ | ||
return mlx5e_rqt_redirect(rqt, &rqn, 1); | ||
} | ||
|
||
int mlx5e_rqt_redirect_indir(struct mlx5e_rqt *rqt, u32 *rqns, unsigned int num_rqns, | ||
u8 hfunc, struct mlx5e_rss_params_indir *indir) | ||
{ | ||
u32 *rss_rqns; | ||
int err; | ||
|
||
if (WARN_ON(rqt->size != MLX5E_INDIR_RQT_SIZE)) | ||
return -EINVAL; | ||
|
||
rss_rqns = kvmalloc_array(MLX5E_INDIR_RQT_SIZE, sizeof(*rss_rqns), GFP_KERNEL); | ||
if (!rss_rqns) | ||
return -ENOMEM; | ||
|
||
err = mlx5e_calc_indir_rqns(rss_rqns, rqns, num_rqns, hfunc, indir); | ||
if (err) | ||
goto out; | ||
|
||
err = mlx5e_rqt_redirect(rqt, rss_rqns, MLX5E_INDIR_RQT_SIZE); | ||
|
||
out: | ||
kvfree(rss_rqns); | ||
return err; | ||
} |
Oops, something went wrong.