2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
6 * This file contains code imported from the OFED rds source file ib_stats.c
7 * Oracle elects to have and use the contents of ib_stats.c under and governed
8 * by the OpenIB.org BSD license (see below for full license text). However,
9 * the following notice accompanied the original version of this file:
13 * Copyright (c) 2006 Oracle. All rights reserved.
15 * This software is available to you under a choice of one of two
16 * licenses. You may choose to be licensed under the terms of the GNU
17 * General Public License (GPL) Version 2, available from the file
18 * COPYING in the main directory of this source tree, or the
19 * OpenIB.org BSD license below:
21 * Redistribution and use in source and binary forms, with or
22 * without modification, are permitted provided that the following
25 * - Redistributions of source code must retain the above
26 * copyright notice, this list of conditions and the following
29 * - Redistributions in binary form must reproduce the above
30 * copyright notice, this list of conditions and the following
31 * disclaimer in the documentation and/or other materials
32 * provided with the distribution.
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
38 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
39 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
46 #include <sys/ib/clients/rdsv3/rdsv3.h>
47 #include <sys/ib/clients/rdsv3/ib.h>
48 #include <sys/ib/clients/rdsv3/rdsv3_debug.h>
50 struct rdsv3_ib_statistics
*rdsv3_ib_stats
= NULL
;
52 static char *rdsv3_ib_stat_names
[] = {
54 "ib_listen_closed_stale",
55 "ib_evt_handler_call",
60 "ib_tx_sg_mapping_failure",
62 "ib_tx_credit_updates",
65 "ib_rx_refill_from_cq",
66 "ib_rx_refill_from_thread",
68 "ib_rx_credit_updates",
70 "ib_ack_send_failure",
71 "ib_ack_send_delayed",
72 "ib_ack_send_piggybacked",
77 "ib_rdma_mr_pool_flush",
78 "ib_rdma_mr_pool_wait",
79 "ib_rdma_mr_pool_depleted",
83 rdsv3_ib_stats_info_copy(struct rdsv3_info_iterator
*iter
,
86 struct rdsv3_ib_statistics stats
= {0, };
92 RDSV3_DPRINTF4("rdsv3_ib_stats_info_copy", "iter: %p, avail: %d",
95 if (avail
< ARRAY_SIZE(rdsv3_ib_stat_names
))
98 for (cpu
= 0; cpu
< nr_cpus
; cpu
++) {
99 src
= (uint64_t *)&(rdsv3_per_cpu(rdsv3_ib_stats
, cpu
));
100 sum
= (uint64_t *)&stats
;
101 for (i
= 0; i
< sizeof (stats
) / sizeof (uint64_t); i
++)
102 *(sum
++) += *(src
++);
105 rdsv3_stats_info_copy(iter
, (uint64_t *)&stats
, rdsv3_ib_stat_names
,
106 ARRAY_SIZE(rdsv3_ib_stat_names
));
108 RDSV3_DPRINTF4("rdsv3_ib_stats_info_copy",
109 "Return: iter: %p, avail: %d", iter
, avail
);
111 return (ARRAY_SIZE(rdsv3_ib_stat_names
));