Home | History | Annotate | Line # | Download | only in sys
iostat.h revision 1.4
      1  1.3   yamt /*	$NetBSD: iostat.h,v 1.4 2006/04/21 13:53:30 yamt Exp $	*/
      2  1.1  blymn 
      3  1.1  blymn /*-
      4  1.1  blymn  * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
      5  1.1  blymn  * All rights reserved.
      6  1.1  blymn  *
      7  1.1  blymn  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  blymn  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.1  blymn  * NASA Ames Research Center.
     10  1.1  blymn  *
     11  1.1  blymn  * Redistribution and use in source and binary forms, with or without
     12  1.1  blymn  * modification, are permitted provided that the following conditions
     13  1.1  blymn  * are met:
     14  1.1  blymn  * 1. Redistributions of source code must retain the above copyright
     15  1.1  blymn  *    notice, this list of conditions and the following disclaimer.
     16  1.1  blymn  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1  blymn  *    notice, this list of conditions and the following disclaimer in the
     18  1.1  blymn  *    documentation and/or other materials provided with the distribution.
     19  1.1  blymn  * 3. All advertising materials mentioning features or use of this software
     20  1.1  blymn  *    must display the following acknowledgement:
     21  1.1  blymn  *	This product includes software developed by the NetBSD
     22  1.1  blymn  *	Foundation, Inc. and its contributors.
     23  1.1  blymn  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.1  blymn  *    contributors may be used to endorse or promote products derived
     25  1.1  blymn  *    from this software without specific prior written permission.
     26  1.1  blymn  *
     27  1.1  blymn  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.1  blymn  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.1  blymn  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.1  blymn  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.1  blymn  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.1  blymn  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.1  blymn  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.1  blymn  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.1  blymn  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.1  blymn  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.1  blymn  * POSSIBILITY OF SUCH DAMAGE.
     38  1.1  blymn  */
     39  1.1  blymn 
     40  1.1  blymn #ifndef _SYS_IOSTAT_H_
     41  1.1  blymn #define _SYS_IOSTAT_H_
     42  1.1  blymn 
     43  1.1  blymn /*
     44  1.1  blymn  * Disk device structures.
     45  1.1  blymn  */
     46  1.1  blymn 
     47  1.1  blymn #include <sys/time.h>
     48  1.1  blymn #include <sys/queue.h>
     49  1.1  blymn #include <sys/lock.h>
     50  1.1  blymn 
     51  1.1  blymn #define	IOSTATNAMELEN	16
     52  1.1  blymn 
     53  1.1  blymn /* types of drives we can have */
     54  1.1  blymn #define IOSTAT_DISK	0
     55  1.1  blymn #define IOSTAT_TAPE	1
     56  1.1  blymn #define IOSTAT_NFS	2
     57  1.1  blymn 
     58  1.1  blymn /* The following structure is 64-bit alignment safe */
     59  1.1  blymn struct io_sysctl {
     60  1.1  blymn 	char		name[IOSTATNAMELEN];
     61  1.1  blymn 	int32_t		busy;
     62  1.1  blymn 	int32_t		type;
     63  1.1  blymn 	u_int64_t	xfer;
     64  1.1  blymn 	u_int64_t	seek;
     65  1.1  blymn 	u_int64_t	bytes;
     66  1.1  blymn 	u_int32_t	attachtime_sec;
     67  1.1  blymn 	u_int32_t	attachtime_usec;
     68  1.1  blymn 	u_int32_t	timestamp_sec;
     69  1.1  blymn 	u_int32_t	timestamp_usec;
     70  1.1  blymn 	u_int32_t	time_sec;
     71  1.1  blymn 	u_int32_t	time_usec;
     72  1.1  blymn 	/* New separate read/write stats */
     73  1.1  blymn 	u_int64_t	rxfer;
     74  1.1  blymn 	u_int64_t	rbytes;
     75  1.1  blymn 	u_int64_t	wxfer;
     76  1.1  blymn 	u_int64_t	wbytes;
     77  1.1  blymn };
     78  1.1  blymn 
     79  1.1  blymn /*
     80  1.1  blymn  * Structure for keeping the in-kernel drive stats - these are linked
     81  1.1  blymn  * together in drivelist.
     82  1.1  blymn  */
     83  1.1  blymn 
     84  1.1  blymn struct io_stats
     85  1.1  blymn {
     86  1.2  blymn 	char		*io_name;  /* device name */
     87  1.2  blymn 	void		*io_parent; /* pointer to what we are attached to */
     88  1.2  blymn 	int		io_type;   /* type of device the state belong to */
     89  1.2  blymn 	int		io_busy;	/* busy counter */
     90  1.2  blymn 	u_int64_t	io_rxfer;	/* total number of read transfers */
     91  1.2  blymn 	u_int64_t	io_wxfer;	/* total number of write transfers */
     92  1.2  blymn 	u_int64_t	io_seek;	/* total independent seek operations */
     93  1.2  blymn 	u_int64_t	io_rbytes;	/* total bytes read */
     94  1.2  blymn 	u_int64_t	io_wbytes;	/* total bytes written */
     95  1.2  blymn 	struct timeval	io_attachtime;	/* time disk was attached */
     96  1.2  blymn 	struct timeval	io_timestamp;	/* timestamp of last unbusy */
     97  1.2  blymn 	struct timeval	io_time;	/* total time spent busy */
     98  1.2  blymn 	TAILQ_ENTRY(io_stats) io_link;
     99  1.1  blymn };
    100  1.1  blymn 
    101  1.1  blymn /*
    102  1.1  blymn  * drivelist_head is defined here so that user-land has access to it.
    103  1.1  blymn  */
    104  1.1  blymn TAILQ_HEAD(iostatlist_head, io_stats);	/* the iostatlist is a TAILQ */
    105  1.1  blymn 
    106  1.1  blymn #ifdef _KERNEL
    107  1.1  blymn void	iostat_busy(struct io_stats *);
    108  1.1  blymn void	iostat_unbusy(struct io_stats *, long, int);
    109  1.4   yamt struct io_stats *iostat_find(const char *);
    110  1.3   yamt struct io_stats *iostat_alloc(int32_t);
    111  1.1  blymn void	iostat_free(struct io_stats *);
    112  1.1  blymn void	iostat_seek(struct io_stats *);
    113  1.1  blymn #endif
    114  1.1  blymn 
    115  1.1  blymn #endif /* _SYS_IOSTAT_H_ */
    116