fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <kstat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/inttypes.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <nsctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "dsstat.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "common.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sdbc_stats.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "report.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern short dflags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return the number of ticks delta between two hrtime_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * values. Attempt to cater for various kinds of overflow
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in hrtime_t - no matter how improbable.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint64_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehrtime_delta(hrtime_t old, hrtime_t new)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t del;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((new >= old) && (old >= 0L)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (new - old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We've overflowed the positive portion of an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hrtime_t.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (new < 0L) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The new value is negative. Handle the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * case where the old value is positive or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * negative.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t n1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t o1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte n1 = -new;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (old > 0L) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (n1 - old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte o1 = -old;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte del = n1 - o1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (del);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Either we've just gone from being negative
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to positive *or* the last entry was positive
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the new entry is also positive but *less*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * than the old entry. This implies we waited
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * quite a few days on a very fast system between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iostat displays.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (old < 0L) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t o2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte o2 = -old;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte del = UINT64_MAX - o2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte del = UINT64_MAX - old;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte del += new;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (del);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take the difference of an unsigned 32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bit int attempting to cater for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * overflow.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteu32_delta(uint32_t old, uint32_t new)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (new >= old)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (new - old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((UINT32_MAX - old) + new + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Take the difference of an unsigned 64
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bit int attempting to cater for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * overflow.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint64_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteu64_delta(uint64_t old, uint64_t new)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (new >= old)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (new - old);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ((UINT64_MAX - old) + new + 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * io_report() - diffs and reports data contained in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat_io_t structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat_io_t *cur - pointer to current data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat_io_t *pre - pointer to data as it was
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * at the beginning of an interval.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
e31df31051ab05e561eab5b23bb1c00627a10d64Thomas Atkinsio_report(kstat_t *cur_kstat, kstat_t *pre_kstat, sdbcstat_t *sdbcstat)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbcvals_t vals;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte double rd_cnt, wr_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte double rd_kb, wr_kb, hr_etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte double rtm, tps, avs, etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
e31df31051ab05e561eab5b23bb1c00627a10d64Thomas Atkins kstat_io_t *cur = cur_kstat->ks_data;
e31df31051ab05e561eab5b23bb1c00627a10d64Thomas Atkins kstat_io_t *pre = pre_kstat->ks_data;
e31df31051ab05e561eab5b23bb1c00627a10d64Thomas Atkins
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbcstat &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_getvalues(sdbcstat, &vals, (SDBC_KBYTES | SDBC_INTAVG)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Time */
e31df31051ab05e561eab5b23bb1c00627a10d64Thomas Atkins hr_etime = hrtime_delta(pre_kstat->ks_snaptime, cur_kstat->ks_snaptime);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte etime = hr_etime / (double)NANOSEC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Read count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rd_cnt = (double)u32_delta(pre->reads, cur->reads);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rd_cnt) rd_cnt /= etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bytes read */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rd_kb = (double)u64_delta(pre->nread, cur->nread) / KILOBYTE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rd_kb) rd_kb /= etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Write count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wr_cnt = (double)u32_delta(pre->writes, cur->writes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wr_cnt) wr_cnt /= etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bytes written */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wr_kb = (double)u64_delta(pre->nwritten, cur->nwritten) / KILOBYTE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wr_kb) wr_kb /= etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate service times */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte avs = (double)hrtime_delta(pre->rlentime, cur->rlentime) / hr_etime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tps = (double)rd_cnt + wr_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tps > 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rtm = (1000 / tps) * avs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rtm = 0.0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & SUMMARY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mode & MULTI) && (mode & SDBC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbcstat) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (float)vals.total_cache);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (float)vals.total_disk);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C6, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, rd_kb + wr_kb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, rd_kb + wr_kb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_INF_FMT, (uint32_t)(rd_cnt + wr_cnt));
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(SVT_INF_FMT, rtm);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & READ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mode & MULTI) && (mode & SDBC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbcstat) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (float)vals.cache_read);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (float)vals.disk_read);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C6, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, rd_kb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, rd_kb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_INF_FMT, (uint32_t)rd_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & WRITE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mode & MULTI) && (mode & SDBC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbcstat) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (float)vals.cache_write);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (float)vals.disk_write);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C6, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, wr_kb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, wr_kb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_INF_FMT, (uint32_t)wr_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & TIMING) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(SVT_INF_FMT, rtm);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linesout++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteio_value_check(kstat_io_t *pre, kstat_io_t *cur)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (u32_delta(pre->reads, cur->reads))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (u32_delta(pre->writes, cur->writes))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cd_report() - reports cache desriptor related statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based on the dflags global variable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sdbcstat_t *sdbcstat - pointer to the cache structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to be reported on.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecd_report(sdbcstat_t *sdbcstat)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbcvals_t vals;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Extract statistics, average for time */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sdbc_getvalues(sdbcstat, &vals, (SDBC_KBYTES | SDBC_INTAVG)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rflags & MULTI) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(VOL_HDR_FMT, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & FLAGS) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(STAT_HDR_FMT, "");
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(STAT_HDR_FMT, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & PCTS)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(PCT_HDR_FMT, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & SUMMARY) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, (float)vals.total_cache);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C4, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C4, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linesout++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & READ) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, (float)vals.cache_read);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C4, NO_INFO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & WRITE) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, (float)vals.cache_write);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C4, NO_INFO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & TIMING) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C4, NO_INFO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linesout++;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & SUMMARY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.total_cache);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.total_disk);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(HIT_INF_FMT, vals.cache_hit);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linesout++;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & READ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.cache_read);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.disk_read);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(HIT_INF_FMT, vals.read_hit);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & WRITE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.cache_write);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.disk_write);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(HIT_INF_FMT, vals.write_hit);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & DESTAGED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.destaged);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & WRCANCEL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(DATA_I32, vals.write_cancellations);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linesout++;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * header() - outputs an appropriate header by referencing the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global variables dflsgs and rflags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteheader()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hflags & HEADERS_EXL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((linesout % DISPLAY_LINES) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hflags & HEADERS_BOR)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linesout != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hflags & HEADERS_ATT)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hflags & HEADERS_OUT)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hflags |= HEADERS_OUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linesout)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(VOL_HDR_FMT, SET_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & FLAGS) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(STAT_HDR_FMT, TYPE_HDR_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(STAT_HDR_FMT, STAT_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & ASYNC_QUEUE)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(STAT_HDR_FMT, QUEUE_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & PCTS)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(PCT_HDR_FMT, PCT_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(ROLE_HDR_FMT, ROLE_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & ASYNC_QUEUE) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_HDR_FMT, QUEUE_ITEMS_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, QUEUE_KBYTES_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_HDR_FMT, QUEUE_ITEMS_HW_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, QUEUE_KBYTES_HW_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & SUMMARY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mode & MULTI) && (mode & SDBC)) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, CKPS_HDR_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, DKPS_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, KPS_HDR_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_HDR_FMT, TPS_HDR_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(SVT_HDR_FMT, SVT_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & READ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mode & MULTI) && (mode & SDBC)) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, CRKPS_HDR_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, DRKPS_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, RKPS_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_HDR_FMT, RTPS_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & WRITE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((mode & MULTI) && (mode & SDBC)) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, CWKPS_HDR_TXT);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, DWKPS_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, WKPS_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_HDR_FMT, WTPS_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & TIMING)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(SVT_HDR_FMT, SVT_HDR_TXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}