/*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 "iw.h"3839DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_iw_statistics, rds_iw_stats);4041static const char *const rds_iw_stat_names[] = {42"iw_connect_raced",43"iw_listen_closed_stale",44"iw_tx_cq_call",45"iw_tx_cq_event",46"iw_tx_ring_full",47"iw_tx_throttle",48"iw_tx_sg_mapping_failure",49"iw_tx_stalled",50"iw_tx_credit_updates",51"iw_rx_cq_call",52"iw_rx_cq_event",53"iw_rx_ring_empty",54"iw_rx_refill_from_cq",55"iw_rx_refill_from_thread",56"iw_rx_alloc_limit",57"iw_rx_credit_updates",58"iw_ack_sent",59"iw_ack_send_failure",60"iw_ack_send_delayed",61"iw_ack_send_piggybacked",62"iw_ack_received",63"iw_rdma_mr_alloc",64"iw_rdma_mr_free",65"iw_rdma_mr_used",66"iw_rdma_mr_pool_flush",67"iw_rdma_mr_pool_wait",68"iw_rdma_mr_pool_depleted",69};7071unsigned int rds_iw_stats_info_copy(struct rds_info_iterator *iter,72unsigned int avail)73{74struct rds_iw_statistics stats = {0, };75uint64_t *src;76uint64_t *sum;77size_t i;78int cpu;7980if (avail < ARRAY_SIZE(rds_iw_stat_names))81goto out;8283for_each_online_cpu(cpu) {84src = (uint64_t *)&(per_cpu(rds_iw_stats, cpu));85sum = (uint64_t *)&stats;86for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++)87*(sum++) += *(src++);88}8990rds_stats_info_copy(iter, (uint64_t *)&stats, rds_iw_stat_names,91ARRAY_SIZE(rds_iw_stat_names));92out:93return ARRAY_SIZE(rds_iw_stat_names);94}959697