/*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 "tcp.h"3839DEFINE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats)40____cacheline_aligned;4142static const char const *rds_tcp_stat_names[] = {43"tcp_data_ready_calls",44"tcp_write_space_calls",45"tcp_sndbuf_full",46"tcp_connect_raced",47"tcp_listen_closed_stale",48};4950unsigned int rds_tcp_stats_info_copy(struct rds_info_iterator *iter,51unsigned int avail)52{53struct rds_tcp_statistics stats = {0, };54uint64_t *src;55uint64_t *sum;56size_t i;57int cpu;5859if (avail < ARRAY_SIZE(rds_tcp_stat_names))60goto out;6162for_each_online_cpu(cpu) {63src = (uint64_t *)&(per_cpu(rds_tcp_stats, cpu));64sum = (uint64_t *)&stats;65for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++)66*(sum++) += *(src++);67}6869rds_stats_info_copy(iter, (uint64_t *)&stats, rds_tcp_stat_names,70ARRAY_SIZE(rds_tcp_stat_names));71out:72return ARRAY_SIZE(rds_tcp_stat_names);73}747576