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