Skip to content

NetworkPkg/DxeNetLib: Reduce SNP media detect timeout and retry attempts [Rebase & FF]#1715

Open
makubacki wants to merge 2 commits intomicrosoft:release/202511from
makubacki:reduce_snp_netlib_detect_timeout
Open

NetworkPkg/DxeNetLib: Reduce SNP media detect timeout and retry attempts [Rebase & FF]#1715
makubacki wants to merge 2 commits intomicrosoft:release/202511from
makubacki:reduce_snp_netlib_detect_timeout

Conversation

@makubacki
Copy link
Copy Markdown
Member

@makubacki makubacki commented Mar 23, 2026

Description

Originally, NetLibDetectMediaWaitTimeout() only used a timeout when detecting media through AIP. When AIP is not available or fails, media detection falls back to SNP. Commit ef7bb4d made the SNP media detection process more robust with a timeout and retry mechanism. This improved detection reliability and overall stability on the network devices targeted by the change. However, it also applied conservative timeout and retry values that may cause longer wait times in some cases where AIP is not used and the SNP media state is already known to be "not present".

This change reduces SNP retry attempts to 0 and the waiting time to 2 seconds. This leaves the retry logic in place but avoids using it for now. The maximum connection time observed in this fallback case has been 1.5 seconds, so 2 seconds is chosen to provide a reasonable buffer while avoiding unnecessarily long waits.


A commit is also included to make timeout code in DxeNetLib consistent:

NetworkPkg/DxeNetLib: Clamp timeouts to MAX_INT64

The original implementation of tracking remaining time in the NetLibDetectMediaWaitTimeout() used a UINT64 to track the remaining time, which could wrap around depending on whether the subtracted time interval (MEDIA_STATE_DETECT_TIME_INTERVAL) was a factor of the timeout given.

This change makes the TimeRemaining variable a INT64 to prevent the wrap around and clamps the incoming timeout to MAX_INT64 to prevent overflow.


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

How This Was Tested

  • Tested with platforms that do not install AIP for the network device and fall back to SNP media detection.
  • Client testing is complete. PXE boot remains successful in cases where network media is present. When network media is not present total wait time is reduced from 160s to 8s.
  • Server platform testing complete. PXE boot remains successful with the change.

Integration Instructions

  • N/A

@makubacki makubacki self-assigned this Mar 23, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 23, 2026

Codecov Report

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

Files with missing lines Patch % Lines
NetworkPkg/Library/DxeNetLib/DxeNetLib.c 0.00% 2 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##             release/202511   #1715   +/-   ##
================================================
  Coverage                  ?   0.55%           
================================================
  Files                     ?     165           
  Lines                     ?   72372           
  Branches                  ?    1789           
================================================
  Hits                      ?     402           
  Misses                    ?   71963           
  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 reduce_snp_netlib_detect_timeout branch from 0aa08cb to 737dc29 Compare March 24, 2026 18:49
@makubacki makubacki changed the title NetworkPkg/DxeNetLib: Reduce SNP media detect timeout and retry attempts NetworkPkg/DxeNetLib: Reduce SNP media detect timeout and retry attempts [Rebase & FF] Mar 24, 2026
The original implementation of tracking remaining time in the
NetLibDetectMediaWaitTimeout() used a UINT64 to track the remaining
time, which could wrap around depending on whether the subtracted
time interval (MEDIA_STATE_DETECT_TIME_INTERVAL) was a factor of
the timeout given.

This changes make the TimeRemaining variable a INT64 to prevent the
wrap around and clamps the incoming timeout to MAX_INT64 to prevent
overflow.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Originally, `NetLibDetectMediaWaitTimeout()` only used a timeout when
detecting media through AIP. When AIP is not available or fails, media
detection falls back to SNP. Commit ef7bb4d made the SNP media
detection process more robust with a timeout and retry mechanism. This
improved detection reliability and overall stability on some network
devices. However, it also applied conservative timeout and retry
values that may cause longer wait times in some cases where AIP is
not used and the SNP media state is already known to be "not present".

This change reduces SNP retry attempts to 0 and the waiting time to 2
seconds. This leaves the retry logic in place but avoids using it for
now. The maximum connection time observed in this fallback case has
been 1.5 secons, so 2 seconds is chosen to provide a reasonable buffer
while avoiding unnecessarily long waits.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
@makubacki makubacki force-pushed the reduce_snp_netlib_detect_timeout branch from 737dc29 to ae0bcf3 Compare March 25, 2026 14:14
@makubacki makubacki marked this pull request as ready for review March 25, 2026 14:14
@makubacki makubacki requested review from apop5, kuqin12 and os-d March 25, 2026 14:15
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.

5 participants