OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [net/] [sunrpc/] [stats.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * linux/net/sunrpc/stats.c
3
 *
4
 * procfs-based user access to generic RPC statistics. The stats files
5
 * reside in /proc/net/rpc.
6
 *
7
 * The read routines assume that the buffer passed in is just big enough.
8
 * If you implement an RPC service that has its own stats routine which
9
 * appends the generic RPC stats, make sure you don't exceed the PAGE_SIZE
10
 * limit.
11
 *
12
 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
13
 */
14
 
15
#include <linux/module.h>
16
 
17
#include <linux/init.h>
18
#include <linux/kernel.h>
19
#include <linux/sched.h>
20
#include <linux/proc_fs.h>
21
#include <linux/sunrpc/clnt.h>
22
#include <linux/sunrpc/svcsock.h>
23
#include <linux/init.h>
24
 
25
#define RPCDBG_FACILITY RPCDBG_MISC
26
 
27
static struct proc_dir_entry    *proc_net_rpc = NULL;
28
 
29
/*
30
 * Get RPC client stats
31
 */
32
int
33
rpc_proc_read(char *buffer, char **start, off_t offset, int count,
34
                                int *eof, void *data)
35
{
36
        struct rpc_stat *statp = (struct rpc_stat *) data;
37
        struct rpc_program *prog = statp->program;
38
        struct rpc_version *vers;
39
        int             len, i, j;
40
 
41
        len = sprintf(buffer,
42
                "net %d %d %d %d\n",
43
                        statp->netcnt,
44
                        statp->netudpcnt,
45
                        statp->nettcpcnt,
46
                        statp->nettcpconn);
47
        len += sprintf(buffer + len,
48
                "rpc %d %d %d\n",
49
                        statp->rpccnt,
50
                        statp->rpcretrans,
51
                        statp->rpcauthrefresh);
52
 
53
        for (i = 0; i < prog->nrvers; i++) {
54
                if (!(vers = prog->version[i]))
55
                        continue;
56
                len += sprintf(buffer + len, "proc%d %d",
57
                                        vers->number, vers->nrprocs);
58
                for (j = 0; j < vers->nrprocs; j++)
59
                        len += sprintf(buffer + len, " %d",
60
                                        vers->procs[j].p_count);
61
                buffer[len++] = '\n';
62
        }
63
 
64
        if (offset >= len) {
65
                *start = buffer;
66
                *eof = 1;
67
                return 0;
68
        }
69
        *start = buffer + offset;
70
        if ((len -= offset) > count)
71
                return count;
72
        *eof = 1;
73
        return len;
74
}
75
 
76
/*
77
 * Get RPC server stats
78
 */
79
int
80
svc_proc_read(char *buffer, char **start, off_t offset, int count,
81
                                int *eof, void *data)
82
{
83
        struct svc_stat *statp  = (struct svc_stat *) data;
84
        struct svc_program *prog = statp->program;
85
        struct svc_procedure *proc;
86
        struct svc_version *vers;
87
        int             len, i, j;
88
 
89
        len = sprintf(buffer,
90
                "net %d %d %d %d\n",
91
                        statp->netcnt,
92
                        statp->netudpcnt,
93
                        statp->nettcpcnt,
94
                        statp->nettcpconn);
95
        len += sprintf(buffer + len,
96
                "rpc %d %d %d %d %d\n",
97
                        statp->rpccnt,
98
                        statp->rpcbadfmt+statp->rpcbadauth+statp->rpcbadclnt,
99
                        statp->rpcbadfmt,
100
                        statp->rpcbadauth,
101
                        statp->rpcbadclnt);
102
 
103
        for (i = 0; i < prog->pg_nvers; i++) {
104
                if (!(vers = prog->pg_vers[i]) || !(proc = vers->vs_proc))
105
                        continue;
106
                len += sprintf(buffer + len, "proc%d %d", i, vers->vs_nproc);
107
                for (j = 0; j < vers->vs_nproc; j++, proc++)
108
                        len += sprintf(buffer + len, " %d", proc->pc_count);
109
                buffer[len++] = '\n';
110
        }
111
 
112
        if (offset >= len) {
113
                *start = buffer;
114
                *eof = 1;
115
                return 0;
116
        }
117
        *start = buffer + offset;
118
        if ((len -= offset) > count)
119
                return count;
120
        *eof = 1;
121
        return len;
122
}
123
 
124
/*
125
 * Register/unregister RPC proc files
126
 */
127
static inline struct proc_dir_entry *
128
do_register(const char *name, void *data, int issvc)
129
{
130
        rpc_proc_init();
131
        dprintk("RPC: registering /proc/net/rpc/%s\n", name);
132
        return create_proc_read_entry(name, 0, proc_net_rpc,
133
                                      issvc? svc_proc_read : rpc_proc_read,
134
                                      data);
135
}
136
 
137
struct proc_dir_entry *
138
rpc_proc_register(struct rpc_stat *statp)
139
{
140
        return do_register(statp->program->name, statp, 0);
141
}
142
 
143
void
144
rpc_proc_unregister(const char *name)
145
{
146
        remove_proc_entry(name, proc_net_rpc);
147
}
148
 
149
struct proc_dir_entry *
150
svc_proc_register(struct svc_stat *statp)
151
{
152
        return do_register(statp->program->pg_name, statp, 1);
153
}
154
 
155
void
156
svc_proc_unregister(const char *name)
157
{
158
        remove_proc_entry(name, proc_net_rpc);
159
}
160
 
161
void
162
rpc_proc_init(void)
163
{
164
        dprintk("RPC: registering /proc/net/rpc\n");
165
        if (!proc_net_rpc) {
166
                struct proc_dir_entry *ent;
167
                ent = proc_mkdir("net/rpc", 0);
168
                if (ent) {
169
                        ent->owner = THIS_MODULE;
170
                        proc_net_rpc = ent;
171
                }
172
        }
173
}
174
 
175
void
176
rpc_proc_exit(void)
177
{
178
        dprintk("RPC: unregistering /proc/net/rpc\n");
179
        if (proc_net_rpc) {
180
                proc_net_rpc = NULL;
181
                remove_proc_entry("net/rpc", 0);
182
        }
183
}
184
 
185
 
186
static int __init
187
init_sunrpc(void)
188
{
189
#ifdef RPC_DEBUG
190
        rpc_register_sysctl();
191
#endif
192
        rpc_proc_init();
193
        return 0;
194
}
195
 
196
static void __exit
197
cleanup_sunrpc(void)
198
{
199
#ifdef RPC_DEBUG
200
        rpc_unregister_sysctl();
201
#endif
202
        rpc_proc_exit();
203
}
204
MODULE_LICENSE("GPL");
205
module_init(init_sunrpc);
206
module_exit(cleanup_sunrpc);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.