Introduce KABIs to query UCONTEXT, PD and MR properties
Subsystems (4)
cover Introduce KABIs to query UCONTEXT, PD and MR properties
From: Leon Romanovsky <[email protected]>
From Yishai,
This series introduce KABIs to query existing UCONTEXT, PD and MR for their properties.
By those KABIs a user space application which owns the command FD of the device can retrieve and rebuild the above objects despite that it wasn't their creator. As of that, PDs and MRs can be shared by any process who owns the command FD of their creator.
This functionality enables to utilize and optimize some application flows, few examples below.
Any solution which is a single business logic based on multi-process design needs this. Example include NGINX, with TCP load balancing, sharing the RSS indirection table with RQ per process. HPC frameworks with multi-rank (process) solution on single hosts. UCX can share IB resources using the shared PD and can help dispatch data to multiple processes/MR's in single RDMA operation. Also, there are use cases when a primary processes registered a large shared memory range, and each worker process spawned will create a private QP on the shared PD, and use the shared MR to save the registration time per-process.
The matching verbs APIs were introduced in the mailing list by the below RFC [1].
In addition, the series enables CQ ioctl commands by default as this functionality is fully mature for a long time and sets IOVA on IB MR in the uverbs layer to let all drivers have it.
[1] https://patchwork.kernel.org/patch/11540665/
Yishai
Yishai Hadas (7):
IB/uverbs: Enable CQ ioctl commands by default IB/uverbs: Set IOVA on IB MR in uverbs layer IB/uverbs: Expose KABI to query ucontext RDMA/mlx5: Refactor mlx5_ib_alloc_ucontext() response RDMA/mlx5: Implement the query ucontext functionality RDMA/mlx5: Introduce KABI to query PD attributes IB/uverbs: Expose KABI to query MR
drivers/infiniband/Kconfig | 8 - drivers/infiniband/core/device.c | 1 + drivers/infiniband/core/uverbs_cmd.c | 4 + drivers/infiniband/core/uverbs_ioctl.c | 1 + drivers/infiniband/core/uverbs_std_types_cq.c | 3 - .../infiniband/core/uverbs_std_types_device.c | 41 +++- drivers/infiniband/core/uverbs_std_types_mr.c | 50 +++- drivers/infiniband/hw/cxgb4/mem.c | 1 - drivers/infiniband/hw/mlx4/mr.c | 1 - drivers/infiniband/hw/mlx5/Makefile | 3 +- drivers/infiniband/hw/mlx5/main.c | 232 ++++++++++-------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 + drivers/infiniband/hw/mlx5/std_types.c | 45 ++++ include/rdma/ib_verbs.h | 4 + include/uapi/rdma/ib_user_ioctl_cmds.h | 15 ++ include/uapi/rdma/mlx5_user_ioctl_cmds.h | 14 ++ 16 files changed, 306 insertions(+), 119 deletions(-) create mode 100644 drivers/infiniband/hw/mlx5/std_types.c
--
2.26.2
PATCH 1/7 IB/uverbs: Enable CQ ioctl commands by default
From: Yishai Hadas <[email protected]>
Enable CQ ioctl commands by default, this functionality is fully mature to be used over ioctl, no reason to maintain any more the EXP KCONFIG entry to enable it.
--- drivers/infiniband/Kconfig | 8 -------- drivers/infiniband/core/uverbs_std_types_cq.c | 3 --- 2 files changed, 11 deletions(-)
drivers/infiniband/Kconfig +0 -8
@@ -37,14 +37,6 @@ config INFINIBAND_USER_ACCESS libibverbs, libibcm and a hardware driver library from rdma-core <https://github.com/linux-rdma/rdma-core>. -config INFINIBAND_EXP_LEGACY_VERBS_NEW_UAPI - bool "Allow experimental legacy verbs in new ioctl uAPI (EXPERIMENTAL)" - depends on INFINIBAND_USER_ACCESS - help - IOCTL based uAPI support for Infiniband is enabled by default for - new verbs only. This allows userspace to invoke the IOCTL based uAPI - for current legacy verbs too. - config INFINIBAND_USER_MEM bool depends on INFINIBAND_USER_ACCESS != n
drivers/infiniband/core/uverbs_std_types_cq.c +0 -3
@@ -207,11 +207,8 @@ DECLARE_UVERBS_NAMED_METHOD(DECLARE_UVERBS_NAMED_OBJECT (UVERBS_OBJECT_CQ ,UVERBS_TYPE_ALLOC_IDR_SZ (sizeof (struct ib_ucq_object ), uverbs_free_cq), - -#if IS_ENABLED(CONFIG_INFINIBAND_EXP_LEGACY_VERBS_NEW_UAPI) &UVERBS_METHOD (UVERBS_METHOD_CQ_CREATE ), &UVERBS_METHOD (UVERBS_METHOD_CQ_DESTROY ) -#endif );const struct uapi_definition uverbs_def_obj_cq[] = {
Signature · 1 line
2.26.2
PATCH 2/7 IB/uverbs: Set IOVA on IB MR in uverbs layer
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Set IOVA on IB MR in uverbs layer to let all drivers have it, this includes both reg/rereg MR flows.
As part of this change cleaned-up this setting from the drivers that already did it by themselves in their user flows.
--- drivers/infiniband/core/uverbs_cmd.c | 4 ++++ drivers/infiniband/hw/cxgb4/mem.c | 1 - drivers/infiniband/hw/mlx4/mr.c | 1 - 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +4 -0
@@ -770,6 +770,7 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) mr->uobject = uobj;atomic_inc (&pd->usecnt); mr->res.type =RDMA_RESTRACK_MR ; + mr->iova = cmd.hca_va;rdma_restrack_uadd (&mr->res); uobj->object = mr;
@@ -861,6 +862,9 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs)atomic_dec (&old_pd->usecnt); } +if (cmd.flags &IB_MR_REREG_TRANS ) + mr->iova = cmd.hca_va; +memset (&resp,0 ,sizeof (resp)); resp.lkey = mr->lkey; resp.rkey = mr->rkey;
drivers/infiniband/hw/cxgb4/mem.c +0 -1
@@ -399,7 +399,6 @@ static int finish_mem_reg(struct c4iw_mr *mhp, u32 stag) mmid = stag >>8 ; mhp->ibmr.rkey = mhp->ibmr.lkey = stag; mhp->ibmr.length = mhp->attr.len; - mhp->ibmr.iova = mhp->attr.va_fbo; mhp->ibmr.page_size =1U << (mhp->attr.page_size +12 );pr_debug ("mmid 0x%x mhp %p\n" , mmid, mhp);return xa_insert_irq (&mhp->rhp->mrs, mmid, mhp,GFP_KERNEL );
drivers/infiniband/hw/mlx4/mr.c +0 -1
@@ -439,7 +439,6 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key; mr->ibmr.length = length; - mr->ibmr.iova = virt_addr; mr->ibmr.page_size =1U << shift;return &mr->ibmr;
Signature · 1 line
2.26.2
PATCH 3/7 IB/uverbs: Expose KABI to query ucontext
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Expose KABI to query ucontext, this will let user space application that didn't allocate the ucontext but has access to by owning the matching command FD to retrieve the ucontext information.
--- drivers/infiniband/core/device.c | 1 + .../infiniband/core/uverbs_std_types_device.c | 41 ++++++++++++++++++- include/rdma/ib_verbs.h | 4 ++ include/uapi/rdma/ib_user_ioctl_cmds.h | 6 +++ 4 files changed, 51 insertions(+), 1 deletion(-)
drivers/infiniband/core/device.c +1 -0
@@ -2669,6 +2669,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)SET_DEVICE_OP (dev_ops, query_port);SET_DEVICE_OP (dev_ops, query_qp);SET_DEVICE_OP (dev_ops, query_srq); +SET_DEVICE_OP (dev_ops, query_ucontext);SET_DEVICE_OP (dev_ops, rdma_netdev_get_params);SET_DEVICE_OP (dev_ops, read_counters);SET_DEVICE_OP (dev_ops, reg_dm_mr);
drivers/infiniband/core/uverbs_std_types_device.c +40 -1
59 lines not on this page · raw message
include/rdma/ib_verbs.h +4 -0
@@ -2646,6 +2646,10 @@ struct ib_device_ops {*/ int (*fill_stat_mr_entry)(struct sk_buff *msg,struct ib_mr *ibmr); +/* query driver for its ucontext properties */ +int (*query_ucontext)(struct ib_ucontext *context, +struct uverbs_attr_bundle *attrs); +DECLARE_RDMA_OBJ_SIZE (ib_ah);DECLARE_RDMA_OBJ_SIZE (ib_cq);DECLARE_RDMA_OBJ_SIZE (ib_pd);
include/uapi/rdma/ib_user_ioctl_cmds.h +6 -0
@@ -69,6 +69,7 @@ enum uverbs_methods_device {UVERBS_METHOD_INFO_HANDLES ,UVERBS_METHOD_QUERY_PORT ,UVERBS_METHOD_GET_CONTEXT , + UVERBS_METHOD_QUERY_CONTEXT, }; enum uverbs_attrs_invoke_write_cmd_attr_ids {
@@ -87,6 +88,11 @@ enum uverbs_attrs_get_context_attr_ids { UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT, }; +enum uverbs_attrs_query_context_attr_ids { +UVERBS_ATTR_QUERY_CONTEXT_NUM_COMP_VECTORS , +UVERBS_ATTR_QUERY_CONTEXT_CORE_SUPPORT , +}; +enum uverbs_attrs_create_cq_cmd_attr_ids {UVERBS_ATTR_CREATE_CQ_HANDLE ,UVERBS_ATTR_CREATE_CQ_CQE ,
Signature · 1 line
2.26.2
PATCH 4/7 RDMA/mlx5: Refactor mlx5_ib_alloc_ucontext() response
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Refactor mlx5_ib_alloc_ucontext() to set its response fields in a cleaner way.
It includes,
- Move the relevant code to a self contained function.
- Calculate the response length once and drop redundant code all around.
- Reuse previously set ucontext fields once preparing the response.
The self contained function will be used in next patch as part of implementing the query ucontext functionality.
--- drivers/infiniband/hw/mlx5/main.c | 196 ++++++++++++++---------------- 1 file changed, 93 insertions(+), 103 deletions(-)
drivers/infiniband/hw/mlx5/main.c +93 -103
@@ -1765,6 +1765,92 @@ static void mlx5_ib_dealloc_transport_domain(struct mlx5_ib_dev *dev, u32 tdn,mlx5_ib_disable_lb (dev, true, false); } +static int set_ucontext_resp (struct ib_ucontext *uctx, +struct mlx5_ib_alloc_ucontext_resp *resp) +{ +struct ib_device *ibdev = uctx->device; +struct mlx5_ib_dev *dev =to_mdev (ibdev); +struct mlx5_ib_ucontext *context =to_mucontext (uctx); +struct mlx5_bfreg_info *bfregi = &context->bfregi; +int err; + +if (MLX5_CAP_GEN (dev->mdev, dump_fill_mkey)) { + err =mlx5_cmd_dump_fill_mkey (dev->mdev, + &resp->dump_fill_mkey); +if (err) +return err; + resp->comp_mask |= +MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_DUMP_FILL_MKEY ; + } + + resp->qp_tab_size =1 <<MLX5_CAP_GEN (dev->mdev, log_max_qp); +if (dev->wc_support) + resp->bf_reg_size =1 <<MLX5_CAP_GEN (dev->mdev, + log_bf_reg_size); + resp->cache_line_size =cache_line_size (); + resp->max_sq_desc_sz =MLX5_CAP_GEN (dev->mdev, max_wqe_sz_sq); + resp->max_rq_desc_sz =MLX5_CAP_GEN (dev->mdev, max_wqe_sz_rq); + resp->max_send_wqebb =1 <<MLX5_CAP_GEN (dev->mdev, log_max_qp_sz); + resp->max_recv_wr =1 <<MLX5_CAP_GEN (dev->mdev, log_max_qp_sz); + resp->max_srq_recv_wr =1 <<MLX5_CAP_GEN (dev->mdev, log_max_srq_sz); + resp->cqe_version = context->cqe_version; + resp->log_uar_size =MLX5_CAP_GEN (dev->mdev, uar_4k) ? +MLX5_ADAPTER_PAGE_SHIFT :PAGE_SHIFT ; + resp->num_uars_per_page =MLX5_CAP_GEN (dev->mdev, uar_4k) ? +MLX5_CAP_GEN (dev->mdev, + num_of_uars_per_page) :1 ; + +if (mlx5_accel_ipsec_device_caps (dev->mdev) & +MLX5_ACCEL_IPSEC_CAP_DEVICE ) { +if (mlx5_get_flow_namespace (dev->mdev, +MLX5_FLOW_NAMESPACE_EGRESS )) + resp->flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM ; +if (mlx5_accel_ipsec_device_caps (dev->mdev) & +MLX5_ACCEL_IPSEC_CAP_REQUIRED_METADATA ) + resp->flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_REQ_METADATA ; +if (MLX5_CAP_FLOWTABLE (dev->mdev, flow_table_properties_nic_receive.ft_field_support.outer_esp_spi)) + resp->flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_SPI_STEERING ; +if (mlx5_accel_ipsec_device_caps (dev->mdev) & +MLX5_ACCEL_IPSEC_CAP_TX_IV_IS_ESN ) + resp->flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_TX_IV_IS_ESN ; +/* MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_FULL_OFFLOAD is currently always 0 */ + } + + resp->tot_bfregs = bfregi->lib_uar_dyn ?0 : + bfregi->total_num_bfregs - bfregi->num_dyn_bfregs; + resp->num_ports = dev->num_ports; + resp->cmds_supp_uhw |=MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE | +MLX5_USER_CMDS_SUPP_UHW_CREATE_AH ; + +if (mlx5_ib_port_link_layer (ibdev,1 ) ==IB_LINK_LAYER_ETHERNET ) { +mlx5_query_min_inline (dev->mdev, &resp->eth_min_inline); + resp->eth_min_inline++; + } + +if (dev->mdev->clock_info) + resp->clock_info_versions =BIT (MLX5_IB_CLOCK_INFO_V1 ); + +/* +* We don't want to expose information from the PCI bar that is located +* after 4096 bytes, so if the arch only supports larger pages, let's +* pretend we don't support reading the HCA's core clock. This is also +* forced by mmap function. +*/ +if (PAGE_SIZE <=4096 ) { + resp->comp_mask |= +MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET ; + resp->hca_core_clock_offset = + offsetof(struct mlx5_init_seg , + internal_timer_h) %PAGE_SIZE ; + } + +if (MLX5_CAP_GEN (dev->mdev, ece_support)) + resp->comp_mask |=MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_ECE ; + + resp->num_dyn_bfregs = bfregi->num_dyn_bfregs; +return 0 ; +} +static int mlx5_ib_alloc_ucontext (struct ib_ucontext *uctx,struct ib_udata *udata) {
@@ -1772,14 +1858,12 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,struct mlx5_ib_dev *dev =to_mdev (ibdev);struct mlx5_ib_alloc_ucontext_req_v2 req = {};struct mlx5_ib_alloc_ucontext_resp resp = {}; -struct mlx5_core_dev *mdev = dev->mdev;struct mlx5_ib_ucontext *context =to_mucontext (uctx);struct mlx5_bfreg_info *bfregi;int ver;int err;size_t min_req_v2 = offsetof(struct mlx5_ib_alloc_ucontext_req_v2 , max_cqe_version); -u32 dump_fill_mkey;bool lib_uar_4k;bool lib_uar_dyn;
@@ -1808,37 +1892,6 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,if (req.num_low_latency_bfregs > req.total_num_bfregs -1 )return -EINVAL ; - resp.qp_tab_size =1 <<MLX5_CAP_GEN (dev->mdev, log_max_qp); -if (dev->wc_support) - resp.bf_reg_size =1 <<MLX5_CAP_GEN (dev->mdev, log_bf_reg_size); - resp.cache_line_size =cache_line_size (); - resp.max_sq_desc_sz =MLX5_CAP_GEN (dev->mdev, max_wqe_sz_sq); - resp.max_rq_desc_sz =MLX5_CAP_GEN (dev->mdev, max_wqe_sz_rq); - resp.max_send_wqebb =1 <<MLX5_CAP_GEN (dev->mdev, log_max_qp_sz); - resp.max_recv_wr =1 <<MLX5_CAP_GEN (dev->mdev, log_max_qp_sz); - resp.max_srq_recv_wr =1 <<MLX5_CAP_GEN (dev->mdev, log_max_srq_sz); - resp.cqe_version =min_t (__u8, - (__u8 )MLX5_CAP_GEN (dev->mdev, cqe_version), - req.max_cqe_version); - resp.log_uar_size =MLX5_CAP_GEN (dev->mdev, uar_4k) ? -MLX5_ADAPTER_PAGE_SHIFT :PAGE_SHIFT ; - resp.num_uars_per_page =MLX5_CAP_GEN (dev->mdev, uar_4k) ? -MLX5_CAP_GEN (dev->mdev, num_of_uars_per_page) :1 ; - resp.response_length =min (offsetof(typeof (resp ), response_length) + -sizeof (resp.response_length), udata->outlen); - -if (mlx5_accel_ipsec_device_caps (dev->mdev) &MLX5_ACCEL_IPSEC_CAP_DEVICE ) { -if (mlx5_get_flow_namespace (dev->mdev,MLX5_FLOW_NAMESPACE_EGRESS )) - resp.flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM ; -if (mlx5_accel_ipsec_device_caps (dev->mdev) &MLX5_ACCEL_IPSEC_CAP_REQUIRED_METADATA ) - resp.flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_REQ_METADATA ; -if (MLX5_CAP_FLOWTABLE (dev->mdev, flow_table_properties_nic_receive.ft_field_support.outer_esp_spi)) - resp.flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_SPI_STEERING ; -if (mlx5_accel_ipsec_device_caps (dev->mdev) &MLX5_ACCEL_IPSEC_CAP_TX_IV_IS_ESN ) - resp.flow_action_flags |=MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_TX_IV_IS_ESN ; -/* MLX5_USER_ALLOC_UCONTEXT_FLOW_ACTION_FLAGS_ESP_AES_GCM_FULL_OFFLOAD is currently always 0 */ - } - lib_uar_4k = req.lib_caps &MLX5_LIB_CAP_4K_UAR ; lib_uar_dyn = req.lib_caps &MLX5_LIB_CAP_DYN_UAR ; bfregi = &context->bfregi;
@@ -1887,87 +1940,24 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,if (err) goto out_devx; -if (MLX5_CAP_GEN (dev->mdev, dump_fill_mkey)) { - err =mlx5_cmd_dump_fill_mkey (dev->mdev, &dump_fill_mkey); -if (err) - goto out_mdev; - } -INIT_LIST_HEAD (&context->db_page_list);mutex_init (&context->db_page_mutex); - resp.tot_bfregs = lib_uar_dyn ?0 : req.total_num_bfregs; - resp.num_ports = dev->num_ports; - -if (offsetofend (typeof (resp), cqe_version) <= udata->outlen) - resp.response_length +=sizeof (resp.cqe_version); - -if (offsetofend (typeof (resp), cmds_supp_uhw) <= udata->outlen) { - resp.cmds_supp_uhw |=MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE | -MLX5_USER_CMDS_SUPP_UHW_CREATE_AH ; - resp.response_length +=sizeof (resp.cmds_supp_uhw); - } - -if (offsetofend (typeof (resp), eth_min_inline) <= udata->outlen) { -if (mlx5_ib_port_link_layer (ibdev,1 ) ==IB_LINK_LAYER_ETHERNET ) { -mlx5_query_min_inline (dev->mdev, &resp.eth_min_inline); - resp.eth_min_inline++; - } - resp.response_length +=sizeof (resp.eth_min_inline); - } - -if (offsetofend (typeof (resp), clock_info_versions) <= udata->outlen) { -if (mdev->clock_info) - resp.clock_info_versions =BIT (MLX5_IB_CLOCK_INFO_V1 ); - resp.response_length +=sizeof (resp.clock_info_versions); - } - -/* -* We don't want to expose information from the PCI bar that is located -* after 4096 bytes, so if the arch only supports larger pages, let's -* pretend we don't support reading the HCA's core clock. This is also -* forced by mmap function. -*/ -if (offsetofend (typeof (resp), hca_core_clock_offset) <= udata->outlen) { -if (PAGE_SIZE <=4096 ) { - resp.comp_mask |= -MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET ; - resp.hca_core_clock_offset = - offsetof(struct mlx5_init_seg , internal_timer_h) %PAGE_SIZE ; - } - resp.response_length +=sizeof (resp.hca_core_clock_offset); - } - -if (offsetofend (typeof (resp), log_uar_size) <= udata->outlen) - resp.response_length +=sizeof (resp.log_uar_size); - -if (offsetofend (typeof (resp), num_uars_per_page) <= udata->outlen) - resp.response_length +=sizeof (resp.num_uars_per_page); - -if (offsetofend (typeof (resp), num_dyn_bfregs) <= udata->outlen) { - resp.num_dyn_bfregs = bfregi->num_dyn_bfregs; - resp.response_length +=sizeof (resp.num_dyn_bfregs); - } - -if (offsetofend (typeof (resp), dump_fill_mkey) <= udata->outlen) { -if (MLX5_CAP_GEN (dev->mdev, dump_fill_mkey)) { - resp.dump_fill_mkey = dump_fill_mkey; - resp.comp_mask |= -MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_DUMP_FILL_MKEY ; - } - resp.response_length +=sizeof (resp.dump_fill_mkey); - } + context->cqe_version =min_t (__u8, + (__u8 )MLX5_CAP_GEN (dev->mdev, cqe_version), + req.max_cqe_version); -if (MLX5_CAP_GEN (dev->mdev, ece_support)) - resp.comp_mask |=MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_ECE ; + err =set_ucontext_resp (uctx, &resp); +if (err) + goto out_mdev; + resp.response_length =min (udata->outlen,sizeof (resp)); err =ib_copy_to_udata (udata, &resp, resp.response_length);if (err) goto out_mdev; bfregi->ver = ver; bfregi->num_low_latency_bfregs = req.num_low_latency_bfregs; - context->cqe_version = resp.cqe_version; context->lib_caps = req.lib_caps;print_lib_caps (dev, context->lib_caps);
Signature · 1 line
2.26.2
PATCH 5/7 RDMA/mlx5: Implement the query ucontext functionality
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Implement the query ucontext functionality by returning the original ucontext data as part of an extra mlx5 attribute that holds the driver UAPI response.
--- drivers/infiniband/core/uverbs_ioctl.c | 1 + drivers/infiniband/hw/mlx5/main.c | 35 ++++++++++++++++++++++++ include/uapi/rdma/mlx5_user_ioctl_cmds.h | 4 +++ 3 files changed, 40 insertions(+)
drivers/infiniband/core/uverbs_ioctl.c +1 -0
@@ -790,6 +790,7 @@ int uverbs_copy_to_struct_or_zero(const struct uverbs_attr_bundle *bundle, }return uverbs_copy_to (bundle, idx, from, size); } +EXPORT_SYMBOL (uverbs_copy_to_struct_or_zero);/* Once called an abort will call through to the type's destroy_hw() */ void uverbs_finalize_uobj_create(const struct uverbs_attr_bundle *bundle,
drivers/infiniband/hw/mlx5/main.c +35 -0
@@ -1990,6 +1990,29 @@ static int mlx5_ib_alloc_ucontext(struct ib_ucontext *uctx,return err; } +static int mlx5_ib_query_ucontext (struct ib_ucontext *ibcontext, +struct uverbs_attr_bundle *attrs) +{ +struct mlx5_ib_alloc_ucontext_resp uctx_resp = {}; +int ret; + + ret =set_ucontext_resp (ibcontext, &uctx_resp); +if (ret) +return ret; + + uctx_resp.response_length = +min_t (size_t, +uverbs_attr_get_len (attrs, +MLX5_IB_ATTR_QUERY_CONTEXT_RESP_UCTX ), +sizeof (uctx_resp)); + + ret =uverbs_copy_to_struct_or_zero (attrs, +MLX5_IB_ATTR_QUERY_CONTEXT_RESP_UCTX , + &uctx_resp, +sizeof (uctx_resp)); +return ret; +} +static void mlx5_ib_dealloc_ucontext (struct ib_ucontext *ibcontext) {struct mlx5_ib_ucontext *context =to_mucontext (ibcontext);
@@ -6375,6 +6398,16 @@ ADD_UVERBS_ATTRIBUTES_SIMPLE(UVERBS_ATTR_FLAGS_IN (MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS , enum mlx5_ib_uapi_flow_action_flags)); +ADD_UVERBS_ATTRIBUTES_SIMPLE ( + mlx5_ib_query_context, +UVERBS_OBJECT_DEVICE , +UVERBS_METHOD_QUERY_CONTEXT , +UVERBS_ATTR_PTR_OUT ( +MLX5_IB_ATTR_QUERY_CONTEXT_RESP_UCTX , + UVERBS_ATTR_STRUCT(struct mlx5_ib_alloc_ucontext_resp, + dump_fill_mkey), +UA_MANDATORY )); +static const struct uapi_definition mlx5_ib_defs[] = {UAPI_DEF_CHAIN (mlx5_ib_devx_defs),UAPI_DEF_CHAIN (mlx5_ib_flow_defs),
@@ -6383,6 +6416,7 @@ static const struct uapi_definition mlx5_ib_defs[] = {UAPI_DEF_CHAIN_OBJ_TREE (UVERBS_OBJECT_FLOW_ACTION , &mlx5_ib_flow_action),UAPI_DEF_CHAIN_OBJ_TREE (UVERBS_OBJECT_DM , &mlx5_ib_dm), +UAPI_DEF_CHAIN_OBJ_TREE (UVERBS_OBJECT_DEVICE , &mlx5_ib_query_context),UAPI_DEF_CHAIN_OBJ_TREE_NAMED (MLX5_IB_OBJECT_VAR ,UAPI_DEF_IS_OBJ_SUPPORTED (var_is_supported)), UAPI_DEF_CHAIN_OBJ_TREE_NAMED(MLX5_IB_OBJECT_UAR),
@@ -6616,6 +6650,7 @@ static const struct ib_device_ops mlx5_ib_dev_ops = { .query_pkey = mlx5_ib_query_pkey, .query_qp = mlx5_ib_query_qp, .query_srq = mlx5_ib_query_srq, + .query_ucontext = mlx5_ib_query_ucontext, .read_counters = mlx5_ib_read_counters, .reg_user_mr = mlx5_ib_reg_user_mr, .req_notify_cq = mlx5_ib_arm_cq,
include/uapi/rdma/mlx5_user_ioctl_cmds.h +4 -0
@@ -228,6 +228,10 @@ enum mlx5_ib_flow_matcher_methods { MLX5_IB_METHOD_FLOW_MATCHER_DESTROY, }; +enum mlx5_ib_device_query_context_attrs { +MLX5_IB_ATTR_QUERY_CONTEXT_RESP_UCTX = (1U <<UVERBS_ID_NS_SHIFT ), +}; +#define MLX5_IB_DW_MATCH_PARAM 0x80struct mlx5_ib_match_params {
Signature · 1 line
2.26.2
PATCH 6/7 RDMA/mlx5: Introduce KABI to query PD attributes
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Introduce KABI to query PD attributes, this can be used to retrieve PD attributes by having the PD handle of the created one and owning the command FD for the ucontxet.
--- drivers/infiniband/hw/mlx5/Makefile | 3 +- drivers/infiniband/hw/mlx5/main.c | 1 + drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 ++ drivers/infiniband/hw/mlx5/std_types.c | 45 ++++++++++++++++++++++++ include/uapi/rdma/mlx5_user_ioctl_cmds.h | 10 ++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 drivers/infiniband/hw/mlx5/std_types.c
drivers/infiniband/hw/mlx5/Makefile +2 -1
@@ -23,4 +23,5 @@ mlx5_ib-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += odp.o mlx5_ib-$(CONFIG_MLX5_ESWITCH) += ib_rep.o mlx5_ib-$(CONFIG_INFINIBAND_USER_ACCESS) += devx.o \ flow.o \ - qos.o + qos.o \ + std_types.o
drivers/infiniband/hw/mlx5/main.c +1 -0
@@ -6412,6 +6412,7 @@ static const struct uapi_definition mlx5_ib_defs[] = {UAPI_DEF_CHAIN (mlx5_ib_devx_defs),UAPI_DEF_CHAIN (mlx5_ib_flow_defs),UAPI_DEF_CHAIN (mlx5_ib_qos_defs), +UAPI_DEF_CHAIN (mlx5_ib_std_types_defs),UAPI_DEF_CHAIN_OBJ_TREE (UVERBS_OBJECT_FLOW_ACTION , &mlx5_ib_flow_action),
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
@@ -1384,6 +1384,8 @@ int mlx5_ib_fill_stat_mr_entry(struct sk_buff *msg, struct ib_mr *ib_mr);extern const struct uapi_definition mlx5_ib_devx_defs[];extern const struct uapi_definition mlx5_ib_flow_defs[];extern const struct uapi_definition mlx5_ib_qos_defs[]; +extern const struct uapi_definition mlx5_ib_std_types_defs[]; +#if IS_ENABLED (CONFIG_INFINIBAND_USER_ACCESS )int mlx5_ib_devx_create (struct mlx5_ib_dev *dev,bool is_user);
drivers/infiniband/hw/mlx5/std_types.c new file +45 -0
45 lines not on this page · raw message
include/uapi/rdma/mlx5_user_ioctl_cmds.h +10 -0
@@ -290,4 +290,14 @@ enum mlx5_ib_create_flow_action_create_packet_reformat_attrs { MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_BUF, }; +enum mlx5_ib_query_pd_attrs { +MLX5_IB_ATTR_QUERY_PD_HANDLE = (1U <<UVERBS_ID_NS_SHIFT ), +MLX5_IB_ATTR_QUERY_PD_RESP_PDN , +}; + +enum mlx5_ib_pd_methods { +MLX5_IB_METHOD_PD_QUERY = (1U <<UVERBS_ID_NS_SHIFT ), + +}; +#endif
Signature · 1 line
2.26.2
PATCH 7/7 IB/uverbs: Expose KABI to query MR
In reply to Leon RomanovskyFrom: Yishai Hadas <[email protected]>
Expose KABI to query MR, this will let user space application that didn't allocate the MR but has access to by owning the matching command FD to retrieve its information.
--- drivers/infiniband/core/uverbs_std_types_mr.c | 50 ++++++++++++++++++- include/uapi/rdma/ib_user_ioctl_cmds.h | 9 ++++ 2 files changed, 58 insertions(+), 1 deletion(-)
drivers/infiniband/core/uverbs_std_types_mr.c +49 -1
@@ -148,6 +148,34 @@ static int UVERBS_HANDLER(UVERBS_METHOD_DM_MR_REG)(return ret; } +static int UVERBS_HANDLER (UVERBS_METHOD_QUERY_MR )( +struct uverbs_attr_bundle *attrs) +{ +struct ib_mr *mr = +uverbs_attr_get_obj (attrs,UVERBS_ATTR_QUERY_MR_HANDLE ); +int ret; + + ret =uverbs_copy_to (attrs,UVERBS_ATTR_QUERY_MR_RESP_LKEY , &mr->lkey, +sizeof (mr->lkey)); +if (ret) +return ret; + + ret =uverbs_copy_to (attrs,UVERBS_ATTR_QUERY_MR_RESP_RKEY , + &mr->rkey,sizeof (mr->rkey)); + +if (ret) +return ret; + + ret =uverbs_copy_to (attrs,UVERBS_ATTR_QUERY_MR_RESP_LENGTH , + &mr->length,sizeof (mr->length)); + +if (ret) +return ret; + +return uverbs_copy_to (attrs,UVERBS_ATTR_QUERY_MR_RESP_IOVA , + &mr->iova,sizeof (mr->iova)); +} + DECLARE_UVERBS_NAMED_METHOD( UVERBS_METHOD_ADVISE_MR, UVERBS_ATTR_IDR(UVERBS_ATTR_ADVISE_MR_PD_HANDLE,
@@ -165,6 +193,25 @@ DECLARE_UVERBS_NAMED_METHOD(UA_MANDATORY , UA_ALLOC_AND_COPY)); +DECLARE_UVERBS_NAMED_METHOD ( +UVERBS_METHOD_QUERY_MR , +UVERBS_ATTR_IDR (UVERBS_ATTR_QUERY_MR_HANDLE , +UVERBS_OBJECT_MR , +UVERBS_ACCESS_READ , +UA_MANDATORY ), +UVERBS_ATTR_PTR_OUT (UVERBS_ATTR_QUERY_MR_RESP_RKEY , +UVERBS_ATTR_TYPE (u32), +UA_MANDATORY ), +UVERBS_ATTR_PTR_OUT (UVERBS_ATTR_QUERY_MR_RESP_LKEY , +UVERBS_ATTR_TYPE (u32), +UA_MANDATORY ), +UVERBS_ATTR_PTR_OUT (UVERBS_ATTR_QUERY_MR_RESP_LENGTH , +UVERBS_ATTR_TYPE (u64), +UA_MANDATORY ), +UVERBS_ATTR_PTR_OUT (UVERBS_ATTR_QUERY_MR_RESP_IOVA , +UVERBS_ATTR_TYPE (u64), +UA_MANDATORY )); + DECLARE_UVERBS_NAMED_METHOD( UVERBS_METHOD_DM_MR_REG, UVERBS_ATTR_IDR(UVERBS_ATTR_REG_DM_MR_HANDLE,
@@ -206,7 +253,8 @@ DECLARE_UVERBS_NAMED_OBJECT(UVERBS_TYPE_ALLOC_IDR (uverbs_free_mr), &UVERBS_METHOD(UVERBS_METHOD_DM_MR_REG), &UVERBS_METHOD(UVERBS_METHOD_MR_DESTROY), - &UVERBS_METHOD(UVERBS_METHOD_ADVISE_MR)); + &UVERBS_METHOD(UVERBS_METHOD_ADVISE_MR), + &UVERBS_METHOD(UVERBS_METHOD_QUERY_MR));const struct uapi_definition uverbs_def_obj_mr[] = { UAPI_DEF_CHAIN_OBJ_TREE_NAMED(UVERBS_OBJECT_MR,
include/uapi/rdma/ib_user_ioctl_cmds.h +9 -0
@@ -248,6 +248,7 @@ enum uverbs_methods_mr {UVERBS_METHOD_DM_MR_REG ,UVERBS_METHOD_MR_DESTROY ,UVERBS_METHOD_ADVISE_MR , + UVERBS_METHOD_QUERY_MR, }; enum uverbs_attrs_mr_destroy_ids {
@@ -261,6 +262,14 @@ enum uverbs_attrs_advise_mr_cmd_attr_ids { UVERBS_ATTR_ADVISE_MR_SGE_LIST, }; +enum uverbs_attrs_query_mr_cmd_attr_ids { +UVERBS_ATTR_QUERY_MR_HANDLE , +UVERBS_ATTR_QUERY_MR_RESP_LKEY , +UVERBS_ATTR_QUERY_MR_RESP_RKEY , +UVERBS_ATTR_QUERY_MR_RESP_LENGTH , +UVERBS_ATTR_QUERY_MR_RESP_IOVA , +}; +enum uverbs_attrs_create_counters_cmd_attr_ids {UVERBS_ATTR_CREATE_COUNTERS_HANDLE , };
Signature · 1 line
2.26.2
I think you are talking about UABIs (which in linux we actually call uapis).
Quoted 2 lines · Christoph Hellwig
I think you are talking about UABIs (which in linux we actually call uapis).
Yes, I used Yishai's cover letter as is.
Quoted 1 line
Quoted 5 lines · Leon Romanovsky
Quoted 2 lines · Christoph Hellwig
I think you are talking about UABIs (which in linux we actually call uapis).
Yes, I used Yishai's cover letter as is.
Why can't he just posted his patches himeself? And if you forward it you could actually add value by fixing up obvious issues :)
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Leon Romanovsky
Quoted 2 lines · Christoph Hellwig
I think you are talking about UABIs (which in linux we actually call uapis).
Yes, I used Yishai's cover letter as is.
Why can't he just posted his patches himeself? And if you forward it you could actually add value by fixing up obvious issues :)
To say that I'm not adding any value, you need to see patches before they arrive to me and after they sent to the mailing list.
Thanks
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Leon Romanovsky
Quoted 2 lines · Christoph Hellwig
I think you are talking about UABIs (which in linux we actually call uapis).
Yes, I used Yishai's cover letter as is.
We used in the past the "kABI" notation in the rdma sub system when we referred to the ioctl interface that kernel exposes to user space.
See the below [1] from Jason and the below [2] mentioned by Linus as of Doug's pull request.
However,
We may better refers to UAPI to make things clearer.
[1] https://patchwork.kernel.org/patch/10226945/
[2] commit 004e390d8133b96485e1ab9af5351c2db4300c63
Merge: 24180a6008ac f45765872e7a
Author: Linus Torvalds <[email protected]>
Date: Thu Feb 22 11:57:39 2018 -0800
Merge tag 'for-linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Doug Ledford:
"Nothing in this is overly interesting, it's mostly your garden
variety
fixes.
There was some work in this merge cycle around the new ioctl kABI, so there are fixes in here related to that (probably with more to come).
Yishai
Quoted 11 lines · Yishai Hadas
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · Leon Romanovsky
Quoted 2 lines · Christoph Hellwig
I think you are talking about UABIs (which in linux we actually call uapis).
Yes, I used Yishai's cover letter as is.
We used in the past the "kABI" notation in the rdma sub system when we referred to the ioctl interface that kernel exposes to user space.
It is true, somewhere along the way it got to be called the "ioctl kabi" which is confusing and wrong, we should move away from that language.
Jason