]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/MnpDxe/MnpImpl.h
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe: Add support for PCD PcdPteMemoryEn...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpImpl.h
CommitLineData
83cbd279 1/** @file\r
6e4bac4d 2 Declaration of structures and functions of 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
83cbd279 9http://opensource.org/licenses/bsd-license.php\r
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_IMPL_H_\r
17#define _MNP_IMPL_H_\r
18\r
19#include "MnpDriver.h"\r
83cbd279 20\r
21#define NET_ETHER_FCS_SIZE 4\r
22\r
19873973 23#define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds\r
aeddd425 24#define MNP_TIMEOUT_CHECK_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds\r
dd29f3ed 25#define MNP_MEDIA_DETECT_INTERVAL (500 * TICKS_PER_MS) // 500 milliseconds\r
83cbd279 26#define MNP_TX_TIMEOUT_TIME (500 * TICKS_PER_MS) // 500 milliseconds\r
27#define MNP_INIT_NET_BUFFER_NUM 512\r
28#define MNP_NET_BUFFER_INCREASEMENT 64\r
29#define MNP_MAX_NET_BUFFER_NUM 65536\r
7b334a31 30#define MNP_TX_BUFFER_INCREASEMENT 32 // Same as the recycling Q length for xmit_done in UNDI command.\r
05074499 31#define MNP_MAX_TX_BUFFER_NUM 65536\r
83cbd279 32\r
33#define MNP_MAX_RCVD_PACKET_QUE_SIZE 256\r
34\r
35#define MNP_RECEIVE_UNICAST 0x01\r
36#define MNP_RECEIVE_BROADCAST 0x02\r
37\r
38#define UNICAST_PACKET MNP_RECEIVE_UNICAST\r
39#define BROADCAST_PACKET MNP_RECEIVE_BROADCAST\r
40\r
f3f2e05d 41#define MNP_INSTANCE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'I')\r
83cbd279 42\r
43#define MNP_INSTANCE_DATA_FROM_THIS(a) \\r
44 CR ( \\r
45 (a), \\r
46 MNP_INSTANCE_DATA, \\r
47 ManagedNetwork, \\r
48 MNP_INSTANCE_DATA_SIGNATURE \\r
49 )\r
50\r
6e4bac4d 51typedef struct {\r
83cbd279 52 UINT32 Signature;\r
53\r
54 MNP_SERVICE_DATA *MnpServiceData;\r
55\r
56 EFI_HANDLE Handle;\r
57\r
e48e37fc 58 LIST_ENTRY InstEntry;\r
83cbd279 59\r
60 EFI_MANAGED_NETWORK_PROTOCOL ManagedNetwork;\r
61\r
62 BOOLEAN Configured;\r
63 BOOLEAN Destroyed;\r
64\r
e48e37fc 65 LIST_ENTRY GroupCtrlBlkList;\r
83cbd279 66\r
67 NET_MAP RxTokenMap;\r
68\r
e48e37fc 69 LIST_ENTRY RxDeliveredPacketQueue;\r
70 LIST_ENTRY RcvdPacketQueue;\r
83cbd279 71 UINTN RcvdPacketQueueSize;\r
72\r
73 EFI_MANAGED_NETWORK_CONFIG_DATA ConfigData;\r
74\r
75 UINT8 ReceiveFilter;\r
76} MNP_INSTANCE_DATA;\r
77\r
6e4bac4d 78typedef struct {\r
e48e37fc 79 LIST_ENTRY AddrEntry;\r
83cbd279 80 EFI_MAC_ADDRESS Address;\r
81 INTN RefCnt;\r
82} MNP_GROUP_ADDRESS;\r
83\r
6e4bac4d 84typedef struct {\r
e48e37fc 85 LIST_ENTRY CtrlBlkEntry;\r
83cbd279 86 MNP_GROUP_ADDRESS *GroupAddress;\r
87} MNP_GROUP_CONTROL_BLOCK;\r
88\r
6e4bac4d 89typedef struct {\r
e48e37fc 90 LIST_ENTRY WrapEntry;\r
83cbd279 91 MNP_INSTANCE_DATA *Instance;\r
92 EFI_MANAGED_NETWORK_RECEIVE_DATA RxData;\r
93 NET_BUF *Nbuf;\r
94 UINT64 TimeoutTick;\r
95} MNP_RXDATA_WRAP;\r
96\r
05074499
FS
97#define MNP_TX_BUF_WRAP_SIGNATURE SIGNATURE_32 ('M', 'T', 'B', 'W')\r
98\r
99typedef struct {\r
100 UINT32 Signature;\r
101 LIST_ENTRY WrapEntry; // Link to FreeTxBufList\r
102 LIST_ENTRY AllEntry; // Link to AllTxBufList\r
103 BOOLEAN InUse;\r
104 UINT8 TxBuf[1];\r
105} MNP_TX_BUF_WRAP;\r
779ae357 106\r
107/**\r
108 Initialize the mnp device context data.\r
109\r
110 @param[in, out] MnpDeviceData Pointer to the mnp device context data.\r
111 @param[in] ImageHandle The driver image handle.\r
112 @param[in] ControllerHandle Handle of device to bind driver to.\r
113\r
114 @retval EFI_SUCCESS The mnp service context is initialized.\r
115 @retval EFI_UNSUPPORTED ControllerHandle does not support Simple Network Protocol.\r
116 @retval Others Other errors as indicated.\r
117\r
118**/\r
119EFI_STATUS\r
120MnpInitializeDeviceData (\r
121 IN OUT MNP_DEVICE_DATA *MnpDeviceData,\r
122 IN EFI_HANDLE ImageHandle,\r
123 IN EFI_HANDLE ControllerHandle\r
124 );\r
125\r
126/**\r
127 Destroy the MNP device context data.\r
128\r
129 @param[in, out] MnpDeviceData Pointer to the mnp device context data.\r
130 @param[in] ImageHandle The driver image handle.\r
131\r
132**/\r
133VOID\r
134MnpDestroyDeviceData (\r
135 IN OUT MNP_DEVICE_DATA *MnpDeviceData,\r
136 IN EFI_HANDLE ImageHandle\r
137 );\r
138\r
139/**\r
140 Create mnp service context data.\r
141\r
142 @param[in] MnpDeviceData Pointer to the mnp device context data.\r
143 @param[in] VlanId The VLAN ID.\r
144 @param[in] Priority The VLAN priority. If VlanId is 0,\r
145 Priority is ignored.\r
146\r
147 @return A pointer to MNP_SERVICE_DATA or NULL if failed to create MNP service context.\r
148\r
149**/\r
150MNP_SERVICE_DATA *\r
151MnpCreateServiceData (\r
152 IN MNP_DEVICE_DATA *MnpDeviceData,\r
153 IN UINT16 VlanId,\r
154 IN UINT8 Priority OPTIONAL\r
155 );\r
156\r
b6c4ecad 157/**\r
158 Initialize the mnp service context data.\r
159\r
6e4bac4d 160 @param[in, out] MnpServiceData Pointer to the mnp service context data.\r
161 @param[in] ImageHandle The driver image handle.\r
162 @param[in] ControllerHandle Handle of device to bind driver to.\r
b6c4ecad 163\r
164 @retval EFI_SUCCESS The mnp service context is initialized.\r
6e4bac4d 165 @retval EFI_UNSUPPORTED ControllerHandle does not support Simple Network Protocol.\r
166 @retval Others Other errors as indicated.\r
b6c4ecad 167\r
168**/\r
83cbd279 169EFI_STATUS\r
170MnpInitializeServiceData (\r
779ae357 171 IN OUT MNP_SERVICE_DATA *MnpServiceData,\r
172 IN EFI_HANDLE ImageHandle,\r
173 IN EFI_HANDLE ControllerHandle\r
83cbd279 174 );\r
175\r
b6c4ecad 176/**\r
779ae357 177 Destroy the MNP service context data.\r
b6c4ecad 178\r
6e4bac4d 179 @param[in, out] MnpServiceData Pointer to the mnp service context data.\r
779ae357 180\r
181 @retval EFI_SUCCESS The mnp service context is destroyed.\r
182 @retval Others Errors as indicated.\r
6e4bac4d 183\r
b6c4ecad 184**/\r
779ae357 185EFI_STATUS\r
186MnpDestroyServiceData (\r
187 IN OUT MNP_SERVICE_DATA *MnpServiceData\r
188 );\r
189\r
190/**\r
191 Destroy all child of the MNP service data.\r
192\r
193 @param[in, out] MnpServiceData Pointer to the mnp service context data.\r
194\r
195 @retval EFI_SUCCESS All child are destroyed.\r
196 @retval Others Failed to destroy all child.\r
197\r
198**/\r
199EFI_STATUS\r
200MnpDestroyServiceChild (\r
201 IN OUT MNP_SERVICE_DATA *MnpServiceData\r
202 );\r
203\r
204/**\r
205 Find the MNP Service Data for given VLAN ID.\r
206\r
207 @param[in] MnpDeviceData Pointer to the mnp device context data.\r
208 @param[in] VlanId The VLAN ID.\r
209\r
210 @return A pointer to MNP_SERVICE_DATA or NULL if not found.\r
211\r
212**/\r
213MNP_SERVICE_DATA *\r
214MnpFindServiceData (\r
215 IN MNP_DEVICE_DATA *MnpDeviceData,\r
216 IN UINT16 VlanId\r
83cbd279 217 );\r
218\r
b6c4ecad 219/**\r
220 Initialize the mnp instance context data.\r
221\r
6e4bac4d 222 @param[in] MnpServiceData Pointer to the mnp service context data.\r
779ae357 223 @param[in, out] Instance Pointer to the mnp instance context data\r
6e4bac4d 224 to initialize.\r
b6c4ecad 225\r
226**/\r
83cbd279 227VOID\r
228MnpInitializeInstanceData (\r
779ae357 229 IN MNP_SERVICE_DATA *MnpServiceData,\r
230 IN OUT MNP_INSTANCE_DATA *Instance\r
83cbd279 231 );\r
232\r
b6c4ecad 233/**\r
6e4bac4d 234 Check whether the token specified by Arg matches the token in Item.\r
b6c4ecad 235\r
3e8c18da 236 @param[in] Map Pointer to the NET_MAP.\r
6e4bac4d 237 @param[in] Item Pointer to the NET_MAP_ITEM.\r
3e8c18da 238 @param[in] Arg Pointer to the Arg, it's a pointer to the token to\r
b6c4ecad 239 check.\r
240\r
241 @retval EFI_SUCCESS The token specified by Arg is different from the\r
242 token in Item.\r
243 @retval EFI_ACCESS_DENIED The token specified by Arg is the same as that in\r
244 Item.\r
245\r
246**/\r
83cbd279 247EFI_STATUS\r
e798cd87 248EFIAPI\r
83cbd279 249MnpTokenExist (\r
779ae357 250 IN NET_MAP *Map,\r
251 IN NET_MAP_ITEM *Item,\r
252 IN VOID *Arg\r
83cbd279 253 );\r
254\r
b6c4ecad 255/**\r
256 Cancel the token specified by Arg if it matches the token in Item.\r
257\r
6e4bac4d 258 @param[in, out] Map Pointer to the NET_MAP.\r
259 @param[in, out] Item Pointer to the NET_MAP_ITEM.\r
779ae357 260 @param[in] Arg Pointer to the Arg, it's a pointer to the\r
6e4bac4d 261 token to cancel.\r
b6c4ecad 262\r
779ae357 263 @retval EFI_SUCCESS The Arg is NULL, and the token in Item is cancelled,\r
3e8c18da 264 or the Arg isn't NULL, and the token in Item is\r
265 different from the Arg.\r
266 @retval EFI_ABORTED The Arg isn't NULL, the token in Item mathces the\r
267 Arg, and the token is cancelled.\r
b6c4ecad 268\r
269**/\r
83cbd279 270EFI_STATUS\r
e798cd87 271EFIAPI\r
83cbd279 272MnpCancelTokens (\r
779ae357 273 IN OUT NET_MAP *Map,\r
274 IN OUT NET_MAP_ITEM *Item,\r
275 IN VOID *Arg\r
83cbd279 276 );\r
277\r
b6c4ecad 278/**\r
279 Flush the instance's received data.\r
280\r
6e4bac4d 281 @param[in, out] Instance Pointer to the mnp instance context data.\r
b6c4ecad 282\r
283**/\r
83cbd279 284VOID\r
285MnpFlushRcvdDataQueue (\r
779ae357 286 IN OUT MNP_INSTANCE_DATA *Instance\r
83cbd279 287 );\r
288\r
b6c4ecad 289/**\r
290 Configure the Instance using ConfigData.\r
291\r
6e4bac4d 292 @param[in, out] Instance Pointer to the mnp instance context data.\r
293 @param[in] ConfigData Pointer to the configuration data used to configure\r
b6c4ecad 294 the isntance.\r
295\r
296 @retval EFI_SUCCESS The Instance is configured.\r
297 @retval EFI_UNSUPPORTED EnableReceiveTimestamps is on and the\r
298 implementation doesn't support it.\r
6e4bac4d 299 @retval Others Other errors as indicated.\r
b6c4ecad 300\r
301**/\r
83cbd279 302EFI_STATUS\r
303MnpConfigureInstance (\r
779ae357 304 IN OUT MNP_INSTANCE_DATA *Instance,\r
305 IN EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData OPTIONAL\r
83cbd279 306 );\r
307\r
b6c4ecad 308/**\r
309 Do the group operations for this instance.\r
310\r
6e4bac4d 311 @param[in, out] Instance Pointer to the instance context data.\r
779ae357 312 @param[in] JoinFlag Set to TRUE to join a group. Set to TRUE to\r
6e4bac4d 313 leave a group/groups.\r
314 @param[in] MacAddress Pointer to the group address to join or leave.\r
779ae357 315 @param[in] CtrlBlk Pointer to the group control block if JoinFlag\r
6e4bac4d 316 is FALSE.\r
b6c4ecad 317\r
6e4bac4d 318 @retval EFI_SUCCESS The group operation finished.\r
319 @retval EFI_OUT_OF_RESOURCES Failed due to lack of memory resources.\r
320 @retval Others Other errors as indicated.\r
b6c4ecad 321\r
322**/\r
83cbd279 323EFI_STATUS\r
324MnpGroupOp (\r
779ae357 325 IN OUT MNP_INSTANCE_DATA *Instance,\r
326 IN BOOLEAN JoinFlag,\r
327 IN EFI_MAC_ADDRESS *MacAddress OPTIONAL,\r
328 IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk OPTIONAL\r
83cbd279 329 );\r
330\r
b6c4ecad 331/**\r
332 Validates the Mnp transmit token.\r
333\r
6e4bac4d 334 @param[in] Instance Pointer to the Mnp instance context data.\r
335 @param[in] Token Pointer to the transmit token to check.\r
b6c4ecad 336\r
337 @return The Token is valid or not.\r
338\r
339**/\r
83cbd279 340BOOLEAN\r
341MnpIsValidTxToken (\r
779ae357 342 IN MNP_INSTANCE_DATA *Instance,\r
343 IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token\r
83cbd279 344 );\r
345\r
b6c4ecad 346/**\r
347 Build the packet to transmit from the TxData passed in.\r
348\r
6e4bac4d 349 @param[in] MnpServiceData Pointer to the mnp service context data.\r
779ae357 350 @param[in] TxData Pointer to the transmit data containing the information\r
6e4bac4d 351 to build the packet.\r
352 @param[out] PktBuf Pointer to record the address of the packet.\r
779ae357 353 @param[out] PktLen Pointer to a UINT32 variable used to record the packet's\r
6e4bac4d 354 length.\r
355\r
05074499
FS
356 @retval EFI_SUCCESS TxPackage is built.\r
357 @retval EFI_OUT_OF_RESOURCES The deliver fails due to lack of memory resource.\r
358\r
b6c4ecad 359**/\r
05074499 360EFI_STATUS\r
83cbd279 361MnpBuildTxPacket (\r
779ae357 362 IN MNP_SERVICE_DATA *MnpServiceData,\r
363 IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,\r
364 OUT UINT8 **PktBuf,\r
365 OUT UINT32 *PktLen\r
83cbd279 366 );\r
367\r
b6c4ecad 368/**\r
05074499
FS
369 Synchronously send out the packet. \r
370\r
371 This functon places the packet buffer to SNP driver's tansmit queue. The packet\r
372 can be considered successfully sent out once SNP acccetp the packet, while the\r
373 packet buffer recycle is deferred for better performance.\r
b6c4ecad 374\r
6e4bac4d 375 @param[in] MnpServiceData Pointer to the mnp service context data.\r
376 @param[in] Packet Pointer to the pakcet buffer.\r
377 @param[in] Length The length of the packet.\r
378 @param[in, out] Token Pointer to the token the packet generated from.\r
b6c4ecad 379\r
6e4bac4d 380 @retval EFI_SUCCESS The packet is sent out.\r
381 @retval EFI_TIMEOUT Time out occurs, the packet isn't sent.\r
382 @retval EFI_DEVICE_ERROR An unexpected network error occurs.\r
b6c4ecad 383\r
384**/\r
83cbd279 385EFI_STATUS\r
386MnpSyncSendPacket (\r
779ae357 387 IN MNP_SERVICE_DATA *MnpServiceData,\r
388 IN UINT8 *Packet,\r
389 IN UINT32 Length,\r
390 IN OUT EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token\r
83cbd279 391 );\r
392\r
b6c4ecad 393/**\r
394 Try to deliver the received packet to the instance.\r
395\r
6e4bac4d 396 @param[in, out] Instance Pointer to the mnp instance context data.\r
b6c4ecad 397\r
398 @retval EFI_SUCCESS The received packet is delivered, or there is no\r
399 packet to deliver, or there is no available receive\r
400 token.\r
401 @retval EFI_OUT_OF_RESOURCES The deliver fails due to lack of memory resource.\r
402\r
403**/\r
83cbd279 404EFI_STATUS\r
405MnpInstanceDeliverPacket (\r
779ae357 406 IN OUT MNP_INSTANCE_DATA *Instance\r
83cbd279 407 );\r
408\r
b6c4ecad 409/**\r
410 Recycle the RxData and other resources used to hold and deliver the received\r
411 packet.\r
412\r
6e4bac4d 413 @param[in] Event The event this notify function registered to.\r
414 @param[in] Context Pointer to the context data registerd to the Event.\r
415\r
b6c4ecad 416**/\r
83cbd279 417VOID\r
418EFIAPI\r
419MnpRecycleRxData (\r
779ae357 420 IN EFI_EVENT Event,\r
421 IN VOID *Context\r
83cbd279 422 );\r
423\r
b6c4ecad 424/**\r
425 Try to receive a packet and deliver it.\r
426\r
779ae357 427 @param[in, out] MnpDeviceData Pointer to the mnp device context data.\r
b6c4ecad 428\r
429 @retval EFI_SUCCESS add return value to function comment\r
430 @retval EFI_NOT_STARTED The simple network protocol is not started.\r
431 @retval EFI_NOT_READY No packet received.\r
432 @retval EFI_DEVICE_ERROR An unexpected error occurs.\r
433\r
434**/\r
83cbd279 435EFI_STATUS\r
436MnpReceivePacket (\r
779ae357 437 IN OUT MNP_DEVICE_DATA *MnpDeviceData\r
83cbd279 438 );\r
439\r
b6c4ecad 440/**\r
779ae357 441 Allocate a free NET_BUF from MnpDeviceData->FreeNbufQue. If there is none\r
b6c4ecad 442 in the queue, first try to allocate some and add them into the queue, then\r
443 fetch the NET_BUF from the updated FreeNbufQue.\r
444\r
779ae357 445 @param[in, out] MnpDeviceData Pointer to the MNP_DEVICE_DATA.\r
b6c4ecad 446\r
779ae357 447 @return Pointer to the allocated free NET_BUF structure, if NULL the\r
3e8c18da 448 operation is failed.\r
b6c4ecad 449\r
450**/\r
83cbd279 451NET_BUF *\r
452MnpAllocNbuf (\r
779ae357 453 IN OUT MNP_DEVICE_DATA *MnpDeviceData\r
83cbd279 454 );\r
455\r
b6c4ecad 456/**\r
457 Try to reclaim the Nbuf into the buffer pool.\r
458\r
779ae357 459 @param[in, out] MnpDeviceData Pointer to the mnp device context data.\r
5fe2f07f 460 @param[in, out] Nbuf Pointer to the NET_BUF to free.\r
6e4bac4d 461\r
b6c4ecad 462**/\r
83cbd279 463VOID\r
464MnpFreeNbuf (\r
779ae357 465 IN OUT MNP_DEVICE_DATA *MnpDeviceData,\r
6e4bac4d 466 IN OUT NET_BUF *Nbuf\r
83cbd279 467 );\r
468\r
05074499
FS
469/**\r
470 Allocate a free TX buffer from MnpDeviceData->FreeTxBufList. If there is none\r
471 in the queue, first try to recycle some from SNP, then try to allocate some and add \r
472 them into the queue, then fetch the NET_BUF from the updated FreeTxBufList.\r
473\r
474 @param[in, out] MnpDeviceData Pointer to the MNP_DEVICE_DATA.\r
475\r
476 @return Pointer to the allocated free NET_BUF structure, if NULL the\r
477 operation is failed.\r
478\r
479**/\r
480UINT8 *\r
481MnpAllocTxBuf (\r
482 IN OUT MNP_DEVICE_DATA *MnpDeviceData\r
483 );\r
484\r
485/**\r
486 Try to recycle all the transmitted buffer address from SNP.\r
487\r
488 @param[in, out] MnpDeviceData Pointer to the mnp device context data.\r
489\r
490 @retval EFI_SUCCESS Successed to recyclethe transmitted buffer address.\r
491 @retval Others Failed to recyclethe transmitted buffer address.\r
492\r
493**/\r
494EFI_STATUS\r
495MnpRecycleTxBuf (\r
496 IN OUT MNP_DEVICE_DATA *MnpDeviceData\r
497 );\r
498\r
b6c4ecad 499/**\r
500 Remove the received packets if timeout occurs.\r
501\r
dd29f3ed 502 @param[in] Event The event this notify function registered to.\r
503 @param[in] Context Pointer to the context data registered to the event.\r
779ae357 504\r
b6c4ecad 505**/\r
83cbd279 506VOID\r
507EFIAPI\r
508MnpCheckPacketTimeout (\r
779ae357 509 IN EFI_EVENT Event,\r
510 IN VOID *Context\r
83cbd279 511 );\r
512\r
dd29f3ed 513/**\r
514 Poll to update MediaPresent field in SNP ModeData by Snp.GetStatus().\r
515\r
516 @param[in] Event The event this notify function registered to.\r
517 @param[in] Context Pointer to the context data registered to the event.\r
518\r
519**/\r
520VOID\r
521EFIAPI\r
522MnpCheckMediaStatus (\r
523 IN EFI_EVENT Event,\r
524 IN VOID *Context\r
525 );\r
526\r
b6c4ecad 527/**\r
528 Poll to receive the packets from Snp. This function is either called by upperlayer\r
529 protocols/applications or the system poll timer notify mechanism.\r
530\r
dd29f3ed 531 @param[in] Event The event this notify function registered to.\r
532 @param[in] Context Pointer to the context data registered to the event.\r
b6c4ecad 533\r
534**/\r
83cbd279 535VOID\r
536EFIAPI\r
537MnpSystemPoll (\r
dd29f3ed 538 IN EFI_EVENT Event,\r
539 IN VOID *Context\r
83cbd279 540 );\r
541\r
b6c4ecad 542/**\r
543 Returns the operational parameters for the current MNP child driver. May also\r
779ae357 544 support returning the underlying SNP driver mode data.\r
545\r
b6c4ecad 546 The GetModeData() function is used to read the current mode data (operational\r
779ae357 547 parameters) from the MNP or the underlying SNP.\r
b6c4ecad 548\r
3e8c18da 549 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
550 @param[out] MnpConfigData Pointer to storage for MNP operational parameters. Type\r
551 EFI_MANAGED_NETWORK_CONFIG_DATA is defined in "Related\r
552 Definitions" below.\r
553 @param[out] SnpModeData Pointer to storage for SNP operational parameters. This\r
554 feature may be unsupported. Type EFI_SIMPLE_NETWORK_MODE\r
555 is defined in the EFI_SIMPLE_NETWORK_PROTOCOL.\r
779ae357 556\r
b6c4ecad 557 @retval EFI_SUCCESS The operation completed successfully.\r
558 @retval EFI_INVALID_PARAMETER This is NULL.\r
559 @retval EFI_UNSUPPORTED The requested feature is unsupported in this\r
560 MNP implementation.\r
561 @retval EFI_NOT_STARTED This MNP child driver instance has not been\r
562 configured. The default values are returned in\r
563 MnpConfigData if it is not NULL.\r
6e4bac4d 564 @retval Others The mode data could not be read.\r
b6c4ecad 565\r
566**/\r
83cbd279 567EFI_STATUS\r
568EFIAPI\r
569MnpGetModeData (\r
779ae357 570 IN EFI_MANAGED_NETWORK_PROTOCOL *This,\r
571 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
572 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
83cbd279 573 );\r
574\r
b6c4ecad 575/**\r
779ae357 576 Sets or clears the operational parameters for the MNP child driver.\r
577\r
578 The Configure() function is used to set, change, or reset the operational\r
b6c4ecad 579 parameters for the MNP child driver instance. Until the operational parameters\r
580 have been set, no network traffic can be sent or received by this MNP child\r
581 driver instance. Once the operational parameters have been reset, no more\r
582 traffic can be sent or received until the operational parameters have been set\r
583 again.\r
584 Each MNP child driver instance can be started and stopped independently of\r
585 each other by setting or resetting their receive filter settings with the\r
586 Configure() function.\r
587 After any successful call to Configure(), the MNP child driver instance is\r
588 started. The internal periodic timer (if supported) is enabled. Data can be\r
589 transmitted and may be received if the receive filters have also been enabled.\r
590 Note: If multiple MNP child driver instances will receive the same packet\r
591 because of overlapping receive filter settings, then the first MNP child\r
592 driver instance will receive the original packet and additional instances will\r
593 receive copies of the original packet.\r
594 Note: Warning: Receive filter settings that overlap will consume extra\r
595 processor and/or DMA resources and degrade system and network performance.\r
596\r
6e4bac4d 597 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
598 @param[in] MnpConfigData Pointer to configuration data that will be assigned\r
599 to the MNP child driver instance. If NULL, the MNP\r
600 child driver instance is reset to startup defaults\r
601 and all pending transmit and receive requests are\r
602 flushed. Type EFI_MANAGED_NETWORK_CONFIG_DATA is\r
603 defined in EFI_MANAGED_NETWORK_PROTOCOL.GetModeData().\r
b6c4ecad 604\r
605 @retval EFI_SUCCESS The operation completed successfully.\r
606 @retval EFI_INVALID_PARAMETER One or more of the following conditions is\r
607 TRUE:\r
608 * This is NULL.\r
609 * MnpConfigData.ProtocolTypeFilter is not\r
610 valid.\r
611 The operational data for the MNP child driver\r
612 instance is unchanged.\r
613 @retval EFI_OUT_OF_RESOURCES Required system resources (usually memory)\r
614 could not be allocated.\r
615 The MNP child driver instance has been reset to\r
616 startup defaults.\r
617 @retval EFI_UNSUPPORTED The requested feature is unsupported in\r
618 this [MNP] implementation. The operational data\r
619 for the MNP child driver instance is unchanged.\r
620 @retval EFI_DEVICE_ERROR An unexpected network or system error\r
621 occurred. The MNP child driver instance has\r
622 been reset to startup defaults.\r
6e4bac4d 623 @retval Others The MNP child driver instance has been reset to\r
b6c4ecad 624 startup defaults.\r
625\r
626**/\r
83cbd279 627EFI_STATUS\r
628EFIAPI\r
629MnpConfigure (\r
779ae357 630 IN EFI_MANAGED_NETWORK_PROTOCOL *This,\r
631 IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL\r
83cbd279 632 );\r
633\r
b6c4ecad 634/**\r
779ae357 635 Translates an IP multicast address to a hardware (MAC) multicast address. This\r
636 function may be unsupported in some MNP implementations.\r
637\r
b6c4ecad 638 The McastIpToMac() function translates an IP multicast address to a hardware\r
639 (MAC) multicast address. This function may be implemented by calling the\r
6e4bac4d 640 underlying EFI_SIMPLE_NETWORK. MCastIpToMac() function, which may also be\r
b6c4ecad 641 unsupported in some MNP implementations.\r
642\r
6e4bac4d 643 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
644 @param[in] Ipv6Flag Set to TRUE to if IpAddress is an IPv6 multicast address.\r
645 Set to FALSE if IpAddress is an IPv4 multicast address.\r
646 @param[in] IpAddress Pointer to the multicast IP address (in network byte\r
647 order) to convert.\r
779ae357 648 @param[out] MacAddress Pointer to the resulting multicast MAC address.\r
b6c4ecad 649\r
650 @retval EFI_SUCCESS The operation completed successfully.\r
651 @retval EFI_INVALID_PARAMETER One of the following conditions is TRUE:\r
652 * This is NULL.\r
653 * IpAddress is NULL.\r
654 * IpAddress is not a valid multicast IP\r
655 address.\r
656 * MacAddress is NULL.\r
657 @retval EFI_NOT_STARTED This MNP child driver instance has not been\r
658 configured.\r
659 @retval EFI_UNSUPPORTED The requested feature is unsupported in this\r
660 MNP implementation.\r
661 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
6e4bac4d 662 @retval Others The address could not be converted.\r
b6c4ecad 663**/\r
83cbd279 664EFI_STATUS\r
665EFIAPI\r
666MnpMcastIpToMac (\r
779ae357 667 IN EFI_MANAGED_NETWORK_PROTOCOL *This,\r
668 IN BOOLEAN Ipv6Flag,\r
669 IN EFI_IP_ADDRESS *IpAddress,\r
670 OUT EFI_MAC_ADDRESS *MacAddress\r
83cbd279 671 );\r
672\r
b6c4ecad 673/**\r
779ae357 674 Enables and disables receive filters for multicast address. This function may\r
b6c4ecad 675 be unsupported in some MNP implementations.\r
779ae357 676\r
677 The Groups() function only adds and removes multicast MAC addresses from the\r
b6c4ecad 678 filter list. The MNP driver does not transmit or process Internet Group\r
679 Management Protocol (IGMP) packets. If JoinFlag is FALSE and MacAddress is\r
680 NULL, then all joined groups are left.\r
779ae357 681\r
3e8c18da 682 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
683 @param[in] JoinFlag Set to TRUE to join this multicast group.\r
684 Set to FALSE to leave this multicast group.\r
685 @param[in] MacAddress Pointer to the multicast MAC group (address) to join or\r
686 leave.\r
b6c4ecad 687\r
688 @retval EFI_SUCCESS The requested operation completed successfully.\r
689 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
690 * This is NULL.\r
691 * JoinFlag is TRUE and MacAddress is NULL.\r
692 * MacAddress is not a valid multicast MAC\r
693 address.\r
694 * The MNP multicast group settings are\r
695 unchanged.\r
696 @retval EFI_NOT_STARTED This MNP child driver instance has not been\r
697 configured.\r
698 @retval EFI_ALREADY_STARTED The supplied multicast group is already joined.\r
699 @retval EFI_NOT_FOUND The supplied multicast group is not joined.\r
700 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
701 The MNP child driver instance has been reset to\r
702 startup defaults.\r
703 @retval EFI_UNSUPPORTED The requested feature is unsupported in this MNP\r
704 implementation.\r
6e4bac4d 705 @retval Others The requested operation could not be completed.\r
b6c4ecad 706 The MNP multicast group settings are unchanged.\r
707\r
708**/\r
83cbd279 709EFI_STATUS\r
710EFIAPI\r
711MnpGroups (\r
779ae357 712 IN EFI_MANAGED_NETWORK_PROTOCOL *This,\r
713 IN BOOLEAN JoinFlag,\r
714 IN EFI_MAC_ADDRESS *MacAddress OPTIONAL\r
83cbd279 715 );\r
716\r
b6c4ecad 717/**\r
718 Places asynchronous outgoing data packets into the transmit queue.\r
779ae357 719\r
720 The Transmit() function places a completion token into the transmit packet\r
b6c4ecad 721 queue. This function is always asynchronous.\r
722 The caller must fill in the Token.Event and Token.TxData fields in the\r
723 completion token, and these fields cannot be NULL. When the transmit operation\r
724 completes, the MNP updates the Token.Status field and the Token.Event is\r
725 signaled.\r
726 Note: There may be a performance penalty if the packet needs to be\r
727 defragmented before it can be transmitted by the network device. Systems in\r
728 which performance is critical should review the requirements and features of\r
729 the underlying communications device and drivers.\r
779ae357 730\r
731\r
3e8c18da 732 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
733 @param[in] Token Pointer to a token associated with the transmit data\r
6e4bac4d 734 descriptor. Type EFI_MANAGED_NETWORK_COMPLETION_TOKEN\r
779ae357 735 is defined in "Related Definitions" below.\r
b6c4ecad 736\r
737 @retval EFI_SUCCESS The transmit completion token was cached.\r
738 @retval EFI_NOT_STARTED This MNP child driver instance has not been\r
739 configured.\r
740 @retval EFI_INVALID_PARAMETER One or more of the following conditions is\r
741 TRUE:\r
742 * This is NULL.\r
743 * Token is NULL.\r
744 * Token.Event is NULL.\r
745 * Token.TxData is NULL.\r
746 * Token.TxData.DestinationAddress is not\r
747 NULL and Token.TxData.HeaderLength is zero.\r
748 * Token.TxData.FragmentCount is zero.\r
749 * (Token.TxData.HeaderLength +\r
750 Token.TxData.DataLength) is not equal to the\r
751 sum of the\r
752 Token.TxData.FragmentTable[].FragmentLength\r
753 fields.\r
754 * One or more of the\r
755 Token.TxData.FragmentTable[].FragmentLength\r
756 fields is zero.\r
757 * One or more of the\r
758 Token.TxData.FragmentTable[].FragmentBufferfields\r
759 is NULL.\r
760 * Token.TxData.DataLength is greater than MTU.\r
761 @retval EFI_ACCESS_DENIED The transmit completion token is already in the\r
762 transmit queue.\r
763 @retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a\r
779ae357 764 lack of system resources (usually memory).\r
b6c4ecad 765 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
766 The MNP child driver instance has been reset to\r
767 startup defaults.\r
768 @retval EFI_NOT_READY The transmit request could not be queued because\r
769 the transmit queue is full.\r
770\r
771**/\r
83cbd279 772EFI_STATUS\r
773EFIAPI\r
774MnpTransmit (\r
779ae357 775 IN EFI_MANAGED_NETWORK_PROTOCOL *This,\r
776 IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token\r
83cbd279 777 );\r
778\r
b6c4ecad 779/**\r
779ae357 780 Aborts an asynchronous transmit or receive request.\r
781\r
b6c4ecad 782 The Cancel() function is used to abort a pending transmit or receive request.\r
783 If the token is in the transmit or receive request queues, after calling this\r
784 function, Token.Status will be set to EFI_ABORTED and then Token.Event will be\r
785 signaled. If the token is not in one of the queues, which usually means that\r
786 the asynchronous operation has completed, this function will not signal the\r
787 token and EFI_NOT_FOUND is returned.\r
788\r
3e8c18da 789 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
790 @param[in] Token Pointer to a token that has been issued by\r
791 EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or\r
779ae357 792 EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all\r
793 pending tokens are aborted.\r
b6c4ecad 794\r
795 @retval EFI_SUCCESS The asynchronous I/O request was aborted and\r
796 Token.Event was signaled. When Token is NULL,\r
797 all pending requests were aborted and their\r
798 events were signaled.\r
799 @retval EFI_NOT_STARTED This MNP child driver instance has not been\r
800 configured.\r
801 @retval EFI_INVALID_PARAMETER This is NULL.\r
802 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O\r
803 request was not found in the transmit or\r
804 receive queue. It has either completed or was\r
805 not issued by Transmit() and Receive().\r
806\r
807**/\r
83cbd279 808EFI_STATUS\r
809EFIAPI\r
810MnpCancel (\r
779ae357 811 IN EFI_MANAGED_NETWORK_PROTOCOL *This,\r
812 IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL\r
83cbd279 813 );\r
814\r
b6c4ecad 815/**\r
816 Places an asynchronous receiving request into the receiving queue.\r
779ae357 817\r
818 The Receive() function places a completion token into the receive packet\r
b6c4ecad 819 queue. This function is always asynchronous.\r
820 The caller must fill in the Token.Event field in the completion token, and\r
821 this field cannot be NULL. When the receive operation completes, the MNP\r
822 updates the Token.Status and Token.RxData fields and the Token.Event is\r
823 signaled.\r
779ae357 824\r
6e4bac4d 825 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
826 @param[in] Token Pointer to a token associated with the receive\r
827 data descriptor. Type\r
828 EFI_MANAGED_NETWORK_COMPLETION_TOKEN is defined in\r
829 EFI_MANAGED_NETWORK_PROTOCOL.Transmit().\r
b6c4ecad 830\r
831 @retval EFI_SUCCESS The receive completion token was cached.\r
832 @retval EFI_NOT_STARTED This MNP child driver instance has not been\r
833 configured.\r
834 @retval EFI_INVALID_PARAMETER One or more of the following conditions is\r
835 TRUE:\r
836 * This is NULL.\r
837 * Token is NULL.\r
838 * Token.Event is NULL\r
839 @retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a\r
840 lack of system resources (usually memory).\r
841 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
842 The MNP child driver instance has been reset to\r
843 startup defaults.\r
844 @retval EFI_ACCESS_DENIED The receive completion token was already in the\r
845 receive queue.\r
846 @retval EFI_NOT_READY The receive request could not be queued because\r
847 the receive queue is full.\r
848\r
849**/\r
83cbd279 850EFI_STATUS\r
851EFIAPI\r
852MnpReceive (\r
779ae357 853 IN EFI_MANAGED_NETWORK_PROTOCOL *This,\r
854 IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token\r
83cbd279 855 );\r
856\r
b6c4ecad 857/**\r
779ae357 858 Polls for incoming data packets and processes outgoing data packets.\r
859\r
860 The Poll() function can be used by network drivers and applications to\r
b6c4ecad 861 increase the rate that data packets are moved between the communications\r
862 device and the transmit and receive queues.\r
863 Normally, a periodic timer event internally calls the Poll() function. But, in\r
864 some systems, the periodic timer event may not call Poll() fast enough to\r
865 transmit and/or receive all data packets without missing packets. Drivers and\r
866 applications that are experiencing packet loss should try calling the Poll()\r
867 function more often.\r
868\r
6e4bac4d 869 @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.\r
b6c4ecad 870\r
871 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
872 @retval EFI_NOT_STARTED This MNP child driver instance has not been\r
873 configured.\r
874 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The\r
875 MNP child driver instance has been reset to startup\r
876 defaults.\r
877 @retval EFI_NOT_READY No incoming or outgoing data was processed. Consider\r
878 increasing the polling rate.\r
879 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive\r
880 queue. Consider increasing the polling rate.\r
881\r
882**/\r
83cbd279 883EFI_STATUS\r
884EFIAPI\r
885MnpPoll (\r
779ae357 886 IN EFI_MANAGED_NETWORK_PROTOCOL *This\r
83cbd279 887 );\r
888\r
aeddd425 889/**\r
890 Configure the Snp receive filters according to the instances' receive filter\r
891 settings.\r
892\r
779ae357 893 @param[in] MnpDeviceData Pointer to the mnp device context data.\r
aeddd425 894\r
895 @retval EFI_SUCCESS The receive filters is configured.\r
779ae357 896 @retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due\r
aeddd425 897 to lack of memory resource.\r
898\r
899**/\r
900EFI_STATUS\r
901MnpConfigReceiveFilters (\r
779ae357 902 IN MNP_DEVICE_DATA *MnpDeviceData\r
aeddd425 903 );\r
904\r
83cbd279 905#endif\r