
https://github.com/ZhouHeyu/disksim-FTL/blob/master/disksim_hptrace.h





/* HPLabs Trace Record Types */

#define HPL_UNKNOWN		0
#define HPL_SHORTIO		1
#define HPL_LONGIO		2
#define HPL_TEXTIO		3
#define HPL_SUSPECTIO		4
#define HPL_BREADFS		5
#define HPL_BREADAFS		6
#define HPL_BREADAAFS		7
#define HPL_BDWRITEFS		8
#define HPL_BWRITEFS		9
#define HPL_CREATE_OPENFS	10

/*
File tr_buf.h from HPL TraceAccess code
// These buffer types are taken from HP-UX vers 8.0.  In future versions, the 
// actual bit positions of these types may change (as did in 9.0 when B_SYNC
// became 0x00800000.  So these are what the SRT files use as the flags.
// The only trick comes in converting KI files to srt files and knowing that 
// the B_SYNC in the particular version of HP-UX that was traced needs to map
// to this value of B_SYNC.

// The HPL values match one for one with the values in HP-UX 8.0.  Those B_
// values that have a 9 after them are the changes from 8.0 to 9.0 values,
// so these need to be converted back to 8.0 values before processing ki
// traces.
*/

#define	HPL_WRITE	  0x00000000	/* non-read pseudo-flag */
#define	HPL_READ	  0x00000001	/* read when I/O occurs */
#define	HPL_DONE	  0x00000002	/* transaction finished */
#define	HPL_ERROR	  0x00000004	/* transaction aborted */
#define	HPL_BUSY	  0x00000008	/* not on av_forw/back list */

#define	HPL_PHYS	  0x00000010	/* physical IO */
#define HPL_END_OF_DATA	  0x00000020
#define	HPL_WANTED        0x00000040	/* issue wakeup when BUSY goes off */
#define	HPL_NDELAY        0x00000080	/* don't retry on failures */

#define	HPL_ASYNC	  0x00000100	/* don't wait for I/O completion */
#define	HPL_DELWRITE      0x00000200	/* write at exit of avail list */
#define HPL_ORDWRI        0x00000400    /* flags ordered asynchronous writes */
#define HPL_REWRITE       0x00000800    /* re-writing buffer - call bdwrite */

#define HPL_PRIVATE       0x00001000    /* private, not part of buffers - LVM */
#define HPL_WRITEV        0x00002000    /* verification of writes  - LVM */
#define HPL_PFTIMEOUT     0x00004000    /* power failure time out - LVM */
#define HPL_CACHE         0x00008000    /* did bread find us in the cache ? */

#define	HPL_INVAL	  0x00010000	/* does not contain valid info  */
#define	HPL_LOCKED        0x00020000	/* locked in core (not reusable) */
#define	HPL_HEAD	  0x00040000	/* a buffer header, not a buffer */
#define HPL_FSYSIO        0x00080000	/* buffer from b{read,write}	*/

#define	HPL_BAD	          0x00100000	/* bad block revectoring in progress */
#define	HPL_CALL	  0x00200000	/* call b_iodone from iodone */
#define HPL_DUX_REM_REQ   0x00400000    /* Buffer is for a remote dux reqest */
#define	HPL_NOCACHE       0x00800000	/* don't cache block when released */

#define HPL_SYNC	  0x01000000	/* buffer write is synchronous */
#define HPL_RAW           0x02000000    /* raw interface (LVM/disc3/autoch) */
#define HPL_NETBUF        0x04000000    /* buffer in network pool */

typedef struct {
   u_int32_t size;    /* record size */
   u_int32_t id;      /* record type */
   u_int32_t sec;     /* time of     */
   u_int32_t usec;    /*       event */
} hpl_record_id;

typedef struct {
   hpl_record_id   rec_id;
   u_int32_t       start;      /* Start time of I/O in usec from enqueue time */
   u_int32_t       stop;       /* Stop time of I/O in usec from enqueue time */
   u_int32_t       size;       /* size in bytes */
   u_int32_t       sectno;     /* sector number on disk addressed */
   u_int32_t       devno;      /* device addressed */
   u_int32_t       drivertype; /* type of driver used by this disk */
   u_int32_t       cylno;      /* cylinder number of the access */
   u_int32_t       ioflags;    /* I/O flags for the device */
   u_int32_t       info;       /* information about where this I/O originated */
   u_int32_t       queuelen;   /* length of the queue */
   u_int32_t       susflags;   /* flags indicating error (for suspectIO) */
   char space[4];
} hpl_short_iorec_ki;

#endif /* HPTRACE_H */
