For network dynamic media support:

1. add library function NetLibDetectMedia to NetLib for media detection
2. update MnpDxe to periodically poll for media status update and check for media status before packet transmit
3. update Ip4Dxe to return ModeData using Mnp->GetModeData()
4. update IScsiDxe to check for media status before try to do DHCP and session login
5. update UefiPxeBcDxe to check for media status before PXE start

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9919 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xdu2 2010-02-03 04:37:53 +00:00
parent e51e619ed7
commit dd29f3edb9
16 changed files with 449 additions and 62 deletions

View File

@ -1092,6 +1092,40 @@ NetLibGetMacString (
OUT CHAR16 **MacString OUT CHAR16 **MacString
); );
/**
Detect media status for specified network device.
The underlying UNDI driver may or may not support reporting media status from
GET_STATUS command (PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED). This routine
will try to invoke Snp->GetStatus() to get the media status: if media already
present, it return directly; if media not present, it will stop SNP and then
restart SNP to get the latest media status, this give chance to get the correct
media status for old UNDI driver which doesn't support reporting media status
from GET_STATUS command.
Note: there will be two limitations for current algorithm:
1) for UNDI with this capability, in case of cable is not attached, there will
be an redundant Stop/Start() process;
2) for UNDI without this capability, in case cable is attached in UNDI
initialize while unattached latter, NetLibDetectMedia() will report
MediaPresent as TRUE, this cause upper layer apps wait for timeout time.
@param[in] ServiceHandle The handle where network service binding protocols are
installed on.
@param[out] MediaPresent The pointer to store the media status.
@retval EFI_SUCCESS Media detection success.
@retval EFI_INVALID_PARAMETER ServiceHandle is not valid network device handle.
@retval EFI_UNSUPPORTED Network device does not support media detection.
@retval EFI_DEVICE_ERROR SNP is in unknown state.
**/
EFI_STATUS
EFIAPI
NetLibDetectMedia (
IN EFI_HANDLE ServiceHandle,
OUT BOOLEAN *MediaPresent
);
/** /**
Create an IPv4 device path node. Create an IPv4 device path node.
@ -1201,7 +1235,7 @@ NetLibDefaultUnload (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip4Address The pointer to the converted IPv4 address. @param[out] Ip4Address The pointer to the converted IPv4 address.
@retval EFI_SUCCESS Convert to IPv4 address successfully. @retval EFI_SUCCESS Convert to IPv4 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL.
**/ **/
@ -1218,7 +1252,7 @@ NetLibAsciiStrToIp4 (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip6Address The pointer to the converted IPv6 address. @param[out] Ip6Address The pointer to the converted IPv6 address.
@retval EFI_SUCCESS Convert to IPv6 address successfully. @retval EFI_SUCCESS Convert to IPv6 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL.
**/ **/
@ -1234,7 +1268,7 @@ NetLibAsciiStrToIp6 (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip4Address The pointer to the converted IPv4 address. @param[out] Ip4Address The pointer to the converted IPv4 address.
@retval EFI_SUCCESS Convert to IPv4 address successfully. @retval EFI_SUCCESS Convert to IPv4 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL.
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource. @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource.
@ -1252,7 +1286,7 @@ NetLibStrToIp4 (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip6Address The pointer to the converted IPv6 address. @param[out] Ip6Address The pointer to the converted IPv6 address.
@retval EFI_SUCCESS Convert to IPv6 address successfully. @retval EFI_SUCCESS Convert to IPv6 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL.
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource. @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource.
@ -1272,7 +1306,7 @@ NetLibStrToIp6 (
@param[out] Ip6Address The pointer to the converted IPv6 address. @param[out] Ip6Address The pointer to the converted IPv6 address.
@param[out] PrefixLength The pointer to the converted prefix length. @param[out] PrefixLength The pointer to the converted prefix length.
@retval EFI_SUCCESS Convert to IPv6 address successfully. @retval EFI_SUCCESS Convert to IPv6 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL.
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource. @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource.

View File

@ -2145,6 +2145,213 @@ NetLibGetMacString (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/**
Detect media status for specified network device.
The underlying UNDI driver may or may not support reporting media status from
GET_STATUS command (PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED). This routine
will try to invoke Snp->GetStatus() to get the media status: if media already
present, it return directly; if media not present, it will stop SNP and then
restart SNP to get the latest media status, this give chance to get the correct
media status for old UNDI driver which doesn't support reporting media status
from GET_STATUS command.
Note: there will be two limitations for current algorithm:
1) for UNDI with this capability, in case of cable is not attached, there will
be an redundant Stop/Start() process;
2) for UNDI without this capability, in case cable is attached in UNDI
initialize while unattached latter, NetLibDetectMedia() will report
MediaPresent as TRUE, this cause upper layer apps wait for timeout time.
@param[in] ServiceHandle The handle where network service binding protocols are
installed on.
@param[out] MediaPresent The pointer to store the media status.
@retval EFI_SUCCESS Media detection success.
@retval EFI_INVALID_PARAMETER ServiceHandle is not valid network device handle.
@retval EFI_UNSUPPORTED Network device does not support media detection.
@retval EFI_DEVICE_ERROR SNP is in unknown state.
**/
EFI_STATUS
EFIAPI
NetLibDetectMedia (
IN EFI_HANDLE ServiceHandle,
OUT BOOLEAN *MediaPresent
)
{
EFI_STATUS Status;
EFI_HANDLE SnpHandle;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
UINT32 InterruptStatus;
UINT32 OldState;
EFI_MAC_ADDRESS *MCastFilter;
UINT32 MCastFilterCount;
UINT32 EnableFilterBits;
UINT32 DisableFilterBits;
BOOLEAN ResetMCastFilters;
ASSERT (MediaPresent != NULL);
//
// Get SNP handle
//
Snp = NULL;
SnpHandle = NetLibGetSnpHandle (ServiceHandle, &Snp);
if (SnpHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Check whether SNP support media detection
//
if (!Snp->Mode->MediaPresentSupported) {
return EFI_UNSUPPORTED;
}
//
// Invoke Snp->GetStatus() to refresh MediaPresent field in SNP mode data
//
Status = Snp->GetStatus (Snp, &InterruptStatus, NULL);
if (EFI_ERROR (Status)) {
return Status;
}
if (Snp->Mode->MediaPresent) {
//
// Media is present, return directly
//
*MediaPresent = TRUE;
return EFI_SUCCESS;
}
//
// Till now, GetStatus() report no media; while, in case UNDI not support
// reporting media status from GetStatus(), this media status may be incorrect.
// So, we will stop SNP and then restart it to get the correct media status.
//
OldState = Snp->Mode->State;
if (OldState >= EfiSimpleNetworkMaxState) {
return EFI_DEVICE_ERROR;
}
MCastFilter = NULL;
if (OldState == EfiSimpleNetworkInitialized) {
//
// SNP is already in use, need Shutdown/Stop and then Start/Initialize
//
//
// Backup current SNP receive filter settings
//
EnableFilterBits = Snp->Mode->ReceiveFilterSetting;
DisableFilterBits = Snp->Mode->ReceiveFilterMask ^ EnableFilterBits;
ResetMCastFilters = TRUE;
MCastFilterCount = Snp->Mode->MCastFilterCount;
if (MCastFilterCount != 0) {
MCastFilter = AllocateCopyPool (
MCastFilterCount * sizeof (EFI_MAC_ADDRESS),
Snp->Mode->MCastFilter
);
ASSERT (MCastFilter != NULL);
ResetMCastFilters = FALSE;
}
//
// Shutdown/Stop the simple network
//
Status = Snp->Shutdown (Snp);
if (!EFI_ERROR (Status)) {
Status = Snp->Stop (Snp);
}
if (EFI_ERROR (Status)) {
goto Exit;
}
//
// Start/Initialize the simple network
//
Status = Snp->Start (Snp);
if (!EFI_ERROR (Status)) {
Status = Snp->Initialize (Snp, 0, 0);
}
if (EFI_ERROR (Status)) {
goto Exit;
}
//
// Here we get the correct media status
//
*MediaPresent = Snp->Mode->MediaPresent;
//
// Restore SNP receive filter settings
//
Status = Snp->ReceiveFilters (
Snp,
EnableFilterBits,
DisableFilterBits,
ResetMCastFilters,
MCastFilterCount,
MCastFilter
);
if (MCastFilter != NULL) {
FreePool (MCastFilter);
}
return Status;
}
//
// SNP is not in use, it's in state of EfiSimpleNetworkStopped or EfiSimpleNetworkStarted
//
if (OldState == EfiSimpleNetworkStopped) {
//
// SNP not start yet, start it
//
Status = Snp->Start (Snp);
if (EFI_ERROR (Status)) {
goto Exit;
}
}
//
// Initialize the simple network
//
Status = Snp->Initialize (Snp, 0, 0);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto Exit;
}
//
// Here we get the correct media status
//
*MediaPresent = Snp->Mode->MediaPresent;
//
// Shut down the simple network
//
Snp->Shutdown (Snp);
Exit:
if (OldState == EfiSimpleNetworkStopped) {
//
// Original SNP sate is Stopped, restore to original state
//
Snp->Stop (Snp);
}
if (MCastFilter != NULL) {
FreePool (MCastFilter);
}
return Status;
}
/** /**
Check the default address used by the IPv4 driver is static or dynamic (acquired Check the default address used by the IPv4 driver is static or dynamic (acquired
from DHCP). from DHCP).
@ -2417,7 +2624,7 @@ NetLibGetNicHandle (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip4Address The pointer to the converted IPv4 address. @param[out] Ip4Address The pointer to the converted IPv4 address.
@retval EFI_SUCCESS Convert to IPv4 address successfully. @retval EFI_SUCCESS Convert to IPv4 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL.
**/ **/
@ -2460,7 +2667,7 @@ NetLibAsciiStrToIp4 (
// //
// Convert the string to IPv4 address. AsciiStrDecimalToUintn stops at the // Convert the string to IPv4 address. AsciiStrDecimalToUintn stops at the
// first character that is not a valid decimal character, '.' or '\0' here. // first character that is not a valid decimal character, '.' or '\0' here.
// //
NodeVal = AsciiStrDecimalToUintn (TempStr); NodeVal = AsciiStrDecimalToUintn (TempStr);
if (NodeVal > 0xFF) { if (NodeVal > 0xFF) {
@ -2483,7 +2690,7 @@ NetLibAsciiStrToIp4 (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip6Address The pointer to the converted IPv6 address. @param[out] Ip6Address The pointer to the converted IPv6 address.
@retval EFI_SUCCESS Convert to IPv6 address successfully. @retval EFI_SUCCESS Convert to IPv6 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL.
**/ **/
@ -2519,7 +2726,7 @@ NetLibAsciiStrToIp6 (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} else { } else {
AllowedCnt = 7; AllowedCnt = 7;
} }
} }
ZeroMem (Ip6Address, sizeof (EFI_IPv6_ADDRESS)); ZeroMem (Ip6Address, sizeof (EFI_IPv6_ADDRESS));
@ -2547,7 +2754,7 @@ NetLibAsciiStrToIp6 (
// ::0 looks strange. report error to user. // ::0 looks strange. report error to user.
// //
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// Skip the abbreviation part of IPv6 address. // Skip the abbreviation part of IPv6 address.
@ -2561,7 +2768,7 @@ NetLibAsciiStrToIp6 (
// //
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
TailNodeCnt++; TailNodeCnt++;
if (TailNodeCnt >= (AllowedCnt - NodeCnt)) { if (TailNodeCnt >= (AllowedCnt - NodeCnt)) {
// //
@ -2572,7 +2779,7 @@ NetLibAsciiStrToIp6 (
} }
TempStr2++; TempStr2++;
} }
Short = TRUE; Short = TRUE;
Update = TRUE; Update = TRUE;
@ -2587,12 +2794,12 @@ NetLibAsciiStrToIp6 (
// //
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
} }
// //
// Convert the string to IPv6 address. AsciiStrHexToUintn stops at the first // Convert the string to IPv6 address. AsciiStrHexToUintn stops at the first
// character that is not a valid hexadecimal character, ':' or '\0' here. // character that is not a valid hexadecimal character, ':' or '\0' here.
// //
NodeVal = AsciiStrHexToUintn (TempStr); NodeVal = AsciiStrHexToUintn (TempStr);
if ((NodeVal > 0xFFFF) || (Index > 14)) { if ((NodeVal > 0xFFFF) || (Index > 14)) {
@ -2625,7 +2832,7 @@ NetLibAsciiStrToIp6 (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip4Address The pointer to the converted IPv4 address. @param[out] Ip4Address The pointer to the converted IPv4 address.
@retval EFI_SUCCESS Convert to IPv4 address successfully. @retval EFI_SUCCESS Convert to IPv4 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL.
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource. @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource.
@ -2638,7 +2845,7 @@ NetLibStrToIp4 (
{ {
CHAR8 *Ip4Str; CHAR8 *Ip4Str;
EFI_STATUS Status; EFI_STATUS Status;
if ((String == NULL) || (Ip4Address == NULL)) { if ((String == NULL) || (Ip4Address == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -2665,7 +2872,7 @@ NetLibStrToIp4 (
@param[in] String The pointer to the Ascii string. @param[in] String The pointer to the Ascii string.
@param[out] Ip6Address The pointer to the converted IPv6 address. @param[out] Ip6Address The pointer to the converted IPv6 address.
@retval EFI_SUCCESS Convert to IPv6 address successfully. @retval EFI_SUCCESS Convert to IPv6 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL.
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource. @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource.
@ -2674,11 +2881,11 @@ EFI_STATUS
NetLibStrToIp6 ( NetLibStrToIp6 (
IN CONST CHAR16 *String, IN CONST CHAR16 *String,
OUT EFI_IPv6_ADDRESS *Ip6Address OUT EFI_IPv6_ADDRESS *Ip6Address
) )
{ {
CHAR8 *Ip6Str; CHAR8 *Ip6Str;
EFI_STATUS Status; EFI_STATUS Status;
if ((String == NULL) || (Ip6Address == NULL)) { if ((String == NULL) || (Ip6Address == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -2706,7 +2913,7 @@ NetLibStrToIp6 (
@param[out] Ip6Address The pointer to the converted IPv6 address. @param[out] Ip6Address The pointer to the converted IPv6 address.
@param[out] PrefixLength The pointer to the converted prefix length. @param[out] PrefixLength The pointer to the converted prefix length.
@retval EFI_SUCCESS Convert to IPv6 address successfully. @retval EFI_SUCCESS Convert to IPv6 address successfully.
@retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL. @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip6Address is NULL.
@retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource. @retval EFI_OUT_OF_RESOURCES Fail to perform the operation due to lack of resource.
@ -2716,14 +2923,14 @@ NetLibStrToIp6andPrefix (
IN CONST CHAR16 *String, IN CONST CHAR16 *String,
OUT EFI_IPv6_ADDRESS *Ip6Address, OUT EFI_IPv6_ADDRESS *Ip6Address,
OUT UINT8 *PrefixLength OUT UINT8 *PrefixLength
) )
{ {
CHAR8 *Ip6Str; CHAR8 *Ip6Str;
CHAR8 *PrefixStr; CHAR8 *PrefixStr;
CHAR8 *TempStr; CHAR8 *TempStr;
EFI_STATUS Status; EFI_STATUS Status;
UINT8 Length; UINT8 Length;
if ((String == NULL) || (Ip6Address == NULL) || (PrefixLength == NULL)) { if ((String == NULL) || (Ip6Address == NULL) || (PrefixLength == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }

View File

@ -770,6 +770,7 @@ ON_EXIT:
@retval EFI_ALREADY_STARTED Some other EFI DHCPv4 Protocol instance already started the @retval EFI_ALREADY_STARTED Some other EFI DHCPv4 Protocol instance already started the
DHCP process. DHCP process.
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
@retval EFI_NO_MEDIA There was a media error.
**/ **/
EFI_STATUS EFI_STATUS

View File

@ -1,7 +1,7 @@
/** @file /** @file
iSCSI DHCP related configuration routines. iSCSI DHCP related configuration routines.
Copyright (c) 2004 - 2009, Intel Corporation.<BR> Copyright (c) 2004 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -344,7 +344,9 @@ IScsiParseDhcpAck (
@retval EFI_SUCCESS The DNS information is got from the DHCP ACK. @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
@retval EFI_NO_MEDIA There was a media error.
@retval Others Other errors as indicated. @retval Others Other errors as indicated.
**/ **/
EFI_STATUS EFI_STATUS
IScsiDoDhcp ( IScsiDoDhcp (
@ -358,11 +360,21 @@ IScsiDoDhcp (
EFI_STATUS Status; EFI_STATUS Status;
EFI_DHCP4_PACKET_OPTION *ParaList; EFI_DHCP4_PACKET_OPTION *ParaList;
EFI_DHCP4_CONFIG_DATA Dhcp4ConfigData; EFI_DHCP4_CONFIG_DATA Dhcp4ConfigData;
BOOLEAN MediaPresent;
Dhcp4Handle = NULL; Dhcp4Handle = NULL;
Dhcp4 = NULL; Dhcp4 = NULL;
ParaList = NULL; ParaList = NULL;
//
// Check media status before do DHCP
//
MediaPresent = TRUE;
NetLibDetectMedia (Controller, &MediaPresent);
if (!MediaPresent) {
return EFI_NO_MEDIA;
}
// //
// Create a DHCP4 child instance and get the protocol. // Create a DHCP4 child instance and get the protocol.
// //

View File

@ -1,7 +1,7 @@
/** @file /** @file
The header file of IScsiDhcp. The header file of IScsiDhcp.
Copyright (c) 2004 - 2009, Intel Corporation.<BR> Copyright (c) 2004 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -47,7 +47,9 @@ typedef struct _ISCSI_ROOT_PATH_FIELD {
@retval EFI_SUCCESS The DNS information is got from the DHCP ACK. @retval EFI_SUCCESS The DNS information is got from the DHCP ACK.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
@retval EFI_NO_MEDIA There was a media error.
@retval Others Other errors as indicated. @retval Others Other errors as indicated.
**/ **/
EFI_STATUS EFI_STATUS
IScsiDoDhcp ( IScsiDoDhcp (

View File

@ -1,7 +1,7 @@
/** @file /** @file
The implementation of iSCSI protocol based on RFC3720. The implementation of iSCSI protocol based on RFC3720.
Copyright (c) 2004 - 2009, Intel Corporation.<BR> Copyright (c) 2004 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -276,7 +276,9 @@ IScsiDestroyConnection (
@retval EFI_SUCCESS The iSCSI session login procedure finished. @retval EFI_SUCCESS The iSCSI session login procedure finished.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
@retval EFI_NO_MEDIA There was a media error.
@retval Others Other errors as indicated. @retval Others Other errors as indicated.
**/ **/
EFI_STATUS EFI_STATUS
IScsiSessionLogin ( IScsiSessionLogin (
@ -287,9 +289,19 @@ IScsiSessionLogin (
ISCSI_SESSION *Session; ISCSI_SESSION *Session;
ISCSI_CONNECTION *Conn; ISCSI_CONNECTION *Conn;
EFI_TCP4_PROTOCOL *Tcp4; EFI_TCP4_PROTOCOL *Tcp4;
BOOLEAN MediaPresent;
Session = &Private->Session; Session = &Private->Session;
//
// Check media status before session login
//
MediaPresent = TRUE;
NetLibDetectMedia (Private->Controller, &MediaPresent);
if (!MediaPresent) {
return EFI_NO_MEDIA;
}
// //
// Create a connection for the session. // Create a connection for the session.
// //

View File

@ -1,7 +1,7 @@
/** @file /** @file
The header file of iSCSI Protocol that defines many specific data structures. The header file of iSCSI Protocol that defines many specific data structures.
Copyright (c) 2004 - 2009, Intel Corporation.<BR> Copyright (c) 2004 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -692,7 +692,9 @@ IScsiDestroyConnection (
@retval EFI_SUCCESS The iSCSI session login procedure finished. @retval EFI_SUCCESS The iSCSI session login procedure finished.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
@retval EFI_NO_MEDIA There was a media error.
@retval Others Other errors as indicated. @retval Others Other errors as indicated.
**/ **/
EFI_STATUS EFI_STATUS
IScsiSessionLogin ( IScsiSessionLogin (

View File

@ -440,16 +440,13 @@ EfiIp4GetModeData (
} }
} }
if (MnpConfigData != NULL) { //
CopyMem (MnpConfigData, &IpSb->MnpConfigData, sizeof (*MnpConfigData)); // Get fresh mode data from MNP, since underlying media status may change
} //
Status = IpSb->Mnp->GetModeData (IpSb->Mnp, MnpConfigData, SnpModeData);
if (SnpModeData != NULL) {
CopyMem (SnpModeData, &IpSb->SnpMode, sizeof (*SnpModeData));
}
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS; return Status;
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
Implementation of Managed Network Protocol private services. Implementation of Managed Network Protocol private services.
Copyright (c) 2005 - 2009, Intel Corporation.<BR> Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full of the BSD License which accompanies this distribution. The full
@ -355,6 +355,22 @@ MnpInitializeDeviceData (
goto ERROR; goto ERROR;
} }
//
// Create the timer for media detection.
//
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL | EVT_TIMER,
TPL_CALLBACK,
MnpCheckMediaStatus,
MnpDeviceData,
&MnpDeviceData->MediaDetectTimer
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "MnpInitializeDeviceData: CreateEvent for media detection failed.\n"));
goto ERROR;
}
// //
// Create the timer for tx timeout check. // Create the timer for tx timeout check.
// //
@ -382,6 +398,10 @@ ERROR:
gBS->CloseEvent (MnpDeviceData->TimeoutCheckTimer); gBS->CloseEvent (MnpDeviceData->TimeoutCheckTimer);
} }
if (MnpDeviceData->MediaDetectTimer != NULL) {
gBS->CloseEvent (MnpDeviceData->MediaDetectTimer);
}
if (MnpDeviceData->PollTimer != NULL) { if (MnpDeviceData->PollTimer != NULL) {
gBS->CloseEvent (MnpDeviceData->PollTimer); gBS->CloseEvent (MnpDeviceData->PollTimer);
} }
@ -443,9 +463,10 @@ MnpDestroyDeviceData (
// //
// Close the event. // Close the event.
// //
gBS->CloseEvent (&MnpDeviceData->TxTimeoutEvent); gBS->CloseEvent (MnpDeviceData->TxTimeoutEvent);
gBS->CloseEvent (&MnpDeviceData->TimeoutCheckTimer); gBS->CloseEvent (MnpDeviceData->TimeoutCheckTimer);
gBS->CloseEvent (&MnpDeviceData->PollTimer); gBS->CloseEvent (MnpDeviceData->MediaDetectTimer);
gBS->CloseEvent (MnpDeviceData->PollTimer);
// //
// Free the tx buffer. // Free the tx buffer.
@ -1010,6 +1031,24 @@ MnpStart (
goto ErrorExit; goto ErrorExit;
} }
//
// Start the media detection timer.
//
Status = gBS->SetTimer (
MnpDeviceData->MediaDetectTimer,
TimerPeriodic,
MNP_MEDIA_DETECT_INTERVAL
);
if (EFI_ERROR (Status)) {
DEBUG (
(EFI_D_ERROR,
"MnpStart, gBS->SetTimer for MediaDetectTimer %r.\n",
Status)
);
goto ErrorExit;
}
} }
} }
@ -1095,6 +1134,11 @@ MnpStop (
// //
Status = gBS->SetTimer (MnpDeviceData->TimeoutCheckTimer, TimerCancel, 0); Status = gBS->SetTimer (MnpDeviceData->TimeoutCheckTimer, TimerCancel, 0);
//
// Cancel the media detect timer.
//
Status = gBS->SetTimer (MnpDeviceData->MediaDetectTimer, TimerCancel, 0);
// //
// Stop the simple network. // Stop the simple network.
// //

View File

@ -1,7 +1,7 @@
/** @file /** @file
Implementation of driver entry point and driver binding protocol. Implementation of driver entry point and driver binding protocol.
Copyright (c) 2005 - 2009, Intel Corporation.<BR> Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full of the BSD License which accompanies this distribution. The full
@ -336,7 +336,7 @@ MnpDriverBindingStop (
} }
// //
// Destroy the Mnp device data // Destroy Mnp Device Data
// //
MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle); MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);
FreePool (MnpDeviceData); FreePool (MnpDeviceData);

View File

@ -1,7 +1,7 @@
/** @file /** @file
Declaration of strctures and functions for MnpDxe driver. Declaration of strctures and functions for MnpDxe driver.
Copyright (c) 2005 - 2009, Intel Corporation.<BR> Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full of the BSD License which accompanies this distribution. The full
@ -70,6 +70,7 @@ typedef struct {
BOOLEAN EnableSystemPoll; BOOLEAN EnableSystemPoll;
EFI_EVENT TimeoutCheckTimer; EFI_EVENT TimeoutCheckTimer;
EFI_EVENT MediaDetectTimer;
UINT32 UnicastCount; UINT32 UnicastCount;
UINT32 BroadcastCount; UINT32 BroadcastCount;

View File

@ -1,7 +1,7 @@
/** @file /** @file
Declaration of structures and functions of MnpDxe driver. Declaration of structures and functions of MnpDxe driver.
Copyright (c) 2005 - 2009, Intel Corporation.<BR> Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full of the BSD License which accompanies this distribution. The full
@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds #define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds
#define MNP_TIMEOUT_CHECK_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds #define MNP_TIMEOUT_CHECK_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds
#define MNP_MEDIA_DETECT_INTERVAL (500 * TICKS_PER_MS) // 500 milliseconds
#define MNP_TX_TIMEOUT_TIME (500 * TICKS_PER_MS) // 500 milliseconds #define MNP_TX_TIMEOUT_TIME (500 * TICKS_PER_MS) // 500 milliseconds
#define MNP_INIT_NET_BUFFER_NUM 512 #define MNP_INIT_NET_BUFFER_NUM 512
#define MNP_NET_BUFFER_INCREASEMENT 64 #define MNP_NET_BUFFER_INCREASEMENT 64
@ -448,9 +449,8 @@ MnpFreeNbuf (
/** /**
Remove the received packets if timeout occurs. Remove the received packets if timeout occurs.
@param[in] Event The event this notify function registered to. @param[in] Event The event this notify function registered to.
@param[in] Context Pointer to the context data registered to the @param[in] Context Pointer to the context data registered to the event.
event.
**/ **/
VOID VOID
@ -460,19 +460,33 @@ MnpCheckPacketTimeout (
IN VOID *Context IN VOID *Context
); );
/**
Poll to update MediaPresent field in SNP ModeData by Snp.GetStatus().
@param[in] Event The event this notify function registered to.
@param[in] Context Pointer to the context data registered to the event.
**/
VOID
EFIAPI
MnpCheckMediaStatus (
IN EFI_EVENT Event,
IN VOID *Context
);
/** /**
Poll to receive the packets from Snp. This function is either called by upperlayer Poll to receive the packets from Snp. This function is either called by upperlayer
protocols/applications or the system poll timer notify mechanism. protocols/applications or the system poll timer notify mechanism.
@param[in] Event The event this notify function registered to. @param[in] Event The event this notify function registered to.
@param[in, out] Context Pointer to the context data registered to the event. @param[in] Context Pointer to the context data registered to the event.
**/ **/
VOID VOID
EFIAPI EFIAPI
MnpSystemPoll ( MnpSystemPoll (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN OUT VOID *Context IN VOID *Context
); );
/** /**

View File

@ -1,7 +1,7 @@
/** @file /** @file
Implementation of Managed Network Protocol I/O functions. Implementation of Managed Network Protocol I/O functions.
Copyright (c) 2005 - 2009, Intel Corporation.<BR> Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full of the BSD License which accompanies this distribution. The full
@ -210,6 +210,18 @@ MnpSyncSendPacket (
HeaderSize = Snp->Mode->MediaHeaderSize - TxData->HeaderLength; HeaderSize = Snp->Mode->MediaHeaderSize - TxData->HeaderLength;
//
// Check media status before transmit packet.
// Note: media status will be updated by periodic timer MediaDetectTimer.
//
if (!Snp->Mode->MediaPresent) {
//
// Media not present, skip packet transmit and report EFI_NO_MEDIA
//
Status = EFI_NO_MEDIA;
goto SIGNAL_TOKEN;
}
// //
// Start the timeout event. // Start the timeout event.
// //
@ -998,9 +1010,8 @@ EXIT:
/** /**
Remove the received packets if timeout occurs. Remove the received packets if timeout occurs.
@param[in] Event The event this notify function registered to. @param[in] Event The event this notify function registered to.
@param[in] Context Pointer to the context data registered to the @param[in] Context Pointer to the context data registered to the event.
event.
**/ **/
VOID VOID
@ -1065,19 +1076,50 @@ MnpCheckPacketTimeout (
} }
} }
/**
Poll to update MediaPresent field in SNP ModeData by Snp->GetStatus().
@param[in] Event The event this notify function registered to.
@param[in] Context Pointer to the context data registered to the event.
**/
VOID
EFIAPI
MnpCheckMediaStatus (
IN EFI_EVENT Event,
IN VOID *Context
)
{
MNP_DEVICE_DATA *MnpDeviceData;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
UINT32 InterruptStatus;
MnpDeviceData = (MNP_DEVICE_DATA *) Context;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
Snp = MnpDeviceData->Snp;
if (Snp->Mode->MediaPresentSupported) {
//
// Upon successful return of GetStatus(), the MediaPresent field of
// EFI_SIMPLE_NETWORK_MODE will be updated to reflect any change of media status
//
Snp->GetStatus (Snp, &InterruptStatus, NULL);
}
}
/** /**
Poll to receive the packets from Snp. This function is either called by upperlayer Poll to receive the packets from Snp. This function is either called by upperlayer
protocols/applications or the system poll timer notify mechanism. protocols/applications or the system poll timer notify mechanism.
@param[in] Event The event this notify function registered to. @param[in] Event The event this notify function registered to.
@param[in, out] Context Pointer to the context data registered to the event. @param[in] Context Pointer to the context data registered to the event.
**/ **/
VOID VOID
EFIAPI EFIAPI
MnpSystemPoll ( MnpSystemPoll (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN OUT VOID *Context IN VOID *Context
) )
{ {
MNP_DEVICE_DATA *MnpDeviceData; MNP_DEVICE_DATA *MnpDeviceData;

View File

@ -1,7 +1,7 @@
/** @file /** @file
Implementation of Managed Network Protocol public services. Implementation of Managed Network Protocol public services.
Copyright (c) 2005 - 2009, Intel Corporation.<BR> Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
of the BSD License which accompanies this distribution. The full of the BSD License which accompanies this distribution. The full
@ -52,6 +52,7 @@ MnpGetModeData (
EFI_SIMPLE_NETWORK_PROTOCOL *Snp; EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_TPL OldTpl; EFI_TPL OldTpl;
EFI_STATUS Status; EFI_STATUS Status;
UINT32 InterruptStatus;
if (This == NULL) { if (This == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -73,6 +74,12 @@ MnpGetModeData (
// Copy the underlayer Snp mode data. // Copy the underlayer Snp mode data.
// //
Snp = Instance->MnpServiceData->MnpDeviceData->Snp; Snp = Instance->MnpServiceData->MnpDeviceData->Snp;
//
// Upon successful return of GetStatus(), the Snp->Mode->MediaPresent
// will be updated to reflect any change of media status
//
Snp->GetStatus (Snp, &InterruptStatus, NULL);
CopyMem (SnpModeData, Snp->Mode, sizeof (*SnpModeData)); CopyMem (SnpModeData, Snp->Mode, sizeof (*SnpModeData));
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
Interface routine for Mtftp4. Interface routine for Mtftp4.
Copyright (c) 2006 - 2009, Intel Corporation<BR> Copyright (c) 2006 - 2010, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -776,6 +776,7 @@ EfiMtftp4ParseOptions (
@retval EFI_TIMEOUT No responses were received from the MTFTPv4 server. @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
@retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received. @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received.
@retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
@retval EFI_NO_MEDIA There was a media error.
**/ **/
EFI_STATUS EFI_STATUS
@ -971,7 +972,8 @@ EfiMtftp4ReadDirectory (
in the Buffer. in the Buffer.
@retval EFI_TIMEOUT No responses were received from the MTFTPv4 server. @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
@retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
@retval EFI_NO_MEDIA There was a media error.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI

View File

@ -2585,6 +2585,7 @@ EfiPxeLoadFile (
BOOLEAN NewMakeCallback; BOOLEAN NewMakeCallback;
EFI_STATUS Status; EFI_STATUS Status;
UINT64 TmpBufSize; UINT64 TmpBufSize;
BOOLEAN MediaPresent;
Private = PXEBC_PRIVATE_DATA_FROM_LOADFILE (This); Private = PXEBC_PRIVATE_DATA_FROM_LOADFILE (This);
PxeBc = &Private->PxeBc; PxeBc = &Private->PxeBc;
@ -2603,6 +2604,15 @@ EfiPxeLoadFile (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
//
// Check media status before PXE start
//
MediaPresent = TRUE;
NetLibDetectMedia (Private->Controller, &MediaPresent);
if (!MediaPresent) {
return EFI_NO_MEDIA;
}
Status = PxeBc->Start (PxeBc, FALSE); Status = PxeBc->Start (PxeBc, FALSE);
if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) { if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
return Status; return Status;