1 .\" Copyright 2016 Garrett D'Amore
   2 .\" Copyright (c) 2006, 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 .Dd Jan 27, 2016
   7 .Dt KSTAT_NAMED_INIT 9F
   8 .Os
   9 .Sh NAME
  10 .Nm kstat_named_init
  11 .Nm kstat_named_setstr
  12 .Nd initialize a named kstat
  13 .Sh SYNOPSIS
  14 .Hf <sys/types.h>
  15 .br
  16 .Hf <sys/kstat.h>
  17 .Lp
  18 .Ft void
  19 .Fo kstat_named_init
  20 .Fa "kstat_named_t *knp"
  21 .Fa "const char *name"
  22 .Fa "uchar_t data_type"
  23 .Fc
  24 .Lp
  25 .Ft void
  26 .Fo kstat_named_setstr
  27 .Fa "kstat_named_t *knp"
  28 .Fa "const char *str"
  29 .Fc
  30 .Sh INTERFACE LEVEL
  31 Solaris DDI specific (Solaris DDI)
  32 .Sh PARAMETERS
  33 .Bl -tag -width Ds
  34 .It Fa knp
  35 Pointer to a
  36 .Xr kstat_named 9S
  37 structure.
  38 .It Fa name
  39 The name of the statistic.
  40 .It Fa data_type
  41 The type of value. This indicates which field of the
  42 .Xr kstat_named 9S
  43 structure should be used. Valid values are:
  44 .Bl -tag -width Ds
  45 .It Sy KSTAT_DATA_CHAR
  46 The "char" field.
  47 .
  48 .It Sy KSTAT_DATA_LONG
  49 The "long" field.
  50 .
  51 .It Sy KSTAT_DATA_ULONG
  52 The "unsigned long" field.
  53 .
  54 .It Sy KSTAT_DATA_LONGLONG
  55 Obsolete. Use
  56 .Sy KSTAT_DATA_INT64 .
  57 .
  58 .It Sy KSTAT_DATA_ULONGLONG
  59 Obsolete. Use
  60 .Sy KSTAT_DATA_UINT64 .
  61 .
  62 .It Sy KSTAT_DATA_STRING
  63 Arbitrary length "long string" field.
  64 .
  65 .It Sy KSTAT_DATA_TIME
  66 The high resolution time stamp field.  Note that this should only be used
  67 for absolute time stamps, such as returned by
  68 .Xr gethrtime 9F ,
  69 and not for relative durations.  For relative durations,
  70 .Sy KSTAT_DATA_UINT64
  71 is preferred.
  72 .El
  73 .It Fa str
  74 Pointer to a
  75 .Sy NULL- Ns No terminated
  76 string.
  77 .El
  78 .Sh DESCRIPTION
  79 .Fn kstat_named_init
  80 associates a name and a type with a
  81 .Xr kstat_named 9S
  82 structure.
  83 .Lp
  84 .Fn kstat_named_setstr
  85 associates
  86 .Fa str
  87 with the named kstat
  88 .Fa knp .
  89 It is an error for
  90 .Fa knp
  91 to be of type other than
  92 .Sy KSTAT_DATA_STRING .
  93 The string argument must remain valid even after the function that is calling
  94 .Fn kstat_named_setstr
  95 is returned. If
  96 .Sy KSTAT_DATA_STRING
  97 is used in a
  98 persistent kstat the string argument must remain valid even after the module
  99 that created the kstat is unloaded.
 100 This is the only supported method of changing the value of long strings.
 101 .Sh CONTEXT
 102 .Fn kstat_named_init
 103 and
 104 .Fn kstat_named_setstr
 105 can be called from user or kernel context.
 106 .Sh RETURN VALUES
 107 None.
 108 .Sh SEE ALSO
 109 .Xr gethrtime 9F ,
 110 .Xr kstat_create 9F ,
 111 .Xr kstat_install 9F ,
 112 .Xr kstat 9S ,
 113 .Xr kstat_named 9S
 114 .Rs
 115 .%B Writing Device Drivers
 116 .Re