Skip to content

Commit 02648b4

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5: Generalize name of UMR alignment definition
Per the device spec, MLX5_UMR_MTT_ALIGNMENT is good not only for UMR MTT entries, but for all other entries as well, like KLMs and KSMs. Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 683d78a commit 02648b4

File tree

6 files changed

+16
-17
lines changed

6 files changed

+16
-17
lines changed

drivers/infiniband/hw/mlx5/odp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ static bool mlx5_ib_invalidate_range(struct mmu_interval_notifier *mni,
230230
struct ib_umem_odp *umem_odp =
231231
container_of(mni, struct ib_umem_odp, notifier);
232232
struct mlx5_ib_mr *mr;
233-
const u64 umr_block_mask = (MLX5_UMR_MTT_ALIGNMENT /
234-
sizeof(struct mlx5_mtt)) - 1;
233+
const u64 umr_block_mask = MLX5_UMR_MTT_NUM_ENTRIES_ALIGNMENT - 1;
235234
u64 idx = 0, blk_start_idx = 0;
236235
u64 invalidations = 0;
237236
unsigned long start;

drivers/infiniband/hw/mlx5/umr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ int mlx5r_umr_rereg_pd_access(struct mlx5_ib_mr *mr, struct ib_pd *pd,
418418
}
419419

420420
#define MLX5_MAX_UMR_CHUNK \
421-
((1 << (MLX5_MAX_UMR_SHIFT + 4)) - MLX5_UMR_MTT_ALIGNMENT)
421+
((1 << (MLX5_MAX_UMR_SHIFT + 4)) - MLX5_UMR_FLEX_ALIGNMENT)
422422
#define MLX5_SPARE_UMR_CHUNK 0x10000
423423

424424
/*
@@ -428,11 +428,11 @@ int mlx5r_umr_rereg_pd_access(struct mlx5_ib_mr *mr, struct ib_pd *pd,
428428
*/
429429
static void *mlx5r_umr_alloc_xlt(size_t *nents, size_t ent_size, gfp_t gfp_mask)
430430
{
431-
const size_t xlt_chunk_align = MLX5_UMR_MTT_ALIGNMENT / ent_size;
431+
const size_t xlt_chunk_align = MLX5_UMR_FLEX_ALIGNMENT / ent_size;
432432
size_t size;
433433
void *res = NULL;
434434

435-
static_assert(PAGE_SIZE % MLX5_UMR_MTT_ALIGNMENT == 0);
435+
static_assert(PAGE_SIZE % MLX5_UMR_FLEX_ALIGNMENT == 0);
436436

437437
/*
438438
* MLX5_IB_UPD_XLT_ATOMIC doesn't signal an atomic context just that the
@@ -666,7 +666,7 @@ int mlx5r_umr_update_mr_pas(struct mlx5_ib_mr *mr, unsigned int flags)
666666
}
667667

668668
final_size = (void *)cur_mtt - (void *)mtt;
669-
sg.length = ALIGN(final_size, MLX5_UMR_MTT_ALIGNMENT);
669+
sg.length = ALIGN(final_size, MLX5_UMR_FLEX_ALIGNMENT);
670670
memset(cur_mtt, 0, sg.length - final_size);
671671
mlx5r_umr_final_update_xlt(dev, &wqe, mr, &sg, flags);
672672

@@ -690,7 +690,7 @@ int mlx5r_umr_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,
690690
int desc_size = (flags & MLX5_IB_UPD_XLT_INDIRECT)
691691
? sizeof(struct mlx5_klm)
692692
: sizeof(struct mlx5_mtt);
693-
const int page_align = MLX5_UMR_MTT_ALIGNMENT / desc_size;
693+
const int page_align = MLX5_UMR_FLEX_ALIGNMENT / desc_size;
694694
struct mlx5_ib_dev *dev = mr_to_mdev(mr);
695695
struct device *ddev = &dev->mdev->pdev->dev;
696696
const int page_mask = page_align - 1;
@@ -711,7 +711,7 @@ int mlx5r_umr_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,
711711
if (WARN_ON(!mr->umem->is_odp))
712712
return -EINVAL;
713713

714-
/* UMR copies MTTs in units of MLX5_UMR_MTT_ALIGNMENT bytes,
714+
/* UMR copies MTTs in units of MLX5_UMR_FLEX_ALIGNMENT bytes,
715715
* so we need to align the offset and length accordingly
716716
*/
717717
if (idx & page_mask) {
@@ -748,7 +748,7 @@ int mlx5r_umr_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,
748748
mlx5_odp_populate_xlt(xlt, idx, npages, mr, flags);
749749
dma_sync_single_for_device(ddev, sg.addr, sg.length,
750750
DMA_TO_DEVICE);
751-
sg.length = ALIGN(size_to_map, MLX5_UMR_MTT_ALIGNMENT);
751+
sg.length = ALIGN(size_to_map, MLX5_UMR_FLEX_ALIGNMENT);
752752

753753
if (pages_mapped + pages_iter >= pages_to_map)
754754
mlx5r_umr_final_update_xlt(dev, &wqe, mr, &sg, flags);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ struct page_pool;
103103
* size actually used at runtime, but it's not a problem when calculating static
104104
* array sizes.
105105
*/
106-
#define MLX5_UMR_MAX_MTT_SPACE \
106+
#define MLX5_UMR_MAX_FLEX_SPACE \
107107
(ALIGN_DOWN(MLX5_SEND_WQE_MAX_SIZE - sizeof(struct mlx5e_umr_wqe), \
108-
MLX5_UMR_MTT_ALIGNMENT))
108+
MLX5_UMR_FLEX_ALIGNMENT))
109109
#define MLX5_MPWRQ_MAX_PAGES_PER_WQE \
110-
rounddown_pow_of_two(MLX5_UMR_MAX_MTT_SPACE / sizeof(struct mlx5_mtt))
110+
rounddown_pow_of_two(MLX5_UMR_MAX_FLEX_SPACE / sizeof(struct mlx5_mtt))
111111

112112
#define MLX5E_MAX_RQ_NUM_MTTS \
113113
(ALIGN_DOWN(U16_MAX, 4) * 2) /* Fits into u16 and aligned by WQEBB. */

drivers/net/ethernet/mellanox/mlx5/core/en/params.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ u8 mlx5e_mpwrq_log_wqe_sz(struct mlx5_core_dev *mdev, u8 page_shift,
107107
/* Keep in sync with MLX5_MPWRQ_MAX_PAGES_PER_WQE. */
108108
max_wqe_size = mlx5e_get_max_sq_aligned_wqebbs(mdev) * MLX5_SEND_WQE_BB;
109109
max_pages_per_wqe = ALIGN_DOWN(max_wqe_size - sizeof(struct mlx5e_umr_wqe),
110-
MLX5_UMR_MTT_ALIGNMENT) / umr_entry_size;
110+
MLX5_UMR_FLEX_ALIGNMENT) / umr_entry_size;
111111
max_log_mpwqe_size = ilog2(max_pages_per_wqe) + page_shift;
112112

113113
WARN_ON_ONCE(max_log_mpwqe_size < MLX5E_ORDER2_MAX_PACKET_MTU);
@@ -146,7 +146,7 @@ u16 mlx5e_mpwrq_umr_wqe_sz(struct mlx5_core_dev *mdev, u8 page_shift,
146146
u16 umr_wqe_sz;
147147

148148
umr_wqe_sz = sizeof(struct mlx5e_umr_wqe) +
149-
ALIGN(pages_per_wqe * umr_entry_size, MLX5_UMR_MTT_ALIGNMENT);
149+
ALIGN(pages_per_wqe * umr_entry_size, MLX5_UMR_FLEX_ALIGNMENT);
150150

151151
WARN_ON_ONCE(DIV_ROUND_UP(umr_wqe_sz, MLX5_SEND_WQE_DS) > MLX5_WQE_CTRL_DS_MASK);
152152

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static u16 mlx5e_mpwrq_umr_octowords(u32 entries, enum mlx5e_mpwrq_umr_mode umr_
208208
u8 umr_entry_size = mlx5e_mpwrq_umr_entry_size(umr_mode);
209209
u32 sz;
210210

211-
sz = ALIGN(entries * umr_entry_size, MLX5_UMR_MTT_ALIGNMENT);
211+
sz = ALIGN(entries * umr_entry_size, MLX5_UMR_FLEX_ALIGNMENT);
212212

213213
return sz / MLX5_OCTWORD;
214214
}

include/linux/mlx5/device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ enum {
291291
};
292292

293293
#define MLX5_UMR_KLM_ALIGNMENT 4
294-
#define MLX5_UMR_MTT_ALIGNMENT 0x40
295-
#define MLX5_UMR_MTT_NUM_ENTRIES_ALIGNMENT (MLX5_UMR_MTT_ALIGNMENT / sizeof(struct mlx5_mtt))
294+
#define MLX5_UMR_FLEX_ALIGNMENT 0x40
295+
#define MLX5_UMR_MTT_NUM_ENTRIES_ALIGNMENT (MLX5_UMR_FLEX_ALIGNMENT / sizeof(struct mlx5_mtt))
296296

297297
#define MLX5_USER_INDEX_LEN (MLX5_FLD_SZ_BYTES(qpc, user_index) * 8)
298298

0 commit comments

Comments
 (0)