]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
Add VLAN support.
[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
4Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
5All rights reserved. This program and the accompanying materials\r
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
83cbd279 36\r
6e4bac4d 37#include "ComponentName.h"\r
83cbd279 38\r
779ae357 39#define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')\r
83cbd279 40\r
6e4bac4d 41typedef struct {\r
83cbd279 42 UINT32 Signature;\r
43\r
44 EFI_HANDLE ControllerHandle;\r
779ae357 45 EFI_HANDLE ImageHandle;\r
83cbd279 46\r
779ae357 47 EFI_VLAN_CONFIG_PROTOCOL VlanConfig;\r
48 UINTN NumberOfVlan;\r
49 CHAR16 *MacString;\r
83cbd279 50 EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
51\r
779ae357 52 //\r
53 // List of MNP_SERVICE_DATA\r
54 //\r
55 LIST_ENTRY ServiceList;\r
56 //\r
57 // Number of configured MNP Service Binding child\r
58 //\r
83cbd279 59 UINTN ConfiguredChildrenNumber;\r
60\r
e48e37fc 61 LIST_ENTRY GroupAddressList;\r
83cbd279 62 UINT32 GroupAddressCount;\r
63\r
64 EFI_EVENT TxTimeoutEvent;\r
65\r
66 NET_BUF_QUEUE FreeNbufQue;\r
67 INTN NbufCnt;\r
68\r
69 EFI_EVENT PollTimer;\r
70 BOOLEAN EnableSystemPoll;\r
71\r
72 EFI_EVENT TimeoutCheckTimer;\r
73\r
74 UINT32 UnicastCount;\r
75 UINT32 BroadcastCount;\r
76 UINT32 MulticastCount;\r
77 UINT32 PromiscuousCount;\r
78\r
79 //\r
80 // The size of the data buffer in the MNP_PACKET_BUFFER used to\r
81 // store a packet.\r
82 //\r
83 UINT32 BufferLength;\r
84 UINT32 PaddingSize;\r
85 NET_BUF *RxNbufCache;\r
86 UINT8 *TxBuf;\r
779ae357 87} MNP_DEVICE_DATA;\r
88\r
89#define MNP_DEVICE_DATA_FROM_THIS(a) \\r
90 CR ( \\r
91 (a), \\r
92 MNP_DEVICE_DATA, \\r
93 VlanConfig, \\r
94 MNP_DEVICE_DATA_SIGNATURE \\r
95 )\r
96\r
97#define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')\r
98\r
99typedef struct {\r
100 UINT32 Signature;\r
101\r
102 LIST_ENTRY Link;\r
103\r
104 MNP_DEVICE_DATA *MnpDeviceData;\r
105 EFI_HANDLE ServiceHandle;\r
106 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
107 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
108\r
109 LIST_ENTRY ChildrenList;\r
110 UINTN ChildrenNumber;\r
111\r
112 UINT32 Mtu;\r
113\r
114 UINT16 VlanId;\r
115 UINT8 Priority;\r
83cbd279 116} MNP_SERVICE_DATA;\r
117\r
779ae357 118\r
83cbd279 119#define MNP_SERVICE_DATA_FROM_THIS(a) \\r
120 CR ( \\r
121 (a), \\r
122 MNP_SERVICE_DATA, \\r
123 ServiceBinding, \\r
124 MNP_SERVICE_DATA_SIGNATURE \\r
125 )\r
126\r
779ae357 127#define MNP_SERVICE_DATA_FROM_LINK(a) \\r
128 CR ( \\r
129 (a), \\r
130 MNP_SERVICE_DATA, \\r
131 Link, \\r
132 MNP_SERVICE_DATA_SIGNATURE \\r
133 )\r
134\r
135\r
b6c4ecad 136/**\r
137 Test to see if this driver supports ControllerHandle. This service\r
138 is called by the EFI boot service ConnectController(). In\r
139 order to make drivers as small as possible, there are a few calling\r
140 restrictions for this service. ConnectController() must\r
141 follow these calling restrictions. If any other agent wishes to call\r
142 Supported() it must also follow these calling restrictions.\r
143\r
6e4bac4d 144 @param[in] This Protocol instance pointer.\r
145 @param[in] ControllerHandle Handle of device to test.\r
779ae357 146 @param[in] RemainingDevicePath Optional parameter use to pick a specific\r
6e4bac4d 147 child device to start.\r
b6c4ecad 148\r
6e4bac4d 149 @retval EFI_SUCCESS This driver supports this device.\r
150 @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
151 @retval Others This driver does not support this device.\r
b6c4ecad 152\r
153**/\r
83cbd279 154EFI_STATUS\r
155EFIAPI\r
156MnpDriverBindingSupported (\r
779ae357 157 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
158 IN EFI_HANDLE ControllerHandle,\r
159 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
83cbd279 160 );\r
161\r
b6c4ecad 162/**\r
163 Start this driver on ControllerHandle. This service is called by the\r
779ae357 164 EFI boot service ConnectController(). In order to make drivers as small\r
6e4bac4d 165 as possible, there are a few calling restrictions for this service.\r
166 ConnectController() must follow these calling restrictions. If any other\r
167 agent wishes to call Start() it must also follow these calling restrictions.\r
168\r
169 @param[in] This Protocol instance pointer.\r
170 @param[in] ControllerHandle Handle of device to bind driver to.\r
779ae357 171 @param[in] RemainingDevicePath Optional parameter use to pick a specific\r
6e4bac4d 172 child device to start.\r
173\r
174 @retval EFI_SUCCESS This driver is added to ControllerHandle.\r
175 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
176 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.\r
177 @retval Others This driver does not support this device.\r
779ae357 178\r
b6c4ecad 179**/\r
83cbd279 180EFI_STATUS\r
181EFIAPI\r
182MnpDriverBindingStart (\r
779ae357 183 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
184 IN EFI_HANDLE ControllerHandle,\r
185 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
83cbd279 186 );\r
187\r
b6c4ecad 188\r
189/**\r
190 Stop this driver on ControllerHandle. This service is called by the\r
779ae357 191 EFI boot service DisconnectController(). In order to make drivers as\r
192 small as possible, there are a few calling restrictions for this service.\r
193 DisconnectController() must follow these calling restrictions. If any other\r
6e4bac4d 194 agent wishes to call Stop() it must also follow these calling restrictions.\r
779ae357 195\r
6e4bac4d 196 @param[in] This Protocol instance pointer.\r
197 @param[in] ControllerHandle Handle of device to stop driver on.\r
779ae357 198 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If\r
199 number of children is zero stop the entire\r
200 bus driver.\r
6e4bac4d 201 @param[in] ChildHandleBuffer List of Child Handles to Stop.\r
b6c4ecad 202\r
6e4bac4d 203 @retval EFI_SUCCESS This driver is removed ControllerHandle.\r
204 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
b6c4ecad 205\r
206**/\r
83cbd279 207EFI_STATUS\r
208EFIAPI\r
209MnpDriverBindingStop (\r
779ae357 210 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
211 IN EFI_HANDLE ControllerHandle,\r
212 IN UINTN NumberOfChildren,\r
213 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
83cbd279 214 );\r
215\r
b6c4ecad 216/**\r
6e4bac4d 217 Creates a child handle with a set of I/O services.\r
b6c4ecad 218\r
6e4bac4d 219 @param[in] This Protocol instance pointer.\r
220 @param[in, out] ChildHandle Pointer to the handle of the child to create. If\r
221 it is NULL, then a new handle is created. If\r
779ae357 222 it is not NULL, then the I/O services are added\r
223 to the existing child handle.\r
b6c4ecad 224\r
779ae357 225 @retval EFI_SUCCES The protocol was added to ChildHandle.\r
226 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
227 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to\r
6e4bac4d 228 create the child.\r
229 @retval Others The child handle was not created.\r
b6c4ecad 230\r
231**/\r
83cbd279 232EFI_STATUS\r
233EFIAPI\r
234MnpServiceBindingCreateChild (\r
779ae357 235 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
236 IN OUT EFI_HANDLE *ChildHandle\r
83cbd279 237 );\r
238\r
b6c4ecad 239/**\r
6e4bac4d 240 Destroys a child handle with a set of I/O services.\r
779ae357 241\r
242 The DestroyChild() function does the opposite of CreateChild(). It removes a\r
243 protocol that was installed by CreateChild() from ChildHandle. If the removed\r
244 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.\r
245\r
246 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL\r
6e4bac4d 247 instance.\r
248 @param[in] ChildHandle Handle of the child to destroy.\r
249\r
779ae357 250 @retval EFI_SUCCES The protocol was removed from ChildHandle.\r
6e4bac4d 251 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that\r
252 is being removed.\r
253 @retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle.\r
254 @retval EFI_ACCESS_DENIED The protocol could not be removed from the\r
255 ChildHandle because its services are being\r
256 used.\r
257 @retval Others The child handle was not destroyed.\r
b6c4ecad 258\r
259**/\r
83cbd279 260EFI_STATUS\r
261EFIAPI\r
262MnpServiceBindingDestroyChild (\r
779ae357 263 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
264 IN EFI_HANDLE ChildHandle\r
83cbd279 265 );\r
266\r
267#endif\r