NetworkPkg: Document SnpMode cache staleness in service data structures

Add comments to the SnpMode field declarations in ARP, IP4, and IP6 service
data structures to document that the cached SNP mode data becomes stale
when MnpConfigure() is called.

Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
This commit is contained in:
Aaron Pop 2026-07-27 13:14:13 -07:00
parent bbf9182f14
commit 6313a61f3a
3 changed files with 59 additions and 24 deletions

View file

@ -153,16 +153,27 @@ struct _ARP_SERVICE_DATA {
EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
EFI_MANAGED_NETWORK_COMPLETION_TOKEN RxToken;
EFI_SIMPLE_NETWORK_MODE SnpMode;
//
// SnpMode is a cached copy of the SNP device configuration data (MAC address,
// media header size, hardware address size, interface type, etc.). This copy is
// obtained during service initialization via GetModeData.
//
// IMPORTANT: This cached data becomes STALE if MnpConfigure() is called, as
// MnpConfigure triggers SNP Start/Initialize which may finalize or alter mode
// fields not set before Start. Code that calls MnpConfigure must refetch the
// SNP mode data via GetModeData after reconfiguration to ensure values like
// MediaHeaderSize, CurrentAddress, and HwAddressSize remain valid.
//
EFI_SIMPLE_NETWORK_MODE SnpMode;
UINTN ChildrenNumber;
LIST_ENTRY ChildrenList;
UINTN ChildrenNumber;
LIST_ENTRY ChildrenList;
LIST_ENTRY PendingRequestTable;
LIST_ENTRY DeniedCacheTable;
LIST_ENTRY ResolvedCacheTable;
LIST_ENTRY PendingRequestTable;
LIST_ENTRY DeniedCacheTable;
LIST_ENTRY ResolvedCacheTable;
EFI_EVENT PeriodicTimer;
EFI_EVENT PeriodicTimer;
};
//

View file

@ -193,28 +193,40 @@ struct _IP4_SERVICE {
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
EFI_SIMPLE_NETWORK_MODE SnpMode;
EFI_EVENT Timer;
EFI_EVENT ReconfigCheckTimer;
EFI_EVENT ReconfigEvent;
//
// SnpMode is a cached copy of the SNP device configuration data (MAC address,
// media header size, hardware address size, interface type, etc.). This copy is
// obtained during service initialization via GetModeData.
//
// IMPORTANT: This cached data becomes STALE if MnpConfigure() is called, as
// MnpConfigure triggers SNP Start/Initialize which may finalize or alter mode
// fields not set before Start. Code that calls MnpConfigure must refetch the
// SNP mode data via GetModeData after reconfiguration to ensure values like
// MediaHeaderSize, CurrentAddress, and HwAddressSize remain valid.
//
EFI_SIMPLE_NETWORK_MODE SnpMode;
BOOLEAN Reconfig;
EFI_EVENT Timer;
EFI_EVENT ReconfigCheckTimer;
EFI_EVENT ReconfigEvent;
BOOLEAN Reconfig;
//
// Underlying media present status.
//
BOOLEAN MediaPresent;
BOOLEAN MediaPresent;
//
// IPv4 Configuration II Protocol instance
//
IP4_CONFIG2_INSTANCE Ip4Config2Instance;
IP4_CONFIG2_INSTANCE Ip4Config2Instance;
CHAR16 *MacString;
CHAR16 *MacString;
UINT32 MaxPacketSize;
UINT32 OldMaxPacketSize; ///< The MTU before IPsec enable.
UINT32 MaxPacketSize;
UINT32 OldMaxPacketSize; ///< The MTU before IPsec enable.
};
#define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \

View file

@ -220,23 +220,35 @@ struct _IP6_SERVICE {
EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
EFI_SIMPLE_NETWORK_MODE SnpMode;
EFI_EVENT Timer;
EFI_EVENT FasterTimer;
//
// SnpMode is a cached copy of the SNP device configuration data (MAC address,
// media header size, hardware address size, interface type, etc.). This copy is
// obtained during service initialization via GetModeData.
//
// IMPORTANT: This cached data becomes STALE if MnpConfigure() is called, as
// MnpConfigure triggers SNP Start/Initialize which may finalize or alter mode
// fields not set before Start. Code that calls MnpConfigure must refetch the
// SNP mode data via GetModeData after reconfiguration to ensure values like
// MediaHeaderSize, CurrentAddress, and HwAddressSize remain valid.
//
EFI_SIMPLE_NETWORK_MODE SnpMode;
EFI_EVENT Timer;
EFI_EVENT FasterTimer;
//
// IPv6 Configuration Protocol instance
//
IP6_CONFIG_INSTANCE Ip6ConfigInstance;
IP6_CONFIG_INSTANCE Ip6ConfigInstance;
//
// The string representation of the current mac address of the
// NIC this IP6_SERVICE works on.
//
CHAR16 *MacString;
UINT32 MaxPacketSize;
UINT32 OldMaxPacketSize;
CHAR16 *MacString;
UINT32 MaxPacketSize;
UINT32 OldMaxPacketSize;
};
/**