aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ocrdma
diff options
context:
space:
mode:
authorMitesh Ahuja <mitesh.ahuja@emulex.com>2014-12-18 03:42:55 -0500
committerRoland Dreier <roland@purestorage.com>2015-02-18 11:24:45 -0500
commitcad1fbb0fd0e72ae2e7c18d486ff33e26c275f6c (patch)
tree2fa4be1805ec54facfdd987b23f85b8e563261e5 /drivers/infiniband/hw/ocrdma
parentbfa76d49576599a4b9f9b7a71f23d73d6dcff735 (diff)
RDMA/ocrdma: Add support for IB stack compliant stats in sysfs.
Add the following per-port sysfs traffic counters for RoCE: port_xmit_packets port_rcv_packets port_rcv_data port_xmit_data Signed-off-by: Mitesh Ahuja <mitesh.ahuja@emulex.com> Signed-off-by: Devesh Sharma <devesh.sharma@emulex.com> Signed-off-by: Selvin Xavier <selvin.xavier@emulex.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw/ocrdma')
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_ah.c19
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_stats.c69
-rw-r--r--drivers/infiniband/hw/ocrdma/ocrdma_stats.h2
3 files changed, 89 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index f3cc8c9e65ae..b80b57b40043 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -29,11 +29,13 @@
29#include <net/netevent.h> 29#include <net/netevent.h>
30 30
31#include <rdma/ib_addr.h> 31#include <rdma/ib_addr.h>
32#include <rdma/ib_mad.h>
32 33
33#include "ocrdma.h" 34#include "ocrdma.h"
34#include "ocrdma_verbs.h" 35#include "ocrdma_verbs.h"
35#include "ocrdma_ah.h" 36#include "ocrdma_ah.h"
36#include "ocrdma_hw.h" 37#include "ocrdma_hw.h"
38#include "ocrdma_stats.h"
37 39
38#define OCRDMA_VID_PCP_SHIFT 0xD 40#define OCRDMA_VID_PCP_SHIFT 0xD
39 41
@@ -191,5 +193,20 @@ int ocrdma_process_mad(struct ib_device *ibdev,
191 struct ib_grh *in_grh, 193 struct ib_grh *in_grh,
192 struct ib_mad *in_mad, struct ib_mad *out_mad) 194 struct ib_mad *in_mad, struct ib_mad *out_mad)
193{ 195{
194 return IB_MAD_RESULT_SUCCESS; 196 int status;
197 struct ocrdma_dev *dev;
198
199 switch (in_mad->mad_hdr.mgmt_class) {
200 case IB_MGMT_CLASS_PERF_MGMT:
201 dev = get_ocrdma_dev(ibdev);
202 if (!ocrdma_pma_counters(dev, out_mad))
203 status = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
204 else
205 status = IB_MAD_RESULT_SUCCESS;
206 break;
207 default:
208 status = IB_MAD_RESULT_SUCCESS;
209 break;
210 }
211 return status;
195} 212}
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index 41a9aec9998d..614d1a8aa01d 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -26,6 +26,7 @@
26 *******************************************************************/ 26 *******************************************************************/
27 27
28#include <rdma/ib_addr.h> 28#include <rdma/ib_addr.h>
29#include <rdma/ib_pma.h>
29#include "ocrdma_stats.h" 30#include "ocrdma_stats.h"
30 31
31static struct dentry *ocrdma_dbgfs_dir; 32static struct dentry *ocrdma_dbgfs_dir;
@@ -249,6 +250,27 @@ static char *ocrdma_rx_stats(struct ocrdma_dev *dev)
249 return stats; 250 return stats;
250} 251}
251 252
253static u64 ocrdma_sysfs_rcv_pkts(struct ocrdma_dev *dev)
254{
255 struct ocrdma_rdma_stats_resp *rdma_stats =
256 (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
257 struct ocrdma_rx_stats *rx_stats = &rdma_stats->rx_stats;
258
259 return convert_to_64bit(rx_stats->roce_frames_lo,
260 rx_stats->roce_frames_hi) + (u64)rx_stats->roce_frame_icrc_drops
261 + (u64)rx_stats->roce_frame_payload_len_drops;
262}
263
264static u64 ocrdma_sysfs_rcv_data(struct ocrdma_dev *dev)
265{
266 struct ocrdma_rdma_stats_resp *rdma_stats =
267 (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
268 struct ocrdma_rx_stats *rx_stats = &rdma_stats->rx_stats;
269
270 return (convert_to_64bit(rx_stats->roce_frame_bytes_lo,
271 rx_stats->roce_frame_bytes_hi))/4;
272}
273
252static char *ocrdma_tx_stats(struct ocrdma_dev *dev) 274static char *ocrdma_tx_stats(struct ocrdma_dev *dev)
253{ 275{
254 char *stats = dev->stats_mem.debugfs_mem, *pcur; 276 char *stats = dev->stats_mem.debugfs_mem, *pcur;
@@ -292,6 +314,37 @@ static char *ocrdma_tx_stats(struct ocrdma_dev *dev)
292 return stats; 314 return stats;
293} 315}
294 316
317static u64 ocrdma_sysfs_xmit_pkts(struct ocrdma_dev *dev)
318{
319 struct ocrdma_rdma_stats_resp *rdma_stats =
320 (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
321 struct ocrdma_tx_stats *tx_stats = &rdma_stats->tx_stats;
322
323 return (convert_to_64bit(tx_stats->send_pkts_lo,
324 tx_stats->send_pkts_hi) +
325 convert_to_64bit(tx_stats->write_pkts_lo, tx_stats->write_pkts_hi) +
326 convert_to_64bit(tx_stats->read_pkts_lo, tx_stats->read_pkts_hi) +
327 convert_to_64bit(tx_stats->read_rsp_pkts_lo,
328 tx_stats->read_rsp_pkts_hi) +
329 convert_to_64bit(tx_stats->ack_pkts_lo, tx_stats->ack_pkts_hi));
330}
331
332static u64 ocrdma_sysfs_xmit_data(struct ocrdma_dev *dev)
333{
334 struct ocrdma_rdma_stats_resp *rdma_stats =
335 (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
336 struct ocrdma_tx_stats *tx_stats = &rdma_stats->tx_stats;
337
338 return (convert_to_64bit(tx_stats->send_bytes_lo,
339 tx_stats->send_bytes_hi) +
340 convert_to_64bit(tx_stats->write_bytes_lo,
341 tx_stats->write_bytes_hi) +
342 convert_to_64bit(tx_stats->read_req_bytes_lo,
343 tx_stats->read_req_bytes_hi) +
344 convert_to_64bit(tx_stats->read_rsp_bytes_lo,
345 tx_stats->read_rsp_bytes_hi))/4;
346}
347
295static char *ocrdma_wqe_stats(struct ocrdma_dev *dev) 348static char *ocrdma_wqe_stats(struct ocrdma_dev *dev)
296{ 349{
297 char *stats = dev->stats_mem.debugfs_mem, *pcur; 350 char *stats = dev->stats_mem.debugfs_mem, *pcur;
@@ -448,6 +501,22 @@ static void ocrdma_update_stats(struct ocrdma_dev *dev)
448 } 501 }
449} 502}
450 503
504int ocrdma_pma_counters(struct ocrdma_dev *dev,
505 struct ib_mad *out_mad)
506{
507 struct ib_pma_portcounters *pma_cnt;
508
509 memset(out_mad->data, 0, sizeof out_mad->data);
510 pma_cnt = (void *)(out_mad->data + 40);
511 ocrdma_update_stats(dev);
512
513 pma_cnt->port_xmit_data = cpu_to_be32(ocrdma_sysfs_xmit_data(dev));
514 pma_cnt->port_rcv_data = cpu_to_be32(ocrdma_sysfs_rcv_data(dev));
515 pma_cnt->port_xmit_packets = cpu_to_be32(ocrdma_sysfs_xmit_pkts(dev));
516 pma_cnt->port_rcv_packets = cpu_to_be32(ocrdma_sysfs_rcv_pkts(dev));
517 return 0;
518}
519
451static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer, 520static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,
452 size_t usr_buf_len, loff_t *ppos) 521 size_t usr_buf_len, loff_t *ppos)
453{ 522{
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.h b/drivers/infiniband/hw/ocrdma/ocrdma_stats.h
index 5f5e20c46d7c..89afe06eca32 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.h
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.h
@@ -50,5 +50,7 @@ void ocrdma_rem_debugfs(void);
50void ocrdma_init_debugfs(void); 50void ocrdma_init_debugfs(void);
51void ocrdma_rem_port_stats(struct ocrdma_dev *dev); 51void ocrdma_rem_port_stats(struct ocrdma_dev *dev);
52void ocrdma_add_port_stats(struct ocrdma_dev *dev); 52void ocrdma_add_port_stats(struct ocrdma_dev *dev);
53int ocrdma_pma_counters(struct ocrdma_dev *dev,
54 struct ib_mad *out_mad);
53 55
54#endif /* __OCRDMA_STATS_H__ */ 56#endif /* __OCRDMA_STATS_H__ */