Go to main content

man pages section 9: DDI and DKI Properties and Data Structures

Exit Print View

Updated: Friday, August 13, 2021

kstat2_intr (9S)


kstat2_intr - structure for v2 interrupt kstats


#include <sys/types.h>
#include <sys/kstat2.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>

Interface Level

Solaris DDI specific (Solaris DDI)


v2 interrupt kstat statistics are held in a kstat2_intr structure which can be used synonymously as an array containing a single v2 kstat name-value pair. When kstat2_create_with_template(9F) function creates an interrupt kstat, the ks2_data field is a pointer to one of these structures and can be accessed using the macro KSTAT2_INTR_PTR() which is defined as follows:

#define KSTAT2_INTR_PTR(kptr) \ 
((kstat2_intr_t *)(kptr->ks2_data))

Structure Members

kstat2_named_t intrs;

The type of the intrs field is an array of 64-bit integers which are accessed through intrs.value.integers.array. This access is simplified using the macro: KSTAT2_NV_INTS(intrs). intrs.value.integers.array must point directly to an array in driver memory. The contents of the array are copied out under the kstat's lock when read.


Example 1 Create an interrupt kstat with framework managed storage
#include <sys/kstat2.h>
const char *pseg =
      { "category", "module", "name", "instance };
static uint64_t my_intrs[KSTAT_NUM_INTRS];
static kstat2_named_t *ks_data;

kstat2_template_t *t = kstat2_lookup_template(KSTAT2_MT_IO);
kstat2_t *ksp = kstat2_create_with_template(pseg, 4,
      ALL_ZONES, t, 0, NULL,
      "My driver IO", KSTAT2_MF_STABLE);
if (ksp != NULL) {
     * Set local array as the value on the kstat data.
    ks_data = KSTAT2_INTR_PTR(ksp)->intrs;
    kstat2_nv_setints(ks_data, my_intrs, KSTAT_NUM_INTRS);

 * Increment an interrupt value.
 * This can be done by explicit reference to the array
 * in the kstat data:
 *     ks_data->value.integers.array[KSTAT_INTR_HARD]++;
 * or by using the supplied macro to reference the array:
 *     KSTAT2_NV_INTS(ks_data)[KSTAT_INTR_HARD]++;
 * or simply by using the local reference to the array:

See Also

kstat2_create(9F), kstat2_create_with_template(9F), kstat2(9S)