Whamcloud - gitweb
Quiet down the lprocfs warnings a bit until Hari gets new code into the tree.
[fs/lustre-release.git] / lustre / include / linux / lprocfs.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2002 Intel Corporation
5  *
6  */
7
8 /*
9  * Author: Hariharan Thantry
10  * File Name: lprocfs.h
11  *
12  * Header file for the LProcFS file system
13  */
14
15 #ifndef _LPROCFS_H
16 #define _LPROCFS_H
17
18 #ifndef LPROCFS_EXISTS
19 #define LPROCFS_EXISTS
20 #endif
21
22 #define LPROCFS_SUCCESS 1
23 #define LPROCFS_FAILURE -1
24
25 #include <linux/time.h>
26 #include <linux/proc_fs.h>
27 #include <linux/config.h>
28 #include <linux/param.h>
29 /* #include <linux/msr.h> */
30
31 typedef enum lprofilers {
32         e_generic=0,
33         e_specific
34 } lprofilers_e;
35
36 typedef struct lprocfs_vars{
37         char* name;
38         read_proc_t* read_fptr;
39         write_proc_t* write_fptr;
40 } lprocfs_vars_t;
41
42 typedef struct lprocfs_group {
43         char** dir_namespace;
44         lprocfs_vars_t* count_func_namespace;
45         lprofilers_e prof_type;
46 } lprocfs_group_t;
47
48 typedef struct lprocfs_obd_nm {
49         char* obd_clname;
50         lprocfs_group_t* obd_names;
51         unsigned int cntr_blk_sz;
52 } lprocfs_obd_nm_t;
53
54
55
56 /*
57  * Structure defining the variables to be maintained
58  * on a per attribute basis for entries. The size of
59  * the profiling entry needs to be passed during registration
60  * with LProcFS, to enable it to allocate space. It is expected
61  * that on a per-device class basis, there would exist only
62  * one signature.
63  */
64
65 struct lprofiler_gen {
66         __u64 min_time;
67         __u64 max_time;
68         __u64 sum_time;
69         __u64 num_ops;
70         /* Default, used for storing intermediate value */
71         unsigned long long start_time;
72 };
73
74 struct lprofiler_ldlm {
75         __u64 min_time;
76         __u64 max_time;
77         __u64 sum_time;
78         __u64 num_ops;
79         __u64 start_time;
80
81         __u64 num_total;
82         __u64 num_zerolatency;
83         __u64 num_zerolatency_inflight;
84         __u64 num_zerolatency_done;
85         __u64 non_zero_mintime;
86         __u64 non_zero_maxtime;
87         __u64 non_zero_sumtime;
88 };
89
90 struct lprofiler_ptlrpc {
91         __u64 min_time;
92         __u64 max_time;
93         __u64 sum_time;
94         __u64 num_ops;
95         /* Default, used for storing intermediate value */
96         __u64 start_time;
97         __u64 msgs_alloc;
98
99         __u64 msgs_max;
100         __u64 recv_count;
101
102         __u64 recv_length;
103         __u64 send_count;
104         __u64 send_length;
105         __u64 portal_kmemory;
106 };
107
108
109
110 struct namespace_index {
111         char* name;
112 };
113
114 struct groupspace_index {
115         char* name;
116         struct namespace_index* directory;
117         struct namespace_index* counters;
118 };
119
120 /*
121  * Used for connections and such
122  */
123
124
125 typedef enum te_leafType {
126         e_String=0,
127         e_longlong
128
129 }e_varType;
130
131
132
133 struct lprocfs_conn_namespace {
134         char* leaf_name;
135         e_varType type;
136         union {
137                 char* string_val;
138                 __u64 cntr_val;
139         } x;
140 };
141
142 #ifdef LPROCFS_EXISTS
143 /*
144  * Utility functions to return the timeofday
145  *
146  */
147 static inline unsigned long lprocfs_util_gettime(void)
148 {
149         return 0;
150         /*
151         struct timeval myTime;
152         __u64 temp;
153         do_gettimeofday(&myTime);
154         temp=((__u64)(myTime.tv_usec))&0xFFFFFFFF;
155         temp|=(((__u64)(myTime.tv_sec))<<(8*sizeof(unsigned long)));
156         return temp;
157         */
158
159 }
160 static inline unsigned long lprocfs_util_getdiff(unsigned long x,
161                                                  unsigned long y)
162 {
163         return ((x>y)?(x-y):(y-x));
164         /*
165         __u64 tempSec=0;
166         __u64 tempuSec=0;
167         tempSec=((y>>8*sizeof(unsigned long))-(x>>8*sizeof(unsigned long)));
168         if(tempSec<0)tempSec=-tempSec;
169         tempuSec=((y&0xFFFFFFFF)-(x&0xFFFFFFFF));
170         if(tempuSec<0)tempuSec=-tempuSec;
171         return(tempSec*1000000+tempuSec);
172         */
173
174 }
175
176 #define LPROCFS_NAMESPACE_ENUM(CLASS, NAME) e_ ##CLASS## _##NAME
177
178
179 #define DEV_PROF_START(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE)         \
180 do {                                                                  \
181         struct lprofiler_##PROF_CLASS *x;                             \
182         int index=LPROCFS_NAMESPACE_ENUM(DEV_CLASS, ATTRIBUTE);       \
183         x=(struct lprofiler_##PROF_CLASS *)((OBD)->counters);         \
184         x+=index;                                                     \
185         /* rdtscl(x->start_time); */                                  \
186         x->start_time=lprocfs_util_gettime();                         \
187 }while(0)                                                             \
188
189
190 #define DEV_PROF_END(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE)                   \
191 do{                                                                           \
192         unsigned long end_time, delta;                                        \
193         int index=LPROCFS_NAMESPACE_ENUM(DEV_CLASS, ATTRIBUTE);               \
194         struct lprofiler_##PROF_CLASS *x=                                     \
195                 (struct lprofiler_##PROF_CLASS*)((OBD)->counters);            \
196         x+=index;                                                             \
197         end_time=lprocfs_util_gettime();                                      \
198         delta=lprocfs_util_getdiff(x->start_time, end_time);                  \
199         if((delta<x->min_time)||(x->min_time==0))x->min_time=delta;           \
200         if(delta>x->max_time)x->max_time=delta;                               \
201         x->sum_time+=delta;                                                   \
202         (x->num_ops)++;                                                       \
203 }while(0)                                                                     \
204
205 /*
206 #define DEV_PROF_END(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE)                   \
207 do{                                                                           \
208         __u64 end_time, delta;                                   \
209         int index=LPROCFS_NAMESPACE_ENUM(DEV_CLASS, ATTRIBUTE);               \
210         struct lprofiler_##PROF_CLASS *x=                              \
211                 (struct lprofiler_##PROF_CLASS*)((OBD)->counters);     \
212         x+=index;                                                             \
213         end_time=lprocfs_util_gettime();                                      \
214         delta=lprocfs_util_getdiff(x->start_time, end_time);                  \
215         if((delta<x->min_time)||(x->min_time==0))x->min_time=delta;           \
216         if(delta>x->max_time)x->max_time=delta;                               \
217         x->sum_time+=delta;                                                   \
218         (x->num_ops)++;                                                       \
219 }while(0)                                                                     \
220 */
221 /*
222 #define DEV_PRINT_CNTR(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE)                 \
223 do{                                                                           \
224         int index=LPROCFS_NAMESPACE_ENUM(DEV_CLASS, ATTRIBUTE);               \
225         struct lprofiler_##PROF_CLASS *x=                              \
226                 (struct lprofiler_##PROF_CLASS *)&((OBD)->counters);   \
227         x+=index;                                                             \
228         printk("Max_time=%lld(usec)\n", x->max_time);                         \
229         printk("Min_time=%lld(usec)\n", x->min_time);                         \
230         printk("Sum_time=%lld(usec)\n", x->sum_time);                         \
231         printk("Num_ops=%lld\n", x->num_ops);                                 \
232 } while(0)                                                                    \
233 */
234
235
236 /*
237  * This enum is used as an array index into the counts
238  * that are maintained for the MDS device. The number of
239  * entries here determine the amount of memory allocated
240  * for counters for every instance of this class of
241  * device
242  */
243 enum {
244         LPROCFS_NAMESPACE_ENUM(mdc, mgmt_setup),
245         LPROCFS_NAMESPACE_ENUM(mdc, mgmt_cleanup),
246         LPROCFS_NAMESPACE_ENUM(mdc, mgmt_connect),
247         LPROCFS_NAMESPACE_ENUM(mdc, mgmt_disconnect),
248         LPROCFS_NAMESPACE_ENUM(mdc, reint),
249         LPROCFS_NAMESPACE_ENUM(mdc, getstatus),
250         LPROCFS_NAMESPACE_ENUM(mdc, getattr),
251         LPROCFS_NAMESPACE_ENUM(mdc, setattr),
252         LPROCFS_NAMESPACE_ENUM(mdc, open),
253         LPROCFS_NAMESPACE_ENUM(mdc, readpage),
254         LPROCFS_NAMESPACE_ENUM(mdc, create),
255         LPROCFS_NAMESPACE_ENUM(mdc, unlink),
256         LPROCFS_NAMESPACE_ENUM(mdc, link),
257         LPROCFS_NAMESPACE_ENUM(mdc, rename),
258         LPROCFS_MAX_ENUM_DIR_MDC
259 };
260
261 enum {
262         LPROCFS_NAMESPACE_ENUM(mds, mgmt_setup),
263         LPROCFS_NAMESPACE_ENUM(mds, mgmt_cleanup),
264         LPROCFS_NAMESPACE_ENUM(mds, mgmt_connect),
265         LPROCFS_NAMESPACE_ENUM(mds, mgmt_disconnect),
266         LPROCFS_NAMESPACE_ENUM(mds, getstatus),
267         LPROCFS_NAMESPACE_ENUM(mds, connect),
268         LPROCFS_NAMESPACE_ENUM(mds, disconnect_callback),
269         LPROCFS_NAMESPACE_ENUM(mds, getattr),
270         LPROCFS_NAMESPACE_ENUM(mds, readpage),
271         LPROCFS_NAMESPACE_ENUM(mds, open),
272         LPROCFS_NAMESPACE_ENUM(mds, close),
273         LPROCFS_NAMESPACE_ENUM(mds, create),
274         LPROCFS_NAMESPACE_ENUM(mds, unlink),
275         LPROCFS_NAMESPACE_ENUM(mds, link),
276         LPROCFS_NAMESPACE_ENUM(mds, rename),
277         LPROCFS_NAMESPACE_ENUM(mds, reint_summary),
278         LPROCFS_NAMESPACE_ENUM(mds, reint_setattr),
279         LPROCFS_NAMESPACE_ENUM(mds, reint_create),
280         LPROCFS_NAMESPACE_ENUM(mds, reint_unlink),
281         LPROCFS_NAMESPACE_ENUM(mds, reint_link),
282         LPROCFS_NAMESPACE_ENUM(mds, reint_rename),
283         LPROCFS_NAMESPACE_ENUM(mds, reint_recreate),
284         LPROCFS_MAX_ENUM_DIR_MDS
285
286 };
287
288 enum {
289         LPROCFS_NAMESPACE_ENUM(mdt, mgmt_setup),
290         LPROCFS_NAMESPACE_ENUM(mdt, mgmt_cleanup),
291         LPROCFS_NAMESPACE_ENUM(mdt, mgmt_connect),
292         LPROCFS_NAMESPACE_ENUM(mdt, mgmt_disconnect),
293 };
294
295 enum {
296         LPROCFS_NAMESPACE_ENUM(osc, mgmt_setup),
297         LPROCFS_NAMESPACE_ENUM(osc, mgmt_cleanup),
298         LPROCFS_NAMESPACE_ENUM(osc, mgmt_connect),
299         LPROCFS_NAMESPACE_ENUM(osc, mgmt_disconnect),
300         LPROCFS_NAMESPACE_ENUM(osc, create),
301         LPROCFS_NAMESPACE_ENUM(osc, destroy),
302         LPROCFS_NAMESPACE_ENUM(osc, getattr),
303         LPROCFS_NAMESPACE_ENUM(osc, setattr),
304         LPROCFS_NAMESPACE_ENUM(osc, open),
305         LPROCFS_NAMESPACE_ENUM(osc, close),
306         LPROCFS_NAMESPACE_ENUM(osc, brw),
307         LPROCFS_NAMESPACE_ENUM(osc, punch),
308         LPROCFS_NAMESPACE_ENUM(osc, summary),
309         LPROCFS_NAMESPACE_ENUM(osc, cancel),
310         LPROCFS_MAX_ENUM_DIR_OSC
311 };
312
313 enum {
314         LPROCFS_NAMESPACE_ENUM(ost, mgmt_setup),
315         LPROCFS_NAMESPACE_ENUM(ost, mgmt_cleanup),
316         LPROCFS_NAMESPACE_ENUM(ost, mgmt_connect),
317         LPROCFS_NAMESPACE_ENUM(ost, mgmt_disconnect),
318         LPROCFS_NAMESPACE_ENUM(ost, create),
319         LPROCFS_NAMESPACE_ENUM(ost, destroy),
320         LPROCFS_NAMESPACE_ENUM(ost, getattr),
321         LPROCFS_NAMESPACE_ENUM(ost, setattr),
322         LPROCFS_NAMESPACE_ENUM(ost, open),
323         LPROCFS_NAMESPACE_ENUM(ost, close),
324         LPROCFS_NAMESPACE_ENUM(ost, brw),
325         LPROCFS_NAMESPACE_ENUM(ost, punch),
326         LPROCFS_NAMESPACE_ENUM(ost, summary),
327         LPROCFS_NAMESPACE_ENUM(ost, cancel),
328         LPROCFS_NAMESPACE_ENUM(ost, getinfo),
329         LPROCFS_MAX_ENUM_DIR_OST
330 };
331
332 enum {
333         LPROCFS_NAMESPACE_ENUM(lov, mgmt_setup),
334         LPROCFS_NAMESPACE_ENUM(lov, mgmt_cleanup),
335         LPROCFS_NAMESPACE_ENUM(lov, mgmt_connect),
336         LPROCFS_NAMESPACE_ENUM(lov, mgmt_disconnect),
337         LPROCFS_NAMESPACE_ENUM(lov, create),
338         LPROCFS_NAMESPACE_ENUM(lov, destroy),
339         LPROCFS_NAMESPACE_ENUM(lov, getattr),
340         LPROCFS_NAMESPACE_ENUM(lov, setattr),
341         LPROCFS_NAMESPACE_ENUM(lov, open),
342         LPROCFS_NAMESPACE_ENUM(lov, close),
343         LPROCFS_NAMESPACE_ENUM(lov, brw),
344         LPROCFS_NAMESPACE_ENUM(lov, punch),
345         LPROCFS_NAMESPACE_ENUM(lov, summary),
346         LPROCFS_NAMESPACE_ENUM(lov, cancel),
347         LPROCFS_NAMESPACE_ENUM(lov, getinfo),
348         LPROCFS_MAX_ENUM_DIR_LOV
349 };
350
351 enum {
352         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_setup),
353         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_cleanup),
354         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_connect),
355         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_disconnect),
356         LPROCFS_NAMESPACE_ENUM(obdfilter, create),
357         LPROCFS_NAMESPACE_ENUM(obdfilter, destroy),
358         LPROCFS_NAMESPACE_ENUM(obdfilter, getattr),
359         LPROCFS_NAMESPACE_ENUM(obdfilter, setattr),
360         LPROCFS_NAMESPACE_ENUM(obdfilter, open),
361         LPROCFS_NAMESPACE_ENUM(obdfilter, close),
362         LPROCFS_NAMESPACE_ENUM(obdfilter, brw),
363         LPROCFS_NAMESPACE_ENUM(obdfilter, punch),
364         LPROCFS_NAMESPACE_ENUM(obdfilter, summary),
365         LPROCFS_NAMESPACE_ENUM(obdfilter, cancel),
366         LPROCFS_NAMESPACE_ENUM(obdfilter, getinfo),
367         LPROCFS_MAX_ENUM_DIR_OBDFILTER
368 };
369
370 enum {
371         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_setup),
372         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_cleanup),
373         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_connect),
374         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_disconnect),
375         LPROCFS_NAMESPACE_ENUM(ldlm, locks_enqueus),
376         LPROCFS_NAMESPACE_ENUM(ldlm, locks_cancels),
377         LPROCFS_NAMESPACE_ENUM(ldlm, locks_converts),
378         LPROCFS_NAMESPACE_ENUM(ldlm, locks_matches),
379         LPROCFS_MAX_ENUM_DIR_LDLM
380 };
381
382 enum {
383         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_setup),
384         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_cleanup),
385         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_connect),
386         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_disconnect),
387         LPROCFS_NAMESPACE_ENUM(ptlrpc, counters),
388         LPROCFS_NAMESPACE_ENUM(ptlrpc, network),
389         LPROCFS_MAX_ENUM_DIR_PTLRPC
390 };
391
392 #define LPROCFS_DIR_INDEX(CLASS, DIR) \
393                          [LPROCFS_NAMESPACE_ENUM(CLASS, DIR)]={#DIR}
394
395 /*
396  * Similar rule for profiling counters
397  */
398
399
400 enum {
401         LPROCFS_NAMESPACE_ENUM(mdc, min_time),
402         LPROCFS_NAMESPACE_ENUM(mdc, max_time),
403         LPROCFS_NAMESPACE_ENUM(mdc, sum_time),
404         LPROCFS_NAMESPACE_ENUM(mdc, num_ops),
405         LPROF_MDC_MAX
406 };
407
408 enum {
409         LPROCFS_NAMESPACE_ENUM(mds, min_time),
410         LPROCFS_NAMESPACE_ENUM(mds, max_time),
411         LPROCFS_NAMESPACE_ENUM(mds, sum_time),
412         LPROCFS_NAMESPACE_ENUM(mds, num_ops),
413         LPROF_MDS_MAX
414 };
415
416 enum {
417         LPROCFS_NAMESPACE_ENUM(osc, min_time),
418         LPROCFS_NAMESPACE_ENUM(osc, max_time),
419         LPROCFS_NAMESPACE_ENUM(osc, sum_time),
420         LPROCFS_NAMESPACE_ENUM(osc, num_ops),
421         LPROF_OSC_MAX
422 };
423
424 enum {
425         LPROCFS_NAMESPACE_ENUM(ost, min_time),
426         LPROCFS_NAMESPACE_ENUM(ost, max_time),
427         LPROCFS_NAMESPACE_ENUM(ost, sum_time),
428         LPROCFS_NAMESPACE_ENUM(ost, num_ops),
429         LPROF_OST_MAX
430 };
431
432 enum {
433         LPROCFS_NAMESPACE_ENUM(lov, min_time),
434         LPROCFS_NAMESPACE_ENUM(lov, max_time),
435         LPROCFS_NAMESPACE_ENUM(lov, sum_time),
436         LPROCFS_NAMESPACE_ENUM(lov, num_ops),
437         LPROF_LOV_MAX
438 };
439
440 enum {
441         LPROCFS_NAMESPACE_ENUM(obdfilter, min_time),
442         LPROCFS_NAMESPACE_ENUM(obdfilter, max_time),
443         LPROCFS_NAMESPACE_ENUM(obdfilter, sum_time),
444         LPROCFS_NAMESPACE_ENUM(obdfilter, num_ops),
445         LPROF_OBDFILTER_MAX
446 };
447
448
449 enum {
450         LPROCFS_NAMESPACE_ENUM(ldlm, min_time),
451         LPROCFS_NAMESPACE_ENUM(ldlm, max_time),
452         LPROCFS_NAMESPACE_ENUM(ldlm, sum_time),
453         LPROCFS_NAMESPACE_ENUM(ldlm, num_ops),
454         LPROCFS_NAMESPACE_ENUM(ldlm, num_total),
455         LPROCFS_NAMESPACE_ENUM(ldlm, num_zerolatency),
456         LPROCFS_NAMESPACE_ENUM(ldlm, num_zerolatency_inflight),
457         LPROCFS_NAMESPACE_ENUM(ldlm, num_zerolatency_done),
458         LPROCFS_NAMESPACE_ENUM(ldlm, nonzero_mintime),
459         LPROCFS_NAMESPACE_ENUM(ldlm, nonzero_maxtime),
460         LPROCFS_NAMESPACE_ENUM(ldlm, nonzero_sumtime),
461         LPROF_LDLM_MAX
462 };
463
464 enum {
465         LPROCFS_NAMESPACE_ENUM(ptlrpc, min_time),
466         LPROCFS_NAMESPACE_ENUM(ptlrpc, max_time),
467         LPROCFS_NAMESPACE_ENUM(ptlrpc, sum_time),
468         LPROCFS_NAMESPACE_ENUM(ptlrpc, num_ops),
469
470         LPROCFS_NAMESPACE_ENUM(ptlrpc, msgs_alloc),
471         LPROCFS_NAMESPACE_ENUM(ptlrpc, msgs_max),
472         LPROCFS_NAMESPACE_ENUM(ptlrpc, recv_count),
473         LPROCFS_NAMESPACE_ENUM(ptlrpc, recv_length),
474         LPROCFS_NAMESPACE_ENUM(ptlrpc, send_count),
475         LPROCFS_NAMESPACE_ENUM(ptlrpc, send_length),
476         LPROCFS_NAMESPACE_ENUM(ptlrpc, portal_kmemory),
477         LPROF_PTLRPC_MAX
478
479 };
480
481 /*
482  * and for groups
483  */
484 #define LPROCFS_ENUM(X) e_##X
485
486 enum {
487         LPROCFS_ENUM(mdc),
488         LPROCFS_ENUM(mds),
489         LPROCFS_ENUM(mdt),
490         LPROCFS_ENUM(osc),
491         LPROCFS_ENUM(ost),
492         LPROCFS_ENUM(lov),
493         LPROCFS_ENUM(obdfilter),
494         LPROCFS_ENUM(ldlm),
495         LPROCFS_ENUM(ptlrpc),
496         LPROCFS_GROUP_MAX
497 };
498
499 #define LPROCFS_CNTR_INDEX(CLASS, NAME) \
500                    [LPROCFS_NAMESPACE_ENUM(CLASS, NAME)]={#NAME}
501
502 #define LPROCFS_GROUP_CREATE(CLASS) \
503       [LPROCFS_ENUM(CLASS)]={#CLASS, dir_##CLASS##_index, prof_##CLASS##_index}
504
505 /*
506  * OBD Namespace API: Obtain the namespace group index, given a name
507  */
508 int lprocfs_get_nm(char* name, lprocfs_obd_nm_t* collection);
509
510
511
512 /*
513  * OBD device APIs
514  */
515
516 int lprocfs_reg_dev(struct obd_device* device, lprocfs_group_t* namespace,
517                     unsigned int cnt_struct_size);
518
519 int lprocfs_dereg_dev(struct obd_device* device);
520
521 /*
522  * Connections API
523  */
524 int lprocfs_reg_conn(unsigned int conn_number,
525                      struct lprocfs_conn_namespace* namespace);
526 int lprocfs_dereg_conn(unsigned int conn_number);
527
528 /*
529  * Import/Export APIs
530  */
531 int lprocfs_add_export(unsigned int conn_number,
532                        struct obd_device* device);
533 int lprocfs_add_import(unsigned int conn_number,
534                        struct obd_device* device);
535 int lprocfs_remove_export(unsigned int conn_number,
536                           struct obd_device* device);
537 int lprocfs_remove_import(unsigned int conn_number,
538                           struct obd_device* device);
539
540 /*
541  * Utility functions
542  */
543
544 struct proc_dir_entry* lprocfs_add_dir(struct proc_dir_entry* root,
545                                        const char* name,
546                                        const char* tok,
547                                        unsigned int* escape);
548
549
550 struct proc_dir_entry* lprocfs_mkdir(const char* dname,
551                                      struct proc_dir_entry *parent);
552
553
554 struct proc_dir_entry* lprocfs_bfs_srch(struct proc_dir_entry* root,
555                                         const char* name);
556
557 struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head,
558                                     const char* name);
559
560 int lprocfs_link_dir_counters(struct obd_device* device,
561                               struct proc_dir_entry* this_dev_root,
562                               lprocfs_group_t* namespace,
563                               unsigned int cnt_struct_size,
564                               unsigned int class_array_index);
565
566 int lprocfs_create_dir_namespace(struct proc_dir_entry* this_dev_root,
567                                  lprocfs_group_t* namespace,
568                                  unsigned int *num_dirs);
569
570 int lprocfs_getclass_idx(struct groupspace_index* group,
571                          const char* classname);
572 struct proc_dir_entry* lprocfs_mkinitdir(struct obd_device* device);
573 int lprocfs_get_idx(struct namespace_index* class, const char* dir_name);
574 unsigned int lprocfs_add_var(struct obd_device* device,
575                              struct proc_dir_entry* root,
576                              lprocfs_vars_t* variable,
577                              int dir_arr_index,
578                              int cnt_arr_index,
579                              unsigned int cnt_arr_size,
580                              lprofilers_e type);
581
582
583 void lprocfs_remove_all(struct proc_dir_entry* root);
584
585 /*
586  * List of read/write functions that will implement reading
587  * or writing to counters/other variables from userland
588  * processes. Note that the definition allows as many different
589  * functions to be defined as there are counter-variables.
590  * In practice, however, the module implementor is expected
591  * to have a different function only when the variable types are
592  * different, for e.g counter types will have one read/write
593  * function, while strings will have another.
594  *
595  */
596
597 int lprocfs_ll_rd(char* page, char **start, off_t off,
598                  int count, int *eof, void *data);
599 int lprocfs_ll_wr(struct file* file, const char *buffer,
600                   unsigned long count, void *data);
601
602 int rd_other(char* page, char **start, off_t off,
603              int count, int *eof, void *data);
604 int wr_other(struct file* file, const char *buffer,
605              unsigned long count, void *data);
606
607 int rd_string(char* page, char **start, off_t off,
608               int count, int *eof, void *data);
609 int wr_string(struct file* file, const char *buffer,
610               unsigned long count, void *data);
611
612 int rd_fs_type(char* page, char **start, off_t off,
613               int count, int *eof, void *data);
614
615 int rd_uuid(char* page, char **start, off_t off,
616              int count, int *eof, void *data);
617 int wr_uuid(struct file* file, const char *buffer,
618              unsigned long count, void *data);
619
620 int rd_uuid(char* page, char **start, off_t off,
621              int count, int *eof, void *data);
622
623 int rd_blksize(char* page, char **start, off_t off,
624              int count, int *eof, void *data);
625 int rd_blktotal(char* page, char **start, off_t off,
626              int count, int *eof, void *data);
627 int rd_blkfree(char* page, char **start, off_t off,
628              int count, int *eof, void *data);
629 int rd_kbfree(char* page, char **start, off_t off,
630              int count, int *eof, void *data);
631
632 int rd_numobjects(char* page, char **start, off_t off,
633              int count, int *eof, void *data);
634 int rd_objfree(char* page, char **start, off_t off,
635              int count, int *eof, void *data);
636
637 int rd_objgroups(char* page, char **start, off_t off,
638              int count, int *eof, void *data);
639
640
641 #else /* LProcFS not compiled */
642
643 #define DEV_PROF_START(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE) 0
644 #define DEV_PROF_END(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE) 0
645 #define DEV_PRINT_CNTR(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE) 0
646
647 static inline int lprocfs_get_nm(char* name, lprocfs_obd_nm_t* collection)
648 {
649         return -1;
650 }
651
652 static inline int lprocfs_reg_dev(struct obd_device* device,
653                                   lprocfs_group_t* namespace,
654                                   unsigned int cnt_struct_size)
655 {
656         return 0;
657 }
658
659 static inline int lprocfs_dereg_dev(struct obd_device* device)
660 {
661         return LPROCFS_SUCCESS;
662 }
663
664 static inline int lprocfs_reg_conn(unsigned int conn_number,
665                                    struct lprocfs_conn_namespace* nm)
666 {
667         return 0;
668 }
669
670 static inline int lprocfs_dereg_conn(unsigned int conn_number)
671 {
672         return 0;
673 }
674
675 static inline int lprocfs_add_export(unsigned int conn_number,
676                                      struct obd_device* device)
677 {
678         return 0;
679 }
680
681 static inline int lprocfs_add_import(unsigned int conn_number,
682                                      struct obd_device* device)
683 {
684         return 0;
685 }
686
687 static inline int lprocfs_remove_export(unsigned int conn_number,
688                                         struct obd_device* device)
689 {
690         return 0;
691 }
692
693 static inline int lprocfs_remove_import(unsigned int conn_number,
694                                         struct obd_device* device)
695 {
696         return 0;
697 }
698
699 #endif /* LPROCFS_EXISTS */
700
701 #endif /* __LPROCFS_H__ */