2 Miscellaneous definitions for iSCSI driver.
4 Copyright (c) 2004 - 2013, 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 typedef struct _ISCSI_SESSION_CONFIG_NVDATA
{
26 EFI_IP_ADDRESS LocalIp
;
27 EFI_IPv4_ADDRESS SubnetMask
;
28 EFI_IP_ADDRESS Gateway
;
30 BOOLEAN InitiatorInfoFromDhcp
;
31 BOOLEAN TargetInfoFromDhcp
;
32 CHAR8 TargetName
[ISCSI_NAME_MAX_SIZE
];
33 EFI_IP_ADDRESS TargetIp
;
37 UINT16 ConnectTimeout
; ///< timout value in milliseconds
38 UINT8 ConnectRetryCount
;
40 } ISCSI_SESSION_CONFIG_NVDATA
;
44 Calculate the prefix length of the IPv4 subnet mask.
46 @param[in] SubnetMask The IPv4 subnet mask.
48 @return The prefix length of the subnet mask.
49 @retval 0 Other errors as indicated.
53 IScsiGetSubnetMaskPrefixLength (
54 IN EFI_IPv4_ADDRESS
*SubnetMask
58 Convert the hexadecimal encoded LUN string into the 64-bit LUN.
60 @param[in] Str The hexadecimal encoded LUN string.
61 @param[out] Lun Storage to return the 64-bit LUN.
63 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
64 @retval EFI_INVALID_PARAMETER The string is malformatted.
74 Convert the 64-bit LUN into the hexadecimal encoded LUN string.
76 @param[in] Lun The 64-bit LUN.
77 @param[out] String The storage to return the hexadecimal encoded LUN string.
81 IScsiLunToUnicodeStr (
87 Convert the mac address into a hexadecimal encoded "-" seperated string.
89 @param[in] Mac The mac address.
90 @param[in] Len Length in bytes of the mac address.
91 @param[in] VlanId VLAN ID of the network device.
92 @param[out] Str The storage to return the mac string.
97 IN EFI_MAC_ADDRESS
*Mac
,
104 Convert the formatted IP address into the binary IP address.
106 @param[in] Str The UNICODE string.
107 @param[in] IpMode Indicates whether the IP address is v4 or v6.
108 @param[out] Ip The storage to return the ASCII string.
110 @retval EFI_SUCCESS The binary IP address is returned in Ip.
111 @retval EFI_INVALID_PARAMETER The IP string is malformatted or IpMode is
119 OUT EFI_IP_ADDRESS
*Ip
123 Convert the binary encoded buffer into a hexadecimal encoded string.
125 @param[in] BinBuffer The buffer containing the binary data.
126 @param[in] BinLength Length of the binary buffer.
127 @param[in, out] HexStr Pointer to the string.
128 @param[in, out] HexLength The length of the string.
130 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string
131 and the length of the string is updated.
132 @retval EFI_BUFFER_TOO_SMALL The string is too small.
133 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
140 IN OUT CHAR8
*HexStr
,
141 IN OUT UINT32
*HexLength
145 Convert the hexadecimal string into a binary encoded buffer.
147 @param[in, out] BinBuffer The binary buffer.
148 @param[in, out] BinLength Length of the binary buffer.
149 @param[in] HexStr The hexadecimal string.
151 @retval EFI_SUCCESS The hexadecimal string is converted into a binary
153 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
158 IN OUT UINT8
*BinBuffer
,
159 IN OUT UINT32
*BinLength
,
165 Convert the decimal-constant string or hex-constant string into a numerical value.
167 @param[in] Str String in decimal or hex.
169 @return The numerical value.
178 Generate random numbers.
180 @param[in, out] Rand The buffer to contain random numbers.
181 @param[in] RandLength The length of the Rand buffer.
191 Record the NIC information in a global structure.
193 @param[in] Controller The handle of the controller.
195 @retval EFI_SUCCESS The operation is completed.
196 @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this
202 IN EFI_HANDLE Controller
206 Delete the recorded NIC information from a global structure. Also delete corresponding
209 @param[in] Controller The handle of the controller.
211 @retval EFI_SUCCESS The operation completed.
212 @retval EFI_NOT_FOUND The NIC information to be deleted is not recorded.
217 IN EFI_HANDLE Controller
221 Get the recorded NIC information from a global structure by the Index.
223 @param[in] NicIndex The index indicates the position of NIC info.
225 @return Pointer to the NIC info or NULL if not found.
229 IScsiGetNicInfoByIndex (
235 Get the NIC's PCI location and return it accroding to the composited
236 format defined in iSCSI Boot Firmware Table.
238 @param[in] Controller The handle of the controller.
239 @param[out] Bus The bus number.
240 @param[out] Device The device number.
241 @param[out] Function The function number.
243 @return The composited representation of the NIC PCI location.
247 IScsiGetNICPciLocation (
248 IN EFI_HANDLE Controller
,
255 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
256 buffer, and the size of the buffer. If failure, return NULL.
258 @param[in] Name String part of EFI variable name.
259 @param[in] VendorGuid GUID part of EFI variable name.
260 @param[out] VariableSize Returns the size of the EFI variable that was read.
262 @return Dynamically allocated memory that contains a copy of the EFI variable.
263 @return Caller is responsible freeing the buffer.
264 @retval NULL Variable was not read.
268 IScsiGetVariableAndSize (
270 IN EFI_GUID
*VendorGuid
,
271 OUT UINTN
*VariableSize
275 Create the iSCSI driver data.
277 @param[in] Image The handle of the driver image.
278 @param[in] Controller The handle of the controller.
280 @return The iSCSI driver data created.
281 @retval NULL Other errors as indicated.
285 IScsiCreateDriverData (
287 IN EFI_HANDLE Controller
291 Clean the iSCSI driver data.
293 @param[in] Private The iSCSI driver data.
297 IScsiCleanDriverData (
298 IN ISCSI_DRIVER_DATA
*Private
302 Check wheather the Controller handle is configured to use DHCP protocol.
304 @param[in] Controller The handle of the controller.
305 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
307 @retval TRUE The handle of the controller need the Dhcp protocol.
308 @retval FALSE The handle of the controller does not need the Dhcp protocol.
312 IScsiDhcpIsConfigured (
313 IN EFI_HANDLE Controller
,
318 Get the various configuration data of this iSCSI instance.
320 @param[in] Private The iSCSI driver data.
322 @retval EFI_SUCCESS Obtained the configuration of this instance.
323 @retval EFI_ABORTED The operation was aborted.
324 @retval Others Other errors as indicated.
329 IN ISCSI_DRIVER_DATA
*Private
333 Get the device path of the iSCSI tcp connection and update it.
335 @param[in] Session The iSCSI session data.
337 @return The updated device path.
338 @retval NULL Other errors as indicated.
341 EFI_DEVICE_PATH_PROTOCOL
*
342 IScsiGetTcpConnDevicePath (
343 IN ISCSI_SESSION
*Session
347 Abort the session when the transition from BS to RT is initiated.
349 @param[in] Event The event signaled.
350 @param[in] Context The iSCSI driver data.
355 IScsiOnExitBootService (