Whamcloud - gitweb
file cfs_lock.h was initially added on branch b_porting.
[fs/lustre-release.git] / lnet / router / proc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Portals
7  *   http://sourceforge.net/projects/sandiaportals/
8  *
9  *   Portals is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   Portals is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with Portals; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23
24 #include "router.h"
25
26 #define KPR_PROC_ROUTER "sys/portals/router"
27
28 int
29 kpr_proc_read (char *page, char **start, off_t off, int count, int *eof, void *data)
30 {
31         unsigned long long bytes = kpr_fwd_bytes;
32         unsigned long      packets = kpr_fwd_packets;
33         unsigned long      errors = kpr_fwd_errors;
34         unsigned int       qdepth = atomic_read (&kpr_queue_depth);
35         int                len;
36         
37         *eof = 1;
38         if (off != 0)
39                 return (0);
40         
41         len = sprintf (page, "%Ld %ld %ld %d\n", bytes, packets, errors, qdepth);
42         
43         *start = page;
44         return (len);
45 }
46
47 int
48 kpr_proc_write (struct file *file, const char *ubuffer, unsigned long count, void *data)
49 {
50         /* Ignore what we've been asked to write, and just zero the stats counters */
51         kpr_fwd_bytes = 0;
52         kpr_fwd_packets = 0;
53         kpr_fwd_errors = 0;
54
55         return (count);
56 }
57
58 void
59 kpr_proc_init(void)
60 {
61         struct proc_dir_entry *entry = create_proc_entry (KPR_PROC_ROUTER, S_IFREG | S_IRUGO | S_IWUSR, NULL);
62
63         if (entry == NULL) 
64         {
65                 CERROR("couldn't create proc entry %s\n", KPR_PROC_ROUTER);
66                 return;
67         }
68
69         entry->data = NULL;
70         entry->read_proc = kpr_proc_read;
71         entry->write_proc = kpr_proc_write;
72 }
73
74 void 
75 kpr_proc_fini(void)
76 {
77         remove_proc_entry(KPR_PROC_ROUTER, 0);
78 }