Add VLAN support.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9649 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1,25 +1,24 @@
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for MnpDxe driver.
|
||||
|
||||
Copyright (c) 2005 - 2007, Intel Corporation. <BR>
|
||||
All rights reserved. This program and the accompanying materials are licensed
|
||||
and made available under the terms and conditions of the BSD License which
|
||||
accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "MnpDriver.h"
|
||||
|
||||
#include "MnpDriver.h"
|
||||
|
||||
//
|
||||
// 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"
|
||||
@@ -28,14 +27,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName = {
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2 = {
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2 = {
|
||||
(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"
|
||||
@@ -88,9 +86,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mMnpDriverNameTable[] = {
|
||||
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 (
|
||||
@@ -149,9 +147,9 @@ MnpComponentNameGetDriverName (
|
||||
Language from the point of view of the driver
|
||||
specified by This.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the user readable name
|
||||
@retval EFI_SUCCESS The Unicode string for the user readable name
|
||||
specified by This, ControllerHandle, ChildHandle,
|
||||
and Language was returned in ControllerName.
|
||||
and Language was returned in ControllerName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||
|
||||
@@ -173,11 +171,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
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
|
@@ -1,10 +1,11 @@
|
||||
/** @file
|
||||
The header file of UEFI Component Name(2) protocol.
|
||||
|
||||
Copyright (c) 2004 - 2007, Intel Corporation.<BR>
|
||||
Copyright (c) 2004 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -18,8 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Protocol/ComponentName.h>
|
||||
#include <Protocol/ComponentName2.h>
|
||||
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName;
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
@@ -63,12 +64,11 @@ extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName;
|
||||
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
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@@ -116,9 +116,9 @@ MnpComponentNameGetDriverName (
|
||||
Language from the point of view of the driver
|
||||
specified by This.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the user readable name
|
||||
@retval EFI_SUCCESS The Unicode string for the user readable name
|
||||
specified by This, ControllerHandle, ChildHandle,
|
||||
and Language was returned in ControllerName.
|
||||
and Language was returned in ControllerName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||
|
||||
@@ -140,11 +140,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
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,12 @@
|
||||
/** @file
|
||||
Implementation of driver entry point and driver binding protocol.
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation. <BR>
|
||||
All rights reserved. This program and the accompanying materials are licensed
|
||||
and made available under the terms and conditions of the BSD License which
|
||||
accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
@@ -14,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#include "MnpDriver.h"
|
||||
#include "MnpImpl.h"
|
||||
|
||||
#include "MnpVlan.h"
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
|
||||
MnpDriverBindingSupported,
|
||||
@@ -35,7 +36,7 @@ EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to test.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
child device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver supports this device.
|
||||
@@ -46,29 +47,14 @@ EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding = {
|
||||
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;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
|
||||
//
|
||||
// Test to see if MNP is already installed.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Test to open the Simple Network protocol BY_DRIVER.
|
||||
//
|
||||
@@ -80,7 +66,6 @@ MnpDriverBindingSupported (
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -101,77 +86,159 @@ MnpDriverBindingSupported (
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service ConnectController(). In order to make drivers as small
|
||||
EFI boot service ConnectController(). In order to make drivers as small
|
||||
as possible, there are a few calling restrictions for this service.
|
||||
ConnectController() must follow these calling restrictions. If any other
|
||||
agent wishes to call Start() it must also follow these calling restrictions.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
child device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver is added to ControllerHandle.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
|
||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
|
||||
@retval Others This driver does not support this device.
|
||||
|
||||
|
||||
**/
|
||||
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;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
BOOLEAN MnpInitialized;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
LIST_ENTRY *Entry;
|
||||
VLAN_TCI *VlanVariable;
|
||||
UINTN NumberOfVlan;
|
||||
UINTN Index;
|
||||
|
||||
MnpInitialized = FALSE;
|
||||
VlanVariable = NULL;
|
||||
|
||||
MnpServiceData = AllocateZeroPool (sizeof (MNP_SERVICE_DATA));
|
||||
if (MnpServiceData == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "MnpDriverBindingStart(): Failed to allocate the Mnp Service Data.\n"));
|
||||
//
|
||||
// Initialize the Mnp Device Data
|
||||
//
|
||||
MnpDeviceData = AllocateZeroPool (sizeof (MNP_DEVICE_DATA));
|
||||
if (MnpDeviceData == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "MnpDriverBindingStart(): Failed to allocate the Mnp Device Data.\n"));
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the Mnp Service Data.
|
||||
//
|
||||
Status = MnpInitializeServiceData (MnpServiceData, This->DriverBindingHandle, ControllerHandle);
|
||||
Status = MnpInitializeDeviceData (MnpDeviceData, This->DriverBindingHandle, ControllerHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "MnpDriverBindingStart: MnpInitializeDeviceData failed, %r.\n", Status));
|
||||
|
||||
DEBUG ((EFI_D_ERROR, "MnpDriverBindingStart: MnpInitializeServiceData failed, %r.\n",Status));
|
||||
goto ErrorExit;
|
||||
FreePool (MnpDeviceData);
|
||||
return Status;
|
||||
}
|
||||
|
||||
MnpInitialized = TRUE;
|
||||
//
|
||||
// Check whether NIC driver has already produced VlanConfig protocol
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// NIC hardware already implement VLAN,
|
||||
// no need to provide software VLAN implementation in MNP driver
|
||||
//
|
||||
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;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Install the MNP Service Binding Protocol.
|
||||
// Install VLAN Config Protocol
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&ControllerHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
&MnpServiceData->ServiceBinding,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
&MnpDeviceData->VlanConfig,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
ErrorExit:
|
||||
//
|
||||
// Get current VLAN configuration from EFI Variable
|
||||
//
|
||||
NumberOfVlan = 0;
|
||||
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;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Create MNP service data for each VLAN
|
||||
//
|
||||
MnpDeviceData->NumberOfVlan = NumberOfVlan;
|
||||
for (Index = 0; Index < NumberOfVlan; Index++) {
|
||||
MnpServiceData = MnpCreateServiceData (
|
||||
MnpDeviceData,
|
||||
VlanVariable[Index].Bits.Vid,
|
||||
(UINT8) VlanVariable[Index].Bits.Priority
|
||||
);
|
||||
|
||||
if (MnpServiceData == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
if (VlanVariable != NULL) {
|
||||
FreePool (VlanVariable);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
if (MnpInitialized) {
|
||||
//
|
||||
// Flush the Mnp Service Data.
|
||||
//
|
||||
MnpFlushServiceData (MnpServiceData, This->DriverBindingHandle);
|
||||
//
|
||||
// Destroy all MNP service data
|
||||
//
|
||||
while (!IsListEmpty (&MnpDeviceData->ServiceList)) {
|
||||
Entry = GetFirstNode (&MnpDeviceData->ServiceList);
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
|
||||
MnpDestroyServiceData (MnpServiceData);
|
||||
}
|
||||
|
||||
FreePool (MnpServiceData);
|
||||
//
|
||||
// Uninstall the VLAN Config Protocol if any
|
||||
//
|
||||
if (MnpDeviceData->VlanConfig.Set != NULL) {
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
MnpDeviceData->ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
&MnpDeviceData->VlanConfig,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Destroy Mnp Device Data
|
||||
//
|
||||
MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);
|
||||
FreePool (MnpDeviceData);
|
||||
}
|
||||
|
||||
return Status;
|
||||
@@ -179,16 +246,16 @@ ErrorExit:
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service DisconnectController(). In order to make drivers as
|
||||
small as possible, there are a few calling restrictions for this service.
|
||||
DisconnectController() must follow these calling restrictions. If any other
|
||||
EFI boot service DisconnectController(). In order to make drivers as
|
||||
small as possible, there are a few calling restrictions for this service.
|
||||
DisconnectController() must follow these calling restrictions. If any other
|
||||
agent wishes to call Stop() it must also follow these calling restrictions.
|
||||
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to stop driver on.
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
|
||||
number of children is zero stop the entire
|
||||
bus driver.
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
|
||||
number of children is zero stop the entire
|
||||
bus driver.
|
||||
@param[in] ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle.
|
||||
@@ -198,19 +265,22 @@ ErrorExit:
|
||||
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;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
EFI_VLAN_CONFIG_PROTOCOL *VlanConfig;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
BOOLEAN AllChildrenStopped;
|
||||
LIST_ENTRY *Entry;
|
||||
|
||||
//
|
||||
// Retrieve the MNP service binding protocol from the ControllerHandle.
|
||||
// Try to retrieve MNP service binding protocol from the ControllerHandle
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
@@ -221,51 +291,77 @@ MnpDriverBindingStop (
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Retrieve VLAN Config Protocol from the ControllerHandle
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
(VOID **) &VlanConfig,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "MnpDriverBindingStop: try to stop unknown Controller.\n"));
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
DEBUG (
|
||||
(EFI_D_ERROR,
|
||||
"MnpDriverBindingStop: Locate MNP Service Binding Protocol failed, %r.\n",
|
||||
Status)
|
||||
);
|
||||
return EFI_DEVICE_ERROR;
|
||||
MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (VlanConfig);
|
||||
} else {
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (ServiceBinding);
|
||||
MnpDeviceData = MnpServiceData->MnpDeviceData;
|
||||
}
|
||||
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_THIS (ServiceBinding);
|
||||
|
||||
if (NumberOfChildren == 0) {
|
||||
//
|
||||
// Uninstall the MNP Service Binding Protocol.
|
||||
// Destroy all MNP service data
|
||||
//
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
ControllerHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
while (!IsListEmpty (&MnpDeviceData->ServiceList)) {
|
||||
Entry = GetFirstNode (&MnpDeviceData->ServiceList);
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
|
||||
MnpDestroyServiceData (MnpServiceData);
|
||||
}
|
||||
|
||||
//
|
||||
// Flush the Mnp service data.
|
||||
// Uninstall the VLAN Config Protocol if any
|
||||
//
|
||||
MnpFlushServiceData (MnpServiceData, This->DriverBindingHandle);
|
||||
if (MnpDeviceData->VlanConfig.Set != NULL) {
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
MnpDeviceData->ControllerHandle,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
&MnpDeviceData->VlanConfig,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
FreePool (MnpServiceData);
|
||||
} else {
|
||||
while (!IsListEmpty (&MnpServiceData->ChildrenList)) {
|
||||
//
|
||||
// Don't use NetListRemoveHead here, the remove opreration will be done
|
||||
// in ServiceBindingDestroyChild.
|
||||
//
|
||||
Instance = NET_LIST_HEAD (
|
||||
&MnpServiceData->ChildrenList,
|
||||
MNP_INSTANCE_DATA,
|
||||
InstEntry
|
||||
);
|
||||
//
|
||||
// Destroy the Mnp device data
|
||||
//
|
||||
MnpDestroyDeviceData (MnpDeviceData, This->DriverBindingHandle);
|
||||
FreePool (MnpDeviceData);
|
||||
|
||||
ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Stop all MNP child
|
||||
//
|
||||
AllChildrenStopped = TRUE;
|
||||
NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
|
||||
|
||||
Status = MnpDestroyServiceChild (MnpServiceData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
AllChildrenStopped = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
if (!AllChildrenStopped) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -275,12 +371,12 @@ MnpDriverBindingStop (
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in, out] ChildHandle Pointer to the handle of the child to create. If
|
||||
it is NULL, then a new handle is created. If
|
||||
it is not NULL, then the I/O services are added
|
||||
to the existing child handle.
|
||||
it is not NULL, then the I/O services are added
|
||||
to the existing child handle.
|
||||
|
||||
@retval EFI_SUCCES The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
|
||||
@retval EFI_SUCCES The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
|
||||
create the child.
|
||||
@retval Others The child handle was not created.
|
||||
|
||||
@@ -288,18 +384,17 @@ 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;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
MNP_INSTANCE_DATA *Instance;
|
||||
VOID *Snp;
|
||||
VOID *MnpSb;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -310,8 +405,8 @@ MnpServiceBindingCreateChild (
|
||||
//
|
||||
Instance = AllocateZeroPool (sizeof (MNP_INSTANCE_DATA));
|
||||
if (Instance == NULL) {
|
||||
|
||||
DEBUG ((EFI_D_ERROR, "MnpServiceBindingCreateChild: Faild to allocate memory for the new instance.\n"));
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@@ -327,12 +422,12 @@ MnpServiceBindingCreateChild (
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
DEBUG (
|
||||
(EFI_D_ERROR,
|
||||
"MnpServiceBindingCreateChild: Failed to install the MNP protocol, %r.\n",
|
||||
Status)
|
||||
);
|
||||
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
@@ -342,9 +437,9 @@ MnpServiceBindingCreateChild (
|
||||
Instance->Handle = *ChildHandle;
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
MnpServiceData->ControllerHandle,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
(VOID **) &Snp,
|
||||
MnpServiceData->ServiceHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
(VOID **) &MnpSb,
|
||||
gMnpDriverBinding.DriverBindingHandle,
|
||||
Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@@ -385,16 +480,16 @@ ErrorExit:
|
||||
|
||||
/**
|
||||
Destroys a child handle with a set of I/O services.
|
||||
|
||||
The DestroyChild() function does the opposite of CreateChild(). It removes a
|
||||
protocol that was installed by CreateChild() from ChildHandle. If the removed
|
||||
protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
|
||||
|
||||
@param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
|
||||
|
||||
The DestroyChild() function does the opposite of CreateChild(). It removes a
|
||||
protocol that was installed by CreateChild() from ChildHandle. If the removed
|
||||
protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
|
||||
|
||||
@param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
|
||||
instance.
|
||||
@param[in] ChildHandle Handle of the child to destroy.
|
||||
|
||||
@retval EFI_SUCCES The protocol was removed from ChildHandle.
|
||||
@retval EFI_SUCCES The protocol was removed from ChildHandle.
|
||||
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
|
||||
is being removed.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle.
|
||||
@@ -407,8 +502,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;
|
||||
@@ -418,7 +513,6 @@ MnpServiceBindingDestroyChild (
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (ChildHandle == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -436,7 +530,6 @@ MnpServiceBindingDestroyChild (
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -449,7 +542,6 @@ MnpServiceBindingDestroyChild (
|
||||
// will only excecute once.
|
||||
//
|
||||
if (Instance->Destroyed) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -459,9 +551,9 @@ MnpServiceBindingDestroyChild (
|
||||
// Close the Simple Network protocol.
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
MnpServiceData->ControllerHandle,
|
||||
&gEfiSimpleNetworkProtocolGuid,
|
||||
gMnpDriverBinding.DriverBindingHandle,
|
||||
MnpServiceData->ServiceHandle,
|
||||
&gEfiManagedNetworkServiceBindingProtocolGuid,
|
||||
MnpServiceData->MnpDeviceData->ImageHandle,
|
||||
ChildHandle
|
||||
);
|
||||
|
||||
@@ -475,7 +567,6 @@ MnpServiceBindingDestroyChild (
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
DEBUG (
|
||||
(EFI_D_ERROR,
|
||||
"MnpServiceBindingDestroyChild: Failed to uninstall the ManagedNetwork protocol, %r.\n",
|
||||
@@ -523,7 +614,7 @@ MnpServiceBindingDestroyChild (
|
||||
@param[in] ImageHandle The image handle of the driver.
|
||||
@param[in] SystemTable The system table.
|
||||
|
||||
@retval EFI_SUCCES The driver binding and component name protocols are
|
||||
@retval EFI_SUCCES The driver binding and component name protocols are
|
||||
successfully installed.
|
||||
@retval Others Other errors as indicated.
|
||||
|
||||
@@ -531,8 +622,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 (
|
||||
|
@@ -1,11 +1,12 @@
|
||||
/** @file
|
||||
Declaration of strctures and functions for MnpDxe driver.
|
||||
|
||||
Copyright (c) 2005 - 2007, Intel Corporation. <BR>
|
||||
All rights reserved. This program and the accompanying materials are licensed
|
||||
and made available under the terms and conditions of the BSD License which
|
||||
accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
@@ -14,11 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#ifndef _MNP_DRIVER_H_
|
||||
#define _MNP_DRIVER_H_
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/ManagedNetwork.h>
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/ServiceBinding.h>
|
||||
#include <Protocol/VlanConfig.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
@@ -28,23 +31,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/NetLib.h>
|
||||
#include <Library/DpcLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
|
||||
#include "ComponentName.h"
|
||||
|
||||
#define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
|
||||
#define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
|
||||
EFI_HANDLE ControllerHandle;
|
||||
EFI_HANDLE ImageHandle;
|
||||
|
||||
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
||||
EFI_VLAN_CONFIG_PROTOCOL VlanConfig;
|
||||
UINTN NumberOfVlan;
|
||||
CHAR16 *MacString;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
|
||||
UINT32 Mtu;
|
||||
|
||||
LIST_ENTRY ChildrenList;
|
||||
UINTN ChildrenNumber;
|
||||
//
|
||||
// List of MNP_SERVICE_DATA
|
||||
//
|
||||
LIST_ENTRY ServiceList;
|
||||
//
|
||||
// Number of configured MNP Service Binding child
|
||||
//
|
||||
UINTN ConfiguredChildrenNumber;
|
||||
|
||||
LIST_ENTRY GroupAddressList;
|
||||
@@ -73,8 +84,38 @@ typedef struct {
|
||||
UINT32 PaddingSize;
|
||||
NET_BUF *RxNbufCache;
|
||||
UINT8 *TxBuf;
|
||||
} MNP_DEVICE_DATA;
|
||||
|
||||
#define MNP_DEVICE_DATA_FROM_THIS(a) \
|
||||
CR ( \
|
||||
(a), \
|
||||
MNP_DEVICE_DATA, \
|
||||
VlanConfig, \
|
||||
MNP_DEVICE_DATA_SIGNATURE \
|
||||
)
|
||||
|
||||
#define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
|
||||
LIST_ENTRY Link;
|
||||
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
EFI_HANDLE ServiceHandle;
|
||||
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
|
||||
LIST_ENTRY ChildrenList;
|
||||
UINTN ChildrenNumber;
|
||||
|
||||
UINT32 Mtu;
|
||||
|
||||
UINT16 VlanId;
|
||||
UINT8 Priority;
|
||||
} MNP_SERVICE_DATA;
|
||||
|
||||
|
||||
#define MNP_SERVICE_DATA_FROM_THIS(a) \
|
||||
CR ( \
|
||||
(a), \
|
||||
@@ -83,6 +124,15 @@ typedef struct {
|
||||
MNP_SERVICE_DATA_SIGNATURE \
|
||||
)
|
||||
|
||||
#define MNP_SERVICE_DATA_FROM_LINK(a) \
|
||||
CR ( \
|
||||
(a), \
|
||||
MNP_SERVICE_DATA, \
|
||||
Link, \
|
||||
MNP_SERVICE_DATA_SIGNATURE \
|
||||
)
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. This service
|
||||
is called by the EFI boot service ConnectController(). In
|
||||
@@ -93,7 +143,7 @@ typedef struct {
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to test.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
child device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver supports this device.
|
||||
@@ -104,50 +154,50 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service ConnectController(). In order to make drivers as small
|
||||
EFI boot service ConnectController(). In order to make drivers as small
|
||||
as possible, there are a few calling restrictions for this service.
|
||||
ConnectController() must follow these calling restrictions. If any other
|
||||
agent wishes to call Start() it must also follow these calling restrictions.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
||||
child device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver is added to ControllerHandle.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
|
||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
|
||||
@retval Others This driver does not support this device.
|
||||
|
||||
|
||||
**/
|
||||
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
|
||||
small as possible, there are a few calling restrictions for this service.
|
||||
DisconnectController() must follow these calling restrictions. If any other
|
||||
EFI boot service DisconnectController(). In order to make drivers as
|
||||
small as possible, there are a few calling restrictions for this service.
|
||||
DisconnectController() must follow these calling restrictions. If any other
|
||||
agent wishes to call Stop() it must also follow these calling restrictions.
|
||||
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to stop driver on.
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
|
||||
number of children is zero stop the entire
|
||||
bus driver.
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
|
||||
number of children is zero stop the entire
|
||||
bus driver.
|
||||
@param[in] ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle.
|
||||
@@ -157,10 +207,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
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -169,12 +219,12 @@ MnpDriverBindingStop (
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in, out] ChildHandle Pointer to the handle of the child to create. If
|
||||
it is NULL, then a new handle is created. If
|
||||
it is not NULL, then the I/O services are added
|
||||
to the existing child handle.
|
||||
it is not NULL, then the I/O services are added
|
||||
to the existing child handle.
|
||||
|
||||
@retval EFI_SUCCES The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
|
||||
@retval EFI_SUCCES The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
|
||||
create the child.
|
||||
@retval Others The child handle was not created.
|
||||
|
||||
@@ -182,22 +232,22 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Destroys a child handle with a set of I/O services.
|
||||
|
||||
The DestroyChild() function does the opposite of CreateChild(). It removes a
|
||||
protocol that was installed by CreateChild() from ChildHandle. If the removed
|
||||
protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
|
||||
|
||||
@param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
|
||||
|
||||
The DestroyChild() function does the opposite of CreateChild(). It removes a
|
||||
protocol that was installed by CreateChild() from ChildHandle. If the removed
|
||||
protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
|
||||
|
||||
@param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
|
||||
instance.
|
||||
@param[in] ChildHandle Handle of the child to destroy.
|
||||
|
||||
@retval EFI_SUCCES The protocol was removed from ChildHandle.
|
||||
@retval EFI_SUCCES The protocol was removed from ChildHandle.
|
||||
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
|
||||
is being removed.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle.
|
||||
@@ -210,8 +260,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
|
||||
|
@@ -1,16 +1,17 @@
|
||||
/** @file
|
||||
Component description file for Mnp module.
|
||||
## @file
|
||||
# Component description file for Mnp module.
|
||||
#
|
||||
# Copyright (c) 2006 - 2009, Intel Corporation. <BR>
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
Copyright (c) 2006, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = MnpDxe
|
||||
@@ -24,7 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
# DRIVER_BINDING = gMnpDriverBinding
|
||||
# DRIVER_BINDING = gMnpDriverBinding
|
||||
# COMPONENT_NAME = gMnpComponentName
|
||||
# COMPONENT_NAME2 = gMnpComponentName2
|
||||
#
|
||||
@@ -38,13 +39,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
MnpDriver.c
|
||||
MnpConfig.c
|
||||
MnpImpl.h
|
||||
|
||||
MnpVlan.h
|
||||
MnpVlan.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
@@ -57,6 +58,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
DpcLib
|
||||
|
||||
[Protocols]
|
||||
gEfiManagedNetworkServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiManagedNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||
gEfiManagedNetworkServiceBindingProtocolGuid ## PRODUCES
|
||||
gEfiSimpleNetworkProtocolGuid ## CONSUMES
|
||||
gEfiManagedNetworkProtocolGuid ## PRODUCES
|
||||
gEfiVlanConfigProtocolGuid ## SOMETIMES_PRODUCES
|
||||
|
@@ -1,10 +1,11 @@
|
||||
/** @file
|
||||
Declaration of structures and functions of MnpDxe driver.
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation. <BR>
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -90,6 +91,57 @@ typedef struct {
|
||||
UINT64 TimeoutTick;
|
||||
} MNP_RXDATA_WRAP;
|
||||
|
||||
|
||||
/**
|
||||
Initialize the mnp device context data.
|
||||
|
||||
@param[in, out] MnpDeviceData Pointer to the mnp device context data.
|
||||
@param[in] ImageHandle The driver image handle.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to.
|
||||
|
||||
@retval EFI_SUCCESS The mnp service context is initialized.
|
||||
@retval EFI_UNSUPPORTED ControllerHandle does not support Simple Network Protocol.
|
||||
@retval Others Other errors as indicated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpInitializeDeviceData (
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_HANDLE ControllerHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Destroy the MNP device context data.
|
||||
|
||||
@param[in, out] MnpDeviceData Pointer to the mnp device context data.
|
||||
@param[in] ImageHandle The driver image handle.
|
||||
|
||||
**/
|
||||
VOID
|
||||
MnpDestroyDeviceData (
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Create mnp service context data.
|
||||
|
||||
@param[in] MnpDeviceData Pointer to the mnp device context data.
|
||||
@param[in] VlanId The VLAN ID.
|
||||
@param[in] Priority The VLAN priority. If VlanId is 0,
|
||||
Priority is ignored.
|
||||
|
||||
@return A pointer to MNP_SERVICE_DATA or NULL if failed to create MNP service context.
|
||||
|
||||
**/
|
||||
MNP_SERVICE_DATA *
|
||||
MnpCreateServiceData (
|
||||
IN MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN UINT16 VlanId,
|
||||
IN UINT8 Priority OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize the mnp service context data.
|
||||
|
||||
@@ -104,36 +156,66 @@ typedef struct {
|
||||
**/
|
||||
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
|
||||
);
|
||||
|
||||
/**
|
||||
Flush the mnp service context data.
|
||||
Destroy the MNP service context data.
|
||||
|
||||
@param[in, out] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in] ImageHandle The driver image handle.
|
||||
|
||||
@retval EFI_SUCCESS The mnp service context is destroyed.
|
||||
@retval Others Errors as indicated.
|
||||
|
||||
**/
|
||||
VOID
|
||||
MnpFlushServiceData (
|
||||
IN OUT MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN EFI_HANDLE ImageHandle
|
||||
EFI_STATUS
|
||||
MnpDestroyServiceData (
|
||||
IN OUT MNP_SERVICE_DATA *MnpServiceData
|
||||
);
|
||||
|
||||
/**
|
||||
Destroy all child of the MNP service data.
|
||||
|
||||
@param[in, out] MnpServiceData Pointer to the mnp service context data.
|
||||
|
||||
@retval EFI_SUCCESS All child are destroyed.
|
||||
@retval Others Failed to destroy all child.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpDestroyServiceChild (
|
||||
IN OUT MNP_SERVICE_DATA *MnpServiceData
|
||||
);
|
||||
|
||||
/**
|
||||
Find the MNP Service Data for given VLAN ID.
|
||||
|
||||
@param[in] MnpDeviceData Pointer to the mnp device context data.
|
||||
@param[in] VlanId The VLAN ID.
|
||||
|
||||
@return A pointer to MNP_SERVICE_DATA or NULL if not found.
|
||||
|
||||
**/
|
||||
MNP_SERVICE_DATA *
|
||||
MnpFindServiceData (
|
||||
IN MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN UINT16 VlanId
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize the mnp instance context data.
|
||||
|
||||
@param[in] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in, out] Instance Pointer to the mnp instance context data
|
||||
@param[in, out] Instance Pointer to the mnp instance context data
|
||||
to initialize.
|
||||
|
||||
**/
|
||||
VOID
|
||||
MnpInitializeInstanceData (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
IN MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -152,9 +234,9 @@ MnpInitializeInstanceData (
|
||||
**/
|
||||
EFI_STATUS
|
||||
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
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -162,10 +244,10 @@ MnpTokenExist (
|
||||
|
||||
@param[in, out] Map Pointer to the NET_MAP.
|
||||
@param[in, out] Item Pointer to the NET_MAP_ITEM.
|
||||
@param[in] Arg Pointer to the Arg, it's a pointer to the
|
||||
@param[in] Arg Pointer to the Arg, it's a pointer to the
|
||||
token to cancel.
|
||||
|
||||
@retval EFI_SUCCESS The Arg is NULL, and the token in Item is cancelled,
|
||||
@retval EFI_SUCCESS The Arg is NULL, and the token in Item is cancelled,
|
||||
or the Arg isn't NULL, and the token in Item is
|
||||
different from the Arg.
|
||||
@retval EFI_ABORTED The Arg isn't NULL, the token in Item mathces the
|
||||
@@ -174,9 +256,9 @@ MnpTokenExist (
|
||||
**/
|
||||
EFI_STATUS
|
||||
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
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -187,7 +269,7 @@ MnpCancelTokens (
|
||||
**/
|
||||
VOID
|
||||
MnpFlushRcvdDataQueue (
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -205,18 +287,18 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Do the group operations for this instance.
|
||||
|
||||
@param[in, out] Instance Pointer to the instance context data.
|
||||
@param[in] JoinFlag Set to TRUE to join a group. Set to TRUE to
|
||||
@param[in] JoinFlag Set to TRUE to join a group. Set to TRUE to
|
||||
leave a group/groups.
|
||||
@param[in] MacAddress Pointer to the group address to join or leave.
|
||||
@param[in] CtrlBlk Pointer to the group control block if JoinFlag
|
||||
@param[in] CtrlBlk Pointer to the group control block if JoinFlag
|
||||
is FALSE.
|
||||
|
||||
@retval EFI_SUCCESS The group operation finished.
|
||||
@@ -226,10 +308,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
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -243,27 +325,27 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Build the packet to transmit from the TxData passed in.
|
||||
|
||||
@param[in] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in] TxData Pointer to the transmit data containing the information
|
||||
@param[in] TxData Pointer to the transmit data containing the information
|
||||
to build the packet.
|
||||
@param[out] PktBuf Pointer to record the address of the packet.
|
||||
@param[out] PktLen Pointer to a UINT32 variable used to record the packet's
|
||||
@param[out] PktLen Pointer to a UINT32 variable used to record the packet's
|
||||
length.
|
||||
|
||||
**/
|
||||
VOID
|
||||
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
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -281,10 +363,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
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -300,7 +382,7 @@ MnpSyncSendPacket (
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpInstanceDeliverPacket (
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -314,14 +396,14 @@ MnpInstanceDeliverPacket (
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpRecycleRxData (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Try to receive a packet and deliver it.
|
||||
|
||||
@param[in, out] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in, out] MnpDeviceData Pointer to the mnp device context data.
|
||||
|
||||
@retval EFI_SUCCESS add return value to function comment
|
||||
@retval EFI_NOT_STARTED The simple network protocol is not started.
|
||||
@@ -331,35 +413,35 @@ MnpRecycleRxData (
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpReceivePacket (
|
||||
IN OUT MNP_SERVICE_DATA *MnpServiceData
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData
|
||||
);
|
||||
|
||||
/**
|
||||
Allocate a free NET_BUF from MnpServiceData->FreeNbufQue. If there is none
|
||||
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
|
||||
fetch the NET_BUF from the updated FreeNbufQue.
|
||||
|
||||
@param[in, out] MnpServiceData Pointer to the MNP_SERVICE_DATA.
|
||||
@param[in, out] MnpDeviceData Pointer to the MNP_DEVICE_DATA.
|
||||
|
||||
@return Pointer to the allocated free NET_BUF structure, if NULL the
|
||||
@return Pointer to the allocated free NET_BUF structure, if NULL the
|
||||
operation is failed.
|
||||
|
||||
**/
|
||||
NET_BUF *
|
||||
MnpAllocNbuf (
|
||||
IN OUT MNP_SERVICE_DATA *MnpServiceData
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData
|
||||
);
|
||||
|
||||
/**
|
||||
Try to reclaim the Nbuf into the buffer pool.
|
||||
|
||||
@param[in, out] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in, out] MnpDeviceData Pointer to the mnp device context data.
|
||||
@param[in, out] Nbuf Pointer to the NET_BUF to free.
|
||||
|
||||
**/
|
||||
VOID
|
||||
MnpFreeNbuf (
|
||||
IN OUT MNP_SERVICE_DATA *MnpServiceData,
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN OUT NET_BUF *Nbuf
|
||||
);
|
||||
|
||||
@@ -369,13 +451,13 @@ MnpFreeNbuf (
|
||||
@param[in] Event The event this notify function registered to.
|
||||
@param[in] Context Pointer to the context data registered to the
|
||||
event.
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpCheckPacketTimeout (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -389,16 +471,16 @@ MnpCheckPacketTimeout (
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpSystemPoll (
|
||||
IN EFI_EVENT Event,
|
||||
IN OUT VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN OUT VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Returns the operational parameters for the current MNP child driver. May also
|
||||
support returning the underlying SNP driver mode data.
|
||||
|
||||
support returning the underlying SNP driver mode data.
|
||||
|
||||
The GetModeData() function is used to read the current mode data (operational
|
||||
parameters) from the MNP or the underlying SNP.
|
||||
parameters) from the MNP or the underlying SNP.
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[out] MnpConfigData Pointer to storage for MNP operational parameters. Type
|
||||
@@ -407,7 +489,7 @@ MnpSystemPoll (
|
||||
@param[out] SnpModeData Pointer to storage for SNP operational parameters. This
|
||||
feature may be unsupported. Type EFI_SIMPLE_NETWORK_MODE
|
||||
is defined in the EFI_SIMPLE_NETWORK_PROTOCOL.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
@retval EFI_UNSUPPORTED The requested feature is unsupported in this
|
||||
@@ -421,15 +503,15 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Sets or clears the operational parameters for the MNP child driver.
|
||||
|
||||
The Configure() function is used to set, change, or reset the operational
|
||||
Sets or clears the operational parameters for the MNP child driver.
|
||||
|
||||
The Configure() function is used to set, change, or reset the operational
|
||||
parameters for the MNP child driver instance. Until the operational parameters
|
||||
have been set, no network traffic can be sent or received by this MNP child
|
||||
driver instance. Once the operational parameters have been reset, no more
|
||||
@@ -481,14 +563,14 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Translates an IP multicast address to a hardware (MAC) multicast address. This
|
||||
function may be unsupported in some MNP implementations.
|
||||
|
||||
Translates an IP multicast address to a hardware (MAC) multicast address. This
|
||||
function may be unsupported in some MNP implementations.
|
||||
|
||||
The McastIpToMac() function translates an IP multicast address to a hardware
|
||||
(MAC) multicast address. This function may be implemented by calling the
|
||||
underlying EFI_SIMPLE_NETWORK. MCastIpToMac() function, which may also be
|
||||
@@ -499,7 +581,7 @@ MnpConfigure (
|
||||
Set to FALSE if IpAddress is an IPv4 multicast address.
|
||||
@param[in] IpAddress Pointer to the multicast IP address (in network byte
|
||||
order) to convert.
|
||||
@param[out] MacAddress Pointer to the resulting multicast MAC address.
|
||||
@param[out] MacAddress Pointer to the resulting multicast MAC address.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER One of the following conditions is TRUE:
|
||||
@@ -518,21 +600,21 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Enables and disables receive filters for multicast address. This function may
|
||||
Enables and disables receive filters for multicast address. This function may
|
||||
be unsupported in some MNP implementations.
|
||||
|
||||
The Groups() function only adds and removes multicast MAC addresses from the
|
||||
|
||||
The Groups() function only adds and removes multicast MAC addresses from the
|
||||
filter list. The MNP driver does not transmit or process Internet Group
|
||||
Management Protocol (IGMP) packets. If JoinFlag is FALSE and MacAddress is
|
||||
NULL, then all joined groups are left.
|
||||
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] JoinFlag Set to TRUE to join this multicast group.
|
||||
Set to FALSE to leave this multicast group.
|
||||
@@ -563,15 +645,15 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Places asynchronous outgoing data packets into the transmit queue.
|
||||
|
||||
The Transmit() function places a completion token into the transmit packet
|
||||
|
||||
The Transmit() function places a completion token into the transmit packet
|
||||
queue. This function is always asynchronous.
|
||||
The caller must fill in the Token.Event and Token.TxData fields in the
|
||||
completion token, and these fields cannot be NULL. When the transmit operation
|
||||
@@ -581,12 +663,12 @@ MnpGroups (
|
||||
defragmented before it can be transmitted by the network device. Systems in
|
||||
which performance is critical should review the requirements and features of
|
||||
the underlying communications device and drivers.
|
||||
|
||||
|
||||
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] Token Pointer to a token associated with the transmit data
|
||||
descriptor. Type EFI_MANAGED_NETWORK_COMPLETION_TOKEN
|
||||
is defined in "Related Definitions" below.
|
||||
is defined in "Related Definitions" below.
|
||||
|
||||
@retval EFI_SUCCESS The transmit completion token was cached.
|
||||
@retval EFI_NOT_STARTED This MNP child driver instance has not been
|
||||
@@ -615,7 +697,7 @@ MnpGroups (
|
||||
@retval EFI_ACCESS_DENIED The transmit completion token is already in the
|
||||
transmit queue.
|
||||
@retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a
|
||||
lack of system resources (usually memory).
|
||||
lack of system resources (usually memory).
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
The MNP child driver instance has been reset to
|
||||
startup defaults.
|
||||
@@ -626,13 +708,13 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Aborts an asynchronous transmit or receive request.
|
||||
|
||||
Aborts an asynchronous transmit or receive request.
|
||||
|
||||
The Cancel() function is used to abort a pending transmit or receive request.
|
||||
If the token is in the transmit or receive request queues, after calling this
|
||||
function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
|
||||
@@ -643,8 +725,8 @@ MnpTransmit (
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] Token Pointer to a token that has been issued by
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all
|
||||
pending tokens are aborted.
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all
|
||||
pending tokens are aborted.
|
||||
|
||||
@retval EFI_SUCCESS The asynchronous I/O request was aborted and
|
||||
Token.Event was signaled. When Token is NULL,
|
||||
@@ -662,20 +744,20 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Places an asynchronous receiving request into the receiving queue.
|
||||
|
||||
The Receive() function places a completion token into the receive packet
|
||||
|
||||
The Receive() function places a completion token into the receive packet
|
||||
queue. This function is always asynchronous.
|
||||
The caller must fill in the Token.Event field in the completion token, and
|
||||
this field cannot be NULL. When the receive operation completes, the MNP
|
||||
updates the Token.Status and Token.RxData fields and the Token.Event is
|
||||
signaled.
|
||||
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] Token Pointer to a token associated with the receive
|
||||
data descriptor. Type
|
||||
@@ -704,14 +786,14 @@ 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
|
||||
);
|
||||
|
||||
/**
|
||||
Polls for incoming data packets and processes outgoing data packets.
|
||||
|
||||
The Poll() function can be used by network drivers and applications to
|
||||
Polls for incoming data packets and processes outgoing data packets.
|
||||
|
||||
The Poll() function can be used by network drivers and applications to
|
||||
increase the rate that data packets are moved between the communications
|
||||
device and the transmit and receive queues.
|
||||
Normally, a periodic timer event internally calls the Poll() function. But, in
|
||||
@@ -737,23 +819,23 @@ MnpReceive (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpPoll (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This
|
||||
);
|
||||
|
||||
/**
|
||||
Configure the Snp receive filters according to the instances' receive filter
|
||||
settings.
|
||||
|
||||
@param[in] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in] MnpDeviceData Pointer to the mnp device context data.
|
||||
|
||||
@retval EFI_SUCCESS The receive filters is configured.
|
||||
@retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due
|
||||
@retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due
|
||||
to lack of memory resource.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpConfigReceiveFilters (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData
|
||||
IN MNP_DEVICE_DATA *MnpDeviceData
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@@ -1,10 +1,11 @@
|
||||
/** @file
|
||||
Implementation of Managed Network Protocol I/O functions.
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation. <BR>
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -13,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
|
||||
#include "MnpImpl.h"
|
||||
#include "MnpVlan.h"
|
||||
|
||||
/**
|
||||
Validates the Mnp transmit token.
|
||||
@@ -25,8 +27,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
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;
|
||||
@@ -38,7 +40,7 @@ MnpIsValidTxToken (
|
||||
MnpServiceData = Instance->MnpServiceData;
|
||||
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
|
||||
|
||||
TxData = Token->Packet.TxData;
|
||||
TxData = Token->Packet.TxData;
|
||||
|
||||
if ((Token->Event == NULL) || (TxData == NULL) || (TxData->FragmentCount == 0)) {
|
||||
//
|
||||
@@ -105,25 +107,27 @@ MnpIsValidTxToken (
|
||||
Build the packet to transmit from the TxData passed in.
|
||||
|
||||
@param[in] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in] TxData Pointer to the transmit data containing the information
|
||||
@param[in] TxData Pointer to the transmit data containing the information
|
||||
to build the packet.
|
||||
@param[out] PktBuf Pointer to record the address of the packet.
|
||||
@param[out] PktLen Pointer to a UINT32 variable used to record the packet's
|
||||
@param[out] PktLen Pointer to a UINT32 variable used to record the packet's
|
||||
length.
|
||||
|
||||
**/
|
||||
VOID
|
||||
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 *MnpDerviceData;
|
||||
|
||||
MnpDerviceData = MnpServiceData->MnpDeviceData;
|
||||
if ((TxData->DestinationAddress == NULL) && (TxData->FragmentCount == 1)) {
|
||||
//
|
||||
// Media header is in FragmentTable and there is only one fragment,
|
||||
@@ -137,8 +141,8 @@ MnpBuildTxPacket (
|
||||
// one fragment, copy the data into the packet buffer. Reserve the
|
||||
// media header space if necessary.
|
||||
//
|
||||
SnpMode = MnpServiceData->Snp->Mode;
|
||||
DstPos = MnpServiceData->TxBuf;
|
||||
SnpMode = MnpDerviceData->Snp->Mode;
|
||||
DstPos = MnpDerviceData->TxBuf;
|
||||
|
||||
*PktLen = 0;
|
||||
if (TxData->DestinationAddress != NULL) {
|
||||
@@ -165,7 +169,7 @@ MnpBuildTxPacket (
|
||||
//
|
||||
// Set the buffer pointer and the buffer length.
|
||||
//
|
||||
*PktBuf = MnpServiceData->TxBuf;
|
||||
*PktBuf = MnpDerviceData->TxBuf;
|
||||
*PktLen += TxData->DataLength + TxData->HeaderLength;
|
||||
}
|
||||
}
|
||||
@@ -186,10 +190,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
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -197,25 +201,32 @@ MnpSyncSendPacket (
|
||||
EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;
|
||||
UINT32 HeaderSize;
|
||||
UINT8 *TxBuf;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
UINT16 ProtocolType;
|
||||
|
||||
Snp = MnpServiceData->Snp;
|
||||
TxData = Token->Packet.TxData;
|
||||
MnpDeviceData = MnpServiceData->MnpDeviceData;
|
||||
Snp = MnpDeviceData->Snp;
|
||||
TxData = Token->Packet.TxData;
|
||||
|
||||
HeaderSize = Snp->Mode->MediaHeaderSize - TxData->HeaderLength;
|
||||
HeaderSize = Snp->Mode->MediaHeaderSize - TxData->HeaderLength;
|
||||
|
||||
//
|
||||
// Start the timeout event.
|
||||
//
|
||||
Status = gBS->SetTimer (
|
||||
MnpServiceData->TxTimeoutEvent,
|
||||
MnpDeviceData->TxTimeoutEvent,
|
||||
TimerRelative,
|
||||
MNP_TX_TIMEOUT_TIME
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
goto SIGNAL_TOKEN;
|
||||
}
|
||||
|
||||
//
|
||||
// Insert VLAN tag
|
||||
//
|
||||
MnpInsertVlanTag (MnpServiceData, TxData, &ProtocolType, &Packet, &Length);
|
||||
|
||||
for (;;) {
|
||||
//
|
||||
// Transmit the packet through SNP.
|
||||
@@ -227,10 +238,9 @@ MnpSyncSendPacket (
|
||||
Packet,
|
||||
TxData->SourceAddress,
|
||||
TxData->DestinationAddress,
|
||||
&TxData->ProtocolType
|
||||
&ProtocolType
|
||||
);
|
||||
if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) {
|
||||
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
break;
|
||||
}
|
||||
@@ -247,22 +257,20 @@ MnpSyncSendPacket (
|
||||
//
|
||||
Snp->GetStatus (Snp, NULL, (VOID **) &TxBuf);
|
||||
|
||||
if (!EFI_ERROR (gBS->CheckEvent (MnpServiceData->TxTimeoutEvent))) {
|
||||
|
||||
if (!EFI_ERROR (gBS->CheckEvent (MnpDeviceData->TxTimeoutEvent))) {
|
||||
Status = EFI_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
} while (TxBuf == NULL);
|
||||
|
||||
if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {
|
||||
|
||||
break;
|
||||
} else {
|
||||
//
|
||||
// Status is EFI_NOT_READY. Restart the timer event and call Snp->Transmit again.
|
||||
//
|
||||
gBS->SetTimer (
|
||||
MnpServiceData->TxTimeoutEvent,
|
||||
MnpDeviceData->TxTimeoutEvent,
|
||||
TimerRelative,
|
||||
MNP_TX_TIMEOUT_TIME
|
||||
);
|
||||
@@ -272,7 +280,7 @@ MnpSyncSendPacket (
|
||||
//
|
||||
// Cancel the timer event.
|
||||
//
|
||||
gBS->SetTimer (MnpServiceData->TxTimeoutEvent, TimerCancel, 0);
|
||||
gBS->SetTimer (MnpDeviceData->TxTimeoutEvent, TimerCancel, 0);
|
||||
|
||||
SIGNAL_TOKEN:
|
||||
|
||||
@@ -301,18 +309,18 @@ SIGNAL_TOKEN:
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpInstanceDeliverPacket (
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
IN OUT MNP_INSTANCE_DATA *Instance
|
||||
)
|
||||
{
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
MNP_RXDATA_WRAP *RxDataWrap;
|
||||
NET_BUF *DupNbuf;
|
||||
EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData;
|
||||
EFI_SIMPLE_NETWORK_MODE *SnpMode;
|
||||
EFI_MANAGED_NETWORK_COMPLETION_TOKEN *RxToken;
|
||||
|
||||
MnpServiceData = Instance->MnpServiceData;
|
||||
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
|
||||
MnpDeviceData = Instance->MnpServiceData->MnpDeviceData;
|
||||
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
|
||||
|
||||
if (NetMapIsEmpty (&Instance->RxTokenMap) || IsListEmpty (&Instance->RcvdPacketQueue)) {
|
||||
//
|
||||
@@ -329,7 +337,7 @@ MnpInstanceDeliverPacket (
|
||||
// There are other instances share this Nbuf, duplicate to get a
|
||||
// copy to allow the instance to do R/W operations.
|
||||
//
|
||||
DupNbuf = MnpAllocNbuf (MnpServiceData);
|
||||
DupNbuf = MnpAllocNbuf (MnpDeviceData);
|
||||
if (DupNbuf == NULL) {
|
||||
DEBUG ((EFI_D_WARN, "MnpDeliverPacket: Failed to allocate a free Nbuf.\n"));
|
||||
|
||||
@@ -340,7 +348,7 @@ MnpInstanceDeliverPacket (
|
||||
// Duplicate the net buffer.
|
||||
//
|
||||
NetbufDuplicate (RxDataWrap->Nbuf, DupNbuf, 0);
|
||||
MnpFreeNbuf (MnpServiceData, RxDataWrap->Nbuf);
|
||||
MnpFreeNbuf (MnpDeviceData, RxDataWrap->Nbuf);
|
||||
RxDataWrap->Nbuf = DupNbuf;
|
||||
}
|
||||
|
||||
@@ -351,7 +359,7 @@ MnpInstanceDeliverPacket (
|
||||
Instance->RcvdPacketQueueSize--;
|
||||
|
||||
RxData = &RxDataWrap->RxData;
|
||||
SnpMode = MnpServiceData->Snp->Mode;
|
||||
SnpMode = MnpDeviceData->Snp->Mode;
|
||||
|
||||
//
|
||||
// Set all the buffer pointers.
|
||||
@@ -390,7 +398,7 @@ MnpInstanceDeliverPacket (
|
||||
**/
|
||||
VOID
|
||||
MnpDeliverPacket (
|
||||
IN MNP_SERVICE_DATA *MnpServiceData
|
||||
IN MNP_SERVICE_DATA *MnpServiceData
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
@@ -421,12 +429,12 @@ MnpDeliverPacket (
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpRecycleRxData (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
MNP_RXDATA_WRAP *RxDataWrap;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
MNP_RXDATA_WRAP *RxDataWrap;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
|
||||
ASSERT (Context != NULL);
|
||||
|
||||
@@ -435,13 +443,13 @@ MnpRecycleRxData (
|
||||
|
||||
ASSERT (RxDataWrap->Nbuf != NULL);
|
||||
|
||||
MnpServiceData = RxDataWrap->Instance->MnpServiceData;
|
||||
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
|
||||
MnpDeviceData = RxDataWrap->Instance->MnpServiceData->MnpDeviceData;
|
||||
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
|
||||
|
||||
//
|
||||
// Free this Nbuf.
|
||||
//
|
||||
MnpFreeNbuf (MnpServiceData, RxDataWrap->Nbuf);
|
||||
MnpFreeNbuf (MnpDeviceData, RxDataWrap->Nbuf);
|
||||
RxDataWrap->Nbuf = NULL;
|
||||
|
||||
//
|
||||
@@ -467,8 +475,8 @@ 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;
|
||||
@@ -528,10 +536,10 @@ 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;
|
||||
@@ -607,18 +615,20 @@ 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;
|
||||
|
||||
SnpMode = MnpServiceData->Snp->Mode;
|
||||
MnpDeviceData = MnpServiceData->MnpDeviceData;
|
||||
SnpMode = MnpDeviceData->Snp->Mode;
|
||||
|
||||
//
|
||||
// Get the packet buffer.
|
||||
@@ -650,7 +660,7 @@ MnpAnalysePacket (
|
||||
//
|
||||
// It's multicast, try to match the multicast filters.
|
||||
//
|
||||
NET_LIST_FOR_EACH (Entry, &MnpServiceData->GroupAddressList) {
|
||||
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)) {
|
||||
@@ -667,7 +677,7 @@ MnpAnalysePacket (
|
||||
*GroupAddress = NULL;
|
||||
RxData->PromiscuousFlag = TRUE;
|
||||
|
||||
if (MnpServiceData->PromiscuousCount == 0) {
|
||||
if (MnpDeviceData->PromiscuousCount == 0) {
|
||||
//
|
||||
// Skip the below code, there is no receiver of this packet.
|
||||
//
|
||||
@@ -703,8 +713,8 @@ 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;
|
||||
@@ -737,8 +747,8 @@ MnpWrapRxData (
|
||||
&RxDataWrap->RxData.RecycleEvent
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
DEBUG ((EFI_D_ERROR, "MnpDispatchPacket: gBS->CreateEvent failed, %r.\n", Status));
|
||||
|
||||
FreePool (RxDataWrap);
|
||||
return NULL;
|
||||
}
|
||||
@@ -758,8 +768,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;
|
||||
@@ -776,7 +786,7 @@ MnpEnqueuePacket (
|
||||
//
|
||||
MnpAnalysePacket (MnpServiceData, Nbuf, &RxData, &GroupAddress, &PktAttr);
|
||||
|
||||
if (RxData.PromiscuousFlag && (MnpServiceData->PromiscuousCount == 0)) {
|
||||
if (RxData.PromiscuousFlag && (MnpServiceData->MnpDeviceData->PromiscuousCount == 0)) {
|
||||
//
|
||||
// No receivers, no more action need.
|
||||
//
|
||||
@@ -799,7 +809,6 @@ MnpEnqueuePacket (
|
||||
// Check the packet against the instance receive filters.
|
||||
//
|
||||
if (MnpMatchPacket (Instance, &RxData, GroupAddress, PktAttr)) {
|
||||
|
||||
//
|
||||
// Wrap the RxData.
|
||||
//
|
||||
@@ -826,7 +835,7 @@ MnpEnqueuePacket (
|
||||
/**
|
||||
Try to receive a packet and deliver it.
|
||||
|
||||
@param[in, out] MnpServiceData Pointer to the mnp service context data.
|
||||
@param[in, out] MnpDeviceData Pointer to the mnp device context data.
|
||||
|
||||
@retval EFI_SUCCESS add return value to function comment
|
||||
@retval EFI_NOT_STARTED The simple network protocol is not started.
|
||||
@@ -836,7 +845,7 @@ MnpEnqueuePacket (
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpReceivePacket (
|
||||
IN OUT MNP_SERVICE_DATA *MnpServiceData
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -846,10 +855,13 @@ MnpReceivePacket (
|
||||
UINTN BufLen;
|
||||
UINTN HeaderSize;
|
||||
UINT32 Trimmed;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
UINT16 VlanId;
|
||||
BOOLEAN IsVlanPacket;
|
||||
|
||||
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
|
||||
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
|
||||
|
||||
Snp = MnpServiceData->Snp;
|
||||
Snp = MnpDeviceData->Snp;
|
||||
if (Snp->Mode->State != EfiSimpleNetworkInitialized) {
|
||||
//
|
||||
// The simple network protocol is not started.
|
||||
@@ -857,20 +869,13 @@ MnpReceivePacket (
|
||||
return EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
if (IsListEmpty (&MnpServiceData->ChildrenList)) {
|
||||
//
|
||||
// There is no child, no need to receive packets.
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (MnpServiceData->RxNbufCache == NULL) {
|
||||
if (MnpDeviceData->RxNbufCache == NULL) {
|
||||
//
|
||||
// Try to get a new buffer as there may be buffers recycled.
|
||||
//
|
||||
MnpServiceData->RxNbufCache = MnpAllocNbuf (MnpServiceData);
|
||||
MnpDeviceData->RxNbufCache = MnpAllocNbuf (MnpDeviceData);
|
||||
|
||||
if (MnpServiceData->RxNbufCache == NULL) {
|
||||
if (MnpDeviceData->RxNbufCache == NULL) {
|
||||
//
|
||||
// No availabe buffer in the buffer pool.
|
||||
//
|
||||
@@ -878,13 +883,13 @@ MnpReceivePacket (
|
||||
}
|
||||
|
||||
NetbufAllocSpace (
|
||||
MnpServiceData->RxNbufCache,
|
||||
MnpServiceData->BufferLength,
|
||||
MnpDeviceData->RxNbufCache,
|
||||
MnpDeviceData->BufferLength,
|
||||
NET_BUF_TAIL
|
||||
);
|
||||
}
|
||||
|
||||
Nbuf = MnpServiceData->RxNbufCache;
|
||||
Nbuf = MnpDeviceData->RxNbufCache;
|
||||
BufLen = Nbuf->TotalSize;
|
||||
BufPtr = NetbufGetByte (Nbuf, 0, NULL);
|
||||
ASSERT (BufPtr != NULL);
|
||||
@@ -894,7 +899,6 @@ MnpReceivePacket (
|
||||
//
|
||||
Status = Snp->Receive (Snp, &HeaderSize, &BufLen, BufPtr, NULL, NULL, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
DEBUG_CODE (
|
||||
if (Status != EFI_NOT_READY) {
|
||||
DEBUG ((EFI_D_WARN, "MnpReceivePacket: Snp->Receive() = %r.\n", Status));
|
||||
@@ -908,7 +912,6 @@ MnpReceivePacket (
|
||||
// Sanity check.
|
||||
//
|
||||
if ((HeaderSize != Snp->Mode->MediaHeaderSize) || (BufLen < HeaderSize)) {
|
||||
|
||||
DEBUG (
|
||||
(EFI_D_WARN,
|
||||
"MnpReceivePacket: Size error, HL:TL = %d:%d.\n",
|
||||
@@ -927,6 +930,25 @@ MnpReceivePacket (
|
||||
ASSERT (Nbuf->TotalSize == BufLen);
|
||||
}
|
||||
|
||||
VlanId = 0;
|
||||
IsVlanPacket = MnpRemoveVlanTag (MnpDeviceData, Nbuf, &VlanId);
|
||||
|
||||
MnpServiceData = MnpFindServiceData (MnpDeviceData, VlanId);
|
||||
if (MnpServiceData == NULL) {
|
||||
//
|
||||
// VLAN is not set for this tagged frame, ignore this packet
|
||||
//
|
||||
if (Trimmed > 0) {
|
||||
NetbufAllocSpace (Nbuf, Trimmed, NET_BUF_TAIL);
|
||||
}
|
||||
|
||||
if (IsVlanPacket) {
|
||||
NetbufAllocSpace (Nbuf, NET_VLAN_TAG_LEN, NET_BUF_HEAD);
|
||||
}
|
||||
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Enqueue the packet to the matched instances.
|
||||
//
|
||||
@@ -937,16 +959,16 @@ MnpReceivePacket (
|
||||
// RefCnt > 2 indicates there is at least one receiver of this packet.
|
||||
// Free the current RxNbufCache and allocate a new one.
|
||||
//
|
||||
MnpFreeNbuf (MnpServiceData, Nbuf);
|
||||
MnpFreeNbuf (MnpDeviceData, Nbuf);
|
||||
|
||||
Nbuf = MnpAllocNbuf (MnpServiceData);
|
||||
MnpServiceData->RxNbufCache = Nbuf;
|
||||
Nbuf = MnpAllocNbuf (MnpDeviceData);
|
||||
MnpDeviceData->RxNbufCache = Nbuf;
|
||||
if (Nbuf == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "MnpReceivePacket: Alloc packet for receiving cache failed.\n"));
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
NetbufAllocSpace (Nbuf, MnpServiceData->BufferLength, NET_BUF_TAIL);
|
||||
NetbufAllocSpace (Nbuf, MnpDeviceData->BufferLength, NET_BUF_TAIL);
|
||||
} else {
|
||||
//
|
||||
// No receiver for this packet.
|
||||
@@ -954,6 +976,9 @@ MnpReceivePacket (
|
||||
if (Trimmed > 0) {
|
||||
NetbufAllocSpace (Nbuf, Trimmed, NET_BUF_TAIL);
|
||||
}
|
||||
if (IsVlanPacket) {
|
||||
NetbufAllocSpace (Nbuf, NET_VLAN_TAG_LEN, NET_BUF_HEAD);
|
||||
}
|
||||
|
||||
goto EXIT;
|
||||
}
|
||||
@@ -964,7 +989,7 @@ MnpReceivePacket (
|
||||
|
||||
EXIT:
|
||||
|
||||
ASSERT (Nbuf->TotalSize == MnpServiceData->BufferLength);
|
||||
ASSERT (Nbuf->TotalSize == MnpDeviceData->BufferLength);
|
||||
|
||||
return Status;
|
||||
}
|
||||
@@ -976,66 +1001,70 @@ EXIT:
|
||||
@param[in] Event The event this notify function registered to.
|
||||
@param[in] Context Pointer to the context data registered to the
|
||||
event.
|
||||
|
||||
|
||||
**/
|
||||
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;
|
||||
|
||||
MnpServiceData = (MNP_SERVICE_DATA *) Context;
|
||||
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
|
||||
MnpDeviceData = (MNP_DEVICE_DATA *) Context;
|
||||
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
|
||||
|
||||
NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {
|
||||
NET_LIST_FOR_EACH (ServiceEntry, &MnpDeviceData->ServiceList) {
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (ServiceEntry);
|
||||
|
||||
Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);
|
||||
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
|
||||
NET_LIST_FOR_EACH (Entry, &MnpServiceData->ChildrenList) {
|
||||
|
||||
if (!Instance->Configured || (Instance->ConfigData.ReceivedQueueTimeoutValue == 0)) {
|
||||
//
|
||||
// This instance is not configured or there is no receive time out,
|
||||
// just skip to the next instance.
|
||||
//
|
||||
continue;
|
||||
}
|
||||
Instance = NET_LIST_USER_STRUCT (Entry, MNP_INSTANCE_DATA, InstEntry);
|
||||
NET_CHECK_SIGNATURE (Instance, MNP_INSTANCE_DATA_SIGNATURE);
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
|
||||
NET_LIST_FOR_EACH_SAFE (RxEntry, NextEntry, &Instance->RcvdPacketQueue) {
|
||||
|
||||
RxDataWrap = NET_LIST_USER_STRUCT (RxEntry, MNP_RXDATA_WRAP, WrapEntry);
|
||||
|
||||
//
|
||||
// TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.
|
||||
//
|
||||
if (RxDataWrap->TimeoutTick >= (MNP_TIMEOUT_CHECK_INTERVAL / 10)) {
|
||||
|
||||
RxDataWrap->TimeoutTick -= (MNP_TIMEOUT_CHECK_INTERVAL / 10);
|
||||
} else {
|
||||
if (!Instance->Configured || (Instance->ConfigData.ReceivedQueueTimeoutValue == 0)) {
|
||||
//
|
||||
// Drop the timeout packet.
|
||||
// This instance is not configured or there is no receive time out,
|
||||
// just skip to the next instance.
|
||||
//
|
||||
DEBUG ((EFI_D_WARN, "MnpCheckPacketTimeout: Received packet timeout.\n"));
|
||||
MnpRecycleRxData (NULL, RxDataWrap);
|
||||
Instance->RcvdPacketQueueSize--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
|
||||
NET_LIST_FOR_EACH_SAFE (RxEntry, NextEntry, &Instance->RcvdPacketQueue) {
|
||||
|
||||
RxDataWrap = NET_LIST_USER_STRUCT (RxEntry, MNP_RXDATA_WRAP, WrapEntry);
|
||||
|
||||
//
|
||||
// TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.
|
||||
//
|
||||
if (RxDataWrap->TimeoutTick >= (MNP_TIMEOUT_CHECK_INTERVAL / 10)) {
|
||||
RxDataWrap->TimeoutTick -= (MNP_TIMEOUT_CHECK_INTERVAL / 10);
|
||||
} else {
|
||||
//
|
||||
// Drop the timeout packet.
|
||||
//
|
||||
DEBUG ((EFI_D_WARN, "MnpCheckPacketTimeout: Received packet timeout.\n"));
|
||||
MnpRecycleRxData (NULL, RxDataWrap);
|
||||
Instance->RcvdPacketQueueSize--;
|
||||
}
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Poll to receive the packets from Snp. This function is either called by upperlayer
|
||||
protocols/applications or the system poll timer notify mechanism.
|
||||
@@ -1047,19 +1076,19 @@ MnpCheckPacketTimeout (
|
||||
VOID
|
||||
EFIAPI
|
||||
MnpSystemPoll (
|
||||
IN EFI_EVENT Event,
|
||||
IN OUT VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN OUT VOID *Context
|
||||
)
|
||||
{
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
|
||||
MnpServiceData = (MNP_SERVICE_DATA *) Context;
|
||||
NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE);
|
||||
MnpDeviceData = (MNP_DEVICE_DATA *) Context;
|
||||
NET_CHECK_SIGNATURE (MnpDeviceData, MNP_DEVICE_DATA_SIGNATURE);
|
||||
|
||||
//
|
||||
// Try to receive packets from Snp.
|
||||
//
|
||||
MnpReceivePacket (MnpServiceData);
|
||||
MnpReceivePacket (MnpDeviceData);
|
||||
|
||||
//
|
||||
// Dispatch the DPC queued by the NotifyFunction of rx token's events.
|
||||
|
@@ -1,10 +1,11 @@
|
||||
/** @file
|
||||
Implementation of Managed Network Protocol public services.
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation. <BR>
|
||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
@@ -16,10 +17,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
/**
|
||||
Returns the operational parameters for the current MNP child driver. May also
|
||||
support returning the underlying SNP driver mode data.
|
||||
|
||||
support returning the underlying SNP driver mode data.
|
||||
|
||||
The GetModeData() function is used to read the current mode data (operational
|
||||
parameters) from the MNP or the underlying SNP.
|
||||
parameters) from the MNP or the underlying SNP.
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[out] MnpConfigData Pointer to storage for MNP operational parameters. Type
|
||||
@@ -28,7 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
@param[out] SnpModeData Pointer to storage for SNP operational parameters. This
|
||||
feature may be unsupported. Type EFI_SIMPLE_NETWORK_MODE
|
||||
is defined in the EFI_SIMPLE_NETWORK_PROTOCOL.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
@retval EFI_UNSUPPORTED The requested feature is unsupported in this
|
||||
@@ -42,9 +43,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
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;
|
||||
@@ -53,7 +54,6 @@ MnpGetModeData (
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (This == NULL) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ MnpGetModeData (
|
||||
//
|
||||
// Copy the underlayer Snp mode data.
|
||||
//
|
||||
Snp = Instance->MnpServiceData->Snp;
|
||||
Snp = Instance->MnpServiceData->MnpDeviceData->Snp;
|
||||
CopyMem (SnpModeData, Snp->Mode, sizeof (*SnpModeData));
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ MnpGetModeData (
|
||||
|
||||
|
||||
/**
|
||||
Sets or clears the operational parameters for the MNP child driver.
|
||||
|
||||
The Configure() function is used to set, change, or reset the operational
|
||||
Sets or clears the operational parameters for the MNP child driver.
|
||||
|
||||
The Configure() function is used to set, change, or reset the operational
|
||||
parameters for the MNP child driver instance. Until the operational parameters
|
||||
have been set, no network traffic can be sent or received by this MNP child
|
||||
driver instance. Once the operational parameters have been reset, no more
|
||||
@@ -143,8 +143,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;
|
||||
@@ -152,10 +152,10 @@ MnpConfigure (
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((This == NULL) ||
|
||||
((MnpConfigData != NULL) &&
|
||||
(MnpConfigData->ProtocolTypeFilter > 0) &&
|
||||
(MnpConfigData->ProtocolTypeFilter <= 1500))) {
|
||||
|
||||
((MnpConfigData != NULL) &&
|
||||
(MnpConfigData->ProtocolTypeFilter > 0) &&
|
||||
(MnpConfigData->ProtocolTypeFilter <= 1500))
|
||||
) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -184,9 +184,9 @@ ON_EXIT:
|
||||
|
||||
|
||||
/**
|
||||
Translates an IP multicast address to a hardware (MAC) multicast address. This
|
||||
function may be unsupported in some MNP implementations.
|
||||
|
||||
Translates an IP multicast address to a hardware (MAC) multicast address. This
|
||||
function may be unsupported in some MNP implementations.
|
||||
|
||||
The McastIpToMac() function translates an IP multicast address to a hardware
|
||||
(MAC) multicast address. This function may be implemented by calling the
|
||||
underlying EFI_SIMPLE_NETWORK. MCastIpToMac() function, which may also be
|
||||
@@ -197,7 +197,7 @@ ON_EXIT:
|
||||
Set to FALSE if IpAddress is an IPv4 multicast address.
|
||||
@param[in] IpAddress Pointer to the multicast IP address (in network byte
|
||||
order) to convert.
|
||||
@param[out] MacAddress Pointer to the resulting multicast MAC address.
|
||||
@param[out] MacAddress Pointer to the resulting multicast MAC address.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval EFI_INVALID_PARAMETER One of the following conditions is TRUE:
|
||||
@@ -216,10 +216,10 @@ 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;
|
||||
@@ -229,7 +229,6 @@ MnpMcastIpToMac (
|
||||
EFI_IPv6_ADDRESS *Ip6Address;
|
||||
|
||||
if ((This == NULL) || (IpAddress == NULL) || (MacAddress == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -254,10 +253,10 @@ MnpMcastIpToMac (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Snp = Instance->MnpServiceData->Snp;
|
||||
Snp = Instance->MnpServiceData->MnpDeviceData->Snp;
|
||||
ASSERT (Snp != NULL);
|
||||
|
||||
ZeroMem (MacAddress, sizeof (EFI_MAC_ADDRESS));
|
||||
ZeroMem (MacAddress, sizeof (EFI_MAC_ADDRESS));
|
||||
|
||||
if (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) {
|
||||
if (!Ipv6Flag) {
|
||||
@@ -273,10 +272,10 @@ MnpMcastIpToMac (
|
||||
MacAddress->Addr[5] = IpAddress->v4.Addr[3];
|
||||
} else {
|
||||
//
|
||||
// Translate the IPv6 address into a multicast MAC address if the NIC is an
|
||||
// Translate the IPv6 address into a multicast MAC address if the NIC is an
|
||||
// ethernet NIC according to RFC2464.
|
||||
//
|
||||
|
||||
|
||||
MacAddress->Addr[0] = 0x33;
|
||||
MacAddress->Addr[1] = 0x33;
|
||||
MacAddress->Addr[2] = Ip6Address->Addr[12];
|
||||
@@ -305,14 +304,14 @@ ON_EXIT:
|
||||
}
|
||||
|
||||
/**
|
||||
Enables and disables receive filters for multicast address. This function may
|
||||
Enables and disables receive filters for multicast address. This function may
|
||||
be unsupported in some MNP implementations.
|
||||
|
||||
The Groups() function only adds and removes multicast MAC addresses from the
|
||||
|
||||
The Groups() function only adds and removes multicast MAC addresses from the
|
||||
filter list. The MNP driver does not transmit or process Internet Group
|
||||
Management Protocol (IGMP) packets. If JoinFlag is FALSE and MacAddress is
|
||||
NULL, then all joined groups are left.
|
||||
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] JoinFlag Set to TRUE to join this multicast group.
|
||||
Set to FALSE to leave this multicast group.
|
||||
@@ -343,9 +342,9 @@ 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;
|
||||
@@ -365,12 +364,11 @@ MnpGroups (
|
||||
}
|
||||
|
||||
Instance = MNP_INSTANCE_DATA_FROM_THIS (This);
|
||||
SnpMode = Instance->MnpServiceData->Snp->Mode;
|
||||
SnpMode = Instance->MnpServiceData->MnpDeviceData->Snp->Mode;
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@@ -452,8 +450,8 @@ ON_EXIT:
|
||||
|
||||
/**
|
||||
Places asynchronous outgoing data packets into the transmit queue.
|
||||
|
||||
The Transmit() function places a completion token into the transmit packet
|
||||
|
||||
The Transmit() function places a completion token into the transmit packet
|
||||
queue. This function is always asynchronous.
|
||||
The caller must fill in the Token.Event and Token.TxData fields in the
|
||||
completion token, and these fields cannot be NULL. When the transmit operation
|
||||
@@ -463,8 +461,8 @@ ON_EXIT:
|
||||
defragmented before it can be transmitted by the network device. Systems in
|
||||
which performance is critical should review the requirements and features of
|
||||
the underlying communications device and drivers.
|
||||
|
||||
|
||||
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] Token Pointer to a token associated with the transmit data
|
||||
descriptor. Type EFI_MANAGED_NETWORK_COMPLETION_TOKEN
|
||||
@@ -497,7 +495,7 @@ ON_EXIT:
|
||||
@retval EFI_ACCESS_DENIED The transmit completion token is already in the
|
||||
transmit queue.
|
||||
@retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a
|
||||
lack of system resources (usually memory).
|
||||
lack of system resources (usually memory).
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
The MNP child driver instance has been reset to
|
||||
startup defaults.
|
||||
@@ -508,8 +506,8 @@ 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;
|
||||
@@ -520,7 +518,6 @@ MnpTransmit (
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (Token == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -564,14 +561,14 @@ ON_EXIT:
|
||||
|
||||
/**
|
||||
Places an asynchronous receiving request into the receiving queue.
|
||||
|
||||
The Receive() function places a completion token into the receive packet
|
||||
|
||||
The Receive() function places a completion token into the receive packet
|
||||
queue. This function is always asynchronous.
|
||||
The caller must fill in the Token.Event field in the completion token, and
|
||||
this field cannot be NULL. When the receive operation completes, the MNP
|
||||
updates the Token.Status and Token.RxData fields and the Token.Event is
|
||||
signaled.
|
||||
|
||||
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] Token Pointer to a token associated with the receive
|
||||
data descriptor. Type
|
||||
@@ -600,8 +597,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;
|
||||
@@ -609,7 +606,6 @@ MnpReceive (
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if ((This == NULL) || (Token == NULL) || (Token->Event == NULL)) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -618,7 +614,6 @@ MnpReceive (
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@@ -628,7 +623,6 @@ MnpReceive (
|
||||
//
|
||||
Status = NetMapIterate (&Instance->RxTokenMap, MnpTokenExist, (VOID *) Token);
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
@@ -636,7 +630,6 @@ MnpReceive (
|
||||
// Insert the Token into the RxTokenMap.
|
||||
//
|
||||
Status = NetMapInsertTail (&Instance->RxTokenMap, (VOID *) Token, NULL);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// Try to deliver any buffered packets.
|
||||
@@ -656,8 +649,8 @@ ON_EXIT:
|
||||
}
|
||||
|
||||
/**
|
||||
Aborts an asynchronous transmit or receive request.
|
||||
|
||||
Aborts an asynchronous transmit or receive request.
|
||||
|
||||
The Cancel() function is used to abort a pending transmit or receive request.
|
||||
If the token is in the transmit or receive request queues, after calling this
|
||||
function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
|
||||
@@ -668,7 +661,7 @@ ON_EXIT:
|
||||
@param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
|
||||
@param[in] Token Pointer to a token that has been issued by
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all
|
||||
EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all
|
||||
pending tokens are aborted.
|
||||
|
||||
@retval EFI_SUCCESS The asynchronous I/O request was aborted and
|
||||
@@ -687,8 +680,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;
|
||||
@@ -696,7 +689,6 @@ MnpCancel (
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if (This == NULL) {
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -705,7 +697,6 @@ MnpCancel (
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
if (!Instance->Configured) {
|
||||
|
||||
Status = EFI_NOT_STARTED;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@@ -714,9 +705,7 @@ MnpCancel (
|
||||
// Iterate the RxTokenMap to cancel the specified Token.
|
||||
//
|
||||
Status = NetMapIterate (&Instance->RxTokenMap, MnpCancelTokens, (VOID *) Token);
|
||||
|
||||
if (Token != NULL) {
|
||||
|
||||
Status = (Status == EFI_ABORTED) ? EFI_SUCCESS : EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -732,9 +721,9 @@ ON_EXIT:
|
||||
}
|
||||
|
||||
/**
|
||||
Polls for incoming data packets and processes outgoing data packets.
|
||||
|
||||
The Poll() function can be used by network drivers and applications to
|
||||
Polls for incoming data packets and processes outgoing data packets.
|
||||
|
||||
The Poll() function can be used by network drivers and applications to
|
||||
increase the rate that data packets are moved between the communications
|
||||
device and the transmit and receive queues.
|
||||
Normally, a periodic timer event internally calls the Poll() function. But, in
|
||||
@@ -760,7 +749,7 @@ ON_EXIT:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MnpPoll (
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This
|
||||
IN EFI_MANAGED_NETWORK_PROTOCOL *This
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
@@ -783,7 +772,7 @@ MnpPoll (
|
||||
//
|
||||
// Try to receive packets.
|
||||
//
|
||||
Status = MnpReceivePacket (Instance->MnpServiceData);
|
||||
Status = MnpReceivePacket (Instance->MnpServiceData->MnpDeviceData);
|
||||
|
||||
//
|
||||
// Dispatch the DPC queued by the NotifyFunction of rx token's events.
|
||||
@@ -795,4 +784,3 @@ ON_EXIT:
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
688
MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.c
Normal file
688
MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.c
Normal file
@@ -0,0 +1,688 @@
|
||||
/** @file
|
||||
VLAN Config Protocol implementation and VLAN packet process routine.
|
||||
|
||||
Copyright (c) 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "MnpImpl.h"
|
||||
#include "MnpVlan.h"
|
||||
|
||||
VLAN_DEVICE_PATH mVlanDevicePathTemplate = {
|
||||
{
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_VLAN_DP,
|
||||
{
|
||||
(UINT8) (sizeof (VLAN_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (VLAN_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0
|
||||
};
|
||||
|
||||
EFI_VLAN_CONFIG_PROTOCOL mVlanConfigProtocolTemplate = {
|
||||
VlanConfigSet,
|
||||
VlanConfigFind,
|
||||
VlanConfigRemove
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Create a child handle for the VLAN ID.
|
||||
|
||||
@param[in] ImageHandle The driver image handle.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to.
|
||||
@param[in] VlanId The VLAN ID.
|
||||
@param[out] Devicepath Pointer to returned device path for child handle.
|
||||
|
||||
@return The handle of VLAN child or NULL if failed to create VLAN child.
|
||||
|
||||
**/
|
||||
EFI_HANDLE
|
||||
MnpCreateVlanChild (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINT16 VlanId,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_HANDLE ChildHandle;
|
||||
VLAN_DEVICE_PATH VlanNode;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL *VlanDevicePath;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Try to get parent device path
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
ImageHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Construct device path for child handle: MAC + VLAN
|
||||
//
|
||||
CopyMem (&VlanNode, &mVlanDevicePathTemplate, sizeof (VLAN_DEVICE_PATH));
|
||||
VlanNode.VlanId = VlanId;
|
||||
VlanDevicePath = AppendDevicePathNode (
|
||||
ParentDevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &VlanNode
|
||||
);
|
||||
if (VlanDevicePath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Create child VLAN handle by installing DevicePath protocol
|
||||
//
|
||||
ChildHandle = NULL;
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&ChildHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
VlanDevicePath,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (VlanDevicePath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Devicepath != NULL) {
|
||||
*Devicepath = VlanDevicePath;
|
||||
}
|
||||
|
||||
return ChildHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
Remove VLAN tag from a packet.
|
||||
|
||||
@param[in, out] MnpDeviceData Pointer to the mnp device context data.
|
||||
@param[in, out] Nbuf Pointer to the NET_BUF to remove VLAN tag.
|
||||
@param[out] VlanId Pointer to the returned VLAN ID.
|
||||
|
||||
@retval TRUE VLAN tag is removed from this packet.
|
||||
@retval FALSE There is no VLAN tag in this packet.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
MnpRemoveVlanTag (
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN OUT NET_BUF *Nbuf,
|
||||
OUT UINT16 *VlanId
|
||||
)
|
||||
{
|
||||
UINT8 *Packet;
|
||||
UINTN ProtocolOffset;
|
||||
UINT16 ProtocolType;
|
||||
VLAN_TCI VlanTag;
|
||||
|
||||
ProtocolOffset = MnpDeviceData->Snp->Mode->HwAddressSize * 2;
|
||||
|
||||
//
|
||||
// Get the packet buffer.
|
||||
//
|
||||
Packet = NetbufGetByte (Nbuf, 0, NULL);
|
||||
ASSERT (Packet != NULL);
|
||||
|
||||
//
|
||||
// Check whether this is VLAN tagged frame by Ether Type
|
||||
//
|
||||
*VlanId = 0;
|
||||
ProtocolType = NTOHS (*(UINT16 *) (Packet + ProtocolOffset));
|
||||
if (ProtocolType != ETHER_TYPE_VLAN) {
|
||||
//
|
||||
// Not a VLAN tagged frame
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VlanTag.Uint16 = NTOHS (*(UINT16 *) (Packet + ProtocolOffset + sizeof (ProtocolType)));
|
||||
*VlanId = VlanTag.Bits.Vid;
|
||||
|
||||
//
|
||||
// Move hardware address (DA + SA) 4 bytes right to override VLAN tag
|
||||
//
|
||||
CopyMem (Packet + NET_VLAN_TAG_LEN, Packet, ProtocolOffset);
|
||||
|
||||
//
|
||||
// Remove VLAN tag from the Nbuf
|
||||
//
|
||||
NetbufTrim (Nbuf, NET_VLAN_TAG_LEN, NET_BUF_HEAD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build the packet to transmit from the TxData passed in.
|
||||
|
||||
@param MnpServiceData Pointer to the mnp service context data.
|
||||
@param TxData Pointer to the transmit data containing the
|
||||
information to build the packet.
|
||||
@param ProtocolType Pointer to the Ethernet protocol type.
|
||||
@param Packet Pointer to record the address of the packet.
|
||||
@param Length Pointer to a UINT32 variable used to record the
|
||||
packet's length.
|
||||
|
||||
**/
|
||||
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
|
||||
)
|
||||
{
|
||||
VLAN_TCI *VlanTci;
|
||||
UINT16 *Tpid;
|
||||
UINT16 *EtherType;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
EFI_SIMPLE_NETWORK_MODE *SnpMode;
|
||||
|
||||
if (MnpServiceData->VlanId == 0) {
|
||||
*ProtocolType = TxData->ProtocolType;
|
||||
return ;
|
||||
}
|
||||
|
||||
MnpDeviceData = MnpServiceData->MnpDeviceData;
|
||||
SnpMode = MnpDeviceData->Snp->Mode;
|
||||
|
||||
*ProtocolType = ETHER_TYPE_VLAN;
|
||||
*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);
|
||||
if (TxData->HeaderLength != 0) {
|
||||
//
|
||||
// Media header is in packet, move DA+SA 4 bytes left
|
||||
//
|
||||
CopyMem (
|
||||
*Packet,
|
||||
*Packet + NET_VLAN_TAG_LEN,
|
||||
SnpMode->MediaHeaderSize - sizeof (*ProtocolType)
|
||||
);
|
||||
*Tpid = HTONS (ETHER_TYPE_VLAN);
|
||||
} else {
|
||||
//
|
||||
// Media header not in packet, VLAN TCI and original protocol type becomes payload
|
||||
//
|
||||
EtherType = (UINT16 *) (UINTN) (VlanTci + 1);
|
||||
*EtherType = HTONS (TxData->ProtocolType);
|
||||
}
|
||||
|
||||
VlanTci->Bits.Vid = MnpServiceData->VlanId;
|
||||
VlanTci->Bits.Cfi = VLAN_TCI_CFI_CANONICAL_MAC;
|
||||
VlanTci->Bits.Priority = MnpServiceData->Priority;
|
||||
VlanTci->Uint16 = HTONS (VlanTci->Uint16);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get VLAN configuration variable.
|
||||
|
||||
@param[in] MnpDeviceData Pointer to the MNP device context data.
|
||||
@param[out] NumberOfVlan Pointer to number of VLAN to be returned.
|
||||
@param[out] VlanVariable Pointer to the buffer to return requested
|
||||
array of VLAN_TCI.
|
||||
|
||||
@retval EFI_SUCCESS The array of VLAN_TCI was returned in VlanVariable
|
||||
and number of VLAN was returned in NumberOfVlan.
|
||||
@retval EFI_NOT_FOUND VLAN configuration variable not found.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the configuration.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpGetVlanVariable (
|
||||
IN MNP_DEVICE_DATA *MnpDeviceData,
|
||||
OUT UINTN *NumberOfVlan,
|
||||
OUT VLAN_TCI **VlanVariable
|
||||
)
|
||||
{
|
||||
UINTN BufferSize;
|
||||
EFI_STATUS Status;
|
||||
VLAN_TCI *Buffer;
|
||||
|
||||
//
|
||||
// Get VLAN configuration from EFI Variable
|
||||
//
|
||||
Buffer = NULL;
|
||||
BufferSize = 0;
|
||||
Status = gRT->GetVariable (
|
||||
MnpDeviceData->MacString,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
NULL
|
||||
);
|
||||
if (Status != EFI_BUFFER_TOO_SMALL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate buffer to read the variable
|
||||
//
|
||||
Buffer = AllocateZeroPool (BufferSize);
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = gRT->GetVariable (
|
||||
MnpDeviceData->MacString,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
NULL,
|
||||
&BufferSize,
|
||||
Buffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Buffer);
|
||||
return Status;
|
||||
}
|
||||
|
||||
*NumberOfVlan = BufferSize / sizeof (VLAN_TCI);
|
||||
*VlanVariable = Buffer;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set VLAN configuration variable.
|
||||
|
||||
@param[in] MnpDeviceData Pointer to the MNP device context data.
|
||||
@param[in] NumberOfVlan Number of VLAN in array VlanVariable.
|
||||
@param[in] VlanVariable Pointer to array of VLAN_TCI.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN variable is successfully set.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enough resource to set the configuration.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpSetVlanVariable (
|
||||
IN MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN UINTN NumberOfVlan,
|
||||
IN VLAN_TCI *VlanVariable
|
||||
)
|
||||
{
|
||||
return gRT->SetVariable (
|
||||
MnpDeviceData->MacString,
|
||||
&gEfiVlanConfigProtocolGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
NumberOfVlan * sizeof (VLAN_TCI),
|
||||
VlanVariable
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a VLAN device or modify the configuration parameter of an
|
||||
already-configured VLAN.
|
||||
|
||||
The Set() function is used to create a new VLAN device or change the VLAN
|
||||
configuration parameters. If the VlanId hasn't been configured in the
|
||||
physical Ethernet device, a new VLAN device will be created. If a VLAN with
|
||||
this VlanId is already configured, then related configuration will be updated
|
||||
as the input parameters.
|
||||
|
||||
If VlanId is zero, the VLAN device will send and receive untagged frames.
|
||||
Otherwise, the VLAN device will send and receive VLAN-tagged frames containing the VlanId.
|
||||
If VlanId is out of scope of (0-4094), EFI_INVALID_PARAMETER is returned.
|
||||
If Priority is out of the scope of (0-7), then EFI_INVALID_PARAMETER is returned.
|
||||
If there is not enough system memory to perform the registration, then
|
||||
EFI_OUT_OF_RESOURCES is returned.
|
||||
|
||||
@param[in] This Points to the EFI_VLAN_CONFIG_PROTOCOL.
|
||||
@param[in] VlanId A unique identifier (1-4094) of the VLAN which is being created
|
||||
or modified, or zero (0).
|
||||
@param[in] Priority 3 bit priority in VLAN header. Priority 0 is default value. If
|
||||
VlanId is zero (0), Priority is ignored.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN is successfully configured.
|
||||
@retval EFI_INVALID_PARAMETER One or more of following conditions is TRUE:
|
||||
- This is NULL.
|
||||
- VlanId is an invalid VLAN Identifier.
|
||||
- Priority is invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to perform the registration.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanConfigSet (
|
||||
IN EFI_VLAN_CONFIG_PROTOCOL *This,
|
||||
IN UINT16 VlanId,
|
||||
IN UINT8 Priority
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
VLAN_TCI *OldVariable;
|
||||
VLAN_TCI *NewVariable;
|
||||
UINTN NumberOfVlan;
|
||||
UINTN Index;
|
||||
BOOLEAN IsAdd;
|
||||
LIST_ENTRY *Entry;
|
||||
|
||||
if ((This == NULL) || (VlanId > 4094) || (Priority > 7)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
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);
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
|
||||
|
||||
if (VlanId != 0) {
|
||||
//
|
||||
// VlanId is not 0, need destroy the default MNP service data
|
||||
//
|
||||
Status = MnpDestroyServiceChild (MnpServiceData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = MnpDestroyServiceData (MnpServiceData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Create a new MNP service data for this VLAN
|
||||
//
|
||||
MnpServiceData = MnpCreateServiceData (MnpDeviceData, VlanId, Priority);
|
||||
if (MnpServiceData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Try to find VlanId in existing VLAN list
|
||||
//
|
||||
MnpServiceData = MnpFindServiceData (MnpDeviceData, VlanId);
|
||||
if (MnpServiceData == NULL) {
|
||||
//
|
||||
// VlanId not found, create a new MNP service data
|
||||
//
|
||||
IsAdd = TRUE;
|
||||
MnpServiceData = MnpCreateServiceData (MnpDeviceData, VlanId, Priority);
|
||||
if (MnpServiceData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MnpServiceData->VlanId = VlanId;
|
||||
MnpServiceData->Priority = Priority;
|
||||
if (IsAdd) {
|
||||
MnpDeviceData->NumberOfVlan++;
|
||||
}
|
||||
|
||||
//
|
||||
// Update VLAN configuration variable
|
||||
//
|
||||
OldVariable = NULL;
|
||||
NewVariable = NULL;
|
||||
NumberOfVlan = 0;
|
||||
MnpGetVlanVariable (MnpDeviceData, &NumberOfVlan, &OldVariable);
|
||||
|
||||
if (IsAdd) {
|
||||
//
|
||||
// VLAN not exist - add
|
||||
//
|
||||
NewVariable = AllocateZeroPool ((NumberOfVlan + 1) * sizeof (VLAN_TCI));
|
||||
if (NewVariable == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if (OldVariable != NULL) {
|
||||
CopyMem (NewVariable, OldVariable, NumberOfVlan * sizeof (VLAN_TCI));
|
||||
}
|
||||
|
||||
Index = NumberOfVlan++;
|
||||
} else {
|
||||
//
|
||||
// VLAN already exist - update
|
||||
//
|
||||
for (Index = 0; Index < NumberOfVlan; Index++) {
|
||||
if (OldVariable[Index].Bits.Vid == VlanId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT (Index < NumberOfVlan);
|
||||
|
||||
NewVariable = OldVariable;
|
||||
OldVariable = NULL;
|
||||
}
|
||||
|
||||
NewVariable[Index].Bits.Vid = VlanId;
|
||||
NewVariable[Index].Bits.Priority = Priority;
|
||||
|
||||
Status = MnpSetVlanVariable (MnpDeviceData, NumberOfVlan, NewVariable);
|
||||
FreePool (NewVariable);
|
||||
|
||||
Exit:
|
||||
if (OldVariable != NULL) {
|
||||
FreePool (OldVariable);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find configuration information for specified VLAN or all configured VLANs.
|
||||
|
||||
The Find() function is used to find the configuration information for matching
|
||||
VLAN and allocate a buffer into which those entries are copied.
|
||||
|
||||
@param[in] This Points to the EFI_VLAN_CONFIG_PROTOCOL.
|
||||
@param[in] VlanId Pointer to VLAN identifier. Set to NULL to find all
|
||||
configured VLANs.
|
||||
@param[out] NumberOfVlan The number of VLANs which is found by the specified criteria.
|
||||
@param[out] Entries The buffer which receive the VLAN configuration.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN is successfully found.
|
||||
@retval EFI_INVALID_PARAMETER One or more of following conditions is TRUE:
|
||||
- This is NULL.
|
||||
- Specified VlanId is invalid.
|
||||
@retval EFI_NOT_FOUND No matching VLAN is found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanConfigFind (
|
||||
IN EFI_VLAN_CONFIG_PROTOCOL *This,
|
||||
IN UINT16 *VlanId OPTIONAL,
|
||||
OUT UINT16 *NumberOfVlan,
|
||||
OUT EFI_VLAN_FIND_DATA **Entries
|
||||
)
|
||||
{
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
LIST_ENTRY *Entry;
|
||||
EFI_VLAN_FIND_DATA *VlanData;
|
||||
|
||||
if ((This == NULL) || (VlanId != NULL && *VlanId > 4094) || (NumberOfVlan == NULL) || (Entries == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*NumberOfVlan = 0;
|
||||
*Entries = NULL;
|
||||
|
||||
MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This);
|
||||
if (MnpDeviceData->NumberOfVlan == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (VlanId == NULL) {
|
||||
//
|
||||
// Return all current VLAN configuration
|
||||
//
|
||||
*NumberOfVlan = (UINT16) MnpDeviceData->NumberOfVlan;
|
||||
VlanData = AllocateZeroPool (*NumberOfVlan * sizeof (EFI_VLAN_FIND_DATA));
|
||||
if (VlanData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
*Entries = VlanData;
|
||||
NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
|
||||
|
||||
VlanData->VlanId = MnpServiceData->VlanId;
|
||||
VlanData->Priority = MnpServiceData->Priority;
|
||||
VlanData++;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// VlanId is specified, try to find it in current VLAN list
|
||||
//
|
||||
MnpServiceData = MnpFindServiceData (MnpDeviceData, *VlanId);
|
||||
if (MnpServiceData == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
VlanData = AllocateZeroPool (sizeof (EFI_VLAN_FIND_DATA));
|
||||
if (VlanData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
VlanData->VlanId = MnpServiceData->VlanId;
|
||||
VlanData->Priority = MnpServiceData->Priority;
|
||||
|
||||
*NumberOfVlan = 1;
|
||||
*Entries = VlanData;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove the configured VLAN device.
|
||||
|
||||
The Remove() function is used to remove the specified VLAN device.
|
||||
If the VlanId is out of the scope of (0-4094), EFI_INVALID_PARAMETER is returned.
|
||||
If specified VLAN hasn't been previously configured, EFI_NOT_FOUND is returned.
|
||||
|
||||
@param[in] This Points to the EFI_VLAN_CONFIG_PROTOCOL.
|
||||
@param[in] VlanId Identifier (0-4094) of the VLAN to be removed.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN is successfully removed.
|
||||
@retval EFI_INVALID_PARAMETER One or more of following conditions is TRUE:
|
||||
- This is NULL.
|
||||
- VlanId is an invalid parameter.
|
||||
@retval EFI_NOT_FOUND The to-be-removed VLAN does not exist.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanConfigRemove (
|
||||
IN EFI_VLAN_CONFIG_PROTOCOL *This,
|
||||
IN UINT16 VlanId
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MNP_DEVICE_DATA *MnpDeviceData;
|
||||
MNP_SERVICE_DATA *MnpServiceData;
|
||||
LIST_ENTRY *Entry;
|
||||
VLAN_TCI *VlanVariable;
|
||||
VLAN_TCI *VlanData;
|
||||
|
||||
if ((This == NULL) || (VlanId > 4094)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This);
|
||||
if (MnpDeviceData->NumberOfVlan == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Try to find the VlanId
|
||||
//
|
||||
MnpServiceData = MnpFindServiceData (MnpDeviceData, VlanId);
|
||||
if (MnpServiceData == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
MnpDeviceData->NumberOfVlan--;
|
||||
|
||||
if ((VlanId != 0) || (MnpDeviceData->NumberOfVlan != 0)) {
|
||||
//
|
||||
// If VlanId is not 0 or VlanId is 0 and it is not the last VLAN to remove,
|
||||
// destroy its MNP service data
|
||||
//
|
||||
Status = MnpDestroyServiceChild (MnpServiceData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = MnpDestroyServiceData (MnpServiceData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
if ((VlanId != 0) && (MnpDeviceData->NumberOfVlan == 0)) {
|
||||
//
|
||||
// This is the last VLAN to be removed, restore the default MNP service data
|
||||
//
|
||||
MnpServiceData = MnpCreateServiceData (MnpDeviceData, 0, 0);
|
||||
if (MnpServiceData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update VLAN configuration variable
|
||||
//
|
||||
VlanVariable = NULL;
|
||||
if (MnpDeviceData->NumberOfVlan != 0) {
|
||||
VlanVariable = AllocatePool (MnpDeviceData->NumberOfVlan * sizeof (VLAN_TCI));
|
||||
if (VlanVariable == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
VlanData = VlanVariable;
|
||||
NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {
|
||||
MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
|
||||
|
||||
VlanData->Bits.Vid = MnpServiceData->VlanId;
|
||||
VlanData->Bits.Priority = MnpServiceData->Priority;
|
||||
VlanData++;
|
||||
}
|
||||
}
|
||||
|
||||
Status = MnpSetVlanVariable (MnpDeviceData, MnpDeviceData->NumberOfVlan, VlanVariable);
|
||||
|
||||
if (VlanVariable != NULL) {
|
||||
FreePool (VlanVariable);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
212
MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.h
Normal file
212
MdeModulePkg/Universal/Network/MnpDxe/MnpVlan.h
Normal file
@@ -0,0 +1,212 @@
|
||||
/** @file
|
||||
Header file to be included by MnpVlan.c.
|
||||
|
||||
Copyright (c) 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions
|
||||
of the BSD License which accompanies this distribution. The full
|
||||
text of the license may be found at<BR>
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __MNP_VLAN_H__
|
||||
#define __MNP_VLAN_H__
|
||||
|
||||
#include "MnpDriver.h"
|
||||
|
||||
extern EFI_VLAN_CONFIG_PROTOCOL mVlanConfigProtocolTemplate;
|
||||
|
||||
|
||||
/**
|
||||
Create a child handle for the VLAN ID.
|
||||
|
||||
@param[in] ImageHandle The driver image handle.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to.
|
||||
@param[in] VlanId The VLAN ID.
|
||||
@param[out] Devicepath Pointer to returned device path for child handle.
|
||||
|
||||
@return The handle of VLAN child or NULL if failed to create VLAN child.
|
||||
|
||||
**/
|
||||
EFI_HANDLE
|
||||
MnpCreateVlanChild (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINT16 VlanId,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Remove VLAN tag of a packet.
|
||||
|
||||
@param[in, out] MnpDeviceData Pointer to the mnp device context data.
|
||||
@param[in, out] Nbuf Pointer to the NET_BUF to remove VLAN tag.
|
||||
@param[out] VlanId Pointer to the returned VLAN ID.
|
||||
|
||||
@retval TRUE VLAN tag is removed from this packet.
|
||||
@retval FALSE There is no VLAN tag in this packet.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
MnpRemoveVlanTag (
|
||||
IN OUT MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN OUT NET_BUF *Nbuf,
|
||||
OUT UINT16 *VlanId
|
||||
);
|
||||
|
||||
/**
|
||||
Build the packet to transmit from the TxData passed in.
|
||||
|
||||
@param MnpServiceData Pointer to the mnp service context data.
|
||||
@param TxData Pointer to the transmit data containing the
|
||||
information to build the packet.
|
||||
@param ProtocolType Pointer to the Ethernet protocol type.
|
||||
@param Packet Pointer to record the address of the packet.
|
||||
@param Length Pointer to a UINT32 variable used to record the
|
||||
packet's length.
|
||||
|
||||
**/
|
||||
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
|
||||
);
|
||||
|
||||
/**
|
||||
Get VLAN configuration variable.
|
||||
|
||||
@param[in] MnpDeviceData Pointer to the MNP device context data.
|
||||
@param[out] NumberOfVlan Pointer to number of VLAN to be returned.
|
||||
@param[out] VlanVariable Pointer to the buffer to return requested
|
||||
array of VLAN_TCI.
|
||||
|
||||
@retval EFI_SUCCESS The array of VLAN_TCI was returned in VlanVariable
|
||||
and number of VLAN was returned in NumberOfVlan.
|
||||
@retval EFI_NOT_FOUND VLAN configuration variable not found.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the configuration.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpGetVlanVariable (
|
||||
IN MNP_DEVICE_DATA *MnpDeviceData,
|
||||
OUT UINTN *NumberOfVlan,
|
||||
OUT VLAN_TCI **VlanVariable
|
||||
);
|
||||
|
||||
/**
|
||||
Set VLAN configuration variable.
|
||||
|
||||
@param[in] MnpDeviceData Pointer to the MNP device context data.
|
||||
@param[in] NumberOfVlan Number of VLAN in array VlanVariable.
|
||||
@param[in] VlanVariable Pointer to array of VLAN_TCI.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN variable is successfully set.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enough resource to set the configuration.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
MnpSetVlanVariable (
|
||||
IN MNP_DEVICE_DATA *MnpDeviceData,
|
||||
IN UINTN NumberOfVlan,
|
||||
IN VLAN_TCI *VlanVariable
|
||||
);
|
||||
|
||||
/**
|
||||
Create a VLAN device or modify the configuration parameter of an
|
||||
already-configured VLAN.
|
||||
|
||||
The Set() function is used to create a new VLAN device or change the VLAN
|
||||
configuration parameters. If the VlanId hasn't been configured in the
|
||||
physical Ethernet device, a new VLAN device will be created. If a VLAN with
|
||||
this VlanId is already configured, then related configuration will be updated
|
||||
as the input parameters.
|
||||
|
||||
If VlanId is zero, the VLAN device will send and receive untagged frames.
|
||||
Otherwise, the VLAN device will send and receive VLAN-tagged frames containing the VlanId.
|
||||
If VlanId is out of scope of (0-4094), EFI_INVALID_PARAMETER is returned.
|
||||
If Priority is out of the scope of (0-7), then EFI_INVALID_PARAMETER is returned.
|
||||
If there is not enough system memory to perform the registration, then
|
||||
EFI_OUT_OF_RESOURCES is returned.
|
||||
|
||||
@param[in] This Points to the EFI_VLAN_CONFIG_PROTOCOL.
|
||||
@param[in] VlanId A unique identifier (1-4094) of the VLAN which is being created
|
||||
or modified, or zero (0).
|
||||
@param[in] Priority 3 bit priority in VLAN header. Priority 0 is default value. If
|
||||
VlanId is zero (0), Priority is ignored.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN is successfully configured.
|
||||
@retval EFI_INVALID_PARAMETER One or more of following conditions is TRUE:
|
||||
- This is NULL.
|
||||
- VlanId is an invalid VLAN Identifier.
|
||||
- Priority is invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES There is not enough system memory to perform the registration.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanConfigSet (
|
||||
IN EFI_VLAN_CONFIG_PROTOCOL *This,
|
||||
IN UINT16 VlanId,
|
||||
IN UINT8 Priority
|
||||
);
|
||||
|
||||
/**
|
||||
Find configuration information for specified VLAN or all configured VLANs.
|
||||
|
||||
The Find() function is used to find the configuration information for matching
|
||||
VLAN and allocate a buffer into which those entries are copied.
|
||||
|
||||
@param[in] This Points to the EFI_VLAN_CONFIG_PROTOCOL.
|
||||
@param[in] VlanId Pointer to VLAN identifier. Set to NULL to find all
|
||||
configured VLANs.
|
||||
@param[out] NumberOfVlan The number of VLANs which is found by the specified criteria.
|
||||
@param[out] Entries The buffer which receive the VLAN configuration.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN is successfully found.
|
||||
@retval EFI_INVALID_PARAMETER One or more of following conditions is TRUE:
|
||||
- This is NULL.
|
||||
- Specified VlanId is invalid.
|
||||
@retval EFI_NOT_FOUND No matching VLAN is found.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanConfigFind (
|
||||
IN EFI_VLAN_CONFIG_PROTOCOL *This,
|
||||
IN UINT16 *VlanId OPTIONAL,
|
||||
OUT UINT16 *NumberOfVlan,
|
||||
OUT EFI_VLAN_FIND_DATA **Entries
|
||||
);
|
||||
|
||||
/**
|
||||
Remove the configured VLAN device.
|
||||
|
||||
The Remove() function is used to remove the specified VLAN device.
|
||||
If the VlanId is out of the scope of (0-4094), EFI_INVALID_PARAMETER is returned.
|
||||
If specified VLAN hasn't been previously configured, EFI_NOT_FOUND is returned.
|
||||
|
||||
@param[in] This Points to the EFI_VLAN_CONFIG_PROTOCOL.
|
||||
@param[in] VlanId Identifier (0-4094) of the VLAN to be removed.
|
||||
|
||||
@retval EFI_SUCCESS The VLAN is successfully removed.
|
||||
@retval EFI_INVALID_PARAMETER One or more of following conditions is TRUE:
|
||||
- This is NULL.
|
||||
- VlanId is an invalid parameter.
|
||||
@retval EFI_NOT_FOUND The to-be-removed VLAN does not exist.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
VlanConfigRemove (
|
||||
IN EFI_VLAN_CONFIG_PROTOCOL *This,
|
||||
IN UINT16 VlanId
|
||||
);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user