source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/include/cxi/lxtrace.h @ 16

Last change on this file since 16 was 16, checked in by rock, 16 years ago
File size: 6.8 KB
Line 
1/***************************************************************************
2 *
3 * Copyright (C) 2001 International Business Machines
4 * All rights reserved.
5 *
6 * This file is part of the GPFS mmfslinux kernel module.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 *  1. Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *  2. Redistributions in binary form must reproduce the above copyright
15 *     notice, this list of conditions and the following disclaimer in the
16 *     documentation and/or other materials provided with the distribution.
17 *  3. The name of the author may not be used to endorse or promote products
18 *     derived from this software without specific prior written
19 *     permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *************************************************************************** */
33/* @(#)99 1.10  src/avs/fs/mmfs/ts/kernext/ibm-linux/lxtrace.h, mmfs, avs_rgpfs24, rgpfs240610b 1/13/05 19:11:45 */
34
35#ifndef _h_lxtrace
36#define _h_lxtrace
37
38/*
39 * Interfaces to the Linux kernel trace device
40 *
41 */
42
43#ifndef _LINUX_TIME_H
44#include <sys/time.h>
45#endif
46
47/* Size of the ioctl trc_dump output buffer */
48#define LXTRACE_DUMP_SIZE 512
49
50#define LXTRACE_MAX_DATA 512
51#define LXTRACE_MAGIC 0xACE98271
52
53/* Number of "$n" substitutions supported in a single trace record */
54#define LXTRACE_MAX_FORMAT_SUBS 20
55
56
57/* Definitions of the trace record format */
58typedef struct
59{
60  uint trMagic;         /* Magic number to allow resynch after trace
61                           wraparound */
62  struct timeval trTime;/* Timestamp of trace record */
63  pid_t trProcess;      /* ID of process making the trace */
64  unsigned char trBuf;  /* bufNum of buffer used for trace */
65  unsigned char trCPU;  /* CPU number of process making the trace */
66  short trLength;       /* Number of bytes that follow, consisting of a
67                           trc_datahdr_t followed by the application
68                           data */
69} trc_header_t;
70/* Followed by the application trace data "char data[Length]" */
71
72/* The following device operations are supported for the trace device:
73    trc_open     Prepare the device for tracing
74    trc_ioctl    Device control operation (see the trace_op definition)
75    trc_read     Allows the daemon to retrieve the trace records
76    trc_write    Trace records are writen to the device
77    trc_fsync    Sync all buffered data to the daemon
78    trc_close    Terminate tracing and close the device
79*/
80
81/* Device ioctl operations */
82enum trace_op
83{
84  trc_begin,    /* Enable tracing for the specified trace types */
85  trc_end,      /* Fence new writes in preparation for close */
86  trc_bufSize,  /* Change the device buffer size */
87  trc_dump      /* Dump trace state information */
88};
89
90/* Structure for passing parameters to the trace device through ioctls */
91struct kArgs
92{
93  long arg1;
94  long arg2;
95  long arg3;
96  long arg4;
97  long arg5;
98};
99
100
101#ifdef __cplusplus
102extern "C"
103{
104#endif
105int trc_fsync();
106#ifdef __cplusplus
107}
108#endif
109
110
111/* Allowable file sizes for the lxtrace command */
112#define MIN_TRC_FILESIZE 1*1024*1024
113#define DEF_TRC_FILESIZE 16*1024*1024
114#define MAX_TRC_FILESIZE 1024*1024*1024
115
116/* Allowable buffer sizes for the lxtrace command.  Two buffers of this
117   size will be allocated. */
118#define MIN_TRC_BUFSIZE 4096
119#define DEF_TRC_BUFSIZE 64*1024
120#define MAX_TRC_BUFSIZE 1024*1024
121
122/* Trace device name */
123#define TRC_DEVICE "/dev/trace0"
124
125/* Header of a trace record to be passed to the trace device */
126typedef struct
127{
128  uint trHook;          /* Trace hook word that uniquely identifies the
129                           format of this trace record */
130  char trNArgs;         /* Number of integer arguments.  Each argument is as
131                           long as the word width of the machine.  Does not
132                           count string, generic, or float arguments. */
133  unsigned char trSPos; /* Position of string argument within argument list.
134                           May also take on special values to indicate all
135                           integers or all integers followed by a float. */
136  short trSLen;         /* If format is string or generic, contains the length
137                           of the variable part, rounded up to a multiple
138                           of the word size */
139} trc_datahdr_t;
140/* followed by char arg[LXTRACE_MAX_DATA-sizeof(trc_datahdr_t)] */
141
142
143#ifdef __KERNEL__
144/* Trace device structures */
145
146/* Possible states of the trace device */
147typedef enum trcdev_state_t
148{
149  trc_initialized,  /* header constructed */
150  trc_opened,       /* device opened      */
151  trc_active,       /* ready for tracing  */
152  trc_stopped       /* tracing disabled   */
153} trcdev_state_t;
154
155typedef struct trcdev_buffer_t
156{
157  char * beginP; /* first byte of the buffer */
158  char * endP;   /* last byte of the buffer */
159  char * nextP;  /* offset of next record to be read/written */
160  char * dirtyP; /* offset of next byte to be read */
161  int bufNum;    /* buffer number */
162} trcdev_buffer_t;
163
164typedef struct trcdev_header_t
165{
166  int major;                /* major number of the trace device */
167  int minor;                /* minor number of the trace device */
168  int bufSize;              /* number of bytes in the trace buffers */
169  int nOpens;               /* number of times the device is open */
170  int nWaits;               /* number of times we had to wait for the daemon */
171  int nBuffers;             /* number of buffers filled with trace data */
172  int nLost;                /* number of traces lost due to full buffer */
173  trcdev_state_t state;     /* status of the trace device */
174  trcdev_buffer_t writeBuf; /* The trace buffer being written */
175  trcdev_buffer_t readBuf;  /* The buffer being read by the daemon */
176  trc_header_t * tHdrP;     /* address of trc_header_t for the record
177                               currently being appended */
178  trc_datahdr_t * hdrP;     /* address of trc_datahdr_t for the record
179                               currently being appended */
180} trcdev_header_t;
181#endif /* __KERNEL __ */
182#endif /* _h_lxtrace */
Note: See TracBrowser for help on using the repository browser.