]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Ip6Dxe/Ip6Driver.c
QuarkPlatformPkg/PlatformFlashAccessLib: Add progress API
[mirror_edk2.git] / NetworkPkg / Ip6Dxe / Ip6Driver.c
index ba702904b5f5c76ad3700e4c211d8ab484d5b416..0797a742f23ad03c7b6080c7c5b1b004491b5cf0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding and service binding protocol for IP6 driver.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
 \r
   This program and the accompanying materials\r
@@ -41,14 +41,20 @@ IpSec2InstalledCallback (
   IN VOID       *Context\r
   )\r
 {\r
+  EFI_STATUS    Status;\r
   //\r
-  // Close the event so it does not get called again.\r
+  // Test if protocol was even found.\r
+  // Notification function will be called at least once.\r
   //\r
-  gBS->CloseEvent (Event);\r
-\r
-  mIpSec2Installed = TRUE;\r
+  Status = gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid, NULL, (VOID **)&mIpSec);\r
+  if (Status == EFI_SUCCESS && mIpSec != NULL) {\r
+    //\r
+    // Close the event so it does not get called again.\r
+    //\r
+    gBS->CloseEvent (Event);\r
 \r
-  return;\r
+    mIpSec2Installed = TRUE;\r
+  }\r
 }\r
 \r
 /**\r
@@ -149,6 +155,22 @@ Ip6CleanService (
   EFI_IPv6_ADDRESS          AllNodes;\r
   IP6_NEIGHBOR_ENTRY        *NeighborCache;\r
 \r
+  IpSb->State     = IP6_SERVICE_DESTROY;\r
+\r
+  if (IpSb->Timer != NULL) {\r
+    gBS->SetTimer (IpSb->Timer, TimerCancel, 0);\r
+    gBS->CloseEvent (IpSb->Timer);\r
+\r
+    IpSb->Timer = NULL;\r
+  }\r
+\r
+  if (IpSb->FasterTimer != NULL) {\r
+    gBS->SetTimer (IpSb->FasterTimer, TimerCancel, 0);\r
+    gBS->CloseEvent (IpSb->FasterTimer);\r
+\r
+    IpSb->FasterTimer = NULL;\r
+  }\r
+\r
   Ip6ConfigCleanInstance (&IpSb->Ip6ConfigInstance);\r
 \r
   if (!IpSb->LinkLocalDadFail) {\r
@@ -214,19 +236,6 @@ Ip6CleanService (
     gBS->CloseEvent (IpSb->RecvRequest.MnpToken.Event);\r
   }\r
 \r
-  if (IpSb->Timer != NULL) {\r
-    gBS->SetTimer (IpSb->Timer, TimerCancel, 0);\r
-    gBS->CloseEvent (IpSb->Timer);\r
-\r
-    IpSb->Timer = NULL;\r
-  }\r
-\r
-  if (IpSb->FasterTimer != NULL) {\r
-    gBS->SetTimer (IpSb->FasterTimer, TimerCancel, 0);\r
-    gBS->CloseEvent (IpSb->FasterTimer);\r
-\r
-    IpSb->FasterTimer = NULL;\r
-  }\r
   //\r
   // Free the Neighbor Discovery resources\r
   //\r
@@ -578,7 +587,7 @@ Ip6DriverBindingStart (
                        DataItem->DataSize,\r
                        DataItem->Data.Ptr\r
                        );\r
-    if (EFI_ERROR(Status)) {\r
+    if (EFI_ERROR(Status) && Status != EFI_NOT_READY) {\r
       goto ON_ERROR;\r
     }\r
   }\r
@@ -599,46 +608,44 @@ Ip6DriverBindingStart (
     }\r
   }\r
 \r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // ready to go: start the receiving and timer\r
-    //\r
-    Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);\r
-    if (EFI_ERROR (Status)) {\r
-      goto ON_ERROR;\r
-    }\r
+  //\r
+  // ready to go: start the receiving and timer\r
+  //\r
+  Status = Ip6ReceiveFrame (Ip6AcceptFrame, IpSb);\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
 \r
-    //\r
-    // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds.\r
-    //\r
-    Status = gBS->SetTimer (\r
-                    IpSb->FasterTimer,\r
-                    TimerPeriodic,\r
-                    TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto ON_ERROR;\r
-    }\r
+  //\r
+  // The timer expires every 100 (IP6_TIMER_INTERVAL_IN_MS) milliseconds.\r
+  //\r
+  Status = gBS->SetTimer (\r
+                  IpSb->FasterTimer,\r
+                  TimerPeriodic,\r
+                  TICKS_PER_MS * IP6_TIMER_INTERVAL_IN_MS\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }\r
 \r
-    //\r
-    // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds.\r
-    //\r
-    Status = gBS->SetTimer (\r
-                    IpSb->Timer,\r
-                    TimerPeriodic,\r
-                    TICKS_PER_MS * IP6_ONE_SECOND_IN_MS\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto ON_ERROR;\r
-    }    \r
+  //\r
+  // The timer expires every 1000 (IP6_ONE_SECOND_IN_MS) milliseconds.\r
+  //\r
+  Status = gBS->SetTimer (\r
+                  IpSb->Timer,\r
+                  TimerPeriodic,\r
+                  TICKS_PER_MS * IP6_ONE_SECOND_IN_MS\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto ON_ERROR;\r
+  }    \r
 \r
-    //\r
-    // Initialize the IP6 ID\r
-    //\r
-    mIp6Id = NET_RANDOM (NetRandomInitSeed ());\r
+  //\r
+  // Initialize the IP6 ID\r
+  //\r
+  mIp6Id = NET_RANDOM (NetRandomInitSeed ());\r
 \r
-    return EFI_SUCCESS;\r
-  }\r
+  return EFI_SUCCESS;\r
 \r
 ON_ERROR:\r
   Ip6CleanService (IpSb);\r
@@ -761,8 +768,6 @@ Ip6DriverBindingStop (
                );\r
   } else if (IsListEmpty (&IpSb->Children)) {\r
     State           = IpSb->State;\r
-    IpSb->State     = IP6_SERVICE_DESTROY;\r
-\r
     Status = Ip6CleanService (IpSb);\r
     if (EFI_ERROR (Status)) {\r
       IpSb->State = State;\r
@@ -797,7 +802,7 @@ Exit:
                                  the existing child handle.\r
 \r
   @retval EFI_SUCCES             The child handle was created with the I/O services.\r
-  @retval EFI_OUT_OF_RESOURCES   There are not enough resources availabe to create\r
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources available to create\r
                                  the child.\r
   @retval other                  The child handle was not created.\r
 \r