Go to main content

Writing Device Drivers in Oracle® Solaris 11.4

Exit Print View

Updated: November 2020
 
 

Equivalent kstat2 APIs for kstat

This appendix lists the mapping of kstat2 and legacy kstat APIs.

Equivalent kstat2 APIs for kstat

Table 40  APIs to Create and Delete kstat
Older kstat API
Equivalent kstat2 API
Description of kstat2 APIs
kstat_create
kstat2_t * kstat2_create(const char *ks_pseg[], uchar_t npseg zoneid_t ks_zone, kstat2_named_t *ks_data, uint_t ks_ndata, uchar_t ks_flags, const kstat2_md_t *ks_metadata, const char *desc, kstat2_metaflag_t ks_mflags);
Creates a kstat. For more information, see the kstat2_create(9F) man page.
-
kstat2_t * kstat2_create_with_template(const char *ks_pseg[], uchar_t npseg, zoneid_t ks_zone, kstat2_template_t *ks_tmpl, uchar_t ks_flags, kstat2_named_t *ks_data, const char *desc, kstat2_metaflag_t ks_mflags);
This is a new API that was not available in the older kstat.
Creates a kstat by using a supplied template. For more information, see the kstat2_create_with_template(9F) man page.
-
kstat2_t * kstat2_create_histogram(const char *ks_pseg[], uchar_t npseg, zoneid_t ks_zone, kstat2_nv_hist_type_t type, kstat2_nv_metatype_t content_type, uint64_t scale, kstat2_nv_metaflag_t md_flags, uint64_t *buckets, uint16_t num_buckets, uint64_t range_min, uint64_t range_max, uint64_t stepping, uchar_t ks_flags, const char *desc, kstat2_metaflag_t ks_mflags);
This is a new API that was not available in the older kstat.
Creates a kstat whose data represents a histogram. For more information, see the kstat2_create_histogram(9F) man page.
-
kstat2_template_t * kstat2_lookup_template(uchar_t tmpl_id);
This is a new API that was not available in the older kstat.
Looks for a system template. For example, I/O, INTR, older TIMER kstat equivalents. For more information, see the kstat2_lookup_template(9F) man page.
-
int kstat2_set_v1_names(kstat2_t *ksp, const char *class, const char *module, const char *name, int instance);
This is a new API that was not available in the older kstat.
Set the fields: ks_class, ks_module, ks_name, and ks_instance in the kstat. For more information, see the kstat2_set_v1_names(9F) man page.
kstat_install
void kstat2_install(kstat2_t *ksp);
Installs a kstat. For more information, see the kstat2_install(9F) man page.
kstat_delete
void kstat2_delete(kstat2_t *ksp);
Deletes a kstat. For more information, see the kstat2_delete(9F) man page.
-
void kstat2_delete_zone(kid_t kid, zoneid_t zoneid);
Looks up a kstat by using kstat ID and deletes it. For more information, see the kstat2_delete_zone(9F) man page.
Table 41  APIs to Monitor IO Queue
Older kstat API
Equivalent kstat2 API
Description of kstat2 APIs
kstat_waitq_enter
void kstat2_waitq_enter(kstat2_io_t *kiop);
Use when a request arrives and is placed into a pre-service state. For more information, see the kstat2_waitq_enter(9F) man page.
kstat_waitq_exit
void kstat2_waitq_exit(kstat2_io_t *kiop);
Use when a request is removed from its pre-service state. For more information, see the kstat2_waitq_exit(9F) man page.
kstat_runq_enter
void kstat2_runq_enter(kstat2_io_t *kiop);
Call when a request is placed in its service state (just prior to calling the driver's start routine, but after kstat2_waitq_exit()). For more information, see the kstat2_runq_enter(9F) man page.
kstat_runq_exit
void kstat2_runq_exit(kstat2_io_t *kiop);
Use when a request is removed from its service state (just prior to calling biodone(9F)). For more information, see the kstat2_runq_exit(9F) man page.
kstat_waitq_to_runq
void kstat2_waitq_to_runq(kstat2_io_t *kiop);
Use when there is a transition of a request from the wait queue to the run queue. This is useful wherever the driver would have normally done a kstat2_waitq_exit() followed by a call to kstat2_runq_enter(). For more information, see the kstat2_waitq_to_runq(9F) man page.
kstat_runq_back_to_waitq
void kstat2_runq_back_to_waitq(kstat2_io_t *kiop);
Use when there is a transition of a request from the run queue back to the wait queue. For more information, see the kstat2_runq_back_to_waitq(9F) man page.
Table 42  APIs to Add and Remove Visibility of kstat in Zones
Older kstat API
Equivalent kstat2 API
Description of kstat2 APIs
kstat_zone_add
void kstat2_zone_add(kstat2_t *ksp, zoneid_t zone);
Makes a kstat visible in a specified zone. For more information, see the kstat2_zone_add(9F) man page.
kstat_zone_remove
void kstat2_zone_remove(kstat2_t *ksp, zoneid_t zone);
Removes visibility of a kstat in a specified zone. For more information, see the kstat2_zone_remove(9F) man page.
Table 43  APIs to Lock and Release kstats
Older kstat API
Equivalent kstat2 API
Description of kstat2 APIs
kstat_hold_bykid
kstat2_t * kstat2_hold_bykid(kid_t kid, zoneid_t zone);
Holds a lock on kstat. For more information, see the kstat2_hold_bykid(9F) man page.
kstat_rele
void kstat2_rele(kstat2_t *ksp);
Releases a lock on kstat. For more information, see the kstat2_rele(9F) man page.
Table 44  General APIs
Older kstat API
Equivalent kstat2 API
Description of kstat2 APIs
kstat_named_init
void kstat2_nv_init(kstat2_named_t *knp, const char *name, uchar_t type, uint16_t flags);
Initializes a named kstat. For more information, see the kstat2_nv_init(9F) man page.
kstat_named_setstr
void kstat2_nv_setstr(kstat2_named_t *knp, const char *str);
Initializes a named kstat. For more information, see the kstat2_nv_setstr(9F) man page.
-
void kstat2_nv_setints(kstat2_named_t *knp, const uint64_t *arr, uint32_t len);
This is a new API that was not available in the older kstat.
Sets an integer array value on a kstat name-value pair. For more information, see the kstat2_nv_setints(9F) man page.
-
void kstat2_nv_setstrs(kstat2_named_t *knp, const kstat2_named_t *arr, uint32_t len);
This is a new API that was not available in the older kstat.
Sets a string array value on a kstat name-value pair. For more information, see the kstat2_nv_setstrs(9F) man page.
-
void kstat2_hist_add_value(kstat2_t *ksp, uint64_t value);
This is a new API that was not available in the older kstat.
Adds a value to a histogram kstat. For more information, see the kstat2_hist_add_value(9F) man page.
-
size_t kstat2_data_size(kstat2_named_t *knp, uint_t ndata);
This is a new API that was not available in the older kstat.
Calculates space required to hold kstat data including names, strings and array data. For more information, see the kstat2_data_size(9F) man page.