18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2006 Oracle. All rights reserved. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 58c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 68c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 78c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 88c2ecf20Sopenharmony_ci * OpenIB.org BSD license below: 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or 118c2ecf20Sopenharmony_ci * without modification, are permitted provided that the following 128c2ecf20Sopenharmony_ci * conditions are met: 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above 158c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 168c2ecf20Sopenharmony_ci * disclaimer. 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above 198c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 208c2ecf20Sopenharmony_ci * disclaimer in the documentation and/or other materials 218c2ecf20Sopenharmony_ci * provided with the distribution. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 248c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 258c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 268c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 278c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 288c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 298c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 308c2ecf20Sopenharmony_ci * SOFTWARE. 318c2ecf20Sopenharmony_ci * 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_ci#include <linux/percpu.h> 348c2ecf20Sopenharmony_ci#include <linux/seq_file.h> 358c2ecf20Sopenharmony_ci#include <linux/proc_fs.h> 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#include "rds.h" 388c2ecf20Sopenharmony_ci#include "tcp.h" 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciDEFINE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats) 418c2ecf20Sopenharmony_ci ____cacheline_aligned; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistatic const char * const rds_tcp_stat_names[] = { 448c2ecf20Sopenharmony_ci "tcp_data_ready_calls", 458c2ecf20Sopenharmony_ci "tcp_write_space_calls", 468c2ecf20Sopenharmony_ci "tcp_sndbuf_full", 478c2ecf20Sopenharmony_ci "tcp_connect_raced", 488c2ecf20Sopenharmony_ci "tcp_listen_closed_stale", 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciunsigned int rds_tcp_stats_info_copy(struct rds_info_iterator *iter, 528c2ecf20Sopenharmony_ci unsigned int avail) 538c2ecf20Sopenharmony_ci{ 548c2ecf20Sopenharmony_ci struct rds_tcp_statistics stats = {0, }; 558c2ecf20Sopenharmony_ci uint64_t *src; 568c2ecf20Sopenharmony_ci uint64_t *sum; 578c2ecf20Sopenharmony_ci size_t i; 588c2ecf20Sopenharmony_ci int cpu; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci if (avail < ARRAY_SIZE(rds_tcp_stat_names)) 618c2ecf20Sopenharmony_ci goto out; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci for_each_online_cpu(cpu) { 648c2ecf20Sopenharmony_ci src = (uint64_t *)&(per_cpu(rds_tcp_stats, cpu)); 658c2ecf20Sopenharmony_ci sum = (uint64_t *)&stats; 668c2ecf20Sopenharmony_ci for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++) 678c2ecf20Sopenharmony_ci *(sum++) += *(src++); 688c2ecf20Sopenharmony_ci } 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci rds_stats_info_copy(iter, (uint64_t *)&stats, rds_tcp_stat_names, 718c2ecf20Sopenharmony_ci ARRAY_SIZE(rds_tcp_stat_names)); 728c2ecf20Sopenharmony_ciout: 738c2ecf20Sopenharmony_ci return ARRAY_SIZE(rds_tcp_stat_names); 748c2ecf20Sopenharmony_ci} 75