2 Miscellaneous definitions for iSCSI driver.
4 Copyright (c) 2004 - 2015, 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 #include <Library/BaseLib.h>
20 typedef struct _ISCSI_SESSION_CONFIG_DATA ISCSI_SESSION_CONFIG_DATA
;
23 /// IPv4 Device Path Node Length
25 #define IP4_NODE_LEN_NEW_VERSIONS 27
31 BOOLEAN InitiatorInfoFromDhcp
;
32 EFI_IPv4_ADDRESS LocalIp
;
33 EFI_IPv4_ADDRESS SubnetMask
;
34 EFI_IPv4_ADDRESS Gateway
;
36 BOOLEAN TargetInfoFromDhcp
;
37 CHAR8 TargetName
[ISCSI_NAME_MAX_SIZE
];
38 EFI_IPv4_ADDRESS TargetIp
;
43 } ISCSI_SESSION_CONFIG_NVDATA
;
46 struct _ISCSI_SESSION_CONFIG_DATA
{
47 ISCSI_SESSION_CONFIG_NVDATA NvData
;
49 EFI_IPv4_ADDRESS PrimaryDns
;
50 EFI_IPv4_ADDRESS SecondaryDns
;
51 EFI_IPv4_ADDRESS DhcpServer
;
55 Calculate the prefix length of the IPv4 subnet mask.
57 @param[in] SubnetMask The IPv4 subnet mask.
59 @return The prefix length of the subnet mask.
60 @retval 0 Other errors as indicated.
63 IScsiGetSubnetMaskPrefixLength (
64 IN EFI_IPv4_ADDRESS
*SubnetMask
68 Convert the hexadecimal encoded LUN string into the 64-bit LUN.
70 @param[in] Str The hexadecimal encoded LUN string.
71 @param[out] Lun Storage to return the 64-bit LUN.
73 @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.
74 @retval EFI_INVALID_PARAMETER The string is malformatted.
83 Convert the 64-bit LUN into the hexadecimal encoded LUN string.
85 @param[in] Lun The 64-bit LUN.
86 @param[out] Str The storage to return the hexadecimal encoded LUN string.
89 IScsiLunToUnicodeStr (
95 Convert the ASCII string into a UNICODE string.
97 @param[in] Source The ASCII string.
98 @param[out] Destination The storage to return the UNICODE string.
100 @return CHAR16 * Pointer to the UNICODE string.
103 IScsiAsciiStrToUnicodeStr (
105 OUT CHAR16
*Destination
109 Convert the UNICODE string into an ASCII string.
111 @param[in] Source The UNICODE string.
112 @param[out] Destination The storage to return the ASCII string.
114 @return CHAR8 * Pointer to the ASCII string.
117 IScsiUnicodeStrToAsciiStr (
119 OUT CHAR8
*Destination
123 Convert the mac address into a hexadecimal encoded "-" seperated string.
125 @param[in] Mac The mac address.
126 @param[in] Len Length in bytes of the mac address.
127 @param[in] VlanId VLAN ID of the network device.
128 @param[out] Str The storage to return the mac string.
132 IN EFI_MAC_ADDRESS
*Mac
,
139 Convert the decimal dotted IPv4 address into the binary IPv4 address.
141 @param[in] Str The UNICODE string.
142 @param[out] Ip The storage to return the ASCII string.
144 @retval EFI_SUCCESS The binary IP address is returned in Ip.
145 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
150 OUT EFI_IPv4_ADDRESS
*Ip
154 Convert the binary encoded buffer into a hexadecimal encoded string.
156 @param[in] BinBuffer The buffer containing the binary data.
157 @param[in] BinLength Length of the binary buffer.
158 @param[in, out] HexStr Pointer to the string.
159 @param[in, out] HexLength The length of the string.
161 @retval EFI_SUCCESS The binary data is converted to the hexadecimal string
162 and the length of the string is updated.
163 @retval EFI_BUFFER_TOO_SMALL The string is too small.
164 @retval EFI_INVALID_PARAMETER The IP string is malformatted.
170 IN OUT CHAR8
*HexStr
,
171 IN OUT UINT32
*HexLength
175 Convert the hexadecimal string into a binary encoded buffer.
177 @param[in, out] BinBuffer The binary buffer.
178 @param[in, out] BinLength Length of the binary buffer.
179 @param[in] HexStr The hexadecimal string.
181 @retval EFI_SUCCESS The hexadecimal string is converted into a binary
183 @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.
187 IN OUT UINT8
*BinBuffer
,
188 IN OUT UINT32
*BinLength
,
193 Generate random numbers.
195 @param[in, out] Rand The buffer to contain random numbers.
196 @param[in] RandLength The length of the Rand buffer.
205 Create the iSCSI driver data..
207 @param[in] Image The handle of the driver image.
208 @param[in] Controller The handle of the controller.
210 @return The iSCSI driver data created.
211 @retval NULL Other errors as indicated.
214 IScsiCreateDriverData (
216 IN EFI_HANDLE Controller
220 Clean the iSCSI driver data.
222 @param[in] Private The iSCSI driver data.
225 IScsiCleanDriverData (
226 IN ISCSI_DRIVER_DATA
*Private
230 Check wheather the Controller is configured to use DHCP protocol.
232 @param[in] Controller The handle of the controller.
234 @retval TRUE The handle of the controller need the Dhcp protocol.
235 @retval FALSE The handle of the controller does not need the Dhcp protocol.
239 IScsiDhcpIsConfigured (
240 IN EFI_HANDLE Controller
244 Get the various configuration data of this iSCSI instance.
246 @param[in] Private The iSCSI driver data.
248 @retval EFI_SUCCESS The configuration of this instance is got.
249 @retval EFI_ABORTED The operation was aborted.
250 @retval Others Other errors as indicated.
254 IN ISCSI_DRIVER_DATA
*Private
258 Get the device path of the iSCSI tcp connection and update it.
260 @param[in] Private The iSCSI driver data.
262 @return The updated device path.
263 @retval NULL Other errors as indicated.
265 EFI_DEVICE_PATH_PROTOCOL
*
266 IScsiGetTcpConnDevicePath (
267 IN ISCSI_DRIVER_DATA
*Private
271 Abort the session when the transition from BS to RT is initiated.
273 @param[in] Event The event signaled.
274 @param[in] Context The iSCSI driver data.
278 IScsiOnExitBootService (
284 Tests whether a controller handle is being managed by IScsi driver.
286 This function tests whether the driver specified by DriverBindingHandle is
287 currently managing the controller specified by ControllerHandle. This test
288 is performed by evaluating if the the protocol specified by ProtocolGuid is
289 present on ControllerHandle and is was opened by DriverBindingHandle and Nic
290 Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
291 If ProtocolGuid is NULL, then ASSERT().
293 @param ControllerHandle A handle for a controller to test.
294 @param DriverBindingHandle Specifies the driver binding handle for the
296 @param ProtocolGuid Specifies the protocol that the driver specified
297 by DriverBindingHandle opens in its Start()
300 @retval EFI_SUCCESS ControllerHandle is managed by the driver
301 specified by DriverBindingHandle.
302 @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
303 specified by DriverBindingHandle.
308 IScsiTestManagedDevice (
309 IN EFI_HANDLE ControllerHandle
,
310 IN EFI_HANDLE DriverBindingHandle
,
311 IN EFI_GUID
*ProtocolGuid