170041088SAndy Grover /*
270041088SAndy Grover * Copyright (c) 2006 Oracle. All rights reserved.
370041088SAndy Grover *
470041088SAndy Grover * This software is available to you under a choice of one of two
570041088SAndy Grover * licenses. You may choose to be licensed under the terms of the GNU
670041088SAndy Grover * General Public License (GPL) Version 2, available from the file
770041088SAndy Grover * COPYING in the main directory of this source tree, or the
870041088SAndy Grover * OpenIB.org BSD license below:
970041088SAndy Grover *
1070041088SAndy Grover * Redistribution and use in source and binary forms, with or
1170041088SAndy Grover * without modification, are permitted provided that the following
1270041088SAndy Grover * conditions are met:
1370041088SAndy Grover *
1470041088SAndy Grover * - Redistributions of source code must retain the above
1570041088SAndy Grover * copyright notice, this list of conditions and the following
1670041088SAndy Grover * disclaimer.
1770041088SAndy Grover *
1870041088SAndy Grover * - Redistributions in binary form must reproduce the above
1970041088SAndy Grover * copyright notice, this list of conditions and the following
2070041088SAndy Grover * disclaimer in the documentation and/or other materials
2170041088SAndy Grover * provided with the distribution.
2270041088SAndy Grover *
2370041088SAndy Grover * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2470041088SAndy Grover * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2570041088SAndy Grover * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2670041088SAndy Grover * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2770041088SAndy Grover * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2870041088SAndy Grover * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2970041088SAndy Grover * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3070041088SAndy Grover * SOFTWARE.
3170041088SAndy Grover *
3270041088SAndy Grover */
3370041088SAndy Grover #include <linux/percpu.h>
3470041088SAndy Grover #include <linux/seq_file.h>
3570041088SAndy Grover #include <linux/proc_fs.h>
3670041088SAndy Grover
3770041088SAndy Grover #include "rds.h"
3870041088SAndy Grover #include "tcp.h"
3970041088SAndy Grover
4070041088SAndy Grover DEFINE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats)
4170041088SAndy Grover ____cacheline_aligned;
4270041088SAndy Grover
43*3e878b8dSGreg Dietsche static const char * const rds_tcp_stat_names[] = {
4470041088SAndy Grover "tcp_data_ready_calls",
4570041088SAndy Grover "tcp_write_space_calls",
4670041088SAndy Grover "tcp_sndbuf_full",
4770041088SAndy Grover "tcp_connect_raced",
4870041088SAndy Grover "tcp_listen_closed_stale",
4970041088SAndy Grover };
5070041088SAndy Grover
rds_tcp_stats_info_copy(struct rds_info_iterator * iter,unsigned int avail)5170041088SAndy Grover unsigned int rds_tcp_stats_info_copy(struct rds_info_iterator *iter,
5270041088SAndy Grover unsigned int avail)
5370041088SAndy Grover {
5470041088SAndy Grover struct rds_tcp_statistics stats = {0, };
5570041088SAndy Grover uint64_t *src;
5670041088SAndy Grover uint64_t *sum;
5770041088SAndy Grover size_t i;
5870041088SAndy Grover int cpu;
5970041088SAndy Grover
6070041088SAndy Grover if (avail < ARRAY_SIZE(rds_tcp_stat_names))
6170041088SAndy Grover goto out;
6270041088SAndy Grover
6370041088SAndy Grover for_each_online_cpu(cpu) {
6470041088SAndy Grover src = (uint64_t *)&(per_cpu(rds_tcp_stats, cpu));
6570041088SAndy Grover sum = (uint64_t *)&stats;
6670041088SAndy Grover for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++)
6770041088SAndy Grover *(sum++) += *(src++);
6870041088SAndy Grover }
6970041088SAndy Grover
7070041088SAndy Grover rds_stats_info_copy(iter, (uint64_t *)&stats, rds_tcp_stat_names,
7170041088SAndy Grover ARRAY_SIZE(rds_tcp_stat_names));
7270041088SAndy Grover out:
7370041088SAndy Grover return ARRAY_SIZE(rds_tcp_stat_names);
7470041088SAndy Grover }
75