xref: /linux/net/rds/ib_stats.c (revision e6babe4cc4ce48577d743cc0de19a214f2527956)
1*e6babe4cSAndy Grover /*
2*e6babe4cSAndy Grover  * Copyright (c) 2006 Oracle.  All rights reserved.
3*e6babe4cSAndy Grover  *
4*e6babe4cSAndy Grover  * This software is available to you under a choice of one of two
5*e6babe4cSAndy Grover  * licenses.  You may choose to be licensed under the terms of the GNU
6*e6babe4cSAndy Grover  * General Public License (GPL) Version 2, available from the file
7*e6babe4cSAndy Grover  * COPYING in the main directory of this source tree, or the
8*e6babe4cSAndy Grover  * OpenIB.org BSD license below:
9*e6babe4cSAndy Grover  *
10*e6babe4cSAndy Grover  *     Redistribution and use in source and binary forms, with or
11*e6babe4cSAndy Grover  *     without modification, are permitted provided that the following
12*e6babe4cSAndy Grover  *     conditions are met:
13*e6babe4cSAndy Grover  *
14*e6babe4cSAndy Grover  *      - Redistributions of source code must retain the above
15*e6babe4cSAndy Grover  *        copyright notice, this list of conditions and the following
16*e6babe4cSAndy Grover  *        disclaimer.
17*e6babe4cSAndy Grover  *
18*e6babe4cSAndy Grover  *      - Redistributions in binary form must reproduce the above
19*e6babe4cSAndy Grover  *        copyright notice, this list of conditions and the following
20*e6babe4cSAndy Grover  *        disclaimer in the documentation and/or other materials
21*e6babe4cSAndy Grover  *        provided with the distribution.
22*e6babe4cSAndy Grover  *
23*e6babe4cSAndy Grover  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24*e6babe4cSAndy Grover  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25*e6babe4cSAndy Grover  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26*e6babe4cSAndy Grover  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27*e6babe4cSAndy Grover  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28*e6babe4cSAndy Grover  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29*e6babe4cSAndy Grover  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30*e6babe4cSAndy Grover  * SOFTWARE.
31*e6babe4cSAndy Grover  *
32*e6babe4cSAndy Grover  */
33*e6babe4cSAndy Grover #include <linux/percpu.h>
34*e6babe4cSAndy Grover #include <linux/seq_file.h>
35*e6babe4cSAndy Grover #include <linux/proc_fs.h>
36*e6babe4cSAndy Grover 
37*e6babe4cSAndy Grover #include "rds.h"
38*e6babe4cSAndy Grover #include "ib.h"
39*e6babe4cSAndy Grover 
40*e6babe4cSAndy Grover DEFINE_PER_CPU(struct rds_ib_statistics, rds_ib_stats) ____cacheline_aligned;
41*e6babe4cSAndy Grover 
42*e6babe4cSAndy Grover static char *rds_ib_stat_names[] = {
43*e6babe4cSAndy Grover 	"ib_connect_raced",
44*e6babe4cSAndy Grover 	"ib_listen_closed_stale",
45*e6babe4cSAndy Grover 	"ib_tx_cq_call",
46*e6babe4cSAndy Grover 	"ib_tx_cq_event",
47*e6babe4cSAndy Grover 	"ib_tx_ring_full",
48*e6babe4cSAndy Grover 	"ib_tx_throttle",
49*e6babe4cSAndy Grover 	"ib_tx_sg_mapping_failure",
50*e6babe4cSAndy Grover 	"ib_tx_stalled",
51*e6babe4cSAndy Grover 	"ib_tx_credit_updates",
52*e6babe4cSAndy Grover 	"ib_rx_cq_call",
53*e6babe4cSAndy Grover 	"ib_rx_cq_event",
54*e6babe4cSAndy Grover 	"ib_rx_ring_empty",
55*e6babe4cSAndy Grover 	"ib_rx_refill_from_cq",
56*e6babe4cSAndy Grover 	"ib_rx_refill_from_thread",
57*e6babe4cSAndy Grover 	"ib_rx_alloc_limit",
58*e6babe4cSAndy Grover 	"ib_rx_credit_updates",
59*e6babe4cSAndy Grover 	"ib_ack_sent",
60*e6babe4cSAndy Grover 	"ib_ack_send_failure",
61*e6babe4cSAndy Grover 	"ib_ack_send_delayed",
62*e6babe4cSAndy Grover 	"ib_ack_send_piggybacked",
63*e6babe4cSAndy Grover 	"ib_ack_received",
64*e6babe4cSAndy Grover 	"ib_rdma_mr_alloc",
65*e6babe4cSAndy Grover 	"ib_rdma_mr_free",
66*e6babe4cSAndy Grover 	"ib_rdma_mr_used",
67*e6babe4cSAndy Grover 	"ib_rdma_mr_pool_flush",
68*e6babe4cSAndy Grover 	"ib_rdma_mr_pool_wait",
69*e6babe4cSAndy Grover 	"ib_rdma_mr_pool_depleted",
70*e6babe4cSAndy Grover };
71*e6babe4cSAndy Grover 
72*e6babe4cSAndy Grover unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,
73*e6babe4cSAndy Grover 				    unsigned int avail)
74*e6babe4cSAndy Grover {
75*e6babe4cSAndy Grover 	struct rds_ib_statistics stats = {0, };
76*e6babe4cSAndy Grover 	uint64_t *src;
77*e6babe4cSAndy Grover 	uint64_t *sum;
78*e6babe4cSAndy Grover 	size_t i;
79*e6babe4cSAndy Grover 	int cpu;
80*e6babe4cSAndy Grover 
81*e6babe4cSAndy Grover 	if (avail < ARRAY_SIZE(rds_ib_stat_names))
82*e6babe4cSAndy Grover 		goto out;
83*e6babe4cSAndy Grover 
84*e6babe4cSAndy Grover 	for_each_online_cpu(cpu) {
85*e6babe4cSAndy Grover 		src = (uint64_t *)&(per_cpu(rds_ib_stats, cpu));
86*e6babe4cSAndy Grover 		sum = (uint64_t *)&stats;
87*e6babe4cSAndy Grover 		for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++)
88*e6babe4cSAndy Grover 			*(sum++) += *(src++);
89*e6babe4cSAndy Grover 	}
90*e6babe4cSAndy Grover 
91*e6babe4cSAndy Grover 	rds_stats_info_copy(iter, (uint64_t *)&stats, rds_ib_stat_names,
92*e6babe4cSAndy Grover 			    ARRAY_SIZE(rds_ib_stat_names));
93*e6babe4cSAndy Grover out:
94*e6babe4cSAndy Grover 	return ARRAY_SIZE(rds_ib_stat_names);
95*e6babe4cSAndy Grover }
96