]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
MdeModulePkg: Update MNP driver to recycle TX buffer asynchronously.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpDriver.h
CommitLineData
83cbd279 1/** @file\r
6e4bac4d 2 Declaration of strctures and functions for MnpDxe driver.\r
779ae357 3\r
05074499 4Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
779ae357 6are licensed and made available under the terms and conditions\r
7of the BSD License which accompanies this distribution. The full\r
8text of the license may be found at<BR>\r
9http://opensource.org/licenses/bsd-license.php\r
83cbd279 10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
83cbd279 14**/\r
15\r
16#ifndef _MNP_DRIVER_H_\r
17#define _MNP_DRIVER_H_\r
779ae357 18\r
c57273b0 19#include <Uefi.h>\r
8a67d61d 20\r
21#include <Protocol/ManagedNetwork.h>\r
83cbd279 22#include <Protocol/SimpleNetwork.h>\r
8a67d61d 23#include <Protocol/ServiceBinding.h>\r
779ae357 24#include <Protocol/VlanConfig.h>\r
8a67d61d 25\r
f3989f41 26#include <Library/BaseLib.h>\r
cfb1461b 27#include <Library/BaseMemoryLib.h>\r
8a67d61d 28#include <Library/DebugLib.h>\r
cfb1461b 29#include <Library/MemoryAllocationLib.h>\r
8a67d61d 30#include <Library/UefiBootServicesTableLib.h>\r
83cbd279 31#include <Library/UefiLib.h>\r
32#include <Library/NetLib.h>\r
d8d26fb2 33#include <Library/DpcLib.h>\r
779ae357 34#include <Library/UefiRuntimeServicesTableLib.h>\r
35#include <Library/DevicePathLib.h>\r
216f7970 36#include <Library/PrintLib.h>\r
83cbd279 37\r
6e4bac4d 38#include "ComponentName.h"\r
83cbd279 39\r
779ae357 40#define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')\r
83cbd279 41\r
216f7970 42//\r
43// Global Variables\r
44//\r
45extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;\r
46\r
6e4bac4d 47typedef struct {\r
83cbd279 48 UINT32 Signature;\r
49\r
50 EFI_HANDLE ControllerHandle;\r
779ae357 51 EFI_HANDLE ImageHandle;\r
83cbd279 52\r
779ae357 53 EFI_VLAN_CONFIG_PROTOCOL VlanConfig;\r
54 UINTN NumberOfVlan;\r
55 CHAR16 *MacString;\r
83cbd279 56 EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
57\r
779ae357 58 //\r
59 // List of MNP_SERVICE_DATA\r
60 //\r
61 LIST_ENTRY ServiceList;\r
62 //\r
63 // Number of configured MNP Service Binding child\r
64 //\r
83cbd279 65 UINTN ConfiguredChildrenNumber;\r
66\r
e48e37fc 67 LIST_ENTRY GroupAddressList;\r
83cbd279 68 UINT32 GroupAddressCount;\r
69\r
05074499
FS
70 LIST_ENTRY FreeTxBufList;\r
71 LIST_ENTRY AllTxBufList;\r
72 UINT32 TxBufCount;\r
83cbd279 73\r
74 NET_BUF_QUEUE FreeNbufQue;\r
75 INTN NbufCnt;\r
76\r
77 EFI_EVENT PollTimer;\r
78 BOOLEAN EnableSystemPoll;\r
79\r
80 EFI_EVENT TimeoutCheckTimer;\r
dd29f3ed 81 EFI_EVENT MediaDetectTimer;\r
83cbd279 82\r
83 UINT32 UnicastCount;\r
84 UINT32 BroadcastCount;\r
85 UINT32 MulticastCount;\r
86 UINT32 PromiscuousCount;\r
87\r
88 //\r
89 // The size of the data buffer in the MNP_PACKET_BUFFER used to\r
90 // store a packet.\r
91 //\r
92 UINT32 BufferLength;\r
93 UINT32 PaddingSize;\r
94 NET_BUF *RxNbufCache;\r
779ae357 95} MNP_DEVICE_DATA;\r
96\r
97#define MNP_DEVICE_DATA_FROM_THIS(a) \\r
98 CR ( \\r
99 (a), \\r
100 MNP_DEVICE_DATA, \\r
101 VlanConfig, \\r
102 MNP_DEVICE_DATA_SIGNATURE \\r
103 )\r
104\r
105#define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')\r
106\r
107typedef struct {\r
108 UINT32 Signature;\r
109\r
110 LIST_ENTRY Link;\r
111\r
112 MNP_DEVICE_DATA *MnpDeviceData;\r
113 EFI_HANDLE ServiceHandle;\r
114 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
115 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
116\r
117 LIST_ENTRY ChildrenList;\r
118 UINTN ChildrenNumber;\r
119\r
120 UINT32 Mtu;\r
121\r
122 UINT16 VlanId;\r
123 UINT8 Priority;\r
83cbd279 124} MNP_SERVICE_DATA;\r
125\r
779ae357 126\r
83cbd279 127#define MNP_SERVICE_DATA_FROM_THIS(a) \\r
128 CR ( \\r
129 (a), \\r
130 MNP_SERVICE_DATA, \\r
131 ServiceBinding, \\r
132 MNP_SERVICE_DATA_SIGNATURE \\r
133 )\r
134\r
779ae357 135#define MNP_SERVICE_DATA_FROM_LINK(a) \\r
136 CR ( \\r
137 (a), \\r
138 MNP_SERVICE_DATA, \\r
139 Link, \\r
140 MNP_SERVICE_DATA_SIGNATURE \\r
141 )\r
142\r
143\r
b6c4ecad 144/**\r
145 Test to see if this driver supports ControllerHandle. This service\r
146 is called by the EFI boot service ConnectController(). In\r
147 order to make drivers as small as possible, there are a few calling\r
148 restrictions for this service. ConnectController() must\r
149 follow these calling restrictions. If any other agent wishes to call\r
150 Supported() it must also follow these calling restrictions.\r
151\r
6e4bac4d 152 @param[in] This Protocol instance pointer.\r
153 @param[in] ControllerHandle Handle of device to test.\r
779ae357 154 @param[in] RemainingDevicePath Optional parameter use to pick a specific\r
6e4bac4d 155 child device to start.\r
b6c4ecad 156\r
6e4bac4d 157 @retval EFI_SUCCESS This driver supports this device.\r
158 @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
159 @retval Others This driver does not support this device.\r
b6c4ecad 160\r
161**/\r
83cbd279 162EFI_STATUS\r
163EFIAPI\r
164MnpDriverBindingSupported (\r
779ae357 165 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
166 IN EFI_HANDLE ControllerHandle,\r
167 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
83cbd279 168 );\r
169\r
b6c4ecad 170/**\r
171 Start this driver on ControllerHandle. This service is called by the\r
779ae357 172 EFI boot service ConnectController(). In order to make drivers as small\r
6e4bac4d 173 as possible, there are a few calling restrictions for this service.\r
174 ConnectController() must follow these calling restrictions. If any other\r
175 agent wishes to call Start() it must also follow these calling restrictions.\r
176\r
177 @param[in] This Protocol instance pointer.\r
178 @param[in] ControllerHandle Handle of device to bind driver to.\r
779ae357 179 @param[in] RemainingDevicePath Optional parameter use to pick a specific\r
6e4bac4d 180 child device to start.\r
181\r
182 @retval EFI_SUCCESS This driver is added to ControllerHandle.\r
183 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
184 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.\r
185 @retval Others This driver does not support this device.\r
779ae357 186\r
b6c4ecad 187**/\r
83cbd279 188EFI_STATUS\r
189EFIAPI\r
190MnpDriverBindingStart (\r
779ae357 191 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
192 IN EFI_HANDLE ControllerHandle,\r
193 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
83cbd279 194 );\r
195\r
b6c4ecad 196\r
197/**\r
198 Stop this driver on ControllerHandle. This service is called by the\r
779ae357 199 EFI boot service DisconnectController(). In order to make drivers as\r
200 small as possible, there are a few calling restrictions for this service.\r
201 DisconnectController() must follow these calling restrictions. If any other\r
6e4bac4d 202 agent wishes to call Stop() it must also follow these calling restrictions.\r
779ae357 203\r
6e4bac4d 204 @param[in] This Protocol instance pointer.\r
205 @param[in] ControllerHandle Handle of device to stop driver on.\r
779ae357 206 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If\r
207 number of children is zero stop the entire\r
208 bus driver.\r
6e4bac4d 209 @param[in] ChildHandleBuffer List of Child Handles to Stop.\r
b6c4ecad 210\r
6e4bac4d 211 @retval EFI_SUCCESS This driver is removed ControllerHandle.\r
212 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
b6c4ecad 213\r
214**/\r
83cbd279 215EFI_STATUS\r
216EFIAPI\r
217MnpDriverBindingStop (\r
779ae357 218 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
219 IN EFI_HANDLE ControllerHandle,\r
220 IN UINTN NumberOfChildren,\r
221 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
83cbd279 222 );\r
223\r
b6c4ecad 224/**\r
6e4bac4d 225 Creates a child handle with a set of I/O services.\r
b6c4ecad 226\r
6e4bac4d 227 @param[in] This Protocol instance pointer.\r
228 @param[in, out] ChildHandle Pointer to the handle of the child to create. If\r
229 it is NULL, then a new handle is created. If\r
779ae357 230 it is not NULL, then the I/O services are added\r
231 to the existing child handle.\r
b6c4ecad 232\r
779ae357 233 @retval EFI_SUCCES The protocol was added to ChildHandle.\r
234 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
235 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to\r
6e4bac4d 236 create the child.\r
237 @retval Others The child handle was not created.\r
b6c4ecad 238\r
239**/\r
83cbd279 240EFI_STATUS\r
241EFIAPI\r
242MnpServiceBindingCreateChild (\r
779ae357 243 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
244 IN OUT EFI_HANDLE *ChildHandle\r
83cbd279 245 );\r
246\r
b6c4ecad 247/**\r
6e4bac4d 248 Destroys a child handle with a set of I/O services.\r
779ae357 249\r
250 The DestroyChild() function does the opposite of CreateChild(). It removes a\r
251 protocol that was installed by CreateChild() from ChildHandle. If the removed\r
252 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.\r
253\r
254 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL\r
6e4bac4d 255 instance.\r
256 @param[in] ChildHandle Handle of the child to destroy.\r
257\r
779ae357 258 @retval EFI_SUCCES The protocol was removed from ChildHandle.\r
6e4bac4d 259 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that\r
260 is being removed.\r
284ee2e8 261 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
6e4bac4d 262 @retval EFI_ACCESS_DENIED The protocol could not be removed from the\r
263 ChildHandle because its services are being\r
264 used.\r
265 @retval Others The child handle was not destroyed.\r
b6c4ecad 266\r
267**/\r
83cbd279 268EFI_STATUS\r
269EFIAPI\r
270MnpServiceBindingDestroyChild (\r
779ae357 271 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
272 IN EFI_HANDLE ChildHandle\r
83cbd279 273 );\r
274\r
275#endif\r