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.

901 lines
21 KiB

  1. //***************************************************************************
  2. //
  3. // method.c
  4. //
  5. // Module: Windows HBA API implmentation
  6. //
  7. // Purpose: Contains routines for doing things
  8. //
  9. // Copyright (c) 2001 Microsoft Corporation
  10. //
  11. //***************************************************************************
  12. #include "hbaapip.h"
  13. HBA_STATUS HBA_GetDiscoveredPortAttributesX(
  14. HBA_HANDLE HbaHandle,
  15. HBA_UINT32 PortIndex,
  16. HBA_UINT32 DiscoveredPortIndex,
  17. HBA_PORTATTRIBUTES *HbaPortAttributes,
  18. BOOLEAN IsAnsi
  19. )
  20. {
  21. HANDLE Handle;
  22. PADAPTER_HANDLE HandleData;
  23. ULONG Status;
  24. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  25. PUCHAR Buffer;
  26. ULONG DataLength;
  27. GetDiscoveredPortAttributes_IN InData;
  28. PGetDiscoveredPortAttributes_OUT OutData;
  29. HandleData = GetDataByHandle(HbaHandle);
  30. if (HandleData != NULL)
  31. {
  32. Status = WmiOpenBlock((LPGUID)&MSFC_HBAPortMethods_GUID,
  33. GENERIC_READ | GENERIC_EXECUTE,
  34. &Handle);
  35. if (Status == ERROR_SUCCESS)
  36. {
  37. DataLength = sizeof(GetDiscoveredPortAttributes_OUT);
  38. Buffer = AllocMemory(DataLength);
  39. if (Buffer != NULL)
  40. {
  41. InData.PortIndex = PortIndex;
  42. InData.DiscoveredPortIndex = DiscoveredPortIndex;
  43. OutData = (PGetDiscoveredPortAttributes_OUT)Buffer;
  44. Status = WmiExecuteMethodW(Handle,
  45. HandleData->InstanceName,
  46. GetDiscoveredPortAttributes,
  47. sizeof(GetDiscoveredPortAttributes_IN),
  48. &InData,
  49. &DataLength,
  50. OutData);
  51. if (Status == ERROR_SUCCESS)
  52. {
  53. //
  54. // Copy port attribs from buffer into
  55. //
  56. //
  57. // Get the HBA status returned from the miniport.
  58. // If the status is HBA_STATUS_OK then the miniport
  59. // has successfully completed the operation and has
  60. // returned results to us. If the status is not
  61. // HBA_STATUS_OK then the miniport is returning an
  62. // HBA api error which we will in turn return to
  63. // the caller. In this case the additional results
  64. // are not valid.
  65. //
  66. HbaStatus = OutData->HBAStatus;
  67. if (HbaStatus == HBA_STATUS_OK)
  68. {
  69. CopyPortAttributes(HbaPortAttributes,
  70. (PUCHAR)&OutData->PortAttributes,
  71. IsAnsi);
  72. }
  73. }
  74. FreeMemory(Buffer);
  75. }
  76. WmiCloseBlock(Handle);
  77. }
  78. }
  79. return(HbaStatus);
  80. }
  81. HBA_STATUS HBA_API HBA_GetDiscoveredPortAttributes(
  82. HBA_HANDLE HbaHandle,
  83. HBA_UINT32 PortIndex,
  84. HBA_UINT32 DiscoveredPortIndex,
  85. HBA_PORTATTRIBUTES *HbaPortAttribute
  86. )
  87. {
  88. return(HBA_GetDiscoveredPortAttributesX(HbaHandle,
  89. PortIndex,
  90. DiscoveredPortIndex,
  91. HbaPortAttribute,
  92. TRUE));
  93. }
  94. HBA_STATUS HBA_GetPortAttributesByWWNX(
  95. HBA_HANDLE HbaHandle,
  96. HBA_WWN PortWWN,
  97. HBA_PORTATTRIBUTES *HbaPortAttributes,
  98. BOOLEAN IsAnsi
  99. )
  100. {
  101. HANDLE Handle;
  102. PADAPTER_HANDLE HandleData;
  103. ULONG Status;
  104. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  105. PUCHAR Buffer;
  106. ULONG DataLength;
  107. PGetPortAttributesByWWN_IN InData;
  108. PGetPortAttributesByWWN_OUT OutData;
  109. HandleData = GetDataByHandle(HbaHandle);
  110. if (HandleData != NULL)
  111. {
  112. Status = WmiOpenBlock((LPGUID)&MSFC_HBAPortMethods_GUID,
  113. GENERIC_READ | GENERIC_EXECUTE,
  114. &Handle);
  115. if (Status == ERROR_SUCCESS)
  116. {
  117. DataLength = sizeof(GetPortAttributesByWWN_OUT);
  118. Buffer = (PUCHAR)AllocMemory(DataLength);
  119. if (Buffer != NULL)
  120. {
  121. InData = (PGetPortAttributesByWWN_IN)&PortWWN;
  122. OutData = (PGetPortAttributesByWWN_OUT)Buffer;
  123. Status = WmiExecuteMethodW(Handle,
  124. HandleData->InstanceName,
  125. GetPortAttributesByWWN,
  126. sizeof(GetPortAttributesByWWN_IN),
  127. InData,
  128. &DataLength,
  129. OutData);
  130. if (Status == ERROR_SUCCESS)
  131. {
  132. //
  133. // Copy port attribs from buffer into
  134. //
  135. //
  136. // Get the HBA status returned from the miniport.
  137. // If the status is HBA_STATUS_OK then the miniport
  138. // has successfully completed the operation and has
  139. // returned results to us. If the status is not
  140. // HBA_STATUS_OK then the miniport is returning an
  141. // HBA api error which we will in turn return to
  142. // the caller. In this case the additional results
  143. // are not valid.
  144. //
  145. HbaStatus = OutData->HBAStatus;
  146. if (HbaStatus == HBA_STATUS_OK)
  147. {
  148. CopyPortAttributes(HbaPortAttributes,
  149. (PUCHAR)&OutData->PortAttributes,
  150. IsAnsi);
  151. }
  152. }
  153. FreeMemory(Buffer);
  154. }
  155. WmiCloseBlock(Handle);
  156. }
  157. }
  158. return(HbaStatus);
  159. }
  160. HBA_STATUS HBA_API HBA_GetPortAttributesByWWN(
  161. HBA_HANDLE HbaHandle,
  162. HBA_WWN PortWWN,
  163. HBA_PORTATTRIBUTES *HbaPortAttributes
  164. )
  165. {
  166. return(HBA_GetPortAttributesByWWNX(HbaHandle,
  167. PortWWN,
  168. HbaPortAttributes,
  169. TRUE));
  170. }
  171. HBA_STATUS HBA_API HBA_SendCTPassThru(
  172. HBA_HANDLE HbaHandle,
  173. void * pReqBuffer,
  174. HBA_UINT32 ReqBufferSize,
  175. void * pRspBuffer,
  176. HBA_UINT32 RspBufferSize
  177. )
  178. {
  179. HANDLE Handle;
  180. PADAPTER_HANDLE HandleData;
  181. ULONG Status;
  182. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  183. PUCHAR Buffer;
  184. ULONG DataLength, InDataLength, OutDataLength;
  185. PSendCTPassThru_OUT OutData;
  186. PSendCTPassThru_IN InData;
  187. HandleData = GetDataByHandle(HbaHandle);
  188. if (HandleData != NULL)
  189. {
  190. Status = WmiOpenBlock((LPGUID)&MSFC_HBAFc3MgmtMethods_GUID,
  191. GENERIC_READ | GENERIC_EXECUTE,
  192. &Handle);
  193. if (Status == ERROR_SUCCESS)
  194. {
  195. if (ReqBufferSize > RspBufferSize)
  196. {
  197. DataLength = ReqBufferSize;
  198. } else {
  199. DataLength = RspBufferSize;
  200. }
  201. DataLength += sizeof(SendCTPassThru_OUT);
  202. Buffer = AllocMemory(DataLength);
  203. if (Buffer != NULL)
  204. {
  205. InData = (PSendCTPassThru_IN)Buffer;
  206. OutData = (PSendCTPassThru_OUT)Buffer;
  207. InDataLength = sizeof(SendCTPassThru_IN) + ReqBufferSize - 1;
  208. InData->RequestBufferCount = ReqBufferSize;
  209. memcpy(InData->RequestBuffer,
  210. pReqBuffer,
  211. ReqBufferSize);
  212. OutDataLength = sizeof(SendCTPassThru_OUT) + RspBufferSize - 1;
  213. Status = WmiExecuteMethodW(Handle,
  214. HandleData->InstanceName,
  215. SendCTPassThru,
  216. InDataLength,
  217. InData,
  218. &OutDataLength,
  219. OutData);
  220. if (Status == ERROR_SUCCESS)
  221. {
  222. if (OutData->ResponseBufferCount <= RspBufferSize)
  223. {
  224. RspBufferSize = OutData->ResponseBufferCount;
  225. } else {
  226. DebugPrint(("HBAAPI: Response size from SendCTPass is %d and is larger than %d\n",
  227. OutData->ResponseBufferCount,
  228. RspBufferSize));
  229. }
  230. //
  231. // Get the HBA status returned from the miniport.
  232. // If the status is HBA_STATUS_OK then the miniport
  233. // has successfully completed the operation and has
  234. // returned results to us. If the status is not
  235. // HBA_STATUS_OK then the miniport is returning an
  236. // HBA api error which we will in turn return to
  237. // the caller. In this case the additional results
  238. // are not valid.
  239. //
  240. HbaStatus = OutData->HBAStatus;
  241. if ((HbaStatus == HBA_STATUS_OK) ||
  242. (HbaStatus == HBA_STATUS_ERROR_MORE_DATA))
  243. {
  244. memcpy(pRspBuffer,
  245. OutData->ResponseBuffer,
  246. RspBufferSize);
  247. }
  248. }
  249. FreeMemory(Buffer);
  250. }
  251. WmiCloseBlock(Handle);
  252. }
  253. }
  254. return(HbaStatus);
  255. }
  256. HBA_STATUS HBA_API HBA_SendRNID(
  257. HBA_HANDLE HbaHandle,
  258. HBA_WWN wwn,
  259. HBA_WWNTYPE wwntype,
  260. void * pRspBuffer,
  261. HBA_UINT32 *RspBufferSize
  262. )
  263. {
  264. HANDLE Handle;
  265. PADAPTER_HANDLE HandleData;
  266. ULONG Status;
  267. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  268. PUCHAR Buffer;
  269. ULONG DataLength;
  270. SendRNID_IN InData;
  271. PSendRNID_OUT OutData;
  272. HandleData = GetDataByHandle(HbaHandle);
  273. if (HandleData != NULL)
  274. {
  275. Status = WmiOpenBlock((LPGUID)&MSFC_HBAFc3MgmtMethods_GUID,
  276. GENERIC_READ | GENERIC_EXECUTE,
  277. &Handle);
  278. if (Status == ERROR_SUCCESS)
  279. {
  280. DataLength = sizeof(SendRNID_OUT) -1 + *RspBufferSize;
  281. Buffer = AllocMemory(DataLength);
  282. if (Buffer != NULL)
  283. {
  284. memcpy(InData.wwn,
  285. &wwn.wwn,
  286. sizeof(HBA_WWN));
  287. InData.wwntype = (ULONG)wwntype;
  288. OutData = (PSendRNID_OUT)Buffer;
  289. Status = WmiExecuteMethodW(Handle,
  290. HandleData->InstanceName,
  291. SendRNID,
  292. sizeof(SendRNID_IN),
  293. &InData,
  294. &DataLength,
  295. OutData);
  296. if (Status == ERROR_SUCCESS)
  297. {
  298. //
  299. // Get the HBA status returned from the miniport.
  300. // If the status is HBA_STATUS_OK then the miniport
  301. // has successfully completed the operation and has
  302. // returned results to us. If the status is not
  303. // HBA_STATUS_OK then the miniport is returning an
  304. // HBA api error which we will in turn return to
  305. // the caller. In this case the additional results
  306. // are not valid.
  307. //
  308. HbaStatus = OutData->HBAStatus;
  309. if ((HbaStatus == HBA_STATUS_OK) ||
  310. (HbaStatus == HBA_STATUS_ERROR_MORE_DATA))
  311. {
  312. if (OutData->ResponseBufferCount <= *RspBufferSize)
  313. {
  314. *RspBufferSize = OutData->ResponseBufferCount;
  315. } else {
  316. DebugPrint(("HBAAPI: Response size from SendRNID is %d and is larger than %d\n",
  317. OutData->ResponseBufferCount,
  318. *RspBufferSize));
  319. }
  320. memcpy(pRspBuffer,
  321. OutData->ResponseBuffer,
  322. *RspBufferSize);
  323. }
  324. }
  325. FreeMemory(Buffer);
  326. }
  327. WmiCloseBlock(Handle);
  328. }
  329. }
  330. return(HbaStatus);
  331. }
  332. _inline void CopyScsiId(
  333. PHBA_SCSIID HbaScsiId,
  334. PHBAScsiID WmiScsiId,
  335. BOOLEAN IsAnsi
  336. )
  337. {
  338. PUCHAR p;
  339. p = (PUCHAR)WmiScsiId->OSDeviceName;
  340. CopyString(HbaScsiId->OSDeviceName,
  341. &p,
  342. 256,
  343. IsAnsi);
  344. HbaScsiId->ScsiBusNumber = WmiScsiId->ScsiBusNumber;
  345. HbaScsiId->ScsiTargetNumber = WmiScsiId->ScsiTargetNumber;
  346. HbaScsiId->ScsiOSLun = WmiScsiId->ScsiOSLun;
  347. }
  348. _inline void CopyFcpId(
  349. PHBA_FCPID HbaFcpId,
  350. PHBAFCPID WmiFcpId
  351. )
  352. {
  353. HbaFcpId->FcId = WmiFcpId->Fcid;
  354. HbaFcpId->FcpLun = WmiFcpId->FcpLun;
  355. memcpy(&HbaFcpId->NodeWWN,
  356. &WmiFcpId->NodeWWN,
  357. sizeof(HBA_WWN));
  358. memcpy(&HbaFcpId->PortWWN,
  359. &WmiFcpId->PortWWN,
  360. sizeof(HBA_WWN));
  361. }
  362. HBA_STATUS HBA_GetFcpTargetMappingX (
  363. HBA_HANDLE HbaHandle,
  364. PHBA_FCPTARGETMAPPING Mapping,
  365. BOOLEAN IsAnsi
  366. )
  367. {
  368. HANDLE Handle;
  369. PADAPTER_HANDLE HandleData;
  370. ULONG Status;
  371. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  372. ULONG DataLength;
  373. PGetFcpTargetMapping_OUT OutData;
  374. ULONG MapCount, ActualCount, i;
  375. PHBA_FCPSCSIENTRY MapEntry;
  376. PHBAFCPScsiEntry OutEntry;
  377. HandleData = GetDataByHandle(HbaHandle);
  378. if (HandleData != NULL)
  379. {
  380. Status = WmiOpenBlock((LPGUID)&(MSFC_HBAFCPInfo_GUID),
  381. GENERIC_READ | GENERIC_EXECUTE,
  382. &Handle);
  383. if (Status == ERROR_SUCCESS)
  384. {
  385. Status = ExecuteMethod(Handle,
  386. HandleData->InstanceName,
  387. GetFcpTargetMapping,
  388. 0,
  389. NULL,
  390. &DataLength,
  391. (PUCHAR *)&OutData);
  392. if (Status == ERROR_SUCCESS)
  393. {
  394. //
  395. // Get the HBA status returned from the miniport.
  396. // If the status is HBA_STATUS_OK then the miniport
  397. // has successfully completed the operation and has
  398. // returned results to us. If the status is not
  399. // HBA_STATUS_OK then the miniport is returning an
  400. // HBA api error which we will in turn return to
  401. // the caller. In this case the additional results
  402. // are not valid.
  403. //
  404. HbaStatus = OutData->HBAStatus;
  405. if (HbaStatus == HBA_STATUS_OK)
  406. {
  407. MapCount = Mapping->NumberOfEntries;
  408. ActualCount = OutData->EntryCount;
  409. Mapping->NumberOfEntries = ActualCount;
  410. if (MapCount > ActualCount)
  411. {
  412. MapCount = ActualCount;
  413. HbaStatus = HBA_STATUS_ERROR_MORE_DATA;
  414. }
  415. for (i = 0; i < MapCount; i++)
  416. {
  417. MapEntry = &Mapping->entry[i];
  418. OutEntry = &OutData->Entry[i];
  419. CopyScsiId(&MapEntry->ScsiId,
  420. &OutEntry->ScsiId,
  421. IsAnsi);
  422. CopyFcpId(&MapEntry->FcpId,
  423. &OutEntry->FCPId);
  424. }
  425. }
  426. FreeMemory(OutData);
  427. }
  428. WmiCloseBlock(Handle);
  429. }
  430. }
  431. return(HbaStatus);
  432. }
  433. HBA_STATUS HBA_API HBA_GetFcpTargetMapping (
  434. HBA_HANDLE HbaHandle,
  435. PHBA_FCPTARGETMAPPING Mapping
  436. )
  437. {
  438. return(HBA_GetFcpTargetMappingX(HbaHandle,
  439. Mapping,
  440. TRUE));
  441. }
  442. HBA_STATUS HBA_GetFcpPersistentBindingX (
  443. HBA_HANDLE HbaHandle,
  444. PHBA_FCPBINDING binding,
  445. BOOLEAN IsAnsi
  446. )
  447. {
  448. HANDLE Handle;
  449. PADAPTER_HANDLE HandleData;
  450. ULONG Status;
  451. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  452. ULONG DataLength;
  453. PGetFcpPersistentBinding_OUT OutData;
  454. ULONG MapCount, ActualCount, i;
  455. PHBA_FCPBINDINGENTRY MapEntry;
  456. PHBAFCPBindingEntry OutEntry;
  457. HandleData = GetDataByHandle(HbaHandle);
  458. if (HandleData != NULL)
  459. {
  460. Status = WmiOpenBlock((LPGUID)&MSFC_HBAFCPInfo_GUID,
  461. GENERIC_READ | GENERIC_EXECUTE,
  462. &Handle);
  463. if (Status == ERROR_SUCCESS)
  464. {
  465. Status = ExecuteMethod(Handle,
  466. HandleData->InstanceName,
  467. GetFcpTargetMapping,
  468. 0,
  469. NULL,
  470. &DataLength,
  471. (PUCHAR *)&OutData);
  472. if (Status == ERROR_SUCCESS)
  473. {
  474. //
  475. // Get the HBA status returned from the miniport.
  476. // If the status is HBA_STATUS_OK then the miniport
  477. // has successfully completed the operation and has
  478. // returned results to us. If the status is not
  479. // HBA_STATUS_OK then the miniport is returning an
  480. // HBA api error which we will in turn return to
  481. // the caller. In this case the additional results
  482. // are not valid.
  483. //
  484. HbaStatus = OutData->HBAStatus;
  485. if (HbaStatus == HBA_STATUS_OK)
  486. {
  487. MapCount = binding->NumberOfEntries;
  488. ActualCount = OutData->EntryCount;
  489. binding->NumberOfEntries = ActualCount;
  490. if (MapCount > ActualCount)
  491. {
  492. MapCount = ActualCount;
  493. HbaStatus = HBA_STATUS_ERROR_MORE_DATA;
  494. }
  495. for (i = 0; i < MapCount; i++)
  496. {
  497. MapEntry = &binding->entry[i];
  498. OutEntry = &OutData->Entry[i];
  499. MapEntry->type = OutEntry->Type;
  500. CopyScsiId(&MapEntry->ScsiId,
  501. &OutEntry->ScsiId,
  502. IsAnsi);
  503. CopyFcpId(&MapEntry->FcpId,
  504. &OutEntry->FCPId);
  505. }
  506. }
  507. FreeMemory(OutData);
  508. }
  509. WmiCloseBlock(Handle);
  510. }
  511. }
  512. return(HbaStatus);
  513. }
  514. HBA_STATUS HBA_API HBA_GetFcpPersistentBinding (
  515. HBA_HANDLE handle,
  516. PHBA_FCPBINDING binding
  517. )
  518. {
  519. return(HBA_GetFcpPersistentBindingX(handle,
  520. binding,
  521. TRUE));
  522. }
  523. void HBA_API HBA_ResetStatistics(
  524. HBA_HANDLE HbaHandle,
  525. HBA_UINT32 PortIndex
  526. )
  527. {
  528. HANDLE Handle;
  529. PADAPTER_HANDLE HandleData;
  530. ULONG Status;
  531. PWCHAR InstanceName;
  532. ULONG DataLength;
  533. HandleData = GetDataByHandle(HbaHandle);
  534. if (HandleData != NULL)
  535. {
  536. Status = WmiOpenBlock((LPGUID)&MSFC_FibrePortHBAMethods_GUID,
  537. GENERIC_READ | GENERIC_EXECUTE,
  538. &Handle);
  539. if (Status == ERROR_SUCCESS)
  540. {
  541. InstanceName = CreatePortInstanceNameW(HandleData->InstanceName,
  542. PortIndex);
  543. if (InstanceName != NULL)
  544. {
  545. DataLength = 0;
  546. Status = WmiExecuteMethodW(Handle,
  547. InstanceName,
  548. ResetStatistics,
  549. 0,
  550. NULL,
  551. &DataLength,
  552. NULL);
  553. #if DBG
  554. if (Status != ERROR_SUCCESS)
  555. {
  556. DebugPrint(("HBAAPI: ResetStatistics method failed %d\n",
  557. Status));
  558. }
  559. #endif
  560. FreeMemory(InstanceName);
  561. }
  562. WmiCloseBlock(Handle);
  563. }
  564. }
  565. }
  566. HBA_STATUS HBA_API HBA_SetRNIDMgmtInfo(
  567. HBA_HANDLE HbaHandle,
  568. HBA_MGMTINFO *HbaMgmtInfo
  569. )
  570. {
  571. HANDLE Handle;
  572. PADAPTER_HANDLE HandleData;
  573. ULONG Status;
  574. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  575. ULONG DataLength;
  576. SetFC3MgmtInfo_IN InData;
  577. SetFC3MgmtInfo_OUT OutData;
  578. HandleData = GetDataByHandle(HbaHandle);
  579. if (HandleData != NULL)
  580. {
  581. Status = WmiOpenBlock((LPGUID)&MSFC_HBAFc3MgmtMethods_GUID,
  582. GENERIC_EXECUTE,
  583. &Handle);
  584. if (Status == ERROR_SUCCESS)
  585. {
  586. //
  587. // We have got our Management info, so copy them
  588. // over to the input buffer
  589. //
  590. memcpy(InData.MgmtInfo.wwn,
  591. &HbaMgmtInfo->wwn,
  592. sizeof(HBA_WWN));
  593. InData.MgmtInfo.unittype = HbaMgmtInfo->unittype;
  594. InData.MgmtInfo.PortId = HbaMgmtInfo->PortId;
  595. InData.MgmtInfo.NumberOfAttachedNodes = HbaMgmtInfo->NumberOfAttachedNodes;
  596. InData.MgmtInfo.IPVersion = HbaMgmtInfo->IPVersion;
  597. InData.MgmtInfo.UDPPort = HbaMgmtInfo->UDPPort;
  598. memcpy(InData.MgmtInfo.IPAddress,
  599. HbaMgmtInfo->IPAddress,
  600. 16);
  601. InData.MgmtInfo.reserved = HbaMgmtInfo->reserved;
  602. InData.MgmtInfo.TopologyDiscoveryFlags = HbaMgmtInfo->TopologyDiscoveryFlags;
  603. DataLength = sizeof(SetFC3MgmtInfo_OUT);
  604. Status = WmiExecuteMethodW(Handle,
  605. HandleData->InstanceName,
  606. SetFC3MgmtInfo,
  607. sizeof(SetFC3MgmtInfo_IN),
  608. &InData,
  609. &DataLength,
  610. &OutData);
  611. if (Status == ERROR_SUCCESS)
  612. {
  613. //
  614. // Get the HBA status returned from the miniport.
  615. // If the miniport returns HBA_STATUS_OK then all
  616. // data is filled in the data block. If any other
  617. // HBA status is returned then the miniport is
  618. // reporting an error and we want to return that
  619. // HBA error code to the caller
  620. //
  621. HbaStatus = OutData.HBAStatus;
  622. }
  623. WmiCloseBlock(Handle);
  624. }
  625. } else {
  626. HbaStatus = HBA_STATUS_ERROR_INVALID_HANDLE;
  627. }
  628. return(HbaStatus);
  629. }
  630. HBA_STATUS HBA_API HBA_GetRNIDMgmtInfo(
  631. HBA_HANDLE HbaHandle,
  632. HBA_MGMTINFO *HbaMgmtInfo
  633. )
  634. {
  635. HANDLE Handle;
  636. PADAPTER_HANDLE HandleData;
  637. ULONG Status;
  638. HBA_STATUS HbaStatus = HBA_STATUS_ERROR;
  639. ULONG DataLength;
  640. GetFC3MgmtInfo_OUT OutData;
  641. HandleData = GetDataByHandle(HbaHandle);
  642. if (HandleData != NULL)
  643. {
  644. Status = WmiOpenBlock((LPGUID)&MSFC_HBAFc3MgmtMethods_GUID,
  645. GENERIC_EXECUTE,
  646. &Handle);
  647. if (Status == ERROR_SUCCESS)
  648. {
  649. DataLength = sizeof(GetFC3MgmtInfo_OUT);
  650. Status = WmiExecuteMethodW(Handle,
  651. HandleData->InstanceName,
  652. GetFC3MgmtInfo,
  653. 0,
  654. NULL,
  655. &DataLength,
  656. &OutData);
  657. if (Status == ERROR_SUCCESS)
  658. {
  659. //
  660. // Get the HBA status returned from the miniport.
  661. // If the miniport returns HBA_STATUS_OK then all
  662. // data is filled in the data block. If any other
  663. // HBA status is returned then the miniport is
  664. // reporting an error and we want to return that
  665. // HBA error code to the caller
  666. //
  667. HbaStatus = OutData.HBAStatus;
  668. if (HbaStatus == HBA_STATUS_OK)
  669. {
  670. //
  671. // We have got our Management info, so copy them
  672. // over to the output buffer
  673. //
  674. memcpy(&HbaMgmtInfo->wwn,
  675. OutData.MgmtInfo.wwn,
  676. sizeof(HBA_WWN));
  677. HbaMgmtInfo->unittype = OutData.MgmtInfo.unittype;
  678. HbaMgmtInfo->PortId = OutData.MgmtInfo.PortId;
  679. HbaMgmtInfo->NumberOfAttachedNodes = OutData.MgmtInfo.NumberOfAttachedNodes;
  680. HbaMgmtInfo->IPVersion = OutData.MgmtInfo.IPVersion;
  681. HbaMgmtInfo->UDPPort = OutData.MgmtInfo.UDPPort;
  682. memcpy(HbaMgmtInfo->IPAddress,
  683. OutData.MgmtInfo.IPAddress,
  684. 16);
  685. HbaMgmtInfo->reserved = OutData.MgmtInfo.reserved;
  686. HbaMgmtInfo->TopologyDiscoveryFlags = OutData.MgmtInfo.TopologyDiscoveryFlags;
  687. }
  688. }
  689. WmiCloseBlock(Handle);
  690. }
  691. } else {
  692. HbaStatus = HBA_STATUS_ERROR_INVALID_HANDLE;
  693. }
  694. return(HbaStatus);
  695. }
  696. void HBA_API HBA_RefreshInformation(
  697. HBA_HANDLE HbaHandle
  698. )
  699. {
  700. HANDLE Handle;
  701. PADAPTER_HANDLE HandleData;
  702. ULONG Status;
  703. ULONG DataLength;
  704. HandleData = GetDataByHandle(HbaHandle);
  705. if (HandleData != NULL)
  706. {
  707. Status = WmiOpenBlock((LPGUID)&MSFC_HBAPortMethods_GUID,
  708. GENERIC_READ | GENERIC_EXECUTE,
  709. &Handle);
  710. if (Status == ERROR_SUCCESS)
  711. {
  712. DataLength = 0;
  713. Status = WmiExecuteMethodW(Handle,
  714. HandleData->InstanceName,
  715. RefreshInformation,
  716. 0,
  717. NULL,
  718. &DataLength,
  719. NULL);
  720. #if DBG
  721. if (Status != ERROR_SUCCESS)
  722. {
  723. DebugPrint(("HBAAPI: RefreshInformation method failed %d\n",
  724. Status));
  725. }
  726. #endif
  727. WmiCloseBlock(Handle);
  728. }
  729. }
  730. }
  731. //
  732. // Not implemented yet
  733. //
  734. HBA_STATUS HBA_API HBA_GetEventBuffer(
  735. HBA_HANDLE handle,
  736. PHBA_EVENTINFO EventBuffer,
  737. HBA_UINT32 *EventCount
  738. )
  739. {
  740. return(HBA_STATUS_ERROR_NOT_SUPPORTED);
  741. }
  742. //
  743. // SCSI apis are not supported by design
  744. //
  745. HBA_STATUS HBA_API HBA_SendScsiInquiry (
  746. HBA_HANDLE handle,
  747. HBA_WWN PortWWN,
  748. HBA_UINT64 fcLUN,
  749. HBA_UINT8 EVPD,
  750. HBA_UINT32 PageCode,
  751. void * pRspBuffer,
  752. HBA_UINT32 RspBufferSize,
  753. void * pSenseBuffer,
  754. HBA_UINT32 SenseBufferSize)
  755. {
  756. return(HBA_STATUS_ERROR_NOT_SUPPORTED);
  757. }
  758. HBA_STATUS HBA_API HBA_SendReportLUNs (
  759. HBA_HANDLE handle,
  760. HBA_WWN portWWN,
  761. void * pRspBuffer,
  762. HBA_UINT32 RspBufferSize,
  763. void * pSenseBuffer,
  764. HBA_UINT32 SenseBufferSize
  765. )
  766. {
  767. return(HBA_STATUS_ERROR_NOT_SUPPORTED);
  768. }
  769. HBA_STATUS HBA_API HBA_SendReadCapacity (
  770. HBA_HANDLE handle,
  771. HBA_WWN portWWN,
  772. HBA_UINT64 fcLUN,
  773. void * pRspBuffer,
  774. HBA_UINT32 RspBufferSize,
  775. void * pSenseBuffer,
  776. HBA_UINT32 SenseBufferSize
  777. )
  778. {
  779. return(HBA_STATUS_ERROR_NOT_SUPPORTED);
  780. }