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