RDMA/efa: Add Completion Counters support
Subsystems (2)
Michael Margolin
maintainerPATCH v6 5/5 RDMA/efa: Add Completion Counters support
Implement completion counters for the EFA device. Each completion counter is backed by two EFA event counters, one for success completions and one for error completions.
The driver creates umem for counters from private descriptor ioctl attributes using core utility.
Read operations are not implemented as the counter values are accessed directly from userspace through the mapped memory.
Reviewed-by Yonatan Nachum <[email protected]>
Signed-off-by Michael Margolin <[email protected]>
--- drivers/infiniband/hw/efa/efa.h | 17 +- drivers/infiniband/hw/efa/efa_com_cmd.c | 110 +++++++++++++ drivers/infiniband/hw/efa/efa_com_cmd.h | 36 +++++ drivers/infiniband/hw/efa/efa_main.c | 7 +- drivers/infiniband/hw/efa/efa_verbs.c | 199 ++++++++++++++++++++++++ include/uapi/rdma/efa-abi.h | 6 + 6 files changed, 373 insertions(+), 2 deletions(-)
drivers/infiniband/hw/efa/efa.h +16 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ /* -* Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All rights reserved. +* Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All rights reserved. */ #ifndef _EFA_H_
@@ -110,6 +110,14 @@ struct efa_cq {struct ib_umem *umem; }; +struct efa_comp_cntr { +struct ib_comp_cntr ibcc; +struct ib_umem *comp_umem; +struct ib_umem *err_umem; +u32 comp_handle; +u32 err_handle; +}; +struct efa_qp {struct ib_qp ibqp;dma_addr_t rq_dma_addr;
@@ -163,6 +171,13 @@ int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,int efa_destroy_cq (struct ib_cq *ibcq,struct ib_udata *udata);int efa_create_user_cq (struct ib_cq *ibcq,const struct ib_cq_init_attr *attr,struct uverbs_attr_bundle *attrs); +int efa_create_comp_cntr (struct ib_comp_cntr *ibcc, +struct uverbs_attr_bundle *attrs); +int efa_destroy_comp_cntr (struct ib_comp_cntr *ibcc); +int efa_modify_comp_cntr (struct ib_comp_cntr *ibcc,enum ib_comp_cntr_entry entry, +enum ib_comp_cntr_modify_op op,u64 value); +int efa_qp_attach_comp_cntr (struct ib_qp *ibqp,struct ib_comp_cntr *ibcc, +struct ib_qp_attach_comp_cntr_attr *attr); struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length, u64 virt_addr, int access_flags, struct ib_dmah *dmah,
drivers/infiniband/hw/efa/efa_com_cmd.c +110 -0
119 lines not on this page · raw message
drivers/infiniband/hw/efa/efa_com_cmd.h +36 -0
@@ -145,6 +145,8 @@ struct efa_com_get_device_attr_result {u16 min_sq_depth;u16 max_link_speed_gbps;u8 db_bar; +u32 max_event_counters; +u64 event_counter_max_val; };struct efa_com_get_hw_hints_result {
@@ -300,6 +302,31 @@ union efa_com_get_stats_result {struct efa_com_network_stats network_stats; }; +struct efa_com_create_event_counter_params { +dma_addr_t dma_addr; +u16 uarn; +}; + +struct efa_com_create_event_counter_result { +u32 cntr_handle; +}; + +struct efa_com_destroy_event_counter_params { +u32 cntr_handle; +}; + +struct efa_com_attach_event_counter_params { +u32 cntr_handle; +u32 qp_handle; +u32 events; +}; + +struct efa_com_modify_event_counter_params { +u32 cntr_handle; +u8 operation; +u64 value; +}; +int efa_com_create_qp (struct efa_com_dev *edev,struct efa_com_create_qp_params *params,struct efa_com_create_qp_result *res);
@@ -350,5 +377,14 @@ int efa_com_dealloc_uar(struct efa_com_dev *edev,int efa_com_get_stats (struct efa_com_dev *edev,struct efa_com_get_stats_params *params,union efa_com_get_stats_result *result); +int efa_com_create_event_counter (struct efa_com_dev *edev, +struct efa_com_create_event_counter_params *params, +struct efa_com_create_event_counter_result *result); +int efa_com_destroy_event_counter (struct efa_com_dev *edev, +struct efa_com_destroy_event_counter_params *params); +int efa_com_attach_event_counter (struct efa_com_dev *edev, +struct efa_com_attach_event_counter_params *params); +int efa_com_modify_event_counter (struct efa_com_dev *edev, +struct efa_com_modify_event_counter_params *params);#endif /* _EFA_COM_CMD_H_ */
drivers/infiniband/hw/efa/efa_main.c +6 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause /* -* Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All rights reserved. +* Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All rights reserved. */ #include <linux/module.h>
@@ -372,20 +372,24 @@ static const struct ib_device_ops efa_dev_ops = { .alloc_pd = efa_alloc_pd, .alloc_ucontext = efa_alloc_ucontext, .create_user_cq = efa_create_user_cq, + .create_comp_cntr = efa_create_comp_cntr, .create_qp = efa_create_qp, .create_user_ah = efa_create_ah, .dealloc_pd = efa_dealloc_pd, .dealloc_ucontext = efa_dealloc_ucontext, .dereg_mr = efa_dereg_mr, .destroy_ah = efa_destroy_ah, + .destroy_comp_cntr = efa_destroy_comp_cntr, .destroy_cq = efa_destroy_cq, .destroy_qp = efa_destroy_qp, .get_hw_stats = efa_get_hw_stats, .get_link_layer = efa_port_link_layer, .get_port_immutable = efa_get_port_immutable, + .modify_comp_cntr = efa_modify_comp_cntr, .mmap = efa_mmap, .mmap_free = efa_mmap_free, .modify_qp = efa_modify_qp, + .qp_attach_comp_cntr = efa_qp_attach_comp_cntr, .query_device = efa_query_device, .query_gid = efa_query_gid, .query_pkey = efa_query_pkey,
@@ -396,6 +400,7 @@ static const struct ib_device_ops efa_dev_ops = {INIT_RDMA_OBJ_SIZE (ib_ah, efa_ah, ibah),INIT_RDMA_OBJ_SIZE (ib_cq, efa_cq, ibcq), +INIT_RDMA_OBJ_SIZE (ib_comp_cntr, efa_comp_cntr, ibcc),INIT_RDMA_OBJ_SIZE (ib_pd, efa_pd, ibpd),INIT_RDMA_OBJ_SIZE (ib_qp, efa_qp, ibqp), INIT_RDMA_OBJ_SIZE(ib_ucontext, efa_ucontext, ibucontext),
drivers/infiniband/hw/efa/efa_verbs.c +199 -0
231 lines not on this page · raw message
include/uapi/rdma/efa-abi.h +6 -0
@@ -133,6 +133,7 @@ enum {EFA_QUERY_DEVICE_CAPS_RDMA_WRITE =1 <<5 ,EFA_QUERY_DEVICE_CAPS_UNSOLICITED_WRITE_RECV =1 <<6 ,EFA_QUERY_DEVICE_CAPS_CQ_WITH_EXT_MEM =1 <<7 , + EFA_QUERY_DEVICE_CAPS_COMP_CNTR = 1 << 8, }; struct efa_ibv_ex_query_device_resp {
@@ -163,4 +164,9 @@ enum efa_mr_methods { EFA_IB_METHOD_MR_QUERY = (1U << UVERBS_ID_NS_SHIFT), }; +enum efa_comp_cntr_create_attrs { +EFA_IB_ATTR_CREATE_COMP_CNTR_COMP_BUFFER = (1U <<UVERBS_ID_NS_SHIFT ), +EFA_IB_ATTR_CREATE_COMP_CNTR_ERR_BUFFER , +}; +#endif /* EFA_ABI_USER_H */
Signature · 1 line
2.47.3