Skip to content

Commit 0608d4d

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Unify slow PCI heuristic
Get the link/pci speed query and logic into a single function. Unify the heuristics and use a single PCI threshold (16G) for all. Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 5d22d47 commit 0608d4d

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

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

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,16 +3902,20 @@ static int mlx5e_get_pci_bw(struct mlx5_core_dev *mdev, u32 *pci_bw)
39023902
return 0;
39033903
}
39043904

3905-
static bool cqe_compress_heuristic(u32 link_speed, u32 pci_bw)
3905+
static bool slow_pci_heuristic(struct mlx5_core_dev *mdev)
39063906
{
3907-
return (link_speed && pci_bw &&
3908-
(pci_bw < 40000) && (pci_bw < link_speed));
3909-
}
3907+
u32 link_speed = 0;
3908+
u32 pci_bw = 0;
39103909

3911-
static bool hw_lro_heuristic(u32 link_speed, u32 pci_bw)
3912-
{
3913-
return !(link_speed && pci_bw &&
3914-
(pci_bw <= 16000) && (pci_bw < link_speed));
3910+
mlx5e_get_max_linkspeed(mdev, &link_speed);
3911+
mlx5e_get_pci_bw(mdev, &pci_bw);
3912+
mlx5_core_dbg_once(mdev, "Max link speed = %d, PCI BW = %d\n",
3913+
link_speed, pci_bw);
3914+
3915+
#define MLX5E_SLOW_PCI_RATIO (2)
3916+
3917+
return link_speed && pci_bw &&
3918+
link_speed > MLX5E_SLOW_PCI_RATIO * pci_bw;
39153919
}
39163920

39173921
void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
@@ -3980,17 +3984,10 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
39803984
u16 max_channels)
39813985
{
39823986
u8 cq_period_mode = 0;
3983-
u32 link_speed = 0;
3984-
u32 pci_bw = 0;
39853987

39863988
params->num_channels = max_channels;
39873989
params->num_tc = 1;
39883990

3989-
mlx5e_get_max_linkspeed(mdev, &link_speed);
3990-
mlx5e_get_pci_bw(mdev, &pci_bw);
3991-
mlx5_core_dbg(mdev, "Max link speed = %d, PCI BW = %d\n",
3992-
link_speed, pci_bw);
3993-
39943991
/* SQ */
39953992
params->log_sq_size = is_kdump_kernel() ?
39963993
MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE :
@@ -4000,7 +3997,7 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
40003997
params->rx_cqe_compress_def = false;
40013998
if (MLX5_CAP_GEN(mdev, cqe_compression) &&
40023999
MLX5_CAP_GEN(mdev, vport_group_manager))
4003-
params->rx_cqe_compress_def = cqe_compress_heuristic(link_speed, pci_bw);
4000+
params->rx_cqe_compress_def = slow_pci_heuristic(mdev);
40044001

40054002
MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS, params->rx_cqe_compress_def);
40064003

@@ -4011,7 +4008,7 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
40114008

40124009
/* TODO: && MLX5_CAP_ETH(mdev, lro_cap) */
40134010
if (params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
4014-
params->lro_en = hw_lro_heuristic(link_speed, pci_bw);
4011+
params->lro_en = !slow_pci_heuristic(mdev);
40154012
params->lro_timeout = mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
40164013

40174014
/* CQ moderation params */

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ extern uint mlx5_core_debug_mask;
5050
__func__, __LINE__, current->pid, \
5151
##__VA_ARGS__)
5252

53+
#define mlx5_core_dbg_once(__dev, format, ...) \
54+
dev_dbg_once(&(__dev)->pdev->dev, "%s:%d:(pid %d): " format, \
55+
__func__, __LINE__, current->pid, \
56+
##__VA_ARGS__)
57+
5358
#define mlx5_core_dbg_mask(__dev, mask, format, ...) \
5459
do { \
5560
if ((mask) & mlx5_core_debug_mask) \

0 commit comments

Comments
 (0)