Add core infrastructure for Completion Counters, a light-weight alternative to polling CQ for tracking operation completions. Define the UVERBS_OBJECT_COMP_CNTR ioctl object with create, destroy, modify and read methods for both success and error counters. Add a QP attach method on the QP object to associate a completion counter with a queue pair. Add ib_comp_cntr struct, ib_comp_cntr_attach_attr, device ops, and DECLARE_RDMA_OBJ_SIZE for driver object allocation. Only userspace Completion Counters are supported at this stage.
Unified · Split
| @@ -38,6 +38,7 @@ ib_umad-y := user_mad.o · 37 unmodified lines | ||
| 38 | 38 | ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \ |
| 39 | 39 | uverbs_std_types.o uverbs_ioctl.o \ |
| 40 | 40 | uverbs_std_types_cq.o \ |
| 41 | + uverbs_std_types_comp_cntr.o \ | |
| 41 | 42 | uverbs_std_types_dmabuf.o \ |
| 42 | 43 | uverbs_std_types_dmah.o \ |
| 43 | 44 | uverbs_std_types_flow_action.o uverbs_std_types_dm.o \ |
| @@ -2742,6 +2742,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) · 2741 unmodified lines | ||
| 2742 | 2742 | SET_DEVICE_OP(dev_ops, create_ah); |
| 2743 | 2743 | SET_DEVICE_OP(dev_ops, create_counters); |
| 2744 | 2744 | SET_DEVICE_OP(dev_ops, create_cq); |
| 2745 | + SET_DEVICE_OP(dev_ops, create_comp_cntr); | |
| 2745 | 2746 | SET_DEVICE_OP(dev_ops, create_user_cq); |
| 2746 | 2747 | SET_DEVICE_OP(dev_ops, create_flow); |
| 2747 | 2748 | SET_DEVICE_OP(dev_ops, create_qp); |
| @@ -2762,6 +2763,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) · 14 unmodified lines | ||
| 2762 | 2763 | SET_DEVICE_OP(dev_ops, destroy_ah); |
| 2763 | 2764 | SET_DEVICE_OP(dev_ops, destroy_counters); |
| 2764 | 2765 | SET_DEVICE_OP(dev_ops, destroy_cq); |
| 2766 | + SET_DEVICE_OP(dev_ops, destroy_comp_cntr); | |
| 2765 | 2767 | SET_DEVICE_OP(dev_ops, destroy_flow); |
| 2766 | 2768 | SET_DEVICE_OP(dev_ops, destroy_flow_action); |
| 2767 | 2769 | SET_DEVICE_OP(dev_ops, destroy_qp); |
| @@ -2813,6 +2815,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) · 45 unmodified lines | ||
| 2813 | 2815 | SET_DEVICE_OP(dev_ops, modify_hw_stat); |
| 2814 | 2816 | SET_DEVICE_OP(dev_ops, modify_port); |
| 2815 | 2817 | SET_DEVICE_OP(dev_ops, modify_qp); |
| 2818 | + SET_DEVICE_OP(dev_ops, qp_attach_comp_cntr); | |
| 2816 | 2819 | SET_DEVICE_OP(dev_ops, modify_srq); |
| 2817 | 2820 | SET_DEVICE_OP(dev_ops, modify_wq); |
| 2818 | 2821 | SET_DEVICE_OP(dev_ops, peek_cq); |
| @@ -2836,12 +2839,14 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) · 17 unmodified lines | ||
| 2836 | 2839 | SET_DEVICE_OP(dev_ops, query_ucontext); |
| 2837 | 2840 | SET_DEVICE_OP(dev_ops, rdma_netdev_get_params); |
| 2838 | 2841 | SET_DEVICE_OP(dev_ops, read_counters); |
| 2842 | + SET_DEVICE_OP(dev_ops, read_comp_cntr); | |
| 2839 | 2843 | SET_DEVICE_OP(dev_ops, reg_dm_mr); |
| 2840 | 2844 | SET_DEVICE_OP(dev_ops, reg_user_mr); |
| 2841 | 2845 | SET_DEVICE_OP(dev_ops, reg_user_mr_dmabuf); |
| 2842 | 2846 | SET_DEVICE_OP(dev_ops, req_notify_cq); |
| 2843 | 2847 | SET_DEVICE_OP(dev_ops, rereg_user_mr); |
| 2844 | 2848 | SET_DEVICE_OP(dev_ops, resize_user_cq); |
| 2849 | + SET_DEVICE_OP(dev_ops, modify_comp_cntr); | |
| 2845 | 2850 | SET_DEVICE_OP(dev_ops, set_vf_guid); |
| 2846 | 2851 | SET_DEVICE_OP(dev_ops, set_vf_link_state); |
| 2847 | 2852 | SET_DEVICE_OP(dev_ops, ufile_hw_cleanup); |
| @@ -2850,6 +2855,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) · 2 unmodified lines | ||
| 2850 | 2855 | SET_OBJ_SIZE(dev_ops, ib_ah); |
| 2851 | 2856 | SET_OBJ_SIZE(dev_ops, ib_counters); |
| 2852 | 2857 | SET_OBJ_SIZE(dev_ops, ib_cq); |
| 2858 | + SET_OBJ_SIZE(dev_ops, ib_comp_cntr); | |
| 2853 | 2859 | SET_OBJ_SIZE(dev_ops, ib_dmah); |
| 2854 | 2860 | SET_OBJ_SIZE(dev_ops, ib_mw); |
| 2855 | 2861 | SET_OBJ_SIZE(dev_ops, ib_pd); |
| @@ -159,6 +159,7 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile); · 158 unmodified lines | ||
| 159 | 159 | |
| 160 | 160 | extern const struct uapi_definition uverbs_def_obj_async_fd[]; |
| 161 | 161 | extern const struct uapi_definition uverbs_def_obj_counters[]; |
| 162 | +extern const struct uapi_definition uverbs_def_obj_comp_cntr[]; | |
| 162 | 163 | extern const struct uapi_definition uverbs_def_obj_cq[]; |
| 163 | 164 | extern const struct uapi_definition uverbs_def_obj_device[]; |
| 164 | 165 | extern const struct uapi_definition uverbs_def_obj_dm[]; |
| @@ -0,0 +1,159 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | |
| 2 | +/* | |
| 3 | + * Copyright Amazon.com, Inc. or its affiliates. All rights reserved. | |
| 4 | + */ | |
| 5 | + | |
| 6 | +#include <rdma/uverbs_std_types.h> | |
| 7 | +#include "rdma_core.h" | |
| 8 | +#include "uverbs.h" | |
| 9 | + | |
| 10 | +static int uverbs_free_comp_cntr(struct ib_uobject *uobject, enum rdma_remove_reason why, | |
| 11 | + struct uverbs_attr_bundle *attrs) | |
| 12 | +{ | |
| 13 | + struct ib_comp_cntr *cc = uobject->object; | |
| 14 | + int ret; | |
| 15 | + | |
| 16 | + ret = cc->device->ops.destroy_comp_cntr(cc); | |
| 17 | + if (ret) | |
| 18 | + return ret; | |
| 19 | + | |
| 20 | + kfree(cc); | |
| 21 | + return 0; | |
| 22 | +} | |
| 23 | + | |
| 24 | +static int UVERBS_HANDLER(UVERBS_METHOD_COMP_CNTR_CREATE)(struct uverbs_attr_bundle *attrs) | |
| 25 | +{ | |
| 26 | + struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs, | |
| 27 | + UVERBS_ATTR_CREATE_COMP_CNTR_HANDLE); | |
| 28 | + struct ib_device *ib_dev = attrs->context->device; | |
| 29 | + struct ib_comp_cntr *cc; | |
| 30 | + int ret; | |
| 31 | + | |
| 32 | + if (!ib_dev->ops.create_comp_cntr || | |
| 33 | + !ib_dev->ops.destroy_comp_cntr || | |
| 34 | + !ib_dev->ops.qp_attach_comp_cntr) | |
| 35 | + return -EOPNOTSUPP; | |
| 36 | + | |
| 37 | + cc = rdma_zalloc_drv_obj(ib_dev, ib_comp_cntr); | |
| 38 | + if (!cc) | |
| 39 | + return -ENOMEM; | |
| 40 | + | |
| 41 | + cc->device = ib_dev; | |
| 42 | + cc->uobject = uobj; | |
| 43 | + | |
| 44 | + ret = ib_dev->ops.create_comp_cntr(cc, attrs); | |
| 45 | + if (ret) | |
| 46 | + goto err_free; | |
| 47 | + | |
| 48 | + uobj->object = cc; | |
| 49 | + uverbs_finalize_uobj_create(attrs, UVERBS_ATTR_CREATE_COMP_CNTR_HANDLE); | |
| 50 | + return 0; | |
| 51 | + | |
| 52 | +err_free: | |
| 53 | + kfree(cc); | |
| 54 | + return ret; | |
| 55 | +} | |
| 56 | + | |
| 57 | +static int UVERBS_HANDLER(UVERBS_METHOD_COMP_CNTR_MODIFY)(struct uverbs_attr_bundle *attrs) | |
| 58 | +{ | |
| 59 | + struct ib_comp_cntr *cc = uverbs_attr_get_obj(attrs, UVERBS_ATTR_MODIFY_COMP_CNTR_HANDLE); | |
| 60 | + enum ib_comp_cntr_modify_op op; | |
| 61 | + enum ib_comp_cntr_entry entry; | |
| 62 | + u64 value; | |
| 63 | + int ret; | |
| 64 | + | |
| 65 | + if (!cc->device->ops.modify_comp_cntr) | |
| 66 | + return -EOPNOTSUPP; | |
| 67 | + | |
| 68 | + ret = uverbs_get_const(&entry, attrs, UVERBS_ATTR_MODIFY_COMP_CNTR_ENTRY); | |
| 69 | + if (ret) | |
| 70 | + return ret; | |
| 71 | + | |
| 72 | + ret = uverbs_get_const(&op, attrs, UVERBS_ATTR_MODIFY_COMP_CNTR_OP); | |
| 73 | + if (ret) | |
| 74 | + return ret; | |
| 75 | + | |
| 76 | + ret = uverbs_copy_from(&value, attrs, UVERBS_ATTR_MODIFY_COMP_CNTR_VALUE); | |
| 77 | + if (ret) | |
| 78 | + return ret; | |
| 79 | + | |
| 80 | + return cc->device->ops.modify_comp_cntr(cc, entry, op, value); | |
| 81 | +} | |
| 82 | + | |
| 83 | +static int UVERBS_HANDLER(UVERBS_METHOD_COMP_CNTR_READ)(struct uverbs_attr_bundle *attrs) | |
| 84 | +{ | |
| 85 | + struct ib_comp_cntr *cc = uverbs_attr_get_obj(attrs, UVERBS_ATTR_READ_COMP_CNTR_HANDLE); | |
| 86 | + enum ib_comp_cntr_entry entry; | |
| 87 | + u64 value = 0; | |
| 88 | + int ret; | |
| 89 | + | |
| 90 | + if (!cc->device->ops.read_comp_cntr) | |
| 91 | + return -EOPNOTSUPP; | |
| 92 | + | |
| 93 | + ret = uverbs_get_const(&entry, attrs, UVERBS_ATTR_READ_COMP_CNTR_ENTRY); | |
| 94 | + if (ret) | |
| 95 | + return ret; | |
| 96 | + | |
| 97 | + ret = cc->device->ops.read_comp_cntr(cc, entry, &value); | |
| 98 | + if (ret) | |
| 99 | + return ret; | |
| 100 | + | |
| 101 | + return uverbs_copy_to(attrs, UVERBS_ATTR_READ_COMP_CNTR_RESP_VALUE, &value, sizeof(value)); | |
| 102 | +} | |
| 103 | + | |
| 104 | +DECLARE_UVERBS_NAMED_METHOD( | |
| 105 | + UVERBS_METHOD_COMP_CNTR_CREATE, | |
| 106 | + UVERBS_ATTR_IDR(UVERBS_ATTR_CREATE_COMP_CNTR_HANDLE, | |
| 107 | + UVERBS_OBJECT_COMP_CNTR, | |
| 108 | + UVERBS_ACCESS_NEW, | |
| 109 | + UA_MANDATORY)); | |
| 110 | + | |
| 111 | +DECLARE_UVERBS_NAMED_METHOD_DESTROY( | |
| 112 | + UVERBS_METHOD_COMP_CNTR_DESTROY, | |
| 113 | + UVERBS_ATTR_IDR(UVERBS_ATTR_DESTROY_COMP_CNTR_HANDLE, | |
| 114 | + UVERBS_OBJECT_COMP_CNTR, | |
| 115 | + UVERBS_ACCESS_DESTROY, | |
| 116 | + UA_MANDATORY)); | |
| 117 | + | |
| 118 | +DECLARE_UVERBS_NAMED_METHOD( | |
| 119 | + UVERBS_METHOD_COMP_CNTR_MODIFY, | |
| 120 | + UVERBS_ATTR_IDR(UVERBS_ATTR_MODIFY_COMP_CNTR_HANDLE, | |
| 121 | + UVERBS_OBJECT_COMP_CNTR, | |
| 122 | + UVERBS_ACCESS_WRITE, | |
| 123 | + UA_MANDATORY), | |
| 124 | + UVERBS_ATTR_CONST_IN(UVERBS_ATTR_MODIFY_COMP_CNTR_ENTRY, | |
| 125 | + enum ib_uverbs_comp_cntr_entry, | |
| 126 | + UA_MANDATORY), | |
| 127 | + UVERBS_ATTR_CONST_IN(UVERBS_ATTR_MODIFY_COMP_CNTR_OP, | |
| 128 | + enum ib_uverbs_comp_cntr_modify_op, | |
| 129 | + UA_MANDATORY), | |
| 130 | + UVERBS_ATTR_PTR_IN(UVERBS_ATTR_MODIFY_COMP_CNTR_VALUE, | |
| 131 | + UVERBS_ATTR_TYPE(u64), | |
| 132 | + UA_MANDATORY)); | |
| 133 | + | |
| 134 | +DECLARE_UVERBS_NAMED_METHOD( | |
| 135 | + UVERBS_METHOD_COMP_CNTR_READ, | |
| 136 | + UVERBS_ATTR_IDR(UVERBS_ATTR_READ_COMP_CNTR_HANDLE, | |
| 137 | + UVERBS_OBJECT_COMP_CNTR, | |
| 138 | + UVERBS_ACCESS_READ, | |
| 139 | + UA_MANDATORY), | |
| 140 | + UVERBS_ATTR_CONST_IN(UVERBS_ATTR_READ_COMP_CNTR_ENTRY, | |
| 141 | + enum ib_uverbs_comp_cntr_entry, | |
| 142 | + UA_MANDATORY), | |
| 143 | + UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_READ_COMP_CNTR_RESP_VALUE, | |
| 144 | + UVERBS_ATTR_TYPE(u64), | |
| 145 | + UA_MANDATORY)); | |
| 146 | + | |
| 147 | +DECLARE_UVERBS_NAMED_OBJECT( | |
| 148 | + UVERBS_OBJECT_COMP_CNTR, | |
| 149 | + UVERBS_TYPE_ALLOC_IDR(uverbs_free_comp_cntr), | |
| 150 | + &UVERBS_METHOD(UVERBS_METHOD_COMP_CNTR_CREATE), | |
| 151 | + &UVERBS_METHOD(UVERBS_METHOD_COMP_CNTR_DESTROY), | |
| 152 | + &UVERBS_METHOD(UVERBS_METHOD_COMP_CNTR_MODIFY), | |
| 153 | + &UVERBS_METHOD(UVERBS_METHOD_COMP_CNTR_READ)); | |
| 154 | + | |
| 155 | +const struct uapi_definition uverbs_def_obj_comp_cntr[] = { | |
| 156 | + UAPI_DEF_CHAIN_OBJ_TREE_NAMED(UVERBS_OBJECT_COMP_CNTR, | |
| 157 | + UAPI_DEF_OBJ_NEEDS_FN(destroy_comp_cntr)), | |
| 158 | + {} | |
| 159 | +}; | |
| @@ -372,11 +372,60 @@ DECLARE_UVERBS_NAMED_METHOD( · 371 unmodified lines | ||
| 372 | 372 | UVERBS_ATTR_TYPE(struct ib_uverbs_destroy_qp_resp), |
| 373 | 373 | UA_MANDATORY)); |
| 374 | 374 | |
| 375 | +static int UVERBS_HANDLER(UVERBS_METHOD_QP_ATTACH_COMP_CNTR)( | |
| 376 | + struct uverbs_attr_bundle *attrs) | |
| 377 | +{ | |
| 378 | + struct ib_uobject *qp_uobj = uverbs_attr_get_uobject( | |
| 379 | + attrs, UVERBS_ATTR_QP_ATTACH_COMP_CNTR_HANDLE); | |
| 380 | + struct ib_comp_cntr *cc = uverbs_attr_get_obj( | |
| 381 | + attrs, UVERBS_ATTR_QP_ATTACH_COMP_CNTR_CNTR_HANDLE); | |
| 382 | + struct ib_qp_attach_comp_cntr_attr attr = {}; | |
| 383 | + struct ib_qp *qp = qp_uobj->object; | |
| 384 | + int ret; | |
| 385 | + | |
| 386 | + if (!cc->device->ops.qp_attach_comp_cntr) | |
| 387 | + return -EOPNOTSUPP; | |
| 388 | + | |
| 389 | + if (qp->real_qp != qp) | |
| 390 | + return -EINVAL; | |
| 391 | + | |
| 392 | + ret = uverbs_get_flags32(&attr.op_mask, attrs, | |
| 393 | + UVERBS_ATTR_QP_ATTACH_COMP_CNTR_OP_MASK, | |
| 394 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_SEND | | |
| 395 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RECV | | |
| 396 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RDMA_READ | | |
| 397 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_READ | | |
| 398 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RDMA_WRITE | | |
| 399 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_WRITE); | |
| 400 | + if (ret) | |
| 401 | + return ret; | |
| 402 | + | |
| 403 | + if (!attr.op_mask) | |
| 404 | + return -EINVAL; | |
| 405 | + | |
| 406 | + return qp->device->ops.qp_attach_comp_cntr(qp, cc, &attr); | |
| 407 | +} | |
| 408 | + | |
| 409 | +DECLARE_UVERBS_NAMED_METHOD( | |
| 410 | + UVERBS_METHOD_QP_ATTACH_COMP_CNTR, | |
| 411 | + UVERBS_ATTR_IDR(UVERBS_ATTR_QP_ATTACH_COMP_CNTR_HANDLE, | |
| 412 | + UVERBS_OBJECT_QP, | |
| 413 | + UVERBS_ACCESS_WRITE, | |
| 414 | + UA_MANDATORY), | |
| 415 | + UVERBS_ATTR_IDR(UVERBS_ATTR_QP_ATTACH_COMP_CNTR_CNTR_HANDLE, | |
| 416 | + UVERBS_OBJECT_COMP_CNTR, | |
| 417 | + UVERBS_ACCESS_READ, | |
| 418 | + UA_MANDATORY), | |
| 419 | + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_QP_ATTACH_COMP_CNTR_OP_MASK, | |
| 420 | + enum ib_uverbs_qp_attach_comp_cntr_op, | |
| 421 | + UA_MANDATORY)); | |
| 422 | + | |
| 375 | 423 | DECLARE_UVERBS_NAMED_OBJECT( |
| 376 | 424 | UVERBS_OBJECT_QP, |
| 377 | 425 | UVERBS_TYPE_ALLOC_IDR_SZ(sizeof(struct ib_uqp_object), uverbs_free_qp), |
| 378 | 426 | &UVERBS_METHOD(UVERBS_METHOD_QP_CREATE), |
| 379 | − &UVERBS_METHOD(UVERBS_METHOD_QP_DESTROY)); | |
| 427 | + &UVERBS_METHOD(UVERBS_METHOD_QP_DESTROY), | |
| 428 | + &UVERBS_METHOD(UVERBS_METHOD_QP_ATTACH_COMP_CNTR)); | |
| 380 | 429 | |
| 381 | 430 | const struct uapi_definition uverbs_def_obj_qp[] = { |
| 382 | 431 | UAPI_DEF_CHAIN_OBJ_TREE_NAMED(UVERBS_OBJECT_QP, |
| @@ -628,6 +628,7 @@ void uverbs_destroy_api(struct uverbs_api *uapi) · 627 unmodified lines | ||
| 628 | 628 | static const struct uapi_definition uverbs_core_api[] = { |
| 629 | 629 | UAPI_DEF_CHAIN(uverbs_def_obj_async_fd), |
| 630 | 630 | UAPI_DEF_CHAIN(uverbs_def_obj_counters), |
| 631 | + UAPI_DEF_CHAIN(uverbs_def_obj_comp_cntr), | |
| 631 | 632 | UAPI_DEF_CHAIN(uverbs_def_obj_cq), |
| 632 | 633 | UAPI_DEF_CHAIN(uverbs_def_obj_device), |
| 633 | 634 | UAPI_DEF_CHAIN(uverbs_def_obj_dm), |
| @@ -1746,6 +1746,34 @@ struct ib_cq { · 1745 unmodified lines | ||
| 1746 | 1746 | struct rdma_restrack_entry res; |
| 1747 | 1747 | }; |
| 1748 | 1748 | |
| 1749 | +enum ib_qp_attach_comp_cntr_op { | |
| 1750 | + IB_QP_ATTACH_COMP_CNTR_OP_SEND = IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_SEND, | |
| 1751 | + IB_QP_ATTACH_COMP_CNTR_OP_RECV = IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RECV, | |
| 1752 | + IB_QP_ATTACH_COMP_CNTR_OP_RDMA_READ = IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RDMA_READ, | |
| 1753 | + IB_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_READ = IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_READ, | |
| 1754 | + IB_QP_ATTACH_COMP_CNTR_OP_RDMA_WRITE = IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RDMA_WRITE, | |
| 1755 | + IB_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_WRITE = IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_WRITE, | |
| 1756 | +}; | |
| 1757 | + | |
| 1758 | +struct ib_comp_cntr { | |
| 1759 | + struct ib_device *device; | |
| 1760 | + struct ib_uobject *uobject; | |
| 1761 | +}; | |
| 1762 | + | |
| 1763 | +enum ib_comp_cntr_entry { | |
| 1764 | + IB_COMP_CNTR_ENTRY_COMP = IB_UVERBS_COMP_CNTR_ENTRY_COMP, | |
| 1765 | + IB_COMP_CNTR_ENTRY_ERR = IB_UVERBS_COMP_CNTR_ENTRY_ERR, | |
| 1766 | +}; | |
| 1767 | + | |
| 1768 | +enum ib_comp_cntr_modify_op { | |
| 1769 | + IB_COMP_CNTR_MODIFY_OP_SET = IB_UVERBS_COMP_CNTR_MODIFY_OP_SET, | |
| 1770 | + IB_COMP_CNTR_MODIFY_OP_INC = IB_UVERBS_COMP_CNTR_MODIFY_OP_INC, | |
| 1771 | +}; | |
| 1772 | + | |
| 1773 | +struct ib_qp_attach_comp_cntr_attr { | |
| 1774 | + u32 op_mask; /* Bitmask of enum ib_qp_attach_comp_cntr_op */ | |
| 1775 | +}; | |
| 1776 | + | |
| 1749 | 1777 | struct ib_srq { |
| 1750 | 1778 | struct ib_device *device; |
| 1751 | 1779 | struct ib_pd *pd; |
| @@ -2629,6 +2657,8 @@ struct ib_device_ops { · 877 unmodified lines | ||
| 2629 | 2657 | struct ib_udata *udata); |
| 2630 | 2658 | int (*modify_qp)(struct ib_qp *qp, struct ib_qp_attr *qp_attr, |
| 2631 | 2659 | int qp_attr_mask, struct ib_udata *udata); |
| 2660 | + int (*qp_attach_comp_cntr)(struct ib_qp *qp, struct ib_comp_cntr *cc, | |
| 2661 | + struct ib_qp_attach_comp_cntr_attr *attr); | |
| 2632 | 2662 | int (*query_qp)(struct ib_qp *qp, struct ib_qp_attr *qp_attr, |
| 2633 | 2663 | int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr); |
| 2634 | 2664 | int (*destroy_qp)(struct ib_qp *qp, struct ib_udata *udata); |
| @@ -2650,6 +2680,12 @@ struct ib_device_ops { · 15 unmodified lines | ||
| 2650 | 2680 | * post_destroy_cq - Free all kernel resources |
| 2651 | 2681 | */ |
| 2652 | 2682 | void (*post_destroy_cq)(struct ib_cq *cq); |
| 2683 | + int (*create_comp_cntr)(struct ib_comp_cntr *cc, | |
| 2684 | + struct uverbs_attr_bundle *attrs); | |
| 2685 | + int (*destroy_comp_cntr)(struct ib_comp_cntr *cc); | |
| 2686 | + int (*modify_comp_cntr)(struct ib_comp_cntr *cc, enum ib_comp_cntr_entry entry, | |
| 2687 | + enum ib_comp_cntr_modify_op op, u64 value); | |
| 2688 | + int (*read_comp_cntr)(struct ib_comp_cntr *cc, enum ib_comp_cntr_entry entry, u64 *value); | |
| 2653 | 2689 | struct ib_mr *(*get_dma_mr)(struct ib_pd *pd, int mr_access_flags); |
| 2654 | 2690 | struct ib_mr *(*reg_user_mr)(struct ib_pd *pd, u64 start, u64 length, |
| 2655 | 2691 | u64 virt_addr, int mr_access_flags, |
| @@ -2883,6 +2919,7 @@ struct ib_device_ops { · 227 unmodified lines | ||
| 2883 | 2919 | DECLARE_RDMA_OBJ_SIZE(ib_ah); |
| 2884 | 2920 | DECLARE_RDMA_OBJ_SIZE(ib_counters); |
| 2885 | 2921 | DECLARE_RDMA_OBJ_SIZE(ib_cq); |
| 2922 | + DECLARE_RDMA_OBJ_SIZE(ib_comp_cntr); | |
| 2886 | 2923 | DECLARE_RDMA_OBJ_SIZE(ib_dmah); |
| 2887 | 2924 | DECLARE_RDMA_OBJ_SIZE(ib_mw); |
| 2888 | 2925 | DECLARE_RDMA_OBJ_SIZE(ib_pd); |
| @@ -57,6 +57,7 @@ enum uverbs_default_objects { · 56 unmodified lines | ||
| 57 | 57 | UVERBS_OBJECT_ASYNC_EVENT, |
| 58 | 58 | UVERBS_OBJECT_DMAH, |
| 59 | 59 | UVERBS_OBJECT_DMABUF, |
| 60 | + UVERBS_OBJECT_COMP_CNTR, | |
| 60 | 61 | }; |
| 61 | 62 | |
| 62 | 63 | enum { |
| @@ -169,9 +170,16 @@ enum uverbs_attrs_destroy_qp_cmd_attr_ids { · 106 unmodified lines | ||
| 169 | 170 | UVERBS_ATTR_DESTROY_QP_RESP, |
| 170 | 171 | }; |
| 171 | 172 | |
| 173 | +enum uverbs_attrs_qp_attach_comp_cntr_cmd_attr_ids { | |
| 174 | + UVERBS_ATTR_QP_ATTACH_COMP_CNTR_HANDLE, | |
| 175 | + UVERBS_ATTR_QP_ATTACH_COMP_CNTR_CNTR_HANDLE, | |
| 176 | + UVERBS_ATTR_QP_ATTACH_COMP_CNTR_OP_MASK, | |
| 177 | +}; | |
| 178 | + | |
| 172 | 179 | enum uverbs_methods_qp { |
| 173 | 180 | UVERBS_METHOD_QP_CREATE, |
| 174 | 181 | UVERBS_METHOD_QP_DESTROY, |
| 182 | + UVERBS_METHOD_QP_ATTACH_COMP_CNTR, | |
| 175 | 183 | }; |
| 176 | 184 | |
| 177 | 185 | enum uverbs_attrs_create_srq_cmd_attr_ids { |
| @@ -438,4 +446,32 @@ enum uverbs_attrs_query_gid_entry_cmd_attr_ids { · 260 unmodified lines | ||
| 438 | 446 | UVERBS_ATTR_QUERY_GID_ENTRY_RESP_ENTRY, |
| 439 | 447 | }; |
| 440 | 448 | |
| 449 | +enum uverbs_methods_comp_cntr { | |
| 450 | + UVERBS_METHOD_COMP_CNTR_CREATE, | |
| 451 | + UVERBS_METHOD_COMP_CNTR_DESTROY, | |
| 452 | + UVERBS_METHOD_COMP_CNTR_MODIFY, | |
| 453 | + UVERBS_METHOD_COMP_CNTR_READ, | |
| 454 | +}; | |
| 455 | + | |
| 456 | +enum uverbs_attrs_create_comp_cntr_cmd_attr_ids { | |
| 457 | + UVERBS_ATTR_CREATE_COMP_CNTR_HANDLE, | |
| 458 | +}; | |
| 459 | + | |
| 460 | +enum uverbs_attrs_destroy_comp_cntr_cmd_attr_ids { | |
| 461 | + UVERBS_ATTR_DESTROY_COMP_CNTR_HANDLE, | |
| 462 | +}; | |
| 463 | + | |
| 464 | +enum uverbs_attrs_modify_comp_cntr_cmd_attr_ids { | |
| 465 | + UVERBS_ATTR_MODIFY_COMP_CNTR_HANDLE, | |
| 466 | + UVERBS_ATTR_MODIFY_COMP_CNTR_ENTRY, | |
| 467 | + UVERBS_ATTR_MODIFY_COMP_CNTR_OP, | |
| 468 | + UVERBS_ATTR_MODIFY_COMP_CNTR_VALUE, | |
| 469 | +}; | |
| 470 | + | |
| 471 | +enum uverbs_attrs_read_comp_cntr_cmd_attr_ids { | |
| 472 | + UVERBS_ATTR_READ_COMP_CNTR_HANDLE, | |
| 473 | + UVERBS_ATTR_READ_COMP_CNTR_ENTRY, | |
| 474 | + UVERBS_ATTR_READ_COMP_CNTR_RESP_VALUE, | |
| 475 | +}; | |
| 476 | + | |
| 441 | 477 | #endif |
| @@ -300,4 +300,23 @@ struct ib_uverbs_buffer_desc { · 299 unmodified lines | ||
| 300 | 300 | __aligned_u64 length; |
| 301 | 301 | }; |
| 302 | 302 | |
| 303 | +enum ib_uverbs_comp_cntr_entry { | |
| 304 | + IB_UVERBS_COMP_CNTR_ENTRY_COMP, | |
| 305 | + IB_UVERBS_COMP_CNTR_ENTRY_ERR, | |
| 306 | +}; | |
| 307 | + | |
| 308 | +enum ib_uverbs_comp_cntr_modify_op { | |
| 309 | + IB_UVERBS_COMP_CNTR_MODIFY_OP_SET, | |
| 310 | + IB_UVERBS_COMP_CNTR_MODIFY_OP_INC, | |
| 311 | +}; | |
| 312 | + | |
| 313 | +enum ib_uverbs_qp_attach_comp_cntr_op { | |
| 314 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_SEND = 1 << 0, | |
| 315 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RECV = 1 << 1, | |
| 316 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RDMA_READ = 1 << 2, | |
| 317 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_READ = 1 << 3, | |
| 318 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_RDMA_WRITE = 1 << 4, | |
| 319 | + IB_UVERBS_QP_ATTACH_COMP_CNTR_OP_REMOTE_RDMA_WRITE = 1 << 5, | |
| 320 | +}; | |
| 321 | + | |
| 303 | 322 | #endif |