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