Skip to content

[Task] Prevent multiple SNP shutdown and reinitialization invocations #1638

Description

@makubacki

NetLibDetectMediaWaitTimeout() in DxeNetLib is called 15 places in the codebase. Multiple callers might call into the function for the same NIC such as Dhcp4Dxe, PxeBcDxe, etc. For example:

  Snp->undi.initialize()  <-- By SimpleNetworkDriverStart

  Snp->undi.initialize()   <-- By NetLibDetectMedia()
  Snp->undi.initialize()  8000h:6h
  Snp->undi.initialize()

  Snp->undi.initialize()  <-- By NetLibDetectMedia()
  Snp->undi.initialize()  8000h:6h
  Snp->undi.initialize()

Initialization might also occur multiple times in the same flow, for example, when SnpUndi32Initialize() first calls with PXE_OPFLAGS_INITIALIZE_DETECT_CABLE and if that fails, again with PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE:

//
// If UNDI support cable detect for INITIALIZE command, try it first.
//
if (Snp->CableDetectSupported) {
if (PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DETECT_CABLE) == EFI_SUCCESS) {
goto ON_EXIT;
}
}
Snp->Mode.MediaPresent = FALSE;
EfiStatus = PxeInit (Snp, PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE);
if (EFI_ERROR (EfiStatus)) {
gBS->CloseEvent (Snp->Snp.WaitForPacket);
goto ON_EXIT;
}
//
// Try to update the MediaPresent field of EFI_SIMPLE_NETWORK_MODE if the UNDI support it.
//
if (Snp->MediaStatusSupported) {
PxeGetStatus (Snp, NULL, FALSE);
}

Collectively this can lead to SNP shutting down and reinitializing multiple times when it might not need to impacting stability and performance.


This issue tracks exploration of a solution to reduce the number of times shutdown and reinitialization occurs across the network stack.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions