]>
Commit | Line | Data |
---|---|---|
4c5a5e0c | 1 | /** @file\r |
2 | Miscellaneous definitions for iSCSI driver.\r | |
3 | \r | |
e590d29f | 4 | Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r |
4c5a5e0c | 5 | This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef _ISCSI_MISC_H_\r | |
16 | #define _ISCSI_MISC_H_\r | |
17 | \r | |
18 | typedef struct _ISCSI_DRIVER_DATA ISCSI_DRIVER_DATA;\r | |
19 | \r | |
42f0586d | 20 | ///\r |
21 | /// IPv4 Device Path Node Length\r | |
22 | ///\r | |
5ae7578a | 23 | #define IP4_NODE_LEN_NEW_VERSIONS 27\r |
42f0586d | 24 | \r |
25 | ///\r | |
26 | /// IPv6 Device Path Node Length\r | |
27 | ///\r | |
5ae7578a | 28 | #define IP6_NODE_LEN_OLD_VERSIONS 43\r |
29 | #define IP6_NODE_LEN_NEW_VERSIONS 60\r | |
42f0586d | 30 | \r |
31 | ///\r | |
32 | /// The ignored field StaticIpAddress's offset in old IPv6 Device Path\r | |
33 | ///\r | |
5ae7578a | 34 | #define IP6_OLD_IPADDRESS_OFFSET 42\r |
42f0586d | 35 | \r |
4c5a5e0c | 36 | #pragma pack(1)\r |
37 | typedef struct _ISCSI_SESSION_CONFIG_NVDATA {\r | |
38 | UINT16 TargetPort;\r | |
39 | UINT8 Enabled;\r | |
40 | UINT8 IpMode;\r | |
41 | \r | |
75dce340 | 42 | EFI_IP_ADDRESS LocalIp;\r |
4c5a5e0c | 43 | EFI_IPv4_ADDRESS SubnetMask;\r |
75dce340 | 44 | EFI_IP_ADDRESS Gateway;\r |
4c5a5e0c | 45 | \r |
46 | BOOLEAN InitiatorInfoFromDhcp;\r | |
47 | BOOLEAN TargetInfoFromDhcp;\r | |
48 | CHAR8 TargetName[ISCSI_NAME_MAX_SIZE];\r | |
49 | EFI_IP_ADDRESS TargetIp;\r | |
75dce340 | 50 | UINT8 PrefixLength;\r |
4c5a5e0c | 51 | UINT8 BootLun[8];\r |
52 | \r | |
53 | UINT16 ConnectTimeout; ///< timout value in milliseconds\r | |
54 | UINT8 ConnectRetryCount;\r | |
55 | UINT8 IsId[6];\r | |
56 | } ISCSI_SESSION_CONFIG_NVDATA;\r | |
57 | #pragma pack()\r | |
58 | \r | |
59 | /**\r | |
60 | Calculate the prefix length of the IPv4 subnet mask.\r | |
61 | \r | |
62 | @param[in] SubnetMask The IPv4 subnet mask.\r | |
63 | \r | |
64 | @return The prefix length of the subnet mask.\r | |
65 | @retval 0 Other errors as indicated.\r | |
66 | \r | |
67 | **/\r | |
68 | UINT8\r | |
69 | IScsiGetSubnetMaskPrefixLength (\r | |
70 | IN EFI_IPv4_ADDRESS *SubnetMask\r | |
71 | );\r | |
72 | \r | |
73 | /**\r | |
74 | Convert the hexadecimal encoded LUN string into the 64-bit LUN. \r | |
75 | \r | |
76 | @param[in] Str The hexadecimal encoded LUN string.\r | |
77 | @param[out] Lun Storage to return the 64-bit LUN.\r | |
78 | \r | |
79 | @retval EFI_SUCCESS The 64-bit LUN is stored in Lun.\r | |
80 | @retval EFI_INVALID_PARAMETER The string is malformatted.\r | |
81 | \r | |
82 | **/\r | |
83 | EFI_STATUS\r | |
84 | IScsiAsciiStrToLun (\r | |
85 | IN CHAR8 *Str,\r | |
86 | OUT UINT8 *Lun\r | |
87 | );\r | |
88 | \r | |
89 | /**\r | |
90 | Convert the 64-bit LUN into the hexadecimal encoded LUN string.\r | |
91 | \r | |
92 | @param[in] Lun The 64-bit LUN.\r | |
93 | @param[out] String The storage to return the hexadecimal encoded LUN string.\r | |
94 | \r | |
95 | **/\r | |
96 | VOID\r | |
97 | IScsiLunToUnicodeStr (\r | |
98 | IN UINT8 *Lun,\r | |
99 | OUT CHAR16 *String\r | |
100 | );\r | |
101 | \r | |
102 | /**\r | |
103 | Convert the mac address into a hexadecimal encoded "-" seperated string.\r | |
104 | \r | |
105 | @param[in] Mac The mac address.\r | |
106 | @param[in] Len Length in bytes of the mac address.\r | |
107 | @param[in] VlanId VLAN ID of the network device.\r | |
108 | @param[out] Str The storage to return the mac string.\r | |
109 | \r | |
110 | **/\r | |
111 | VOID\r | |
112 | IScsiMacAddrToStr (\r | |
113 | IN EFI_MAC_ADDRESS *Mac,\r | |
114 | IN UINT32 Len,\r | |
115 | IN UINT16 VlanId,\r | |
116 | OUT CHAR16 *Str\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Convert the formatted IP address into the binary IP address.\r | |
121 | \r | |
122 | @param[in] Str The UNICODE string.\r | |
123 | @param[in] IpMode Indicates whether the IP address is v4 or v6.\r | |
124 | @param[out] Ip The storage to return the ASCII string.\r | |
125 | \r | |
126 | @retval EFI_SUCCESS The binary IP address is returned in Ip.\r | |
127 | @retval EFI_INVALID_PARAMETER The IP string is malformatted or IpMode is\r | |
128 | invalid.\r | |
129 | \r | |
130 | **/\r | |
131 | EFI_STATUS\r | |
132 | IScsiAsciiStrToIp (\r | |
133 | IN CHAR8 *Str,\r | |
134 | IN UINT8 IpMode,\r | |
135 | OUT EFI_IP_ADDRESS *Ip\r | |
136 | );\r | |
137 | \r | |
138 | /**\r | |
139 | Convert the binary encoded buffer into a hexadecimal encoded string.\r | |
140 | \r | |
141 | @param[in] BinBuffer The buffer containing the binary data.\r | |
142 | @param[in] BinLength Length of the binary buffer.\r | |
143 | @param[in, out] HexStr Pointer to the string.\r | |
144 | @param[in, out] HexLength The length of the string.\r | |
145 | \r | |
146 | @retval EFI_SUCCESS The binary data is converted to the hexadecimal string \r | |
147 | and the length of the string is updated.\r | |
148 | @retval EFI_BUFFER_TOO_SMALL The string is too small.\r | |
149 | @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r | |
150 | \r | |
151 | **/\r | |
152 | EFI_STATUS\r | |
153 | IScsiBinToHex (\r | |
154 | IN UINT8 *BinBuffer,\r | |
155 | IN UINT32 BinLength,\r | |
156 | IN OUT CHAR8 *HexStr,\r | |
157 | IN OUT UINT32 *HexLength\r | |
158 | );\r | |
159 | \r | |
160 | /**\r | |
161 | Convert the hexadecimal string into a binary encoded buffer.\r | |
162 | \r | |
163 | @param[in, out] BinBuffer The binary buffer.\r | |
164 | @param[in, out] BinLength Length of the binary buffer.\r | |
165 | @param[in] HexStr The hexadecimal string.\r | |
166 | \r | |
167 | @retval EFI_SUCCESS The hexadecimal string is converted into a binary\r | |
168 | encoded buffer.\r | |
169 | @retval EFI_BUFFER_TOO_SMALL The binary buffer is too small to hold the converted data.\r | |
170 | \r | |
171 | **/\r | |
172 | EFI_STATUS\r | |
173 | IScsiHexToBin (\r | |
174 | IN OUT UINT8 *BinBuffer,\r | |
175 | IN OUT UINT32 *BinLength,\r | |
176 | IN CHAR8 *HexStr\r | |
177 | );\r | |
178 | \r | |
179 | \r | |
180 | /**\r | |
181 | Convert the decimal-constant string or hex-constant string into a numerical value.\r | |
182 | \r | |
183 | @param[in] Str String in decimal or hex.\r | |
184 | \r | |
185 | @return The numerical value.\r | |
186 | \r | |
187 | **/\r | |
188 | UINTN\r | |
189 | IScsiNetNtoi (\r | |
190 | IN CHAR8 *Str\r | |
191 | );\r | |
192 | \r | |
193 | /**\r | |
194 | Generate random numbers.\r | |
195 | \r | |
196 | @param[in, out] Rand The buffer to contain random numbers.\r | |
197 | @param[in] RandLength The length of the Rand buffer.\r | |
198 | \r | |
199 | **/\r | |
200 | VOID\r | |
201 | IScsiGenRandom (\r | |
202 | IN OUT UINT8 *Rand,\r | |
203 | IN UINTN RandLength\r | |
204 | );\r | |
205 | \r | |
206 | /**\r | |
207 | Record the NIC information in a global structure.\r | |
208 | \r | |
209 | @param[in] Controller The handle of the controller.\r | |
210 | \r | |
211 | @retval EFI_SUCCESS The operation is completed.\r | |
212 | @retval EFI_OUT_OF_RESOURCES Do not have sufficient resource to finish this\r | |
213 | operation.\r | |
214 | \r | |
215 | **/\r | |
216 | EFI_STATUS\r | |
217 | IScsiAddNic (\r | |
218 | IN EFI_HANDLE Controller\r | |
219 | );\r | |
220 | \r | |
221 | /**\r | |
222 | Delete the recorded NIC information from a global structure. Also delete corresponding\r | |
223 | attempts.\r | |
224 | \r | |
225 | @param[in] Controller The handle of the controller.\r | |
226 | \r | |
227 | @retval EFI_SUCCESS The operation completed.\r | |
228 | @retval EFI_NOT_FOUND The NIC information to be deleted is not recorded.\r | |
229 | \r | |
230 | **/\r | |
231 | EFI_STATUS\r | |
232 | IScsiRemoveNic (\r | |
233 | IN EFI_HANDLE Controller\r | |
234 | );\r | |
235 | \r | |
236 | /**\r | |
237 | Get the recorded NIC information from a global structure by the Index.\r | |
238 | \r | |
239 | @param[in] NicIndex The index indicates the position of NIC info.\r | |
240 | \r | |
241 | @return Pointer to the NIC info or NULL if not found.\r | |
242 | \r | |
243 | **/\r | |
244 | ISCSI_NIC_INFO *\r | |
245 | IScsiGetNicInfoByIndex (\r | |
246 | IN UINT8 NicIndex\r | |
247 | );\r | |
248 | \r | |
249 | \r | |
250 | /**\r | |
59c0c1cb | 251 | Get the NIC's PCI location and return it according to the composited\r |
4c5a5e0c | 252 | format defined in iSCSI Boot Firmware Table.\r |
253 | \r | |
254 | @param[in] Controller The handle of the controller.\r | |
255 | @param[out] Bus The bus number.\r | |
256 | @param[out] Device The device number.\r | |
257 | @param[out] Function The function number.\r | |
258 | \r | |
259 | @return The composited representation of the NIC PCI location.\r | |
260 | \r | |
261 | **/\r | |
262 | UINT16\r | |
263 | IScsiGetNICPciLocation (\r | |
264 | IN EFI_HANDLE Controller,\r | |
265 | OUT UINTN *Bus,\r | |
266 | OUT UINTN *Device,\r | |
267 | OUT UINTN *Function\r | |
268 | );\r | |
269 | \r | |
270 | /**\r | |
271 | Read the EFI variable (VendorGuid/Name) and return a dynamically allocated\r | |
272 | buffer, and the size of the buffer. If failure, return NULL.\r | |
273 | \r | |
274 | @param[in] Name String part of EFI variable name.\r | |
275 | @param[in] VendorGuid GUID part of EFI variable name.\r | |
276 | @param[out] VariableSize Returns the size of the EFI variable that was read.\r | |
277 | \r | |
278 | @return Dynamically allocated memory that contains a copy of the EFI variable.\r | |
279 | @return Caller is responsible freeing the buffer.\r | |
280 | @retval NULL Variable was not read.\r | |
281 | \r | |
282 | **/\r | |
283 | VOID *\r | |
284 | IScsiGetVariableAndSize (\r | |
285 | IN CHAR16 *Name,\r | |
286 | IN EFI_GUID *VendorGuid,\r | |
287 | OUT UINTN *VariableSize\r | |
288 | );\r | |
289 | \r | |
290 | /**\r | |
291 | Create the iSCSI driver data.\r | |
292 | \r | |
293 | @param[in] Image The handle of the driver image.\r | |
294 | @param[in] Controller The handle of the controller.\r | |
295 | \r | |
296 | @return The iSCSI driver data created.\r | |
297 | @retval NULL Other errors as indicated.\r | |
298 | \r | |
299 | **/\r | |
300 | ISCSI_DRIVER_DATA *\r | |
301 | IScsiCreateDriverData (\r | |
302 | IN EFI_HANDLE Image,\r | |
303 | IN EFI_HANDLE Controller\r | |
304 | );\r | |
305 | \r | |
306 | /**\r | |
307 | Clean the iSCSI driver data.\r | |
308 | \r | |
e590d29f ZL |
309 | @param[in] Private The iSCSI driver data.\r |
310 | \r | |
311 | @retval EFI_SUCCES The clean operation is successful.\r | |
312 | @retval Others Other errors as indicated.\r | |
4c5a5e0c | 313 | \r |
314 | **/\r | |
e590d29f | 315 | EFI_STATUS\r |
4c5a5e0c | 316 | IScsiCleanDriverData (\r |
317 | IN ISCSI_DRIVER_DATA *Private\r | |
318 | );\r | |
319 | \r | |
b7cc5bf1 WJ |
320 | /**\r |
321 | Check wheather the Controller handle is configured to use DHCP protocol.\r | |
322 | \r | |
323 | @param[in] Controller The handle of the controller.\r | |
324 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r | |
325 | \r | |
326 | @retval TRUE The handle of the controller need the Dhcp protocol.\r | |
327 | @retval FALSE The handle of the controller does not need the Dhcp protocol.\r | |
328 | \r | |
329 | **/\r | |
330 | BOOLEAN\r | |
331 | IScsiDhcpIsConfigured (\r | |
332 | IN EFI_HANDLE Controller,\r | |
333 | IN UINT8 IpVersion\r | |
334 | );\r | |
335 | \r | |
4c5a5e0c | 336 | /**\r |
337 | Get the various configuration data of this iSCSI instance.\r | |
338 | \r | |
339 | @param[in] Private The iSCSI driver data.\r | |
340 | \r | |
341 | @retval EFI_SUCCESS Obtained the configuration of this instance.\r | |
342 | @retval EFI_ABORTED The operation was aborted.\r | |
343 | @retval Others Other errors as indicated.\r | |
344 | \r | |
345 | **/\r | |
346 | EFI_STATUS\r | |
347 | IScsiGetConfigData (\r | |
348 | IN ISCSI_DRIVER_DATA *Private\r | |
349 | );\r | |
350 | \r | |
351 | /**\r | |
352 | Get the device path of the iSCSI tcp connection and update it.\r | |
353 | \r | |
354 | @param[in] Session The iSCSI session data.\r | |
355 | \r | |
356 | @return The updated device path.\r | |
357 | @retval NULL Other errors as indicated.\r | |
358 | \r | |
359 | **/\r | |
360 | EFI_DEVICE_PATH_PROTOCOL *\r | |
361 | IScsiGetTcpConnDevicePath (\r | |
362 | IN ISCSI_SESSION *Session\r | |
363 | );\r | |
364 | \r | |
365 | /**\r | |
366 | Abort the session when the transition from BS to RT is initiated.\r | |
367 | \r | |
368 | @param[in] Event The event signaled.\r | |
369 | @param[in] Context The iSCSI driver data.\r | |
370 | \r | |
371 | **/\r | |
372 | VOID\r | |
373 | EFIAPI\r | |
374 | IScsiOnExitBootService (\r | |
375 | IN EFI_EVENT Event,\r | |
376 | IN VOID *Context\r | |
377 | );\r | |
378 | \r | |
18b24f92 FS |
379 | /**\r |
380 | Tests whether a controller handle is being managed by IScsi driver.\r | |
381 | \r | |
382 | This function tests whether the driver specified by DriverBindingHandle is\r | |
383 | currently managing the controller specified by ControllerHandle. This test\r | |
384 | is performed by evaluating if the the protocol specified by ProtocolGuid is\r | |
385 | present on ControllerHandle and is was opened by DriverBindingHandle and Nic\r | |
386 | Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r | |
387 | If ProtocolGuid is NULL, then ASSERT().\r | |
388 | \r | |
389 | @param ControllerHandle A handle for a controller to test.\r | |
390 | @param DriverBindingHandle Specifies the driver binding handle for the\r | |
391 | driver.\r | |
392 | @param ProtocolGuid Specifies the protocol that the driver specified\r | |
393 | by DriverBindingHandle opens in its Start()\r | |
394 | function.\r | |
395 | \r | |
396 | @retval EFI_SUCCESS ControllerHandle is managed by the driver\r | |
397 | specified by DriverBindingHandle.\r | |
398 | @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver\r | |
399 | specified by DriverBindingHandle.\r | |
400 | \r | |
401 | **/\r | |
402 | EFI_STATUS\r | |
403 | EFIAPI\r | |
404 | IScsiTestManagedDevice (\r | |
405 | IN EFI_HANDLE ControllerHandle,\r | |
406 | IN EFI_HANDLE DriverBindingHandle,\r | |
407 | IN EFI_GUID *ProtocolGuid\r | |
408 | );\r | |
4c5a5e0c | 409 | #endif\r |