Whamcloud - gitweb
Replace all of the "char[37]" uses with obd_uuid_t.
[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(osc, mgmt_setup),
290         LPROCFS_NAMESPACE_ENUM(osc, mgmt_cleanup),
291         LPROCFS_NAMESPACE_ENUM(osc, mgmt_connect),
292         LPROCFS_NAMESPACE_ENUM(osc, mgmt_disconnect),
293         LPROCFS_NAMESPACE_ENUM(osc, create),
294         LPROCFS_NAMESPACE_ENUM(osc, destroy),
295         LPROCFS_NAMESPACE_ENUM(osc, getattr),
296         LPROCFS_NAMESPACE_ENUM(osc, setattr),
297         LPROCFS_NAMESPACE_ENUM(osc, open),
298         LPROCFS_NAMESPACE_ENUM(osc, close),
299         LPROCFS_NAMESPACE_ENUM(osc, brw),
300         LPROCFS_NAMESPACE_ENUM(osc, punch),
301         LPROCFS_NAMESPACE_ENUM(osc, summary),
302         LPROCFS_NAMESPACE_ENUM(osc, cancel),
303         LPROCFS_MAX_ENUM_DIR_OSC
304 };
305
306 enum {
307         LPROCFS_NAMESPACE_ENUM(ost, mgmt_setup),
308         LPROCFS_NAMESPACE_ENUM(ost, mgmt_cleanup),
309         LPROCFS_NAMESPACE_ENUM(ost, mgmt_connect),
310         LPROCFS_NAMESPACE_ENUM(ost, mgmt_disconnect),
311         LPROCFS_NAMESPACE_ENUM(ost, create),
312         LPROCFS_NAMESPACE_ENUM(ost, destroy),
313         LPROCFS_NAMESPACE_ENUM(ost, getattr),
314         LPROCFS_NAMESPACE_ENUM(ost, setattr),
315         LPROCFS_NAMESPACE_ENUM(ost, open),
316         LPROCFS_NAMESPACE_ENUM(ost, close),
317         LPROCFS_NAMESPACE_ENUM(ost, brw),
318         LPROCFS_NAMESPACE_ENUM(ost, punch),
319         LPROCFS_NAMESPACE_ENUM(ost, summary),
320         LPROCFS_NAMESPACE_ENUM(ost, cancel),
321         LPROCFS_NAMESPACE_ENUM(ost, getinfo),
322         LPROCFS_MAX_ENUM_DIR_OST
323 };
324
325 enum {
326         LPROCFS_NAMESPACE_ENUM(lov, mgmt_setup),
327         LPROCFS_NAMESPACE_ENUM(lov, mgmt_cleanup),
328         LPROCFS_NAMESPACE_ENUM(lov, mgmt_connect),
329         LPROCFS_NAMESPACE_ENUM(lov, mgmt_disconnect),
330         LPROCFS_NAMESPACE_ENUM(lov, create),
331         LPROCFS_NAMESPACE_ENUM(lov, destroy),
332         LPROCFS_NAMESPACE_ENUM(lov, getattr),
333         LPROCFS_NAMESPACE_ENUM(lov, setattr),
334         LPROCFS_NAMESPACE_ENUM(lov, open),
335         LPROCFS_NAMESPACE_ENUM(lov, close),
336         LPROCFS_NAMESPACE_ENUM(lov, brw),
337         LPROCFS_NAMESPACE_ENUM(lov, punch),
338         LPROCFS_NAMESPACE_ENUM(lov, summary),
339         LPROCFS_NAMESPACE_ENUM(lov, cancel),
340         LPROCFS_NAMESPACE_ENUM(lov, getinfo),
341         LPROCFS_MAX_ENUM_DIR_LOV
342 };
343
344 enum {
345         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_setup),
346         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_cleanup),
347         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_connect),
348         LPROCFS_NAMESPACE_ENUM(obdfilter, mgmt_disconnect),
349         LPROCFS_NAMESPACE_ENUM(obdfilter, create),
350         LPROCFS_NAMESPACE_ENUM(obdfilter, destroy),
351         LPROCFS_NAMESPACE_ENUM(obdfilter, getattr),
352         LPROCFS_NAMESPACE_ENUM(obdfilter, setattr),
353         LPROCFS_NAMESPACE_ENUM(obdfilter, open),
354         LPROCFS_NAMESPACE_ENUM(obdfilter, close),
355         LPROCFS_NAMESPACE_ENUM(obdfilter, brw),
356         LPROCFS_NAMESPACE_ENUM(obdfilter, punch),
357         LPROCFS_NAMESPACE_ENUM(obdfilter, summary),
358         LPROCFS_NAMESPACE_ENUM(obdfilter, cancel),
359         LPROCFS_NAMESPACE_ENUM(obdfilter, getinfo),
360         LPROCFS_MAX_ENUM_DIR_OBDFILTER
361 };
362
363 enum {
364         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_setup),
365         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_cleanup),
366         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_connect),
367         LPROCFS_NAMESPACE_ENUM(ldlm, mgmt_disconnect),
368         LPROCFS_NAMESPACE_ENUM(ldlm, locks_enqueus),
369         LPROCFS_NAMESPACE_ENUM(ldlm, locks_cancels),
370         LPROCFS_NAMESPACE_ENUM(ldlm, locks_converts),
371         LPROCFS_NAMESPACE_ENUM(ldlm, locks_matches),
372         LPROCFS_MAX_ENUM_DIR_LDLM
373 };
374
375 enum {
376         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_setup),
377         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_cleanup),
378         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_connect),
379         LPROCFS_NAMESPACE_ENUM(ptlrpc, mgmt_disconnect),
380         LPROCFS_NAMESPACE_ENUM(ptlrpc, counters),
381         LPROCFS_NAMESPACE_ENUM(ptlrpc, network),
382         LPROCFS_MAX_ENUM_DIR_PTLRPC
383 };
384
385 #define LPROCFS_DIR_INDEX(CLASS, DIR) \
386                          [LPROCFS_NAMESPACE_ENUM(CLASS, DIR)]={#DIR}
387
388 /*
389  * Similar rule for profiling counters
390  */
391
392
393 enum {
394         LPROCFS_NAMESPACE_ENUM(mdc, min_time),
395         LPROCFS_NAMESPACE_ENUM(mdc, max_time),
396         LPROCFS_NAMESPACE_ENUM(mdc, sum_time),
397         LPROCFS_NAMESPACE_ENUM(mdc, num_ops),
398         LPROF_MDC_MAX
399 };
400
401 enum {
402         LPROCFS_NAMESPACE_ENUM(mds, min_time),
403         LPROCFS_NAMESPACE_ENUM(mds, max_time),
404         LPROCFS_NAMESPACE_ENUM(mds, sum_time),
405         LPROCFS_NAMESPACE_ENUM(mds, num_ops),
406         LPROF_MDS_MAX
407 };
408
409 enum {
410         LPROCFS_NAMESPACE_ENUM(osc, min_time),
411         LPROCFS_NAMESPACE_ENUM(osc, max_time),
412         LPROCFS_NAMESPACE_ENUM(osc, sum_time),
413         LPROCFS_NAMESPACE_ENUM(osc, num_ops),
414         LPROF_OSC_MAX
415 };
416
417 enum {
418         LPROCFS_NAMESPACE_ENUM(ost, min_time),
419         LPROCFS_NAMESPACE_ENUM(ost, max_time),
420         LPROCFS_NAMESPACE_ENUM(ost, sum_time),
421         LPROCFS_NAMESPACE_ENUM(ost, num_ops),
422         LPROF_OST_MAX
423 };
424
425 enum {
426         LPROCFS_NAMESPACE_ENUM(lov, min_time),
427         LPROCFS_NAMESPACE_ENUM(lov, max_time),
428         LPROCFS_NAMESPACE_ENUM(lov, sum_time),
429         LPROCFS_NAMESPACE_ENUM(lov, num_ops),
430         LPROF_LOV_MAX
431 };
432
433 enum {
434         LPROCFS_NAMESPACE_ENUM(obdfilter, min_time),
435         LPROCFS_NAMESPACE_ENUM(obdfilter, max_time),
436         LPROCFS_NAMESPACE_ENUM(obdfilter, sum_time),
437         LPROCFS_NAMESPACE_ENUM(obdfilter, num_ops),
438         LPROF_OBDFILTER_MAX
439 };
440
441
442 enum {
443         LPROCFS_NAMESPACE_ENUM(ldlm, min_time),
444         LPROCFS_NAMESPACE_ENUM(ldlm, max_time),
445         LPROCFS_NAMESPACE_ENUM(ldlm, sum_time),
446         LPROCFS_NAMESPACE_ENUM(ldlm, num_ops),
447         LPROCFS_NAMESPACE_ENUM(ldlm, num_total),
448         LPROCFS_NAMESPACE_ENUM(ldlm, num_zerolatency),
449         LPROCFS_NAMESPACE_ENUM(ldlm, num_zerolatency_inflight),
450         LPROCFS_NAMESPACE_ENUM(ldlm, num_zerolatency_done),
451         LPROCFS_NAMESPACE_ENUM(ldlm, nonzero_mintime),
452         LPROCFS_NAMESPACE_ENUM(ldlm, nonzero_maxtime),
453         LPROCFS_NAMESPACE_ENUM(ldlm, nonzero_sumtime),
454         LPROF_LDLM_MAX
455 };
456
457 enum {
458         LPROCFS_NAMESPACE_ENUM(ptlrpc, min_time),
459         LPROCFS_NAMESPACE_ENUM(ptlrpc, max_time),
460         LPROCFS_NAMESPACE_ENUM(ptlrpc, sum_time),
461         LPROCFS_NAMESPACE_ENUM(ptlrpc, num_ops),
462
463         LPROCFS_NAMESPACE_ENUM(ptlrpc, msgs_alloc),
464         LPROCFS_NAMESPACE_ENUM(ptlrpc, msgs_max),
465         LPROCFS_NAMESPACE_ENUM(ptlrpc, recv_count),
466         LPROCFS_NAMESPACE_ENUM(ptlrpc, recv_length),
467         LPROCFS_NAMESPACE_ENUM(ptlrpc, send_count),
468         LPROCFS_NAMESPACE_ENUM(ptlrpc, send_length),
469         LPROCFS_NAMESPACE_ENUM(ptlrpc, portal_kmemory),
470         LPROF_PTLRPC_MAX
471
472 };
473
474 /*
475  * and for groups
476  */
477 #define LPROCFS_ENUM(X) e_##X
478
479 enum {
480         LPROCFS_ENUM(mdc),
481         LPROCFS_ENUM(mds),
482         LPROCFS_ENUM(osc),
483         LPROCFS_ENUM(ost),
484         LPROCFS_ENUM(lov),
485         LPROCFS_ENUM(obdfilter),
486         LPROCFS_ENUM(ldlm),
487         LPROCFS_ENUM(ptlrpc),
488         LPROCFS_GROUP_MAX
489 };
490
491 #define LPROCFS_CNTR_INDEX(CLASS, NAME) \
492                    [LPROCFS_NAMESPACE_ENUM(CLASS, NAME)]={#NAME}
493
494 #define LPROCFS_GROUP_CREATE(CLASS) \
495       [LPROCFS_ENUM(CLASS)]={#CLASS, dir_##CLASS##_index, prof_##CLASS##_index}
496
497 /*
498  * OBD Namespace API: Obtain the namespace group index, given a name
499  */
500 int lprocfs_get_nm(char* name, lprocfs_obd_nm_t* collection);
501
502
503
504 /*
505  * OBD device APIs
506  */
507
508 int lprocfs_reg_dev(struct obd_device* device, lprocfs_group_t* namespace,
509                     unsigned int cnt_struct_size);
510
511 int lprocfs_dereg_dev(struct obd_device* device);
512
513 /*
514  * Connections API
515  */
516 int lprocfs_reg_conn(unsigned int conn_number,
517                      struct lprocfs_conn_namespace* namespace);
518 int lprocfs_dereg_conn(unsigned int conn_number);
519
520 /*
521  * Import/Export APIs
522  */
523 int lprocfs_add_export(unsigned int conn_number,
524                        struct obd_device* device);
525 int lprocfs_add_import(unsigned int conn_number,
526                        struct obd_device* device);
527 int lprocfs_remove_export(unsigned int conn_number,
528                           struct obd_device* device);
529 int lprocfs_remove_import(unsigned int conn_number,
530                           struct obd_device* device);
531
532 /*
533  * Utility functions
534  */
535
536 struct proc_dir_entry* lprocfs_add_dir(struct proc_dir_entry* root,
537                                        const char* name,
538                                        const char* tok,
539                                        unsigned int* escape);
540
541
542 struct proc_dir_entry* lprocfs_mkdir(const char* dname,
543                                      struct proc_dir_entry *parent);
544
545
546 struct proc_dir_entry* lprocfs_bfs_srch(struct proc_dir_entry* root,
547                                         const char* name);
548
549 struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head,
550                                     const char* name);
551
552 int lprocfs_link_dir_counters(struct obd_device* device,
553                               struct proc_dir_entry* this_dev_root,
554                               lprocfs_group_t* namespace,
555                               unsigned int cnt_struct_size,
556                               unsigned int class_array_index);
557
558 int lprocfs_create_dir_namespace(struct proc_dir_entry* this_dev_root,
559                                  lprocfs_group_t* namespace,
560                                  unsigned int *num_dirs);
561
562 int lprocfs_getclass_idx(struct groupspace_index* group,
563                          const char* classname);
564 struct proc_dir_entry* lprocfs_mkinitdir(struct obd_device* device);
565 int lprocfs_get_idx(struct namespace_index* class, const char* dir_name);
566 unsigned int lprocfs_add_var(struct obd_device* device,
567                              struct proc_dir_entry* root,
568                              lprocfs_vars_t* variable,
569                              int dir_arr_index,
570                              int cnt_arr_index,
571                              unsigned int cnt_arr_size,
572                              lprofilers_e type);
573
574
575 void lprocfs_remove_all(struct proc_dir_entry* root);
576
577 /*
578  * List of read/write functions that will implement reading
579  * or writing to counters/other variables from userland
580  * processes. Note that the definition allows as many different
581  * functions to be defined as there are counter-variables.
582  * In practice, however, the module implementor is expected
583  * to have a different function only when the variable types are
584  * different, for e.g counter types will have one read/write
585  * function, while strings will have another.
586  *
587  */
588
589 int lprocfs_ll_rd(char* page, char **start, off_t off,
590                  int count, int *eof, void *data);
591 int lprocfs_ll_wr(struct file* file, const char *buffer,
592                   unsigned long count, void *data);
593
594 int rd_other(char* page, char **start, off_t off,
595              int count, int *eof, void *data);
596 int wr_other(struct file* file, const char *buffer,
597              unsigned long count, void *data);
598
599 int rd_string(char* page, char **start, off_t off,
600               int count, int *eof, void *data);
601 int wr_string(struct file* file, const char *buffer,
602               unsigned long count, void *data);
603
604
605
606
607 #else /* LProcFS not compiled */
608
609 #define DEV_PROF_START(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE) 0
610 #define DEV_PROF_END(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE) 0
611 #define DEV_PRINT_CNTR(DEV_CLASS, OBD, PROF_CLASS, ATTRIBUTE) 0
612
613 static inline int lprocfs_get_nm(char* name, lprocfs_obd_nm_t* collection)
614 {
615         return -1;
616 }
617
618 static inline int lprocfs_reg_dev(struct obd_device* device,
619                                   lprocfs_group_t* namespace,
620                                   unsigned int cnt_struct_size)
621 {
622         return 0;
623 }
624
625 static inline int lprocfs_dereg_dev(struct obd_device* device)
626 {
627         return LPROCFS_SUCCESS;
628 }
629
630 static inline int lprocfs_reg_conn(unsigned int conn_number,
631                                    struct lprocfs_conn_namespace* nm)
632 {
633         return 0;
634 }
635
636 static inline int lprocfs_dereg_conn(unsigned int conn_number)
637 {
638         return 0;
639 }
640
641 static inline int lprocfs_add_export(unsigned int conn_number,
642                                      struct obd_device* device)
643 {
644         return 0;
645 }
646
647 static inline int lprocfs_add_import(unsigned int conn_number,
648                                      struct obd_device* device)
649 {
650         return 0;
651 }
652
653 static inline int lprocfs_remove_export(unsigned int conn_number,
654                                         struct obd_device* device)
655 {
656         return 0;
657 }
658
659 static inline int lprocfs_remove_import(unsigned int conn_number,
660                                         struct obd_device* device)
661 {
662         return 0;
663 }
664
665 #endif /* LPROCFS_EXISTS */
666
667 #endif /* __LPROCFS_H__ */