2 * ****************************************************************************
5 * smhbaapi.h - general header file for client
6 * and library developers
9 * The contents of this file are subject to the SNIA Public License
10 * Version 1.0 (the "License"); you may not use this file except in
11 * compliance with the License. You may obtain a copy of the License at
13 * /http://www.snia.org/English/Resources/Code/OpenSource.html
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code for SM-HBA API general header file
22 * The Initial Developer of the Original Code is:
23 * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com)
26 * Tuan Lam, QLogic Corp. (t_lam@qlc.com)
27 * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com)
28 * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com)
29 * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)
31 * ****************************************************************************
33 * Adding on SM-HBA related definitions.
35 * - Includes the original HBA API header.
36 * - SMHBA_* interfaces and structures are defined.
38 * ****************************************************************************
41 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
42 * Use is subject to license terms.
54 /* Library version string */
55 #define SMHBA_LIBVERSION 1
58 * A SCSI function was requested at a time when issuing the requested command
59 * would cause a SCSI overlapped command condition (see SAM-3)
61 #define HBA_STATUS_ERROR_TARGET_BUSY 30
62 /* SM-HBA 6.2 Status Return Values */
63 /* A call was made to HBA_FreeLibrary when no library was loaded */
64 #define HBA_STATUS_ERROR_NOT_LOADED 31
65 /* A call was made to HBA_LoadLibrary when a library was already loaded */
66 #define HBA_STATUS_ERROR_ALREADY_LOADED 32
68 * The Address Identifier specified in a call to HBA_SendRNIDV2
69 * violates access control rules * for that call.
71 #define HBA_STATUS_ERROR_ILLEGAL_FCID 33
72 #define HBA_STATUS_ERROR_NOT_ASCSIDEVICE 34
73 #define HBA_STATUS_ERROR_INVALID_PROTOCOL_TYPE 35
74 #define HBA_STATUS_ERROR_BAD_EVENT_TYPE 36
77 /* SM-HBA 6.4.1.1 Port Type */
78 #define HBA_PORTTYPE_SASDEVICE 30 /* SAS (SSP or STP) */
79 #define HBA_PORTTYPE_SATADEVICE 31 /* SATA Device, i.e. Direct Attach SATA */
80 #define HBA_PORTTYPE_SASEXPANDER 32 /* SAS Expander */
82 /* SM-HBA 6.4.1.2 Port State */
83 #define HBA_PORTSTATE_DEGRADED 9 /* Degraded, but Operational mode */
85 /* SM-HBA 6.11.1.3 Port Speed */
86 #define HBA_PORTSPEED_4GBIT 8 /* 4 GBit / sec */
88 /* SM-HBA 6.1 Basic Attributes Types */
89 typedef struct SMHBA_scsilun
{HBA_UINT8 lun
[8]; }
90 SMHBA_SCSILUN
, *PSMHBA_SCSILUN
;
91 /* A byte array representation of a SCSI */
92 /* LUN (see SAM-4). The first byte of the */
93 /* LUN shall be in the first byte of the */
94 /* array, and successive bytes of the SCSI */
95 /* LUN shall be in successive bytes of the */
97 typedef unsigned long HBA_SCSILUN
;
98 /* A 64 bit unsigned integer representation */
99 /* of a SCSI LUN (see SAM-4); */
100 /* may use OS-specific typedef. */
101 /* Byte zero of a SCSI LUN shall be stored */
102 /* in the lowest memory address */
103 /* of the unsigned 64-bit integer value, */
104 /* and successive bytes of the SCSI LUN */
105 /* shall be stored in successively higher memory */
106 /* addresses of the unsigned 64-bit intege value. */
107 /* Note that computers often do not store */
108 /* a byte array in memory in the same order */
109 /* as they store an integer. */
110 /* This standard requires storage as a byte array */
113 /* SM-HBA 6.3.1 Generic Adapter Attribute */
114 typedef struct SMHBA_AdapterAttributes
{
115 char Manufacturer
[64];
116 char SerialNumber
[64];
118 char ModelDescription
[256];
119 char HardwareVersion
[256];
120 char DriverVersion
[256];
121 char OptionROMVersion
[256];
122 char FirmwareVersion
[256];
123 HBA_UINT32 VendorSpecificID
;
124 char DriverName
[256];
125 char HBASymbolicName
[256];
126 char RedundantOptionROMVersion
[256];
127 char RedundantFirmwareVersion
[256];
128 } SMHBA_ADAPTERATTRIBUTES
, *PSMHBA_ADAPTERATTRIBUTES
;
130 /* SM-HBA 6.4.6 SMHBA FC Port Attributes */
131 typedef struct SMHBA_FC_Port
{
135 HBA_COS PortSupportedClassofService
;
136 HBA_FC4TYPES PortSupportedFc4Types
;
137 HBA_FC4TYPES PortActiveFc4Types
;
139 char PortSymbolicName
[256];
140 HBA_UINT32 NumberofDiscoveredPorts
;
141 HBA_UINT8 NumberofPhys
;
142 }SMHBA_FC_PORT
, *PSMHBA_FC_PORT
;
144 /* SM-HBA 6.4.7.1 HBA_SASPortProtocol */
145 typedef HBA_UINT32 HBA_SASPORTPROTOCOL
;
146 #define HBA_SASPORTPROTOCOL_SSP 1 /* Serial SCSI Protocol Port */
147 #define HBA_SASPORTPROTOCOL_STP 2 /* Serial ATA Tunneling Protocol Port */
148 #define HBA_SASPORTPROTOCOL_SMP 4 /* Serial Management Protocol Port */
149 /* SATA Device, Direct Attached or anywhere in the domain. */
150 #define HBA_SASPORTPROTOCOL_SATA 8
152 /* SM-HBA 6.4.8 SMHBA SAS Port Attributes */
153 typedef struct SMHBA_SAS_Port
{
154 HBA_SASPORTPROTOCOL PortProtocol
;
155 HBA_WWN LocalSASAddress
;
156 HBA_WWN AttachedSASAddress
;
157 HBA_UINT32 NumberofDiscoveredPorts
;
158 HBA_UINT32 NumberofPhys
;
159 } SMHBA_SAS_PORT
, *PSMHBA_SAS_PORT
;
161 /* SM-HBA 6.4.2 Generic Port Attributes */
162 typedef union SMHBA_Port
{
163 SMHBA_FC_PORT
*FCPort
;
164 SMHBA_SAS_PORT
*SASPort
;
165 } SMHBA_PORT
, *PSMHBA_PORT
;
167 typedef struct SMHBA_PortAttributes
{
168 HBA_PORTTYPE PortType
;
169 HBA_PORTSTATE PortState
;
170 char OSDeviceName
[256];
171 SMHBA_PORT PortSpecificAttribute
;
172 } SMHBA_PORTATTRIBUTES
, *PSMHBA_PORTATTRIBUTES
;
174 /* SM-HBA 6.5.1.1 FC Phy Speed */
175 typedef HBA_UINT32 HBA_FCPHYSPEED
;
176 /* Unknown transceiver incapable of reporting */
177 #define HBA_FCSPEED_UNKNOWN 0
179 * The following are redundantly defined in SM-HBA 6.11.1.3 Port Speed.
180 * #define HBA_PORTSPEED_1GBIT 1 1 GBit/sec
181 * #define HBA_PORTSPEED_2GBIT 2 2 GBit/sec
182 * #define HBA_PORTSPEED_10GBIT 4 10 GBit/sec
183 * #define HBA_PORTSPEED_4GBIT 8 4 GBit/sec
185 #define HBA_FCPHYSPEED_8GBIT 16 /* 8 GBit/sec */
186 #define HBA_FCPHYSPEED_16GBIT 32 /* 16 GBit/sec */
188 * The following conflicts with HBA API
189 * #define HBA_PORTSPEED_NOT_NEGOTIATED (1<<15) Speed not established
192 /* SM-HBA 6.6.1.2 SM-HBA FC Phy Type */
193 typedef HBA_UINT8 HBA_FCPHYTYPE
;
194 #define HBA_FCPHYTYPE_UNKNOWN 1 /* Unknown Phy type */
195 #define HBA_FCPHYTYPE_OPTICAL 2 /* Optical Phy */
196 #define HBA_FCPHYTYPE_COPPER 4 /* Copper Phy */
198 /* SM-HBA 6.5.2 SM-HBA FC Phy Attributes */
199 typedef struct SMHBA_FC_Phy
{
200 HBA_FCPHYSPEED PhySupportedSpeed
; /* PhySupportedSpeed */
201 HBA_FCPHYSPEED PhySpeed
; /* PhySpeed */
202 HBA_FCPHYTYPE PhyType
;
203 HBA_UINT32 MaxFrameSize
; /* MaxFrameSize */
204 } SMHBA_FC_PHY
, *PSMHBA_FC_PHY
;
206 /* SM-HBA 6.5.4 SAS PHY Attribute Data Declaration */
207 typedef HBA_UINT32 HBA_SASPHYSPEED
;
209 #define HBA_SASSTATE_UNKNOWN 0x00 /* Phy is enabled. Speed is unknown */
210 #define HBA_SASSTATE_DISABLED 0x01 /* Phy is disabled. */
211 /* Phy is enabled. But failed speed negotiation. */
212 #define HBA_SASSTATE_FAILED 0x02
214 * Phy is enabled. Detected a SATA device and entered the SATA Spinup hold
217 #define HBA_SASSTATE_SATASPINUP 0x03
218 /* The phy is attached to a Port Selector (see SATA-2.6). */
219 #define HBA_SASSTATE_SATAPORTSEL 0x04
220 #define HBA_SASSPEED_1_5GBIT 0x08 /* 1.5 GBit/sec */
221 #define HBA_SASSPEED_3GBIT 0x09 /* 3 GBit/sec */
222 #define HBA_SASSPEED_6GBIT 0x0a /* 6 GBit/sec */
224 /* SM-HBA 6.5.5 SAS Phy Attribute */
225 typedef struct SMHBA_SAS_Phy
{
226 HBA_UINT8 PhyIdentifier
;
227 HBA_SASPHYSPEED NegotiatedLinkRate
;
228 HBA_SASPHYSPEED ProgrammedMinLinkRate
;
229 HBA_SASPHYSPEED HardwareMinLinkRate
;
230 HBA_SASPHYSPEED ProgrammedMaxLinkRate
;
231 HBA_SASPHYSPEED HardwareMaxLinkRate
;
232 HBA_WWN domainPortWWN
;
233 } SMHBA_SAS_PHY
, *PSMHBA_SAS_PHY
;
235 /* SM-HBA 6.6.1.1 Protocol Statistics Data Declarations */
236 /* Statistical counters for FC-4, SSP, STP, SMP protocols */
237 typedef struct SMHBA_ProtocolStatistics
{
238 HBA_INT64 SecondsSinceLastReset
;
239 HBA_INT64 InputRequests
;
240 HBA_INT64 OutputRequests
;
241 HBA_INT64 ControlRequests
;
242 HBA_INT64 InputMegabytes
;
243 HBA_INT64 OutputMegabytes
;
244 } SMHBA_PROTOCOLSTATISTICS
, *PSMHBA_PROTOCOLSTATISTICS
;
246 /* SM-HBA 6.6.2.1 Port Statistics Data Declarations */
247 typedef struct SMHBA_PortStatistics
{
248 HBA_INT64 SecondsSinceLastReset
;
253 }SMHBA_PORTSTATISTICS
, *PSMHBA_PORTSTATISTICS
;
255 /* SM-HBA 6.6.2.2 SAS Phy Statistics Data Declaration */
256 typedef struct SMHBA_SASPhyStatistics
{
257 HBA_INT64 SecondsSinceLastReset
;
262 HBA_INT64 InvalidDwordCount
;
263 HBA_INT64 RunningDisparityErrorCount
;
264 HBA_INT64 LossofDwordSyncCount
;
265 HBA_INT64 PhyResetProblemCount
;
266 } SMHBA_SASPHYSTATISTICS
, *PSMHBA_SASPHYSTATISTICS
;
268 /* SM-HBA 6.6.2.4 FC Phy Statistics Data Declaration */
269 /* Statistical counters for FC-0, FC-1, and FC-2 */
270 typedef struct SMHBA_FCPhyStatistics
{
271 HBA_INT64 SecondsSinceLastReset
;
278 HBA_INT64 ErrorFrames
;
279 HBA_INT64 DumpedFrames
;
280 HBA_INT64 LinkFailureCount
;
281 HBA_INT64 LossOfSyncCount
;
282 HBA_INT64 LossOfSignalCount
;
283 HBA_INT64 PrimitiveSeqProtocolErrCount
;
284 HBA_INT64 InvalidTxWordCount
;
285 HBA_INT64 InvalidCRCCount
;
286 }SMHBA_FCPHYSTATISTICS
, *PSMHBA_FCPHYSTATISTICS
;
288 /* SM-HBA 6.6.2.1 Phy Statistics Data Declaration */
289 typedef union SMHBA_PhyStatistics
{
290 SMHBA_SASPHYSTATISTICS
*SASPhyStatistics
;
291 SMHBA_FCPHYSTATISTICS
*FCPhyStatistics
;
292 } SMHBA_PHYSTATISTICS
, *PSMHBA_PHYSTATISTICS
;
294 /* SM-HBA 6.7.1.1 SMHBA_BIND_CAPABILITY */
295 typedef HBA_UINT32 SMHBA_BIND_CAPABILITY
;
296 #define SMHBA_CAN_BIND_TO_WWPN 0x0001
297 #define SMHBA_CAN_BIND_TO_LUID 0x0002
298 #define SMHBA_CAN_BIND_ANY_LUNS 0x0400
299 #define SMHBA_CAN_BIND_AUTOMAP 0x0800
301 /* SM-HBA 6.7.1.2 SMHBA_BIND_TYPE */
302 typedef HBA_UINT32 SMHBA_BIND_TYPE
;
303 #define SMHBA_BIND_TO_WWPN 0x0001
304 #define SMHBA_BIND_TO_LUID 0x0002
306 /* SM-HBA 6.7.1.3 SMHBA_ScsiId */
307 typedef struct SMHBA_ScsiId
{
308 char OSDeviceName
[256];
309 HBA_UINT32 ScsiBusNumber
;
310 HBA_UINT32 ScsiTargetNumber
;
311 HBA_UINT32 ScsiOSLun
;
312 } SMHBA_SCSIID
, *PSMHBA_SCSIID
;
314 /* SM-HBA 6.7.1.4 SMHBA_LUID */
315 typedef struct SMHBA_LUID
{
317 } SMHBA_LUID
, *PSMHBA_LUID
;
319 /* SM-HBA 6.7.1.5 SMHBA_PORTLUN */
320 typedef struct SMHBA_PORTLUN
{
322 HBA_WWN domainPortWWN
;
323 SMHBA_SCSILUN TargetLun
;
324 } SMHBA_PORTLUN
, *PSMHBA_PORTLUN
;
326 /* SM-HBA 6.7.1.6 Composite types */
327 typedef struct SMHBA_ScsiEntry
{
329 SMHBA_PORTLUN PortLun
;
331 } SMHBA_SCSIENTRY
, *PSMHBA_SCSIENTRY
;
333 typedef struct SMHBA_TargetMapping
{
334 HBA_UINT32 NumberOfEntries
;
335 SMHBA_SCSIENTRY entry
[1]; /* Variable length array */
336 } SMHBA_TARGETMAPPING
, *PSMHBA_TARGETMAPPING
;
338 typedef struct SMHBA_BindingEntry
{
339 SMHBA_BIND_TYPE type
;
341 SMHBA_PORTLUN PortLun
;
344 } SMHBA_BINDINGENTRY
, *PSMHBA_BINDINGENTRY
;
346 typedef struct SMHBA_Binding
{
347 HBA_UINT32 NumberOfEntries
;
348 SMHBA_BINDINGENTRY entry
[1]; /* Variable length array */
349 } SMHBA_BINDING
, *PSMHBA_BINDING
;
351 /* SM-HBA 6.9.5 Library Attribute Data Declarations */
352 typedef struct SMHBA_LibraryAttributes
{
357 int tm_mday
; /* day of the month - [1 - 31] */
358 int tm_mon
; /* months since January - [0 - 11] */
359 int tm_year
; /* years since 1900 */
361 } SMHBA_LIBRARYATTRIBUTES
, *PSMHBA_LIBRARYATTRIBUTES
;
363 /* SM-HBA 6.8.1 Asynchronous Event Data Declarations */
364 #define HBA_EVENT_PORT_BROADCAST_CHANGE 0x205
365 #define HBA_EVENT_PORT_BROADCAST_SES 0x208
366 #define HBA_EVENT_PORT_BROADCAST_D24_0 0x206
367 #define HBA_EVENT_PORT_BROADCAST_D27_4 0x207
368 #define HBA_EVENT_PORT_BROADCAST_D01_4 0x209
369 #define HBA_EVENT_PORT_BROADCAST_D04_7 0x20A
370 #define HBA_EVENT_PORT_BROADCAST_D16_7 0x20B
371 #define HBA_EVENT_PORT_BROADCAST_D29_7 0x20C
372 #define HBA_EVENT_PORT_ALL 0x2FF
374 /* SM-HBA specific entry points. */
376 HBA_UINT32
SMHBA_GetVersion();
378 HBA_UINT32
SMHBA_GetWrapperLibraryAttributes(
379 SMHBA_LIBRARYATTRIBUTES
*attributes
382 HBA_UINT32
SMHBA_GetVendorLibraryAttributes(
383 HBA_UINT32 adapter_index
,
384 SMHBA_LIBRARYATTRIBUTES
*attributes
387 HBA_STATUS
SMHBA_GetAdapterAttributes(
389 SMHBA_ADAPTERATTRIBUTES
*pAdapterAttributes
392 HBA_STATUS
SMHBA_GetNumberOfPorts(
394 HBA_UINT32
*numberofports
397 HBA_STATUS
SMHBA_GetPortType(
399 HBA_UINT32 portindex
,
400 HBA_PORTTYPE
*porttype
403 HBA_STATUS
SMHBA_GetAdapterPortAttributes(
405 HBA_UINT32 portindex
,
406 SMHBA_PORTATTRIBUTES
*portattributes
409 HBA_STATUS
SMHBA_GetDiscoveredPortAttributes(
411 HBA_UINT32 portindex
,
412 HBA_UINT32 discoveredportindex
,
413 SMHBA_PORTATTRIBUTES
*porattributes
416 HBA_STATUS
SMHBA_GetPortAttributesByWWN(
419 HBA_WWN domainPortWWN
,
420 SMHBA_PORTATTRIBUTES
*portattributes
423 HBA_STATUS
SMHBA_GetPortAttributesByWWN(
426 HBA_WWN domainPortWWN
,
427 SMHBA_PORTATTRIBUTES
*portattributes
430 HBA_STATUS
SMHBA_GetFCPhyAttributes(
432 HBA_UINT32 portindex
,
434 SMHBA_FC_PHY
*phytype
437 HBA_STATUS
SMHBA_GetSASPhyAttributes(
439 HBA_UINT32 portindex
,
441 SMHBA_SAS_PHY
*phytype
444 HBA_STATUS
SMHBA_GetProtocolStatistics(
446 HBA_UINT32 portindex
,
447 HBA_UINT32 protocoltype
,
448 SMHBA_PROTOCOLSTATISTICS
*pProtocolStatistics
451 HBA_STATUS
SMHBA_GetPhyStatistics(
453 HBA_UINT32 portindex
,
455 SMHBA_PHYSTATISTICS
*pPhyStatistics
458 HBA_STATUS
SMHBA_SendTEST(
464 HBA_UINT32 ReqBufferSize
467 HBA_STATUS
SMHBA_SendECHO(
473 HBA_UINT32 ReqBufferSize
,
475 HBA_UINT32
*pRspBufferSize
478 HBA_UINT32
SMHBA_SendSMPPassThru(
482 HBA_WWN domainPortWWN
,
484 HBA_UINT32 ReqBufferSize
,
486 HBA_UINT32
*pRspBufferSize
489 HBA_STATUS
SMHBA_GetBindingCapability(
492 HBA_WWN domainPortWWN
,
493 SMHBA_BIND_CAPABILITY
*pFlags
496 HBA_STATUS
SMHBA_GetBindingSupport(
499 HBA_WWN domainPortWWN
,
500 SMHBA_BIND_CAPABILITY
*pFlags
503 HBA_STATUS
SMHBA_SetBindingSupport(
506 HBA_WWN domainPortWWN
,
507 SMHBA_BIND_CAPABILITY flags
510 HBA_STATUS
SMHBA_GetTargetMapping(
513 HBA_WWN domainPortWWN
,
514 SMHBA_TARGETMAPPING
*pMapping
517 HBA_STATUS
SMHBA_GetPersistentBinding(
520 HBA_WWN domainPortWWN
,
521 SMHBA_BINDING
*binding
524 HBA_STATUS
SMHBA_SetPersistentBinding(
527 HBA_WWN domainPortWWN
,
528 const SMHBA_BINDING
*binding
531 HBA_STATUS
SMHBA_RemovePersistentBinding(
534 HBA_WWN domainPortWWN
,
535 const SMHBA_BINDING
*binding
538 HBA_STATUS
SMHBA_RemoveAllPersistentBindings(
541 HBA_WWN domainPortWWN
544 HBA_STATUS
SMHBA_GetLUNStatistics(
546 const HBA_SCSIID
*lunit
,
547 SMHBA_PROTOCOLSTATISTICS
*statistics
550 HBA_STATUS
SMHBA_ScsiInquiry(
553 HBA_WWN discoveredPortWWN
,
554 HBA_WWN domainPortWWN
,
555 SMHBA_SCSILUN smhbaLUN
,
559 HBA_UINT32
*pRspBufferSize
,
560 HBA_UINT8
*pScsiStatus
,
562 HBA_UINT32
*pSenseBufferSize
565 HBA_STATUS
SMHBA_ScsiReportLUNs(
568 HBA_WWN discoveredPortWWN
,
569 HBA_WWN domainPortWWN
,
571 HBA_UINT32
*pRspBufferSize
,
572 HBA_UINT8
*pScsiStatus
,
574 HBA_UINT32
*pSenseBufferSize
577 HBA_STATUS
SMHBA_ScsiReadCapacity(
580 HBA_WWN discoveredPortWWN
,
581 HBA_WWN domainPortWWN
,
582 SMHBA_SCSILUN smhbaLUN
,
584 HBA_UINT32
*pRspBufferSize
,
585 HBA_UINT8
*pScsiStatus
,
587 HBA_UINT32
*pSenseBufferSize
590 HBA_STATUS
SMHBA_RegisterForAdapterAddEvents(
594 HBA_UINT32 eventType
),
596 HBA_CALLBACKHANDLE
*pCallbackHandle
599 HBA_STATUS
SMHBA_RegisterForAdapterEvents(
603 HBA_UINT32 eventType
),
606 HBA_CALLBACKHANDLE
*pCallbackHandle
609 HBA_STATUS
SMHBA_RegisterForAdapterPortEvents(
613 HBA_UINT32 eventType
,
614 HBA_UINT32 fabricPortID
),
618 HBA_UINT32 specificEventType
,
619 HBA_CALLBACKHANDLE
*pCallbackHandle
622 HBA_STATUS
SMHBA_RegisterForAdapterPortStatEvents(
626 HBA_UINT32 protocolType
,
627 HBA_UINT32 eventType
),
631 HBA_UINT32 protocolType
,
632 SMHBA_PROTOCOLSTATISTICS stats
,
634 HBA_CALLBACKHANDLE
*pCallbackHandle
637 HBA_STATUS
SMHBA_RegisterForAdapterPhyStatEvents(
642 HBA_UINT32 eventType
),
647 SMHBA_PHYSTATISTICS stats
,
649 HBA_CALLBACKHANDLE
*pCallbackHandle
652 HBA_STATUS
SMHBA_RegisterForTargetEvents(
656 HBA_WWN discoveredPortWWN
,
657 HBA_WWN domainPortWWN
,
658 HBA_UINT32 eventType
),
662 HBA_WWN discoveredPortWWN
,
663 HBA_WWN domainPortWWN
,
664 HBA_CALLBACKHANDLE
*pCallbackHandle
,
665 HBA_UINT32 allTargets
672 #endif /* _SMHBAAPI_H_ */