Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2006 Oracle.  All rights reserved.
0003  *
0004  * This software is available to you under a choice of one of two
0005  * licenses.  You may choose to be licensed under the terms of the GNU
0006  * General Public License (GPL) Version 2, available from the file
0007  * COPYING in the main directory of this source tree, or the
0008  * OpenIB.org BSD license below:
0009  *
0010  *     Redistribution and use in source and binary forms, with or
0011  *     without modification, are permitted provided that the following
0012  *     conditions are met:
0013  *
0014  *      - Redistributions of source code must retain the above
0015  *        copyright notice, this list of conditions and the following
0016  *        disclaimer.
0017  *
0018  *      - Redistributions in binary form must reproduce the above
0019  *        copyright notice, this list of conditions and the following
0020  *        disclaimer in the documentation and/or other materials
0021  *        provided with the distribution.
0022  *
0023  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0024  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0025  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0026  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0027  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0028  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0029  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0030  * SOFTWARE.
0031  *
0032  */
0033 #include <linux/percpu.h>
0034 #include <linux/seq_file.h>
0035 #include <linux/proc_fs.h>
0036 
0037 #include "rds.h"
0038 #include "tcp.h"
0039 
0040 DEFINE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats)
0041     ____cacheline_aligned;
0042 
0043 static const char * const rds_tcp_stat_names[] = {
0044     "tcp_data_ready_calls",
0045     "tcp_write_space_calls",
0046     "tcp_sndbuf_full",
0047     "tcp_connect_raced",
0048     "tcp_listen_closed_stale",
0049 };
0050 
0051 unsigned int rds_tcp_stats_info_copy(struct rds_info_iterator *iter,
0052                      unsigned int avail)
0053 {
0054     struct rds_tcp_statistics stats = {0, };
0055     uint64_t *src;
0056     uint64_t *sum;
0057     size_t i;
0058     int cpu;
0059 
0060     if (avail < ARRAY_SIZE(rds_tcp_stat_names))
0061         goto out;
0062 
0063     for_each_online_cpu(cpu) {
0064         src = (uint64_t *)&(per_cpu(rds_tcp_stats, cpu));
0065         sum = (uint64_t *)&stats;
0066         for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++)
0067             *(sum++) += *(src++);
0068     }
0069 
0070     rds_stats_info_copy(iter, (uint64_t *)&stats, rds_tcp_stat_names,
0071                 ARRAY_SIZE(rds_tcp_stat_names));
0072 out:
0073     return ARRAY_SIZE(rds_tcp_stat_names);
0074 }