2 Declaration of strctures and functions for MnpDxe driver.
4 Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The full
8 text of the license may be found at<BR>
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _MNP_DRIVER_H_
17 #define _MNP_DRIVER_H_
21 #include <Protocol/ManagedNetwork.h>
22 #include <Protocol/SimpleNetwork.h>
23 #include <Protocol/ServiceBinding.h>
24 #include <Protocol/VlanConfig.h>
26 #include <Library/BaseLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/NetLib.h>
33 #include <Library/DpcLib.h>
34 #include <Library/UefiRuntimeServicesTableLib.h>
35 #include <Library/DevicePathLib.h>
36 #include <Library/PrintLib.h>
38 #include "ComponentName.h"
40 #define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')
45 extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding
;
50 EFI_HANDLE ControllerHandle
;
51 EFI_HANDLE ImageHandle
;
53 EFI_VLAN_CONFIG_PROTOCOL VlanConfig
;
56 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
59 // List of MNP_SERVICE_DATA
61 LIST_ENTRY ServiceList
;
63 // Number of configured MNP Service Binding child
65 UINTN ConfiguredChildrenNumber
;
67 LIST_ENTRY GroupAddressList
;
68 UINT32 GroupAddressCount
;
70 LIST_ENTRY FreeTxBufList
;
71 LIST_ENTRY AllTxBufList
;
74 NET_BUF_QUEUE FreeNbufQue
;
78 BOOLEAN EnableSystemPoll
;
80 EFI_EVENT TimeoutCheckTimer
;
81 EFI_EVENT MediaDetectTimer
;
84 UINT32 BroadcastCount
;
85 UINT32 MulticastCount
;
86 UINT32 PromiscuousCount
;
89 // The size of the data buffer in the MNP_PACKET_BUFFER used to
97 #define MNP_DEVICE_DATA_FROM_THIS(a) \
102 MNP_DEVICE_DATA_SIGNATURE \
105 #define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
112 MNP_DEVICE_DATA
*MnpDeviceData
;
113 EFI_HANDLE ServiceHandle
;
114 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
115 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
117 LIST_ENTRY ChildrenList
;
118 UINTN ChildrenNumber
;
127 #define MNP_SERVICE_DATA_FROM_THIS(a) \
132 MNP_SERVICE_DATA_SIGNATURE \
135 #define MNP_SERVICE_DATA_FROM_LINK(a) \
140 MNP_SERVICE_DATA_SIGNATURE \
145 Test to see if this driver supports ControllerHandle. This service
146 is called by the EFI boot service ConnectController(). In
147 order to make drivers as small as possible, there are a few calling
148 restrictions for this service. ConnectController() must
149 follow these calling restrictions. If any other agent wishes to call
150 Supported() it must also follow these calling restrictions.
152 @param[in] This Protocol instance pointer.
153 @param[in] ControllerHandle Handle of device to test.
154 @param[in] RemainingDevicePath Optional parameter use to pick a specific
155 child device to start.
157 @retval EFI_SUCCESS This driver supports this device.
158 @retval EFI_ALREADY_STARTED This driver is already running on this device.
159 @retval Others This driver does not support this device.
164 MnpDriverBindingSupported (
165 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
166 IN EFI_HANDLE ControllerHandle
,
167 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
171 Start this driver on ControllerHandle. This service is called by the
172 EFI boot service ConnectController(). In order to make drivers as small
173 as possible, there are a few calling restrictions for this service.
174 ConnectController() must follow these calling restrictions. If any other
175 agent wishes to call Start() it must also follow these calling restrictions.
177 @param[in] This Protocol instance pointer.
178 @param[in] ControllerHandle Handle of device to bind driver to.
179 @param[in] RemainingDevicePath Optional parameter use to pick a specific
180 child device to start.
182 @retval EFI_SUCCESS This driver is added to ControllerHandle.
183 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
184 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
185 @retval Others This driver does not support this device.
190 MnpDriverBindingStart (
191 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
192 IN EFI_HANDLE ControllerHandle
,
193 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
198 Stop this driver on ControllerHandle. This service is called by the
199 EFI boot service DisconnectController(). In order to make drivers as
200 small as possible, there are a few calling restrictions for this service.
201 DisconnectController() must follow these calling restrictions. If any other
202 agent wishes to call Stop() it must also follow these calling restrictions.
204 @param[in] This Protocol instance pointer.
205 @param[in] ControllerHandle Handle of device to stop driver on.
206 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
207 number of children is zero stop the entire
209 @param[in] ChildHandleBuffer List of Child Handles to Stop.
211 @retval EFI_SUCCESS This driver is removed ControllerHandle.
212 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
217 MnpDriverBindingStop (
218 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
219 IN EFI_HANDLE ControllerHandle
,
220 IN UINTN NumberOfChildren
,
221 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
225 Creates a child handle with a set of I/O services.
227 @param[in] This Protocol instance pointer.
228 @param[in, out] ChildHandle Pointer to the handle of the child to create. If
229 it is NULL, then a new handle is created. If
230 it is not NULL, then the I/O services are added
231 to the existing child handle.
233 @retval EFI_SUCCES The protocol was added to ChildHandle.
234 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
235 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
237 @retval Others The child handle was not created.
242 MnpServiceBindingCreateChild (
243 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
244 IN OUT EFI_HANDLE
*ChildHandle
248 Destroys a child handle with a set of I/O services.
250 The DestroyChild() function does the opposite of CreateChild(). It removes a
251 protocol that was installed by CreateChild() from ChildHandle. If the removed
252 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
254 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
256 @param[in] ChildHandle Handle of the child to destroy.
258 @retval EFI_SUCCES The protocol was removed from ChildHandle.
259 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
261 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
262 @retval EFI_ACCESS_DENIED The protocol could not be removed from the
263 ChildHandle because its services are being
265 @retval Others The child handle was not destroyed.
270 MnpServiceBindingDestroyChild (
271 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
272 IN EFI_HANDLE ChildHandle