Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

346 lines
9.2 KiB

  1. //***************************************************************************
  2. //
  3. // main.c
  4. //
  5. // Module: Windows HBA API implmentation
  6. //
  7. // Purpose: Contains HBA api header
  8. //
  9. // Copyright (c) 2001 Microsoft Corporation
  10. //
  11. //***************************************************************************
  12. #ifdef _HBAAPIP_
  13. #define HBA_API __cdecl
  14. #else
  15. #define HBA_API DECLSPEC_IMPORT __cdecl
  16. #endif
  17. #define HBA_VERSION 1
  18. typedef ULONGLONG HBA_UINT64;
  19. typedef LONGLONG HBA_INT64;
  20. typedef ULONG HBA_UINT32;
  21. typedef USHORT HBA_UINT16;
  22. typedef UCHAR HBA_UINT8;
  23. typedef HBA_UINT32 HBA_HANDLE;
  24. typedef HBA_UINT32 HBA_STATUS;
  25. #define HBA_STATUS_OK 0
  26. #define HBA_STATUS_ERROR 1 /* Error */
  27. #define HBA_STATUS_ERROR_NOT_SUPPORTED 2 /* Function not supported.*/
  28. #define HBA_STATUS_ERROR_INVALID_HANDLE 3 /* invalid handle */
  29. #define HBA_STATUS_ERROR_ARG 4 /* Bad argument */
  30. #define HBA_STATUS_ERROR_ILLEGAL_WWN 5 /* WWN not recognized */
  31. #define HBA_STATUS_ERROR_ILLEGAL_INDEX 6 /* Index not recognized */
  32. #define HBA_STATUS_ERROR_MORE_DATA 7 /* Larger buffer required */
  33. #define HBA_STATUS_ERROR_STALE_DATA 8 /* Data is stale, HBARefreshInformation is required */
  34. typedef HBA_UINT32 HBA_PORTTYPE;
  35. #define HBA_PORTTYPE_UNKNOWN 1 /* Unknown */
  36. #define HBA_PORTTYPE_OTHER 2 /* Other */
  37. #define HBA_PORTTYPE_NOTPRESENT 3 /* Not present */
  38. #define HBA_PORTTYPE_NPORT 5 /* Fabric */
  39. #define HBA_PORTTYPE_NLPORT 6 /* Public Loop */
  40. #define HBA_PORTTYPE_FLPORT 7
  41. #define HBA_PORTTYPE_FPORT 8 /* Fabric Port */
  42. #define HBA_PORTTYPE_EPORT 9 /* Fabric expansion port */
  43. #define HBA_PORTTYPE_GPORT 10 /* Generic Fabric Port */
  44. #define HBA_PORTTYPE_LPORT 20 /* Private Loop */
  45. #define HBA_PORTTYPE_PTP 21 /* Point to Point */
  46. typedef HBA_UINT32 HBA_PORTSTATE;
  47. #define HBA_PORTSTATE_UNKNOWN 1 /* Unknown */
  48. #define HBA_PORTSTATE_ONLINE 2 /* Operational */
  49. #define HBA_PORTSTATE_OFFLINE 3 /* User Offline */
  50. #define HBA_PORTSTATE_BYPASSED 4 /* Bypassed */
  51. #define HBA_PORTSTATE_DIAGNOSTICS 5 /* In diagnostics mode */
  52. #define HBA_PORTSTATE_LINKDOWN 6 /* Link Down */
  53. #define HBA_PORTSTATE_ERROR 7 /* Port Error */
  54. #define HBA_PORTSTATE_LOOPBACK 8 /* Loopback */
  55. typedef HBA_UINT32 HBA_PORTSPEED;
  56. #define HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */
  57. #define HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */
  58. #define HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */
  59. typedef HBA_UINT32 HBA_COS;
  60. typedef struct HBA_fc4types {
  61. HBA_UINT8 bits[32]; /* 32 bytes of FC-4 per GS-2 */
  62. } HBA_FC4TYPES, *PHBA_FC4TYPES;
  63. typedef struct HBA_wwn {
  64. HBA_UINT8 wwn[8];
  65. } HBA_WWN, *PHBA_WWN;
  66. typedef struct HBA_ipaddress {
  67. int ipversion; // see enumerations in RNID
  68. union
  69. {
  70. unsigned char ipv4address[4];
  71. unsigned char ipv6address[16];
  72. } ipaddress;
  73. } HBA_IPADDRESS, *PHBA_IPADDRESS;
  74. typedef struct HBA_AdapterAttributes {
  75. char Manufacturer[64]; /*Emulex */
  76. char SerialNumber[64]; /* A12345 */
  77. char Model[256]; /* QLA2200 */
  78. char ModelDescription[256]; /* Agilent TachLite */
  79. HBA_WWN NodeWWN;
  80. char NodeSymbolicName[256]; /* From GS-2 */
  81. char HardwareVersion[256]; /* Vendor use */
  82. char DriverVersion[256]; /* Vendor use */
  83. char OptionROMVersion[256]; /* Vendor use - i.e. hardware boot ROM*/
  84. char FirmwareVersion[256]; /* Vendor use */
  85. HBA_UINT32 VendorSpecificID; /* Vendor specific */
  86. HBA_UINT32 NumberOfPorts;
  87. char DriverName[256]; /* Binary path and/or name of driver file. */
  88. } HBA_ADAPTERATTRIBUTES, *PHBA_ADAPTERATTRIBUTES;
  89. typedef struct HBA_PortAttributes {
  90. HBA_WWN NodeWWN;
  91. HBA_WWN PortWWN;
  92. HBA_UINT32 PortFcId;
  93. HBA_PORTTYPE PortType; /*PTP, Fabric, etc. */
  94. HBA_PORTSTATE PortState;
  95. HBA_COS PortSupportedClassofService;
  96. HBA_FC4TYPES PortSupportedFc4Types;
  97. HBA_FC4TYPES PortActiveFc4Types;
  98. char PortSymbolicName[256];
  99. char OSDeviceName[256]; /* \device\ScsiPort3 */
  100. HBA_PORTSPEED PortSupportedSpeed;
  101. HBA_PORTSPEED PortSpeed;
  102. HBA_UINT32 PortMaxFrameSize;
  103. HBA_WWN FabricName;
  104. HBA_UINT32 NumberofDiscoveredPorts;
  105. } HBA_PORTATTRIBUTES, *PHBA_PORTATTRIBUTES;
  106. typedef struct HBA_PortStatistics {
  107. HBA_INT64 SecondsSinceLastReset;
  108. HBA_INT64 TxFrames;
  109. HBA_INT64 TxWords;
  110. HBA_INT64 RxFrames;
  111. HBA_INT64 RxWords;
  112. HBA_INT64 LIPCount;
  113. HBA_INT64 NOSCount;
  114. HBA_INT64 ErrorFrames;
  115. HBA_INT64 DumpedFrames;
  116. HBA_INT64 LinkFailureCount;
  117. HBA_INT64 LossOfSyncCount;
  118. HBA_INT64 LossOfSignalCount;
  119. HBA_INT64 PrimitiveSeqProtocolErrCount;
  120. HBA_INT64 InvalidTxWordCount;
  121. HBA_INT64 InvalidCRCCount;
  122. } HBA_PORTSTATISTICS, *PHBA_PORTSTATISTICS;
  123. typedef enum HBA_fcpbindingtype { TO_D_ID, TO_WWN } HBA_FCPBINDINGTYPE;
  124. typedef struct HBA_ScsiId {
  125. char OSDeviceName[256]; /* \device\ScsiPort3 */
  126. HBA_UINT32 ScsiBusNumber; /* Bus on the HBA */
  127. HBA_UINT32 ScsiTargetNumber; /* SCSI Target ID to OS */
  128. HBA_UINT32 ScsiOSLun;
  129. } HBA_SCSIID, *PHBA_SCSIID;
  130. typedef struct HBA_FcpId {
  131. HBA_UINT32 FcId;
  132. HBA_WWN NodeWWN;
  133. HBA_WWN PortWWN;
  134. HBA_UINT64 FcpLun;
  135. } HBA_FCPID, *PHBA_FCPID;
  136. typedef struct HBA_FcpScsiEntry {
  137. HBA_SCSIID ScsiId;
  138. HBA_FCPID FcpId;
  139. } HBA_FCPSCSIENTRY, *PHBA_FCPSCSIENTRY;
  140. typedef struct HBA_FCPTargetMapping {
  141. HBA_UINT32 NumberOfEntries;
  142. HBA_FCPSCSIENTRY entry[1]; /* Variable length array containing mappings*/
  143. } HBA_FCPTARGETMAPPING, *PHBA_FCPTARGETMAPPING;
  144. typedef struct HBA_FCPBindingEntry {
  145. HBA_FCPBINDINGTYPE type;
  146. HBA_SCSIID ScsiId;
  147. HBA_FCPID FcpId;
  148. } HBA_FCPBINDINGENTRY, *PHBA_FCPBINDINGENTRY;
  149. typedef struct HBA_FCPBinding {
  150. HBA_UINT32 NumberOfEntries;
  151. HBA_FCPBINDINGENTRY entry[1]; /* Variable length array */
  152. } HBA_FCPBINDING, *PHBA_FCPBINDING;
  153. typedef enum HBA_wwntype { NODE_WWN, PORT_WWN } HBA_WWNTYPE;
  154. typedef struct HBA_MgmtInfo {
  155. HBA_WWN wwn;
  156. HBA_UINT32 unittype;
  157. HBA_UINT32 PortId;
  158. HBA_UINT32 NumberOfAttachedNodes;
  159. HBA_UINT16 IPVersion;
  160. HBA_UINT16 UDPPort;
  161. HBA_UINT8 IPAddress[16];
  162. HBA_UINT16 reserved;
  163. HBA_UINT16 TopologyDiscoveryFlags;
  164. } HBA_MGMTINFO, *PHBA_MGMTINFO;
  165. #define HBA_EVENT_LIP_OCCURRED 1
  166. #define HBA_EVENT_LINK_UP 2
  167. #define HBA_EVENT_LINK_DOWN 3
  168. #define HBA_EVENT_LIP_RESET_OCCURRED 4
  169. #define HBA_EVENT_RSCN 5
  170. #define HBA_EVENT_PROPRIETARY 0xFFFF
  171. typedef struct HBA_Link_EventInfo {
  172. HBA_UINT32 PortFcId; /* Port which this event occurred */
  173. HBA_UINT32 Reserved[3];
  174. } HBA_LINK_EVENTINFO, *PHBA_LINK_EVENTINFO;
  175. typedef struct HBA_RSCN_EventInfo {
  176. HBA_UINT32 PortFcId; /* Port which this event occurred */
  177. HBA_UINT32 NPortPage; /* Reference FC-FS for RSCN ELS "Affected N-Port Pages"*/
  178. HBA_UINT32 Reserved[2];
  179. } HBA_RSCN_EVENTINFO, *PHBA_RSCN_EVENTINFO;
  180. typedef struct HBA_Pty_EventInfo {
  181. HBA_UINT32 PtyData[4]; /* Proprietary data */
  182. } HBA_PTY_EVENTINFO, *PHBA_PTY_EVENTINFO;
  183. typedef struct HBA_EventInfo {
  184. HBA_UINT32 EventCode;
  185. union {
  186. HBA_LINK_EVENTINFO Link_EventInfo;
  187. HBA_RSCN_EVENTINFO RSCN_EventInfo;
  188. HBA_PTY_EVENTINFO Pty_EventInfo;
  189. } Event;
  190. } HBA_EVENTINFO, *PHBA_EVENTINFO;
  191. typedef PVOID PHBA_ENTRYPOINTS;
  192. HBA_STATUS HBA_API HBA_RegisterLibrary(PHBA_ENTRYPOINTS entrypoints);
  193. HBA_UINT32 HBA_API HBA_GetVersion();
  194. HBA_STATUS HBA_API HBA_LoadLibrary();
  195. HBA_STATUS HBA_API HBA_FreeLibrary();
  196. HBA_UINT32 HBA_API HBA_GetNumberOfAdapters();
  197. HBA_STATUS HBA_API HBA_GetAdapterName(HBA_UINT32 adapterindex, char *adaptername);
  198. HBA_HANDLE HBA_API HBA_OpenAdapter(
  199. char* adaptername
  200. );
  201. void HBA_API HBA_CloseAdapter(
  202. HBA_HANDLE handle
  203. );
  204. HBA_STATUS HBA_API HBA_GetAdapterAttributes(
  205. HBA_HANDLE handle,
  206. HBA_ADAPTERATTRIBUTES *hbaattributes
  207. );
  208. HBA_STATUS HBA_API HBA_GetAdapterPortAttributes(
  209. HBA_HANDLE handle,
  210. HBA_UINT32 portindex,
  211. HBA_PORTATTRIBUTES *portattributes
  212. );
  213. HBA_STATUS HBA_API HBA_GetPortStatistics(
  214. HBA_HANDLE handle,
  215. HBA_UINT32 portindex,
  216. HBA_PORTSTATISTICS *portstatistics
  217. );
  218. HBA_STATUS HBA_API HBA_GetDiscoveredPortAttributes(
  219. HBA_HANDLE handle,
  220. HBA_UINT32 portindex,
  221. HBA_UINT32 discoveredportindex,
  222. HBA_PORTATTRIBUTES *portattributes
  223. );
  224. HBA_STATUS HBA_API HBA_GetPortAttributesByWWN(
  225. HBA_HANDLE handle,
  226. HBA_WWN PortWWN,
  227. HBA_PORTATTRIBUTES *portattributes
  228. );
  229. HBA_STATUS HBA_API HBA_SendCTPassThru(
  230. HBA_HANDLE handle,
  231. void * pReqBuffer,
  232. HBA_UINT32 ReqBufferSize,
  233. void * pRspBuffer,
  234. HBA_UINT32 RspBufferSize
  235. );
  236. HBA_STATUS HBA_API HBA_GetEventBuffer(
  237. HBA_HANDLE handle,
  238. PHBA_EVENTINFO EventBuffer,
  239. HBA_UINT32 *EventCount);
  240. HBA_STATUS HBA_API HBA_SetRNIDMgmtInfo(
  241. HBA_HANDLE handle,
  242. HBA_MGMTINFO *pInfo);
  243. HBA_STATUS HBA_API HBA_GetRNIDMgmtInfo(
  244. HBA_HANDLE handle,
  245. HBA_MGMTINFO *pInfo);
  246. HBA_STATUS HBA_API HBA_SendRNID(
  247. HBA_HANDLE handle,
  248. HBA_WWN wwn,
  249. HBA_WWNTYPE wnntype,
  250. void * pRspBuffer,
  251. HBA_UINT32 *RspBufferSize
  252. );
  253. HBA_STATUS HBA_API HBA_GetFcpTargetMapping (
  254. HBA_HANDLE handle,
  255. PHBA_FCPTARGETMAPPING mapping
  256. );
  257. HBA_STATUS HBA_API HBA_GetFcpPersistentBinding (
  258. HBA_HANDLE handle,
  259. PHBA_FCPBINDING binding
  260. );
  261. HBA_STATUS HBA_API HBA_SendScsiInquiry (
  262. HBA_HANDLE handle,
  263. HBA_WWN PortWWN,
  264. HBA_UINT64 fcLUN,
  265. HBA_UINT8 EVPD,
  266. HBA_UINT32 PageCode,
  267. void * pRspBuffer,
  268. HBA_UINT32 RspBufferSize,
  269. void * pSenseBuffer,
  270. HBA_UINT32 SenseBufferSize);
  271. HBA_STATUS HBA_API HBA_SendReportLUNs (
  272. HBA_HANDLE handle,
  273. HBA_WWN portWWN,
  274. void * pRspBuffer,
  275. HBA_UINT32 RspBufferSize,
  276. void * pSenseBuffer,
  277. HBA_UINT32 SenseBufferSize
  278. );
  279. HBA_STATUS HBA_API HBA_SendReadCapacity (
  280. HBA_HANDLE handle,
  281. HBA_WWN portWWN,
  282. HBA_UINT64 fcLUN,
  283. void * pRspBuffer,
  284. HBA_UINT32 RspBufferSize,
  285. void * pSenseBuffer,
  286. HBA_UINT32 SenseBufferSize
  287. );
  288. void HBA_API HBA_RefreshInformation(HBA_HANDLE handle);
  289. void HBA_API HBA_ResetStatistics(HBA_HANDLE handle, HBA_UINT32 portindex);