/*************************************************************************** * * Copyright (C) 2001 International Business Machines * All rights reserved. * * This file is part of the GPFS mmfslinux kernel module. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *************************************************************************** */ /* @(#)99 1.10 src/avs/fs/mmfs/ts/kernext/ibm-linux/lxtrace.h, mmfs, avs_rgpfs24, rgpfs240610b 1/13/05 19:11:45 */ #ifndef _h_lxtrace #define _h_lxtrace /* * Interfaces to the Linux kernel trace device * */ #ifndef _LINUX_TIME_H #include #endif /* Size of the ioctl trc_dump output buffer */ #define LXTRACE_DUMP_SIZE 512 #define LXTRACE_MAX_DATA 512 #define LXTRACE_MAGIC 0xACE98271 /* Number of "$n" substitutions supported in a single trace record */ #define LXTRACE_MAX_FORMAT_SUBS 20 /* Definitions of the trace record format */ typedef struct { uint trMagic; /* Magic number to allow resynch after trace wraparound */ struct timeval trTime;/* Timestamp of trace record */ pid_t trProcess; /* ID of process making the trace */ unsigned char trBuf; /* bufNum of buffer used for trace */ unsigned char trCPU; /* CPU number of process making the trace */ short trLength; /* Number of bytes that follow, consisting of a trc_datahdr_t followed by the application data */ } trc_header_t; /* Followed by the application trace data "char data[Length]" */ /* The following device operations are supported for the trace device: trc_open Prepare the device for tracing trc_ioctl Device control operation (see the trace_op definition) trc_read Allows the daemon to retrieve the trace records trc_write Trace records are writen to the device trc_fsync Sync all buffered data to the daemon trc_close Terminate tracing and close the device */ /* Device ioctl operations */ enum trace_op { trc_begin, /* Enable tracing for the specified trace types */ trc_end, /* Fence new writes in preparation for close */ trc_bufSize, /* Change the device buffer size */ trc_dump /* Dump trace state information */ }; /* Structure for passing parameters to the trace device through ioctls */ struct kArgs { long arg1; long arg2; long arg3; long arg4; long arg5; }; #ifdef __cplusplus extern "C" { #endif int trc_fsync(); #ifdef __cplusplus } #endif /* Allowable file sizes for the lxtrace command */ #define MIN_TRC_FILESIZE 1*1024*1024 #define DEF_TRC_FILESIZE 16*1024*1024 #define MAX_TRC_FILESIZE 1024*1024*1024 /* Allowable buffer sizes for the lxtrace command. Two buffers of this size will be allocated. */ #define MIN_TRC_BUFSIZE 4096 #define DEF_TRC_BUFSIZE 64*1024 #define MAX_TRC_BUFSIZE 1024*1024 /* Trace device name */ #define TRC_DEVICE "/dev/trace0" /* Header of a trace record to be passed to the trace device */ typedef struct { uint trHook; /* Trace hook word that uniquely identifies the format of this trace record */ char trNArgs; /* Number of integer arguments. Each argument is as long as the word width of the machine. Does not count string, generic, or float arguments. */ unsigned char trSPos; /* Position of string argument within argument list. May also take on special values to indicate all integers or all integers followed by a float. */ short trSLen; /* If format is string or generic, contains the length of the variable part, rounded up to a multiple of the word size */ } trc_datahdr_t; /* followed by char arg[LXTRACE_MAX_DATA-sizeof(trc_datahdr_t)] */ #ifdef __KERNEL__ /* Trace device structures */ /* Possible states of the trace device */ typedef enum trcdev_state_t { trc_initialized, /* header constructed */ trc_opened, /* device opened */ trc_active, /* ready for tracing */ trc_stopped /* tracing disabled */ } trcdev_state_t; typedef struct trcdev_buffer_t { char * beginP; /* first byte of the buffer */ char * endP; /* last byte of the buffer */ char * nextP; /* offset of next record to be read/written */ char * dirtyP; /* offset of next byte to be read */ int bufNum; /* buffer number */ } trcdev_buffer_t; typedef struct trcdev_header_t { int major; /* major number of the trace device */ int minor; /* minor number of the trace device */ int bufSize; /* number of bytes in the trace buffers */ int nOpens; /* number of times the device is open */ int nWaits; /* number of times we had to wait for the daemon */ int nBuffers; /* number of buffers filled with trace data */ int nLost; /* number of traces lost due to full buffer */ trcdev_state_t state; /* status of the trace device */ trcdev_buffer_t writeBuf; /* The trace buffer being written */ trcdev_buffer_t readBuf; /* The buffer being read by the daemon */ trc_header_t * tHdrP; /* address of trc_header_t for the record currently being appended */ trc_datahdr_t * hdrP; /* address of trc_datahdr_t for the record currently being appended */ } trcdev_header_t; #endif /* __KERNEL __ */ #endif /* _h_lxtrace */