RDMA/bnxt_re: Support Perf management counters
Subsystems (2)
Selvin Xavier
maintainerPATCH v3 1/1 RDMA/bnxt_re: Support Perf management counters
From: Preethi G <[email protected]>
Add support for process_mad hook to retrieve the perf management counters. Supports IB_PMA_PORT_COUNTERS and IB_PMA_PORT_COUNTERS_EXT counters. Query the data from HW contexts and FW commands.
---v2->v3:
Addressed Leon's comment. If FW command fails, return immediately.v1->v2:
Fix the warning reported by kernel test robot by returning rc
drivers/infiniband/hw/bnxt_re/bnxt_re.h | 4 ++ drivers/infiniband/hw/bnxt_re/hw_counters.c | 92 +++++++++++++++++++++++++++++ drivers/infiniband/hw/bnxt_re/ib_verbs.c | 36 +++++++++++ drivers/infiniband/hw/bnxt_re/ib_verbs.h | 6 ++ drivers/infiniband/hw/bnxt_re/main.c | 1 + 5 files changed, 139 insertions(+)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +4 -0
@@ -246,6 +246,10 @@ struct bnxt_re_dev {#define BNXT_RE_CHECK_RC (x) ((x) && ((x) != -ETIMEDOUT))void bnxt_re_pacing_alert (struct bnxt_re_dev *rdev); +int bnxt_re_assign_pma_port_counters (struct bnxt_re_dev *rdev,struct ib_mad *out_mad); +int bnxt_re_assign_pma_port_ext_counters (struct bnxt_re_dev *rdev, +struct ib_mad *out_mad); +static inline struct device *rdev_to_dev (struct bnxt_re_dev *rdev) {if (rdev)
drivers/infiniband/hw/bnxt_re/hw_counters.c +92 -0
104 lines not on this page · raw message
drivers/infiniband/hw/bnxt_re/ib_verbs.c +36 -0
@@ -49,6 +49,7 @@#include <rdma/ib_addr.h> #include <rdma/ib_mad.h> #include <rdma/ib_cache.h> +#include <rdma/ib_pma.h> #include <rdma/uverbs_ioctl.h> #include <linux/hashtable.h>
@@ -4489,6 +4490,41 @@ void bnxt_re_mmap_free(struct rdma_user_mmap_entry *rdma_entry)kfree (bnxt_entry); } +int bnxt_re_process_mad (struct ib_device *ibdev,int mad_flags, +u32 port_num,const struct ib_wc *in_wc, +const struct ib_grh *in_grh, +const struct ib_mad *in_mad,struct ib_mad *out_mad, +size_t *out_mad_size,u16 *out_mad_pkey_index) +{ +struct bnxt_re_dev *rdev =to_bnxt_re_dev (ibdev, ibdev); +struct ib_class_port_info cpi = {}; +int ret =IB_MAD_RESULT_SUCCESS ; +int rc =0 ; + +if (in_mad->mad_hdr.mgmt_class !=IB_MGMT_CLASS_PERF_MGMT ) +return ret; + +switch (in_mad->mad_hdr.attr_id) { +case IB_PMA_CLASS_PORT_INFO : + cpi.capability_mask =IB_PMA_CLASS_CAP_EXT_WIDTH ; +memcpy ((out_mad->data +40 ), &cpi,sizeof (cpi)); +break ; +case IB_PMA_PORT_COUNTERS_EXT : + rc =bnxt_re_assign_pma_port_ext_counters (rdev, out_mad); +break ; +case IB_PMA_PORT_COUNTERS : + rc =bnxt_re_assign_pma_port_counters (rdev, out_mad); +break ; +default : + rc = -EINVAL ; +break ; + } +if (rc) +return IB_MAD_RESULT_FAILURE ; + ret |=IB_MAD_RESULT_REPLY ; +return ret; +} +static int UVERBS_HANDLER (BNXT_RE_METHOD_NOTIFY_DRV )(struct uverbs_attr_bundle *attrs) {struct bnxt_re_ucontext *uctx;
drivers/infiniband/hw/bnxt_re/ib_verbs.h +6 -0
@@ -268,6 +268,12 @@ void bnxt_re_dealloc_ucontext(struct ib_ucontext *context);int bnxt_re_mmap (struct ib_ucontext *context,struct vm_area_struct *vma);void bnxt_re_mmap_free (struct rdma_user_mmap_entry *rdma_entry); +int bnxt_re_process_mad (struct ib_device *device,int process_mad_flags, +u32 port_num,const struct ib_wc *in_wc, +const struct ib_grh *in_grh, +const struct ib_mad *in_mad,struct ib_mad *out_mad, +size_t *out_mad_size,u16 *out_mad_pkey_index); +static inline u32 __to_ib_port_num (u16 port_id) {return (u32 )port_id +1 ;
drivers/infiniband/hw/bnxt_re/main.c +1 -0
@@ -1276,6 +1276,7 @@ static const struct ib_device_ops bnxt_re_dev_ops = { .post_recv = bnxt_re_post_recv, .post_send = bnxt_re_post_send, .post_srq_recv = bnxt_re_post_srq_recv, + .process_mad = bnxt_re_process_mad, .query_ah = bnxt_re_query_ah, .query_device = bnxt_re_query_device, .modify_device = bnxt_re_modify_device,
Signature · 1 line
2.5.5
Leon Romanovsky
AppliedQuoted 5 lines · Selvin Xavier
Add support for
process_madhook to retrieve the perf management counters. SupportsIB_PMA_PORT_COUNTERSandIB_PMA_PORT_COUNTERS_EXTcounters. Query the data from HW contexts and FW commands.
Applied, thanks!
[1/1] RDMA/bnxt_re: Support Perf management counters
https://git.kernel.org/rdma/rdma/c/b9aa02931ceef5
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>