c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * This file contains code imported from the OFED rds source file ib_stats.c
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * Oracle elects to have and use the contents of ib_stats.c under and governed
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * by the OpenIB.org BSD license (see below for full license text). However,
16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347agiri * the following notice accompanied the original version of this file:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/*
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Copyright (c) 2006 Oracle. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * This software is available to you under a choice of one of two
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * licenses. You may choose to be licensed under the terms of the GNU
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * General Public License (GPL) Version 2, available from the file
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * COPYING in the main directory of this source tree, or the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * OpenIB.org BSD license below:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Redistribution and use in source and binary forms, with or
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * without modification, are permitted provided that the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * conditions are met:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - Redistributions of source code must retain the above
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * copyright notice, this list of conditions and the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * disclaimer.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * - Redistributions in binary form must reproduce the above
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * copyright notice, this list of conditions and the following
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * disclaimer in the documentation and/or other materials
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * provided with the distribution.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * SOFTWARE.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#include <sys/rds.h>
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#include <sys/ib/clients/rdsv3/rdsv3.h>
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#include <sys/ib/clients/rdsv3/ib.h>
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota#include <sys/ib/clients/rdsv3/rdsv3_debug.h>
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
a530e0a9c7875fde3c123c906ca193a70dfacc4fagiristruct rdsv3_ib_statistics *rdsv3_ib_stats = NULL;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic char *rdsv3_ib_stat_names[] = {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_connect_raced",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_listen_closed_stale",
5e12ddada2833f3aa285210603ce9aaeb8be35ccEiji Ota "ib_evt_handler_call",
5e12ddada2833f3aa285210603ce9aaeb8be35ccEiji Ota "ib_tasklet_call",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_tx_cq_event",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_tx_ring_full",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_tx_throttle",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_tx_sg_mapping_failure",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_tx_stalled",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_tx_credit_updates",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rx_cq_event",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rx_ring_empty",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rx_refill_from_cq",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rx_refill_from_thread",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rx_alloc_limit",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rx_credit_updates",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_ack_sent",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_ack_send_failure",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_ack_send_delayed",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_ack_send_piggybacked",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_ack_received",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rdma_mr_alloc",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rdma_mr_free",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rdma_mr_used",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rdma_mr_pool_flush",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rdma_mr_pool_wait",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "ib_rdma_mr_pool_depleted",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota};
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaunsigned int
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otardsv3_ib_stats_info_copy(struct rdsv3_info_iterator *iter,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota unsigned int avail)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota{
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota struct rdsv3_ib_statistics stats = {0, };
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint64_t *src;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota uint64_t *sum;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota size_t i;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota int cpu;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_ib_stats_info_copy", "iter: %p, avail: %d",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota iter, avail);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (avail < ARRAY_SIZE(rdsv3_ib_stat_names))
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota goto out;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
a530e0a9c7875fde3c123c906ca193a70dfacc4fagiri for (cpu = 0; cpu < nr_cpus; cpu++) {
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota src = (uint64_t *)&(rdsv3_per_cpu(rdsv3_ib_stats, cpu));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota sum = (uint64_t *)&stats;
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota for (i = 0; i < sizeof (stats) / sizeof (uint64_t); i++)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota *(sum++) += *(src++);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota }
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rdsv3_stats_info_copy(iter, (uint64_t *)&stats, rdsv3_ib_stat_names,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota ARRAY_SIZE(rdsv3_ib_stat_names));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota RDSV3_DPRINTF4("rdsv3_ib_stats_info_copy",
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "Return: iter: %p, avail: %d", iter, avail);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otaout:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (ARRAY_SIZE(rdsv3_ib_stat_names));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota}