/*1* Copyright (c) 2006 Oracle. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*31*/32#include <linux/percpu.h>33#include <linux/seq_file.h>34#include <linux/proc_fs.h>3536#include "rds.h"37#include "ib.h"3839DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_ib_statistics, rds_ib_stats);4041static const char *const rds_ib_stat_names[] = {42"ib_connect_raced",43"ib_listen_closed_stale",44"ib_tx_cq_call",45"ib_tx_cq_event",46"ib_tx_ring_full",47"ib_tx_throttle",48"ib_tx_sg_mapping_failure",49"ib_tx_stalled",50"ib_tx_credit_updates",51"ib_rx_cq_call",52"ib_rx_cq_event",53"ib_rx_ring_empty",54"ib_rx_refill_from_cq",55"ib_rx_refill_from_thread",56"ib_rx_alloc_limit",57"ib_rx_credit_updates",58"ib_ack_sent",59"ib_ack_send_failure",60"ib_ack_send_delayed",61"ib_ack_send_piggybacked",62"ib_ack_received",63"ib_rdma_mr_alloc",64"ib_rdma_mr_free",65"ib_rdma_mr_used",66"ib_rdma_mr_pool_flush",67"ib_rdma_mr_pool_wait",68"ib_rdma_mr_pool_depleted",69"ib_atomic_cswp",70"ib_atomic_fadd",71};7273unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,74unsigned int avail)75{76struct rds_ib_statistics stats = {0, };77uint64_t *src;78uint64_t *sum;79size_t i;80int cpu;8182if (avail < ARRAY_SIZE(rds_ib_stat_names))83goto out;8485for_each_online_cpu(cpu) {86src = (uint64_t *)&(per_cpu(rds_ib_stats, cpu));87sum = (uint64_t *)&stats;88for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++)89*(sum++) += *(src++);90}9192rds_stats_info_copy(iter, (uint64_t *)&stats, rds_ib_stat_names,93ARRAY_SIZE(rds_ib_stat_names));94out:95return ARRAY_SIZE(rds_ib_stat_names);96}979899