ia64/linux-2.6.18-xen.hg

view net/rxrpc/proc.c @ 673:3161879fdf22

[IA64] xencomm: support XENMEM_add_to_physmap and XENMEM_remove_from_phsymap

support XENMEM_add_to_physmap and XENMEM_remove_from_phsymap.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Tue Sep 16 21:26:15 2008 +0900 (2008-09-16)
parents 831230e53067
children
line source
1 /* proc.c: /proc interface for RxRPC
2 *
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
12 #include <linux/sched.h>
13 #include <linux/slab.h>
14 #include <linux/module.h>
15 #include <linux/proc_fs.h>
16 #include <linux/seq_file.h>
17 #include <rxrpc/rxrpc.h>
18 #include <rxrpc/transport.h>
19 #include <rxrpc/peer.h>
20 #include <rxrpc/connection.h>
21 #include <rxrpc/call.h>
22 #include <rxrpc/message.h>
23 #include "internal.h"
25 static struct proc_dir_entry *proc_rxrpc;
27 static int rxrpc_proc_transports_open(struct inode *inode, struct file *file);
28 static void *rxrpc_proc_transports_start(struct seq_file *p, loff_t *pos);
29 static void *rxrpc_proc_transports_next(struct seq_file *p, void *v, loff_t *pos);
30 static void rxrpc_proc_transports_stop(struct seq_file *p, void *v);
31 static int rxrpc_proc_transports_show(struct seq_file *m, void *v);
33 static struct seq_operations rxrpc_proc_transports_ops = {
34 .start = rxrpc_proc_transports_start,
35 .next = rxrpc_proc_transports_next,
36 .stop = rxrpc_proc_transports_stop,
37 .show = rxrpc_proc_transports_show,
38 };
40 static struct file_operations rxrpc_proc_transports_fops = {
41 .open = rxrpc_proc_transports_open,
42 .read = seq_read,
43 .llseek = seq_lseek,
44 .release = seq_release,
45 };
47 static int rxrpc_proc_peers_open(struct inode *inode, struct file *file);
48 static void *rxrpc_proc_peers_start(struct seq_file *p, loff_t *pos);
49 static void *rxrpc_proc_peers_next(struct seq_file *p, void *v, loff_t *pos);
50 static void rxrpc_proc_peers_stop(struct seq_file *p, void *v);
51 static int rxrpc_proc_peers_show(struct seq_file *m, void *v);
53 static struct seq_operations rxrpc_proc_peers_ops = {
54 .start = rxrpc_proc_peers_start,
55 .next = rxrpc_proc_peers_next,
56 .stop = rxrpc_proc_peers_stop,
57 .show = rxrpc_proc_peers_show,
58 };
60 static struct file_operations rxrpc_proc_peers_fops = {
61 .open = rxrpc_proc_peers_open,
62 .read = seq_read,
63 .llseek = seq_lseek,
64 .release = seq_release,
65 };
67 static int rxrpc_proc_conns_open(struct inode *inode, struct file *file);
68 static void *rxrpc_proc_conns_start(struct seq_file *p, loff_t *pos);
69 static void *rxrpc_proc_conns_next(struct seq_file *p, void *v, loff_t *pos);
70 static void rxrpc_proc_conns_stop(struct seq_file *p, void *v);
71 static int rxrpc_proc_conns_show(struct seq_file *m, void *v);
73 static struct seq_operations rxrpc_proc_conns_ops = {
74 .start = rxrpc_proc_conns_start,
75 .next = rxrpc_proc_conns_next,
76 .stop = rxrpc_proc_conns_stop,
77 .show = rxrpc_proc_conns_show,
78 };
80 static struct file_operations rxrpc_proc_conns_fops = {
81 .open = rxrpc_proc_conns_open,
82 .read = seq_read,
83 .llseek = seq_lseek,
84 .release = seq_release,
85 };
87 static int rxrpc_proc_calls_open(struct inode *inode, struct file *file);
88 static void *rxrpc_proc_calls_start(struct seq_file *p, loff_t *pos);
89 static void *rxrpc_proc_calls_next(struct seq_file *p, void *v, loff_t *pos);
90 static void rxrpc_proc_calls_stop(struct seq_file *p, void *v);
91 static int rxrpc_proc_calls_show(struct seq_file *m, void *v);
93 static struct seq_operations rxrpc_proc_calls_ops = {
94 .start = rxrpc_proc_calls_start,
95 .next = rxrpc_proc_calls_next,
96 .stop = rxrpc_proc_calls_stop,
97 .show = rxrpc_proc_calls_show,
98 };
100 static struct file_operations rxrpc_proc_calls_fops = {
101 .open = rxrpc_proc_calls_open,
102 .read = seq_read,
103 .llseek = seq_lseek,
104 .release = seq_release,
105 };
107 static const char *rxrpc_call_states7[] = {
108 "complet",
109 "error ",
110 "rcv_op ",
111 "rcv_arg",
112 "got_arg",
113 "snd_rpl",
114 "fin_ack",
115 "snd_arg",
116 "rcv_rpl",
117 "got_rpl"
118 };
120 static const char *rxrpc_call_error_states7[] = {
121 "no_err ",
122 "loc_abt",
123 "rmt_abt",
124 "loc_err",
125 "rmt_err"
126 };
128 /*****************************************************************************/
129 /*
130 * initialise the /proc/net/rxrpc/ directory
131 */
132 int rxrpc_proc_init(void)
133 {
134 struct proc_dir_entry *p;
136 proc_rxrpc = proc_mkdir("rxrpc", proc_net);
137 if (!proc_rxrpc)
138 goto error;
139 proc_rxrpc->owner = THIS_MODULE;
141 p = create_proc_entry("calls", 0, proc_rxrpc);
142 if (!p)
143 goto error_proc;
144 p->proc_fops = &rxrpc_proc_calls_fops;
145 p->owner = THIS_MODULE;
147 p = create_proc_entry("connections", 0, proc_rxrpc);
148 if (!p)
149 goto error_calls;
150 p->proc_fops = &rxrpc_proc_conns_fops;
151 p->owner = THIS_MODULE;
153 p = create_proc_entry("peers", 0, proc_rxrpc);
154 if (!p)
155 goto error_calls;
156 p->proc_fops = &rxrpc_proc_peers_fops;
157 p->owner = THIS_MODULE;
159 p = create_proc_entry("transports", 0, proc_rxrpc);
160 if (!p)
161 goto error_conns;
162 p->proc_fops = &rxrpc_proc_transports_fops;
163 p->owner = THIS_MODULE;
165 return 0;
167 error_conns:
168 remove_proc_entry("connections", proc_rxrpc);
169 error_calls:
170 remove_proc_entry("calls", proc_rxrpc);
171 error_proc:
172 remove_proc_entry("rxrpc", proc_net);
173 error:
174 return -ENOMEM;
175 } /* end rxrpc_proc_init() */
177 /*****************************************************************************/
178 /*
179 * clean up the /proc/net/rxrpc/ directory
180 */
181 void rxrpc_proc_cleanup(void)
182 {
183 remove_proc_entry("transports", proc_rxrpc);
184 remove_proc_entry("peers", proc_rxrpc);
185 remove_proc_entry("connections", proc_rxrpc);
186 remove_proc_entry("calls", proc_rxrpc);
188 remove_proc_entry("rxrpc", proc_net);
190 } /* end rxrpc_proc_cleanup() */
192 /*****************************************************************************/
193 /*
194 * open "/proc/net/rxrpc/transports" which provides a summary of extant transports
195 */
196 static int rxrpc_proc_transports_open(struct inode *inode, struct file *file)
197 {
198 struct seq_file *m;
199 int ret;
201 ret = seq_open(file, &rxrpc_proc_transports_ops);
202 if (ret < 0)
203 return ret;
205 m = file->private_data;
206 m->private = PDE(inode)->data;
208 return 0;
209 } /* end rxrpc_proc_transports_open() */
211 /*****************************************************************************/
212 /*
213 * set up the iterator to start reading from the transports list and return the first item
214 */
215 static void *rxrpc_proc_transports_start(struct seq_file *m, loff_t *_pos)
216 {
217 struct list_head *_p;
218 loff_t pos = *_pos;
220 /* lock the list against modification */
221 down_read(&rxrpc_proc_transports_sem);
223 /* allow for the header line */
224 if (!pos)
225 return SEQ_START_TOKEN;
226 pos--;
228 /* find the n'th element in the list */
229 list_for_each(_p, &rxrpc_proc_transports)
230 if (!pos--)
231 break;
233 return _p != &rxrpc_proc_transports ? _p : NULL;
234 } /* end rxrpc_proc_transports_start() */
236 /*****************************************************************************/
237 /*
238 * move to next call in transports list
239 */
240 static void *rxrpc_proc_transports_next(struct seq_file *p, void *v, loff_t *pos)
241 {
242 struct list_head *_p;
244 (*pos)++;
246 _p = v;
247 _p = (v == SEQ_START_TOKEN) ? rxrpc_proc_transports.next : _p->next;
249 return _p != &rxrpc_proc_transports ? _p : NULL;
250 } /* end rxrpc_proc_transports_next() */
252 /*****************************************************************************/
253 /*
254 * clean up after reading from the transports list
255 */
256 static void rxrpc_proc_transports_stop(struct seq_file *p, void *v)
257 {
258 up_read(&rxrpc_proc_transports_sem);
260 } /* end rxrpc_proc_transports_stop() */
262 /*****************************************************************************/
263 /*
264 * display a header line followed by a load of call lines
265 */
266 static int rxrpc_proc_transports_show(struct seq_file *m, void *v)
267 {
268 struct rxrpc_transport *trans =
269 list_entry(v, struct rxrpc_transport, proc_link);
271 /* display header on line 1 */
272 if (v == SEQ_START_TOKEN) {
273 seq_puts(m, "LOCAL USE\n");
274 return 0;
275 }
277 /* display one transport per line on subsequent lines */
278 seq_printf(m, "%5hu %3d\n",
279 trans->port,
280 atomic_read(&trans->usage)
281 );
283 return 0;
284 } /* end rxrpc_proc_transports_show() */
286 /*****************************************************************************/
287 /*
288 * open "/proc/net/rxrpc/peers" which provides a summary of extant peers
289 */
290 static int rxrpc_proc_peers_open(struct inode *inode, struct file *file)
291 {
292 struct seq_file *m;
293 int ret;
295 ret = seq_open(file, &rxrpc_proc_peers_ops);
296 if (ret < 0)
297 return ret;
299 m = file->private_data;
300 m->private = PDE(inode)->data;
302 return 0;
303 } /* end rxrpc_proc_peers_open() */
305 /*****************************************************************************/
306 /*
307 * set up the iterator to start reading from the peers list and return the
308 * first item
309 */
310 static void *rxrpc_proc_peers_start(struct seq_file *m, loff_t *_pos)
311 {
312 struct list_head *_p;
313 loff_t pos = *_pos;
315 /* lock the list against modification */
316 down_read(&rxrpc_peers_sem);
318 /* allow for the header line */
319 if (!pos)
320 return SEQ_START_TOKEN;
321 pos--;
323 /* find the n'th element in the list */
324 list_for_each(_p, &rxrpc_peers)
325 if (!pos--)
326 break;
328 return _p != &rxrpc_peers ? _p : NULL;
329 } /* end rxrpc_proc_peers_start() */
331 /*****************************************************************************/
332 /*
333 * move to next conn in peers list
334 */
335 static void *rxrpc_proc_peers_next(struct seq_file *p, void *v, loff_t *pos)
336 {
337 struct list_head *_p;
339 (*pos)++;
341 _p = v;
342 _p = (v == SEQ_START_TOKEN) ? rxrpc_peers.next : _p->next;
344 return _p != &rxrpc_peers ? _p : NULL;
345 } /* end rxrpc_proc_peers_next() */
347 /*****************************************************************************/
348 /*
349 * clean up after reading from the peers list
350 */
351 static void rxrpc_proc_peers_stop(struct seq_file *p, void *v)
352 {
353 up_read(&rxrpc_peers_sem);
355 } /* end rxrpc_proc_peers_stop() */
357 /*****************************************************************************/
358 /*
359 * display a header line followed by a load of conn lines
360 */
361 static int rxrpc_proc_peers_show(struct seq_file *m, void *v)
362 {
363 struct rxrpc_peer *peer = list_entry(v, struct rxrpc_peer, proc_link);
364 long timeout;
366 /* display header on line 1 */
367 if (v == SEQ_START_TOKEN) {
368 seq_puts(m, "LOCAL REMOTE USAGE CONNS TIMEOUT"
369 " MTU RTT(uS)\n");
370 return 0;
371 }
373 /* display one peer per line on subsequent lines */
374 timeout = 0;
375 if (!list_empty(&peer->timeout.link))
376 timeout = (long) peer->timeout.timo_jif -
377 (long) jiffies;
379 seq_printf(m, "%5hu %08x %5d %5d %8ld %5Zu %7lu\n",
380 peer->trans->port,
381 ntohl(peer->addr.s_addr),
382 atomic_read(&peer->usage),
383 atomic_read(&peer->conn_count),
384 timeout,
385 peer->if_mtu,
386 (long) peer->rtt
387 );
389 return 0;
390 } /* end rxrpc_proc_peers_show() */
392 /*****************************************************************************/
393 /*
394 * open "/proc/net/rxrpc/connections" which provides a summary of extant
395 * connections
396 */
397 static int rxrpc_proc_conns_open(struct inode *inode, struct file *file)
398 {
399 struct seq_file *m;
400 int ret;
402 ret = seq_open(file, &rxrpc_proc_conns_ops);
403 if (ret < 0)
404 return ret;
406 m = file->private_data;
407 m->private = PDE(inode)->data;
409 return 0;
410 } /* end rxrpc_proc_conns_open() */
412 /*****************************************************************************/
413 /*
414 * set up the iterator to start reading from the conns list and return the
415 * first item
416 */
417 static void *rxrpc_proc_conns_start(struct seq_file *m, loff_t *_pos)
418 {
419 struct list_head *_p;
420 loff_t pos = *_pos;
422 /* lock the list against modification */
423 down_read(&rxrpc_conns_sem);
425 /* allow for the header line */
426 if (!pos)
427 return SEQ_START_TOKEN;
428 pos--;
430 /* find the n'th element in the list */
431 list_for_each(_p, &rxrpc_conns)
432 if (!pos--)
433 break;
435 return _p != &rxrpc_conns ? _p : NULL;
436 } /* end rxrpc_proc_conns_start() */
438 /*****************************************************************************/
439 /*
440 * move to next conn in conns list
441 */
442 static void *rxrpc_proc_conns_next(struct seq_file *p, void *v, loff_t *pos)
443 {
444 struct list_head *_p;
446 (*pos)++;
448 _p = v;
449 _p = (v == SEQ_START_TOKEN) ? rxrpc_conns.next : _p->next;
451 return _p != &rxrpc_conns ? _p : NULL;
452 } /* end rxrpc_proc_conns_next() */
454 /*****************************************************************************/
455 /*
456 * clean up after reading from the conns list
457 */
458 static void rxrpc_proc_conns_stop(struct seq_file *p, void *v)
459 {
460 up_read(&rxrpc_conns_sem);
462 } /* end rxrpc_proc_conns_stop() */
464 /*****************************************************************************/
465 /*
466 * display a header line followed by a load of conn lines
467 */
468 static int rxrpc_proc_conns_show(struct seq_file *m, void *v)
469 {
470 struct rxrpc_connection *conn;
471 long timeout;
473 conn = list_entry(v, struct rxrpc_connection, proc_link);
475 /* display header on line 1 */
476 if (v == SEQ_START_TOKEN) {
477 seq_puts(m,
478 "LOCAL REMOTE RPORT SRVC CONN END SERIALNO "
479 "CALLNO MTU TIMEOUT"
480 "\n");
481 return 0;
482 }
484 /* display one conn per line on subsequent lines */
485 timeout = 0;
486 if (!list_empty(&conn->timeout.link))
487 timeout = (long) conn->timeout.timo_jif -
488 (long) jiffies;
490 seq_printf(m,
491 "%5hu %08x %5hu %04hx %08x %-3.3s %08x %08x %5Zu %8ld\n",
492 conn->trans->port,
493 ntohl(conn->addr.sin_addr.s_addr),
494 ntohs(conn->addr.sin_port),
495 ntohs(conn->service_id),
496 ntohl(conn->conn_id),
497 conn->out_clientflag ? "CLT" : "SRV",
498 conn->serial_counter,
499 conn->call_counter,
500 conn->mtu_size,
501 timeout
502 );
504 return 0;
505 } /* end rxrpc_proc_conns_show() */
507 /*****************************************************************************/
508 /*
509 * open "/proc/net/rxrpc/calls" which provides a summary of extant calls
510 */
511 static int rxrpc_proc_calls_open(struct inode *inode, struct file *file)
512 {
513 struct seq_file *m;
514 int ret;
516 ret = seq_open(file, &rxrpc_proc_calls_ops);
517 if (ret < 0)
518 return ret;
520 m = file->private_data;
521 m->private = PDE(inode)->data;
523 return 0;
524 } /* end rxrpc_proc_calls_open() */
526 /*****************************************************************************/
527 /*
528 * set up the iterator to start reading from the calls list and return the
529 * first item
530 */
531 static void *rxrpc_proc_calls_start(struct seq_file *m, loff_t *_pos)
532 {
533 struct list_head *_p;
534 loff_t pos = *_pos;
536 /* lock the list against modification */
537 down_read(&rxrpc_calls_sem);
539 /* allow for the header line */
540 if (!pos)
541 return SEQ_START_TOKEN;
542 pos--;
544 /* find the n'th element in the list */
545 list_for_each(_p, &rxrpc_calls)
546 if (!pos--)
547 break;
549 return _p != &rxrpc_calls ? _p : NULL;
550 } /* end rxrpc_proc_calls_start() */
552 /*****************************************************************************/
553 /*
554 * move to next call in calls list
555 */
556 static void *rxrpc_proc_calls_next(struct seq_file *p, void *v, loff_t *pos)
557 {
558 struct list_head *_p;
560 (*pos)++;
562 _p = v;
563 _p = (v == SEQ_START_TOKEN) ? rxrpc_calls.next : _p->next;
565 return _p != &rxrpc_calls ? _p : NULL;
566 } /* end rxrpc_proc_calls_next() */
568 /*****************************************************************************/
569 /*
570 * clean up after reading from the calls list
571 */
572 static void rxrpc_proc_calls_stop(struct seq_file *p, void *v)
573 {
574 up_read(&rxrpc_calls_sem);
576 } /* end rxrpc_proc_calls_stop() */
578 /*****************************************************************************/
579 /*
580 * display a header line followed by a load of call lines
581 */
582 static int rxrpc_proc_calls_show(struct seq_file *m, void *v)
583 {
584 struct rxrpc_call *call = list_entry(v, struct rxrpc_call, call_link);
586 /* display header on line 1 */
587 if (v == SEQ_START_TOKEN) {
588 seq_puts(m,
589 "LOCAL REMOT SRVC CONN CALL DIR USE "
590 " L STATE OPCODE ABORT ERRNO\n"
591 );
592 return 0;
593 }
595 /* display one call per line on subsequent lines */
596 seq_printf(m,
597 "%5hu %5hu %04hx %08x %08x %s %3u%c"
598 " %c %-7.7s %6d %08x %5d\n",
599 call->conn->trans->port,
600 ntohs(call->conn->addr.sin_port),
601 ntohs(call->conn->service_id),
602 ntohl(call->conn->conn_id),
603 ntohl(call->call_id),
604 call->conn->service ? "SVC" : "CLT",
605 atomic_read(&call->usage),
606 waitqueue_active(&call->waitq) ? 'w' : ' ',
607 call->app_last_rcv ? 'Y' : '-',
608 (call->app_call_state!=RXRPC_CSTATE_ERROR ?
609 rxrpc_call_states7[call->app_call_state] :
610 rxrpc_call_error_states7[call->app_err_state]),
611 call->app_opcode,
612 call->app_abort_code,
613 call->app_errno
614 );
616 return 0;
617 } /* end rxrpc_proc_calls_show() */