2 Miscellaneous definitions for iSCSI driver.
4 Copyright (c) 2004 - 2011, 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_IPv4_ADDRESS LocalIp
;
27 EFI_IPv4_ADDRESS SubnetMask
;
28 EFI_IPv4_ADDRESS Gateway
;
30 BOOLEAN InitiatorInfoFromDhcp
;
31 BOOLEAN TargetInfoFromDhcp
;
32 CHAR8 TargetName
[ISCSI_NAME_MAX_SIZE
];
33 EFI_IP_ADDRESS TargetIp
;
36 UINT16 ConnectTimeout
; ///< timout value in milliseconds
37 UINT8 ConnectRetryCount
;
39 } ISCSI_SESSION_CONFIG_NVDATA
;
43 Calculate the prefix length of the IPv4 subnet mask.
45 @param[in] SubnetMask The IPv4 subnet mask.
47 @return The prefix length of the subnet mask.
48 @retval 0 Other errors as indicated.
52 IScsiGetSubnetMaskPrefixLength (
53 IN EFI_IPv4_ADDRESS
*SubnetMask
57 Convert the hexadecimal encoded LUN string into the 64-bit LUN.
59 @param[in] Str The hexadecimal encoded LUN string.
60 @param[out] Lun Storage to return the 64-bit LUN.
62 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
63 @retval EFI_INVALID_PARAMETER The string is malformatted.
73 Convert the 64-bit LUN into the hexadecimal encoded LUN string.
75 @param[in] Lun The 64-bit LUN.
76 @param[out] String The storage to return the hexadecimal encoded LUN string.
80 IScsiLunToUnicodeStr (
86 Convert the mac address into a hexadecimal encoded "-" seperated string.
88 @param[in] Mac The mac address.
89 @param[in] Len Length in bytes of the mac address.
90 @param[in] VlanId VLAN ID of the network device.
91 @param[out] Str The storage to return the mac string.
96 IN EFI_MAC_ADDRESS
*Mac
,
103 Convert the formatted IP address into the binary IP address.
105 @param[in] Str The UNICODE string.
106 @param[in] IpMode Indicates whether the IP address is v4 or v6.
107 @param[out] Ip The storage to return the ASCII string.
109 @retval EFI_SUCCESS The binary IP address is returned in Ip.
110 @retval EFI_INVALID_PARAMETER The IP string is malformatted or IpMode is
118 OUT EFI_IP_ADDRESS
*Ip
122 Convert the binary encoded buffer into a hexadecimal encoded string.
124 @param[in] BinBuffer The buffer containing the binary data.
125 @param[in] BinLength Length of the binary buffer.
126 @param[in, out] HexStr Pointer to the string.
127 @param[in, out] HexLength The length of the string.
129 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string
130 and the length of the string is updated.
131 @retval EFI_BUFFER_TOO_SMALL The string is too small.
132 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
139 IN OUT CHAR8
*HexStr
,
140 IN OUT UINT32
*HexLength
144 Convert the hexadecimal string into a binary encoded buffer.
146 @param[in, out] BinBuffer The binary buffer.
147 @param[in, out] BinLength Length of the binary buffer.
148 @param[in] HexStr The hexadecimal string.
150 @retval EFI_SUCCESS The hexadecimal string is converted into a binary
152 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
157 IN OUT UINT8
*BinBuffer
,
158 IN OUT UINT32
*BinLength
,
164 Convert the decimal-constant string or hex-constant string into a numerical value.
166 @param[in] Str String in decimal or hex.
168 @return The numerical value.
177 Generate random numbers.
179 @param[in, out] Rand The buffer to contain random numbers.
180 @param[in] RandLength The length of the Rand buffer.
190 Record the NIC information in a global structure.
192 @param[in] Controller The handle of the controller.
194 @retval EFI_SUCCESS The operation is completed.
195 @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this
201 IN EFI_HANDLE Controller
205 Delete the recorded NIC information from a global structure. Also delete corresponding
208 @param[in] Controller The handle of the controller.
210 @retval EFI_SUCCESS The operation completed.
211 @retval EFI_NOT_FOUND The NIC information to be deleted is not recorded.
216 IN EFI_HANDLE Controller
220 Get the recorded NIC information from a global structure by the Index.
222 @param[in] NicIndex The index indicates the position of NIC info.
224 @return Pointer to the NIC info or NULL if not found.
228 IScsiGetNicInfoByIndex (
234 Get the NIC's PCI location and return it accroding to the composited
235 format defined in iSCSI Boot Firmware Table.
237 @param[in] Controller The handle of the controller.
238 @param[out] Bus The bus number.
239 @param[out] Device The device number.
240 @param[out] Function The function number.
242 @return The composited representation of the NIC PCI location.
246 IScsiGetNICPciLocation (
247 IN EFI_HANDLE Controller
,
254 Read the EFI variable (VendorGuid/Name) and return a dynamically allocated
255 buffer, and the size of the buffer. If failure, return NULL.
257 @param[in] Name String part of EFI variable name.
258 @param[in] VendorGuid GUID part of EFI variable name.
259 @param[out] VariableSize Returns the size of the EFI variable that was read.
261 @return Dynamically allocated memory that contains a copy of the EFI variable.
262 @return Caller is responsible freeing the buffer.
263 @retval NULL Variable was not read.
267 IScsiGetVariableAndSize (
269 IN EFI_GUID
*VendorGuid
,
270 OUT UINTN
*VariableSize
274 Create the iSCSI driver data.
276 @param[in] Image The handle of the driver image.
277 @param[in] Controller The handle of the controller.
279 @return The iSCSI driver data created.
280 @retval NULL Other errors as indicated.
284 IScsiCreateDriverData (
286 IN EFI_HANDLE Controller
290 Clean the iSCSI driver data.
292 @param[in] Private The iSCSI driver data.
296 IScsiCleanDriverData (
297 IN ISCSI_DRIVER_DATA
*Private
301 Get the various configuration data of this iSCSI instance.
303 @param[in] Private The iSCSI driver data.
305 @retval EFI_SUCCESS Obtained the configuration of this instance.
306 @retval EFI_ABORTED The operation was aborted.
307 @retval Others Other errors as indicated.
312 IN ISCSI_DRIVER_DATA
*Private
316 Get the device path of the iSCSI tcp connection and update it.
318 @param[in] Session The iSCSI session data.
320 @return The updated device path.
321 @retval NULL Other errors as indicated.
324 EFI_DEVICE_PATH_PROTOCOL
*
325 IScsiGetTcpConnDevicePath (
326 IN ISCSI_SESSION
*Session
330 Abort the session when the transition from BS to RT is initiated.
332 @param[in] Event The event signaled.
333 @param[in] Context The iSCSI driver data.
338 IScsiOnExitBootService (