Skip to content

Conversation

@makubacki
Copy link
Member

@makubacki makubacki commented Feb 11, 2026

Description

Resolves #1635

Simplify the NetLibDetectMediaWaitTimeout() execution flow and add a timeout on non-AIP media detection to allow NICs sufficient time to initialize and report media state.

Previously, DxeNetLib would only poll AIP media state with a timeout, while non-AIP media detection would immediately return and rely upon a logic bug in the implementation for the caller to be told network media was present (even though it might not be).


By default, network devices must properly report media presence. However, previous implementation would check Aip->GetInformation() fall back to Snp->GetStatus() and then return media is present if that was not SNP returned that it did not support media detection. A PCD (gEfiNetworkPkgTokenSpaceGuid.PcdTreatSnpMediaUnsupportedAsSuccess) is added to support that behavior if necessary.


  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

So far:

  • NetworkPkg CI

Todo (PR will be taken out of draft when done):

  • Physical client platform PXE boot
  • Physical server platform PXE boot

Integration Instructions

  • N/A

@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 0% with 121 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/202502@c4a845c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
NetworkPkg/Library/DxeNetLib/DxeNetLib.c 0.00% 121 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##             release/202502   #1636   +/-   ##
================================================
  Coverage                  ?   0.55%           
================================================
  Files                     ?     165           
  Lines                     ?   72020           
  Branches                  ?    1781           
================================================
  Hits                      ?     402           
  Misses                    ?   71611           
  Partials                  ?       7           
Flag Coverage Δ
NetworkPkg 0.55% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@makubacki makubacki force-pushed the networkpkg_dxenetlib_media_presence_timeout branch from 25b53de to fa0ad85 Compare February 11, 2026 22:18
Simplify the `NetLibDetectMediaWaitTimeout()` execution flow and
add a timeout on non-AIP media detection to allow NICs sufficient
time to initialize and report media state.

Previously, DxeNetLib would only poll AIP media state with a timeout,
while non-AIP media detection would immediately return and rely
upon a logic bug in the implementation for the caller to be told
network media was present (even though it might not be).

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki makubacki force-pushed the networkpkg_dxenetlib_media_presence_timeout branch from fa0ad85 to 4820673 Compare February 11, 2026 22:20
…init

Wait for presence to be reported after SNP initialization is called
without calling it again.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki makubacki force-pushed the networkpkg_dxenetlib_media_presence_timeout branch from 4820673 to cc0e97a Compare February 11, 2026 22:32
@makubacki
Copy link
Member Author

Since NetLibDetectMedia() is in a public library header (NetworkPkg/Include/Library/NetLib.h), I will update this to leave that API unmodified. Add a new public API with a Timeout parameter and then have both call a common internal function where the original NetLibDetectMedia() implementation passes it a Timeout of 0.

Restore the API to the original one to prevent that from being a
breaking change. Make internal refactors in support.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Update some names to better distinguish between function
responsibilities.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
…n as success

Network media detection currently happens through AIP->GetInformation()
or SNP->GetStatus(). If the underlying SNP driver does not support
media detection, previous code simply returned that media was
present. This change allows more correct behavior by default, to
force media detection, but adds a PCD to allow treating unsupported
media detection as success for backwards compatibility.

Platforms that need to enable the PCD, should try to find a way to
have media detection be supported.

PCD: gEfiNetworkPkgTokenSpaceGuid.PcdTreatSnpMediaUnsupportedAsSuccess

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki
Copy link
Member Author

Since NetLibDetectMedia() is in a public library header (NetworkPkg/Include/Library/NetLib.h), I will update this to leave that API unmodified. Add a new public API with a Timeout parameter and then have both call a common internal function where the original NetLibDetectMedia() implementation passes it a Timeout of 0.

Pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Consider timeout for NetLibDetectMedia() calls in NetLibDetectMediaWaitTimeout()

2 participants