2007-09-30 05:08:02 +02:00
|
|
|
/** @file
|
2020-02-07 02:07:56 +01:00
|
|
|
Declaration of structures and functions for MnpDxe driver.
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2016-01-08 03:38:34 +01:00
|
|
|
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:05:13 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2007-09-30 05:08:02 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef _MNP_DRIVER_H_
|
|
|
|
#define _MNP_DRIVER_H_
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2009-01-08 05:47:41 +01:00
|
|
|
#include <Uefi.h>
|
2007-07-24 10:06:37 +02:00
|
|
|
|
|
|
|
#include <Protocol/ManagedNetwork.h>
|
2007-09-30 05:08:02 +02:00
|
|
|
#include <Protocol/SimpleNetwork.h>
|
2007-07-24 10:06:37 +02:00
|
|
|
#include <Protocol/ServiceBinding.h>
|
2009-12-30 14:47:55 +01:00
|
|
|
#include <Protocol/VlanConfig.h>
|
2007-07-24 10:06:37 +02:00
|
|
|
|
2009-05-20 22:05:06 +02:00
|
|
|
#include <Library/BaseLib.h>
|
2009-05-21 01:15:47 +02:00
|
|
|
#include <Library/BaseMemoryLib.h>
|
2007-07-24 10:06:37 +02:00
|
|
|
#include <Library/DebugLib.h>
|
2009-05-21 01:15:47 +02:00
|
|
|
#include <Library/MemoryAllocationLib.h>
|
2007-07-24 10:06:37 +02:00
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
2007-09-30 05:08:02 +02:00
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/NetLib.h>
|
2009-07-12 00:51:51 +02:00
|
|
|
#include <Library/DpcLib.h>
|
2009-12-30 14:47:55 +01:00
|
|
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
|
|
#include <Library/DevicePathLib.h>
|
2012-12-13 07:47:06 +01:00
|
|
|
#include <Library/PrintLib.h>
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2009-02-03 08:56:54 +01:00
|
|
|
#include "ComponentName.h"
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2009-12-30 14:47:55 +01:00
|
|
|
#define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2012-12-13 07:47:06 +01:00
|
|
|
//
|
|
|
|
// Global Variables
|
|
|
|
//
|
2021-12-05 23:54:07 +01:00
|
|
|
extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;
|
2012-12-13 07:47:06 +01:00
|
|
|
|
2009-02-03 08:56:54 +01:00
|
|
|
typedef struct {
|
2021-12-05 23:54:07 +01:00
|
|
|
UINT32 Signature;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
EFI_HANDLE ControllerHandle;
|
|
|
|
EFI_HANDLE ImageHandle;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
EFI_VLAN_CONFIG_PROTOCOL VlanConfig;
|
|
|
|
UINTN NumberOfVlan;
|
|
|
|
CHAR16 *MacString;
|
|
|
|
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2009-12-30 14:47:55 +01:00
|
|
|
//
|
|
|
|
// List of MNP_SERVICE_DATA
|
|
|
|
//
|
2021-12-05 23:54:07 +01:00
|
|
|
LIST_ENTRY ServiceList;
|
2009-12-30 14:47:55 +01:00
|
|
|
//
|
|
|
|
// Number of configured MNP Service Binding child
|
|
|
|
//
|
2021-12-05 23:54:07 +01:00
|
|
|
UINTN ConfiguredChildrenNumber;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
LIST_ENTRY GroupAddressList;
|
|
|
|
UINT32 GroupAddressCount;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
LIST_ENTRY FreeTxBufList;
|
|
|
|
LIST_ENTRY AllTxBufList;
|
|
|
|
UINT32 TxBufCount;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
NET_BUF_QUEUE FreeNbufQue;
|
|
|
|
INTN NbufCnt;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
EFI_EVENT PollTimer;
|
|
|
|
BOOLEAN EnableSystemPoll;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
EFI_EVENT TimeoutCheckTimer;
|
|
|
|
EFI_EVENT MediaDetectTimer;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
UINT32 UnicastCount;
|
|
|
|
UINT32 BroadcastCount;
|
|
|
|
UINT32 MulticastCount;
|
|
|
|
UINT32 PromiscuousCount;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// The size of the data buffer in the MNP_PACKET_BUFFER used to
|
|
|
|
// store a packet.
|
|
|
|
//
|
2021-12-05 23:54:07 +01:00
|
|
|
UINT32 BufferLength;
|
|
|
|
UINT32 PaddingSize;
|
|
|
|
NET_BUF *RxNbufCache;
|
2009-12-30 14:47:55 +01:00
|
|
|
} 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 {
|
2021-12-05 23:54:07 +01:00
|
|
|
UINT32 Signature;
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
LIST_ENTRY Link;
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
MNP_DEVICE_DATA *MnpDeviceData;
|
|
|
|
EFI_HANDLE ServiceHandle;
|
|
|
|
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
LIST_ENTRY ChildrenList;
|
|
|
|
UINTN ChildrenNumber;
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
UINT32 Mtu;
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2021-12-05 23:54:07 +01:00
|
|
|
UINT16 VlanId;
|
|
|
|
UINT8 Priority;
|
2007-09-30 05:08:02 +02:00
|
|
|
} MNP_SERVICE_DATA;
|
|
|
|
|
|
|
|
#define MNP_SERVICE_DATA_FROM_THIS(a) \
|
|
|
|
CR ( \
|
|
|
|
(a), \
|
|
|
|
MNP_SERVICE_DATA, \
|
|
|
|
ServiceBinding, \
|
|
|
|
MNP_SERVICE_DATA_SIGNATURE \
|
|
|
|
)
|
|
|
|
|
2009-12-30 14:47:55 +01:00
|
|
|
#define MNP_SERVICE_DATA_FROM_LINK(a) \
|
|
|
|
CR ( \
|
|
|
|
(a), \
|
|
|
|
MNP_SERVICE_DATA, \
|
|
|
|
Link, \
|
|
|
|
MNP_SERVICE_DATA_SIGNATURE \
|
|
|
|
)
|
|
|
|
|
2008-11-18 05:52:51 +01:00
|
|
|
/**
|
|
|
|
Test to see if this driver supports ControllerHandle. This service
|
|
|
|
is called by the 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
|
|
|
|
Supported() it must also follow these calling restrictions.
|
|
|
|
|
2009-02-03 08:56:54 +01:00
|
|
|
@param[in] This Protocol instance pointer.
|
|
|
|
@param[in] ControllerHandle Handle of device to test.
|
2009-12-30 14:47:55 +01:00
|
|
|
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
2009-02-03 08:56:54 +01:00
|
|
|
child device to start.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
2009-02-03 08:56:54 +01:00
|
|
|
@retval EFI_SUCCESS This driver supports this device.
|
|
|
|
@retval EFI_ALREADY_STARTED This driver is already running on this device.
|
|
|
|
@retval Others This driver does not support this device.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MnpDriverBindingSupported (
|
2021-12-05 23:54:07 +01:00
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 05:52:51 +01:00
|
|
|
/**
|
|
|
|
Start this driver on ControllerHandle. This service is called by the
|
2009-12-30 14:47:55 +01:00
|
|
|
EFI boot service ConnectController(). In order to make drivers as small
|
2009-02-03 08:56:54 +01:00
|
|
|
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.
|
2009-12-30 14:47:55 +01:00
|
|
|
@param[in] RemainingDevicePath Optional parameter use to pick a specific
|
2009-02-03 08:56:54 +01:00
|
|
|
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.
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2008-11-18 05:52:51 +01:00
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MnpDriverBindingStart (
|
2021-12-05 23:54:07 +01:00
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 05:52:51 +01:00
|
|
|
/**
|
|
|
|
Stop this driver on ControllerHandle. This service is called by the
|
2009-12-30 14:47:55 +01:00
|
|
|
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
|
2009-02-03 08:56:54 +01:00
|
|
|
agent wishes to call Stop() it must also follow these calling restrictions.
|
2009-12-30 14:47:55 +01:00
|
|
|
|
2009-02-03 08:56:54 +01:00
|
|
|
@param[in] This Protocol instance pointer.
|
|
|
|
@param[in] ControllerHandle Handle of device to stop driver on.
|
2009-12-30 14:47:55 +01:00
|
|
|
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
|
|
|
|
number of children is zero stop the entire
|
|
|
|
bus driver.
|
2009-02-03 08:56:54 +01:00
|
|
|
@param[in] ChildHandleBuffer List of Child Handles to Stop.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
2009-02-03 08:56:54 +01:00
|
|
|
@retval EFI_SUCCESS This driver is removed ControllerHandle.
|
|
|
|
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MnpDriverBindingStop (
|
2021-12-05 23:54:07 +01:00
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN UINTN NumberOfChildren,
|
|
|
|
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 05:52:51 +01:00
|
|
|
/**
|
2009-02-03 08:56:54 +01:00
|
|
|
Creates a child handle with a set of I/O services.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
2009-02-03 08:56:54 +01:00
|
|
|
@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
|
2009-12-30 14:47:55 +01:00
|
|
|
it is not NULL, then the I/O services are added
|
|
|
|
to the existing child handle.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
2020-02-07 02:07:56 +01:00
|
|
|
@retval EFI_SUCCESS The protocol was added to ChildHandle.
|
2009-12-30 14:47:55 +01:00
|
|
|
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
2016-07-08 08:21:04 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES There are not enough resources available to
|
2009-02-03 08:56:54 +01:00
|
|
|
create the child.
|
|
|
|
@retval Others The child handle was not created.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MnpServiceBindingCreateChild (
|
2021-12-05 23:54:07 +01:00
|
|
|
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
|
|
|
IN OUT EFI_HANDLE *ChildHandle
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 05:52:51 +01:00
|
|
|
/**
|
2009-02-03 08:56:54 +01:00
|
|
|
Destroys a child handle with a set of I/O services.
|
2009-12-30 14:47:55 +01:00
|
|
|
|
|
|
|
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
|
2009-02-03 08:56:54 +01:00
|
|
|
instance.
|
|
|
|
@param[in] ChildHandle Handle of the child to destroy.
|
|
|
|
|
2020-02-07 02:07:56 +01:00
|
|
|
@retval EFI_SUCCESS The protocol was removed from ChildHandle.
|
2009-02-03 08:56:54 +01:00
|
|
|
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
|
|
|
|
is being removed.
|
2011-07-06 05:55:36 +02:00
|
|
|
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
2009-02-03 08:56:54 +01:00
|
|
|
@retval EFI_ACCESS_DENIED The protocol could not be removed from the
|
|
|
|
ChildHandle because its services are being
|
|
|
|
used.
|
|
|
|
@retval Others The child handle was not destroyed.
|
2008-11-18 05:52:51 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MnpServiceBindingDestroyChild (
|
2021-12-05 23:54:07 +01:00
|
|
|
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ChildHandle
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|