112198SEiji.Ota@Sun.COM /*
212198SEiji.Ota@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
312198SEiji.Ota@Sun.COM */
412198SEiji.Ota@Sun.COM
512198SEiji.Ota@Sun.COM /*
612763SGiri.Adari@Sun.COM * This file contains code imported from the OFED rds source file ib_stats.c
712763SGiri.Adari@Sun.COM * Oracle elects to have and use the contents of ib_stats.c under and governed
812763SGiri.Adari@Sun.COM * by the OpenIB.org BSD license (see below for full license text). However,
912763SGiri.Adari@Sun.COM * the following notice accompanied the original version of this file:
1012763SGiri.Adari@Sun.COM */
1112763SGiri.Adari@Sun.COM
1212763SGiri.Adari@Sun.COM /*
1312198SEiji.Ota@Sun.COM * Copyright (c) 2006 Oracle. All rights reserved.
1412198SEiji.Ota@Sun.COM *
1512198SEiji.Ota@Sun.COM * This software is available to you under a choice of one of two
1612198SEiji.Ota@Sun.COM * licenses. You may choose to be licensed under the terms of the GNU
1712198SEiji.Ota@Sun.COM * General Public License (GPL) Version 2, available from the file
1812198SEiji.Ota@Sun.COM * COPYING in the main directory of this source tree, or the
1912198SEiji.Ota@Sun.COM * OpenIB.org BSD license below:
2012198SEiji.Ota@Sun.COM *
2112198SEiji.Ota@Sun.COM * Redistribution and use in source and binary forms, with or
2212198SEiji.Ota@Sun.COM * without modification, are permitted provided that the following
2312198SEiji.Ota@Sun.COM * conditions are met:
2412198SEiji.Ota@Sun.COM *
2512198SEiji.Ota@Sun.COM * - Redistributions of source code must retain the above
2612198SEiji.Ota@Sun.COM * copyright notice, this list of conditions and the following
2712198SEiji.Ota@Sun.COM * disclaimer.
2812198SEiji.Ota@Sun.COM *
2912198SEiji.Ota@Sun.COM * - Redistributions in binary form must reproduce the above
3012198SEiji.Ota@Sun.COM * copyright notice, this list of conditions and the following
3112198SEiji.Ota@Sun.COM * disclaimer in the documentation and/or other materials
3212198SEiji.Ota@Sun.COM * provided with the distribution.
3312198SEiji.Ota@Sun.COM *
3412198SEiji.Ota@Sun.COM * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3512198SEiji.Ota@Sun.COM * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3612198SEiji.Ota@Sun.COM * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3712198SEiji.Ota@Sun.COM * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3812198SEiji.Ota@Sun.COM * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3912198SEiji.Ota@Sun.COM * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
4012198SEiji.Ota@Sun.COM * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4112198SEiji.Ota@Sun.COM * SOFTWARE.
4212198SEiji.Ota@Sun.COM *
4312198SEiji.Ota@Sun.COM */
4412198SEiji.Ota@Sun.COM #include <sys/rds.h>
4512198SEiji.Ota@Sun.COM
4612198SEiji.Ota@Sun.COM #include <sys/ib/clients/rdsv3/rdsv3.h>
4712198SEiji.Ota@Sun.COM #include <sys/ib/clients/rdsv3/ib.h>
4812198SEiji.Ota@Sun.COM #include <sys/ib/clients/rdsv3/rdsv3_debug.h>
4912198SEiji.Ota@Sun.COM
5012922SGiri.Adari@Sun.COM struct rdsv3_ib_statistics *rdsv3_ib_stats = NULL;
5112198SEiji.Ota@Sun.COM
5212198SEiji.Ota@Sun.COM static char *rdsv3_ib_stat_names[] = {
5312198SEiji.Ota@Sun.COM "ib_connect_raced",
5412198SEiji.Ota@Sun.COM "ib_listen_closed_stale",
55*13118SEiji.Ota@Sun.COM "ib_evt_handler_call",
56*13118SEiji.Ota@Sun.COM "ib_tasklet_call",
5712198SEiji.Ota@Sun.COM "ib_tx_cq_event",
5812198SEiji.Ota@Sun.COM "ib_tx_ring_full",
5912198SEiji.Ota@Sun.COM "ib_tx_throttle",
6012198SEiji.Ota@Sun.COM "ib_tx_sg_mapping_failure",
6112198SEiji.Ota@Sun.COM "ib_tx_stalled",
6212198SEiji.Ota@Sun.COM "ib_tx_credit_updates",
6312198SEiji.Ota@Sun.COM "ib_rx_cq_event",
6412198SEiji.Ota@Sun.COM "ib_rx_ring_empty",
6512198SEiji.Ota@Sun.COM "ib_rx_refill_from_cq",
6612198SEiji.Ota@Sun.COM "ib_rx_refill_from_thread",
6712198SEiji.Ota@Sun.COM "ib_rx_alloc_limit",
6812198SEiji.Ota@Sun.COM "ib_rx_credit_updates",
6912198SEiji.Ota@Sun.COM "ib_ack_sent",
7012198SEiji.Ota@Sun.COM "ib_ack_send_failure",
7112198SEiji.Ota@Sun.COM "ib_ack_send_delayed",
7212198SEiji.Ota@Sun.COM "ib_ack_send_piggybacked",
7312198SEiji.Ota@Sun.COM "ib_ack_received",
7412198SEiji.Ota@Sun.COM "ib_rdma_mr_alloc",
7512198SEiji.Ota@Sun.COM "ib_rdma_mr_free",
7612198SEiji.Ota@Sun.COM "ib_rdma_mr_used",
7712198SEiji.Ota@Sun.COM "ib_rdma_mr_pool_flush",
7812198SEiji.Ota@Sun.COM "ib_rdma_mr_pool_wait",
7912198SEiji.Ota@Sun.COM "ib_rdma_mr_pool_depleted",
8012198SEiji.Ota@Sun.COM };
8112198SEiji.Ota@Sun.COM
8212198SEiji.Ota@Sun.COM unsigned int
rdsv3_ib_stats_info_copy(struct rdsv3_info_iterator * iter,unsigned int avail)8312198SEiji.Ota@Sun.COM rdsv3_ib_stats_info_copy(struct rdsv3_info_iterator *iter,
8412198SEiji.Ota@Sun.COM unsigned int avail)
8512198SEiji.Ota@Sun.COM {
8612198SEiji.Ota@Sun.COM struct rdsv3_ib_statistics stats = {0, };
8712198SEiji.Ota@Sun.COM uint64_t *src;
8812198SEiji.Ota@Sun.COM uint64_t *sum;
8912198SEiji.Ota@Sun.COM size_t i;
9012198SEiji.Ota@Sun.COM int cpu;
9112198SEiji.Ota@Sun.COM
9212198SEiji.Ota@Sun.COM RDSV3_DPRINTF4("rdsv3_ib_stats_info_copy", "iter: %p, avail: %d",
9312198SEiji.Ota@Sun.COM iter, avail);
9412198SEiji.Ota@Sun.COM
9512198SEiji.Ota@Sun.COM if (avail < ARRAY_SIZE(rdsv3_ib_stat_names))
9612198SEiji.Ota@Sun.COM goto out;
9712198SEiji.Ota@Sun.COM
9812922SGiri.Adari@Sun.COM for (cpu = 0; cpu < nr_cpus; cpu++) {
9912198SEiji.Ota@Sun.COM src = (uint64_t *)&(rdsv3_per_cpu(rdsv3_ib_stats, cpu));
10012198SEiji.Ota@Sun.COM sum = (uint64_t *)&stats;
10112198SEiji.Ota@Sun.COM for (i = 0; i < sizeof (stats) / sizeof (uint64_t); i++)
10212198SEiji.Ota@Sun.COM *(sum++) += *(src++);
10312198SEiji.Ota@Sun.COM }
10412198SEiji.Ota@Sun.COM
10512198SEiji.Ota@Sun.COM rdsv3_stats_info_copy(iter, (uint64_t *)&stats, rdsv3_ib_stat_names,
10612198SEiji.Ota@Sun.COM ARRAY_SIZE(rdsv3_ib_stat_names));
10712198SEiji.Ota@Sun.COM
10812198SEiji.Ota@Sun.COM RDSV3_DPRINTF4("rdsv3_ib_stats_info_copy",
10912198SEiji.Ota@Sun.COM "Return: iter: %p, avail: %d", iter, avail);
11012198SEiji.Ota@Sun.COM out:
11112198SEiji.Ota@Sun.COM return (ARRAY_SIZE(rdsv3_ib_stat_names));
11212198SEiji.Ota@Sun.COM }
113