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 */
223 #define HBA_SASSPEED_12GBIT 0x0b /* 12 GBit/sec */
225 /* SM-HBA 6.5.5 SAS Phy Attribute */
226 typedef struct SMHBA_SAS_Phy
{
227 HBA_UINT8 PhyIdentifier
;
228 HBA_SASPHYSPEED NegotiatedLinkRate
;
229 HBA_SASPHYSPEED ProgrammedMinLinkRate
;
230 HBA_SASPHYSPEED HardwareMinLinkRate
;
231 HBA_SASPHYSPEED ProgrammedMaxLinkRate
;
232 HBA_SASPHYSPEED HardwareMaxLinkRate
;
233 HBA_WWN domainPortWWN
;
234 } SMHBA_SAS_PHY
, *PSMHBA_SAS_PHY
;
236 /* SM-HBA 6.6.1.1 Protocol Statistics Data Declarations */
237 /* Statistical counters for FC-4, SSP, STP, SMP protocols */
238 typedef struct SMHBA_ProtocolStatistics
{
239 HBA_INT64 SecondsSinceLastReset
;
240 HBA_INT64 InputRequests
;
241 HBA_INT64 OutputRequests
;
242 HBA_INT64 ControlRequests
;
243 HBA_INT64 InputMegabytes
;
244 HBA_INT64 OutputMegabytes
;
245 } SMHBA_PROTOCOLSTATISTICS
, *PSMHBA_PROTOCOLSTATISTICS
;
247 /* SM-HBA 6.6.2.1 Port Statistics Data Declarations */
248 typedef struct SMHBA_PortStatistics
{
249 HBA_INT64 SecondsSinceLastReset
;
254 }SMHBA_PORTSTATISTICS
, *PSMHBA_PORTSTATISTICS
;
256 /* SM-HBA 6.6.2.2 SAS Phy Statistics Data Declaration */
257 typedef struct SMHBA_SASPhyStatistics
{
258 HBA_INT64 SecondsSinceLastReset
;
263 HBA_INT64 InvalidDwordCount
;
264 HBA_INT64 RunningDisparityErrorCount
;
265 HBA_INT64 LossofDwordSyncCount
;
266 HBA_INT64 PhyResetProblemCount
;
267 } SMHBA_SASPHYSTATISTICS
, *PSMHBA_SASPHYSTATISTICS
;
269 /* SM-HBA 6.6.2.4 FC Phy Statistics Data Declaration */
270 /* Statistical counters for FC-0, FC-1, and FC-2 */
271 typedef struct SMHBA_FCPhyStatistics
{
272 HBA_INT64 SecondsSinceLastReset
;
279 HBA_INT64 ErrorFrames
;
280 HBA_INT64 DumpedFrames
;
281 HBA_INT64 LinkFailureCount
;
282 HBA_INT64 LossOfSyncCount
;
283 HBA_INT64 LossOfSignalCount
;
284 HBA_INT64 PrimitiveSeqProtocolErrCount
;
285 HBA_INT64 InvalidTxWordCount
;
286 HBA_INT64 InvalidCRCCount
;
287 }SMHBA_FCPHYSTATISTICS
, *PSMHBA_FCPHYSTATISTICS
;
289 /* SM-HBA 6.6.2.1 Phy Statistics Data Declaration */
290 typedef union SMHBA_PhyStatistics
{
291 SMHBA_SASPHYSTATISTICS
*SASPhyStatistics
;
292 SMHBA_FCPHYSTATISTICS
*FCPhyStatistics
;
293 } SMHBA_PHYSTATISTICS
, *PSMHBA_PHYSTATISTICS
;
295 /* SM-HBA 6.7.1.1 SMHBA_BIND_CAPABILITY */
296 typedef HBA_UINT32 SMHBA_BIND_CAPABILITY
;
297 #define SMHBA_CAN_BIND_TO_WWPN 0x0001
298 #define SMHBA_CAN_BIND_TO_LUID 0x0002
299 #define SMHBA_CAN_BIND_ANY_LUNS 0x0400
300 #define SMHBA_CAN_BIND_AUTOMAP 0x0800
302 /* SM-HBA 6.7.1.2 SMHBA_BIND_TYPE */
303 typedef HBA_UINT32 SMHBA_BIND_TYPE
;
304 #define SMHBA_BIND_TO_WWPN 0x0001
305 #define SMHBA_BIND_TO_LUID 0x0002
307 /* SM-HBA 6.7.1.3 SMHBA_ScsiId */
308 typedef struct SMHBA_ScsiId
{
309 char OSDeviceName
[256];
310 HBA_UINT32 ScsiBusNumber
;
311 HBA_UINT32 ScsiTargetNumber
;
312 HBA_UINT32 ScsiOSLun
;
313 } SMHBA_SCSIID
, *PSMHBA_SCSIID
;
315 /* SM-HBA 6.7.1.4 SMHBA_LUID */
316 typedef struct SMHBA_LUID
{
318 } SMHBA_LUID
, *PSMHBA_LUID
;
320 /* SM-HBA 6.7.1.5 SMHBA_PORTLUN */
321 typedef struct SMHBA_PORTLUN
{
323 HBA_WWN domainPortWWN
;
324 SMHBA_SCSILUN TargetLun
;
325 } SMHBA_PORTLUN
, *PSMHBA_PORTLUN
;
327 /* SM-HBA 6.7.1.6 Composite types */
328 typedef struct SMHBA_ScsiEntry
{
330 SMHBA_PORTLUN PortLun
;
332 } SMHBA_SCSIENTRY
, *PSMHBA_SCSIENTRY
;
334 typedef struct SMHBA_TargetMapping
{
335 HBA_UINT32 NumberOfEntries
;
336 SMHBA_SCSIENTRY entry
[1]; /* Variable length array */
337 } SMHBA_TARGETMAPPING
, *PSMHBA_TARGETMAPPING
;
339 typedef struct SMHBA_BindingEntry
{
340 SMHBA_BIND_TYPE type
;
342 SMHBA_PORTLUN PortLun
;
345 } SMHBA_BINDINGENTRY
, *PSMHBA_BINDINGENTRY
;
347 typedef struct SMHBA_Binding
{
348 HBA_UINT32 NumberOfEntries
;
349 SMHBA_BINDINGENTRY entry
[1]; /* Variable length array */
350 } SMHBA_BINDING
, *PSMHBA_BINDING
;
352 /* SM-HBA 6.9.5 Library Attribute Data Declarations */
353 typedef struct SMHBA_LibraryAttributes
{
358 int tm_mday
; /* day of the month - [1 - 31] */
359 int tm_mon
; /* months since January - [0 - 11] */
360 int tm_year
; /* years since 1900 */
362 } SMHBA_LIBRARYATTRIBUTES
, *PSMHBA_LIBRARYATTRIBUTES
;
364 /* SM-HBA 6.8.1 Asynchronous Event Data Declarations */
365 #define HBA_EVENT_PORT_BROADCAST_CHANGE 0x205
366 #define HBA_EVENT_PORT_BROADCAST_SES 0x208
367 #define HBA_EVENT_PORT_BROADCAST_D24_0 0x206
368 #define HBA_EVENT_PORT_BROADCAST_D27_4 0x207
369 #define HBA_EVENT_PORT_BROADCAST_D01_4 0x209
370 #define HBA_EVENT_PORT_BROADCAST_D04_7 0x20A
371 #define HBA_EVENT_PORT_BROADCAST_D16_7 0x20B
372 #define HBA_EVENT_PORT_BROADCAST_D29_7 0x20C
373 #define HBA_EVENT_PORT_ALL 0x2FF
375 /* SM-HBA specific entry points. */
377 HBA_UINT32
SMHBA_GetVersion();
379 HBA_UINT32
SMHBA_GetWrapperLibraryAttributes(
380 SMHBA_LIBRARYATTRIBUTES
*attributes
383 HBA_UINT32
SMHBA_GetVendorLibraryAttributes(
384 HBA_UINT32 adapter_index
,
385 SMHBA_LIBRARYATTRIBUTES
*attributes
388 HBA_STATUS
SMHBA_GetAdapterAttributes(
390 SMHBA_ADAPTERATTRIBUTES
*pAdapterAttributes
393 HBA_STATUS
SMHBA_GetNumberOfPorts(
395 HBA_UINT32
*numberofports
398 HBA_STATUS
SMHBA_GetPortType(
400 HBA_UINT32 portindex
,
401 HBA_PORTTYPE
*porttype
404 HBA_STATUS
SMHBA_GetAdapterPortAttributes(
406 HBA_UINT32 portindex
,
407 SMHBA_PORTATTRIBUTES
*portattributes
410 HBA_STATUS
SMHBA_GetDiscoveredPortAttributes(
412 HBA_UINT32 portindex
,
413 HBA_UINT32 discoveredportindex
,
414 SMHBA_PORTATTRIBUTES
*porattributes
417 HBA_STATUS
SMHBA_GetPortAttributesByWWN(
420 HBA_WWN domainPortWWN
,
421 SMHBA_PORTATTRIBUTES
*portattributes
424 HBA_STATUS
SMHBA_GetPortAttributesByWWN(
427 HBA_WWN domainPortWWN
,
428 SMHBA_PORTATTRIBUTES
*portattributes
431 HBA_STATUS
SMHBA_GetFCPhyAttributes(
433 HBA_UINT32 portindex
,
435 SMHBA_FC_PHY
*phytype
438 HBA_STATUS
SMHBA_GetSASPhyAttributes(
440 HBA_UINT32 portindex
,
442 SMHBA_SAS_PHY
*phytype
445 HBA_STATUS
SMHBA_GetProtocolStatistics(
447 HBA_UINT32 portindex
,
448 HBA_UINT32 protocoltype
,
449 SMHBA_PROTOCOLSTATISTICS
*pProtocolStatistics
452 HBA_STATUS
SMHBA_GetPhyStatistics(
454 HBA_UINT32 portindex
,
456 SMHBA_PHYSTATISTICS
*pPhyStatistics
459 HBA_STATUS
SMHBA_SendTEST(
465 HBA_UINT32 ReqBufferSize
468 HBA_STATUS
SMHBA_SendECHO(
474 HBA_UINT32 ReqBufferSize
,
476 HBA_UINT32
*pRspBufferSize
479 HBA_UINT32
SMHBA_SendSMPPassThru(
483 HBA_WWN domainPortWWN
,
485 HBA_UINT32 ReqBufferSize
,
487 HBA_UINT32
*pRspBufferSize
490 HBA_STATUS
SMHBA_GetBindingCapability(
493 HBA_WWN domainPortWWN
,
494 SMHBA_BIND_CAPABILITY
*pFlags
497 HBA_STATUS
SMHBA_GetBindingSupport(
500 HBA_WWN domainPortWWN
,
501 SMHBA_BIND_CAPABILITY
*pFlags
504 HBA_STATUS
SMHBA_SetBindingSupport(
507 HBA_WWN domainPortWWN
,
508 SMHBA_BIND_CAPABILITY flags
511 HBA_STATUS
SMHBA_GetTargetMapping(
514 HBA_WWN domainPortWWN
,
515 SMHBA_TARGETMAPPING
*pMapping
518 HBA_STATUS
SMHBA_GetPersistentBinding(
521 HBA_WWN domainPortWWN
,
522 SMHBA_BINDING
*binding
525 HBA_STATUS
SMHBA_SetPersistentBinding(
528 HBA_WWN domainPortWWN
,
529 const SMHBA_BINDING
*binding
532 HBA_STATUS
SMHBA_RemovePersistentBinding(
535 HBA_WWN domainPortWWN
,
536 const SMHBA_BINDING
*binding
539 HBA_STATUS
SMHBA_RemoveAllPersistentBindings(
542 HBA_WWN domainPortWWN
545 HBA_STATUS
SMHBA_GetLUNStatistics(
547 const HBA_SCSIID
*lunit
,
548 SMHBA_PROTOCOLSTATISTICS
*statistics
551 HBA_STATUS
SMHBA_ScsiInquiry(
554 HBA_WWN discoveredPortWWN
,
555 HBA_WWN domainPortWWN
,
556 SMHBA_SCSILUN smhbaLUN
,
560 HBA_UINT32
*pRspBufferSize
,
561 HBA_UINT8
*pScsiStatus
,
563 HBA_UINT32
*pSenseBufferSize
566 HBA_STATUS
SMHBA_ScsiReportLUNs(
569 HBA_WWN discoveredPortWWN
,
570 HBA_WWN domainPortWWN
,
572 HBA_UINT32
*pRspBufferSize
,
573 HBA_UINT8
*pScsiStatus
,
575 HBA_UINT32
*pSenseBufferSize
578 HBA_STATUS
SMHBA_ScsiReadCapacity(
581 HBA_WWN discoveredPortWWN
,
582 HBA_WWN domainPortWWN
,
583 SMHBA_SCSILUN smhbaLUN
,
585 HBA_UINT32
*pRspBufferSize
,
586 HBA_UINT8
*pScsiStatus
,
588 HBA_UINT32
*pSenseBufferSize
591 HBA_STATUS
SMHBA_RegisterForAdapterAddEvents(
595 HBA_UINT32 eventType
),
597 HBA_CALLBACKHANDLE
*pCallbackHandle
600 HBA_STATUS
SMHBA_RegisterForAdapterEvents(
604 HBA_UINT32 eventType
),
607 HBA_CALLBACKHANDLE
*pCallbackHandle
610 HBA_STATUS
SMHBA_RegisterForAdapterPortEvents(
614 HBA_UINT32 eventType
,
615 HBA_UINT32 fabricPortID
),
619 HBA_UINT32 specificEventType
,
620 HBA_CALLBACKHANDLE
*pCallbackHandle
623 HBA_STATUS
SMHBA_RegisterForAdapterPortStatEvents(
627 HBA_UINT32 protocolType
,
628 HBA_UINT32 eventType
),
632 HBA_UINT32 protocolType
,
633 SMHBA_PROTOCOLSTATISTICS stats
,
635 HBA_CALLBACKHANDLE
*pCallbackHandle
638 HBA_STATUS
SMHBA_RegisterForAdapterPhyStatEvents(
643 HBA_UINT32 eventType
),
648 SMHBA_PHYSTATISTICS stats
,
650 HBA_CALLBACKHANDLE
*pCallbackHandle
653 HBA_STATUS
SMHBA_RegisterForTargetEvents(
657 HBA_WWN discoveredPortWWN
,
658 HBA_WWN domainPortWWN
,
659 HBA_UINT32 eventType
),
663 HBA_WWN discoveredPortWWN
,
664 HBA_WWN domainPortWWN
,
665 HBA_CALLBACKHANDLE
*pCallbackHandle
,
666 HBA_UINT32 allTargets
673 #endif /* _SMHBAAPI_H_ */