Skip to content

Commit f32f5bd

Browse files
Daniel JurgensSaeed Mahameed
authored andcommitted
net/mlx5: Configure cache line size for start and end padding
There is a hardware feature that will pad the start or end of a DMA to be cache line aligned to avoid RMWs on the last cache line. The default cache line size setting for this feature is 64B. This change configures the hardware to use 128B alignment on systems with 128B cache lines. In addition we lower bound MPWRQ stride by HCA cacheline in mlx5e, MPWRQ stride should be at least the HCA cacheline, the current default is 64B and in case HCA_CAP.cach_line_128byte capability is set, MPWRQ RX stride will automatically be aligned to 128B. Signed-off-by: Daniel Jurgens <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent a61d5ce commit f32f5bd

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@
7070

7171
#define MLX5_RX_HEADROOM NET_SKB_PAD
7272

73-
#define MLX5_MPWRQ_LOG_STRIDE_SIZE 6 /* >= 6, HW restriction */
74-
#define MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS 8 /* >= 6, HW restriction */
73+
#define MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev) \
74+
(6 + MLX5_CAP_GEN(mdev, cache_line_128byte)) /* HW restriction */
75+
#define MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, req) \
76+
max_t(u32, MLX5_MPWRQ_MIN_LOG_STRIDE_SZ(mdev), req)
77+
#define MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 6)
78+
#define MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) MLX5_MPWRQ_LOG_STRIDE_SZ(mdev, 8)
79+
7580
#define MLX5_MPWRQ_LOG_WQE_SZ 18
7681
#define MLX5_MPWRQ_WQE_PAGE_ORDER (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \
7782
MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ static void mlx5e_set_rq_type_params(struct mlx5e_priv *priv, u8 rq_type)
8989
MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW;
9090
priv->params.mpwqe_log_stride_sz =
9191
MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) ?
92-
MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS :
93-
MLX5_MPWRQ_LOG_STRIDE_SIZE;
92+
MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(priv->mdev) :
93+
MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(priv->mdev);
9494
priv->params.mpwqe_log_num_strides = MLX5_MPWRQ_LOG_WQE_SZ -
9595
priv->params.mpwqe_log_stride_sz;
9696
break;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,12 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
543543

544544
MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12);
545545

546+
if (MLX5_CAP_GEN_MAX(dev, cache_line_128byte))
547+
MLX5_SET(cmd_hca_cap,
548+
set_hca_cap,
549+
cache_line_128byte,
550+
cache_line_size() == 128 ? 1 : 0);
551+
546552
err = set_caps(dev, set_ctx, set_sz,
547553
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE);
548554

include/linux/mlx5/mlx5_ifc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,12 @@ struct mlx5_ifc_cmd_hca_cap_bits {
804804
u8 reserved_at_150[0xa];
805805
u8 log_max_ra_res_qp[0x6];
806806

807-
u8 pad_cap[0x1];
807+
u8 end_pad[0x1];
808808
u8 cc_query_allowed[0x1];
809809
u8 cc_modify_allowed[0x1];
810-
u8 reserved_at_163[0xd];
810+
u8 start_pad[0x1];
811+
u8 cache_line_128byte[0x1];
812+
u8 reserved_at_163[0xb];
811813
u8 gid_table_size[0x10];
812814

813815
u8 out_of_seq_cnt[0x1];

0 commit comments

Comments
 (0)