NetworkPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the NetworkPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:07 -08:00
committed by mergify[bot]
parent 2f88bd3a12
commit d1050b9dff
294 changed files with 29888 additions and 30440 deletions

View File

@@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// EFI Component Name Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName = {
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName = {
MnpComponentNameGetDriverName,
MnpComponentNameGetControllerName,
"eng"
@@ -21,12 +21,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName =
// EFI Component Name 2 Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) MnpComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) MnpComponentNameGetControllerName,
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)MnpComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)MnpComponentNameGetControllerName,
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMnpDriverNameTable[] = {
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMnpDriverNameTable[] = {
{
"eng;en",
L"MNP Network Service Driver"
@@ -37,7 +37,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMnpDriverNameTable[
}
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMnpControllerNameTable = NULL;
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMnpControllerNameTable = NULL;
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -81,9 +81,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gMnpControllerNameTab
EFI_STATUS
EFIAPI
MnpComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
@@ -91,7 +91,7 @@ MnpComponentNameGetDriverName (
This->SupportedLanguages,
mMnpDriverNameTable,
DriverName,
(BOOLEAN) (This == &gMnpComponentName)
(BOOLEAN)(This == &gMnpComponentName)
);
}
@@ -107,7 +107,7 @@ MnpComponentNameGetDriverName (
**/
EFI_STATUS
UpdateName (
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp
IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp
)
{
EFI_STATUS Status;
@@ -146,6 +146,7 @@ UpdateName (
SnpModeData.CurrentAddress.Addr[Index]
);
}
ASSERT (OffSet > 0);
//
// Remove the last '-'
@@ -267,11 +268,11 @@ UpdateName (
EFI_STATUS
EFIAPI
MnpComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;

View File

@@ -12,9 +12,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/ComponentName.h>
#include <Protocol/ComponentName2.h>
extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2;
extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName;
extern EFI_UNICODE_STRING_TABLE *gMnpControllerNameTable;
extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2;
extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName;
extern EFI_UNICODE_STRING_TABLE *gMnpControllerNameTable;
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -58,9 +58,9 @@ extern EFI_UNICODE_STRING_TABLE *gMnpControllerNameTable;
EFI_STATUS
EFIAPI
MnpComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
/**
@@ -134,11 +134,11 @@ MnpComponentNameGetDriverName (
EFI_STATUS
EFIAPI
MnpComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
#endif

View File

@@ -9,12 +9,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "MnpImpl.h"
#include "MnpVlan.h"
EFI_SERVICE_BINDING_PROTOCOL mMnpServiceBindingProtocol = {
EFI_SERVICE_BINDING_PROTOCOL mMnpServiceBindingProtocol = {
MnpServiceBindingCreateChild,
MnpServiceBindingDestroyChild
};
EFI_MANAGED_NETWORK_PROTOCOL mMnpProtocolTemplate = {
EFI_MANAGED_NETWORK_PROTOCOL mMnpProtocolTemplate = {
MnpGetModeData,
MnpConfigure,
MnpMcastIpToMac,
@@ -25,7 +25,7 @@ EFI_MANAGED_NETWORK_PROTOCOL mMnpProtocolTemplate = {
MnpPoll
};
EFI_MANAGED_NETWORK_CONFIG_DATA mMnpDefaultConfigData = {
EFI_MANAGED_NETWORK_CONFIG_DATA mMnpDefaultConfigData = {
10000000,
10000000,
0,
@@ -52,8 +52,8 @@ EFI_MANAGED_NETWORK_CONFIG_DATA mMnpDefaultConfigData = {
**/
EFI_STATUS
MnpAddFreeNbuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN Count
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN Count
)
{
EFI_STATUS Status;
@@ -88,7 +88,6 @@ MnpAddFreeNbuf (
return Status;
}
/**
Allocate a free NET_BUF from MnpDeviceData->FreeNbufQue. If there is none
in the queue, first try to allocate some and add them into the queue, then
@@ -102,13 +101,13 @@ MnpAddFreeNbuf (
**/
NET_BUF *
MnpAllocNbuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
)
{
EFI_STATUS Status;
NET_BUF_QUEUE *FreeNbufQue;
NET_BUF *Nbuf;
EFI_TPL OldTpl;
EFI_STATUS Status;
NET_BUF_QUEUE *FreeNbufQue;
NET_BUF *Nbuf;
EFI_TPL OldTpl;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
@@ -122,8 +121,8 @@ MnpAllocNbuf (
if ((MnpDeviceData->NbufCnt + MNP_NET_BUFFER_INCREASEMENT) > MNP_MAX_NET_BUFFER_NUM) {
DEBUG (
(DEBUG_ERROR,
"MnpAllocNbuf: The maximum NET_BUF size is reached for MNP driver instance %p.\n",
MnpDeviceData)
"MnpAllocNbuf: The maximum NET_BUF size is reached for MNP driver instance %p.\n",
MnpDeviceData)
);
Nbuf = NULL;
@@ -134,8 +133,8 @@ MnpAllocNbuf (
if (EFI_ERROR (Status)) {
DEBUG (
(DEBUG_ERROR,
"MnpAllocNbuf: Failed to add NET_BUFs into the FreeNbufQue, %r.\n",
Status)
"MnpAllocNbuf: Failed to add NET_BUFs into the FreeNbufQue, %r.\n",
Status)
);
//
@@ -160,7 +159,6 @@ ON_EXIT:
return Nbuf;
}
/**
Try to reclaim the Nbuf into the buffer pool.
@@ -170,8 +168,8 @@ ON_EXIT:
**/
VOID
MnpFreeNbuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf
)
{
EFI_TPL OldTpl;
@@ -215,26 +213,27 @@ MnpFreeNbuf (
**/
EFI_STATUS
MnpAddFreeTxBuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN Count
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN Count
)
{
EFI_STATUS Status;
UINT32 Index;
MNP_TX_BUF_WRAP *TxBufWrap;
EFI_STATUS Status;
UINT32 Index;
MNP_TX_BUF_WRAP *TxBufWrap;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
ASSERT ((Count > 0) && (MnpDeviceData->BufferLength > 0));
Status = EFI_SUCCESS;
for (Index = 0; Index < Count; Index++) {
TxBufWrap = (MNP_TX_BUF_WRAP*) AllocatePool (OFFSET_OF (MNP_TX_BUF_WRAP, TxBuf) + MnpDeviceData->BufferLength );
TxBufWrap = (MNP_TX_BUF_WRAP *)AllocatePool (OFFSET_OF (MNP_TX_BUF_WRAP, TxBuf) + MnpDeviceData->BufferLength);
if (TxBufWrap == NULL) {
DEBUG ((DEBUG_ERROR, "MnpAddFreeTxBuf: TxBuf Alloc failed.\n"));
Status = EFI_OUT_OF_RESOURCES;
break;
}
DEBUG ((DEBUG_INFO, "MnpAddFreeTxBuf: Add TxBufWrap %p, TxBuf %p\n", TxBufWrap, TxBufWrap->TxBuf));
TxBufWrap->Signature = MNP_TX_BUF_WRAP_SIGNATURE;
TxBufWrap->InUse = FALSE;
@@ -259,14 +258,14 @@ MnpAddFreeTxBuf (
**/
UINT8 *
MnpAllocTxBuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
)
{
EFI_TPL OldTpl;
UINT8 *TxBuf;
EFI_STATUS Status;
LIST_ENTRY *Entry;
MNP_TX_BUF_WRAP *TxBufWrap;
EFI_TPL OldTpl;
UINT8 *TxBuf;
EFI_STATUS Status;
LIST_ENTRY *Entry;
MNP_TX_BUF_WRAP *TxBufWrap;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
@@ -289,8 +288,8 @@ MnpAllocTxBuf (
if ((MnpDeviceData->TxBufCount + MNP_TX_BUFFER_INCREASEMENT) > MNP_MAX_TX_BUFFER_NUM) {
DEBUG (
(DEBUG_ERROR,
"MnpAllocTxBuf: The maximum TxBuf size is reached for MNP driver instance %p.\n",
MnpDeviceData)
"MnpAllocTxBuf: The maximum TxBuf size is reached for MNP driver instance %p.\n",
MnpDeviceData)
);
TxBuf = NULL;
@@ -301,8 +300,8 @@ MnpAllocTxBuf (
if (IsListEmpty (&MnpDeviceData->FreeTxBufList)) {
DEBUG (
(DEBUG_ERROR,
"MnpAllocNbuf: Failed to add TxBuf into the FreeTxBufList, %r.\n",
Status)
"MnpAllocNbuf: Failed to add TxBuf into the FreeTxBufList, %r.\n",
Status)
);
TxBuf = NULL;
@@ -314,9 +313,9 @@ MnpAllocTxBuf (
ASSERT (!IsListEmpty (&MnpDeviceData->FreeTxBufList));
Entry = MnpDeviceData->FreeTxBufList.ForwardLink;
RemoveEntryList (MnpDeviceData->FreeTxBufList.ForwardLink);
TxBufWrap = NET_LIST_USER_STRUCT_S (Entry, MNP_TX_BUF_WRAP, WrapEntry, MNP_TX_BUF_WRAP_SIGNATURE);
TxBufWrap = NET_LIST_USER_STRUCT_S (Entry, MNP_TX_BUF_WRAP, WrapEntry, MNP_TX_BUF_WRAP_SIGNATURE);
TxBufWrap->InUse = TRUE;
TxBuf = TxBufWrap->TxBuf;
TxBuf = TxBufWrap->TxBuf;
ON_EXIT:
gBS->RestoreTPL (OldTpl);
@@ -333,12 +332,12 @@ ON_EXIT:
**/
VOID
MnpFreeTxBuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT UINT8 *TxBuf
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT UINT8 *TxBuf
)
{
MNP_TX_BUF_WRAP *TxBufWrap;
EFI_TPL OldTpl;
MNP_TX_BUF_WRAP *TxBufWrap;
EFI_TPL OldTpl;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
@@ -350,7 +349,7 @@ MnpFreeTxBuf (
if (TxBufWrap->Signature != MNP_TX_BUF_WRAP_SIGNATURE) {
DEBUG (
(DEBUG_ERROR,
"MnpFreeTxBuf: Signature check failed in MnpFreeTxBuf.\n")
"MnpFreeTxBuf: Signature check failed in MnpFreeTxBuf.\n")
);
return;
}
@@ -358,7 +357,7 @@ MnpFreeTxBuf (
if (!TxBufWrap->InUse) {
DEBUG (
(DEBUG_WARN,
"MnpFreeTxBuf: Duplicated recycle report from SNP.\n")
"MnpFreeTxBuf: Duplicated recycle report from SNP.\n")
);
return;
}
@@ -380,19 +379,19 @@ MnpFreeTxBuf (
**/
EFI_STATUS
MnpRecycleTxBuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
)
{
UINT8 *TxBuf;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_STATUS Status;
UINT8 *TxBuf;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_STATUS Status;
Snp = MnpDeviceData->Snp;
ASSERT (Snp != NULL);
do {
TxBuf = NULL;
Status = Snp->GetStatus (Snp, NULL, (VOID **) &TxBuf);
TxBuf = NULL;
Status = Snp->GetStatus (Snp, NULL, (VOID **)&TxBuf);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -419,14 +418,14 @@ MnpRecycleTxBuf (
**/
EFI_STATUS
MnpInitializeDeviceData (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle
)
{
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MnpDeviceData->Signature = MNP_DEVICE_DATA_SIGNATURE;
MnpDeviceData->ImageHandle = ImageHandle;
@@ -443,7 +442,7 @@ MnpInitializeDeviceData (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiSimpleNetworkProtocolGuid,
(VOID **) &Snp,
(VOID **)&Snp,
ImageHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -594,17 +593,16 @@ ERROR:
// Close the Simple Network Protocol.
//
gBS->CloseProtocol (
ControllerHandle,
&gEfiSimpleNetworkProtocolGuid,
ImageHandle,
ControllerHandle
);
ControllerHandle,
&gEfiSimpleNetworkProtocolGuid,
ImageHandle,
ControllerHandle
);
}
return Status;
}
/**
Destroy the MNP device context data.
@@ -614,13 +612,13 @@ ERROR:
**/
VOID
MnpDestroyDeviceData (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle
)
{
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
MNP_TX_BUF_WRAP *TxBufWrap;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
MNP_TX_BUF_WRAP *TxBufWrap;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
@@ -646,7 +644,7 @@ MnpDestroyDeviceData (
//
// Free the Tx buffer pool.
//
NET_LIST_FOR_EACH_SAFE(Entry, NextEntry, &MnpDeviceData->AllTxBufList) {
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &MnpDeviceData->AllTxBufList) {
TxBufWrap = NET_LIST_USER_STRUCT (Entry, MNP_TX_BUF_WRAP, AllEntry);
RemoveEntryList (Entry);
FreePool (TxBufWrap);
@@ -677,7 +675,6 @@ MnpDestroyDeviceData (
);
}
/**
Create mnp service context data.
@@ -691,9 +688,9 @@ MnpDestroyDeviceData (
**/
MNP_SERVICE_DATA *
MnpCreateServiceData (
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId,
IN UINT8 Priority OPTIONAL
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId,
IN UINT8 Priority OPTIONAL
)
{
EFI_HANDLE MnpServiceHandle;
@@ -753,7 +750,7 @@ MnpCreateServiceData (
Status = gBS->OpenProtocol (
MnpDeviceData->ControllerHandle,
&gEfiVlanConfigProtocolGuid,
(VOID **) &VlanConfig,
(VOID **)&VlanConfig,
MnpDeviceData->ImageHandle,
MnpServiceHandle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -808,7 +805,7 @@ Exit:
**/
EFI_STATUS
MnpDestroyServiceData (
IN OUT MNP_SERVICE_DATA *MnpServiceData
IN OUT MNP_SERVICE_DATA *MnpServiceData
)
{
EFI_STATUS Status;
@@ -881,15 +878,15 @@ MnpDestroyServiceData (
EFI_STATUS
EFIAPI
MnpDestoryChildEntry (
IN LIST_ENTRY *Entry,
IN VOID *Context
IN LIST_ENTRY *Entry,
IN VOID *Context
)
{
MNP_INSTANCE_DATA *Instance;
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context;
Instance = CR (Entry, MNP_INSTANCE_DATA, InstEntry, MNP_INSTANCE_DATA_SIGNATURE);
ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *)Context;
Instance = CR (Entry, MNP_INSTANCE_DATA, InstEntry, MNP_INSTANCE_DATA_SIGNATURE);
return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
}
@@ -904,12 +901,12 @@ MnpDestoryChildEntry (
**/
EFI_STATUS
MnpDestroyServiceChild (
IN OUT MNP_SERVICE_DATA *MnpServiceData
IN OUT MNP_SERVICE_DATA *MnpServiceData
)
{
LIST_ENTRY *List;
EFI_STATUS Status;
UINTN ListLength;
LIST_ENTRY *List;
EFI_STATUS Status;
UINTN ListLength;
List = &MnpServiceData->ChildrenList;
@@ -919,7 +916,7 @@ MnpDestroyServiceChild (
&MnpServiceData->ServiceBinding,
&ListLength
);
if (EFI_ERROR (Status) || ListLength != 0) {
if (EFI_ERROR (Status) || (ListLength != 0)) {
return EFI_DEVICE_ERROR;
}
@@ -937,8 +934,8 @@ MnpDestroyServiceChild (
**/
MNP_SERVICE_DATA *
MnpFindServiceData (
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId
)
{
LIST_ENTRY *Entry;
@@ -967,8 +964,8 @@ MnpFindServiceData (
**/
VOID
MnpInitializeInstanceData (
IN MNP_SERVICE_DATA *MnpServiceData,
IN OUT MNP_INSTANCE_DATA *Instance
IN MNP_SERVICE_DATA *MnpServiceData,
IN OUT MNP_INSTANCE_DATA *Instance
)
{
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
@@ -1007,7 +1004,6 @@ MnpInitializeInstanceData (
Instance->MnpServiceData = MnpServiceData;
}
/**
Check whether the token specified by Arg matches the token in Item.
@@ -1025,16 +1021,16 @@ MnpInitializeInstanceData (
EFI_STATUS
EFIAPI
MnpTokenExist (
IN NET_MAP *Map,
IN NET_MAP_ITEM *Item,
IN VOID *Arg
IN NET_MAP *Map,
IN NET_MAP_ITEM *Item,
IN VOID *Arg
)
{
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token;
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *TokenInItem;
Token = (EFI_MANAGED_NETWORK_COMPLETION_TOKEN *) Arg;
TokenInItem = (EFI_MANAGED_NETWORK_COMPLETION_TOKEN *) Item->Key;
Token = (EFI_MANAGED_NETWORK_COMPLETION_TOKEN *)Arg;
TokenInItem = (EFI_MANAGED_NETWORK_COMPLETION_TOKEN *)Item->Key;
if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
//
@@ -1065,9 +1061,9 @@ MnpTokenExist (
EFI_STATUS
EFIAPI
MnpCancelTokens (
IN OUT NET_MAP *Map,
IN OUT NET_MAP_ITEM *Item,
IN VOID *Arg
IN OUT NET_MAP *Map,
IN OUT NET_MAP_ITEM *Item,
IN VOID *Arg
)
{
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *TokenToCancel;
@@ -1079,7 +1075,7 @@ MnpCancelTokens (
return EFI_SUCCESS;
}
TokenToCancel = (EFI_MANAGED_NETWORK_COMPLETION_TOKEN *) Item->Key;
TokenToCancel = (EFI_MANAGED_NETWORK_COMPLETION_TOKEN *)Item->Key;
//
// Remove the item from the map.
@@ -1102,7 +1098,6 @@ MnpCancelTokens (
return EFI_SUCCESS;
}
/**
Start and initialize the simple network.
@@ -1114,7 +1109,7 @@ MnpCancelTokens (
**/
EFI_STATUS
MnpStartSnp (
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp
)
{
EFI_STATUS Status;
@@ -1136,7 +1131,6 @@ MnpStartSnp (
return Status;
}
/**
Stop the simple network.
@@ -1148,11 +1142,11 @@ MnpStartSnp (
**/
EFI_STATUS
MnpStopSnp (
IN MNP_DEVICE_DATA *MnpDeviceData
IN MNP_DEVICE_DATA *MnpDeviceData
)
{
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
Snp = MnpDeviceData->Snp;
ASSERT (Snp != NULL);
@@ -1168,7 +1162,7 @@ MnpStopSnp (
//
// Shut down the simple network.
//
Status = Snp->Shutdown (Snp);
Status = Snp->Shutdown (Snp);
if (!EFI_ERROR (Status)) {
//
// Stop the simple network.
@@ -1179,7 +1173,6 @@ MnpStopSnp (
return Status;
}
/**
Start the managed network, this function is called when one instance is configured
or reconfigured.
@@ -1196,14 +1189,14 @@ MnpStopSnp (
**/
EFI_STATUS
MnpStart (
IN OUT MNP_SERVICE_DATA *MnpServiceData,
IN BOOLEAN IsConfigUpdate,
IN BOOLEAN EnableSystemPoll
IN OUT MNP_SERVICE_DATA *MnpServiceData,
IN BOOLEAN IsConfigUpdate,
IN BOOLEAN EnableSystemPoll
)
{
EFI_STATUS Status;
EFI_TIMER_DELAY TimerOpType;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_STATUS Status;
EFI_TIMER_DELAY TimerOpType;
MNP_DEVICE_DATA *MnpDeviceData;
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
@@ -1238,8 +1231,8 @@ MnpStart (
if (EFI_ERROR (Status)) {
DEBUG (
(DEBUG_ERROR,
"MnpStart, gBS->SetTimer for TimeoutCheckTimer %r.\n",
Status)
"MnpStart, gBS->SetTimer for TimeoutCheckTimer %r.\n",
Status)
);
goto ErrorExit;
@@ -1256,8 +1249,8 @@ MnpStart (
if (EFI_ERROR (Status)) {
DEBUG (
(DEBUG_ERROR,
"MnpStart, gBS->SetTimer for MediaDetectTimer %r.\n",
Status)
"MnpStart, gBS->SetTimer for MediaDetectTimer %r.\n",
Status)
);
goto ErrorExit;
@@ -1272,7 +1265,7 @@ MnpStart (
//
TimerOpType = EnableSystemPoll ? TimerPeriodic : TimerCancel;
Status = gBS->SetTimer (MnpDeviceData->PollTimer, TimerOpType, MNP_SYS_POLL_INTERVAL);
Status = gBS->SetTimer (MnpDeviceData->PollTimer, TimerOpType, MNP_SYS_POLL_INTERVAL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MnpStart: gBS->SetTimer for PollTimer failed, %r.\n", Status));
@@ -1291,7 +1284,6 @@ ErrorExit:
return Status;
}
/**
Stop the managed network.
@@ -1303,11 +1295,11 @@ ErrorExit:
**/
EFI_STATUS
MnpStop (
IN OUT MNP_SERVICE_DATA *MnpServiceData
IN OUT MNP_SERVICE_DATA *MnpServiceData
)
{
EFI_STATUS Status;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_STATUS Status;
MNP_DEVICE_DATA *MnpDeviceData;
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
MnpDeviceData = MnpServiceData->MnpDeviceData;
@@ -1338,7 +1330,7 @@ MnpStop (
//
// The system poll in on, cancel the poll timer.
//
Status = gBS->SetTimer (MnpDeviceData->PollTimer, TimerCancel, 0);
Status = gBS->SetTimer (MnpDeviceData->PollTimer, TimerCancel, 0);
MnpDeviceData->EnableSystemPoll = FALSE;
}
@@ -1359,7 +1351,6 @@ MnpStop (
return Status;
}
/**
Flush the instance's received data.
@@ -1368,11 +1359,11 @@ MnpStop (
**/
VOID
MnpFlushRcvdDataQueue (
IN OUT MNP_INSTANCE_DATA *Instance
IN OUT MNP_INSTANCE_DATA *Instance
)
{
EFI_TPL OldTpl;
MNP_RXDATA_WRAP *RxDataWrap;
EFI_TPL OldTpl;
MNP_RXDATA_WRAP *RxDataWrap;
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -1387,7 +1378,7 @@ MnpFlushRcvdDataQueue (
//
// Recycle the RxDataWrap.
//
MnpRecycleRxData (NULL, (VOID *) RxDataWrap);
MnpRecycleRxData (NULL, (VOID *)RxDataWrap);
Instance->RcvdPacketQueueSize--;
}
@@ -1396,7 +1387,6 @@ MnpFlushRcvdDataQueue (
gBS->RestoreTPL (OldTpl);
}
/**
Configure the Instance using ConfigData.
@@ -1412,16 +1402,16 @@ MnpFlushRcvdDataQueue (
**/
EFI_STATUS
MnpConfigureInstance (
IN OUT MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData OPTIONAL
IN OUT MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData OPTIONAL
)
{
EFI_STATUS Status;
MNP_SERVICE_DATA *MnpServiceData;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_MANAGED_NETWORK_CONFIG_DATA *OldConfigData;
EFI_MANAGED_NETWORK_CONFIG_DATA *NewConfigData;
BOOLEAN IsConfigUpdate;
EFI_STATUS Status;
MNP_SERVICE_DATA *MnpServiceData;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_MANAGED_NETWORK_CONFIG_DATA *OldConfigData;
EFI_MANAGED_NETWORK_CONFIG_DATA *NewConfigData;
BOOLEAN IsConfigUpdate;
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -1432,16 +1422,16 @@ MnpConfigureInstance (
return EFI_UNSUPPORTED;
}
Status = EFI_SUCCESS;
Status = EFI_SUCCESS;
MnpServiceData = Instance->MnpServiceData;
MnpDeviceData = MnpServiceData->MnpDeviceData;
MnpServiceData = Instance->MnpServiceData;
MnpDeviceData = MnpServiceData->MnpDeviceData;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
IsConfigUpdate = (BOOLEAN) ((Instance->Configured) && (ConfigData != NULL));
IsConfigUpdate = (BOOLEAN)((Instance->Configured) && (ConfigData != NULL));
OldConfigData = &Instance->ConfigData;
NewConfigData = ConfigData;
OldConfigData = &Instance->ConfigData;
NewConfigData = ConfigData;
if (NewConfigData == NULL) {
//
// Restore back the default config data if a reset of this instance
@@ -1513,16 +1503,16 @@ MnpConfigureInstance (
//
CopyMem (OldConfigData, NewConfigData, sizeof (*OldConfigData));
Instance->Configured = (BOOLEAN) (ConfigData != NULL);
Instance->Configured = (BOOLEAN)(ConfigData != NULL);
if (Instance->Configured) {
//
// The instance is configured, start the Mnp.
//
Status = MnpStart (
MnpServiceData,
IsConfigUpdate,
(BOOLEAN) !NewConfigData->DisableBackgroundPolling
);
MnpServiceData,
IsConfigUpdate,
(BOOLEAN) !NewConfigData->DisableBackgroundPolling
);
} else {
//
// The instance is changed to the unconfigured state, stop the Mnp.
@@ -1546,19 +1536,19 @@ MnpConfigureInstance (
**/
EFI_STATUS
MnpConfigReceiveFilters (
IN MNP_DEVICE_DATA *MnpDeviceData
IN MNP_DEVICE_DATA *MnpDeviceData
)
{
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_MAC_ADDRESS *MCastFilter;
UINT32 MCastFilterCnt;
UINT32 EnableFilterBits;
UINT32 DisableFilterBits;
BOOLEAN ResetMCastFilters;
LIST_ENTRY *Entry;
UINT32 Index;
MNP_GROUP_ADDRESS *GroupAddress;
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_MAC_ADDRESS *MCastFilter;
UINT32 MCastFilterCnt;
UINT32 EnableFilterBits;
UINT32 DisableFilterBits;
BOOLEAN ResetMCastFilters;
LIST_ENTRY *Entry;
UINT32 Index;
MNP_GROUP_ADDRESS *GroupAddress;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
@@ -1607,8 +1597,8 @@ MnpConfigReceiveFilters (
//
// Allocate pool for the multicast addresses.
//
MCastFilterCnt = MnpDeviceData->GroupAddressCount;
MCastFilter = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);
MCastFilterCnt = MnpDeviceData->GroupAddressCount;
MCastFilter = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);
if (MCastFilter == NULL) {
DEBUG ((DEBUG_ERROR, "MnpConfigReceiveFilters: Failed to allocate memory resource for MCastFilter.\n"));
@@ -1620,7 +1610,6 @@ MnpConfigReceiveFilters (
//
Index = 0;
NET_LIST_FOR_EACH (Entry, &MnpDeviceData->GroupAddressList) {
GroupAddress = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry);
CopyMem (MCastFilter + Index, &GroupAddress->Address, sizeof (*(MCastFilter + Index)));
Index++;
@@ -1670,13 +1659,14 @@ MnpConfigReceiveFilters (
MCastFilter
);
DEBUG_CODE_BEGIN ();
if (EFI_ERROR (Status)) {
DEBUG (
(DEBUG_ERROR,
"MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n",
Status)
);
}
if (EFI_ERROR (Status)) {
DEBUG (
(DEBUG_ERROR,
"MnpConfigReceiveFilters: Snp->ReceiveFilters failed, %r.\n",
Status)
);
}
DEBUG_CODE_END ();
if (MCastFilter != NULL) {
@@ -1689,7 +1679,6 @@ MnpConfigReceiveFilters (
return Status;
}
/**
Add a group address control block which controls the MacAddress for
this instance.
@@ -1706,11 +1695,11 @@ MnpConfigReceiveFilters (
**/
EFI_STATUS
MnpGroupOpAddCtrlBlk (
IN OUT MNP_INSTANCE_DATA *Instance,
IN OUT MNP_GROUP_CONTROL_BLOCK *CtrlBlk,
IN OUT MNP_GROUP_ADDRESS *GroupAddress OPTIONAL,
IN EFI_MAC_ADDRESS *MacAddress,
IN UINT32 HwAddressSize
IN OUT MNP_INSTANCE_DATA *Instance,
IN OUT MNP_GROUP_CONTROL_BLOCK *CtrlBlk,
IN OUT MNP_GROUP_ADDRESS *GroupAddress OPTIONAL,
IN EFI_MAC_ADDRESS *MacAddress,
IN UINT32 HwAddressSize
)
{
MNP_DEVICE_DATA *MnpDeviceData;
@@ -1728,7 +1717,6 @@ MnpGroupOpAddCtrlBlk (
//
GroupAddress = AllocatePool (sizeof (MNP_GROUP_ADDRESS));
if (GroupAddress == NULL) {
DEBUG ((DEBUG_ERROR, "MnpGroupOpFormCtrlBlk: Failed to allocate memory resource.\n"));
return EFI_OUT_OF_RESOURCES;
@@ -1757,7 +1745,6 @@ MnpGroupOpAddCtrlBlk (
return EFI_SUCCESS;
}
/**
Delete a group control block from the instance. If the controlled group address's
reference count reaches zero, the group address is removed too.
@@ -1770,12 +1757,12 @@ MnpGroupOpAddCtrlBlk (
**/
BOOLEAN
MnpGroupOpDelCtrlBlk (
IN MNP_INSTANCE_DATA *Instance,
IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk
IN MNP_INSTANCE_DATA *Instance,
IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk
)
{
MNP_DEVICE_DATA *MnpDeviceData;
MNP_GROUP_ADDRESS *GroupAddress;
MNP_DEVICE_DATA *MnpDeviceData;
MNP_GROUP_ADDRESS *GroupAddress;
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -1810,7 +1797,6 @@ MnpGroupOpDelCtrlBlk (
return FALSE;
}
/**
Do the group operations for this instance.
@@ -1828,21 +1814,21 @@ MnpGroupOpDelCtrlBlk (
**/
EFI_STATUS
MnpGroupOp (
IN OUT MNP_INSTANCE_DATA *Instance,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL,
IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk OPTIONAL
IN OUT MNP_INSTANCE_DATA *Instance,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL,
IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk OPTIONAL
)
{
MNP_DEVICE_DATA *MnpDeviceData;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
MNP_GROUP_ADDRESS *GroupAddress;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MNP_GROUP_CONTROL_BLOCK *NewCtrlBlk;
EFI_STATUS Status;
BOOLEAN AddressExist;
BOOLEAN NeedUpdate;
MNP_DEVICE_DATA *MnpDeviceData;
LIST_ENTRY *Entry;
LIST_ENTRY *NextEntry;
MNP_GROUP_ADDRESS *GroupAddress;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MNP_GROUP_CONTROL_BLOCK *NewCtrlBlk;
EFI_STATUS Status;
BOOLEAN AddressExist;
BOOLEAN NeedUpdate;
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -1853,8 +1839,8 @@ MnpGroupOp (
//
// A new group address is to be added.
//
GroupAddress = NULL;
AddressExist = FALSE;
GroupAddress = NULL;
AddressExist = FALSE;
//
// Allocate memory for the control block.
@@ -1885,12 +1871,12 @@ MnpGroupOp (
// Add the GroupAddress for this instance.
//
Status = MnpGroupOpAddCtrlBlk (
Instance,
NewCtrlBlk,
GroupAddress,
MacAddress,
SnpMode->HwAddressSize
);
Instance,
NewCtrlBlk,
GroupAddress,
MacAddress,
SnpMode->HwAddressSize
);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1911,12 +1897,11 @@ MnpGroupOp (
NeedUpdate = FALSE;
NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Instance->GroupCtrlBlkList) {
NewCtrlBlk = NET_LIST_USER_STRUCT (
Entry,
MNP_GROUP_CONTROL_BLOCK,
CtrlBlkEntry
);
Entry,
MNP_GROUP_CONTROL_BLOCK,
CtrlBlkEntry
);
//
// Update is required if the group address left is no longer used
// by other instances.

View File

@@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "MnpImpl.h"
#include "MnpVlan.h"
EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
MnpDriverBindingSupported,
MnpDriverBindingStart,
MnpDriverBindingStop,
@@ -32,11 +32,11 @@ EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
EFI_STATUS
EFIAPI
MnpDestroyServiceDataEntry (
IN LIST_ENTRY *Entry,
IN VOID *Context
IN LIST_ENTRY *Entry,
IN VOID *Context
)
{
MNP_SERVICE_DATA *MnpServiceData;
MNP_SERVICE_DATA *MnpServiceData;
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
return MnpDestroyServiceData (MnpServiceData);
@@ -55,11 +55,11 @@ MnpDestroyServiceDataEntry (
EFI_STATUS
EFIAPI
MnpDestroyServiceChildEntry (
IN LIST_ENTRY *Entry,
IN VOID *Context
IN LIST_ENTRY *Entry,
IN VOID *Context
)
{
MNP_SERVICE_DATA *MnpServiceData;
MNP_SERVICE_DATA *MnpServiceData;
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
return MnpDestroyServiceChild (MnpServiceData);
@@ -86,9 +86,9 @@ MnpDestroyServiceChildEntry (
EFI_STATUS
EFIAPI
MnpDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
@@ -100,7 +100,7 @@ MnpDriverBindingSupported (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiSimpleNetworkProtocolGuid,
(VOID **) &Snp,
(VOID **)&Snp,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -122,7 +122,6 @@ MnpDriverBindingSupported (
return EFI_SUCCESS;
}
/**
Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make drivers as small
@@ -144,9 +143,9 @@ MnpDriverBindingSupported (
EFI_STATUS
EFIAPI
MnpDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
EFI_STATUS Status;
@@ -196,7 +195,7 @@ MnpDriverBindingStart (
MnpDeviceData->NumberOfVlan = 0;
ZeroMem (&MnpDeviceData->VlanConfig, sizeof (EFI_VLAN_CONFIG_PROTOCOL));
MnpServiceData = MnpCreateServiceData (MnpDeviceData, 0, 0);
Status = (MnpServiceData != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
Status = (MnpServiceData != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
goto Exit;
}
@@ -217,14 +216,14 @@ MnpDriverBindingStart (
// Get current VLAN configuration from EFI Variable
//
NumberOfVlan = 0;
Status = MnpGetVlanVariable (MnpDeviceData, &NumberOfVlan, &VlanVariable);
Status = MnpGetVlanVariable (MnpDeviceData, &NumberOfVlan, &VlanVariable);
if (EFI_ERROR (Status)) {
//
// No VLAN is set, create a default MNP service data for untagged frame
//
MnpDeviceData->NumberOfVlan = 0;
MnpServiceData = MnpCreateServiceData (MnpDeviceData, 0, 0);
Status = (MnpServiceData != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
MnpServiceData = MnpCreateServiceData (MnpDeviceData, 0, 0);
Status = (MnpServiceData != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
goto Exit;
}
@@ -236,7 +235,7 @@ MnpDriverBindingStart (
MnpServiceData = MnpCreateServiceData (
MnpDeviceData,
VlanVariable[Index].Bits.Vid,
(UINT8) VlanVariable[Index].Bits.Priority
(UINT8)VlanVariable[Index].Bits.Priority
);
if (MnpServiceData == NULL) {
@@ -256,7 +255,7 @@ Exit:
// Destroy all MNP service data
//
while (!IsListEmpty (&MnpDeviceData->ServiceList)) {
Entry = GetFirstNode (&MnpDeviceData->ServiceList);
Entry = GetFirstNode (&MnpDeviceData->ServiceList);
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
MnpDestroyServiceData (MnpServiceData);
}
@@ -304,10 +303,10 @@ Exit:
EFI_STATUS
EFIAPI
MnpDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
EFI_STATUS Status;
@@ -324,7 +323,7 @@ MnpDriverBindingStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiManagedNetworkServiceBindingProtocolGuid,
(VOID **) &ServiceBinding,
(VOID **)&ServiceBinding,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -336,7 +335,7 @@ MnpDriverBindingStop (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiVlanConfigProtocolGuid,
(VOID **) &VlanConfig,
(VOID **)&VlanConfig,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -349,21 +348,21 @@ MnpDriverBindingStop (
MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (VlanConfig);
} else {
MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (ServiceBinding);
MnpDeviceData = MnpServiceData->MnpDeviceData;
MnpDeviceData = MnpServiceData->MnpDeviceData;
}
if (NumberOfChildren == 0) {
//
// Destroy all MNP service data
//
List = &MnpDeviceData->ServiceList;
List = &MnpDeviceData->ServiceList;
Status = NetDestroyLinkList (
List,
MnpDestroyServiceDataEntry,
NULL,
&ListLength
);
if (EFI_ERROR (Status) || ListLength !=0) {
if (EFI_ERROR (Status) || (ListLength != 0)) {
return EFI_DEVICE_ERROR;
}
@@ -389,13 +388,14 @@ MnpDriverBindingStop (
FreeUnicodeStringTable (gMnpControllerNameTable);
gMnpControllerNameTable = NULL;
}
return EFI_SUCCESS;
}
//
// Stop all MNP child
//
List = &MnpDeviceData->ServiceList;
List = &MnpDeviceData->ServiceList;
Status = NetDestroyLinkList (
List,
MnpDestroyServiceChildEntry,
@@ -409,7 +409,6 @@ MnpDriverBindingStop (
return EFI_SUCCESS;
}
/**
Creates a child handle with a set of I/O services.
@@ -429,8 +428,8 @@ MnpDriverBindingStop (
EFI_STATUS
EFIAPI
MnpServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN OUT EFI_HANDLE *ChildHandle
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN OUT EFI_HANDLE *ChildHandle
)
{
EFI_STATUS Status;
@@ -469,8 +468,8 @@ MnpServiceBindingCreateChild (
if (EFI_ERROR (Status)) {
DEBUG (
(DEBUG_ERROR,
"MnpServiceBindingCreateChild: Failed to install the MNP protocol, %r.\n",
Status)
"MnpServiceBindingCreateChild: Failed to install the MNP protocol, %r.\n",
Status)
);
goto ErrorExit;
@@ -484,7 +483,7 @@ MnpServiceBindingCreateChild (
Status = gBS->OpenProtocol (
MnpServiceData->ServiceHandle,
&gEfiManagedNetworkServiceBindingProtocolGuid,
(VOID **) &MnpSb,
(VOID **)&MnpSb,
gMnpDriverBinding.DriverBindingHandle,
Instance->Handle,
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -506,15 +505,13 @@ MnpServiceBindingCreateChild (
ErrorExit:
if (EFI_ERROR (Status)) {
if (Instance->Handle != NULL) {
gBS->UninstallMultipleProtocolInterfaces (
Instance->Handle,
&gEfiManagedNetworkProtocolGuid,
&Instance->ManagedNetwork,
NULL
);
Instance->Handle,
&gEfiManagedNetworkProtocolGuid,
&Instance->ManagedNetwork,
NULL
);
}
FreePool (Instance);
@@ -523,7 +520,6 @@ ErrorExit:
return Status;
}
/**
Destroys a child handle with a set of I/O services.
@@ -548,8 +544,8 @@ ErrorExit:
EFI_STATUS
EFIAPI
MnpServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
)
{
EFI_STATUS Status;
@@ -570,7 +566,7 @@ MnpServiceBindingDestroyChild (
Status = gBS->OpenProtocol (
ChildHandle,
&gEfiManagedNetworkProtocolGuid,
(VOID **) &ManagedNetwork,
(VOID **)&ManagedNetwork,
gMnpDriverBinding.DriverBindingHandle,
ChildHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -615,8 +611,8 @@ MnpServiceBindingDestroyChild (
if (EFI_ERROR (Status)) {
DEBUG (
(DEBUG_ERROR,
"MnpServiceBindingDestroyChild: Failed to uninstall the ManagedNetwork protocol, %r.\n",
Status)
"MnpServiceBindingDestroyChild: Failed to uninstall the ManagedNetwork protocol, %r.\n",
Status)
);
Instance->Destroyed = FALSE;
@@ -668,8 +664,8 @@ MnpServiceBindingDestroyChild (
EFI_STATUS
EFIAPI
MnpDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (

View File

@@ -35,56 +35,56 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Global Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;
extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;
typedef struct {
UINT32 Signature;
UINT32 Signature;
EFI_HANDLE ControllerHandle;
EFI_HANDLE ImageHandle;
EFI_HANDLE ControllerHandle;
EFI_HANDLE ImageHandle;
EFI_VLAN_CONFIG_PROTOCOL VlanConfig;
UINTN NumberOfVlan;
CHAR16 *MacString;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_VLAN_CONFIG_PROTOCOL VlanConfig;
UINTN NumberOfVlan;
CHAR16 *MacString;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
//
// List of MNP_SERVICE_DATA
//
LIST_ENTRY ServiceList;
LIST_ENTRY ServiceList;
//
// Number of configured MNP Service Binding child
//
UINTN ConfiguredChildrenNumber;
UINTN ConfiguredChildrenNumber;
LIST_ENTRY GroupAddressList;
UINT32 GroupAddressCount;
LIST_ENTRY GroupAddressList;
UINT32 GroupAddressCount;
LIST_ENTRY FreeTxBufList;
LIST_ENTRY AllTxBufList;
UINT32 TxBufCount;
LIST_ENTRY FreeTxBufList;
LIST_ENTRY AllTxBufList;
UINT32 TxBufCount;
NET_BUF_QUEUE FreeNbufQue;
INTN NbufCnt;
NET_BUF_QUEUE FreeNbufQue;
INTN NbufCnt;
EFI_EVENT PollTimer;
BOOLEAN EnableSystemPoll;
EFI_EVENT PollTimer;
BOOLEAN EnableSystemPoll;
EFI_EVENT TimeoutCheckTimer;
EFI_EVENT MediaDetectTimer;
EFI_EVENT TimeoutCheckTimer;
EFI_EVENT MediaDetectTimer;
UINT32 UnicastCount;
UINT32 BroadcastCount;
UINT32 MulticastCount;
UINT32 PromiscuousCount;
UINT32 UnicastCount;
UINT32 BroadcastCount;
UINT32 MulticastCount;
UINT32 PromiscuousCount;
//
// The size of the data buffer in the MNP_PACKET_BUFFER used to
// store a packet.
//
UINT32 BufferLength;
UINT32 PaddingSize;
NET_BUF *RxNbufCache;
UINT32 BufferLength;
UINT32 PaddingSize;
NET_BUF *RxNbufCache;
} MNP_DEVICE_DATA;
#define MNP_DEVICE_DATA_FROM_THIS(a) \
@@ -98,25 +98,24 @@ typedef struct {
#define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
typedef struct {
UINT32 Signature;
UINT32 Signature;
LIST_ENTRY Link;
LIST_ENTRY Link;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_HANDLE ServiceHandle;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_HANDLE ServiceHandle;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
LIST_ENTRY ChildrenList;
UINTN ChildrenNumber;
LIST_ENTRY ChildrenList;
UINTN ChildrenNumber;
UINT32 Mtu;
UINT32 Mtu;
UINT16 VlanId;
UINT8 Priority;
UINT16 VlanId;
UINT8 Priority;
} MNP_SERVICE_DATA;
#define MNP_SERVICE_DATA_FROM_THIS(a) \
CR ( \
(a), \
@@ -133,7 +132,6 @@ typedef struct {
MNP_SERVICE_DATA_SIGNATURE \
)
/**
Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In
@@ -155,9 +153,9 @@ typedef struct {
EFI_STATUS
EFIAPI
MnpDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
/**
@@ -181,12 +179,11 @@ MnpDriverBindingSupported (
EFI_STATUS
EFIAPI
MnpDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to make drivers as
@@ -208,10 +205,10 @@ MnpDriverBindingStart (
EFI_STATUS
EFIAPI
MnpDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
);
/**
@@ -233,8 +230,8 @@ MnpDriverBindingStop (
EFI_STATUS
EFIAPI
MnpServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN OUT EFI_HANDLE *ChildHandle
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN OUT EFI_HANDLE *ChildHandle
);
/**
@@ -261,8 +258,8 @@ MnpServiceBindingCreateChild (
EFI_STATUS
EFIAPI
MnpServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
);
#endif

View File

@@ -11,27 +11,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "MnpDriver.h"
#define NET_ETHER_FCS_SIZE 4
#define NET_ETHER_FCS_SIZE 4
#define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 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_INIT_NET_BUFFER_NUM 512
#define MNP_NET_BUFFER_INCREASEMENT 64
#define MNP_MAX_NET_BUFFER_NUM 65536
#define MNP_TX_BUFFER_INCREASEMENT 32 // Same as the recycling Q length for xmit_done in UNDI command.
#define MNP_MAX_TX_BUFFER_NUM 65536
#define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 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_INIT_NET_BUFFER_NUM 512
#define MNP_NET_BUFFER_INCREASEMENT 64
#define MNP_MAX_NET_BUFFER_NUM 65536
#define MNP_TX_BUFFER_INCREASEMENT 32 // Same as the recycling Q length for xmit_done in UNDI command.
#define MNP_MAX_TX_BUFFER_NUM 65536
#define MNP_MAX_RCVD_PACKET_QUE_SIZE 256
#define MNP_RECEIVE_UNICAST 0x01
#define MNP_RECEIVE_BROADCAST 0x02
#define MNP_RECEIVE_UNICAST 0x01
#define MNP_RECEIVE_BROADCAST 0x02
#define UNICAST_PACKET MNP_RECEIVE_UNICAST
#define BROADCAST_PACKET MNP_RECEIVE_BROADCAST
#define UNICAST_PACKET MNP_RECEIVE_UNICAST
#define BROADCAST_PACKET MNP_RECEIVE_BROADCAST
#define MNP_INSTANCE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'I')
#define MNP_INSTANCE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'I')
#define MNP_INSTANCE_DATA_FROM_THIS(a) \
CR ( \
@@ -42,59 +42,59 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
)
typedef struct {
UINT32 Signature;
UINT32 Signature;
MNP_SERVICE_DATA *MnpServiceData;
MNP_SERVICE_DATA *MnpServiceData;
EFI_HANDLE Handle;
EFI_HANDLE Handle;
LIST_ENTRY InstEntry;
LIST_ENTRY InstEntry;
EFI_MANAGED_NETWORK_PROTOCOL ManagedNetwork;
EFI_MANAGED_NETWORK_PROTOCOL ManagedNetwork;
BOOLEAN Configured;
BOOLEAN Destroyed;
BOOLEAN Configured;
BOOLEAN Destroyed;
LIST_ENTRY GroupCtrlBlkList;
LIST_ENTRY GroupCtrlBlkList;
NET_MAP RxTokenMap;
NET_MAP RxTokenMap;
LIST_ENTRY RxDeliveredPacketQueue;
LIST_ENTRY RcvdPacketQueue;
UINTN RcvdPacketQueueSize;
LIST_ENTRY RxDeliveredPacketQueue;
LIST_ENTRY RcvdPacketQueue;
UINTN RcvdPacketQueueSize;
EFI_MANAGED_NETWORK_CONFIG_DATA ConfigData;
EFI_MANAGED_NETWORK_CONFIG_DATA ConfigData;
UINT8 ReceiveFilter;
UINT8 ReceiveFilter;
} MNP_INSTANCE_DATA;
typedef struct {
LIST_ENTRY AddrEntry;
EFI_MAC_ADDRESS Address;
INTN RefCnt;
LIST_ENTRY AddrEntry;
EFI_MAC_ADDRESS Address;
INTN RefCnt;
} MNP_GROUP_ADDRESS;
typedef struct {
LIST_ENTRY CtrlBlkEntry;
MNP_GROUP_ADDRESS *GroupAddress;
LIST_ENTRY CtrlBlkEntry;
MNP_GROUP_ADDRESS *GroupAddress;
} MNP_GROUP_CONTROL_BLOCK;
typedef struct {
LIST_ENTRY WrapEntry;
MNP_INSTANCE_DATA *Instance;
EFI_MANAGED_NETWORK_RECEIVE_DATA RxData;
NET_BUF *Nbuf;
UINT64 TimeoutTick;
LIST_ENTRY WrapEntry;
MNP_INSTANCE_DATA *Instance;
EFI_MANAGED_NETWORK_RECEIVE_DATA RxData;
NET_BUF *Nbuf;
UINT64 TimeoutTick;
} MNP_RXDATA_WRAP;
#define MNP_TX_BUF_WRAP_SIGNATURE SIGNATURE_32 ('M', 'T', 'B', 'W')
#define MNP_TX_BUF_WRAP_SIGNATURE SIGNATURE_32 ('M', 'T', 'B', 'W')
typedef struct {
UINT32 Signature;
LIST_ENTRY WrapEntry; // Link to FreeTxBufList
LIST_ENTRY AllEntry; // Link to AllTxBufList
BOOLEAN InUse;
UINT8 TxBuf[1];
UINT32 Signature;
LIST_ENTRY WrapEntry; // Link to FreeTxBufList
LIST_ENTRY AllEntry; // Link to AllTxBufList
BOOLEAN InUse;
UINT8 TxBuf[1];
} MNP_TX_BUF_WRAP;
/**
@@ -111,9 +111,9 @@ typedef struct {
**/
EFI_STATUS
MnpInitializeDeviceData (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle
);
/**
@@ -125,8 +125,8 @@ MnpInitializeDeviceData (
**/
VOID
MnpDestroyDeviceData (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN EFI_HANDLE ImageHandle
);
/**
@@ -142,9 +142,9 @@ MnpDestroyDeviceData (
**/
MNP_SERVICE_DATA *
MnpCreateServiceData (
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId,
IN UINT8 Priority OPTIONAL
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId,
IN UINT8 Priority OPTIONAL
);
/**
@@ -161,9 +161,9 @@ MnpCreateServiceData (
**/
EFI_STATUS
MnpInitializeServiceData (
IN OUT MNP_SERVICE_DATA *MnpServiceData,
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle
IN OUT MNP_SERVICE_DATA *MnpServiceData,
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle
);
/**
@@ -177,7 +177,7 @@ MnpInitializeServiceData (
**/
EFI_STATUS
MnpDestroyServiceData (
IN OUT MNP_SERVICE_DATA *MnpServiceData
IN OUT MNP_SERVICE_DATA *MnpServiceData
);
/**
@@ -191,7 +191,7 @@ MnpDestroyServiceData (
**/
EFI_STATUS
MnpDestroyServiceChild (
IN OUT MNP_SERVICE_DATA *MnpServiceData
IN OUT MNP_SERVICE_DATA *MnpServiceData
);
/**
@@ -205,8 +205,8 @@ MnpDestroyServiceChild (
**/
MNP_SERVICE_DATA *
MnpFindServiceData (
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINT16 VlanId
);
/**
@@ -219,8 +219,8 @@ MnpFindServiceData (
**/
VOID
MnpInitializeInstanceData (
IN MNP_SERVICE_DATA *MnpServiceData,
IN OUT MNP_INSTANCE_DATA *Instance
IN MNP_SERVICE_DATA *MnpServiceData,
IN OUT MNP_INSTANCE_DATA *Instance
);
/**
@@ -240,9 +240,9 @@ MnpInitializeInstanceData (
EFI_STATUS
EFIAPI
MnpTokenExist (
IN NET_MAP *Map,
IN NET_MAP_ITEM *Item,
IN VOID *Arg
IN NET_MAP *Map,
IN NET_MAP_ITEM *Item,
IN VOID *Arg
);
/**
@@ -263,9 +263,9 @@ MnpTokenExist (
EFI_STATUS
EFIAPI
MnpCancelTokens (
IN OUT NET_MAP *Map,
IN OUT NET_MAP_ITEM *Item,
IN VOID *Arg
IN OUT NET_MAP *Map,
IN OUT NET_MAP_ITEM *Item,
IN VOID *Arg
);
/**
@@ -276,7 +276,7 @@ MnpCancelTokens (
**/
VOID
MnpFlushRcvdDataQueue (
IN OUT MNP_INSTANCE_DATA *Instance
IN OUT MNP_INSTANCE_DATA *Instance
);
/**
@@ -294,8 +294,8 @@ MnpFlushRcvdDataQueue (
**/
EFI_STATUS
MnpConfigureInstance (
IN OUT MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData OPTIONAL
IN OUT MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData OPTIONAL
);
/**
@@ -315,10 +315,10 @@ MnpConfigureInstance (
**/
EFI_STATUS
MnpGroupOp (
IN OUT MNP_INSTANCE_DATA *Instance,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL,
IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk OPTIONAL
IN OUT MNP_INSTANCE_DATA *Instance,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL,
IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk OPTIONAL
);
/**
@@ -332,8 +332,8 @@ MnpGroupOp (
**/
BOOLEAN
MnpIsValidTxToken (
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
);
/**
@@ -352,10 +352,10 @@ MnpIsValidTxToken (
**/
EFI_STATUS
MnpBuildTxPacket (
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT8 **PktBuf,
OUT UINT32 *PktLen
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT8 **PktBuf,
OUT UINT32 *PktLen
);
/**
@@ -377,10 +377,10 @@ MnpBuildTxPacket (
**/
EFI_STATUS
MnpSyncSendPacket (
IN MNP_SERVICE_DATA *MnpServiceData,
IN UINT8 *Packet,
IN UINT32 Length,
IN OUT EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN MNP_SERVICE_DATA *MnpServiceData,
IN UINT8 *Packet,
IN UINT32 Length,
IN OUT EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
);
/**
@@ -396,7 +396,7 @@ MnpSyncSendPacket (
**/
EFI_STATUS
MnpInstanceDeliverPacket (
IN OUT MNP_INSTANCE_DATA *Instance
IN OUT MNP_INSTANCE_DATA *Instance
);
/**
@@ -410,8 +410,8 @@ MnpInstanceDeliverPacket (
VOID
EFIAPI
MnpRecycleRxData (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/**
@@ -427,7 +427,7 @@ MnpRecycleRxData (
**/
EFI_STATUS
MnpReceivePacket (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
);
/**
@@ -443,7 +443,7 @@ MnpReceivePacket (
**/
NET_BUF *
MnpAllocNbuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
);
/**
@@ -455,8 +455,8 @@ MnpAllocNbuf (
**/
VOID
MnpFreeNbuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf
);
/**
@@ -472,7 +472,7 @@ MnpFreeNbuf (
**/
UINT8 *
MnpAllocTxBuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
);
/**
@@ -486,7 +486,7 @@ MnpAllocTxBuf (
**/
EFI_STATUS
MnpRecycleTxBuf (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
);
/**
@@ -499,8 +499,8 @@ MnpRecycleTxBuf (
VOID
EFIAPI
MnpCheckPacketTimeout (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/**
@@ -513,8 +513,8 @@ MnpCheckPacketTimeout (
VOID
EFIAPI
MnpCheckMediaStatus (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/**
@@ -528,8 +528,8 @@ MnpCheckMediaStatus (
VOID
EFIAPI
MnpSystemPoll (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/**
@@ -560,9 +560,9 @@ MnpSystemPoll (
EFI_STATUS
EFIAPI
MnpGetModeData (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
);
/**
@@ -620,8 +620,8 @@ MnpGetModeData (
EFI_STATUS
EFIAPI
MnpConfigure (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
);
/**
@@ -657,10 +657,10 @@ MnpConfigure (
EFI_STATUS
EFIAPI
MnpMcastIpToMac (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN Ipv6Flag,
IN EFI_IP_ADDRESS *IpAddress,
OUT EFI_MAC_ADDRESS *MacAddress
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN Ipv6Flag,
IN EFI_IP_ADDRESS *IpAddress,
OUT EFI_MAC_ADDRESS *MacAddress
);
/**
@@ -702,9 +702,9 @@ MnpMcastIpToMac (
EFI_STATUS
EFIAPI
MnpGroups (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
);
/**
@@ -765,8 +765,8 @@ MnpGroups (
EFI_STATUS
EFIAPI
MnpTransmit (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
);
/**
@@ -801,8 +801,8 @@ MnpTransmit (
EFI_STATUS
EFIAPI
MnpCancel (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
);
/**
@@ -843,8 +843,8 @@ MnpCancel (
EFI_STATUS
EFIAPI
MnpReceive (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
);
/**
@@ -876,7 +876,7 @@ MnpReceive (
EFI_STATUS
EFIAPI
MnpPoll (
IN EFI_MANAGED_NETWORK_PROTOCOL *This
IN EFI_MANAGED_NETWORK_PROTOCOL *This
);
/**
@@ -892,7 +892,7 @@ MnpPoll (
**/
EFI_STATUS
MnpConfigReceiveFilters (
IN MNP_DEVICE_DATA *MnpDeviceData
IN MNP_DEVICE_DATA *MnpDeviceData
);
#endif

View File

@@ -20,15 +20,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
BOOLEAN
MnpIsValidTxToken (
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
)
{
MNP_SERVICE_DATA *MnpServiceData;
EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;
UINT32 Index;
UINT32 TotalLength;
EFI_MANAGED_NETWORK_FRAGMENT_DATA *FragmentTable;
MNP_SERVICE_DATA *MnpServiceData;
EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;
UINT32 Index;
UINT32 TotalLength;
EFI_MANAGED_NETWORK_FRAGMENT_DATA *FragmentTable;
MnpServiceData = Instance->MnpServiceData;
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
@@ -56,7 +56,6 @@ MnpIsValidTxToken (
TotalLength = 0;
FragmentTable = TxData->FragmentTable;
for (Index = 0; Index < TxData->FragmentCount; Index++) {
if ((FragmentTable[Index].FragmentLength == 0) || (FragmentTable[Index].FragmentBuffer == NULL)) {
//
// The token is invalid if any FragmentLength is zero or any FragmentBuffer is NULL.
@@ -111,17 +110,17 @@ MnpIsValidTxToken (
**/
EFI_STATUS
MnpBuildTxPacket (
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT8 **PktBuf,
OUT UINT32 *PktLen
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT8 **PktBuf,
OUT UINT32 *PktLen
)
{
EFI_SIMPLE_NETWORK_MODE *SnpMode;
UINT8 *DstPos;
UINT16 Index;
MNP_DEVICE_DATA *MnpDeviceData;
UINT8 *TxBuf;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
UINT8 *DstPos;
UINT16 Index;
MNP_DEVICE_DATA *MnpDeviceData;
UINT8 *TxBuf;
MnpDeviceData = MnpServiceData->MnpDeviceData;
@@ -141,10 +140,10 @@ MnpBuildTxPacket (
if ((TxData->DestinationAddress == NULL) && (TxData->FragmentCount == 1)) {
CopyMem (
*PktBuf,
TxData->FragmentTable[0].FragmentBuffer,
TxData->FragmentTable[0].FragmentLength
);
*PktBuf,
TxData->FragmentTable[0].FragmentBuffer,
TxData->FragmentTable[0].FragmentLength
);
*PktLen = TxData->FragmentTable[0].FragmentLength;
} else {
@@ -161,7 +160,7 @@ MnpBuildTxPacket (
// If dest address is not NULL, move DstPos to reserve space for the
// media header. Add the media header length to buflen.
//
DstPos += SnpMode->MediaHeaderSize;
DstPos += SnpMode->MediaHeaderSize;
*PktLen += SnpMode->MediaHeaderSize;
}
@@ -186,7 +185,6 @@ MnpBuildTxPacket (
return EFI_SUCCESS;
}
/**
Synchronously send out the packet.
@@ -206,18 +204,18 @@ MnpBuildTxPacket (
**/
EFI_STATUS
MnpSyncSendPacket (
IN MNP_SERVICE_DATA *MnpServiceData,
IN UINT8 *Packet,
IN UINT32 Length,
IN OUT EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN MNP_SERVICE_DATA *MnpServiceData,
IN UINT8 *Packet,
IN UINT32 Length,
IN OUT EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
)
{
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;
UINT32 HeaderSize;
MNP_DEVICE_DATA *MnpDeviceData;
UINT16 ProtocolType;
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;
UINT32 HeaderSize;
MNP_DEVICE_DATA *MnpDeviceData;
UINT16 ProtocolType;
MnpDeviceData = MnpServiceData->MnpDeviceData;
Snp = MnpDeviceData->Snp;
@@ -238,7 +236,6 @@ MnpSyncSendPacket (
goto SIGNAL_TOKEN;
}
if (MnpServiceData->VlanId != 0) {
//
// Insert VLAN tag
@@ -294,7 +291,6 @@ SIGNAL_TOKEN:
return EFI_SUCCESS;
}
/**
Try to deliver the received packet to the instance.
@@ -308,7 +304,7 @@ SIGNAL_TOKEN:
**/
EFI_STATUS
MnpInstanceDeliverPacket (
IN OUT MNP_INSTANCE_DATA *Instance
IN OUT MNP_INSTANCE_DATA *Instance
)
{
MNP_DEVICE_DATA *MnpDeviceData;
@@ -363,10 +359,10 @@ MnpInstanceDeliverPacket (
//
// Set all the buffer pointers.
//
RxData->MediaHeader = NetbufGetByte (RxDataWrap->Nbuf, 0, NULL);
RxData->DestinationAddress = RxData->MediaHeader;
RxData->SourceAddress = (UINT8 *) RxData->MediaHeader + SnpMode->HwAddressSize;
RxData->PacketData = (UINT8 *) RxData->MediaHeader + SnpMode->MediaHeaderSize;
RxData->MediaHeader = NetbufGetByte (RxDataWrap->Nbuf, 0, NULL);
RxData->DestinationAddress = RxData->MediaHeader;
RxData->SourceAddress = (UINT8 *)RxData->MediaHeader + SnpMode->HwAddressSize;
RxData->PacketData = (UINT8 *)RxData->MediaHeader + SnpMode->MediaHeaderSize;
//
// Insert this RxDataWrap into the delivered queue.
@@ -381,14 +377,13 @@ MnpInstanceDeliverPacket (
//
// Signal this token's event.
//
RxToken->Packet.RxData = &RxDataWrap->RxData;
RxToken->Status = EFI_SUCCESS;
RxToken->Packet.RxData = &RxDataWrap->RxData;
RxToken->Status = EFI_SUCCESS;
gBS->SignalEvent (RxToken->Event);
return EFI_SUCCESS;
}
/**
Deliver the received packet for the instances belonging to the MnpServiceData.
@@ -397,11 +392,11 @@ MnpInstanceDeliverPacket (
**/
VOID
MnpDeliverPacket (
IN MNP_SERVICE_DATA *MnpServiceData
IN MNP_SERVICE_DATA *MnpServiceData
)
{
LIST_ENTRY *Entry;
MNP_INSTANCE_DATA *Instance;
LIST_ENTRY *Entry;
MNP_INSTANCE_DATA *Instance;
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
@@ -416,7 +411,6 @@ MnpDeliverPacket (
}
}
/**
Recycle the RxData and other resources used to hold and deliver the received
packet.
@@ -428,16 +422,16 @@ MnpDeliverPacket (
VOID
EFIAPI
MnpRecycleRxData (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
MNP_RXDATA_WRAP *RxDataWrap;
MNP_DEVICE_DATA *MnpDeviceData;
MNP_RXDATA_WRAP *RxDataWrap;
MNP_DEVICE_DATA *MnpDeviceData;
ASSERT (Context != NULL);
RxDataWrap = (MNP_RXDATA_WRAP *) Context;
RxDataWrap = (MNP_RXDATA_WRAP *)Context;
NET_CHECK_SIGNATURE (RxDataWrap->Instance, MNP_INSTANCE_DATA_SIGNATURE);
ASSERT (RxDataWrap->Nbuf != NULL);
@@ -464,7 +458,6 @@ MnpRecycleRxData (
FreePool (RxDataWrap);
}
/**
Queue the received packet into instance's receive queue.
@@ -474,11 +467,11 @@ MnpRecycleRxData (
**/
VOID
MnpQueueRcvdPacket (
IN OUT MNP_INSTANCE_DATA *Instance,
IN OUT MNP_RXDATA_WRAP *RxDataWrap
IN OUT MNP_INSTANCE_DATA *Instance,
IN OUT MNP_RXDATA_WRAP *RxDataWrap
)
{
MNP_RXDATA_WRAP *OldRxDataWrap;
MNP_RXDATA_WRAP *OldRxDataWrap;
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -487,7 +480,6 @@ MnpQueueRcvdPacket (
// from the head.
//
if (Instance->RcvdPacketQueueSize == MNP_MAX_RCVD_PACKET_QUE_SIZE) {
DEBUG ((DEBUG_WARN, "MnpQueueRcvdPacket: Drop one packet bcz queue size limit reached.\n"));
//
@@ -502,7 +494,7 @@ MnpQueueRcvdPacket (
//
// Recycle this OldRxDataWrap, this entry will be removed by the callee.
//
MnpRecycleRxData (NULL, (VOID *) OldRxDataWrap);
MnpRecycleRxData (NULL, (VOID *)OldRxDataWrap);
Instance->RcvdPacketQueueSize--;
}
@@ -518,7 +510,6 @@ MnpQueueRcvdPacket (
Instance->RcvdPacketQueueSize++;
}
/**
Match the received packet with the instance receive filters.
@@ -535,15 +526,15 @@ MnpQueueRcvdPacket (
**/
BOOLEAN
MnpMatchPacket (
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData,
IN MNP_GROUP_ADDRESS *GroupAddress OPTIONAL,
IN UINT8 PktAttr
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData,
IN MNP_GROUP_ADDRESS *GroupAddress OPTIONAL,
IN UINT8 PktAttr
)
{
EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData;
LIST_ENTRY *Entry;
MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk;
EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData;
LIST_ENTRY *Entry;
MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk;
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -574,11 +565,9 @@ MnpMatchPacket (
// Check multicast addresses.
//
if (ConfigData->EnableMulticastReceive && RxData->MulticastFlag) {
ASSERT (GroupAddress != NULL);
NET_LIST_FOR_EACH (Entry, &Instance->GroupCtrlBlkList) {
GroupCtrlBlk = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_CONTROL_BLOCK, CtrlBlkEntry);
if (GroupCtrlBlk->GroupAddress == GroupAddress) {
//
@@ -596,7 +585,6 @@ MnpMatchPacket (
return FALSE;
}
/**
Analyse the received packets.
@@ -614,17 +602,17 @@ MnpMatchPacket (
**/
VOID
MnpAnalysePacket (
IN MNP_SERVICE_DATA *MnpServiceData,
IN NET_BUF *Nbuf,
IN OUT EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData,
OUT MNP_GROUP_ADDRESS **GroupAddress,
OUT UINT8 *PktAttr
IN MNP_SERVICE_DATA *MnpServiceData,
IN NET_BUF *Nbuf,
IN OUT EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData,
OUT MNP_GROUP_ADDRESS **GroupAddress,
OUT UINT8 *PktAttr
)
{
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MNP_DEVICE_DATA *MnpDeviceData;
UINT8 *BufPtr;
LIST_ENTRY *Entry;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MNP_DEVICE_DATA *MnpDeviceData;
UINT8 *BufPtr;
LIST_ENTRY *Entry;
MnpDeviceData = MnpServiceData->MnpDeviceData;
SnpMode = MnpDeviceData->Snp->Mode;
@@ -660,7 +648,6 @@ MnpAnalysePacket (
// It's multicast, try to match the multicast filters.
//
NET_LIST_FOR_EACH (Entry, &MnpDeviceData->GroupAddressList) {
*GroupAddress = NET_LIST_USER_STRUCT (Entry, MNP_GROUP_ADDRESS, AddrEntry);
if (NET_MAC_EQUAL (BufPtr, &((*GroupAddress)->Address), SnpMode->HwAddressSize)) {
RxData->MulticastFlag = TRUE;
@@ -680,7 +667,7 @@ MnpAnalysePacket (
//
// Skip the below code, there is no receiver of this packet.
//
return ;
return;
}
}
} else {
@@ -697,10 +684,9 @@ MnpAnalysePacket (
RxData->HeaderLength = SnpMode->MediaHeaderSize;
RxData->AddressLength = SnpMode->HwAddressSize;
RxData->DataLength = RxData->PacketLength - RxData->HeaderLength;
RxData->ProtocolType = NTOHS (*(UINT16 *) (BufPtr + 2 * SnpMode->HwAddressSize));
RxData->ProtocolType = NTOHS (*(UINT16 *)(BufPtr + 2 * SnpMode->HwAddressSize));
}
/**
Wrap the RxData.
@@ -712,12 +698,12 @@ MnpAnalysePacket (
**/
MNP_RXDATA_WRAP *
MnpWrapRxData (
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData
IN MNP_INSTANCE_DATA *Instance,
IN EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData
)
{
EFI_STATUS Status;
MNP_RXDATA_WRAP *RxDataWrap;
EFI_STATUS Status;
MNP_RXDATA_WRAP *RxDataWrap;
//
// Allocate memory.
@@ -755,7 +741,6 @@ MnpWrapRxData (
return RxDataWrap;
}
/**
Enqueue the received the packets to the instances belonging to the
MnpServiceData.
@@ -767,8 +752,8 @@ MnpWrapRxData (
**/
VOID
MnpEnqueuePacket (
IN MNP_SERVICE_DATA *MnpServiceData,
IN NET_BUF *Nbuf
IN MNP_SERVICE_DATA *MnpServiceData,
IN NET_BUF *Nbuf
)
{
LIST_ENTRY *Entry;
@@ -778,7 +763,6 @@ MnpEnqueuePacket (
MNP_GROUP_ADDRESS *GroupAddress;
MNP_RXDATA_WRAP *RxDataWrap;
GroupAddress = NULL;
//
// First, analyse the packet header.
@@ -789,14 +773,13 @@ MnpEnqueuePacket (
//
// No receivers, no more action need.
//
return ;
return;
}
//
// Iterate the children to find match.
//
NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {
Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -830,7 +813,6 @@ MnpEnqueuePacket (
}
}
/**
Try to receive a packet and deliver it.
@@ -844,19 +826,19 @@ MnpEnqueuePacket (
**/
EFI_STATUS
MnpReceivePacket (
IN OUT MNP_DEVICE_DATA *MnpDeviceData
IN OUT MNP_DEVICE_DATA *MnpDeviceData
)
{
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
NET_BUF *Nbuf;
UINT8 *BufPtr;
UINTN BufLen;
UINTN HeaderSize;
UINT32 Trimmed;
MNP_SERVICE_DATA *MnpServiceData;
UINT16 VlanId;
BOOLEAN IsVlanPacket;
EFI_STATUS Status;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
NET_BUF *Nbuf;
UINT8 *BufPtr;
UINTN BufLen;
UINTN HeaderSize;
UINT32 Trimmed;
MNP_SERVICE_DATA *MnpServiceData;
UINT16 VlanId;
BOOLEAN IsVlanPacket;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
@@ -888,9 +870,9 @@ MnpReceivePacket (
);
}
Nbuf = MnpDeviceData->RxNbufCache;
BufLen = Nbuf->TotalSize;
BufPtr = NetbufGetByte (Nbuf, 0, NULL);
Nbuf = MnpDeviceData->RxNbufCache;
BufLen = Nbuf->TotalSize;
BufPtr = NetbufGetByte (Nbuf, 0, NULL);
ASSERT (BufPtr != NULL);
//
@@ -899,9 +881,10 @@ MnpReceivePacket (
Status = Snp->Receive (Snp, &HeaderSize, &BufLen, BufPtr, NULL, NULL, NULL);
if (EFI_ERROR (Status)) {
DEBUG_CODE_BEGIN ();
if (Status != EFI_NOT_READY) {
DEBUG ((DEBUG_WARN, "MnpReceivePacket: Snp->Receive() = %r.\n", Status));
}
if (Status != EFI_NOT_READY) {
DEBUG ((DEBUG_WARN, "MnpReceivePacket: Snp->Receive() = %r.\n", Status));
}
DEBUG_CODE_END ();
return Status;
@@ -913,9 +896,9 @@ MnpReceivePacket (
if ((HeaderSize != Snp->Mode->MediaHeaderSize) || (BufLen < HeaderSize)) {
DEBUG (
(DEBUG_WARN,
"MnpReceivePacket: Size error, HL:TL = %d:%d.\n",
HeaderSize,
BufLen)
"MnpReceivePacket: Size error, HL:TL = %d:%d.\n",
HeaderSize,
BufLen)
);
return EFI_DEVICE_ERROR;
}
@@ -925,7 +908,7 @@ MnpReceivePacket (
//
// Trim the packet from tail.
//
Trimmed = NetbufTrim (Nbuf, Nbuf->TotalSize - (UINT32) BufLen, NET_BUF_TAIL);
Trimmed = NetbufTrim (Nbuf, Nbuf->TotalSize - (UINT32)BufLen, NET_BUF_TAIL);
ASSERT (Nbuf->TotalSize == BufLen);
}
@@ -982,12 +965,14 @@ MnpReceivePacket (
if (Trimmed > 0) {
NetbufAllocSpace (Nbuf, Trimmed, NET_BUF_TAIL);
}
if (IsVlanPacket) {
NetbufAllocSpace (Nbuf, NET_VLAN_TAG_LEN, NET_BUF_HEAD);
}
goto EXIT;
}
//
// Deliver the queued packets.
//
@@ -1000,7 +985,6 @@ EXIT:
return Status;
}
/**
Remove the received packets if timeout occurs.
@@ -1011,28 +995,27 @@ EXIT:
VOID
EFIAPI
MnpCheckPacketTimeout (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
MNP_DEVICE_DATA *MnpDeviceData;
MNP_SERVICE_DATA *MnpServiceData;
LIST_ENTRY *Entry;
LIST_ENTRY *ServiceEntry;
LIST_ENTRY *RxEntry;
LIST_ENTRY *NextEntry;
MNP_INSTANCE_DATA *Instance;
MNP_RXDATA_WRAP *RxDataWrap;
EFI_TPL OldTpl;
MNP_DEVICE_DATA *MnpDeviceData;
MNP_SERVICE_DATA *MnpServiceData;
LIST_ENTRY *Entry;
LIST_ENTRY *ServiceEntry;
LIST_ENTRY *RxEntry;
LIST_ENTRY *NextEntry;
MNP_INSTANCE_DATA *Instance;
MNP_RXDATA_WRAP *RxDataWrap;
EFI_TPL OldTpl;
MnpDeviceData = (MNP_DEVICE_DATA *) Context;
MnpDeviceData = (MNP_DEVICE_DATA *)Context;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
NET_LIST_FOR_EACH (ServiceEntry, &MnpDeviceData->ServiceList) {
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (ServiceEntry);
NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {
Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
@@ -1047,7 +1030,6 @@ MnpCheckPacketTimeout (
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
NET_LIST_FOR_EACH_SAFE (RxEntry, NextEntry, &Instance->RcvdPacketQueue) {
RxDataWrap = NET_LIST_USER_STRUCT (RxEntry, MNP_RXDATA_WRAP, WrapEntry);
//
@@ -1080,15 +1062,15 @@ MnpCheckPacketTimeout (
VOID
EFIAPI
MnpCheckMediaStatus (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
MNP_DEVICE_DATA *MnpDeviceData;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
UINT32 InterruptStatus;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
UINT32 InterruptStatus;
MnpDeviceData = (MNP_DEVICE_DATA *) Context;
MnpDeviceData = (MNP_DEVICE_DATA *)Context;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
Snp = MnpDeviceData->Snp;
@@ -1112,13 +1094,13 @@ MnpCheckMediaStatus (
VOID
EFIAPI
MnpSystemPoll (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
MNP_DEVICE_DATA *MnpDeviceData;
MnpDeviceData = (MNP_DEVICE_DATA *) Context;
MnpDeviceData = (MNP_DEVICE_DATA *)Context;
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
//

View File

@@ -36,16 +36,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
MnpGetModeData (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
)
{
MNP_INSTANCE_DATA *Instance;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
UINT32 InterruptStatus;
MNP_INSTANCE_DATA *Instance;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_TPL OldTpl;
EFI_STATUS Status;
UINT32 InterruptStatus;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -87,7 +87,6 @@ MnpGetModeData (
return Status;
}
/**
Sets or clears the operational parameters for the MNP child driver.
@@ -143,8 +142,8 @@ MnpGetModeData (
EFI_STATUS
EFIAPI
MnpConfigure (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
)
{
MNP_INSTANCE_DATA *Instance;
@@ -155,7 +154,8 @@ MnpConfigure (
((MnpConfigData != NULL) &&
(MnpConfigData->ProtocolTypeFilter > 0) &&
(MnpConfigData->ProtocolTypeFilter <= 1500))
) {
)
{
return EFI_INVALID_PARAMETER;
}
@@ -182,7 +182,6 @@ ON_EXIT:
return Status;
}
/**
Translates an IP multicast address to a hardware (MAC) multicast address. This
function may be unsupported in some MNP implementations.
@@ -216,17 +215,17 @@ ON_EXIT:
EFI_STATUS
EFIAPI
MnpMcastIpToMac (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN Ipv6Flag,
IN EFI_IP_ADDRESS *IpAddress,
OUT EFI_MAC_ADDRESS *MacAddress
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN Ipv6Flag,
IN EFI_IP_ADDRESS *IpAddress,
OUT EFI_MAC_ADDRESS *MacAddress
)
{
EFI_STATUS Status;
MNP_INSTANCE_DATA *Instance;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_TPL OldTpl;
EFI_IPv6_ADDRESS *Ip6Address;
EFI_STATUS Status;
MNP_INSTANCE_DATA *Instance;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_TPL OldTpl;
EFI_IPv6_ADDRESS *Ip6Address;
if ((This == NULL) || (IpAddress == NULL) || (MacAddress == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -236,7 +235,8 @@ MnpMcastIpToMac (
if ((Ipv6Flag && !IP6_IS_MULTICAST (Ip6Address)) ||
(!Ipv6Flag && !IP4_IS_MULTICAST (EFI_NTOHL (*IpAddress)))
) {
)
{
//
// The IP address passed in is not a multicast address.
//
@@ -248,7 +248,6 @@ MnpMcastIpToMac (
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (!Instance->Configured) {
Status = EFI_NOT_STARTED;
goto ON_EXIT;
}
@@ -267,7 +266,7 @@ MnpMcastIpToMac (
MacAddress->Addr[0] = 0x01;
MacAddress->Addr[1] = 0x00;
MacAddress->Addr[2] = 0x5E;
MacAddress->Addr[3] = (UINT8) (IpAddress->v4.Addr[1] & 0x7F);
MacAddress->Addr[3] = (UINT8)(IpAddress->v4.Addr[1] & 0x7F);
MacAddress->Addr[4] = IpAddress->v4.Addr[2];
MacAddress->Addr[5] = IpAddress->v4.Addr[3];
} else {
@@ -342,29 +341,29 @@ ON_EXIT:
EFI_STATUS
EFIAPI
MnpGroups (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN BOOLEAN JoinFlag,
IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
)
{
MNP_INSTANCE_DATA *Instance;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk;
MNP_GROUP_ADDRESS *GroupAddress;
LIST_ENTRY *ListEntry;
BOOLEAN AddressExist;
EFI_TPL OldTpl;
EFI_STATUS Status;
MNP_INSTANCE_DATA *Instance;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MNP_GROUP_CONTROL_BLOCK *GroupCtrlBlk;
MNP_GROUP_ADDRESS *GroupAddress;
LIST_ENTRY *ListEntry;
BOOLEAN AddressExist;
EFI_TPL OldTpl;
EFI_STATUS Status;
if (This == NULL || (JoinFlag && (MacAddress == NULL))) {
if ((This == NULL) || (JoinFlag && (MacAddress == NULL))) {
//
// This is NULL, or it's a join operation but MacAddress is NULL.
//
return EFI_INVALID_PARAMETER;
}
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
SnpMode = Instance->MnpServiceData->MnpDeviceData->Snp->Mode;
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
SnpMode = Instance->MnpServiceData->MnpDeviceData->Snp->Mode;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
@@ -374,7 +373,8 @@ MnpGroups (
}
if ((!Instance->ConfigData.EnableMulticastReceive) ||
((MacAddress != NULL) && !NET_MAC_IS_MULTICAST (MacAddress, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize))) {
((MacAddress != NULL) && !NET_MAC_IS_MULTICAST (MacAddress, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize)))
{
//
// The instance isn't configured to do multicast receive. OR
// the passed in MacAddress is not a multicast mac address.
@@ -392,18 +392,18 @@ MnpGroups (
// Search the instance's GroupCtrlBlkList to find the specific address.
//
NET_LIST_FOR_EACH (ListEntry, &Instance->GroupCtrlBlkList) {
GroupCtrlBlk = NET_LIST_USER_STRUCT (
ListEntry,
MNP_GROUP_CONTROL_BLOCK,
CtrlBlkEntry
);
ListEntry,
MNP_GROUP_CONTROL_BLOCK,
CtrlBlkEntry
);
GroupAddress = GroupCtrlBlk->GroupAddress;
if (0 == CompareMem (
MacAddress,
&GroupAddress->Address,
SnpMode->HwAddressSize
)) {
MacAddress,
&GroupAddress->Address,
SnpMode->HwAddressSize
))
{
//
// There is already the same multicast mac address configured.
//
@@ -506,16 +506,16 @@ ON_EXIT:
EFI_STATUS
EFIAPI
MnpTransmit (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
)
{
EFI_STATUS Status;
MNP_INSTANCE_DATA *Instance;
MNP_SERVICE_DATA *MnpServiceData;
UINT8 *PktBuf;
UINT32 PktLen;
EFI_TPL OldTpl;
EFI_STATUS Status;
MNP_INSTANCE_DATA *Instance;
MNP_SERVICE_DATA *MnpServiceData;
UINT8 *PktBuf;
UINT32 PktLen;
EFI_TPL OldTpl;
if ((This == NULL) || (Token == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -526,7 +526,6 @@ MnpTransmit (
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
if (!Instance->Configured) {
Status = EFI_NOT_STARTED;
goto ON_EXIT;
}
@@ -561,7 +560,6 @@ ON_EXIT:
return Status;
}
/**
Places an asynchronous receiving request into the receiving queue.
@@ -600,8 +598,8 @@ ON_EXIT:
EFI_STATUS
EFIAPI
MnpReceive (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
)
{
EFI_STATUS Status;
@@ -624,7 +622,7 @@ MnpReceive (
//
// Check whether this token(event) is already in the rx token queue.
//
Status = NetMapIterate (&Instance->RxTokenMap, MnpTokenExist, (VOID *) Token);
Status = NetMapIterate (&Instance->RxTokenMap, MnpTokenExist, (VOID *)Token);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -632,7 +630,7 @@ MnpReceive (
//
// Insert the Token into the RxTokenMap.
//
Status = NetMapInsertTail (&Instance->RxTokenMap, (VOID *) Token, NULL);
Status = NetMapInsertTail (&Instance->RxTokenMap, (VOID *)Token, NULL);
if (!EFI_ERROR (Status)) {
//
// Try to deliver any buffered packets.
@@ -683,8 +681,8 @@ ON_EXIT:
EFI_STATUS
EFIAPI
MnpCancel (
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
IN EFI_MANAGED_NETWORK_PROTOCOL *This,
IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
)
{
EFI_STATUS Status;
@@ -707,7 +705,7 @@ MnpCancel (
//
// Iterate the RxTokenMap to cancel the specified Token.
//
Status = NetMapIterate (&Instance->RxTokenMap, MnpCancelTokens, (VOID *) Token);
Status = NetMapIterate (&Instance->RxTokenMap, MnpCancelTokens, (VOID *)Token);
if (Token != NULL) {
Status = (Status == EFI_ABORTED) ? EFI_SUCCESS : EFI_NOT_FOUND;
}
@@ -752,7 +750,7 @@ ON_EXIT:
EFI_STATUS
EFIAPI
MnpPoll (
IN EFI_MANAGED_NETWORK_PROTOCOL *This
IN EFI_MANAGED_NETWORK_PROTOCOL *This
)
{
EFI_STATUS Status;

View File

@@ -9,13 +9,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "MnpImpl.h"
#include "MnpVlan.h"
VLAN_DEVICE_PATH mVlanDevicePathTemplate = {
VLAN_DEVICE_PATH mVlanDevicePathTemplate = {
{
MESSAGING_DEVICE_PATH,
MSG_VLAN_DP,
{
(UINT8) (sizeof (VLAN_DEVICE_PATH)),
(UINT8) ((sizeof (VLAN_DEVICE_PATH)) >> 8)
(UINT8)(sizeof (VLAN_DEVICE_PATH)),
(UINT8)((sizeof (VLAN_DEVICE_PATH)) >> 8)
}
},
0
@@ -27,7 +27,6 @@ EFI_VLAN_CONFIG_PROTOCOL mVlanConfigProtocolTemplate = {
VlanConfigRemove
};
/**
Create a child handle for the VLAN ID.
@@ -41,10 +40,10 @@ EFI_VLAN_CONFIG_PROTOCOL mVlanConfigProtocolTemplate = {
**/
EFI_HANDLE
MnpCreateVlanChild (
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle,
IN UINT16 VlanId,
OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle,
IN UINT16 VlanId,
OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL
)
{
EFI_HANDLE ChildHandle;
@@ -59,7 +58,7 @@ MnpCreateVlanChild (
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
(VOID **) &ParentDevicePath,
(VOID **)&ParentDevicePath,
ImageHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -73,10 +72,10 @@ MnpCreateVlanChild (
//
CopyMem (&VlanNode, &mVlanDevicePathTemplate, sizeof (VLAN_DEVICE_PATH));
VlanNode.VlanId = VlanId;
VlanDevicePath = AppendDevicePathNode (
ParentDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *) &VlanNode
);
VlanDevicePath = AppendDevicePathNode (
ParentDevicePath,
(EFI_DEVICE_PATH_PROTOCOL *)&VlanNode
);
if (VlanDevicePath == NULL) {
return NULL;
}
@@ -85,12 +84,12 @@ MnpCreateVlanChild (
// Create child VLAN handle by installing DevicePath protocol
//
ChildHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&ChildHandle,
&gEfiDevicePathProtocolGuid,
VlanDevicePath,
NULL
);
Status = gBS->InstallMultipleProtocolInterfaces (
&ChildHandle,
&gEfiDevicePathProtocolGuid,
VlanDevicePath,
NULL
);
if (EFI_ERROR (Status)) {
FreePool (VlanDevicePath);
return NULL;
@@ -116,9 +115,9 @@ MnpCreateVlanChild (
**/
BOOLEAN
MnpRemoveVlanTag (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf,
OUT UINT16 *VlanId
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf,
OUT UINT16 *VlanId
)
{
UINT8 *Packet;
@@ -138,7 +137,7 @@ MnpRemoveVlanTag (
// Check whether this is VLAN tagged frame by Ether Type
//
*VlanId = 0;
ProtocolType = NTOHS (*(UINT16 *) (Packet + ProtocolOffset));
ProtocolType = NTOHS (*(UINT16 *)(Packet + ProtocolOffset));
if (ProtocolType != ETHER_TYPE_VLAN) {
//
// Not a VLAN tagged frame
@@ -146,8 +145,8 @@ MnpRemoveVlanTag (
return FALSE;
}
VlanTag.Uint16 = NTOHS (*(UINT16 *) (Packet + ProtocolOffset + sizeof (ProtocolType)));
*VlanId = VlanTag.Bits.Vid;
VlanTag.Uint16 = NTOHS (*(UINT16 *)(Packet + ProtocolOffset + sizeof (ProtocolType)));
*VlanId = VlanTag.Bits.Vid;
//
// Move hardware address (DA + SA) 4 bytes right to override VLAN tag
@@ -162,7 +161,6 @@ MnpRemoveVlanTag (
return TRUE;
}
/**
Build the vlan packet to transmit from the TxData passed in.
@@ -177,28 +175,28 @@ MnpRemoveVlanTag (
**/
VOID
MnpInsertVlanTag (
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT16 *ProtocolType,
IN OUT UINT8 **Packet,
IN OUT UINT32 *Length
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT16 *ProtocolType,
IN OUT UINT8 **Packet,
IN OUT UINT32 *Length
)
{
VLAN_TCI *VlanTci;
UINT16 *Tpid;
UINT16 *EtherType;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
VLAN_TCI *VlanTci;
UINT16 *Tpid;
UINT16 *EtherType;
MNP_DEVICE_DATA *MnpDeviceData;
EFI_SIMPLE_NETWORK_MODE *SnpMode;
MnpDeviceData = MnpServiceData->MnpDeviceData;
SnpMode = MnpDeviceData->Snp->Mode;
*ProtocolType = ETHER_TYPE_VLAN;
*Length = *Length + NET_VLAN_TAG_LEN;
*Packet = *Packet - NET_VLAN_TAG_LEN;
*Length = *Length + NET_VLAN_TAG_LEN;
*Packet = *Packet - NET_VLAN_TAG_LEN;
Tpid = (UINT16 *) (*Packet + SnpMode->MediaHeaderSize - sizeof (*ProtocolType));
VlanTci = (VLAN_TCI *) (UINTN) (Tpid + 1);
Tpid = (UINT16 *)(*Packet + SnpMode->MediaHeaderSize - sizeof (*ProtocolType));
VlanTci = (VLAN_TCI *)(UINTN)(Tpid + 1);
if (TxData->HeaderLength != 0) {
//
// Media header is in packet, move DA+SA 4 bytes left
@@ -213,7 +211,7 @@ MnpInsertVlanTag (
//
// Media header not in packet, VLAN TCI and original protocol type becomes payload
//
EtherType = (UINT16 *) (UINTN) (VlanTci + 1);
EtherType = (UINT16 *)(UINTN)(VlanTci + 1);
*EtherType = HTONS (TxData->ProtocolType);
}
@@ -237,36 +235,38 @@ MnpInsertVlanTag (
**/
EFI_STATUS
MnpCheckVlanVariable (
IN MNP_DEVICE_DATA *MnpDeviceData,
IN VLAN_TCI *Buffer,
IN UINTN NumberOfVlan,
OUT UINTN *NewNumberOfVlan
IN MNP_DEVICE_DATA *MnpDeviceData,
IN VLAN_TCI *Buffer,
IN UINTN NumberOfVlan,
OUT UINTN *NewNumberOfVlan
)
{
UINTN Index;
UINTN Index2;
UINTN Count;
BOOLEAN FoundDuplicateItem;
EFI_STATUS Status;
UINTN Index;
UINTN Index2;
UINTN Count;
BOOLEAN FoundDuplicateItem;
EFI_STATUS Status;
Count = 0;
FoundDuplicateItem = FALSE;
Status = EFI_SUCCESS;
Count = 0;
FoundDuplicateItem = FALSE;
Status = EFI_SUCCESS;
for (Index = 0; Index < NumberOfVlan; Index++) {
for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) {
if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) {
FoundDuplicateItem = TRUE;
Count++;
break;
}
}
if (FoundDuplicateItem) {
for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) {
CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI));
for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) {
if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) {
FoundDuplicateItem = TRUE;
Count++;
break;
}
}
}
FoundDuplicateItem = FALSE;
if (FoundDuplicateItem) {
for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) {
CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI));
}
}
FoundDuplicateItem = FALSE;
}
*NewNumberOfVlan = NumberOfVlan - Count;
@@ -293,9 +293,9 @@ MnpCheckVlanVariable (
**/
EFI_STATUS
MnpGetVlanVariable (
IN MNP_DEVICE_DATA *MnpDeviceData,
OUT UINTN *NumberOfVlan,
OUT VLAN_TCI **VlanVariable
IN MNP_DEVICE_DATA *MnpDeviceData,
OUT UINTN *NumberOfVlan,
OUT VLAN_TCI **VlanVariable
)
{
UINTN BufferSize;
@@ -306,15 +306,15 @@ MnpGetVlanVariable (
//
// Get VLAN configuration from EFI Variable
//
Buffer = NULL;
Buffer = NULL;
BufferSize = 0;
Status = gRT->GetVariable (
MnpDeviceData->MacString,
&gEfiVlanConfigProtocolGuid,
NULL,
&BufferSize,
NULL
);
Status = gRT->GetVariable (
MnpDeviceData->MacString,
&gEfiVlanConfigProtocolGuid,
NULL,
&BufferSize,
NULL
);
if (Status != EFI_BUFFER_TOO_SMALL) {
return EFI_NOT_FOUND;
}
@@ -361,9 +361,9 @@ MnpGetVlanVariable (
**/
EFI_STATUS
MnpSetVlanVariable (
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN NumberOfVlan,
IN VLAN_TCI *VlanVariable
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN NumberOfVlan,
IN VLAN_TCI *VlanVariable
)
{
return gRT->SetVariable (
@@ -375,7 +375,6 @@ MnpSetVlanVariable (
);
}
/**
Create a VLAN device or modify the configuration parameter of an
already-configured VLAN.
@@ -410,9 +409,9 @@ MnpSetVlanVariable (
EFI_STATUS
EFIAPI
VlanConfigSet (
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId,
IN UINT8 Priority
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId,
IN UINT8 Priority
)
{
EFI_STATUS Status;
@@ -429,14 +428,14 @@ VlanConfigSet (
return EFI_INVALID_PARAMETER;
}
IsAdd = FALSE;
IsAdd = FALSE;
MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This);
if (MnpDeviceData->NumberOfVlan == 0) {
//
// No existing VLAN, this is the first VLAN to add
//
IsAdd = TRUE;
Entry = GetFirstNode (&MnpDeviceData->ServiceList);
IsAdd = TRUE;
Entry = GetFirstNode (&MnpDeviceData->ServiceList);
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
if (VlanId != 0) {
@@ -470,7 +469,7 @@ VlanConfigSet (
//
// VlanId not found, create a new MNP service data
//
IsAdd = TRUE;
IsAdd = TRUE;
MnpServiceData = MnpCreateServiceData (MnpDeviceData, VlanId, Priority);
if (MnpServiceData == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -478,7 +477,7 @@ VlanConfigSet (
}
}
MnpServiceData->VlanId = VlanId;
MnpServiceData->VlanId = VlanId;
MnpServiceData->Priority = Priority;
if (IsAdd) {
MnpDeviceData->NumberOfVlan++;
@@ -516,6 +515,7 @@ VlanConfigSet (
break;
}
}
ASSERT (Index < NumberOfVlan);
NewVariable = OldVariable;
@@ -536,7 +536,6 @@ Exit:
return Status;
}
/**
Find configuration information for specified VLAN or all configured VLANs.
@@ -559,10 +558,10 @@ Exit:
EFI_STATUS
EFIAPI
VlanConfigFind (
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 *VlanId OPTIONAL,
OUT UINT16 *NumberOfVlan,
OUT EFI_VLAN_FIND_DATA **Entries
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 *VlanId OPTIONAL,
OUT UINT16 *NumberOfVlan,
OUT EFI_VLAN_FIND_DATA **Entries
)
{
MNP_DEVICE_DATA *MnpDeviceData;
@@ -570,7 +569,7 @@ VlanConfigFind (
LIST_ENTRY *Entry;
EFI_VLAN_FIND_DATA *VlanData;
if ((This == NULL) || (VlanId != NULL && *VlanId > 4094) || (NumberOfVlan == NULL) || (Entries == NULL)) {
if ((This == NULL) || ((VlanId != NULL) && (*VlanId > 4094)) || (NumberOfVlan == NULL) || (Entries == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -586,8 +585,8 @@ VlanConfigFind (
//
// Return all current VLAN configuration
//
*NumberOfVlan = (UINT16) MnpDeviceData->NumberOfVlan;
VlanData = AllocateZeroPool (*NumberOfVlan * sizeof (EFI_VLAN_FIND_DATA));
*NumberOfVlan = (UINT16)MnpDeviceData->NumberOfVlan;
VlanData = AllocateZeroPool (*NumberOfVlan * sizeof (EFI_VLAN_FIND_DATA));
if (VlanData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -596,7 +595,7 @@ VlanConfigFind (
NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
VlanData->VlanId = MnpServiceData->VlanId;
VlanData->VlanId = MnpServiceData->VlanId;
VlanData->Priority = MnpServiceData->Priority;
VlanData++;
}
@@ -616,16 +615,16 @@ VlanConfigFind (
if (VlanData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
VlanData->VlanId = MnpServiceData->VlanId;
VlanData->VlanId = MnpServiceData->VlanId;
VlanData->Priority = MnpServiceData->Priority;
*NumberOfVlan = 1;
*Entries = VlanData;
*Entries = VlanData;
return EFI_SUCCESS;
}
/**
Remove the configured VLAN device.
@@ -646,8 +645,8 @@ VlanConfigFind (
EFI_STATUS
EFIAPI
VlanConfigRemove (
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId
)
{
EFI_STATUS Status;

View File

@@ -11,8 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "MnpDriver.h"
extern EFI_VLAN_CONFIG_PROTOCOL mVlanConfigProtocolTemplate;
extern EFI_VLAN_CONFIG_PROTOCOL mVlanConfigProtocolTemplate;
/**
Create a child handle for the VLAN ID.
@@ -27,10 +26,10 @@ extern EFI_VLAN_CONFIG_PROTOCOL mVlanConfigProtocolTemplate;
**/
EFI_HANDLE
MnpCreateVlanChild (
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle,
IN UINT16 VlanId,
OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL
IN EFI_HANDLE ImageHandle,
IN EFI_HANDLE ControllerHandle,
IN UINT16 VlanId,
OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL
);
/**
@@ -46,9 +45,9 @@ MnpCreateVlanChild (
**/
BOOLEAN
MnpRemoveVlanTag (
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf,
OUT UINT16 *VlanId
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
IN OUT NET_BUF *Nbuf,
OUT UINT16 *VlanId
);
/**
@@ -65,11 +64,11 @@ MnpRemoveVlanTag (
**/
VOID
MnpInsertVlanTag (
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT16 *ProtocolType,
IN OUT UINT8 **Packet,
IN OUT UINT32 *Length
IN MNP_SERVICE_DATA *MnpServiceData,
IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
OUT UINT16 *ProtocolType,
IN OUT UINT8 **Packet,
IN OUT UINT32 *Length
);
/**
@@ -88,9 +87,9 @@ MnpInsertVlanTag (
**/
EFI_STATUS
MnpGetVlanVariable (
IN MNP_DEVICE_DATA *MnpDeviceData,
OUT UINTN *NumberOfVlan,
OUT VLAN_TCI **VlanVariable
IN MNP_DEVICE_DATA *MnpDeviceData,
OUT UINTN *NumberOfVlan,
OUT VLAN_TCI **VlanVariable
);
/**
@@ -106,9 +105,9 @@ MnpGetVlanVariable (
**/
EFI_STATUS
MnpSetVlanVariable (
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN NumberOfVlan,
IN VLAN_TCI *VlanVariable
IN MNP_DEVICE_DATA *MnpDeviceData,
IN UINTN NumberOfVlan,
IN VLAN_TCI *VlanVariable
);
/**
@@ -145,9 +144,9 @@ MnpSetVlanVariable (
EFI_STATUS
EFIAPI
VlanConfigSet (
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId,
IN UINT8 Priority
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId,
IN UINT8 Priority
);
/**
@@ -172,10 +171,10 @@ VlanConfigSet (
EFI_STATUS
EFIAPI
VlanConfigFind (
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 *VlanId OPTIONAL,
OUT UINT16 *NumberOfVlan,
OUT EFI_VLAN_FIND_DATA **Entries
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 *VlanId OPTIONAL,
OUT UINT16 *NumberOfVlan,
OUT EFI_VLAN_FIND_DATA **Entries
);
/**
@@ -198,8 +197,8 @@ VlanConfigFind (
EFI_STATUS
EFIAPI
VlanConfigRemove (
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId
IN EFI_VLAN_CONFIG_PROTOCOL *This,
IN UINT16 VlanId
);
#endif