summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/scsi_wwnstr_to_wwn.9f
blob: 3ff86940500e4cb03669b09d18e83e13e2ae6cb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
.\"
.\" This file and its contents are supplied under the terms of the
.\" Common Development and Distribution License ("CDDL"), version 1.0.
.\" You may only use this file in accordance with the terms of version
.\" 1.0 of the CDDL.
.\"
.\" A full copy of the text of the CDDL should have accompanied this
.\" source.  A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
.\" Copyright (c) 2017, Joyent, Inc.
.\"
.Dd Feb 28, 2017
.Dt SCSI_WWNSTR_TO_WWN 9F
.Os
.Sh NAME
.Nm scsi_wwnstr_to_wwn ,
.Nm scsi_wwn_to_wwnstr ,
.Nm scsi_free_wwnstr
.Nd SCSI World Wide Name string conversion functions
.Sh SYNOPSIS
.In sys/scsi/scsi.h
.Ft int
.Fo scsi_wwnstr_to_wwn
.Fa "const char *wwwnstr"
.Fa "uint64_t *wwnp"
.Fc
.Ft "char *"
.Fo scsi_wwn_to_wwnstr
.Fa "uint64_t wwn"
.Fa "int ua_form"
.Fa "char *wwnstr"
.Fc
.Ft void
.Fo scsi_free_wwnstr
.Fa "char *wwnstr"
.Fc
.Sh INTERFACE LEVEL
.Sy Evolving -
This interface is still evolving in illumos.
API and ABI stability is not guaranteed.
.Sh PARAMETERS
.Bl -tag -width Fa
.It Fa wwn
A 64-bit world wide number.
.It Fa wwnstr
A string representation of a world wide number.
.It Fa wwnp
A pointer to a 64-bit value that will store a world wide number.
.It Fa ua_form
An integer indicating whether or not the unit address form should be
used.
.El
.Sh DESCRIPTION
The
.Fn scsi_wwnstr_to_wwn
and
.Fn scsi_wwn_to_wwnstr
functions convert an 8-byte world wide number to and from a string
representation.
.Pp
World wide numbers are unique identifiers that are used in storage
technologies, particularly ATA, SAS, and FC.
The format of a WWN is defined by the IEEE and generally come in 8 and
16 byte forms.
These interfaces only operate on the 8 byte forms.
.Pp
When the WWN is represented as a string, it is represented as a 16
character hexadecimal string.
This character string may either use uppercase or lowercase hexadecimal
characters.
The character string may be preceded by a
.Sq w
character.
When this is present, this is called the
.Em unit-address form .
If the string is not 16 ASCII character long or 17, when using the
unit-address form, the string is considered invalid.
The following macros are provided to help deal with these lengths:
.Bl -tag -width Dv
.It Dv SCSI_WWN_STRLEN
The number of bytes, excluding a terminating nul character, for a world
wide number to be represented when not in the unit-address form.
.It Dv SCSI_WWN_UA_STRLEN
The number of bytes, excluding a terminating nul character, for a world
wide number to be represented in the unit-address form.
.It Dv SCSI_WWN_BUFLEN
A number of bytes that is guaranteed to be sufficient to hold any form
of a world wide number and a nul terminator.
.El
.Pp
The
.Fn scsi_wwnstr_to_wwn
function parses the string form of the WWN
.Fa wwnstr
and converts it to a 64-bit representation.
The string form may either be in unit-address form or not.
The string must have a nul terminator.
If the string is successfully parsed, the world wide number is stored in
.Fa wwnp .
.Pp
The
.Fn scsi_wwn_to_wwnstr
converts the world wide number in
.Fa wwn
into a human-readable string as described above.
If the
.Fa ua_form
is non-zero then the unit-address form is used and a leading
.Sq w
is placed.
.Pp
If the
.Fa wwnstr
argument is supplied by the user, then it must be large enough to
contain both the string form of the world wide number and a nul
character.
The
.Dv SCSI_WWN_BUFLEN
macro is recommended.
It will always ensure that a buffer is large
enough to hold any supported string representation of a world wide
number.
.Pp
If the
.Fa wwnstr
argument is instead
.Dv NULL ,
then a character string of sufficient size will be allocated by the
system.
Note, this allocation will block until memory is available.
If memory is allocated in this way, then the caller should free this
memory with the
.Fn scsi_free_wwnstr
function.
.Sh CONTEXT
The
.Fn scsi_wwnstr_to_wwn ,
.Fn scsi_wwn_to_wwnstr ,
and
.Fn scsi_free_wwnstr
functions may be used in
.Sy user ,
.Sy kernel ,
and
.Sy interrupt
context.
.Sh RETURN VALUES
Upon successful completion, the
.Fn scsi_wwnstr_to_wwn
function returns
.Dv DDI_SUCCESS
and fills in
.Fa wwnp
with the WWN.
Otherwise,
.Dv DDI_FAILURE
is returned, indicating an invalid argument or a malformed string in
.Fa wwnstr .
.Pp
Upon successful completion, the
.Fn scsi_wwn_to_wwnstr
function returns a pointer to the start of the world wide number.
Otherwise
.Dv NULL
is returned to indicate that the conversion failed.
.Sh SEE ALSO
.Xr scsi_hba_iport_unit_address 9F