RDMA/efa: Expose device statistics
Subsystems (2)
PATCH v2 1/1 RDMA/efa: Expose device statistics
Expose hardware statistics through the sysfs api:/sys/class/infiniband/efa_0/hw_counters/*. /sys/class/infiniband/efa_0/ports/1/hw_counters/*.
Reviewed-by Firas JahJah <[email protected]>
Reviewed-by Yossi Leybovich <[email protected]>
Signed-off-by Gal Pressman <[email protected]>
---
This patch should be merged after:
https://patchwork.kernel.org/patch/11053949/
To prevent null dereference.
Changelog:
* Remove the 'if (port_num)' check from efa_alloc_hw_stats
--- drivers/infiniband/hw/efa/efa.h | 3 + drivers/infiniband/hw/efa/efa_com_cmd.c | 35 ++++++++++++ drivers/infiniband/hw/efa/efa_com_cmd.h | 23 ++++++++ drivers/infiniband/hw/efa/efa_main.c | 2 + drivers/infiniband/hw/efa/efa_verbs.c | 75 +++++++++++++++++++++++++ 5 files changed, 138 insertions(+)
drivers/infiniband/hw/efa/efa.h +3 -0
@@ -156,5 +156,8 @@ int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, struct ib_udata *udata);enum rdma_link_layer efa_port_link_layer (struct ib_device *ibdev,u8 port_num); +struct rdma_hw_stats *efa_alloc_hw_stats (struct ib_device *ibdev,u8 port_num); +int efa_get_hw_stats (struct ib_device *ibdev,struct rdma_hw_stats *stats, +u8 port_num,int index);#endif /* _EFA_H_ */
drivers/infiniband/hw/efa/efa_com_cmd.c +35 -0
@@ -702,3 +702,38 @@ int efa_com_dealloc_uar(struct efa_com_dev *edev,return 0 ; } + +int efa_com_get_stats (struct efa_com_dev *edev, +struct efa_com_get_stats_params *params, +union efa_com_get_stats_result *result) +{ +struct efa_com_admin_queue *aq = &edev->aq; +struct efa_admin_aq_get_stats_cmd cmd = {}; +struct efa_admin_acq_get_stats_resp resp; +int err; + + cmd.aq_common_descriptor.opcode =EFA_ADMIN_GET_STATS ; + cmd.type = params->type; + cmd.scope = params->scope; + cmd.scope_modifier = params->scope_modifier; + + err =efa_com_cmd_exec (aq, + (struct efa_admin_aq_entry *)&cmd, +sizeof (cmd), + (struct efa_admin_acq_entry *)&resp, +sizeof (resp)); +if (err) { +ibdev_err (edev->efa_dev, +"Failed to get stats type-%u scope-%u.%u [%d]\n" , + cmd.type, cmd.scope, cmd.scope_modifier, err); +return err; + } + + result->basic_stats.tx_bytes = resp.basic_stats.tx_bytes; + result->basic_stats.tx_pkts = resp.basic_stats.tx_pkts; + result->basic_stats.rx_bytes = resp.basic_stats.rx_bytes; + result->basic_stats.rx_pkts = resp.basic_stats.rx_pkts; + result->basic_stats.rx_drops = resp.basic_stats.rx_drops; + +return 0 ; +}
drivers/infiniband/hw/efa/efa_com_cmd.h +23 -0
@@ -225,6 +225,26 @@ struct efa_com_dealloc_uar_params {u16 uarn; }; +struct efa_com_get_stats_params { +/* see enum efa_admin_get_stats_type */ +u8 type; +/* see enum efa_admin_get_stats_scope */ +u8 scope; +u16 scope_modifier; +}; + +struct efa_com_basic_stats { +u64 tx_bytes; +u64 tx_pkts; +u64 rx_bytes; +u64 rx_pkts; +u64 rx_drops; +}; + +union efa_com_get_stats_result { +struct efa_com_basic_stats basic_stats; +}; +void efa_com_set_dma_addr (dma_addr_t addr,u32 *addr_high,u32 *addr_low); int efa_com_create_qp(struct efa_com_dev *edev, struct efa_com_create_qp_params *params,
@@ -266,5 +286,8 @@ int efa_com_alloc_uar(struct efa_com_dev *edev, struct efa_com_alloc_uar_result *result);int efa_com_dealloc_uar (struct efa_com_dev *edev,struct efa_com_dealloc_uar_params *params); +int efa_com_get_stats (struct efa_com_dev *edev, +struct efa_com_get_stats_params *params, +union efa_com_get_stats_result *result);#endif /* _EFA_COM_CMD_H_ */
drivers/infiniband/hw/efa/efa_main.c +2 -0
@@ -201,6 +201,7 @@ static const struct ib_device_ops efa_dev_ops = { .driver_id = RDMA_DRIVER_EFA, .uverbs_abi_ver = EFA_UVERBS_ABI_VERSION, + .alloc_hw_stats = efa_alloc_hw_stats, .alloc_pd = efa_alloc_pd, .alloc_ucontext = efa_alloc_ucontext, .create_ah = efa_create_ah,
@@ -212,6 +213,7 @@ static const struct ib_device_ops efa_dev_ops = { .destroy_ah = efa_destroy_ah, .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, .mmap = efa_mmap,
drivers/infiniband/hw/efa/efa_verbs.c +75 -0
87 lines not on this page · raw message
Signature · 1 line
2.22.0
Doug Ledford
AppliedQuoted 4 lines · Gal Pressman
Expose hardware statistics through the sysfs api:
/sys/class/infiniband/efa_0/hw_counters/*./sys/class/infiniband/efa_0/ports/1/hw_counters/*.
Quoted 8 lines
Reviewed-by Firas JahJah <[email protected]>Reviewed-by Yossi Leybovich <[email protected]>Signed-off-by Gal Pressman <[email protected]>---
This patch should be merged after:
https://patchwork.kernel.org/patch/11053949/To prevent null dereference.
I merged the current for-rc into for-next and then took this to for- next. Thanks.
Signature · 3 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD