2 Declaration of strctures and functions for MnpDxe driver.
4 Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #define _MNP_DRIVER_H_
14 #include <Protocol/ManagedNetwork.h>
15 #include <Protocol/SimpleNetwork.h>
16 #include <Protocol/ServiceBinding.h>
17 #include <Protocol/VlanConfig.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/MemoryAllocationLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/UefiLib.h>
25 #include <Library/NetLib.h>
26 #include <Library/DpcLib.h>
27 #include <Library/UefiRuntimeServicesTableLib.h>
28 #include <Library/DevicePathLib.h>
29 #include <Library/PrintLib.h>
31 #include "ComponentName.h"
33 #define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')
38 extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding
;
43 EFI_HANDLE ControllerHandle
;
44 EFI_HANDLE ImageHandle
;
46 EFI_VLAN_CONFIG_PROTOCOL VlanConfig
;
49 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
52 // List of MNP_SERVICE_DATA
54 LIST_ENTRY ServiceList
;
56 // Number of configured MNP Service Binding child
58 UINTN ConfiguredChildrenNumber
;
60 LIST_ENTRY GroupAddressList
;
61 UINT32 GroupAddressCount
;
63 LIST_ENTRY FreeTxBufList
;
64 LIST_ENTRY AllTxBufList
;
67 NET_BUF_QUEUE FreeNbufQue
;
71 BOOLEAN EnableSystemPoll
;
73 EFI_EVENT TimeoutCheckTimer
;
74 EFI_EVENT MediaDetectTimer
;
77 UINT32 BroadcastCount
;
78 UINT32 MulticastCount
;
79 UINT32 PromiscuousCount
;
82 // The size of the data buffer in the MNP_PACKET_BUFFER used to
90 #define MNP_DEVICE_DATA_FROM_THIS(a) \
95 MNP_DEVICE_DATA_SIGNATURE \
98 #define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
105 MNP_DEVICE_DATA
*MnpDeviceData
;
106 EFI_HANDLE ServiceHandle
;
107 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
108 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
110 LIST_ENTRY ChildrenList
;
111 UINTN ChildrenNumber
;
120 #define MNP_SERVICE_DATA_FROM_THIS(a) \
125 MNP_SERVICE_DATA_SIGNATURE \
128 #define MNP_SERVICE_DATA_FROM_LINK(a) \
133 MNP_SERVICE_DATA_SIGNATURE \
138 Test to see if this driver supports ControllerHandle. This service
139 is called by the EFI boot service ConnectController(). In
140 order to make drivers as small as possible, there are a few calling
141 restrictions for this service. ConnectController() must
142 follow these calling restrictions. If any other agent wishes to call
143 Supported() it must also follow these calling restrictions.
145 @param[in] This Protocol instance pointer.
146 @param[in] ControllerHandle Handle of device to test.
147 @param[in] RemainingDevicePath Optional parameter use to pick a specific
148 child device to start.
150 @retval EFI_SUCCESS This driver supports this device.
151 @retval EFI_ALREADY_STARTED This driver is already running on this device.
152 @retval Others This driver does not support this device.
157 MnpDriverBindingSupported (
158 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
159 IN EFI_HANDLE ControllerHandle
,
160 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
164 Start this driver on ControllerHandle. This service is called by the
165 EFI boot service ConnectController(). In order to make drivers as small
166 as possible, there are a few calling restrictions for this service.
167 ConnectController() must follow these calling restrictions. If any other
168 agent wishes to call Start() it must also follow these calling restrictions.
170 @param[in] This Protocol instance pointer.
171 @param[in] ControllerHandle Handle of device to bind driver to.
172 @param[in] RemainingDevicePath Optional parameter use to pick a specific
173 child device to start.
175 @retval EFI_SUCCESS This driver is added to ControllerHandle.
176 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
177 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
178 @retval Others This driver does not support this device.
183 MnpDriverBindingStart (
184 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
185 IN EFI_HANDLE ControllerHandle
,
186 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
191 Stop this driver on ControllerHandle. This service is called by the
192 EFI boot service DisconnectController(). In order to make drivers as
193 small as possible, there are a few calling restrictions for this service.
194 DisconnectController() must follow these calling restrictions. If any other
195 agent wishes to call Stop() it must also follow these calling restrictions.
197 @param[in] This Protocol instance pointer.
198 @param[in] ControllerHandle Handle of device to stop driver on.
199 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
200 number of children is zero stop the entire
202 @param[in] ChildHandleBuffer List of Child Handles to Stop.
204 @retval EFI_SUCCESS This driver is removed ControllerHandle.
205 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
210 MnpDriverBindingStop (
211 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
212 IN EFI_HANDLE ControllerHandle
,
213 IN UINTN NumberOfChildren
,
214 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
218 Creates a child handle with a set of I/O services.
220 @param[in] This Protocol instance pointer.
221 @param[in, out] ChildHandle Pointer to the handle of the child to create. If
222 it is NULL, then a new handle is created. If
223 it is not NULL, then the I/O services are added
224 to the existing child handle.
226 @retval EFI_SUCCES The protocol was added to ChildHandle.
227 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
228 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
230 @retval Others The child handle was not created.
235 MnpServiceBindingCreateChild (
236 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
237 IN OUT EFI_HANDLE
*ChildHandle
241 Destroys a child handle with a set of I/O services.
243 The DestroyChild() function does the opposite of CreateChild(). It removes a
244 protocol that was installed by CreateChild() from ChildHandle. If the removed
245 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
247 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
249 @param[in] ChildHandle Handle of the child to destroy.
251 @retval EFI_SUCCES The protocol was removed from ChildHandle.
252 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
254 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
255 @retval EFI_ACCESS_DENIED The protocol could not be removed from the
256 ChildHandle because its services are being
258 @retval Others The child handle was not destroyed.
263 MnpServiceBindingDestroyChild (
264 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
265 IN EFI_HANDLE ChildHandle