Commit a6492af3 authored by Yevgeny Kliteynik's avatar Yevgeny Kliteynik Committed by Saeed Mahameed

RDMA/mlx5: Support handling of modify-header pattern ICM area

Add support for allocate/deallocate and registering MR of the new type
of ICM area. Support exists only for devices that support sw_owner_v2.
Signed-off-by: default avatarYevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 66765836
...@@ -336,9 +336,15 @@ static struct ib_dm *handle_alloc_dm_memic(struct ib_ucontext *ctx, ...@@ -336,9 +336,15 @@ static struct ib_dm *handle_alloc_dm_memic(struct ib_ucontext *ctx,
static enum mlx5_sw_icm_type get_icm_type(int uapi_type) static enum mlx5_sw_icm_type get_icm_type(int uapi_type)
{ {
return uapi_type == MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM ? switch (uapi_type) {
MLX5_SW_ICM_TYPE_STEERING : case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM:
MLX5_SW_ICM_TYPE_HEADER_MODIFY; return MLX5_SW_ICM_TYPE_HEADER_MODIFY;
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_PATTERN_SW_ICM:
return MLX5_SW_ICM_TYPE_HEADER_MODIFY_PATTERN;
case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM:
default:
return MLX5_SW_ICM_TYPE_STEERING;
}
} }
static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx, static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,
...@@ -347,11 +353,32 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx, ...@@ -347,11 +353,32 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,
int type) int type)
{ {
struct mlx5_core_dev *dev = to_mdev(ctx->device)->mdev; struct mlx5_core_dev *dev = to_mdev(ctx->device)->mdev;
enum mlx5_sw_icm_type icm_type = get_icm_type(type); enum mlx5_sw_icm_type icm_type;
struct mlx5_ib_dm_icm *dm; struct mlx5_ib_dm_icm *dm;
u64 act_size; u64 act_size;
int err; int err;
if (!capable(CAP_SYS_RAWIO) || !capable(CAP_NET_RAW))
return ERR_PTR(-EPERM);
switch (type) {
case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM:
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM:
if (!(MLX5_CAP_FLOWTABLE_NIC_RX(dev, sw_owner) ||
MLX5_CAP_FLOWTABLE_NIC_TX(dev, sw_owner) ||
MLX5_CAP_FLOWTABLE_NIC_RX(dev, sw_owner_v2) ||
MLX5_CAP_FLOWTABLE_NIC_TX(dev, sw_owner_v2)))
return ERR_PTR(-EOPNOTSUPP);
break;
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_PATTERN_SW_ICM:
if (!MLX5_CAP_FLOWTABLE_NIC_RX(dev, sw_owner_v2) ||
!MLX5_CAP_FLOWTABLE_NIC_TX(dev, sw_owner_v2))
return ERR_PTR(-EOPNOTSUPP);
break;
default:
return ERR_PTR(-EOPNOTSUPP);
}
dm = kzalloc(sizeof(*dm), GFP_KERNEL); dm = kzalloc(sizeof(*dm), GFP_KERNEL);
if (!dm) if (!dm)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -359,19 +386,6 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx, ...@@ -359,19 +386,6 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,
dm->base.type = type; dm->base.type = type;
dm->base.ibdm.device = ctx->device; dm->base.ibdm.device = ctx->device;
if (!capable(CAP_SYS_RAWIO) || !capable(CAP_NET_RAW)) {
err = -EPERM;
goto free;
}
if (!(MLX5_CAP_FLOWTABLE_NIC_RX(dev, sw_owner) ||
MLX5_CAP_FLOWTABLE_NIC_TX(dev, sw_owner) ||
MLX5_CAP_FLOWTABLE_NIC_RX(dev, sw_owner_v2) ||
MLX5_CAP_FLOWTABLE_NIC_TX(dev, sw_owner_v2))) {
err = -EOPNOTSUPP;
goto free;
}
/* Allocation size must a multiple of the basic block size /* Allocation size must a multiple of the basic block size
* and a power of 2. * and a power of 2.
*/ */
...@@ -379,6 +393,8 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx, ...@@ -379,6 +393,8 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,
act_size = roundup_pow_of_two(act_size); act_size = roundup_pow_of_two(act_size);
dm->base.size = act_size; dm->base.size = act_size;
icm_type = get_icm_type(type);
err = mlx5_dm_sw_icm_alloc(dev, icm_type, act_size, attr->alignment, err = mlx5_dm_sw_icm_alloc(dev, icm_type, act_size, attr->alignment,
to_mucontext(ctx)->devx_uid, to_mucontext(ctx)->devx_uid,
&dm->base.dev_addr, &dm->obj_id); &dm->base.dev_addr, &dm->obj_id);
...@@ -420,8 +436,8 @@ struct ib_dm *mlx5_ib_alloc_dm(struct ib_device *ibdev, ...@@ -420,8 +436,8 @@ struct ib_dm *mlx5_ib_alloc_dm(struct ib_device *ibdev,
case MLX5_IB_UAPI_DM_TYPE_MEMIC: case MLX5_IB_UAPI_DM_TYPE_MEMIC:
return handle_alloc_dm_memic(context, attr, attrs); return handle_alloc_dm_memic(context, attr, attrs);
case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM: case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM:
return handle_alloc_dm_sw_icm(context, attr, attrs, type);
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM: case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM:
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_PATTERN_SW_ICM:
return handle_alloc_dm_sw_icm(context, attr, attrs, type); return handle_alloc_dm_sw_icm(context, attr, attrs, type);
default: default:
return ERR_PTR(-EOPNOTSUPP); return ERR_PTR(-EOPNOTSUPP);
...@@ -474,6 +490,7 @@ static int mlx5_ib_dealloc_dm(struct ib_dm *ibdm, ...@@ -474,6 +490,7 @@ static int mlx5_ib_dealloc_dm(struct ib_dm *ibdm,
return 0; return 0;
case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM: case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM:
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM: case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM:
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_PATTERN_SW_ICM:
return mlx5_dm_icm_dealloc(ctx, to_icm(ibdm)); return mlx5_dm_icm_dealloc(ctx, to_icm(ibdm));
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -1083,6 +1083,7 @@ struct ib_mr *mlx5_ib_reg_dm_mr(struct ib_pd *pd, struct ib_dm *dm, ...@@ -1083,6 +1083,7 @@ struct ib_mr *mlx5_ib_reg_dm_mr(struct ib_pd *pd, struct ib_dm *dm,
break; break;
case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM: case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM:
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM: case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM:
case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_PATTERN_SW_ICM:
if (attr->access_flags & ~MLX5_IB_DM_SW_ICM_ALLOWED_ACCESS) if (attr->access_flags & ~MLX5_IB_DM_SW_ICM_ALLOWED_ACCESS)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
......
...@@ -63,6 +63,7 @@ enum mlx5_ib_uapi_dm_type { ...@@ -63,6 +63,7 @@ enum mlx5_ib_uapi_dm_type {
MLX5_IB_UAPI_DM_TYPE_MEMIC, MLX5_IB_UAPI_DM_TYPE_MEMIC,
MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM, MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM,
MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM, MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM,
MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_PATTERN_SW_ICM,
}; };
enum mlx5_ib_uapi_devx_create_event_channel_flags { enum mlx5_ib_uapi_devx_create_event_channel_flags {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment