4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI"
34 * busstat works by reading and writing from/to kstat's which are
35 * exported by drivers on the system.
37 * busstat parses the command line it is given and builds up a
38 * pair of linked list's to represent the various options specified.
39 * An example command line is given below..
41 * -w ac2,pic0=wio_pkts,pic1=rbio_pkts -w ac2,pic0=rto_pkts,pic1=rto_pkts -r ac5
42 * =============================================================================
46 * | ac2|->wio_pkts->rto_pkts
54 * | ac2|->rbio_pkts->rto_pkts
75 * The above diagram shows the lists created after the initial parsing.
77 * Each device instance/pic is represented by a device node. Hanging off
78 * that is at least one event node.
80 * Event nodes come in two different types. Nodes that are the result of a -r
81 * operation will have the r_w field in their parent dev_node set to EVT_READ,
82 * and most of their other fields set to zero or NULL. An event node that was
83 * created because of a -w operation (r_w = EVT_WRITE) will have all it's fields
84 * filled in. When a device node is created, an event node is automatically
85 * created and marked as EVT_READ. If the device node was created as the result
86 * of a -r operation, nothing more happens. But if it was a -w operation, then
87 * the event node is modified (r_w changed to EVT_WRITE, event pcr mask and
88 * event name written if known).
90 * Setting events : work along the list of dev_nodes, for each device node check
91 * the event node pointed to by evt_node, if it is marked as EVT_WRITE in the
92 * corresponding r_w array, if so set the event stored in the node.
94 * Reading events : work along the list of dev_nodes, for each device node check
95 * the event node pointed to by evt_node, if it is marked EVT_WRITE, just read
96 * the event count from the appropiate PIC and store it in the node. If the node
97 * is EVT_READ however, read the PCR, determine the event name, store it in the
98 * node along with the event count.
100 * Multiplexing is handled by cycling through the event nodes. The event nodes
101 * are on a circular list, which allows each pic to be multiplexing between
102 * different numbers of events.
113 #define EVT_WRITE 0x2
114 #define ONE_INST_CALL 0x4
115 #define ALL_INST_CALL 0x8
117 #define STATE_INIT 0x10 /* Initial state of node when created */
118 #define STATE_INST 0x20 /* Node was created by specific instance call */
119 #define STATE_ALL 0x40 /* Node was created by call for all instances */
121 #define NANO 1000000000 /* To convert from nanosecs to secs */
123 #define PIC_STR_LEN 3
127 typedef struct evt_node
{
128 char evt_name
[KSTAT_STRLEN
]; /* The event name */
129 uint64_t prev_count
; /* The previous count for this evt */
130 uint64_t total
; /* Total count for this event */
131 uint64_t evt_pcr_mask
; /* PCR mask for this event */
132 struct evt_node
*next
;
135 typedef struct dev_node
{
136 char name
[KSTAT_STRLEN
]; /* Device name e.g. ac */
137 int dev_inst
; /* Device instance number */
138 int pic_num
; /* PIC number. */
139 kstat_t
*cnt_ksp
; /* "counters" kstat pointer */
140 kstat_t
*pic_ksp
; /* pointer to picN kstat */
141 int r_w
; /* r_w flag */
142 int state
; /* state flag */
143 struct evt_node
*evt_node
; /* ptr to current evt_node */
144 struct dev_node
*next
;
147 #endif /* _BUSSTAT_H */