1 | /** @file
|
---|
2 | The entry point of IScsi driver.
|
---|
3 |
|
---|
4 | Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
|
---|
5 | (C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
|
---|
6 |
|
---|
7 | This program and the accompanying materials
|
---|
8 | are licensed and made available under the terms and conditions of the BSD License
|
---|
9 | which accompanies this distribution. The full text of the license may be found at
|
---|
10 | http://opensource.org/licenses/bsd-license.php
|
---|
11 |
|
---|
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
14 |
|
---|
15 | **/
|
---|
16 |
|
---|
17 | #include "IScsiImpl.h"
|
---|
18 |
|
---|
19 | EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = {
|
---|
20 | IScsiIp4DriverBindingSupported,
|
---|
21 | IScsiIp4DriverBindingStart,
|
---|
22 | IScsiIp4DriverBindingStop,
|
---|
23 | 0xa,
|
---|
24 | NULL,
|
---|
25 | NULL
|
---|
26 | };
|
---|
27 |
|
---|
28 | EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = {
|
---|
29 | IScsiIp6DriverBindingSupported,
|
---|
30 | IScsiIp6DriverBindingStart,
|
---|
31 | IScsiIp6DriverBindingStop,
|
---|
32 | 0xa,
|
---|
33 | NULL,
|
---|
34 | NULL
|
---|
35 | };
|
---|
36 |
|
---|
37 | EFI_GUID gIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
|
---|
38 | EFI_GUID gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
|
---|
39 | ISCSI_PRIVATE_DATA *mPrivate = NULL;
|
---|
40 |
|
---|
41 | /**
|
---|
42 | Tests to see if this driver supports the RemainingDevicePath.
|
---|
43 |
|
---|
44 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
---|
45 | parameter is ignored by device drivers, and is optional for bus
|
---|
46 | drivers. For bus drivers, if this parameter is not NULL, then
|
---|
47 | the bus driver must determine if the bus controller specified
|
---|
48 | by ControllerHandle and the child controller specified
|
---|
49 | by RemainingDevicePath are both supported by this
|
---|
50 | bus driver.
|
---|
51 |
|
---|
52 | @retval EFI_SUCCESS The RemainingDevicePath is supported or NULL.
|
---|
53 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
|
---|
54 | RemainingDevicePath is not supported by the driver specified by This.
|
---|
55 | **/
|
---|
56 | EFI_STATUS
|
---|
57 | IScsiIsDevicePathSupported (
|
---|
58 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
---|
59 | )
|
---|
60 | {
|
---|
61 | EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
|
---|
62 |
|
---|
63 | CurrentDevicePath = RemainingDevicePath;
|
---|
64 | if (CurrentDevicePath != NULL) {
|
---|
65 | while (!IsDevicePathEnd (CurrentDevicePath)) {
|
---|
66 | if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) && (CurrentDevicePath->SubType == MSG_ISCSI_DP)) {
|
---|
67 | return EFI_SUCCESS;
|
---|
68 | }
|
---|
69 |
|
---|
70 | CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
|
---|
71 | }
|
---|
72 |
|
---|
73 | return EFI_UNSUPPORTED;
|
---|
74 | }
|
---|
75 |
|
---|
76 | return EFI_SUCCESS;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | Check whether an iSCSI HBA adapter already installs an AIP instance with
|
---|
81 | network boot policy matching the value specified in PcdIScsiAIPNetworkBootPolicy.
|
---|
82 | If yes, return EFI_SUCCESS.
|
---|
83 |
|
---|
84 | @retval EFI_SUCCESS Found an AIP with matching network boot policy.
|
---|
85 | @retval EFI_NOT_FOUND AIP is unavailable or the network boot policy
|
---|
86 | not matched.
|
---|
87 | **/
|
---|
88 | EFI_STATUS
|
---|
89 | IScsiCheckAip (
|
---|
90 | VOID
|
---|
91 | )
|
---|
92 | {
|
---|
93 | UINTN AipHandleCount;
|
---|
94 | EFI_HANDLE *AipHandleBuffer;
|
---|
95 | UINTN AipIndex;
|
---|
96 | EFI_ADAPTER_INFORMATION_PROTOCOL *Aip;
|
---|
97 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
|
---|
98 | EFI_GUID *InfoTypesBuffer;
|
---|
99 | UINTN InfoTypeBufferCount;
|
---|
100 | UINTN TypeIndex;
|
---|
101 | VOID *InfoBlock;
|
---|
102 | UINTN InfoBlockSize;
|
---|
103 | BOOLEAN Supported;
|
---|
104 | EFI_ADAPTER_INFO_NETWORK_BOOT *NetworkBoot;
|
---|
105 | EFI_STATUS Status;
|
---|
106 | UINT8 NetworkBootPolicy;
|
---|
107 |
|
---|
108 | //
|
---|
109 | // Check any AIP instances exist in system.
|
---|
110 | //
|
---|
111 | AipHandleCount = 0;
|
---|
112 | AipHandleBuffer = NULL;
|
---|
113 | Status = gBS->LocateHandleBuffer (
|
---|
114 | ByProtocol,
|
---|
115 | &gEfiAdapterInformationProtocolGuid,
|
---|
116 | NULL,
|
---|
117 | &AipHandleCount,
|
---|
118 | &AipHandleBuffer
|
---|
119 | );
|
---|
120 | if (EFI_ERROR (Status) || AipHandleCount == 0) {
|
---|
121 | return EFI_NOT_FOUND;
|
---|
122 | }
|
---|
123 |
|
---|
124 | ASSERT (AipHandleBuffer != NULL);
|
---|
125 |
|
---|
126 | InfoBlock = NULL;
|
---|
127 |
|
---|
128 | for (AipIndex = 0; AipIndex < AipHandleCount; AipIndex++) {
|
---|
129 | Status = gBS->HandleProtocol (
|
---|
130 | AipHandleBuffer[AipIndex],
|
---|
131 | &gEfiAdapterInformationProtocolGuid,
|
---|
132 | (VOID *) &Aip
|
---|
133 | );
|
---|
134 | ASSERT_EFI_ERROR (Status);
|
---|
135 | ASSERT (Aip != NULL);
|
---|
136 |
|
---|
137 | Status = gBS->HandleProtocol (
|
---|
138 | AipHandleBuffer[AipIndex],
|
---|
139 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
140 | (VOID *) &ExtScsiPassThru
|
---|
141 | );
|
---|
142 | if (EFI_ERROR (Status) || ExtScsiPassThru == NULL) {
|
---|
143 | continue;
|
---|
144 | }
|
---|
145 |
|
---|
146 | InfoTypesBuffer = NULL;
|
---|
147 | InfoTypeBufferCount = 0;
|
---|
148 | Status = Aip->GetSupportedTypes (Aip, &InfoTypesBuffer, &InfoTypeBufferCount);
|
---|
149 | if (EFI_ERROR (Status) || InfoTypesBuffer == NULL) {
|
---|
150 | continue;
|
---|
151 | }
|
---|
152 | //
|
---|
153 | // Check whether the AIP instance has Network boot information block.
|
---|
154 | //
|
---|
155 | Supported = FALSE;
|
---|
156 | for (TypeIndex = 0; TypeIndex < InfoTypeBufferCount; TypeIndex++) {
|
---|
157 | if (CompareGuid (&InfoTypesBuffer[TypeIndex], &gEfiAdapterInfoNetworkBootGuid)) {
|
---|
158 | Supported = TRUE;
|
---|
159 | break;
|
---|
160 | }
|
---|
161 | }
|
---|
162 |
|
---|
163 | FreePool (InfoTypesBuffer);
|
---|
164 | if (!Supported) {
|
---|
165 | continue;
|
---|
166 | }
|
---|
167 |
|
---|
168 | //
|
---|
169 | // We now have network boot information block.
|
---|
170 | //
|
---|
171 | InfoBlock = NULL;
|
---|
172 | InfoBlockSize = 0;
|
---|
173 | Status = Aip->GetInformation (Aip, &gEfiAdapterInfoNetworkBootGuid, &InfoBlock, &InfoBlockSize);
|
---|
174 | if (EFI_ERROR (Status) || InfoBlock == NULL) {
|
---|
175 | continue;
|
---|
176 | }
|
---|
177 |
|
---|
178 | //
|
---|
179 | // Check whether the network boot policy matches.
|
---|
180 | //
|
---|
181 | NetworkBoot = (EFI_ADAPTER_INFO_NETWORK_BOOT *) InfoBlock;
|
---|
182 | NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy);
|
---|
183 |
|
---|
184 | if (NetworkBootPolicy == STOP_UEFI_ISCSI_IF_HBA_INSTALL_AIP) {
|
---|
185 | Status = EFI_SUCCESS;
|
---|
186 | goto Exit;
|
---|
187 | }
|
---|
188 | if (((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP4) != 0 &&
|
---|
189 | !NetworkBoot->iScsiIpv4BootCapablity) ||
|
---|
190 | ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_IP6) != 0 &&
|
---|
191 | !NetworkBoot->iScsiIpv6BootCapablity) ||
|
---|
192 | ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_OFFLOAD) != 0 &&
|
---|
193 | !NetworkBoot->OffloadCapability) ||
|
---|
194 | ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_SUPPORT_MPIO) != 0 &&
|
---|
195 | !NetworkBoot->iScsiMpioCapability) ||
|
---|
196 | ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP4) != 0 &&
|
---|
197 | !NetworkBoot->iScsiIpv4Boot) ||
|
---|
198 | ((NetworkBootPolicy & STOP_UEFI_ISCSI_IF_AIP_CONFIGURED_IP6) != 0 &&
|
---|
199 | !NetworkBoot->iScsiIpv6Boot)) {
|
---|
200 | FreePool (InfoBlock);
|
---|
201 | continue;
|
---|
202 | }
|
---|
203 |
|
---|
204 | Status = EFI_SUCCESS;
|
---|
205 | goto Exit;
|
---|
206 | }
|
---|
207 |
|
---|
208 | Status = EFI_NOT_FOUND;
|
---|
209 |
|
---|
210 | Exit:
|
---|
211 | if (InfoBlock != NULL) {
|
---|
212 | FreePool (InfoBlock);
|
---|
213 | }
|
---|
214 | if (AipHandleBuffer != NULL) {
|
---|
215 | FreePool (AipHandleBuffer);
|
---|
216 | }
|
---|
217 | return Status;
|
---|
218 | }
|
---|
219 |
|
---|
220 | /**
|
---|
221 | Tests to see if this driver supports a given controller. This is the worker function for
|
---|
222 | IScsiIp4(6)DriverBindingSupported.
|
---|
223 |
|
---|
224 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
225 | @param[in] ControllerHandle The handle of the controller to test. This handle
|
---|
226 | must support a protocol interface that supplies
|
---|
227 | an I/O abstraction to the driver.
|
---|
228 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
---|
229 | parameter is ignored by device drivers, and is optional for bus
|
---|
230 | drivers. For bus drivers, if this parameter is not NULL, then
|
---|
231 | the bus driver must determine if the bus controller specified
|
---|
232 | by ControllerHandle and the child controller specified
|
---|
233 | by RemainingDevicePath are both supported by this
|
---|
234 | bus driver.
|
---|
235 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
|
---|
236 |
|
---|
237 | @retval EFI_SUCCESS The device specified by ControllerHandle and
|
---|
238 | RemainingDevicePath is supported by the driver specified by This.
|
---|
239 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
|
---|
240 | RemainingDevicePath is already being managed by the driver
|
---|
241 | specified by This.
|
---|
242 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
|
---|
243 | RemainingDevicePath is not supported by the driver specified by This.
|
---|
244 | **/
|
---|
245 | EFI_STATUS
|
---|
246 | EFIAPI
|
---|
247 | IScsiSupported (
|
---|
248 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
249 | IN EFI_HANDLE ControllerHandle,
|
---|
250 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
|
---|
251 | IN UINT8 IpVersion
|
---|
252 | )
|
---|
253 | {
|
---|
254 | EFI_STATUS Status;
|
---|
255 | EFI_GUID *IScsiServiceBindingGuid;
|
---|
256 | EFI_GUID *TcpServiceBindingGuid;
|
---|
257 | EFI_GUID *DhcpServiceBindingGuid;
|
---|
258 | EFI_GUID *DnsServiceBindingGuid;
|
---|
259 |
|
---|
260 | if (IpVersion == IP_VERSION_4) {
|
---|
261 | IScsiServiceBindingGuid = &gIScsiV4PrivateGuid;
|
---|
262 | TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
---|
263 | DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
|
---|
264 | DnsServiceBindingGuid = &gEfiDns4ServiceBindingProtocolGuid;
|
---|
265 |
|
---|
266 | } else {
|
---|
267 | IScsiServiceBindingGuid = &gIScsiV6PrivateGuid;
|
---|
268 | TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
---|
269 | DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;
|
---|
270 | DnsServiceBindingGuid = &gEfiDns6ServiceBindingProtocolGuid;
|
---|
271 | }
|
---|
272 |
|
---|
273 | Status = gBS->OpenProtocol (
|
---|
274 | ControllerHandle,
|
---|
275 | IScsiServiceBindingGuid,
|
---|
276 | NULL,
|
---|
277 | This->DriverBindingHandle,
|
---|
278 | ControllerHandle,
|
---|
279 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
---|
280 | );
|
---|
281 | if (!EFI_ERROR (Status)) {
|
---|
282 | return EFI_ALREADY_STARTED;
|
---|
283 | }
|
---|
284 |
|
---|
285 | Status = gBS->OpenProtocol (
|
---|
286 | ControllerHandle,
|
---|
287 | TcpServiceBindingGuid,
|
---|
288 | NULL,
|
---|
289 | This->DriverBindingHandle,
|
---|
290 | ControllerHandle,
|
---|
291 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
---|
292 | );
|
---|
293 | if (EFI_ERROR (Status)) {
|
---|
294 | return EFI_UNSUPPORTED;
|
---|
295 | }
|
---|
296 |
|
---|
297 | Status = IScsiIsDevicePathSupported (RemainingDevicePath);
|
---|
298 | if (EFI_ERROR (Status)) {
|
---|
299 | return EFI_UNSUPPORTED;
|
---|
300 | }
|
---|
301 |
|
---|
302 | if (IScsiDhcpIsConfigured (ControllerHandle, IpVersion)) {
|
---|
303 | Status = gBS->OpenProtocol (
|
---|
304 | ControllerHandle,
|
---|
305 | DhcpServiceBindingGuid,
|
---|
306 | NULL,
|
---|
307 | This->DriverBindingHandle,
|
---|
308 | ControllerHandle,
|
---|
309 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
---|
310 | );
|
---|
311 | if (EFI_ERROR (Status)) {
|
---|
312 | return EFI_UNSUPPORTED;
|
---|
313 | }
|
---|
314 | }
|
---|
315 |
|
---|
316 | if (IScsiDnsIsConfigured (ControllerHandle)) {
|
---|
317 | Status = gBS->OpenProtocol (
|
---|
318 | ControllerHandle,
|
---|
319 | DnsServiceBindingGuid,
|
---|
320 | NULL,
|
---|
321 | This->DriverBindingHandle,
|
---|
322 | ControllerHandle,
|
---|
323 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
---|
324 | );
|
---|
325 | if (EFI_ERROR (Status)) {
|
---|
326 | return EFI_UNSUPPORTED;
|
---|
327 | }
|
---|
328 | }
|
---|
329 |
|
---|
330 | return EFI_SUCCESS;
|
---|
331 | }
|
---|
332 |
|
---|
333 |
|
---|
334 | /**
|
---|
335 | Start to manage the controller. This is the worker function for
|
---|
336 | IScsiIp4(6)DriverBindingStart.
|
---|
337 |
|
---|
338 | @param[in] Image Handle of the image.
|
---|
339 | @param[in] ControllerHandle Handle of the controller.
|
---|
340 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
|
---|
341 |
|
---|
342 | @retval EFI_SUCCES This driver was started.
|
---|
343 | @retval EFI_ALREADY_STARTED This driver is already running on this device.
|
---|
344 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
---|
345 | @retval EFI_NOT_FOUND There is no sufficient information to establish
|
---|
346 | the iScsi session.
|
---|
347 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
---|
348 | @retval EFI_DEVICE_ERROR Failed to get TCP connection device path.
|
---|
349 | @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle
|
---|
350 | because its interfaces are being used.
|
---|
351 |
|
---|
352 | **/
|
---|
353 | EFI_STATUS
|
---|
354 | IScsiStart (
|
---|
355 | IN EFI_HANDLE Image,
|
---|
356 | IN EFI_HANDLE ControllerHandle,
|
---|
357 | IN UINT8 IpVersion
|
---|
358 | )
|
---|
359 | {
|
---|
360 | EFI_STATUS Status;
|
---|
361 | ISCSI_DRIVER_DATA *Private;
|
---|
362 | LIST_ENTRY *Entry;
|
---|
363 | LIST_ENTRY *NextEntry;
|
---|
364 | ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
|
---|
365 | ISCSI_SESSION *Session;
|
---|
366 | UINT8 Index;
|
---|
367 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExistIScsiExtScsiPassThru;
|
---|
368 | ISCSI_DRIVER_DATA *ExistPrivate;
|
---|
369 | UINT8 *AttemptConfigOrder;
|
---|
370 | UINTN AttemptConfigOrderSize;
|
---|
371 | UINT8 BootSelected;
|
---|
372 | EFI_HANDLE *HandleBuffer;
|
---|
373 | UINTN NumberOfHandles;
|
---|
374 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
---|
375 | EFI_GUID *IScsiPrivateGuid;
|
---|
376 | EFI_GUID *TcpServiceBindingGuid;
|
---|
377 | BOOLEAN NeedUpdate;
|
---|
378 | VOID *Interface;
|
---|
379 | EFI_GUID *ProtocolGuid;
|
---|
380 | UINT8 NetworkBootPolicy;
|
---|
381 | ISCSI_SESSION_CONFIG_NVDATA *NvData;
|
---|
382 |
|
---|
383 | //
|
---|
384 | // Test to see if iSCSI driver supports the given controller.
|
---|
385 | //
|
---|
386 |
|
---|
387 | if (IpVersion == IP_VERSION_4) {
|
---|
388 | IScsiPrivateGuid = &gIScsiV4PrivateGuid;
|
---|
389 | TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
---|
390 | ProtocolGuid = &gEfiTcp4ProtocolGuid;
|
---|
391 | } else if (IpVersion == IP_VERSION_6) {
|
---|
392 | IScsiPrivateGuid = &gIScsiV6PrivateGuid;
|
---|
393 | TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
---|
394 | ProtocolGuid = &gEfiTcp6ProtocolGuid;
|
---|
395 | } else {
|
---|
396 | return EFI_INVALID_PARAMETER;
|
---|
397 | }
|
---|
398 |
|
---|
399 | Status = gBS->OpenProtocol (
|
---|
400 | ControllerHandle,
|
---|
401 | IScsiPrivateGuid,
|
---|
402 | NULL,
|
---|
403 | Image,
|
---|
404 | ControllerHandle,
|
---|
405 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
---|
406 | );
|
---|
407 | if (!EFI_ERROR (Status)) {
|
---|
408 | return EFI_ALREADY_STARTED;
|
---|
409 | }
|
---|
410 |
|
---|
411 | Status = gBS->OpenProtocol (
|
---|
412 | ControllerHandle,
|
---|
413 | TcpServiceBindingGuid,
|
---|
414 | NULL,
|
---|
415 | Image,
|
---|
416 | ControllerHandle,
|
---|
417 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
---|
418 | );
|
---|
419 | if (EFI_ERROR (Status)) {
|
---|
420 | return EFI_UNSUPPORTED;
|
---|
421 | }
|
---|
422 |
|
---|
423 | NetworkBootPolicy = PcdGet8 (PcdIScsiAIPNetworkBootPolicy);
|
---|
424 | if (NetworkBootPolicy == ALWAYS_USE_ISCSI_HBA_AND_IGNORE_UEFI_ISCSI) {
|
---|
425 | return EFI_ABORTED;
|
---|
426 | }
|
---|
427 |
|
---|
428 | if (NetworkBootPolicy != ALWAYS_USE_UEFI_ISCSI_AND_IGNORE_ISCSI_HBA) {
|
---|
429 | //
|
---|
430 | // Check existing iSCSI AIP.
|
---|
431 | //
|
---|
432 | Status = IScsiCheckAip ();
|
---|
433 | if (!EFI_ERROR (Status)) {
|
---|
434 | //
|
---|
435 | // Find iSCSI AIP with specified network boot policy. return EFI_ABORTED.
|
---|
436 | //
|
---|
437 | return EFI_ABORTED;
|
---|
438 | }
|
---|
439 | }
|
---|
440 |
|
---|
441 | //
|
---|
442 | // Record the incoming NIC info.
|
---|
443 | //
|
---|
444 | Status = IScsiAddNic (ControllerHandle, Image);
|
---|
445 | if (EFI_ERROR (Status)) {
|
---|
446 | return Status;
|
---|
447 | }
|
---|
448 |
|
---|
449 | //
|
---|
450 | // Create the instance private data.
|
---|
451 | //
|
---|
452 | Private = IScsiCreateDriverData (Image, ControllerHandle);
|
---|
453 | if (Private == NULL) {
|
---|
454 | return EFI_OUT_OF_RESOURCES;
|
---|
455 | }
|
---|
456 |
|
---|
457 | //
|
---|
458 | // Create a underlayer child instance, but not need to configure it. Just open ChildHandle
|
---|
459 | // via BY_DRIVER. That is, establishing the relationship between ControllerHandle and ChildHandle.
|
---|
460 | // Therefore, when DisconnectController(), especially VLAN virtual controller handle,
|
---|
461 | // IScsiDriverBindingStop() will be called.
|
---|
462 | //
|
---|
463 | Status = NetLibCreateServiceChild (
|
---|
464 | ControllerHandle,
|
---|
465 | Image,
|
---|
466 | TcpServiceBindingGuid,
|
---|
467 | &Private->ChildHandle
|
---|
468 | );
|
---|
469 |
|
---|
470 | if (EFI_ERROR (Status)) {
|
---|
471 | goto ON_ERROR;
|
---|
472 | }
|
---|
473 |
|
---|
474 | Status = gBS->OpenProtocol (
|
---|
475 | Private->ChildHandle, /// Default Tcp child
|
---|
476 | ProtocolGuid,
|
---|
477 | &Interface,
|
---|
478 | Image,
|
---|
479 | ControllerHandle,
|
---|
480 | EFI_OPEN_PROTOCOL_BY_DRIVER
|
---|
481 | );
|
---|
482 |
|
---|
483 | if (EFI_ERROR (Status)) {
|
---|
484 | goto ON_ERROR;
|
---|
485 | }
|
---|
486 |
|
---|
487 | //
|
---|
488 | // Always install private protocol no matter what happens later. We need to
|
---|
489 | // keep the relationship between ControllerHandle and ChildHandle.
|
---|
490 | //
|
---|
491 | Status = gBS->InstallProtocolInterface (
|
---|
492 | &ControllerHandle,
|
---|
493 | IScsiPrivateGuid,
|
---|
494 | EFI_NATIVE_INTERFACE,
|
---|
495 | &Private->IScsiIdentifier
|
---|
496 | );
|
---|
497 | if (EFI_ERROR (Status)) {
|
---|
498 | goto ON_ERROR;
|
---|
499 | }
|
---|
500 |
|
---|
501 | if (IpVersion == IP_VERSION_4) {
|
---|
502 | mPrivate->Ipv6Flag = FALSE;
|
---|
503 | } else {
|
---|
504 | mPrivate->Ipv6Flag = TRUE;
|
---|
505 | }
|
---|
506 |
|
---|
507 | //
|
---|
508 | // Get the current iSCSI configuration data.
|
---|
509 | //
|
---|
510 | Status = IScsiGetConfigData (Private);
|
---|
511 | if (EFI_ERROR (Status)) {
|
---|
512 | goto ON_ERROR;
|
---|
513 | }
|
---|
514 |
|
---|
515 | //
|
---|
516 | // If there is already a successul attempt, check whether this attempt is the
|
---|
517 | // first "enabled for MPIO" attempt. If not, still try the first attempt.
|
---|
518 | // In single path mode, try all attempts.
|
---|
519 | //
|
---|
520 | ExistPrivate = NULL;
|
---|
521 | Status = EFI_NOT_FOUND;
|
---|
522 |
|
---|
523 | if (mPrivate->OneSessionEstablished && mPrivate->EnableMpio) {
|
---|
524 | AttemptConfigData = NULL;
|
---|
525 | NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
|
---|
526 | AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
|
---|
527 | if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
|
---|
528 | break;
|
---|
529 | }
|
---|
530 | }
|
---|
531 |
|
---|
532 | if (AttemptConfigData == NULL) {
|
---|
533 | goto ON_ERROR;
|
---|
534 | }
|
---|
535 |
|
---|
536 | if (AttemptConfigData->AttemptConfigIndex == mPrivate->BootSelectedIndex) {
|
---|
537 | goto ON_EXIT;
|
---|
538 | }
|
---|
539 |
|
---|
540 | //
|
---|
541 | // Uninstall the original ExtScsiPassThru first.
|
---|
542 | //
|
---|
543 |
|
---|
544 | //
|
---|
545 | // Locate all ExtScsiPassThru protocol instances.
|
---|
546 | //
|
---|
547 | Status = gBS->LocateHandleBuffer (
|
---|
548 | ByProtocol,
|
---|
549 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
550 | NULL,
|
---|
551 | &NumberOfHandles,
|
---|
552 | &HandleBuffer
|
---|
553 | );
|
---|
554 | if (EFI_ERROR (Status)) {
|
---|
555 | goto ON_ERROR;
|
---|
556 | }
|
---|
557 |
|
---|
558 | //
|
---|
559 | // Find ExtScsiPassThru protocol instance produced by this driver.
|
---|
560 | //
|
---|
561 | ExistIScsiExtScsiPassThru = NULL;
|
---|
562 | for (Index = 0; Index < NumberOfHandles && ExistIScsiExtScsiPassThru == NULL; Index++) {
|
---|
563 | Status = gBS->HandleProtocol (
|
---|
564 | HandleBuffer[Index],
|
---|
565 | &gEfiDevicePathProtocolGuid,
|
---|
566 | (VOID **) &DevicePath
|
---|
567 | );
|
---|
568 | if (EFI_ERROR (Status)) {
|
---|
569 | continue;
|
---|
570 | }
|
---|
571 |
|
---|
572 | while (!IsDevicePathEnd (DevicePath)) {
|
---|
573 | if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType == MSG_MAC_ADDR_DP)) {
|
---|
574 | //
|
---|
575 | // Get the ExtScsiPassThru protocol instance.
|
---|
576 | //
|
---|
577 | Status = gBS->HandleProtocol (
|
---|
578 | HandleBuffer[Index],
|
---|
579 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
580 | (VOID **) &ExistIScsiExtScsiPassThru
|
---|
581 | );
|
---|
582 | ASSERT_EFI_ERROR (Status);
|
---|
583 | break;
|
---|
584 | }
|
---|
585 |
|
---|
586 | DevicePath = NextDevicePathNode (DevicePath);
|
---|
587 | }
|
---|
588 | }
|
---|
589 |
|
---|
590 | FreePool (HandleBuffer);
|
---|
591 |
|
---|
592 | if (ExistIScsiExtScsiPassThru == NULL) {
|
---|
593 | Status = EFI_NOT_FOUND;
|
---|
594 | goto ON_ERROR;
|
---|
595 | }
|
---|
596 |
|
---|
597 | ExistPrivate = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (ExistIScsiExtScsiPassThru);
|
---|
598 |
|
---|
599 | Status = gBS->UninstallProtocolInterface (
|
---|
600 | ExistPrivate->ExtScsiPassThruHandle,
|
---|
601 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
602 | &ExistPrivate->IScsiExtScsiPassThru
|
---|
603 | );
|
---|
604 | if (EFI_ERROR (Status)) {
|
---|
605 | goto ON_ERROR;
|
---|
606 | }
|
---|
607 | }
|
---|
608 |
|
---|
609 | //
|
---|
610 | // Install the Ext SCSI PASS THRU protocol.
|
---|
611 | //
|
---|
612 | Status = gBS->InstallProtocolInterface (
|
---|
613 | &Private->ExtScsiPassThruHandle,
|
---|
614 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
615 | EFI_NATIVE_INTERFACE,
|
---|
616 | &Private->IScsiExtScsiPassThru
|
---|
617 | );
|
---|
618 | if (EFI_ERROR (Status)) {
|
---|
619 | goto ON_ERROR;
|
---|
620 | }
|
---|
621 |
|
---|
622 | BootSelected = 0;
|
---|
623 |
|
---|
624 | NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mPrivate->AttemptConfigs) {
|
---|
625 | AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
|
---|
626 | //
|
---|
627 | // Don't process the attempt that does not associate with the current NIC or
|
---|
628 | // this attempt is disabled or established.
|
---|
629 | //
|
---|
630 | if (AttemptConfigData->NicIndex != mPrivate->CurrentNic ||
|
---|
631 | AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED ||
|
---|
632 | AttemptConfigData->ValidPath) {
|
---|
633 | continue;
|
---|
634 | }
|
---|
635 |
|
---|
636 | //
|
---|
637 | // In multipath mode, don't process attempts configured for single path.
|
---|
638 | // In default single path mode, don't process attempts configured for multipath.
|
---|
639 | //
|
---|
640 | if ((mPrivate->EnableMpio &&
|
---|
641 | AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO) ||
|
---|
642 | (!mPrivate->EnableMpio &&
|
---|
643 | AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)) {
|
---|
644 | continue;
|
---|
645 | }
|
---|
646 |
|
---|
647 | //
|
---|
648 | // Don't process the attempt that fails to get the init/target information from DHCP.
|
---|
649 | //
|
---|
650 | if (AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp &&
|
---|
651 | !AttemptConfigData->DhcpSuccess) {
|
---|
652 | if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
|
---|
653 | mPrivate->ValidSinglePathCount--;
|
---|
654 | }
|
---|
655 | continue;
|
---|
656 | }
|
---|
657 |
|
---|
658 | //
|
---|
659 | // Don't process the autoconfigure path if it is already established.
|
---|
660 | //
|
---|
661 | if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
|
---|
662 | AttemptConfigData->AutoConfigureSuccess) {
|
---|
663 | continue;
|
---|
664 | }
|
---|
665 |
|
---|
666 | //
|
---|
667 | // Don't process the attempt if its IP mode is not in the current IP version.
|
---|
668 | //
|
---|
669 | if (!mPrivate->Ipv6Flag) {
|
---|
670 | if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) {
|
---|
671 | continue;
|
---|
672 | }
|
---|
673 | if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
|
---|
674 | AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) {
|
---|
675 | continue;
|
---|
676 | }
|
---|
677 | } else {
|
---|
678 | if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) {
|
---|
679 | continue;
|
---|
680 | }
|
---|
681 | if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
|
---|
682 | AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4) {
|
---|
683 | continue;
|
---|
684 | }
|
---|
685 | }
|
---|
686 |
|
---|
687 | //
|
---|
688 | // Fill in the Session and init it.
|
---|
689 | //
|
---|
690 | Session = (ISCSI_SESSION *) AllocateZeroPool (sizeof (ISCSI_SESSION));
|
---|
691 | if (Session == NULL) {
|
---|
692 | Status = EFI_OUT_OF_RESOURCES;
|
---|
693 | goto ON_ERROR;
|
---|
694 | }
|
---|
695 |
|
---|
696 | Session->Private = Private;
|
---|
697 | Session->ConfigData = AttemptConfigData;
|
---|
698 | Session->AuthType = AttemptConfigData->AuthenticationType;
|
---|
699 |
|
---|
700 | UnicodeSPrint (
|
---|
701 | mPrivate->PortString,
|
---|
702 | (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
|
---|
703 | L"Attempt %d",
|
---|
704 | (UINTN) AttemptConfigData->AttemptConfigIndex
|
---|
705 | );
|
---|
706 |
|
---|
707 | if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
|
---|
708 | Session->AuthData.CHAP.AuthConfig = &AttemptConfigData->AuthConfigData.CHAP;
|
---|
709 | }
|
---|
710 |
|
---|
711 | IScsiSessionInit (Session, FALSE);
|
---|
712 |
|
---|
713 | //
|
---|
714 | // Try to login and create an iSCSI session according to the configuration.
|
---|
715 | //
|
---|
716 | Status = IScsiSessionLogin (Session);
|
---|
717 | if (Status == EFI_MEDIA_CHANGED) {
|
---|
718 | //
|
---|
719 | // The specified target is not available, and the redirection information is
|
---|
720 | // received. Login the session again with the updated target address.
|
---|
721 | //
|
---|
722 | Status = IScsiSessionLogin (Session);
|
---|
723 | } else if (Status == EFI_NOT_READY) {
|
---|
724 | Status = IScsiSessionReLogin (Session);
|
---|
725 | }
|
---|
726 |
|
---|
727 | //
|
---|
728 | // Restore the origial user setting which specifies the proxy/virtual iSCSI target to NV region.
|
---|
729 | //
|
---|
730 | NvData = &AttemptConfigData->SessionConfigData;
|
---|
731 | if (NvData->RedirectFlag) {
|
---|
732 | NvData->TargetPort = NvData->OriginalTargetPort;
|
---|
733 | CopyMem (&NvData->TargetIp, &NvData->OriginalTargetIp, sizeof (EFI_IP_ADDRESS));
|
---|
734 | NvData->RedirectFlag = FALSE;
|
---|
735 |
|
---|
736 | gRT->SetVariable (
|
---|
737 | mPrivate->PortString,
|
---|
738 | &gEfiIScsiInitiatorNameProtocolGuid,
|
---|
739 | ISCSI_CONFIG_VAR_ATTR,
|
---|
740 | sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
|
---|
741 | AttemptConfigData
|
---|
742 | );
|
---|
743 | }
|
---|
744 |
|
---|
745 | if (EFI_ERROR (Status)) {
|
---|
746 | //
|
---|
747 | // In Single path mode, only the successful attempt will be recorded in iBFT;
|
---|
748 | // in multi-path mode, all the attempt entries in MPIO will be recorded in iBFT.
|
---|
749 | //
|
---|
750 | if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
|
---|
751 | mPrivate->ValidSinglePathCount--;
|
---|
752 | }
|
---|
753 |
|
---|
754 | FreePool (Session);
|
---|
755 |
|
---|
756 | } else {
|
---|
757 | AttemptConfigData->ValidPath = TRUE;
|
---|
758 |
|
---|
759 | //
|
---|
760 | // Do not record the attempt in iBFT if it login with KRB5.
|
---|
761 | // TODO: record KRB5 attempt information in the iSCSI device path.
|
---|
762 | //
|
---|
763 | if (Session->AuthType == ISCSI_AUTH_TYPE_KRB) {
|
---|
764 | if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
|
---|
765 | mPrivate->ValidSinglePathCount--;
|
---|
766 | }
|
---|
767 |
|
---|
768 | AttemptConfigData->ValidiBFTPath = FALSE;
|
---|
769 | } else {
|
---|
770 | AttemptConfigData->ValidiBFTPath = TRUE;
|
---|
771 | }
|
---|
772 |
|
---|
773 | //
|
---|
774 | // IScsi session success. Update the attempt state to NVR.
|
---|
775 | //
|
---|
776 | if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) {
|
---|
777 | AttemptConfigData->AutoConfigureSuccess = TRUE;
|
---|
778 | }
|
---|
779 |
|
---|
780 | gRT->SetVariable (
|
---|
781 | mPrivate->PortString,
|
---|
782 | &gEfiIScsiInitiatorNameProtocolGuid,
|
---|
783 | ISCSI_CONFIG_VAR_ATTR,
|
---|
784 | sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
|
---|
785 | AttemptConfigData
|
---|
786 | );
|
---|
787 |
|
---|
788 | //
|
---|
789 | // Select the first login session. Abort others.
|
---|
790 | //
|
---|
791 | if (Private->Session == NULL) {
|
---|
792 | Private->Session = Session;
|
---|
793 | BootSelected = AttemptConfigData->AttemptConfigIndex;
|
---|
794 | //
|
---|
795 | // Don't validate other attempt in multipath mode if one is success.
|
---|
796 | //
|
---|
797 | if (mPrivate->EnableMpio) {
|
---|
798 | break;
|
---|
799 | }
|
---|
800 | } else {
|
---|
801 | IScsiSessionAbort (Session);
|
---|
802 | FreePool (Session);
|
---|
803 | }
|
---|
804 | }
|
---|
805 | }
|
---|
806 |
|
---|
807 | //
|
---|
808 | // All attempts configured for this driver instance are not valid.
|
---|
809 | //
|
---|
810 | if (Private->Session == NULL) {
|
---|
811 | Status = gBS->UninstallProtocolInterface (
|
---|
812 | Private->ExtScsiPassThruHandle,
|
---|
813 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
814 | &Private->IScsiExtScsiPassThru
|
---|
815 | );
|
---|
816 | ASSERT_EFI_ERROR (Status);
|
---|
817 | Private->ExtScsiPassThruHandle = NULL;
|
---|
818 |
|
---|
819 | //
|
---|
820 | // Reinstall the original ExtScsiPassThru back.
|
---|
821 | //
|
---|
822 | if (mPrivate->OneSessionEstablished && ExistPrivate != NULL) {
|
---|
823 | Status = gBS->InstallProtocolInterface (
|
---|
824 | &ExistPrivate->ExtScsiPassThruHandle,
|
---|
825 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
826 | EFI_NATIVE_INTERFACE,
|
---|
827 | &ExistPrivate->IScsiExtScsiPassThru
|
---|
828 | );
|
---|
829 | if (EFI_ERROR (Status)) {
|
---|
830 | goto ON_ERROR;
|
---|
831 | }
|
---|
832 |
|
---|
833 | goto ON_EXIT;
|
---|
834 | }
|
---|
835 |
|
---|
836 | Status = EFI_NOT_FOUND;
|
---|
837 |
|
---|
838 | goto ON_ERROR;
|
---|
839 | }
|
---|
840 |
|
---|
841 | NeedUpdate = TRUE;
|
---|
842 | //
|
---|
843 | // More than one attempt successes.
|
---|
844 | //
|
---|
845 | if (Private->Session != NULL && mPrivate->OneSessionEstablished) {
|
---|
846 |
|
---|
847 | AttemptConfigOrder = IScsiGetVariableAndSize (
|
---|
848 | L"AttemptOrder",
|
---|
849 | &gIScsiConfigGuid,
|
---|
850 | &AttemptConfigOrderSize
|
---|
851 | );
|
---|
852 | if (AttemptConfigOrder == NULL) {
|
---|
853 | goto ON_ERROR;
|
---|
854 | }
|
---|
855 | for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
|
---|
856 | if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex ||
|
---|
857 | AttemptConfigOrder[Index] == BootSelected) {
|
---|
858 | break;
|
---|
859 | }
|
---|
860 | }
|
---|
861 |
|
---|
862 | if (mPrivate->EnableMpio) {
|
---|
863 | //
|
---|
864 | // Use the attempt in earlier order. Abort the later one in MPIO.
|
---|
865 | //
|
---|
866 | if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex) {
|
---|
867 | IScsiSessionAbort (Private->Session);
|
---|
868 | FreePool (Private->Session);
|
---|
869 | Private->Session = NULL;
|
---|
870 | gBS->UninstallProtocolInterface (
|
---|
871 | Private->ExtScsiPassThruHandle,
|
---|
872 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
873 | &Private->IScsiExtScsiPassThru
|
---|
874 | );
|
---|
875 | Private->ExtScsiPassThruHandle = NULL;
|
---|
876 |
|
---|
877 | //
|
---|
878 | // Reinstall the original ExtScsiPassThru back.
|
---|
879 | //
|
---|
880 | Status = gBS->InstallProtocolInterface (
|
---|
881 | &ExistPrivate->ExtScsiPassThruHandle,
|
---|
882 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
883 | EFI_NATIVE_INTERFACE,
|
---|
884 | &ExistPrivate->IScsiExtScsiPassThru
|
---|
885 | );
|
---|
886 | if (EFI_ERROR (Status)) {
|
---|
887 | goto ON_ERROR;
|
---|
888 | }
|
---|
889 |
|
---|
890 | goto ON_EXIT;
|
---|
891 | } else {
|
---|
892 | if (AttemptConfigOrder[Index] != BootSelected) {
|
---|
893 | goto ON_ERROR;
|
---|
894 | }
|
---|
895 | mPrivate->BootSelectedIndex = BootSelected;
|
---|
896 | //
|
---|
897 | // Clear the resource in ExistPrivate.
|
---|
898 | //
|
---|
899 | gBS->UninstallProtocolInterface (
|
---|
900 | ExistPrivate->Controller,
|
---|
901 | IScsiPrivateGuid,
|
---|
902 | &ExistPrivate->IScsiIdentifier
|
---|
903 | );
|
---|
904 |
|
---|
905 | IScsiRemoveNic (ExistPrivate->Controller);
|
---|
906 | if (ExistPrivate->Session != NULL) {
|
---|
907 | IScsiSessionAbort (ExistPrivate->Session);
|
---|
908 | }
|
---|
909 |
|
---|
910 | if (ExistPrivate->DevicePath != NULL) {
|
---|
911 | Status = gBS->UninstallProtocolInterface (
|
---|
912 | ExistPrivate->ExtScsiPassThruHandle,
|
---|
913 | &gEfiDevicePathProtocolGuid,
|
---|
914 | ExistPrivate->DevicePath
|
---|
915 | );
|
---|
916 | if (EFI_ERROR (Status)) {
|
---|
917 | goto ON_ERROR;
|
---|
918 | }
|
---|
919 |
|
---|
920 | FreePool (ExistPrivate->DevicePath);
|
---|
921 | }
|
---|
922 |
|
---|
923 | gBS->CloseEvent (ExistPrivate->ExitBootServiceEvent);
|
---|
924 | FreePool (ExistPrivate);
|
---|
925 |
|
---|
926 | }
|
---|
927 | } else {
|
---|
928 | //
|
---|
929 | // Use the attempt in earlier order as boot selected in single path mode.
|
---|
930 | //
|
---|
931 | if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex) {
|
---|
932 | NeedUpdate = FALSE;
|
---|
933 | }
|
---|
934 | }
|
---|
935 |
|
---|
936 | }
|
---|
937 |
|
---|
938 | if (NeedUpdate) {
|
---|
939 | mPrivate->OneSessionEstablished = TRUE;
|
---|
940 | mPrivate->BootSelectedIndex = BootSelected;
|
---|
941 | }
|
---|
942 |
|
---|
943 | //
|
---|
944 | // Duplicate the Session's tcp connection device path. The source port field
|
---|
945 | // will be set to zero as one iSCSI session is comprised of several iSCSI
|
---|
946 | // connections.
|
---|
947 | //
|
---|
948 | Private->DevicePath = IScsiGetTcpConnDevicePath (Private->Session);
|
---|
949 | if (Private->DevicePath == NULL) {
|
---|
950 | Status = EFI_DEVICE_ERROR;
|
---|
951 | goto ON_ERROR;
|
---|
952 | }
|
---|
953 | //
|
---|
954 | // Install the updated device path onto the ExtScsiPassThruHandle.
|
---|
955 | //
|
---|
956 | Status = gBS->InstallProtocolInterface (
|
---|
957 | &Private->ExtScsiPassThruHandle,
|
---|
958 | &gEfiDevicePathProtocolGuid,
|
---|
959 | EFI_NATIVE_INTERFACE,
|
---|
960 | Private->DevicePath
|
---|
961 | );
|
---|
962 | if (EFI_ERROR (Status)) {
|
---|
963 | goto ON_ERROR;
|
---|
964 | }
|
---|
965 |
|
---|
966 | //
|
---|
967 | // ISCSI children should share the default Tcp child, just open the default Tcp child via BY_CHILD_CONTROLLER.
|
---|
968 | //
|
---|
969 | Status = gBS->OpenProtocol (
|
---|
970 | Private->ChildHandle, /// Default Tcp child
|
---|
971 | ProtocolGuid,
|
---|
972 | &Interface,
|
---|
973 | Image,
|
---|
974 | Private->ExtScsiPassThruHandle,
|
---|
975 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
---|
976 | );
|
---|
977 | if (EFI_ERROR (Status)) {
|
---|
978 | gBS->UninstallMultipleProtocolInterfaces (
|
---|
979 | Private->ExtScsiPassThruHandle,
|
---|
980 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
981 | &Private->IScsiExtScsiPassThru,
|
---|
982 | &gEfiDevicePathProtocolGuid,
|
---|
983 | Private->DevicePath,
|
---|
984 | NULL
|
---|
985 | );
|
---|
986 |
|
---|
987 | goto ON_ERROR;
|
---|
988 | }
|
---|
989 |
|
---|
990 | ON_EXIT:
|
---|
991 |
|
---|
992 | //
|
---|
993 | // Update/Publish the iSCSI Boot Firmware Table.
|
---|
994 | //
|
---|
995 | if (mPrivate->BootSelectedIndex != 0) {
|
---|
996 | IScsiPublishIbft ();
|
---|
997 | }
|
---|
998 |
|
---|
999 | return EFI_SUCCESS;
|
---|
1000 |
|
---|
1001 | ON_ERROR:
|
---|
1002 |
|
---|
1003 | if (Private->Session != NULL) {
|
---|
1004 | IScsiSessionAbort (Private->Session);
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | return Status;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | /**
|
---|
1011 | Stops a device controller or a bus controller. This is the worker function for
|
---|
1012 | IScsiIp4(6)DriverBindingStop.
|
---|
1013 |
|
---|
1014 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
1015 | @param[in] ControllerHandle A handle to the device being stopped. The handle must
|
---|
1016 | support a bus specific I/O protocol for the driver
|
---|
1017 | to use to stop the device.
|
---|
1018 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
|
---|
1019 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
|
---|
1020 | if NumberOfChildren is 0.
|
---|
1021 | @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
|
---|
1022 |
|
---|
1023 | @retval EFI_SUCCESS The device was stopped.
|
---|
1024 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
---|
1025 | @retval EFI_INVALID_PARAMETER Child handle is NULL.
|
---|
1026 | @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle
|
---|
1027 | because its interfaces are being used.
|
---|
1028 |
|
---|
1029 | **/
|
---|
1030 | EFI_STATUS
|
---|
1031 | EFIAPI
|
---|
1032 | IScsiStop (
|
---|
1033 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
1034 | IN EFI_HANDLE ControllerHandle,
|
---|
1035 | IN UINTN NumberOfChildren,
|
---|
1036 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL,
|
---|
1037 | IN UINT8 IpVersion
|
---|
1038 | )
|
---|
1039 | {
|
---|
1040 | EFI_HANDLE IScsiController;
|
---|
1041 | EFI_STATUS Status;
|
---|
1042 | ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
|
---|
1043 | ISCSI_DRIVER_DATA *Private;
|
---|
1044 | EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
|
---|
1045 | ISCSI_CONNECTION *Conn;
|
---|
1046 | EFI_GUID *ProtocolGuid;
|
---|
1047 | EFI_GUID *TcpServiceBindingGuid;
|
---|
1048 | EFI_GUID *TcpProtocolGuid;
|
---|
1049 |
|
---|
1050 |
|
---|
1051 | if (NumberOfChildren != 0) {
|
---|
1052 | //
|
---|
1053 | // We should have only one child.
|
---|
1054 | //
|
---|
1055 | Status = gBS->OpenProtocol (
|
---|
1056 | ChildHandleBuffer[0],
|
---|
1057 | &gEfiExtScsiPassThruProtocolGuid,
|
---|
1058 | (VOID **) &PassThru,
|
---|
1059 | This->DriverBindingHandle,
|
---|
1060 | ControllerHandle,
|
---|
1061 | EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
---|
1062 | );
|
---|
1063 | if (EFI_ERROR (Status)) {
|
---|
1064 | return EFI_DEVICE_ERROR;
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
|
---|
1068 | Conn = NET_LIST_HEAD (&Private->Session->Conns, ISCSI_CONNECTION, Link);
|
---|
1069 |
|
---|
1070 | //
|
---|
1071 | // Previously the TCP protocol is opened BY_CHILD_CONTROLLER. Just close
|
---|
1072 | // the protocol here, but do not uninstall the device path protocol and
|
---|
1073 | // EXT SCSI PASS THRU protocol installed on ExtScsiPassThruHandle.
|
---|
1074 | //
|
---|
1075 | if (IpVersion == IP_VERSION_4) {
|
---|
1076 | ProtocolGuid = &gEfiTcp4ProtocolGuid;
|
---|
1077 | } else {
|
---|
1078 | ProtocolGuid = &gEfiTcp6ProtocolGuid;
|
---|
1079 | }
|
---|
1080 |
|
---|
1081 | gBS->CloseProtocol (
|
---|
1082 | Private->ChildHandle,
|
---|
1083 | ProtocolGuid,
|
---|
1084 | Private->Image,
|
---|
1085 | Private->ExtScsiPassThruHandle
|
---|
1086 | );
|
---|
1087 |
|
---|
1088 | gBS->CloseProtocol (
|
---|
1089 | Conn->TcpIo.Handle,
|
---|
1090 | ProtocolGuid,
|
---|
1091 | Private->Image,
|
---|
1092 | Private->ExtScsiPassThruHandle
|
---|
1093 | );
|
---|
1094 |
|
---|
1095 | return EFI_SUCCESS;
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 | //
|
---|
1099 | // Get the handle of the controller we are controling.
|
---|
1100 | //
|
---|
1101 | if (IpVersion == IP_VERSION_4) {
|
---|
1102 | ProtocolGuid = &gIScsiV4PrivateGuid;
|
---|
1103 | TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
|
---|
1104 | TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
---|
1105 | } else {
|
---|
1106 | ProtocolGuid = &gIScsiV6PrivateGuid;
|
---|
1107 | TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
|
---|
1108 | TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
---|
1109 | }
|
---|
1110 | IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
|
---|
1111 | if (IScsiController == NULL) {
|
---|
1112 | return EFI_SUCCESS;
|
---|
1113 | }
|
---|
1114 |
|
---|
1115 | Status = gBS->OpenProtocol (
|
---|
1116 | IScsiController,
|
---|
1117 | ProtocolGuid,
|
---|
1118 | (VOID **) &IScsiIdentifier,
|
---|
1119 | This->DriverBindingHandle,
|
---|
1120 | ControllerHandle,
|
---|
1121 | EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
---|
1122 | );
|
---|
1123 | if (EFI_ERROR (Status)) {
|
---|
1124 | return EFI_DEVICE_ERROR;
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | Private = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);
|
---|
1128 | ASSERT (Private != NULL);
|
---|
1129 |
|
---|
1130 | if (Private->ChildHandle != NULL) {
|
---|
1131 | Status = gBS->CloseProtocol (
|
---|
1132 | Private->ChildHandle,
|
---|
1133 | TcpProtocolGuid,
|
---|
1134 | This->DriverBindingHandle,
|
---|
1135 | IScsiController
|
---|
1136 | );
|
---|
1137 |
|
---|
1138 | ASSERT (!EFI_ERROR (Status));
|
---|
1139 |
|
---|
1140 | Status = NetLibDestroyServiceChild (
|
---|
1141 | IScsiController,
|
---|
1142 | This->DriverBindingHandle,
|
---|
1143 | TcpServiceBindingGuid,
|
---|
1144 | Private->ChildHandle
|
---|
1145 | );
|
---|
1146 |
|
---|
1147 | ASSERT (!EFI_ERROR (Status));
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | gBS->UninstallProtocolInterface (
|
---|
1151 | IScsiController,
|
---|
1152 | ProtocolGuid,
|
---|
1153 | &Private->IScsiIdentifier
|
---|
1154 | );
|
---|
1155 |
|
---|
1156 | //
|
---|
1157 | // Remove this NIC.
|
---|
1158 | //
|
---|
1159 | IScsiRemoveNic (IScsiController);
|
---|
1160 |
|
---|
1161 | //
|
---|
1162 | // Update the iSCSI Boot Firware Table.
|
---|
1163 | //
|
---|
1164 | IScsiPublishIbft ();
|
---|
1165 |
|
---|
1166 | if (Private->Session != NULL) {
|
---|
1167 | IScsiSessionAbort (Private->Session);
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | Status = IScsiCleanDriverData (Private);
|
---|
1171 |
|
---|
1172 | if (EFI_ERROR (Status)) {
|
---|
1173 | return Status;
|
---|
1174 | }
|
---|
1175 |
|
---|
1176 | return EFI_SUCCESS;
|
---|
1177 | }
|
---|
1178 |
|
---|
1179 | /**
|
---|
1180 | Tests to see if this driver supports a given controller. If a child device is provided,
|
---|
1181 | it tests to see if this driver supports creating a handle for the specified child device.
|
---|
1182 |
|
---|
1183 | This function checks to see if the driver specified by This supports the device specified by
|
---|
1184 | ControllerHandle. Drivers typically use the device path attached to
|
---|
1185 | ControllerHandle and/or the services from the bus I/O abstraction attached to
|
---|
1186 | ControllerHandle to determine if the driver supports ControllerHandle. This function
|
---|
1187 | may be called many times during platform initialization. In order to reduce boot times, the tests
|
---|
1188 | performed by this function must be very small and take as little time as possible to execute. This
|
---|
1189 | function must not change the state of any hardware devices, and this function must be aware that the
|
---|
1190 | device specified by ControllerHandle may already be managed by the same driver or a
|
---|
1191 | different driver. This function must match its calls to AllocatePages() with FreePages(),
|
---|
1192 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
|
---|
1193 | Since ControllerHandle may have been previously started by the same driver, if a protocol is
|
---|
1194 | already in the opened state, then it must not be closed with CloseProtocol(). This is required
|
---|
1195 | to guarantee the state of ControllerHandle is not modified by this function.
|
---|
1196 |
|
---|
1197 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
1198 | @param[in] ControllerHandle The handle of the controller to test. This handle
|
---|
1199 | must support a protocol interface that supplies
|
---|
1200 | an I/O abstraction to the driver.
|
---|
1201 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
---|
1202 | parameter is ignored by device drivers, and is optional for bus
|
---|
1203 | drivers. For bus drivers, if this parameter is not NULL, then
|
---|
1204 | the bus driver must determine if the bus controller specified
|
---|
1205 | by ControllerHandle and the child controller specified
|
---|
1206 | by RemainingDevicePath are both supported by this
|
---|
1207 | bus driver.
|
---|
1208 |
|
---|
1209 | @retval EFI_SUCCESS The device specified by ControllerHandle and
|
---|
1210 | RemainingDevicePath is supported by the driver specified by This.
|
---|
1211 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
|
---|
1212 | RemainingDevicePath is already managed by the driver
|
---|
1213 | specified by This.
|
---|
1214 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
|
---|
1215 | RemainingDevicePath is already managed by a different
|
---|
1216 | driver or an application that requires exclusive access.
|
---|
1217 | Currently not implemented.
|
---|
1218 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
|
---|
1219 | RemainingDevicePath is not supported by the driver specified by This.
|
---|
1220 | **/
|
---|
1221 | EFI_STATUS
|
---|
1222 | EFIAPI
|
---|
1223 | IScsiIp4DriverBindingSupported (
|
---|
1224 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
1225 | IN EFI_HANDLE ControllerHandle,
|
---|
1226 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
---|
1227 | )
|
---|
1228 | {
|
---|
1229 | return IScsiSupported (
|
---|
1230 | This,
|
---|
1231 | ControllerHandle,
|
---|
1232 | RemainingDevicePath,
|
---|
1233 | IP_VERSION_4
|
---|
1234 | );
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | /**
|
---|
1238 | Starts a device controller or a bus controller.
|
---|
1239 |
|
---|
1240 | The Start() function is designed to be invoked from the EFI boot service ConnectController().
|
---|
1241 | As a result, much of the error checking on the parameters to Start() has been moved into this
|
---|
1242 | common boot service. It is legal to call Start() from other locations,
|
---|
1243 | but the following calling restrictions must be followed or the system behavior will not be deterministic.
|
---|
1244 | 1. ControllerHandle must be a valid EFI_HANDLE.
|
---|
1245 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
|
---|
1246 | EFI_DEVICE_PATH_PROTOCOL.
|
---|
1247 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must
|
---|
1248 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
|
---|
1249 |
|
---|
1250 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
1251 | @param[in] ControllerHandle The handle of the controller to start. This handle
|
---|
1252 | must support a protocol interface that supplies
|
---|
1253 | an I/O abstraction to the driver.
|
---|
1254 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
---|
1255 | parameter is ignored by device drivers, and is optional for bus
|
---|
1256 | drivers. For a bus driver, if this parameter is NULL, then handles
|
---|
1257 | for all the children of Controller are created by this driver.
|
---|
1258 | If this parameter is not NULL and the first Device Path Node is
|
---|
1259 | not the End of Device Path Node, then only the handle for the
|
---|
1260 | child device specified by the first Device Path Node of
|
---|
1261 | RemainingDevicePath is created by this driver.
|
---|
1262 | If the first Device Path Node of RemainingDevicePath is
|
---|
1263 | the End of Device Path Node, no child handle is created by this
|
---|
1264 | driver.
|
---|
1265 |
|
---|
1266 | @retval EFI_SUCCESS The device was started.
|
---|
1267 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented.
|
---|
1268 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
---|
1269 | @retval Others The driver failed to start the device.
|
---|
1270 |
|
---|
1271 | **/
|
---|
1272 | EFI_STATUS
|
---|
1273 | EFIAPI
|
---|
1274 | IScsiIp4DriverBindingStart (
|
---|
1275 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
1276 | IN EFI_HANDLE ControllerHandle,
|
---|
1277 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
---|
1278 | )
|
---|
1279 | {
|
---|
1280 | EFI_STATUS Status;
|
---|
1281 |
|
---|
1282 | Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4);
|
---|
1283 | if (Status == EFI_ALREADY_STARTED) {
|
---|
1284 | Status = EFI_SUCCESS;
|
---|
1285 | }
|
---|
1286 |
|
---|
1287 | return Status;
|
---|
1288 | }
|
---|
1289 |
|
---|
1290 | /**
|
---|
1291 | Stops a device controller or a bus controller.
|
---|
1292 |
|
---|
1293 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
|
---|
1294 | As a result, much of the error checking on the parameters to Stop() has been moved
|
---|
1295 | into this common boot service. It is legal to call Stop() from other locations,
|
---|
1296 | but the following calling restrictions must be followed or the system behavior will not be deterministic.
|
---|
1297 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
|
---|
1298 | same driver's Start() function.
|
---|
1299 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
|
---|
1300 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's
|
---|
1301 | Start() function, and the Start() function must have called OpenProtocol() on
|
---|
1302 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
|
---|
1303 |
|
---|
1304 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
1305 | @param[in] ControllerHandle A handle to the device being stopped. The handle must
|
---|
1306 | support a bus specific I/O protocol for the driver
|
---|
1307 | to use to stop the device.
|
---|
1308 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
|
---|
1309 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
|
---|
1310 | if NumberOfChildren is 0.
|
---|
1311 |
|
---|
1312 | @retval EFI_SUCCESS The device was stopped.
|
---|
1313 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
---|
1314 |
|
---|
1315 | **/
|
---|
1316 | EFI_STATUS
|
---|
1317 | EFIAPI
|
---|
1318 | IScsiIp4DriverBindingStop (
|
---|
1319 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
1320 | IN EFI_HANDLE ControllerHandle,
|
---|
1321 | IN UINTN NumberOfChildren,
|
---|
1322 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
|
---|
1323 | )
|
---|
1324 | {
|
---|
1325 | return IScsiStop (
|
---|
1326 | This,
|
---|
1327 | ControllerHandle,
|
---|
1328 | NumberOfChildren,
|
---|
1329 | ChildHandleBuffer,
|
---|
1330 | IP_VERSION_4
|
---|
1331 | );
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | /**
|
---|
1335 | Tests to see if this driver supports a given controller. If a child device is provided,
|
---|
1336 | it tests to see if this driver supports creating a handle for the specified child device.
|
---|
1337 |
|
---|
1338 | This function checks to see if the driver specified by This supports the device specified by
|
---|
1339 | ControllerHandle. Drivers typically use the device path attached to
|
---|
1340 | ControllerHandle and/or the services from the bus I/O abstraction attached to
|
---|
1341 | ControllerHandle to determine if the driver supports ControllerHandle. This function
|
---|
1342 | may be called many times during platform initialization. In order to reduce boot times, the tests
|
---|
1343 | performed by this function must be very small and take as little time as possible to execute. This
|
---|
1344 | function must not change the state of any hardware devices, and this function must be aware that the
|
---|
1345 | device specified by ControllerHandle may already be managed by the same driver or a
|
---|
1346 | different driver. This function must match its calls to AllocatePages() with FreePages(),
|
---|
1347 | AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
|
---|
1348 | Since ControllerHandle may have been previously started by the same driver, if a protocol is
|
---|
1349 | already in the opened state, then it must not be closed with CloseProtocol(). This is required
|
---|
1350 | to guarantee the state of ControllerHandle is not modified by this function.
|
---|
1351 |
|
---|
1352 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
1353 | @param[in] ControllerHandle The handle of the controller to test. This handle
|
---|
1354 | must support a protocol interface that supplies
|
---|
1355 | an I/O abstraction to the driver.
|
---|
1356 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
---|
1357 | parameter is ignored by device drivers, and is optional for bus
|
---|
1358 | drivers. For bus drivers, if this parameter is not NULL, then
|
---|
1359 | the bus driver must determine if the bus controller specified
|
---|
1360 | by ControllerHandle and the child controller specified
|
---|
1361 | by RemainingDevicePath are both supported by this
|
---|
1362 | bus driver.
|
---|
1363 |
|
---|
1364 | @retval EFI_SUCCESS The device specified by ControllerHandle and
|
---|
1365 | RemainingDevicePath is supported by the driver specified by This.
|
---|
1366 | @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
|
---|
1367 | RemainingDevicePath is already managed by the driver
|
---|
1368 | specified by This.
|
---|
1369 | @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
|
---|
1370 | RemainingDevicePath is already managed by a different
|
---|
1371 | driver or an application that requires exclusive access.
|
---|
1372 | Currently not implemented.
|
---|
1373 | @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
|
---|
1374 | RemainingDevicePath is not supported by the driver specified by This.
|
---|
1375 | **/
|
---|
1376 | EFI_STATUS
|
---|
1377 | EFIAPI
|
---|
1378 | IScsiIp6DriverBindingSupported (
|
---|
1379 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
1380 | IN EFI_HANDLE ControllerHandle,
|
---|
1381 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
---|
1382 | )
|
---|
1383 | {
|
---|
1384 | return IScsiSupported (
|
---|
1385 | This,
|
---|
1386 | ControllerHandle,
|
---|
1387 | RemainingDevicePath,
|
---|
1388 | IP_VERSION_6
|
---|
1389 | );
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | /**
|
---|
1393 | Starts a device controller or a bus controller.
|
---|
1394 |
|
---|
1395 | The Start() function is designed to be invoked from the EFI boot service ConnectController().
|
---|
1396 | As a result, much of the error checking on the parameters to Start() has been moved into this
|
---|
1397 | common boot service. It is legal to call Start() from other locations,
|
---|
1398 | but the following calling restrictions must be followed or the system behavior will not be deterministic.
|
---|
1399 | 1. ControllerHandle must be a valid EFI_HANDLE.
|
---|
1400 | 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
|
---|
1401 | EFI_DEVICE_PATH_PROTOCOL.
|
---|
1402 | 3. Prior to calling Start(), the Supported() function for the driver specified by This must
|
---|
1403 | have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
|
---|
1404 |
|
---|
1405 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
1406 | @param[in] ControllerHandle The handle of the controller to start. This handle
|
---|
1407 | must support a protocol interface that supplies
|
---|
1408 | an I/O abstraction to the driver.
|
---|
1409 | @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
---|
1410 | parameter is ignored by device drivers, and is optional for bus
|
---|
1411 | drivers. For a bus driver, if this parameter is NULL, then handles
|
---|
1412 | for all the children of Controller are created by this driver.
|
---|
1413 | If this parameter is not NULL and the first Device Path Node is
|
---|
1414 | not the End of Device Path Node, then only the handle for the
|
---|
1415 | child device specified by the first Device Path Node of
|
---|
1416 | RemainingDevicePath is created by this driver.
|
---|
1417 | If the first Device Path Node of RemainingDevicePath is
|
---|
1418 | the End of Device Path Node, no child handle is created by this
|
---|
1419 | driver.
|
---|
1420 |
|
---|
1421 | @retval EFI_SUCCESS The device was started.
|
---|
1422 | @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented.
|
---|
1423 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
---|
1424 | @retval Others The driver failed to start the device.
|
---|
1425 |
|
---|
1426 | **/
|
---|
1427 | EFI_STATUS
|
---|
1428 | EFIAPI
|
---|
1429 | IScsiIp6DriverBindingStart (
|
---|
1430 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
1431 | IN EFI_HANDLE ControllerHandle,
|
---|
1432 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
---|
1433 | )
|
---|
1434 | {
|
---|
1435 | EFI_STATUS Status;
|
---|
1436 |
|
---|
1437 | Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
|
---|
1438 | if (Status == EFI_ALREADY_STARTED) {
|
---|
1439 | Status = EFI_SUCCESS;
|
---|
1440 | }
|
---|
1441 |
|
---|
1442 | return Status;
|
---|
1443 | }
|
---|
1444 |
|
---|
1445 | /**
|
---|
1446 | Stops a device controller or a bus controller.
|
---|
1447 |
|
---|
1448 | The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
|
---|
1449 | As a result, much of the error checking on the parameters to Stop() has been moved
|
---|
1450 | into this common boot service. It is legal to call Stop() from other locations,
|
---|
1451 | but the following calling restrictions must be followed or the system behavior will not be deterministic.
|
---|
1452 | 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
|
---|
1453 | same driver's Start() function.
|
---|
1454 | 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
|
---|
1455 | EFI_HANDLE. In addition, all of these handles must have been created in this driver's
|
---|
1456 | Start() function, and the Start() function must have called OpenProtocol() on
|
---|
1457 | ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
|
---|
1458 |
|
---|
1459 | @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
---|
1460 | @param[in] ControllerHandle A handle to the device being stopped. The handle must
|
---|
1461 | support a bus specific I/O protocol for the driver
|
---|
1462 | to use to stop the device.
|
---|
1463 | @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
|
---|
1464 | @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
|
---|
1465 | if NumberOfChildren is 0.
|
---|
1466 |
|
---|
1467 | @retval EFI_SUCCESS The device was stopped.
|
---|
1468 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
---|
1469 |
|
---|
1470 | **/
|
---|
1471 | EFI_STATUS
|
---|
1472 | EFIAPI
|
---|
1473 | IScsiIp6DriverBindingStop (
|
---|
1474 | IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
---|
1475 | IN EFI_HANDLE ControllerHandle,
|
---|
1476 | IN UINTN NumberOfChildren,
|
---|
1477 | IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
|
---|
1478 | )
|
---|
1479 | {
|
---|
1480 | return IScsiStop (
|
---|
1481 | This,
|
---|
1482 | ControllerHandle,
|
---|
1483 | NumberOfChildren,
|
---|
1484 | ChildHandleBuffer,
|
---|
1485 | IP_VERSION_6
|
---|
1486 | );
|
---|
1487 | }
|
---|
1488 |
|
---|
1489 | /**
|
---|
1490 | Unload the iSCSI driver.
|
---|
1491 |
|
---|
1492 | @param[in] ImageHandle The handle of the driver image.
|
---|
1493 |
|
---|
1494 | @retval EFI_SUCCESS The driver is unloaded.
|
---|
1495 | @retval EFI_DEVICE_ERROR An unexpected error occurred.
|
---|
1496 |
|
---|
1497 | **/
|
---|
1498 | EFI_STATUS
|
---|
1499 | EFIAPI
|
---|
1500 | IScsiUnload (
|
---|
1501 | IN EFI_HANDLE ImageHandle
|
---|
1502 | )
|
---|
1503 | {
|
---|
1504 | EFI_STATUS Status;
|
---|
1505 | UINTN DeviceHandleCount;
|
---|
1506 | EFI_HANDLE *DeviceHandleBuffer;
|
---|
1507 | UINTN Index;
|
---|
1508 | EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
|
---|
1509 | EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
|
---|
1510 |
|
---|
1511 | //
|
---|
1512 | // Try to disonnect the driver from the devices it's controlling.
|
---|
1513 | //
|
---|
1514 | Status = gBS->LocateHandleBuffer (
|
---|
1515 | AllHandles,
|
---|
1516 | NULL,
|
---|
1517 | NULL,
|
---|
1518 | &DeviceHandleCount,
|
---|
1519 | &DeviceHandleBuffer
|
---|
1520 | );
|
---|
1521 | if (EFI_ERROR (Status)) {
|
---|
1522 | return Status;
|
---|
1523 | }
|
---|
1524 |
|
---|
1525 | //
|
---|
1526 | // Disconnect the iSCSI4 driver from the controlled device.
|
---|
1527 | //
|
---|
1528 | for (Index = 0; Index < DeviceHandleCount; Index++) {
|
---|
1529 | Status = IScsiTestManagedDevice (
|
---|
1530 | DeviceHandleBuffer[Index],
|
---|
1531 | gIScsiIp4DriverBinding.DriverBindingHandle,
|
---|
1532 | &gEfiTcp4ProtocolGuid)
|
---|
1533 | ;
|
---|
1534 | if (EFI_ERROR (Status)) {
|
---|
1535 | continue;
|
---|
1536 | }
|
---|
1537 | Status = gBS->DisconnectController (
|
---|
1538 | DeviceHandleBuffer[Index],
|
---|
1539 | gIScsiIp4DriverBinding.DriverBindingHandle,
|
---|
1540 | NULL
|
---|
1541 | );
|
---|
1542 | if (EFI_ERROR (Status)) {
|
---|
1543 | goto ON_EXIT;
|
---|
1544 | }
|
---|
1545 | }
|
---|
1546 |
|
---|
1547 | //
|
---|
1548 | // Disconnect the iSCSI6 driver from the controlled device.
|
---|
1549 | //
|
---|
1550 | for (Index = 0; Index < DeviceHandleCount; Index++) {
|
---|
1551 | Status = IScsiTestManagedDevice (
|
---|
1552 | DeviceHandleBuffer[Index],
|
---|
1553 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1554 | &gEfiTcp6ProtocolGuid
|
---|
1555 | );
|
---|
1556 | if (EFI_ERROR (Status)) {
|
---|
1557 | continue;
|
---|
1558 | }
|
---|
1559 | Status = gBS->DisconnectController (
|
---|
1560 | DeviceHandleBuffer[Index],
|
---|
1561 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1562 | NULL
|
---|
1563 | );
|
---|
1564 | if (EFI_ERROR (Status)) {
|
---|
1565 | goto ON_EXIT;
|
---|
1566 | }
|
---|
1567 | }
|
---|
1568 |
|
---|
1569 | //
|
---|
1570 | // Unload the iSCSI configuration form.
|
---|
1571 | //
|
---|
1572 | Status = IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
|
---|
1573 | if (EFI_ERROR (Status)) {
|
---|
1574 | goto ON_EXIT;
|
---|
1575 | }
|
---|
1576 |
|
---|
1577 | //
|
---|
1578 | // Uninstall the protocols installed by iSCSI driver.
|
---|
1579 | //
|
---|
1580 | Status = gBS->UninstallMultipleProtocolInterfaces (
|
---|
1581 | ImageHandle,
|
---|
1582 | &gEfiAuthenticationInfoProtocolGuid,
|
---|
1583 | &gIScsiAuthenticationInfo,
|
---|
1584 | NULL
|
---|
1585 | );
|
---|
1586 | if (EFI_ERROR (Status)) {
|
---|
1587 | goto ON_EXIT;
|
---|
1588 | }
|
---|
1589 |
|
---|
1590 | if (gIScsiControllerNameTable!= NULL) {
|
---|
1591 | Status = FreeUnicodeStringTable (gIScsiControllerNameTable);
|
---|
1592 | if (EFI_ERROR (Status)) {
|
---|
1593 | goto ON_EXIT;
|
---|
1594 | }
|
---|
1595 | gIScsiControllerNameTable = NULL;
|
---|
1596 | }
|
---|
1597 |
|
---|
1598 | //
|
---|
1599 | // Uninstall the ComponentName and ComponentName2 protocol from iSCSI4 driver binding handle
|
---|
1600 | // if it has been installed.
|
---|
1601 | //
|
---|
1602 | Status = gBS->HandleProtocol (
|
---|
1603 | gIScsiIp4DriverBinding.DriverBindingHandle,
|
---|
1604 | &gEfiComponentNameProtocolGuid,
|
---|
1605 | (VOID **) &ComponentName
|
---|
1606 | );
|
---|
1607 | if (!EFI_ERROR (Status)) {
|
---|
1608 | Status = gBS->UninstallMultipleProtocolInterfaces (
|
---|
1609 | gIScsiIp4DriverBinding.DriverBindingHandle,
|
---|
1610 | &gEfiComponentNameProtocolGuid,
|
---|
1611 | ComponentName,
|
---|
1612 | NULL
|
---|
1613 | );
|
---|
1614 | if (EFI_ERROR (Status)) {
|
---|
1615 | goto ON_EXIT;
|
---|
1616 | }
|
---|
1617 | }
|
---|
1618 |
|
---|
1619 | Status = gBS->HandleProtocol (
|
---|
1620 | gIScsiIp4DriverBinding.DriverBindingHandle,
|
---|
1621 | &gEfiComponentName2ProtocolGuid,
|
---|
1622 | (VOID **) &ComponentName2
|
---|
1623 | );
|
---|
1624 | if (!EFI_ERROR (Status)) {
|
---|
1625 | gBS->UninstallMultipleProtocolInterfaces (
|
---|
1626 | gIScsiIp4DriverBinding.DriverBindingHandle,
|
---|
1627 | &gEfiComponentName2ProtocolGuid,
|
---|
1628 | ComponentName2,
|
---|
1629 | NULL
|
---|
1630 | );
|
---|
1631 | if (EFI_ERROR (Status)) {
|
---|
1632 | goto ON_EXIT;
|
---|
1633 | }
|
---|
1634 | }
|
---|
1635 |
|
---|
1636 | //
|
---|
1637 | // Uninstall the ComponentName and ComponentName2 protocol from iSCSI6 driver binding handle
|
---|
1638 | // if it has been installed.
|
---|
1639 | //
|
---|
1640 | Status = gBS->HandleProtocol (
|
---|
1641 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1642 | &gEfiComponentNameProtocolGuid,
|
---|
1643 | (VOID **) &ComponentName
|
---|
1644 | );
|
---|
1645 | if (!EFI_ERROR (Status)) {
|
---|
1646 | Status = gBS->UninstallMultipleProtocolInterfaces (
|
---|
1647 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1648 | &gEfiComponentNameProtocolGuid,
|
---|
1649 | ComponentName,
|
---|
1650 | NULL
|
---|
1651 | );
|
---|
1652 | if (EFI_ERROR (Status)) {
|
---|
1653 | goto ON_EXIT;
|
---|
1654 | }
|
---|
1655 | }
|
---|
1656 |
|
---|
1657 | Status = gBS->HandleProtocol (
|
---|
1658 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1659 | &gEfiComponentName2ProtocolGuid,
|
---|
1660 | (VOID **) &ComponentName2
|
---|
1661 | );
|
---|
1662 | if (!EFI_ERROR (Status)) {
|
---|
1663 | gBS->UninstallMultipleProtocolInterfaces (
|
---|
1664 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1665 | &gEfiComponentName2ProtocolGuid,
|
---|
1666 | ComponentName2,
|
---|
1667 | NULL
|
---|
1668 | );
|
---|
1669 | if (EFI_ERROR (Status)) {
|
---|
1670 | goto ON_EXIT;
|
---|
1671 | }
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | //
|
---|
1675 | // Uninstall the IScsiInitiatorNameProtocol and all the driver binding protocols.
|
---|
1676 | //
|
---|
1677 | Status = gBS->UninstallMultipleProtocolInterfaces (
|
---|
1678 | gIScsiIp4DriverBinding.DriverBindingHandle,
|
---|
1679 | &gEfiDriverBindingProtocolGuid,
|
---|
1680 | &gIScsiIp4DriverBinding,
|
---|
1681 | &gEfiIScsiInitiatorNameProtocolGuid,
|
---|
1682 | &gIScsiInitiatorName,
|
---|
1683 | NULL
|
---|
1684 | );
|
---|
1685 | if (EFI_ERROR (Status)) {
|
---|
1686 | goto ON_EXIT;
|
---|
1687 | }
|
---|
1688 |
|
---|
1689 | Status = gBS->UninstallMultipleProtocolInterfaces (
|
---|
1690 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1691 | &gEfiDriverBindingProtocolGuid,
|
---|
1692 | &gIScsiIp6DriverBinding,
|
---|
1693 | NULL
|
---|
1694 | );
|
---|
1695 |
|
---|
1696 | ON_EXIT:
|
---|
1697 |
|
---|
1698 | if (DeviceHandleBuffer != NULL) {
|
---|
1699 | FreePool (DeviceHandleBuffer);
|
---|
1700 | }
|
---|
1701 |
|
---|
1702 | return Status;
|
---|
1703 | }
|
---|
1704 |
|
---|
1705 | /**
|
---|
1706 | This is the declaration of an EFI image entry point. This entry point is
|
---|
1707 | the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
|
---|
1708 | both device drivers and bus drivers.
|
---|
1709 |
|
---|
1710 | The entry point for iSCSI driver which initializes the global variables and
|
---|
1711 | installs the driver binding, component name protocol, iSCSI initiator name
|
---|
1712 | protocol and Authentication Info protocol on its image.
|
---|
1713 |
|
---|
1714 | @param[in] ImageHandle The firmware allocated handle for the UEFI image.
|
---|
1715 | @param[in] SystemTable A pointer to the EFI System Table.
|
---|
1716 |
|
---|
1717 | @retval EFI_SUCCESS The operation completed successfully.
|
---|
1718 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
---|
1719 |
|
---|
1720 | **/
|
---|
1721 | EFI_STATUS
|
---|
1722 | EFIAPI
|
---|
1723 | IScsiDriverEntryPoint (
|
---|
1724 | IN EFI_HANDLE ImageHandle,
|
---|
1725 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
1726 | )
|
---|
1727 | {
|
---|
1728 | EFI_STATUS Status;
|
---|
1729 | EFI_ISCSI_INITIATOR_NAME_PROTOCOL *IScsiInitiatorName;
|
---|
1730 | EFI_AUTHENTICATION_INFO_PROTOCOL *AuthenticationInfo;
|
---|
1731 |
|
---|
1732 | //
|
---|
1733 | // There should be only one EFI_ISCSI_INITIATOR_NAME_PROTOCOL.
|
---|
1734 | //
|
---|
1735 | Status = gBS->LocateProtocol (
|
---|
1736 | &gEfiIScsiInitiatorNameProtocolGuid,
|
---|
1737 | NULL,
|
---|
1738 | (VOID **) &IScsiInitiatorName
|
---|
1739 | );
|
---|
1740 | if (!EFI_ERROR (Status)) {
|
---|
1741 | return EFI_ACCESS_DENIED;
|
---|
1742 | }
|
---|
1743 |
|
---|
1744 | //
|
---|
1745 | // Initialize the EFI Driver Library.
|
---|
1746 | //
|
---|
1747 | Status = EfiLibInstallDriverBindingComponentName2 (
|
---|
1748 | ImageHandle,
|
---|
1749 | SystemTable,
|
---|
1750 | &gIScsiIp4DriverBinding,
|
---|
1751 | ImageHandle,
|
---|
1752 | &gIScsiComponentName,
|
---|
1753 | &gIScsiComponentName2
|
---|
1754 | );
|
---|
1755 | if (EFI_ERROR (Status)) {
|
---|
1756 | return Status;
|
---|
1757 | }
|
---|
1758 |
|
---|
1759 | Status = EfiLibInstallDriverBindingComponentName2 (
|
---|
1760 | ImageHandle,
|
---|
1761 | SystemTable,
|
---|
1762 | &gIScsiIp6DriverBinding,
|
---|
1763 | NULL,
|
---|
1764 | &gIScsiComponentName,
|
---|
1765 | &gIScsiComponentName2
|
---|
1766 | );
|
---|
1767 | if (EFI_ERROR (Status)) {
|
---|
1768 | goto Error1;
|
---|
1769 | }
|
---|
1770 |
|
---|
1771 | //
|
---|
1772 | // Install the iSCSI Initiator Name Protocol.
|
---|
1773 | //
|
---|
1774 | Status = gBS->InstallProtocolInterface (
|
---|
1775 | &ImageHandle,
|
---|
1776 | &gEfiIScsiInitiatorNameProtocolGuid,
|
---|
1777 | EFI_NATIVE_INTERFACE,
|
---|
1778 | &gIScsiInitiatorName
|
---|
1779 | );
|
---|
1780 | if (EFI_ERROR (Status)) {
|
---|
1781 | goto Error2;
|
---|
1782 | }
|
---|
1783 |
|
---|
1784 | //
|
---|
1785 | // Create the private data structures.
|
---|
1786 | //
|
---|
1787 | mPrivate = AllocateZeroPool (sizeof (ISCSI_PRIVATE_DATA));
|
---|
1788 | if (mPrivate == NULL) {
|
---|
1789 | Status = EFI_OUT_OF_RESOURCES;
|
---|
1790 | goto Error3;
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | InitializeListHead (&mPrivate->NicInfoList);
|
---|
1794 | InitializeListHead (&mPrivate->AttemptConfigs);
|
---|
1795 |
|
---|
1796 | //
|
---|
1797 | // Initialize the configuration form of iSCSI.
|
---|
1798 | //
|
---|
1799 | Status = IScsiConfigFormInit (gIScsiIp4DriverBinding.DriverBindingHandle);
|
---|
1800 | if (EFI_ERROR (Status)) {
|
---|
1801 | goto Error4;
|
---|
1802 | }
|
---|
1803 |
|
---|
1804 | //
|
---|
1805 | // Create the Maximum Attempts.
|
---|
1806 | //
|
---|
1807 | Status = IScsiCreateAttempts (PcdGet8 (PcdMaxIScsiAttemptNumber));
|
---|
1808 | if (EFI_ERROR (Status)) {
|
---|
1809 | goto Error5;
|
---|
1810 | }
|
---|
1811 |
|
---|
1812 | //
|
---|
1813 | // Create Keywords for all the Attempts.
|
---|
1814 | //
|
---|
1815 | Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber));
|
---|
1816 | if (EFI_ERROR (Status)) {
|
---|
1817 | goto Error6;
|
---|
1818 | }
|
---|
1819 |
|
---|
1820 | //
|
---|
1821 | // There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If already exists,
|
---|
1822 | // do not produce the protocol instance.
|
---|
1823 | //
|
---|
1824 | Status = gBS->LocateProtocol (
|
---|
1825 | &gEfiAuthenticationInfoProtocolGuid,
|
---|
1826 | NULL,
|
---|
1827 | (VOID **) &AuthenticationInfo
|
---|
1828 | );
|
---|
1829 | if (Status == EFI_NOT_FOUND) {
|
---|
1830 | Status = gBS->InstallProtocolInterface (
|
---|
1831 | &ImageHandle,
|
---|
1832 | &gEfiAuthenticationInfoProtocolGuid,
|
---|
1833 | EFI_NATIVE_INTERFACE,
|
---|
1834 | &gIScsiAuthenticationInfo
|
---|
1835 | );
|
---|
1836 | if (EFI_ERROR (Status)) {
|
---|
1837 | goto Error6;
|
---|
1838 | }
|
---|
1839 | }
|
---|
1840 |
|
---|
1841 | return EFI_SUCCESS;
|
---|
1842 |
|
---|
1843 | Error6:
|
---|
1844 | IScsiCleanAttemptVariable ();
|
---|
1845 |
|
---|
1846 | Error5:
|
---|
1847 | IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
|
---|
1848 |
|
---|
1849 | Error4:
|
---|
1850 | if (mPrivate != NULL) {
|
---|
1851 | FreePool (mPrivate);
|
---|
1852 | mPrivate = NULL;
|
---|
1853 | }
|
---|
1854 |
|
---|
1855 | Error3:
|
---|
1856 | gBS->UninstallMultipleProtocolInterfaces (
|
---|
1857 | ImageHandle,
|
---|
1858 | &gEfiIScsiInitiatorNameProtocolGuid,
|
---|
1859 | &gIScsiInitiatorName,
|
---|
1860 | NULL
|
---|
1861 | );
|
---|
1862 |
|
---|
1863 | Error2:
|
---|
1864 | gBS->UninstallMultipleProtocolInterfaces (
|
---|
1865 | gIScsiIp6DriverBinding.DriverBindingHandle,
|
---|
1866 | &gEfiDriverBindingProtocolGuid,
|
---|
1867 | &gIScsiIp6DriverBinding,
|
---|
1868 | &gEfiComponentName2ProtocolGuid,
|
---|
1869 | &gIScsiComponentName2,
|
---|
1870 | &gEfiComponentNameProtocolGuid,
|
---|
1871 | &gIScsiComponentName,
|
---|
1872 | NULL
|
---|
1873 | );
|
---|
1874 |
|
---|
1875 | Error1:
|
---|
1876 | gBS->UninstallMultipleProtocolInterfaces (
|
---|
1877 | ImageHandle,
|
---|
1878 | &gEfiDriverBindingProtocolGuid,
|
---|
1879 | &gIScsiIp4DriverBinding,
|
---|
1880 | &gEfiComponentName2ProtocolGuid,
|
---|
1881 | &gIScsiComponentName2,
|
---|
1882 | &gEfiComponentNameProtocolGuid,
|
---|
1883 | &gIScsiComponentName,
|
---|
1884 | NULL
|
---|
1885 | );
|
---|
1886 |
|
---|
1887 | return Status;
|
---|
1888 | }
|
---|
1889 |
|
---|