* [PATCH mlx5-next 1/3] net/mlx5: Introduce header-modify-pattern ICM properties
2022-06-07 12:47 [PATCH mlx5-next 0/3] Add ICM header-modify-pattern RDMA API Leon Romanovsky
@ 2022-06-07 12:47 ` Leon Romanovsky
2022-06-08 6:44 ` Saeed Mahameed
2022-06-07 12:47 ` [PATCH mlx5-next 2/3] net/mlx5: Manage ICM of type modify-header pattern Leon Romanovsky
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Leon Romanovsky @ 2022-06-07 12:47 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Yevgeny Kliteynik, Erez Shitrit, Eric Dumazet, Jakub Kicinski,
linux-rdma, netdev, Paolo Abeni, Saeed Mahameed
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
Added new fields for device memory capabilities, in order to
support creation of ICM memory for modify header patterns.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
include/linux/mlx5/mlx5_ifc.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 006836ae7e43..4e41b3164dc8 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -1086,11 +1086,14 @@ struct mlx5_ifc_device_mem_cap_bits {
u8 log_sw_icm_alloc_granularity[0x6];
u8 log_steering_sw_icm_size[0x8];
- u8 reserved_at_120[0x20];
+ u8 reserved_at_120[0x18];
+ u8 log_header_modify_pattern_sw_icm_size[0x8];
u8 header_modify_sw_icm_start_address[0x40];
- u8 reserved_at_180[0x80];
+ u8 reserved_at_180[0x40];
+
+ u8 header_modify_pattern_sw_icm_start_address[0x40];
u8 memic_operations[0x20];
--
2.36.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH mlx5-next 1/3] net/mlx5: Introduce header-modify-pattern ICM properties
2022-06-07 12:47 ` [PATCH mlx5-next 1/3] net/mlx5: Introduce header-modify-pattern ICM properties Leon Romanovsky
@ 2022-06-08 6:44 ` Saeed Mahameed
0 siblings, 0 replies; 7+ messages in thread
From: Saeed Mahameed @ 2022-06-08 6:44 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Jason Gunthorpe, Yevgeny Kliteynik, Erez Shitrit, Eric Dumazet,
Jakub Kicinski, linux-rdma, netdev, Paolo Abeni, Saeed Mahameed
On 07 Jun 15:47, Leon Romanovsky wrote:
>From: Yevgeny Kliteynik <kliteyn@nvidia.com>
>
>Added new fields for device memory capabilities, in order to
>support creation of ICM memory for modify header patterns.
>
>Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
>Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
>Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Saeed Mahameed <saeedm@nvidia.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH mlx5-next 2/3] net/mlx5: Manage ICM of type modify-header pattern
2022-06-07 12:47 [PATCH mlx5-next 0/3] Add ICM header-modify-pattern RDMA API Leon Romanovsky
2022-06-07 12:47 ` [PATCH mlx5-next 1/3] net/mlx5: Introduce header-modify-pattern ICM properties Leon Romanovsky
@ 2022-06-07 12:47 ` Leon Romanovsky
2022-06-08 6:44 ` Saeed Mahameed
2022-06-07 12:47 ` [PATCH mlx5-next 3/3] RDMA/mlx5: Support handling of modify-header pattern ICM area Leon Romanovsky
2022-06-14 18:24 ` [PATCH mlx5-next 0/3] Add ICM header-modify-pattern RDMA API Saeed Mahameed
3 siblings, 1 reply; 7+ messages in thread
From: Leon Romanovsky @ 2022-06-07 12:47 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Yevgeny Kliteynik, Erez Shitrit, Eric Dumazet, Jakub Kicinski,
linux-rdma, netdev, Paolo Abeni, Saeed Mahameed
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
Added support for managing new type of ICM for devices that
support sw_owner_v2.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/lib/dm.c | 42 +++++++++++++++++++
include/linux/mlx5/driver.h | 1 +
2 files changed, 43 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c
index 3d5e57ff558c..7e02cbe8c3b9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c
@@ -12,13 +12,16 @@ struct mlx5_dm {
spinlock_t lock;
unsigned long *steering_sw_icm_alloc_blocks;
unsigned long *header_modify_sw_icm_alloc_blocks;
+ unsigned long *header_modify_pattern_sw_icm_alloc_blocks;
};
struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev)
{
+ u64 header_modify_pattern_icm_blocks = 0;
u64 header_modify_icm_blocks = 0;
u64 steering_icm_blocks = 0;
struct mlx5_dm *dm;
+ bool support_v2;
if (!(MLX5_CAP_GEN_64(dev, general_obj_types) & MLX5_GENERAL_OBJ_TYPES_CAP_SW_ICM))
return NULL;
@@ -53,8 +56,27 @@ struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev)
goto err_modify_hdr;
}
+ support_v2 = MLX5_CAP_FLOWTABLE_NIC_RX(dev, sw_owner_v2) &&
+ MLX5_CAP_FLOWTABLE_NIC_TX(dev, sw_owner_v2) &&
+ MLX5_CAP64_DEV_MEM(dev, header_modify_pattern_sw_icm_start_address);
+
+ if (support_v2) {
+ header_modify_pattern_icm_blocks =
+ BIT(MLX5_CAP_DEV_MEM(dev, log_header_modify_pattern_sw_icm_size) -
+ MLX5_LOG_SW_ICM_BLOCK_SIZE(dev));
+
+ dm->header_modify_pattern_sw_icm_alloc_blocks =
+ kcalloc(BITS_TO_LONGS(header_modify_pattern_icm_blocks),
+ sizeof(unsigned long), GFP_KERNEL);
+ if (!dm->header_modify_pattern_sw_icm_alloc_blocks)
+ goto err_pattern;
+ }
+
return dm;
+err_pattern:
+ kfree(dm->header_modify_sw_icm_alloc_blocks);
+
err_modify_hdr:
kfree(dm->steering_sw_icm_alloc_blocks);
@@ -86,6 +108,14 @@ void mlx5_dm_cleanup(struct mlx5_core_dev *dev)
kfree(dm->header_modify_sw_icm_alloc_blocks);
}
+ if (dm->header_modify_pattern_sw_icm_alloc_blocks) {
+ WARN_ON(!bitmap_empty(dm->header_modify_pattern_sw_icm_alloc_blocks,
+ BIT(MLX5_CAP_DEV_MEM(dev,
+ log_header_modify_pattern_sw_icm_size) -
+ MLX5_LOG_SW_ICM_BLOCK_SIZE(dev))));
+ kfree(dm->header_modify_pattern_sw_icm_alloc_blocks);
+ }
+
kfree(dm);
}
@@ -130,6 +160,13 @@ int mlx5_dm_sw_icm_alloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type,
log_header_modify_sw_icm_size);
block_map = dm->header_modify_sw_icm_alloc_blocks;
break;
+ case MLX5_SW_ICM_TYPE_HEADER_MODIFY_PATTERN:
+ icm_start_addr = MLX5_CAP64_DEV_MEM(dev,
+ header_modify_pattern_sw_icm_start_address);
+ log_icm_size = MLX5_CAP_DEV_MEM(dev,
+ log_header_modify_pattern_sw_icm_size);
+ block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;
+ break;
default:
return -EINVAL;
}
@@ -203,6 +240,11 @@ int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type
icm_start_addr = MLX5_CAP64_DEV_MEM(dev, header_modify_sw_icm_start_address);
block_map = dm->header_modify_sw_icm_alloc_blocks;
break;
+ case MLX5_SW_ICM_TYPE_HEADER_MODIFY_PATTERN:
+ icm_start_addr = MLX5_CAP64_DEV_MEM(dev,
+ header_modify_pattern_sw_icm_start_address);
+ block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;
+ break;
default:
return -EINVAL;
}
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index aeaedb985c1f..220597c2f436 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -676,6 +676,7 @@ struct mlx5e_resources {
enum mlx5_sw_icm_type {
MLX5_SW_ICM_TYPE_STEERING,
MLX5_SW_ICM_TYPE_HEADER_MODIFY,
+ MLX5_SW_ICM_TYPE_HEADER_MODIFY_PATTERN,
};
#define MLX5_MAX_RESERVED_GIDS 8
--
2.36.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH mlx5-next 2/3] net/mlx5: Manage ICM of type modify-header pattern
2022-06-07 12:47 ` [PATCH mlx5-next 2/3] net/mlx5: Manage ICM of type modify-header pattern Leon Romanovsky
@ 2022-06-08 6:44 ` Saeed Mahameed
0 siblings, 0 replies; 7+ messages in thread
From: Saeed Mahameed @ 2022-06-08 6:44 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Jason Gunthorpe, Yevgeny Kliteynik, Erez Shitrit, Eric Dumazet,
Jakub Kicinski, linux-rdma, netdev, Paolo Abeni, Saeed Mahameed
On 07 Jun 15:47, Leon Romanovsky wrote:
>From: Yevgeny Kliteynik <kliteyn@nvidia.com>
>
>Added support for managing new type of ICM for devices that
>support sw_owner_v2.
>
>Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
>Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
>Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
>---
Acked-by: Saeed Mahameed <saeedm@nvidia.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH mlx5-next 3/3] RDMA/mlx5: Support handling of modify-header pattern ICM area
2022-06-07 12:47 [PATCH mlx5-next 0/3] Add ICM header-modify-pattern RDMA API Leon Romanovsky
2022-06-07 12:47 ` [PATCH mlx5-next 1/3] net/mlx5: Introduce header-modify-pattern ICM properties Leon Romanovsky
2022-06-07 12:47 ` [PATCH mlx5-next 2/3] net/mlx5: Manage ICM of type modify-header pattern Leon Romanovsky
@ 2022-06-07 12:47 ` Leon Romanovsky
2022-06-14 18:24 ` [PATCH mlx5-next 0/3] Add ICM header-modify-pattern RDMA API Saeed Mahameed
3 siblings, 0 replies; 7+ messages in thread
From: Leon Romanovsky @ 2022-06-07 12:47 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Yevgeny Kliteynik, David S. Miller, Erez Shitrit, Eric Dumazet,
Jakub Kicinski, linux-rdma, netdev, Paolo Abeni, Saeed Mahameed
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
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: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/infiniband/hw/mlx5/dm.c | 53 +++++++++++++++--------
drivers/infiniband/hw/mlx5/mr.c | 1 +
include/uapi/rdma/mlx5_user_ioctl_verbs.h | 1 +
3 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/dm.c b/drivers/infiniband/hw/mlx5/dm.c
index 001d766cf291..3669c90b2dad 100644
--- a/drivers/infiniband/hw/mlx5/dm.c
+++ b/drivers/infiniband/hw/mlx5/dm.c
@@ -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)
{
- return uapi_type == MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM ?
- MLX5_SW_ICM_TYPE_STEERING :
- MLX5_SW_ICM_TYPE_HEADER_MODIFY;
+ switch (uapi_type) {
+ case MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM:
+ 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,
@@ -347,11 +353,32 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,
int type)
{
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;
u64 act_size;
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);
if (!dm)
return ERR_PTR(-ENOMEM);
@@ -359,19 +386,6 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,
dm->base.type = type;
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
* and a power of 2.
*/
@@ -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);
dm->base.size = act_size;
+ icm_type = get_icm_type(type);
+
err = mlx5_dm_sw_icm_alloc(dev, icm_type, act_size, attr->alignment,
to_mucontext(ctx)->devx_uid,
&dm->base.dev_addr, &dm->obj_id);
@@ -420,8 +436,8 @@ struct ib_dm *mlx5_ib_alloc_dm(struct ib_device *ibdev,
case MLX5_IB_UAPI_DM_TYPE_MEMIC:
return handle_alloc_dm_memic(context, attr, attrs);
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_PATTERN_SW_ICM:
return handle_alloc_dm_sw_icm(context, attr, attrs, type);
default:
return ERR_PTR(-EOPNOTSUPP);
@@ -474,6 +490,7 @@ static int mlx5_ib_dealloc_dm(struct ib_dm *ibdm,
return 0;
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_PATTERN_SW_ICM:
return mlx5_dm_icm_dealloc(ctx, to_icm(ibdm));
default:
return -EOPNOTSUPP;
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 90bb61ad8c64..dd8887bf83f0 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1132,6 +1132,7 @@ struct ib_mr *mlx5_ib_reg_dm_mr(struct ib_pd *pd, struct ib_dm *dm,
break;
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_PATTERN_SW_ICM:
if (attr->access_flags & ~MLX5_IB_DM_SW_ICM_ALLOWED_ACCESS)
return ERR_PTR(-EINVAL);
diff --git a/include/uapi/rdma/mlx5_user_ioctl_verbs.h b/include/uapi/rdma/mlx5_user_ioctl_verbs.h
index a21ca8ece8db..7af9e09ea556 100644
--- a/include/uapi/rdma/mlx5_user_ioctl_verbs.h
+++ b/include/uapi/rdma/mlx5_user_ioctl_verbs.h
@@ -63,6 +63,7 @@ enum mlx5_ib_uapi_dm_type {
MLX5_IB_UAPI_DM_TYPE_MEMIC,
MLX5_IB_UAPI_DM_TYPE_STEERING_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 {
--
2.36.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH mlx5-next 0/3] Add ICM header-modify-pattern RDMA API
2022-06-07 12:47 [PATCH mlx5-next 0/3] Add ICM header-modify-pattern RDMA API Leon Romanovsky
` (2 preceding siblings ...)
2022-06-07 12:47 ` [PATCH mlx5-next 3/3] RDMA/mlx5: Support handling of modify-header pattern ICM area Leon Romanovsky
@ 2022-06-14 18:24 ` Saeed Mahameed
3 siblings, 0 replies; 7+ messages in thread
From: Saeed Mahameed @ 2022-06-14 18:24 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Jason Gunthorpe, Leon Romanovsky, Erez Shitrit, Eric Dumazet,
Jakub Kicinski, linux-kernel, linux-rdma, netdev, Paolo Abeni,
Saeed Mahameed, Yevgeny Kliteynik
On 07 Jun 15:47, Leon Romanovsky wrote:
>From: Leon Romanovsky <leonro@nvidia.com>
>
>SW steering manipulates packet's header using "modifying header" actions.
>Many of these actions do the same operation, but use different data each time.
>Currently we create and keep every one of these actions, which use expensive
>and limited resources.
>
Series applied to mlx5-next
>Now we introduce a new mechanism - pattern and argument, which splits
>a modifying action into two parts:
>1. action pattern: contains the operations to be applied on packet's header,
>mainly set/add/copy of fields in the packet
>2. action data/argument: contains the data to be used by each operation
>in the pattern.
>
>This way we reuse same patterns with different arguments to create new
>modifying actions, and since many actions share the same operations, we end
>up creating a small number of patterns that we keep in a dedicated cache.
>
>These modify header patterns are implemented as new type of ICM memory,
>so the following kernel patch series add the support for this new ICM type.
>
>Thanks
>
^ permalink raw reply [flat|nested] 7+ messages in thread