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