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