Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * iSeries_proc.c |
| 3 | * Copyright (C) 2001 Kyle A. Lucke IBM Corporation |
| 4 | * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/proc_fs.h> |
| 22 | #include <linux/seq_file.h> |
| 23 | #include <linux/param.h> /* for HZ */ |
| 24 | #include <asm/paca.h> |
| 25 | #include <asm/processor.h> |
| 26 | #include <asm/time.h> |
| 27 | #include <asm/lppaca.h> |
| 28 | #include <asm/iSeries/ItLpQueue.h> |
| 29 | #include <asm/iSeries/HvCallXm.h> |
| 30 | #include <asm/iSeries/IoHriMainStore.h> |
| 31 | #include <asm/iSeries/LparData.h> |
| 32 | #include <asm/iSeries/iSeries_proc.h> |
| 33 | |
| 34 | static int __init iseries_proc_create(void) |
| 35 | { |
| 36 | struct proc_dir_entry *e = proc_mkdir("iSeries", 0); |
| 37 | if (!e) |
| 38 | return 1; |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | core_initcall(iseries_proc_create); |
| 43 | |
| 44 | static char *event_types[9] = { |
| 45 | "Hypervisor\t\t", |
| 46 | "Machine Facilities\t", |
| 47 | "Session Manager\t", |
| 48 | "SPD I/O\t\t", |
| 49 | "Virtual Bus\t\t", |
| 50 | "PCI I/O\t\t", |
| 51 | "RIO I/O\t\t", |
| 52 | "Virtual Lan\t\t", |
| 53 | "Virtual I/O\t\t" |
| 54 | }; |
| 55 | |
| 56 | static int proc_lpevents_show(struct seq_file *m, void *v) |
| 57 | { |
| 58 | unsigned int i; |
| 59 | |
| 60 | seq_printf(m, "LpEventQueue 0\n"); |
| 61 | seq_printf(m, " events processed:\t%lu\n", |
| 62 | (unsigned long)xItLpQueue.xLpIntCount); |
| 63 | |
| 64 | for (i = 0; i < 9; ++i) |
| 65 | seq_printf(m, " %s %10lu\n", event_types[i], |
| 66 | (unsigned long)xItLpQueue.xLpIntCountByType[i]); |
| 67 | |
| 68 | seq_printf(m, "\n events processed by processor:\n"); |
| 69 | |
| 70 | for_each_online_cpu(i) |
| 71 | seq_printf(m, " CPU%02d %10u\n", i, paca[i].lpevent_count); |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | static int proc_lpevents_open(struct inode *inode, struct file *file) |
| 77 | { |
| 78 | return single_open(file, proc_lpevents_show, NULL); |
| 79 | } |
| 80 | |
| 81 | static struct file_operations proc_lpevents_operations = { |
| 82 | .open = proc_lpevents_open, |
| 83 | .read = seq_read, |
| 84 | .llseek = seq_lseek, |
| 85 | .release = single_release, |
| 86 | }; |
| 87 | |
| 88 | static unsigned long startTitan = 0; |
| 89 | static unsigned long startTb = 0; |
| 90 | |
| 91 | static int proc_titantod_show(struct seq_file *m, void *v) |
| 92 | { |
| 93 | unsigned long tb0, titan_tod; |
| 94 | |
| 95 | tb0 = get_tb(); |
| 96 | titan_tod = HvCallXm_loadTod(); |
| 97 | |
| 98 | seq_printf(m, "Titan\n" ); |
| 99 | seq_printf(m, " time base = %016lx\n", tb0); |
| 100 | seq_printf(m, " titan tod = %016lx\n", titan_tod); |
| 101 | seq_printf(m, " xProcFreq = %016x\n", |
| 102 | xIoHriProcessorVpd[0].xProcFreq); |
| 103 | seq_printf(m, " xTimeBaseFreq = %016x\n", |
| 104 | xIoHriProcessorVpd[0].xTimeBaseFreq); |
| 105 | seq_printf(m, " tb_ticks_per_jiffy = %lu\n", tb_ticks_per_jiffy); |
| 106 | seq_printf(m, " tb_ticks_per_usec = %lu\n", tb_ticks_per_usec); |
| 107 | |
| 108 | if (!startTitan) { |
| 109 | startTitan = titan_tod; |
| 110 | startTb = tb0; |
| 111 | } else { |
| 112 | unsigned long titan_usec = (titan_tod - startTitan) >> 12; |
| 113 | unsigned long tb_ticks = (tb0 - startTb); |
| 114 | unsigned long titan_jiffies = titan_usec / (1000000/HZ); |
| 115 | unsigned long titan_jiff_usec = titan_jiffies * (1000000/HZ); |
| 116 | unsigned long titan_jiff_rem_usec = titan_usec - titan_jiff_usec; |
| 117 | unsigned long tb_jiffies = tb_ticks / tb_ticks_per_jiffy; |
| 118 | unsigned long tb_jiff_ticks = tb_jiffies * tb_ticks_per_jiffy; |
| 119 | unsigned long tb_jiff_rem_ticks = tb_ticks - tb_jiff_ticks; |
| 120 | unsigned long tb_jiff_rem_usec = tb_jiff_rem_ticks / tb_ticks_per_usec; |
| 121 | unsigned long new_tb_ticks_per_jiffy = (tb_ticks * (1000000/HZ))/titan_usec; |
| 122 | |
| 123 | seq_printf(m, " titan elapsed = %lu uSec\n", titan_usec); |
| 124 | seq_printf(m, " tb elapsed = %lu ticks\n", tb_ticks); |
| 125 | seq_printf(m, " titan jiffies = %lu.%04lu \n", titan_jiffies, |
| 126 | titan_jiff_rem_usec); |
| 127 | seq_printf(m, " tb jiffies = %lu.%04lu\n", tb_jiffies, |
| 128 | tb_jiff_rem_usec); |
| 129 | seq_printf(m, " new tb_ticks_per_jiffy = %lu\n", |
| 130 | new_tb_ticks_per_jiffy); |
| 131 | } |
| 132 | |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | static int proc_titantod_open(struct inode *inode, struct file *file) |
| 137 | { |
| 138 | return single_open(file, proc_titantod_show, NULL); |
| 139 | } |
| 140 | |
| 141 | static struct file_operations proc_titantod_operations = { |
| 142 | .open = proc_titantod_open, |
| 143 | .read = seq_read, |
| 144 | .llseek = seq_lseek, |
| 145 | .release = single_release, |
| 146 | }; |
| 147 | |
| 148 | static int __init iseries_proc_init(void) |
| 149 | { |
| 150 | struct proc_dir_entry *e; |
| 151 | |
| 152 | e = create_proc_entry("iSeries/lpevents", S_IFREG|S_IRUGO, NULL); |
| 153 | if (e) |
| 154 | e->proc_fops = &proc_lpevents_operations; |
| 155 | |
| 156 | e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL); |
| 157 | if (e) |
| 158 | e->proc_fops = &proc_titantod_operations; |
| 159 | |
| 160 | return 0; |
| 161 | } |
| 162 | __initcall(iseries_proc_init); |