Skip to contentSkip to conversation

RDMA/efa: Expose device statistics

PATCH Superseded Gal Pressman 2 participants 3 messages Jul 7, 2019 – Jul 25, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/efa: Expose device statistics

Expose hardware statistics through the sysfs api:
/sys/class/infiniband/efa_0/hw_counters/*.

---
 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   | 79 +++++++++++++++++++++++++
 5 files changed, 142 insertions(+)
drivers/infiniband/hw/efa/efa.h +3 -0
index 119f8efec564..2283e432693e 100644
@@ -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
index 62345d8abf3c..16b115df63e8 100644
@@ -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
index a1174380462c..7f6c13052f49 100644
@@ -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
index dd1c6d49466f..83858f7e83d0 100644
@@ -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 +79 -0

91 lines not on this page · raw message

Signature · 1 line
2.22.0
#1 lore raw
Quoted 6 lines · Gal Pressman

Expose hardware statistics through the sysfs api:
/sys/class/infiniband/efa_0/hw_counters/*.

Quoted 7 lines
---
 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   | 79 +++++++++++++++++++++++++
 5 files changed, 142 insertions(+)

Am I right that this patch needs

https://patchwork.kernel.org/patch/11053949/

before it won't crash?

Jason

#2 lore raw
Quoted 15 lines · Jason Gunthorpe
Quoted 6 lines · Gal Pressman

Expose hardware statistics through the sysfs api:
/sys/class/infiniband/efa_0/hw_counters/*.

Quoted 7 lines
---
 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   | 79 +++++++++++++++++++++++++
 5 files changed, 142 insertions(+)
Quoted 5 lines

Am I right that this patch needs

https://patchwork.kernel.org/patch/11053949/

before it won't crash?

That's right.
I'm going to resubmit this patch regardless to remove the 'if (port_num)' check in efa_alloc_hw_stats as the exposed device stats are the same as the port stats (only port 1) and some userspace tools use the port stats.

I'll make sure to note the patch dependency in v2.