Skip to content

Commit 9eabb3f

Browse files
aharonl-nvidiaYishai Hadas
authored and
Yishai Hadas
committed
mlx5: Allow an application to use the indirect mkey tag
An application should be able to update mkey tag bits (Mkey[7:0]) post the mkey creation, but currently, this option is ignored when building the UMR WQE. An application interested in updating the mkey tag should call mlx5dv_create_mkey with MLX5DV_MKEY_INIT_ATTR_FLAGS_UPDATE_TAG. If this option is not supported the creation will fail, otherwise, it can go and update the mkey tag bits and it may be applicable. Signed-off-by: Aharon Landau <[email protected]> Reviewed-by: Michael Guralnik <[email protected]> Signed-off-by: Yishai Hadas <[email protected]>
1 parent f1cc88f commit 9eabb3f

File tree

6 files changed

+25
-2
lines changed

6 files changed

+25
-2
lines changed

providers/mlx5/man/mlx5dv_create_mkey.3.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tagline: Verbs
99

1010
mlx5dv_create_mkey - Creates an indirect mkey
1111

12-
mlx5dv_create_mkey - Destroys an indirect mkey
12+
mlx5dv_destroy_mkey - Destroys an indirect mkey
1313

1414
# SYNOPSIS
1515

@@ -59,6 +59,10 @@ Create an indirect mkey to enable application uses its specific device functiona
5959
was not configured for crypto properties using
6060
**mlx5dv_wr_set_mkey_crypto()**, then running traffic with the
6161
MKey will fail, generating a CQE with error.
62+
MLX5DV_MKEY_INIT_ATTR_FLAGS_UPDATE_TAG:
63+
Enable update tag support for mkey.
64+
Setting this flag allows an application to set the mkey tag post of creating the mkey.
65+
If the kernel does not support updating the mkey tag, mkey creation will fail.
6266
6367
*max_entries*
6468
: Requested max number of pointed entries by this indirect mkey.

providers/mlx5/mlx5.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,6 +2407,10 @@ static int mlx5_set_context(struct mlx5_context *context,
24072407
if (resp->comp_mask & MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_REAL_TIME_TS)
24082408
context->flags |= MLX5_CTX_FLAGS_REAL_TIME_TS_SUPPORTED;
24092409

2410+
if (resp->comp_mask &
2411+
MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_MKEY_UPDATE_TAG)
2412+
context->flags |= MLX5_CTX_FLAGS_MKEY_UPDATE_TAG_SUPPORTED;
2413+
24102414
if (resp->comp_mask & MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_DUMP_FILL_MKEY) {
24112415
context->dump_fill_mkey = resp->dump_fill_mkey;
24122416
/* Have the BE value ready to be used in data path */

providers/mlx5/mlx5.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ enum mlx5_ctx_flags {
263263
MLX5_CTX_FLAGS_ECE_SUPPORTED = 1 << 2,
264264
MLX5_CTX_FLAGS_SQD2RTS_SUPPORTED = 1 << 3,
265265
MLX5_CTX_FLAGS_REAL_TIME_TS_SUPPORTED = 1 << 4,
266+
MLX5_CTX_FLAGS_MKEY_UPDATE_TAG_SUPPORTED = 1 << 5,
266267
};
267268

268269
struct mlx5_entropy_caps {

providers/mlx5/mlx5dv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ enum mlx5dv_mkey_init_attr_flags {
283283
MLX5DV_MKEY_INIT_ATTR_FLAGS_INDIRECT = 1 << 0,
284284
MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE = 1 << 1,
285285
MLX5DV_MKEY_INIT_ATTR_FLAGS_CRYPTO = 1 << 2,
286+
MLX5DV_MKEY_INIT_ATTR_FLAGS_UPDATE_TAG = 1 << 3,
286287
};
287288

288289
struct mlx5dv_mkey_init_attr {

providers/mlx5/qp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,6 +2796,7 @@ static void mlx5_send_wr_mkey_configure(struct mlx5dv_qp_ex *dv_qp,
27962796
struct mlx5dv_mkey_conf_attr *attr)
27972797
{
27982798
struct mlx5_qp *mqp = mqp_from_mlx5dv_qp_ex(dv_qp);
2799+
struct mlx5_context *mctx = to_mctx(mqp->ibv_qp->context);
27992800
struct ibv_qp_ex *ibqp = &mqp->verbs_qp.qp_ex;
28002801
struct mlx5_wqe_umr_ctrl_seg *umr_ctrl;
28012802
struct mlx5_wqe_mkey_context_seg *mk;
@@ -2838,7 +2839,14 @@ static void mlx5_send_wr_mkey_configure(struct mlx5dv_qp_ex *dv_qp,
28382839

28392840
mk = seg;
28402841
memset(mk, 0, sizeof(*mk));
2842+
if (unlikely(dv_mkey->lkey & 0xff &&
2843+
!(mctx->flags &
2844+
MLX5_CTX_FLAGS_MKEY_UPDATE_TAG_SUPPORTED))) {
2845+
mqp->err = EOPNOTSUPP;
2846+
return;
2847+
}
28412848
mk->qpn_mkey = htobe32(0xffffff00 | (dv_mkey->lkey & 0xff));
2849+
mkey_mask |= MLX5_WQE_UMR_CTRL_MKEY_MASK_MKEY;
28422850

28432851
seg += sizeof(*mk);
28442852
mqp->cur_size += (sizeof(*mk) / 16);

providers/mlx5/verbs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6727,17 +6727,22 @@ _mlx5dv_create_mkey(struct mlx5dv_mkey_init_attr *mkey_init_attr)
67276727
uint32_t out[DEVX_ST_SZ_DW(create_mkey_out)] = {};
67286728
uint32_t in[DEVX_ST_SZ_DW(create_mkey_in)] = {};
67296729
struct mlx5_mkey *mkey;
6730+
bool update_tag;
67306731
bool sig_mkey;
67316732
bool crypto_mkey;
67326733
struct ibv_pd *pd = mkey_init_attr->pd;
67336734
size_t bsf_size = 0;
67346735
void *mkc;
67356736

6737+
update_tag = to_mctx(pd->context)->flags &
6738+
MLX5_CTX_FLAGS_MKEY_UPDATE_TAG_SUPPORTED;
67366739
if (!mkey_init_attr->create_flags ||
67376740
!check_comp_mask(mkey_init_attr->create_flags,
67386741
MLX5DV_MKEY_INIT_ATTR_FLAGS_INDIRECT |
67396742
MLX5DV_MKEY_INIT_ATTR_FLAGS_BLOCK_SIGNATURE |
6740-
MLX5DV_MKEY_INIT_ATTR_FLAGS_CRYPTO)) {
6743+
MLX5DV_MKEY_INIT_ATTR_FLAGS_CRYPTO |
6744+
(update_tag ?
6745+
MLX5DV_MKEY_INIT_ATTR_FLAGS_UPDATE_TAG : 0))) {
67416746
errno = EOPNOTSUPP;
67426747
return NULL;
67436748
}

0 commit comments

Comments
 (0)