Expose c0 and SW encap ICM for RDMA
Subsystems (5)
cover Expose c0 and SW encap ICM for RDMA
From: Leon Romanovsky <[email protected]>
Hi,
These two series from Mark and Shun extend RDMA mlx5 API.
Mark's series provides c0 register used to match egress traffic sent by local device.
Shun's series adds new type for ICM area.
Thanks
Mark Bloch (2):
net/mlx5: E-Switch, expose eswitch manager vport RDMA/mlx5: Expose register c0 for RDMA device
Shun Hao (3):
net/mlx5: Introduce indirect-sw-encap icm properties net/mlx5: Manage ICM type of SW encap RDMA/mlx5: Support handling of SW encap ICM area
drivers/infiniband/hw/mlx5/dm.c | 5 +++ drivers/infiniband/hw/mlx5/main.c | 24 ++++++++++++ drivers/infiniband/hw/mlx5/mr.c | 1 + .../net/ethernet/mellanox/mlx5/core/eswitch.h | 7 ---- .../net/ethernet/mellanox/mlx5/core/lib/dm.c | 38 ++++++++++++++++++- include/linux/mlx5/driver.h | 1 + include/linux/mlx5/eswitch.h | 8 ++++ include/linux/mlx5/mlx5_ifc.h | 9 ++++- include/uapi/rdma/mlx5-abi.h | 2 + include/uapi/rdma/mlx5_user_ioctl_verbs.h | 1 + 10 files changed, 86 insertions(+), 10 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/5 net/mlx5: Introduce indirect-sw-encap icm properties
From: Shun Hao <[email protected]>
Add new fields for device memory capabilities, in order to support creation of new ICM memory type of SW encap.
--- include/linux/mlx5/mlx5_ifc.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/mlx5/mlx5_ifc.h +7 -2
@@ -1193,7 +1193,8 @@ 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[0x18 ]; +u8 log_indirect_encap_sw_icm_size[0x8 ]; +u8 reserved_at_128[0x10 ];u8 log_header_modify_pattern_sw_icm_size[0x8 ];u8 header_modify_sw_icm_start_address[0x40 ];
@@ -1204,7 +1205,11 @@ struct mlx5_ifc_device_mem_cap_bits {u8 memic_operations[0x20 ]; -u8 reserved_at_220[0x5e0 ]; +u8 reserved_at_220[0x20 ]; + +u8 indirect_encap_sw_icm_start_address[0x40 ]; + +u8 reserved_at_280[0x580 ]; };struct mlx5_ifc_device_event_cap_bits {
Signature · 1 line
2.43.0
PATCH 2/5 net/mlx5: Manage ICM type of SW encap
In reply to Leon RomanovskyFrom: Shun Hao <[email protected]>
Support allocate/deallocate the new SW encap ICM type memory. The new ICM type is used for encap context allocation managed by SW, instead FW. It can increase encap context maximum number and allocation speed
--- .../net/ethernet/mellanox/mlx5/core/lib/dm.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c +37 -1
@@ -13,11 +13,13 @@ struct mlx5_dm {unsigned long *steering_sw_icm_alloc_blocks;unsigned long *header_modify_sw_icm_alloc_blocks;unsigned long *header_modify_pattern_sw_icm_alloc_blocks; +unsigned long *header_encap_sw_icm_alloc_blocks; };struct mlx5_dm *mlx5_dm_create (struct mlx5_core_dev *dev) {u64 header_modify_pattern_icm_blocks =0 ; +u64 header_sw_encap_icm_blocks =0 ;u64 header_modify_icm_blocks =0 ;u64 steering_icm_blocks =0 ;struct mlx5_dm *dm;
@@ -54,6 +56,17 @@ struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev) goto err_modify_hdr; } +if (MLX5_CAP_DEV_MEM (dev, log_indirect_encap_sw_icm_size)) { + header_sw_encap_icm_blocks = +BIT (MLX5_CAP_DEV_MEM (dev, log_indirect_encap_sw_icm_size) - +MLX5_LOG_SW_ICM_BLOCK_SIZE (dev)); + + dm->header_encap_sw_icm_alloc_blocks = +bitmap_zalloc (header_sw_encap_icm_blocks,GFP_KERNEL ); +if (!dm->header_encap_sw_icm_alloc_blocks) + goto err_pattern; + } + 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);
@@ -66,11 +79,14 @@ struct mlx5_dm *mlx5_dm_create(struct mlx5_core_dev *dev) dm->header_modify_pattern_sw_icm_alloc_blocks =bitmap_zalloc (header_modify_pattern_icm_blocks,GFP_KERNEL );if (!dm->header_modify_pattern_sw_icm_alloc_blocks) - goto err_pattern; + goto err_sw_encap; }return dm; +err_sw_encap: +bitmap_free (dm->header_encap_sw_icm_alloc_blocks); + err_pattern:bitmap_free (dm->header_modify_sw_icm_alloc_blocks);
@@ -105,6 +121,14 @@ void mlx5_dm_cleanup(struct mlx5_core_dev *dev) bitmap_free(dm->header_modify_sw_icm_alloc_blocks); } + if (dm->header_encap_sw_icm_alloc_blocks) { + WARN_ON(!bitmap_empty(dm->header_encap_sw_icm_alloc_blocks, + BIT(MLX5_CAP_DEV_MEM(dev, + log_indirect_encap_sw_icm_size) - + MLX5_LOG_SW_ICM_BLOCK_SIZE(dev)))); + bitmap_free(dm->header_encap_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,
@@ -164,6 +188,13 @@ int mlx5_dm_sw_icm_alloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type, log_header_modify_pattern_sw_icm_size); block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;break ; +case MLX5_SW_ICM_TYPE_SW_ENCAP : + icm_start_addr =MLX5_CAP64_DEV_MEM (dev, + indirect_encap_sw_icm_start_address); + log_icm_size =MLX5_CAP_DEV_MEM (dev, + log_indirect_encap_sw_icm_size); + block_map = dm->header_encap_sw_icm_alloc_blocks; +break ;default :return -EINVAL ; }
@@ -242,6 +273,11 @@ int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type header_modify_pattern_sw_icm_start_address); block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;break ; +case MLX5_SW_ICM_TYPE_SW_ENCAP : + icm_start_addr =MLX5_CAP64_DEV_MEM (dev, + indirect_encap_sw_icm_start_address); + block_map = dm->header_encap_sw_icm_alloc_blocks; +break ;default :return -EINVAL ; }
Signature · 1 line
2.43.0
Simon Horman
reviewerRe: [PATCH mlx5-next 2/5] net/mlx5: Manage ICM type of SW encap
Quoted 9 lines · Leon Romanovsky
From: Shun Hao <[email protected]>
Support allocate/deallocate the new SW encap ICM type memory. The new ICM type is used for encap context allocation managed by SW, instead FW. It can increase encap context maximum number and allocation speed
Signed-off-by Shun Hao <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>
...
Quoted 16 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c +7
-0@@ -164,6 +188,13 @@ int mlx5_dm_sw_icm_alloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type, log_header_modify_pattern_sw_icm_size); block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;break ; +case MLX5_SW_ICM_TYPE_SW_ENCAP : + icm_start_addr =MLX5_CAP64_DEV_MEM (dev, + indirect_encap_sw_icm_start_address); + log_icm_size =MLX5_CAP_DEV_MEM (dev, + log_indirect_encap_sw_icm_size); + block_map = dm->header_encap_sw_icm_alloc_blocks; +break ;default :return -EINVAL ; }@@ -242,6 +273,11 @@ int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type header_modify_pattern_sw_icm_start_address);
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type · line 283
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c +5
-0block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;break ; +case MLX5_SW_ICM_TYPE_SW_ENCAP : + icm_start_addr =MLX5_CAP64_DEV_MEM (dev, + indirect_encap_sw_icm_start_address); + block_map = dm->header_encap_sw_icm_alloc_blocks; +break ;default :return -EINVAL ; }
Hi Leon and Shun,
a minor nit from my side: this patch uses MLX5_SW_ICM_TYPE_SW_ENCAP, but that enum value isn't present until the following patch.
Re: [PATCH mlx5-next 2/5] net/mlx5: Manage ICM type of SW encap
Quoted 42 lines · Simon Horman
Quoted 9 lines · Leon Romanovsky
From: Shun Hao <[email protected]>
Support allocate/deallocate the new SW encap ICM type memory. The new ICM type is used for encap context allocation managed by SW, instead FW. It can increase encap context maximum number and allocation speed
Signed-off-by Shun Hao <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>...
Quoted 16 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c +7
-0@@ -164,6 +188,13 @@ int mlx5_dm_sw_icm_alloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type, log_header_modify_pattern_sw_icm_size); block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;break ; +case MLX5_SW_ICM_TYPE_SW_ENCAP : + icm_start_addr =MLX5_CAP64_DEV_MEM (dev, + indirect_encap_sw_icm_start_address); + log_icm_size =MLX5_CAP_DEV_MEM (dev, + log_indirect_encap_sw_icm_size); + block_map = dm->header_encap_sw_icm_alloc_blocks; +break ;default :return -EINVAL ; }@@ -242,6 +273,11 @@ int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type header_modify_pattern_sw_icm_start_address);drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c int mlx5_dm_sw_icm_dealloc(struct mlx5_core_dev *dev, enum mlx5_sw_icm_type type · line 283
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/lib/dm.c +5
-0block_map = dm->header_modify_pattern_sw_icm_alloc_blocks;break ; +case MLX5_SW_ICM_TYPE_SW_ENCAP : + icm_start_addr =MLX5_CAP64_DEV_MEM (dev, + indirect_encap_sw_icm_start_address); + block_map = dm->header_encap_sw_icm_alloc_blocks; +break ;default :return -EINVAL ; }Hi Leon and Shun,
Quoted 2 lines
a minor nit from my side: this patch uses
MLX5_SW_ICM_TYPE_SW_ENCAP, but that enum value isn't present until the following patch.
Thanks, it was my mistake to reorder patches, will change to right order and resubmit.
PATCH 3/5 RDMA/mlx5: Support handling of SW encap ICM area
In reply to Leon RomanovskyFrom: Shun Hao <[email protected]>
New type for this ICM area, now the user can allocate/deallocate the new type of SW encap ICM memory, to store the encap header data which are managed by SW.
--- drivers/infiniband/hw/mlx5/dm.c | 5 +++++ drivers/infiniband/hw/mlx5/mr.c | 1 + include/linux/mlx5/driver.h | 1 + include/uapi/rdma/mlx5_user_ioctl_verbs.h | 1 + 4 files changed, 8 insertions(+)
drivers/infiniband/hw/mlx5/dm.c +5 -0
@@ -341,6 +341,8 @@ static enum mlx5_sw_icm_type get_icm_type(int uapi_type)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_ENCAP_SW_ICM : +return MLX5_SW_ICM_TYPE_SW_ENCAP ;case MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM :default :return MLX5_SW_ICM_TYPE_STEERING ;
@@ -364,6 +366,7 @@ static struct ib_dm *handle_alloc_dm_sw_icm(struct ib_ucontext *ctx,switch (type) {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_ENCAP_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) ||
@@ -438,6 +441,7 @@ struct ib_dm *mlx5_ib_alloc_dm(struct ib_device *ibdev,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 : +case MLX5_IB_UAPI_DM_TYPE_ENCAP_SW_ICM :return handle_alloc_dm_sw_icm (context, attr, attrs, type);default :return ERR_PTR (-EOPNOTSUPP );
@@ -491,6 +495,7 @@ static int mlx5_ib_dealloc_dm(struct ib_dm *ibdm,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 : +case MLX5_IB_UAPI_DM_TYPE_ENCAP_SW_ICM :return mlx5_dm_icm_dealloc (ctx,to_icm (ibdm));default :return -EOPNOTSUPP ;
drivers/infiniband/hw/mlx5/mr.c +1 -0
@@ -1349,6 +1349,7 @@ struct ib_mr *mlx5_ib_reg_dm_mr(struct ib_pd *pd, struct ib_dm *dm,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 : +case MLX5_IB_UAPI_DM_TYPE_ENCAP_SW_ICM :if (attr->access_flags & ~MLX5_IB_DM_SW_ICM_ALLOWED_ACCESS )return ERR_PTR (-EINVAL );
include/linux/mlx5/driver.h +1 -0
@@ -688,6 +688,7 @@ enum mlx5_sw_icm_type {MLX5_SW_ICM_TYPE_STEERING ,MLX5_SW_ICM_TYPE_HEADER_MODIFY ,MLX5_SW_ICM_TYPE_HEADER_MODIFY_PATTERN , + MLX5_SW_ICM_TYPE_SW_ENCAP, };#define MLX5_MAX_RESERVED_GIDS 8
include/uapi/rdma/mlx5_user_ioctl_verbs.h +1 -0
@@ -64,6 +64,7 @@ enum mlx5_ib_uapi_dm_type {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 , + MLX5_IB_UAPI_DM_TYPE_ENCAP_SW_ICM, }; enum mlx5_ib_uapi_devx_create_event_channel_flags {
Signature · 1 line
2.43.0
PATCH 4/5 net/mlx5: E-Switch, expose eswitch manager vport
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
Expose the ability the query the eswitch manager vport number. Next patch will utilize this capability to reveal the correct register C0 value to the users.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 7 ------- include/linux/mlx5/eswitch.h | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 -7
@@ -616,13 +616,6 @@ static inline bool mlx5_esw_allowed(const struct mlx5_eswitch *esw)return esw &&MLX5_ESWITCH_MANAGER (esw->dev); } -/* The returned number is valid only when the dev is eswitch manager. */ -static inline u16 mlx5_eswitch_manager_vport (struct mlx5_core_dev *dev) -{ -return mlx5_core_is_ecpf_esw_manager (dev) ? -MLX5_VPORT_ECPF :MLX5_VPORT_PF ; -} -static inline bool mlx5_esw_is_manager_vport (const struct mlx5_eswitch *esw,u16 vport_num) {
include/linux/mlx5/eswitch.h +8 -0
@@ -7,6 +7,7 @@#define _MLX5_ESWITCH_#include <linux/mlx5/driver.h> +#include <linux/mlx5/vport.h> #include <net/devlink.h> #define MLX5_ESWITCH_MANAGER (mdev) MLX5_CAP_GEN(mdev, eswitch_manager)
@@ -210,4 +211,11 @@ static inline bool is_mdev_switchdev_mode(struct mlx5_core_dev *dev) return mlx5_eswitch_mode(dev) == MLX5_ESWITCH_OFFLOADS; } +/* The returned number is valid only when the dev is eswitch manager. */ +static inline u16 mlx5_eswitch_manager_vport (struct mlx5_core_dev *dev) +{ +return mlx5_core_is_ecpf_esw_manager (dev) ? +MLX5_VPORT_ECPF :MLX5_VPORT_PF ; +} +#endif
Signature · 1 line
2.43.0
PATCH 5/5 RDMA/mlx5: Expose register c0 for RDMA device
In reply to Leon RomanovskyFrom: Mark Bloch <[email protected]>
This patch introduces improvements for matching egress traffic sent by the local device. When applicable, all egress traffic from the local vport is now tagged with the provided value. This enhancement is particularly useful for FDB steering purposes.
The primary focus of this update is facilitating the transmission of traffic from the hypervisor to a VF. To achieve this, one must initiate an SQ on the hypervisor and subsequently create a rule in the FDB that matches on the eswitch manager vport and the SQN of the aforementioned SQ.
Obtaining the SQN can be had from SQ opened, and the eswitch manager vport match can be substituted with the register c0 value exposed by this patch.
--- drivers/infiniband/hw/mlx5/main.c | 24 ++++++++++++++++++++++++ include/uapi/rdma/mlx5-abi.h | 2 ++ 2 files changed, 26 insertions(+)
drivers/infiniband/hw/mlx5/main.c +24 -0
@@ -849,6 +849,17 @@ static int mlx5_query_node_desc(struct mlx5_ib_dev *dev, char *node_desc) MLX5_REG_NODE_DESC, 0, 0); } +static void fill_esw_mgr_reg_c0 (struct mlx5_core_dev *mdev, +struct mlx5_ib_query_device_resp *resp) +{ +struct mlx5_eswitch *esw = mdev->priv.eswitch; +u16 vport =mlx5_eswitch_manager_vport (mdev); + + resp->reg_c0.value =mlx5_eswitch_get_vport_metadata_for_match (esw, + vport); + resp->reg_c0.mask =mlx5_eswitch_get_vport_metadata_mask (); +} +static int mlx5_ib_query_device (struct ib_device *ibdev,struct ib_device_attr *props,struct ib_udata *uhw)
@@ -1240,6 +1251,19 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,MLX5_CAP_GEN (mdev, log_max_dci_errored_streams); } +if (offsetofend (typeof (resp), reserved) <= uhw_outlen) + resp.response_length +=sizeof (resp.reserved); + +if (offsetofend (typeof (resp), reg_c0) <= uhw_outlen) { +struct mlx5_eswitch *esw = mdev->priv.eswitch; + + resp.response_length +=sizeof (resp.reg_c0); + +if (mlx5_eswitch_mode (mdev) ==MLX5_ESWITCH_OFFLOADS && +mlx5_eswitch_vport_match_metadata_enabled (esw)) +fill_esw_mgr_reg_c0 (mdev, &resp); + } +if (uhw_outlen) { err =ib_copy_to_udata (uhw, &resp, resp.response_length);
include/uapi/rdma/mlx5-abi.h +2 -0
@@ -37,6 +37,7 @@#include <linux/types.h> #include <linux/if_ether.h> /* For ETH_ALEN. */ #include <rdma/ib_user_ioctl_verbs.h> +#include <rdma/mlx5_user_ioctl_verbs.h> enum {MLX5_QP_FLAG_SIGNATURE =1 <<0 ,
@@ -275,6 +276,7 @@ struct mlx5_ib_query_device_resp {__u32 tunnel_offloads_caps;/* enum mlx5_ib_tunnel_offloads */ struct mlx5_ib_dci_streams_caps dci_streams_caps;__u16 reserved; +struct mlx5_ib_uapi_reg reg_c0; };enum mlx5_ib_create_cq_flags {
Signature · 1 line
2.43.0