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
17 #include "afs/param.h"
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 /* functions for finding a particular event */
70 #define ICL_EVENTBYTE(x) (((x) & 0x3ff) >> 3)
71 #define ICL_EVENTMASK(x) (1 << ((x) & 0x7))
73 /* define ICL syscalls by name!! */
74 #define ICL_OP_COPYOUT 1
75 #define ICL_OP_ENUMLOGS 2
76 #define ICL_OP_CLRLOG 3
77 #define ICL_OP_CLRSET 4
78 #define ICL_OP_CLRALL 5
79 #define ICL_OP_ENUMSETS 6
80 #define ICL_OP_SETSTAT 7
81 #define ICL_OP_SETSTATALL 8
82 #define ICL_OP_SETLOGSIZE 9
83 #define ICL_OP_ENUMLOGSBYSET 10
84 #define ICL_OP_GETSETINFO 11
85 #define ICL_OP_GETLOGINFO 12
86 #define ICL_OP_COPYOUTCLR 13
87 /* Determine version number and type size info from icl package. */
88 #define ICL_OP_VERSION 14
90 /* define setstat commands */
91 #define ICL_OP_SS_ACTIVATE 1
92 #define ICL_OP_SS_DEACTIVATE 2
93 #define ICL_OP_SS_FREE 3
96 /* The format of the circular log is:
98 * <8 bits: size of record in longs> <6 bits: p1 type> <6 bits: p2 type>
99 * <6 bits: p3 type> <6 bits: p4 type>
102 * <32 bits: timestamp in microseconds>
108 * Note that the representation for each parm starts at a new 32 bit
109 * offset, and only the represented parameters are marshalled.
110 * You can tell if a particular parameter exists by looking at its
111 * type; type 0 means the parameter does not exist.
114 /* descriptor of the circular log. Note that it can never be 100% full
115 * since we break the ambiguity of head == tail by calling that
119 int refCount; /* reference count */
120 int setCount; /* number of non-FREED sets pointing to this guy */
121 osi_dlock_t lock; /* lock */
122 char *name; /* log name */
123 struct afs_icl_log *nextp; /* next log in system */
124 afs_int32 logSize; /* allocated # of elements in log */
125 afs_int32 logElements; /* # of elements in log right now */
126 afs_int32 *datap; /* pointer to the data */
127 afs_int32 firstUsed; /* first element used */
128 afs_int32 firstFree; /* index of first free dude */
129 long baseCookie; /* cookie value of first entry */
130 afs_int32 states; /* state bits */
131 afs_uint32 lastTS; /* last timestamp written to this log */
134 /* macro used to compute size of parameter when in log, used by
135 * afs_icl_AppendRecord below.
137 * Note that "tsize" and "rsize" are free variables!
138 * I use rsize to determine correct alignment (and hence size).
139 * The #ifdef's start to get unwieldly when the 32 bit kernels for SGI 6.2 are
140 * factored in. So, I'm going to a single macro with a variable for sizeof long.
141 * User space programs need to set this based on the size of the kernel long.
142 * Defined in afs_call.c and venus/fstrace.c
144 extern int afs_icl_sizeofLong;
146 #define ICL_SIZEHACK(t1, p1, ts1, rs1) \
148 if ((t1) == ICL_TYPE_STRING) { \
149 ts1 = (int)((unsigned)(strlen((char *)(p1)) + 4) >> 2); \
150 } else if ((t1) == ICL_TYPE_HYPER || (t1) == ICL_TYPE_INT64) \
152 else if ((t1) == ICL_TYPE_FID) \
154 else if ((t1) == ICL_TYPE_INT32) \
157 ts1 = afs_icl_sizeofLong; \
158 /* now add in the parameter */ \
163 #define ICL_LOGF_DELETED 1 /* freed */
164 #define ICL_LOGF_WAITING 2 /* waiting for output to appear */
165 #define ICL_LOGF_PERSISTENT 4 /* persistent */
167 /* macros for calling these things easily */
168 #define ICL_SETACTIVE(setp) ((setp) && (setp->states & ICL_SETF_ACTIVE))
169 #define afs_Trace0(set, id) \
170 (ICL_SETACTIVE(set) ? afs_icl_Event0(set, id, 1<<24) : 0)
171 #define afs_Trace1(set, id, t1, p1) \
172 (ICL_SETACTIVE(set) ? afs_icl_Event1(set, id, (1<<24)+((t1)<<18), (long)(p1)) : 0)
173 #define afs_Trace2(set, id, t1, p1, t2, p2) \
174 (ICL_SETACTIVE(set) ? afs_icl_Event2(set, id, (1<<24)+((t1)<<18)+((t2)<<12), \
175 (long)(p1), (long)(p2)) : 0)
176 #define afs_Trace3(set, id, t1, p1, t2, p2, t3, p3) \
177 (ICL_SETACTIVE(set) ? afs_icl_Event3(set, id, (1<<24)+((t1)<<18)+((t2)<<12)+((t3)<<6), \
178 (long)(p1), (long)(p2), (long)(p3)) : 0)
179 #define afs_Trace4(set, id, t1, p1, t2, p2, t3, p3, t4, p4) \
180 (ICL_SETACTIVE(set) ? afs_icl_Event4(set, id, (1<<24)+((t1)<<18)+((t2)<<12)+((t3)<<6)+(t4), \
181 (long)(p1), (long)(p2), (long)(p3), (long)(p4)) : 0)
183 /* types for icl_trace macros; values must be less than 64. If
184 * you add a new type here, don't forget to check for ICL_MAXEXPANSION
187 #define ICL_TYPE_NONE 0 /* parameter doesn't exist */
188 #define ICL_TYPE_LONG 1
189 #define ICL_TYPE_INT32 7
190 #define ICL_TYPE_POINTER 2
191 #define ICL_TYPE_HYPER 3
192 #define ICL_TYPE_STRING 4
193 #define ICL_TYPE_FID 5
194 #define ICL_TYPE_UNIXDATE 6
195 #define ICL_TYPE_INT64 8
197 #ifdef AFS_64BIT_CLIENT
198 #define ICL_TYPE_OFFSET ICL_TYPE_INT64
199 #define ICL_HANDLE_OFFSET(x) (&x)
200 #else /* AFS_64BIT_CLIENT */
201 #define ICL_TYPE_OFFSET ICL_TYPE_INT64
202 #define ICL_HANDLE_OFFSET(x) (x)
203 #endif /* AFS_64BIT_CLIENT */
205 /* max # of words put in the printf buffer per parameter */
206 #define ICL_MAXEXPANSION 4
208 /* define flags to be used by afs_icl_CreateSetWithFlags */
209 #define ICL_CRSET_FLAG_DEFAULT_ON 1
210 #define ICL_CRSET_FLAG_DEFAULT_OFF 2
211 #define ICL_CRSET_FLAG_PERSISTENT 4
213 /* define flags to be used by afs_icl_CreateLogWithFlags */
214 #define ICL_CRLOG_FLAG_PERSISTENT 1
217 #define ICL_COPYOUTF_WAITIO 1 /* block for output */
218 #define ICL_COPYOUTF_CLRAFTERREAD 2 /* clear log after reading */
220 #define ICL_COPYOUTF_MISSEDSOME 1 /* missed some output */
222 #define lock_ObtainWrite ObtainWriteLock
223 #define lock_ReleaseWrite ReleaseWriteLock
226 extern struct afs_icl_set *afs_iclSetp; /* standard icl trace */
227 /* A separate icl set to collect long term debugging info. */
228 extern struct afs_icl_set *afs_iclLongTermSetp;
230 #define osi_Alloc malloc
231 #define osi_Free(a,b) free(a)
233 #define ICL_RPC_MAX_SETS (64)
234 #define ICL_RPC_MAX_LOGS (64)
240 #define ICL_ERROR_NOSET 9001
241 #define ICL_ERROR_NOLOG 9002
242 #define ICL_ERROR_CANTOPEN 9003
243 #define ICL_INFO_TIMESTAMP 9004
245 #endif /* _ICL_H__ENV_ */