2 Miscellaneous definitions for iSCSI driver.
4 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _ISCSI_MISC_H_
16 #define _ISCSI_MISC_H_
18 typedef struct _ISCSI_DRIVER_DATA ISCSI_DRIVER_DATA
;
21 /// IPv4 Device Path Node Length
23 #define IP4_NODE_LEN_NEW_VERSIONS 27
26 /// IPv6 Device Path Node Length
28 #define IP6_NODE_LEN_OLD_VERSIONS 43
29 #define IP6_NODE_LEN_NEW_VERSIONS 60
32 /// The ignored field StaticIpAddress's offset in old IPv6 Device Path
34 #define IP6_OLD_IPADDRESS_OFFSET 42
37 typedef struct _ISCSI_SESSION_CONFIG_NVDATA
{
42 EFI_IP_ADDRESS LocalIp
;
43 EFI_IPv4_ADDRESS SubnetMask
;
44 EFI_IP_ADDRESS Gateway
;
46 BOOLEAN InitiatorInfoFromDhcp
;
47 BOOLEAN TargetInfoFromDhcp
;
48 CHAR8 TargetName
[ISCSI_NAME_MAX_SIZE
];
49 EFI_IP_ADDRESS TargetIp
;
53 UINT16 ConnectTimeout
; ///< timout value in milliseconds
54 UINT8 ConnectRetryCount
;
56 } ISCSI_SESSION_CONFIG_NVDATA
;
60 Calculate the prefix length of the IPv4 subnet mask.
62 @param[in] SubnetMask The IPv4 subnet mask.
64 @return The prefix length of the subnet mask.
65 @retval 0 Other errors as indicated.
69 IScsiGetSubnetMaskPrefixLength (
70 IN EFI_IPv4_ADDRESS
*SubnetMask
74 Convert the hexadecimal encoded LUN string into the 64-bit LUN.
76 @param[in] Str The hexadecimal encoded LUN string.
77 @param[out] Lun Storage to return the 64-bit LUN.
79 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
80 @retval EFI_INVALID_PARAMETER The string is malformatted.
90 Convert the 64-bit LUN into the hexadecimal encoded LUN string.
92 @param[in] Lun The 64-bit LUN.
93 @param[out] String The storage to return the hexadecimal encoded LUN string.
97 IScsiLunToUnicodeStr (
103 Convert the mac address into a hexadecimal encoded "-" seperated string.
105 @param[in] Mac The mac address.
106 @param[in] Len Length in bytes of the mac address.
107 @param[in] VlanId VLAN ID of the network device.
108 @param[out] Str The storage to return the mac string.
113 IN EFI_MAC_ADDRESS
*Mac
,
120 Convert the formatted IP address into the binary IP address.
122 @param[in] Str The UNICODE string.
123 @param[in] IpMode Indicates whether the IP address is v4 or v6.
124 @param[out] Ip The storage to return the ASCII string.
126 @retval EFI_SUCCESS The binary IP address is returned in Ip.
127 @retval EFI_INVALID_PARAMETER The IP string is malformatted or IpMode is
135 OUT EFI_IP_ADDRESS
*Ip
139 Convert the binary encoded buffer into a hexadecimal encoded string.
141 @param[in] BinBuffer The buffer containing the binary data.
142 @param[in] BinLength Length of the binary buffer.
143 @param[in, out] HexStr Pointer to the string.
144 @param[in, out] HexLength The length of the string.
146 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string
147 and the length of the string is updated.
148 @retval EFI_BUFFER_TOO_SMALL The string is too small.
149 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
156 IN OUT CHAR8
*HexStr
,
157 IN OUT UINT32
*HexLength
161 Convert the hexadecimal string into a binary encoded buffer.
163 @param[in, out] BinBuffer The binary buffer.
164 @param[in, out] BinLength Length of the binary buffer.
165 @param[in] HexStr The hexadecimal string.
167 @retval EFI_SUCCESS The hexadecimal string is converted into a binary
169 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
174 IN OUT UINT8
*BinBuffer
,
175 IN OUT UINT32
*BinLength
,
181 Convert the decimal-constant string or hex-constant string into a numerical value.
183 @param[in] Str String in decimal or hex.
185 @return The numerical value.
194 Generate random numbers.
196 @param[in, out] Rand The buffer to contain random numbers.
197 @param[in] RandLength The length of the Rand buffer.
207 Record the NIC information in a global structure.
209 @param[in] Controller The handle of the controller.
211 @retval EFI_SUCCESS The operation is completed.
212 @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this
218 IN EFI_HANDLE Controller
222 Delete the recorded NIC information from a global structure. Also delete corresponding
225 @param[in] Controller The handle of the controller.
227 @retval EFI_SUCCESS The operation completed.
228 @retval EFI_NOT_FOUND The NIC information to be deleted is not recorded.
233 IN EFI_HANDLE Controller
237 Get the recorded NIC information from a global structure by the Index.
239 @param[in] NicIndex The index indicates the position of NIC info.
241 @return Pointer to the NIC info or NULL if not found.
245 IScsiGetNicInfoByIndex (
251 Get the NIC's PCI location and return it according to the composited
252 format defined in iSCSI Boot Firmware Table.
254 @param[in] Controller The handle of the controller.
255 @param[out] Bus The bus number.
256 @param[out] Device The device number.
257 @param[out] Function The function number.
259 @return The composited representation of the NIC PCI location.
263 IScsiGetNICPciLocation (
264 IN EFI_HANDLE Controller
,
271 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
272 buffer, and the size of the buffer. If failure, return NULL.
274 @param[in] Name String part of EFI variable name.
275 @param[in] VendorGuid GUID part of EFI variable name.
276 @param[out] VariableSize Returns the size of the EFI variable that was read.
278 @return Dynamically allocated memory that contains a copy of the EFI variable.
279 @return Caller is responsible freeing the buffer.
280 @retval NULL Variable was not read.
284 IScsiGetVariableAndSize (
286 IN EFI_GUID
*VendorGuid
,
287 OUT UINTN
*VariableSize
291 Create the iSCSI driver data.
293 @param[in] Image The handle of the driver image.
294 @param[in] Controller The handle of the controller.
296 @return The iSCSI driver data created.
297 @retval NULL Other errors as indicated.
301 IScsiCreateDriverData (
303 IN EFI_HANDLE Controller
307 Clean the iSCSI driver data.
309 @param[in] Private The iSCSI driver data.
311 @retval EFI_SUCCES The clean operation is successful.
312 @retval Others Other errors as indicated.
316 IScsiCleanDriverData (
317 IN ISCSI_DRIVER_DATA
*Private
321 Check wheather the Controller handle is configured to use DHCP protocol.
323 @param[in] Controller The handle of the controller.
324 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
326 @retval TRUE The handle of the controller need the Dhcp protocol.
327 @retval FALSE The handle of the controller does not need the Dhcp protocol.
331 IScsiDhcpIsConfigured (
332 IN EFI_HANDLE Controller
,
337 Get the various configuration data of this iSCSI instance.
339 @param[in] Private The iSCSI driver data.
341 @retval EFI_SUCCESS Obtained the configuration of this instance.
342 @retval EFI_ABORTED The operation was aborted.
343 @retval Others Other errors as indicated.
348 IN ISCSI_DRIVER_DATA
*Private
352 Get the device path of the iSCSI tcp connection and update it.
354 @param[in] Session The iSCSI session data.
356 @return The updated device path.
357 @retval NULL Other errors as indicated.
360 EFI_DEVICE_PATH_PROTOCOL
*
361 IScsiGetTcpConnDevicePath (
362 IN ISCSI_SESSION
*Session
366 Abort the session when the transition from BS to RT is initiated.
368 @param[in] Event The event signaled.
369 @param[in] Context The iSCSI driver data.
374 IScsiOnExitBootService (
380 Tests whether a controller handle is being managed by IScsi driver.
382 This function tests whether the driver specified by DriverBindingHandle is
383 currently managing the controller specified by ControllerHandle. This test
384 is performed by evaluating if the the protocol specified by ProtocolGuid is
385 present on ControllerHandle and is was opened by DriverBindingHandle and Nic
386 Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
387 If ProtocolGuid is NULL, then ASSERT().
389 @param ControllerHandle A handle for a controller to test.
390 @param DriverBindingHandle Specifies the driver binding handle for the
392 @param ProtocolGuid Specifies the protocol that the driver specified
393 by DriverBindingHandle opens in its Start()
396 @retval EFI_SUCCESS ControllerHandle is managed by the driver
397 specified by DriverBindingHandle.
398 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
399 specified by DriverBindingHandle.
404 IScsiTestManagedDevice (
405 IN EFI_HANDLE ControllerHandle
,
406 IN EFI_HANDLE DriverBindingHandle
,
407 IN EFI_GUID
*ProtocolGuid