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 "ib.h"
0039 
0040 DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_ib_statistics, rds_ib_stats);
0041 
0042 static const char *const rds_ib_stat_names[] = {
0043     "ib_connect_raced",
0044     "ib_listen_closed_stale",
0045     "ib_evt_handler_call",
0046     "ib_tasklet_call",
0047     "ib_tx_cq_event",
0048     "ib_tx_ring_full",
0049     "ib_tx_throttle",
0050     "ib_tx_sg_mapping_failure",
0051     "ib_tx_stalled",
0052     "ib_tx_credit_updates",
0053     "ib_rx_cq_event",
0054     "ib_rx_ring_empty",
0055     "ib_rx_refill_from_cq",
0056     "ib_rx_refill_from_thread",
0057     "ib_rx_alloc_limit",
0058     "ib_rx_total_frags",
0059     "ib_rx_total_incs",
0060     "ib_rx_credit_updates",
0061     "ib_ack_sent",
0062     "ib_ack_send_failure",
0063     "ib_ack_send_delayed",
0064     "ib_ack_send_piggybacked",
0065     "ib_ack_received",
0066     "ib_rdma_mr_8k_alloc",
0067     "ib_rdma_mr_8k_free",
0068     "ib_rdma_mr_8k_used",
0069     "ib_rdma_mr_8k_pool_flush",
0070     "ib_rdma_mr_8k_pool_wait",
0071     "ib_rdma_mr_8k_pool_depleted",
0072     "ib_rdma_mr_1m_alloc",
0073     "ib_rdma_mr_1m_free",
0074     "ib_rdma_mr_1m_used",
0075     "ib_rdma_mr_1m_pool_flush",
0076     "ib_rdma_mr_1m_pool_wait",
0077     "ib_rdma_mr_1m_pool_depleted",
0078     "ib_rdma_mr_8k_reused",
0079     "ib_rdma_mr_1m_reused",
0080     "ib_atomic_cswp",
0081     "ib_atomic_fadd",
0082 };
0083 
0084 unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter,
0085                     unsigned int avail)
0086 {
0087     struct rds_ib_statistics stats = {0, };
0088     uint64_t *src;
0089     uint64_t *sum;
0090     size_t i;
0091     int cpu;
0092 
0093     if (avail < ARRAY_SIZE(rds_ib_stat_names))
0094         goto out;
0095 
0096     for_each_online_cpu(cpu) {
0097         src = (uint64_t *)&(per_cpu(rds_ib_stats, cpu));
0098         sum = (uint64_t *)&stats;
0099         for (i = 0; i < sizeof(stats) / sizeof(uint64_t); i++)
0100             *(sum++) += *(src++);
0101     }
0102 
0103     rds_stats_info_copy(iter, (uint64_t *)&stats, rds_ib_stat_names,
0104                 ARRAY_SIZE(rds_ib_stat_names));
0105 out:
0106     return ARRAY_SIZE(rds_ib_stat_names);
0107 }