Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Heiko Carstens | e018ba1 | 2006-02-01 03:06:31 -0800 | [diff] [blame] | 3 | * linux/drivers/s390/net/qeth_fs.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | * Linux on zSeries OSA Express and HiperSockets support |
| 6 | * This file contains code related to procfs. |
| 7 | * |
| 8 | * Copyright 2000,2003 IBM Corporation |
| 9 | * |
| 10 | * Author(s): Thomas Spatzier <tspat@de.ibm.com> |
| 11 | * |
| 12 | */ |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/proc_fs.h> |
| 16 | #include <linux/seq_file.h> |
| 17 | #include <linux/list.h> |
| 18 | #include <linux/rwsem.h> |
| 19 | |
| 20 | #include "qeth.h" |
| 21 | #include "qeth_mpc.h" |
| 22 | #include "qeth_fs.h" |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | /***** /proc/qeth *****/ |
| 25 | #define QETH_PROCFILE_NAME "qeth" |
| 26 | static struct proc_dir_entry *qeth_procfile; |
| 27 | |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 28 | static int |
| 29 | qeth_procfile_seq_match(struct device *dev, void *data) |
| 30 | { |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 31 | return(dev ? 1 : 0); |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | static void * |
| 35 | qeth_procfile_seq_start(struct seq_file *s, loff_t *offset) |
| 36 | { |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 37 | struct device *dev = NULL; |
| 38 | loff_t nr = 0; |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem); |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 41 | if (*offset == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | return SEQ_START_TOKEN; |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 43 | while (1) { |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 44 | dev = driver_find_device(&qeth_ccwgroup_driver.driver, dev, |
| 45 | NULL, qeth_procfile_seq_match); |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 46 | if (++nr == *offset) |
| 47 | break; |
| 48 | put_device(dev); |
| 49 | } |
| 50 | return dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | static void |
| 54 | qeth_procfile_seq_stop(struct seq_file *s, void* it) |
| 55 | { |
| 56 | up_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem); |
| 57 | } |
| 58 | |
| 59 | static void * |
| 60 | qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset) |
| 61 | { |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 62 | struct device *prev, *next; |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 63 | |
| 64 | if (it == SEQ_START_TOKEN) |
| 65 | prev = NULL; |
| 66 | else |
| 67 | prev = (struct device *) it; |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 68 | next = driver_find_device(&qeth_ccwgroup_driver.driver, |
| 69 | prev, NULL, qeth_procfile_seq_match); |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 70 | (*offset)++; |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 71 | return (void *) next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | static inline const char * |
| 75 | qeth_get_router_str(struct qeth_card *card, int ipv) |
| 76 | { |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 77 | enum qeth_routing_types routing_type = NO_ROUTER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 79 | if (ipv == 4) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | routing_type = card->options.route4.type; |
| 81 | } else { |
| 82 | #ifdef CONFIG_QETH_IPV6 |
| 83 | routing_type = card->options.route6.type; |
| 84 | #else |
| 85 | return "n/a"; |
| 86 | #endif /* CONFIG_QETH_IPV6 */ |
| 87 | } |
| 88 | |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 89 | switch (routing_type){ |
| 90 | case PRIMARY_ROUTER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | return "pri"; |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 92 | case SECONDARY_ROUTER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | return "sec"; |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 94 | case MULTICAST_ROUTER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) |
| 96 | return "mc+"; |
| 97 | return "mc"; |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 98 | case PRIMARY_CONNECTOR: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) |
| 100 | return "p+c"; |
| 101 | return "p.c"; |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 102 | case SECONDARY_CONNECTOR: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) |
| 104 | return "s+c"; |
| 105 | return "s.c"; |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 106 | default: /* NO_ROUTER */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | return "no"; |
Frank Pavlic | 1380fee | 2006-03-22 16:03:41 +0100 | [diff] [blame] | 108 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | static int |
| 112 | qeth_procfile_seq_show(struct seq_file *s, void *it) |
| 113 | { |
| 114 | struct device *device; |
| 115 | struct qeth_card *card; |
| 116 | char tmp[12]; /* for qeth_get_prioq_str */ |
| 117 | |
| 118 | if (it == SEQ_START_TOKEN){ |
| 119 | seq_printf(s, "devices CHPID interface " |
| 120 | "cardtype port chksum prio-q'ing rtr4 " |
| 121 | "rtr6 fsz cnt\n"); |
| 122 | seq_printf(s, "-------------------------- ----- ---------- " |
| 123 | "-------------- ---- ------ ---------- ---- " |
| 124 | "---- ----- -----\n"); |
| 125 | } else { |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 126 | device = (struct device *) it; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | card = device->driver_data; |
| 128 | seq_printf(s, "%s/%s/%s x%02X %-10s %-14s %-4i ", |
| 129 | CARD_RDEV_ID(card), |
| 130 | CARD_WDEV_ID(card), |
| 131 | CARD_DDEV_ID(card), |
| 132 | card->info.chpid, |
| 133 | QETH_CARD_IFNAME(card), |
| 134 | qeth_get_cardname_short(card), |
| 135 | card->info.portno); |
| 136 | if (card->lan_online) |
| 137 | seq_printf(s, "%-6s %-10s %-4s %-4s %-5s %-5i\n", |
| 138 | qeth_get_checksum_str(card), |
| 139 | qeth_get_prioq_str(card, tmp), |
| 140 | qeth_get_router_str(card, 4), |
| 141 | qeth_get_router_str(card, 6), |
| 142 | qeth_get_bufsize_str(card), |
| 143 | card->qdio.in_buf_pool.buf_count); |
| 144 | else |
| 145 | seq_printf(s, " +++ LAN OFFLINE +++\n"); |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 146 | put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | } |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | static struct seq_operations qeth_procfile_seq_ops = { |
| 152 | .start = qeth_procfile_seq_start, |
| 153 | .stop = qeth_procfile_seq_stop, |
| 154 | .next = qeth_procfile_seq_next, |
| 155 | .show = qeth_procfile_seq_show, |
| 156 | }; |
| 157 | |
| 158 | static int |
| 159 | qeth_procfile_open(struct inode *inode, struct file *file) |
| 160 | { |
| 161 | return seq_open(file, &qeth_procfile_seq_ops); |
| 162 | } |
| 163 | |
| 164 | static struct file_operations qeth_procfile_fops = { |
| 165 | .owner = THIS_MODULE, |
| 166 | .open = qeth_procfile_open, |
| 167 | .read = seq_read, |
| 168 | .llseek = seq_lseek, |
| 169 | .release = seq_release, |
| 170 | }; |
| 171 | |
| 172 | /***** /proc/qeth_perf *****/ |
| 173 | #define QETH_PERF_PROCFILE_NAME "qeth_perf" |
| 174 | static struct proc_dir_entry *qeth_perf_procfile; |
| 175 | |
| 176 | #ifdef CONFIG_QETH_PERF_STATS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | static int |
| 178 | qeth_perf_procfile_seq_show(struct seq_file *s, void *it) |
| 179 | { |
| 180 | struct device *device; |
| 181 | struct qeth_card *card; |
| 182 | |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 183 | |
| 184 | if (it == SEQ_START_TOKEN) |
| 185 | return 0; |
| 186 | |
Cornelia Huck | 66aea23 | 2005-08-08 09:22:36 -0700 | [diff] [blame] | 187 | device = (struct device *) it; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | card = device->driver_data; |
| 189 | seq_printf(s, "For card with devnos %s/%s/%s (%s):\n", |
| 190 | CARD_RDEV_ID(card), |
| 191 | CARD_WDEV_ID(card), |
| 192 | CARD_DDEV_ID(card), |
| 193 | QETH_CARD_IFNAME(card) |
| 194 | ); |
Frank Pavlic | 95f6b5a | 2006-03-22 16:03:39 +0100 | [diff] [blame] | 195 | seq_printf(s, " Skb's/buffers received : %lu/%u\n" |
| 196 | " Skb's/buffers sent : %lu/%u\n\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | card->stats.rx_packets, card->perf_stats.bufs_rec, |
| 198 | card->stats.tx_packets, card->perf_stats.bufs_sent |
| 199 | ); |
Frank Pavlic | 95f6b5a | 2006-03-22 16:03:39 +0100 | [diff] [blame] | 200 | seq_printf(s, " Skb's/buffers sent without packing : %lu/%u\n" |
| 201 | " Skb's/buffers sent with packing : %u/%u\n\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | card->stats.tx_packets - card->perf_stats.skbs_sent_pack, |
| 203 | card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack, |
| 204 | card->perf_stats.skbs_sent_pack, |
| 205 | card->perf_stats.bufs_sent_pack |
| 206 | ); |
Frank Pavlic | 95f6b5a | 2006-03-22 16:03:39 +0100 | [diff] [blame] | 207 | seq_printf(s, " Skbs sent in SG mode : %u\n" |
| 208 | " Skb fragments sent in SG mode : %u\n\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | card->perf_stats.sg_skbs_sent, |
| 210 | card->perf_stats.sg_frags_sent); |
Frank Pavlic | 95f6b5a | 2006-03-22 16:03:39 +0100 | [diff] [blame] | 211 | seq_printf(s, " large_send tx (in Kbytes) : %u\n" |
| 212 | " large_send count : %u\n\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | card->perf_stats.large_send_bytes >> 10, |
| 214 | card->perf_stats.large_send_cnt); |
Frank Pavlic | 95f6b5a | 2006-03-22 16:03:39 +0100 | [diff] [blame] | 215 | seq_printf(s, " Packing state changes no pkg.->packing : %u/%u\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | " Watermarks L/H : %i/%i\n" |
| 217 | " Current buffer usage (outbound q's) : " |
| 218 | "%i/%i/%i/%i\n\n", |
| 219 | card->perf_stats.sc_dp_p, card->perf_stats.sc_p_dp, |
| 220 | QETH_LOW_WATERMARK_PACK, QETH_HIGH_WATERMARK_PACK, |
| 221 | atomic_read(&card->qdio.out_qs[0]->used_buffers), |
| 222 | (card->qdio.no_out_queues > 1)? |
| 223 | atomic_read(&card->qdio.out_qs[1]->used_buffers) |
| 224 | : 0, |
| 225 | (card->qdio.no_out_queues > 2)? |
| 226 | atomic_read(&card->qdio.out_qs[2]->used_buffers) |
| 227 | : 0, |
| 228 | (card->qdio.no_out_queues > 3)? |
| 229 | atomic_read(&card->qdio.out_qs[3]->used_buffers) |
| 230 | : 0 |
| 231 | ); |
Frank Pavlic | 95f6b5a | 2006-03-22 16:03:39 +0100 | [diff] [blame] | 232 | seq_printf(s, " Inbound handler time (in us) : %u\n" |
| 233 | " Inbound handler count : %u\n" |
| 234 | " Inbound do_QDIO time (in us) : %u\n" |
| 235 | " Inbound do_QDIO count : %u\n\n" |
| 236 | " Outbound handler time (in us) : %u\n" |
| 237 | " Outbound handler count : %u\n\n" |
| 238 | " Outbound time (in us, incl QDIO) : %u\n" |
| 239 | " Outbound count : %u\n" |
| 240 | " Outbound do_QDIO time (in us) : %u\n" |
| 241 | " Outbound do_QDIO count : %u\n\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | card->perf_stats.inbound_time, |
| 243 | card->perf_stats.inbound_cnt, |
| 244 | card->perf_stats.inbound_do_qdio_time, |
| 245 | card->perf_stats.inbound_do_qdio_cnt, |
| 246 | card->perf_stats.outbound_handler_time, |
| 247 | card->perf_stats.outbound_handler_cnt, |
| 248 | card->perf_stats.outbound_time, |
| 249 | card->perf_stats.outbound_cnt, |
| 250 | card->perf_stats.outbound_do_qdio_time, |
| 251 | card->perf_stats.outbound_do_qdio_cnt |
| 252 | ); |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 253 | put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | static struct seq_operations qeth_perf_procfile_seq_ops = { |
Frank Pavlic | 3df3cc6 | 2005-12-13 08:23:26 +0100 | [diff] [blame] | 258 | .start = qeth_procfile_seq_start, |
| 259 | .stop = qeth_procfile_seq_stop, |
| 260 | .next = qeth_procfile_seq_next, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | .show = qeth_perf_procfile_seq_show, |
| 262 | }; |
| 263 | |
| 264 | static int |
| 265 | qeth_perf_procfile_open(struct inode *inode, struct file *file) |
| 266 | { |
| 267 | return seq_open(file, &qeth_perf_procfile_seq_ops); |
| 268 | } |
| 269 | |
| 270 | static struct file_operations qeth_perf_procfile_fops = { |
| 271 | .owner = THIS_MODULE, |
| 272 | .open = qeth_perf_procfile_open, |
| 273 | .read = seq_read, |
| 274 | .llseek = seq_lseek, |
| 275 | .release = seq_release, |
| 276 | }; |
| 277 | |
| 278 | #define qeth_perf_procfile_created qeth_perf_procfile |
| 279 | #else |
| 280 | #define qeth_perf_procfile_created 1 |
| 281 | #endif /* CONFIG_QETH_PERF_STATS */ |
| 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | int __init |
| 284 | qeth_create_procfs_entries(void) |
| 285 | { |
| 286 | qeth_procfile = create_proc_entry(QETH_PROCFILE_NAME, |
| 287 | S_IFREG | 0444, NULL); |
| 288 | if (qeth_procfile) |
| 289 | qeth_procfile->proc_fops = &qeth_procfile_fops; |
| 290 | |
| 291 | #ifdef CONFIG_QETH_PERF_STATS |
| 292 | qeth_perf_procfile = create_proc_entry(QETH_PERF_PROCFILE_NAME, |
| 293 | S_IFREG | 0444, NULL); |
| 294 | if (qeth_perf_procfile) |
| 295 | qeth_perf_procfile->proc_fops = &qeth_perf_procfile_fops; |
| 296 | #endif /* CONFIG_QETH_PERF_STATS */ |
| 297 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | if (qeth_procfile && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | qeth_perf_procfile_created) |
| 300 | return 0; |
| 301 | else |
| 302 | return -ENOMEM; |
| 303 | } |
| 304 | |
| 305 | void __exit |
| 306 | qeth_remove_procfs_entries(void) |
| 307 | { |
| 308 | if (qeth_procfile) |
| 309 | remove_proc_entry(QETH_PROCFILE_NAME, NULL); |
| 310 | if (qeth_perf_procfile) |
| 311 | remove_proc_entry(QETH_PERF_PROCFILE_NAME, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | } |
| 313 | |