2 Declaration of structures 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
;
119 #define MNP_SERVICE_DATA_FROM_THIS(a) \
124 MNP_SERVICE_DATA_SIGNATURE \
127 #define MNP_SERVICE_DATA_FROM_LINK(a) \
132 MNP_SERVICE_DATA_SIGNATURE \
136 Test to see if this driver supports ControllerHandle. This service
137 is called by the EFI boot service ConnectController(). In
138 order to make drivers as small as possible, there are a few calling
139 restrictions for this service. ConnectController() must
140 follow these calling restrictions. If any other agent wishes to call
141 Supported() it must also follow these calling restrictions.
143 @param[in] This Protocol instance pointer.
144 @param[in] ControllerHandle Handle of device to test.
145 @param[in] RemainingDevicePath Optional parameter use to pick a specific
146 child device to start.
148 @retval EFI_SUCCESS This driver supports this device.
149 @retval EFI_ALREADY_STARTED This driver is already running on this device.
150 @retval Others This driver does not support this device.
155 MnpDriverBindingSupported (
156 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
157 IN EFI_HANDLE ControllerHandle
,
158 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
162 Start this driver on ControllerHandle. This service is called by the
163 EFI boot service ConnectController(). In order to make drivers as small
164 as possible, there are a few calling restrictions for this service.
165 ConnectController() must follow these calling restrictions. If any other
166 agent wishes to call Start() it must also follow these calling restrictions.
168 @param[in] This Protocol instance pointer.
169 @param[in] ControllerHandle Handle of device to bind driver to.
170 @param[in] RemainingDevicePath Optional parameter use to pick a specific
171 child device to start.
173 @retval EFI_SUCCESS This driver is added to ControllerHandle.
174 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
175 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
176 @retval Others This driver does not support this device.
181 MnpDriverBindingStart (
182 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
183 IN EFI_HANDLE ControllerHandle
,
184 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
188 Stop this driver on ControllerHandle. This service is called by the
189 EFI boot service DisconnectController(). In order to make drivers as
190 small as possible, there are a few calling restrictions for this service.
191 DisconnectController() must follow these calling restrictions. If any other
192 agent wishes to call Stop() it must also follow these calling restrictions.
194 @param[in] This Protocol instance pointer.
195 @param[in] ControllerHandle Handle of device to stop driver on.
196 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
197 number of children is zero stop the entire
199 @param[in] ChildHandleBuffer List of Child Handles to Stop.
201 @retval EFI_SUCCESS This driver is removed ControllerHandle.
202 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
207 MnpDriverBindingStop (
208 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
209 IN EFI_HANDLE ControllerHandle
,
210 IN UINTN NumberOfChildren
,
211 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
215 Creates a child handle with a set of I/O services.
217 @param[in] This Protocol instance pointer.
218 @param[in, out] ChildHandle Pointer to the handle of the child to create. If
219 it is NULL, then a new handle is created. If
220 it is not NULL, then the I/O services are added
221 to the existing child handle.
223 @retval EFI_SUCCESS The protocol was added to ChildHandle.
224 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
225 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
227 @retval Others The child handle was not created.
232 MnpServiceBindingCreateChild (
233 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
234 IN OUT EFI_HANDLE
*ChildHandle
238 Destroys a child handle with a set of I/O services.
240 The DestroyChild() function does the opposite of CreateChild(). It removes a
241 protocol that was installed by CreateChild() from ChildHandle. If the removed
242 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
244 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
246 @param[in] ChildHandle Handle of the child to destroy.
248 @retval EFI_SUCCESS The protocol was removed from ChildHandle.
249 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
251 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
252 @retval EFI_ACCESS_DENIED The protocol could not be removed from the
253 ChildHandle because its services are being
255 @retval Others The child handle was not destroyed.
260 MnpServiceBindingDestroyChild (
261 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
262 IN EFI_HANDLE ChildHandle