1ks_update(9E) Driver Entry Points ks_update(9E)
2
3
4
6 ks_update - dynamically update kstats
7
9 #include <sys/types.h>
10 #include <sys/kstat.h>
11 #include <sys/ddi.h>
12 #include <sys/sunddi.h>
13
14
15
16 int prefix_ks_update(kstat_t *ksp, int rw);
17
18
20 Solaris DDI specific (Solaris DDI)
21
23 ksp Pointer to a kstat(9S) structure.
24
25
26 rw Read/Write flag. Possible values are
27
28 KSTAT_READ Update kstat structure statistics from the
29 driver.
30
31
32 KSTAT_WRITE Update driver statistics from the kstat struc‐
33 ture.
34
35
36
38 The kstat mechanism allows for an optional ks_update() function to
39 update kstat data. This is useful for drivers where the underlying
40 device keeps cheap hardware statistics, but extraction is expensive.
41 Instead of constantly keeping the kstat data section up to date, the
42 driver can supply a ks_update() function which updates the kstat's data
43 section on demand. To take advantage of this feature, set the
44 ks_update field before calling kstat_install(9F).
45
46
47 The ks_update() function must have the following structure:
48
49 static int
50 xx_kstat_update(kstat_t *ksp, int rw)
51 {
52 if (rw == KSTAT_WRITE) {
53 /* update the native stats from ksp->ks_data */
54 /* return EACCES if you don't support this */
55 } else {
56 /* update ksp->ks_data from the native stats */
57 }
58 return (0);
59 }
60
61
62
63 In general, the ks_update() routine may need to refer to provider-pri‐
64 vate data; for example, it may need a pointer to the provider's raw
65 statistics. The ks_private field is available for this purpose. Its
66 use is entirely at the provider's discretion.
67
68
69 No kstat locking should be done inside the ks_update() routine. The
70 caller will already be holding the kstat's ks_lock (to ensure consis‐
71 tent data) and will prevent the kstat from being removed.
72
74 ks_update() should return
75
76 0 For success.
77
78
79 EACCES If KSTAT_WRITE is not allowed.
80
81
82 EIO For any other error.
83
84
86 kstat_create(9F), kstat_install(9F), kstat(9S)
87
88
89 Writing Device Drivers
90
91
92
93SunOS 5.11 27 May 1994 ks_update(9E)