Home | History | Annotate | Download | only in btreplay
      1 /*
      2  * Blktrace record utility - Convert binary trace data into bunches of IOs
      3  *
      4  * Copyright (C) 2007 Alan D. Brunelle <Alan.Brunelle (at) hp.com>
      5  *
      6  *  This program is free software; you can redistribute it and/or modify
      7  *  it under the terms of the GNU General Public License as published by
      8  *  the Free Software Foundation; either version 2 of the License, or
      9  *  (at your option) any later version.
     10  *
     11  *  This program is distributed in the hope that it will be useful,
     12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  *  GNU General Public License for more details.
     15  *
     16  *  You should have received a copy of the GNU General Public License
     17  *  along with this program; if not, write to the Free Software
     18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     19  */
     20 
     21 #if !defined(__BTRECORD_H__)
     22 #define __BTRECORD_H__
     23 
     24 #include <asm/types.h>
     25 
     26 #define BT_MAX_PKTS	512
     27 
     28 /*
     29  * Header for each bunch
     30  *
     31  * @nkts: 	Number of IO packets to process
     32  * @time_stamp:	Time stamp for this bunch of IOs
     33  */
     34 struct io_bunch_hdr {
     35 	__u64 npkts;
     36 	__u64 time_stamp;
     37 };
     38 
     39 /*
     40  * IO specifer
     41  *
     42  * @sector:	Sector number of IO
     43  * @nbytes:	Number of bytes to process
     44  * @rw:		IO direction: 0 = write, 1 = read
     45  */
     46 struct io_pkt {
     47 	__u64 sector;
     48 	__u64 nbytes;
     49 	__u32 rw;
     50 };
     51 
     52 /*
     53  * Shorthand notion of a bunch of IOs
     54  *
     55  * @hdr: 	Header describing stall and how many IO packets follow
     56  * @pkts: 	Individual IOs are described here
     57  */
     58 struct io_bunch {
     59 	struct io_bunch_hdr hdr;
     60 	struct io_pkt pkts[BT_MAX_PKTS];
     61 };
     62 
     63 /*
     64  * Header for each recorded file
     65  *
     66  * @version:	Version information
     67  * @genesis:	Time stamp for earliest bunch
     68  * @nbunches:	Number of bunches put into the file
     69  * @total_pkts:	Number of packets to be processed
     70  */
     71 struct io_file_hdr {
     72 	__u64 version;
     73 	__u64 genesis;
     74 	__u64 nbunches;
     75 	__u64 total_pkts;
     76 };
     77 
     78 static inline __u64 mk_btversion(int mjr, int mnr, int sub)
     79 {
     80 	return ((mjr & 0xff) << 16) | ((mnr & 0xff) << 8) | (sub & 0xff);
     81 }
     82 
     83 static inline void get_btversion(__u64 version, int *mjr, int *mnr, int *sub)
     84 {
     85 	*mjr = (int)((version >> 16) & 0xff);
     86 	*mnr = (int)((version >>  8) & 0xff);
     87 	*sub = (int)((version >>  0) & 0xff);
     88 }
     89 
     90 static char my_btversion[] = "1.0.0";
     91 static int btver_mjr = 1;
     92 static int btver_mnr = 0;
     93 static int btver_sub = 0;
     94 
     95 #endif
     96