2
* Copyright 2000, International Business Machines Corporation and others.
5
* This software has been released under the terms of the IBM Public
6
* License. For details, see the LICENSE file in the top-level source
7
* directory or online at http://www.openafs.org/dl/license10.html
14
#define _ICL_H__ENV_ 1
20
#include "afs_trace.h"
23
typedef struct Lock afs_lock_t;
26
#define ICL_LOGSPERSET 8 /* max logs per set */
27
#define ICL_DEFAULTEVENTS 1024 /* default events per event set */
28
#define ICL_DEFAULT_LOGSIZE 60*1024 /* number of words in default log size */
30
#define osi_dlock_t afs_lock_t
31
extern osi_dlock_t afs_icl_lock; /* lock for log and set refcounts */
32
extern int afs_icl_inited;
33
extern struct afs_icl_log *afs_icl_allLogs;
34
extern struct afs_icl_set *afs_icl_allSets;
36
/* define an in-core logging package */
38
afs_int32 refCount; /* reference count */
39
afs_int32 states; /* state flags */
40
osi_dlock_t lock; /* lock */
41
struct afs_icl_set *nextp; /* next dude in all known tables */
42
char *name; /* name of set */
43
struct afs_icl_log *logs[ICL_LOGSPERSET]; /* logs */
44
afs_int32 nevents; /* count of events */
45
char *eventFlags; /* pointer to event flags */
49
#define ICL_SETF_DELETED 1
50
#define ICL_SETF_ACTIVE 2
51
#define ICL_SETF_FREED 4
52
#define ICL_SETF_PERSISTENT 8
54
#ifdef ICL_DEFAULT_ENABLED
55
#define ICL_DEFAULT_SET_STATES 0 /* was ICL_SETF_ACTIVE*/
56
#else /* ICL_DEFAULT_ENABLED */
58
#ifdef ICL_DEFAULT_DISABLED
59
#define ICL_DEFAULT_SET_STATES ICL_SETF_FREED
60
#endif /* ICL_DEFAULT_DISABLED */
62
#endif /* ICL_DEFAULT_ENABLED */
64
#ifndef ICL_DEFAULT_SET_STATES
65
/* if not changed already, default to ACTIVE on created sets */
66
#define ICL_DEFAULT_SET_STATES 0 /* was ICL_SETF_ACTIVE */
67
#endif /* ICL_DEFAULT_SET_STATES */
69
/* bytes required by eventFlags array, for x events */
70
#define ICL_EVENTBYTES(x) ((((x) - 1) | 7) + 1)
72
/* functions for finding a particular event */
73
#define ICL_EVENTBYTE(x) (((x) & 0x3ff) >> 3)
74
#define ICL_EVENTMASK(x) (1 << ((x) & 0x7))
75
#define ICL_EVENTOK(setp, x) ((x&0x3ff) >= 0 && (x&0x3ff) < (setp)->nevents)
77
/* define ICL syscalls by name!! */
78
#define ICL_OP_COPYOUT 1
79
#define ICL_OP_ENUMLOGS 2
80
#define ICL_OP_CLRLOG 3
81
#define ICL_OP_CLRSET 4
82
#define ICL_OP_CLRALL 5
83
#define ICL_OP_ENUMSETS 6
84
#define ICL_OP_SETSTAT 7
85
#define ICL_OP_SETSTATALL 8
86
#define ICL_OP_SETLOGSIZE 9
87
#define ICL_OP_ENUMLOGSBYSET 10
88
#define ICL_OP_GETSETINFO 11
89
#define ICL_OP_GETLOGINFO 12
90
#define ICL_OP_COPYOUTCLR 13
91
/* Determine version number and type size info from icl package. */
92
#define ICL_OP_VERSION 14
94
/* define setstat commands */
95
#define ICL_OP_SS_ACTIVATE 1
96
#define ICL_OP_SS_DEACTIVATE 2
97
#define ICL_OP_SS_FREE 3
99
/* define set status flags */
100
#define ICL_FLAG_ACTIVE 1
101
#define ICL_FLAG_FREED 2
103
/* The format of the circular log is:
105
* <8 bits: size of record in longs> <6 bits: p1 type> <6 bits: p2 type>
106
* <6 bits: p3 type> <6 bits: p4 type>
109
* <32 bits: timestamp in microseconds>
115
* Note that the representation for each parm starts at a new 32 bit
116
* offset, and only the represented parameters are marshalled.
117
* You can tell if a particular parameter exists by looking at its
118
* type; type 0 means the parameter does not exist.
121
/* descriptor of the circular log. Note that it can never be 100% full
122
* since we break the ambiguity of head == tail by calling that
126
int refCount; /* reference count */
127
int setCount; /* number of non-FREED sets pointing to this guy */
128
osi_dlock_t lock; /* lock */
129
char *name; /* log name */
130
struct afs_icl_log *nextp; /* next log in system */
131
afs_int32 logSize; /* allocated # of elements in log */
132
afs_int32 logElements; /* # of elements in log right now */
133
afs_int32 *datap; /* pointer to the data */
134
afs_int32 firstUsed; /* first element used */
135
afs_int32 firstFree; /* index of first free dude */
136
long baseCookie; /* cookie value of first entry */
137
afs_int32 states; /* state bits */
138
afs_uint32 lastTS; /* last timestamp written to this log */
141
/* macro used to compute size of parameter when in log, used by
142
* afs_icl_AppendRecord below.
144
* Note that "tsize" and "rsize" are free variables!
145
* I use rsize to determine correct alignment (and hence size).
146
* The #ifdef's start to get unwieldly when the 32 bit kernels for SGI 6.2 are
147
* factored in. So, I'm going to a single macro with a variable for sizeof long.
148
* User space programs need to set this based on the size of the kernel long.
149
* Defined in afs_call.c and venus/fstrace.c
151
extern int afs_icl_sizeofLong;
153
#define ICL_SIZEHACK(t1, p1) \
155
if ((t1) == ICL_TYPE_STRING) { \
156
tsize = (int)((unsigned)(strlen((char *)(p1)) + 4) >> 2); \
157
} else if ((t1) == ICL_TYPE_HYPER) \
159
else if ((t1) == ICL_TYPE_FID) \
161
else if ((t1) == ICL_TYPE_INT32) \
164
tsize = afs_icl_sizeofLong; \
165
/* now add in the parameter */ \
170
#define ICL_LOGF_DELETED 1 /* freed */
171
#define ICL_LOGF_WAITING 2 /* waiting for output to appear */
172
#define ICL_LOGF_PERSISTENT 4 /* persistent */
174
/* macros for calling these things easily */
175
#define ICL_SETACTIVE(setp) ((setp) && (setp->states & ICL_SETF_ACTIVE))
176
#define afs_Trace0(set, id) \
177
(ICL_SETACTIVE(set) ? afs_icl_Event0(set, id, 1<<24) : 0)
178
#define afs_Trace1(set, id, t1, p1) \
179
(ICL_SETACTIVE(set) ? afs_icl_Event1(set, id, (1<<24)+((t1)<<18), (long)(p1)) : 0)
180
#define afs_Trace2(set, id, t1, p1, t2, p2) \
181
(ICL_SETACTIVE(set) ? afs_icl_Event2(set, id, (1<<24)+((t1)<<18)+((t2)<<12), \
182
(long)(p1), (long)(p2)) : 0)
183
#define afs_Trace3(set, id, t1, p1, t2, p2, t3, p3) \
184
(ICL_SETACTIVE(set) ? afs_icl_Event3(set, id, (1<<24)+((t1)<<18)+((t2)<<12)+((t3)<<6), \
185
(long)(p1), (long)(p2), (long)(p3)) : 0)
186
#define afs_Trace4(set, id, t1, p1, t2, p2, t3, p3, t4, p4) \
187
(ICL_SETACTIVE(set) ? afs_icl_Event4(set, id, (1<<24)+((t1)<<18)+((t2)<<12)+((t3)<<6)+(t4), \
188
(long)(p1), (long)(p2), (long)(p3), (long)(p4)) : 0)
190
/* types for icl_trace macros; values must be less than 64. If
191
* you add a new type here, don't forget to check for ICL_MAXEXPANSION
194
#define ICL_TYPE_NONE 0 /* parameter doesn't exist */
195
#define ICL_TYPE_LONG 1
196
#define ICL_TYPE_INT32 7
197
#define ICL_TYPE_POINTER 2
198
#define ICL_TYPE_HYPER 3
199
#define ICL_TYPE_STRING 4
200
#define ICL_TYPE_FID 5
201
#define ICL_TYPE_UNIXDATE 6
203
/* max # of words put in the printf buffer per parameter */
204
#define ICL_MAXEXPANSION 4
206
/* define flags to be used by afs_icl_CreateSetWithFlags */
207
#define ICL_CRSET_FLAG_DEFAULT_ON 1
208
#define ICL_CRSET_FLAG_DEFAULT_OFF 2
209
#define ICL_CRSET_FLAG_PERSISTENT 4
211
/* define flags to be used by afs_icl_CreateLogWithFlags */
212
#define ICL_CRLOG_FLAG_PERSISTENT 1
215
#define ICL_COPYOUTF_WAITIO 1 /* block for output */
216
#define ICL_COPYOUTF_CLRAFTERREAD 2 /* clear log after reading */
218
#define ICL_COPYOUTF_MISSEDSOME 1 /* missed some output */
220
#define lock_ObtainWrite ObtainWriteLock
221
#define lock_ReleaseWrite ReleaseWriteLock
224
extern struct afs_icl_set *afs_iclSetp; /* standard icl trace */
225
/* A separate icl set to collect long term debugging info. */
226
extern struct afs_icl_set *afs_iclLongTermSetp;
228
#define osi_Alloc malloc
229
#define osi_Free(a,b) free(a)
231
#define ICL_RPC_MAX_SETS (64)
232
#define ICL_RPC_MAX_LOGS (64)
234
typedef struct afs_icl_setinfo {
239
typedef struct afs_icl_loginfo {
242
afs_uint32 logElements;
246
typedef struct afs_icl_bulkSetinfo {
248
afs_icl_setinfo_t setinfo[1];
249
} afs_icl_bulkSetinfo_t;
251
typedef struct afs_icl_bulkLoginfo {
253
afs_icl_loginfo_t loginfo[1];
254
} afs_icl_bulkLoginfo_t;
259
#define ICL_ERROR_NOSET 9001
260
#define ICL_ERROR_NOLOG 9002
261
#define ICL_ERROR_CANTOPEN 9003
262
#define ICL_INFO_TIMESTAMP 9004
264
#endif /* _ICL_H__ENV_ */