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