summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c67
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h31
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c27
3 files changed, 121 insertions, 4 deletions
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
index 2c74a80308..937da41f2c 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
@@ -1,7 +1,7 @@
/** @file
This code implements the IP4Config and NicIp4Config protocols.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at<BR>
@@ -129,6 +129,17 @@ EfiNicIp4ConfigSetInfo (
DispatchDpc ();
}
+ //
+ // A dedicated timer is used to poll underlying media status.In case of
+ // cable swap, a new round auto configuration will be initiated. The timer
+ // starts in DHCP policy only. STATIC policy stops the timer.
+ //
+ if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {
+ gBS->SetTimer (Instance->Timer, TimerPeriodic, TICKS_PER_SECOND);
+ } else if (NicConfig->Source == IP4_CONFIG_SOURCE_STATIC) {
+ gBS->SetTimer (Instance->Timer, TimerCancel, 0);
+ }
+
return Status;
}
@@ -659,3 +670,57 @@ Ip4ConfigCleanConfig (
Ip4ConfigCleanDhcp4 (Instance);
}
+
+/**
+ A dedicated timer is used to poll underlying media status. In case of
+ cable swap, a new round auto configuration will be initiated. The timer
+ will signal the IP4 to run the auto configuration again. IP4 driver will free
+ old IP address related resource, such as route table and Interface, then
+ initiate a DHCP process by IP4Config->Start to acquire new IP, eventually
+ create route table for new IP address.
+
+ @param[in] Event The IP4 service instance's heart beat timer.
+ @param[in] Context The IP4 service instance.
+
+**/
+VOID
+EFIAPI
+MediaChangeDetect (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ BOOLEAN OldMediaPresent;
+ EFI_STATUS Status;
+ EFI_SIMPLE_NETWORK_MODE SnpModeData;
+ IP4_CONFIG_INSTANCE *Instance;
+
+ Instance = (IP4_CONFIG_INSTANCE *) Context;
+
+ OldMediaPresent = Instance->MediaPresent;
+
+ //
+ // Get fresh mode data from MNP, since underlying media status may change
+ //
+ Status = Instance->Mnp->GetModeData (Instance->Mnp, NULL, &SnpModeData);
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
+ return;
+ }
+
+ Instance->MediaPresent = SnpModeData.MediaPresent;
+ //
+ // Media transimit Unpresent to Present means new link movement is detected.
+ //
+ if (!OldMediaPresent && Instance->MediaPresent) {
+ //
+ // Signal the IP4 to run the auto configuration again. IP4 driver will free
+ // old IP address related resource, such as route table and Interface, then
+ // initiate a DHCP round by IP4Config->Start to acquire new IP, eventually
+ // create route table for new IP address.
+ //
+ if (Instance->ReconfigEvent != NULL) {
+ Status = gBS->SignalEvent (Instance->ReconfigEvent);
+ DispatchDpc ();
+ }
+ }
+}
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
index eacd893890..622b87ee03 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
@@ -1,7 +1,7 @@
/** @file
Header file for IP4Config driver.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at<BR>
@@ -128,6 +128,16 @@ typedef struct _IP4_CONFIG_INSTANCE {
EFI_DHCP4_PROTOCOL *Dhcp4;
EFI_HANDLE Dhcp4Handle;
EFI_EVENT Dhcp4Event;
+
+ //
+ // A dedicated timer is used to poll underlying media status
+ //
+ EFI_EVENT Timer;
+
+ //
+ // Underlying media present status.
+ //
+ BOOLEAN MediaPresent;
} IP4_CONFIG_INSTANCE;
#define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \
@@ -496,4 +506,23 @@ EfiIp4ConfigGetData (
OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL
);
+/**
+ A dedicated timer is used to poll underlying media status. In case of
+ cable swap, a new round auto configuration will be initiated. The timer
+ will signal the IP4 to run the auto configuration again. IP4 driver will free
+ old IP address related resource, such as route table and Interface, then
+ initiate a DHCP round by IP4Config->Start to acquire new IP, eventually
+ create route table for new IP address.
+
+ @param[in] Event The IP4 service instance's heart beat timer.
+ @param[in] Context The IP4 service instance.
+
+**/
+VOID
+EFIAPI
+MediaChangeDetect (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
#endif
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
index fdbb26cd78..9ed9ae82a8 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
@@ -1,7 +1,7 @@
/** @file
The driver binding for IP4 CONFIG protocol.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at<BR>
@@ -77,7 +77,9 @@ IP4_CONFIG_INSTANCE mIp4ConfigTemplate = {
(NIC_IP4_CONFIG_INFO *) NULL,
(EFI_DHCP4_PROTOCOL *) NULL,
NULL,
- NULL
+ NULL,
+ NULL,
+ TRUE
};
/**
@@ -286,6 +288,21 @@ Ip4ConfigDriverBindingStart (
}
//
+ // A dedicated timer is used to poll underlying media status.
+ //
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL | EVT_TIMER,
+ TPL_CALLBACK,
+ MediaChangeDetect,
+ Instance,
+ &Instance->Timer
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto ON_ERROR;
+ }
+
+ //
// Get the previous configure parameters. If an error happend here,
// just ignore it because the driver should be able to operate.
//
@@ -476,6 +493,12 @@ Ip4ConfigDriverBindingStop (
FreePool (Instance->MacString);
}
+ if (Instance->Timer != NULL) {
+ gBS->SetTimer (Instance->Timer, TimerCancel, 0);
+ gBS->CloseEvent (Instance->Timer);
+ Instance->Timer = NULL;
+ }
+
Ip4ConfigCleanConfig (Instance);
FreePool (Instance);