2 .\" Copyright (c) 1994, Sun Microsystems, Inc., All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH KS_UPDATE 9E "May 27, 1994"
8 ks_update \- dynamically update kstats
12 #include <sys/types.h>
13 #include <sys/kstat.h>
15 #include <sys/sunddi.h>
19 \fBint prefix\fR\fB_ks_update\fR(\fBkstat_t *\fR\fIksp\fR, \fBint\fR \fIrw\fR);
25 Solaris DDI specific (Solaris DDI)
33 Pointer to a \fBkstat\fR(9S) structure.
42 Read/Write flag. Possible values are
46 \fB\fBKSTAT_READ\fR \fR
49 Update \fBkstat\fR structure statistics from the driver.
55 \fB\fBKSTAT_WRITE\fR \fR
58 Update driver statistics from the kstat structure.
66 The kstat mechanism allows for an optional \fBks_update()\fR function to update
67 kstat data. This is useful for drivers where the underlying device keeps cheap
68 hardware statistics, but extraction is expensive. Instead of constantly
69 keeping the kstat data section up to date, the driver can supply a
70 \fBks_update()\fR function which updates the kstat's data section on demand. To
71 take advantage of this feature, set the \fBks_update\fR field before calling
72 \fBkstat_install\fR(9F).
75 The \fBks_update()\fR function must have the following structure:
80 xx_kstat_update(kstat_t *ksp, int rw)
82 if (rw == KSTAT_WRITE) {
83 /* update the native stats from ksp->ks_data */
84 /* return EACCES if you don't support this */
86 /* update ksp->ks_data from the native stats */
95 In general, the \fBks_update()\fR routine may need to refer to provider-private
96 data; for example, it may need a pointer to the provider's raw statistics. The
97 \fBks_private\fR field is available for this purpose. Its use is entirely at
98 the provider's discretion.
101 No \fBkstat\fR locking should be done inside the \fBks_update()\fR routine.
102 The caller will already be holding the \fBkstat's\fR \fBks_lock\fR (to ensure
103 consistent data) and will prevent the \fBkstat\fR from being removed.
107 \fBks_update()\fR should return
123 If \fBKSTAT_WRITE\fR is not allowed.
138 \fBkstat_create\fR(9F), \fBkstat_install\fR(9F), \fBkstat\fR(9S)
141 \fIWriting Device Drivers\fR