1 /** @file
2   The EFI_SIMPLE_NETWORK_PROTOCOL provides services to initialize a network interface,
3   transmit packets, receive packets, and close a network interface.
4 
5   Basic network device abstraction.
6 
7   Rx    - Received
8   Tx    - Transmit
9   MCast - MultiCast
10   ...
11 
12 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
13 SPDX-License-Identifier: BSD-2-Clause-Patent
14 
15   @par Revision Reference:
16   This Protocol is introduced in EFI Specification 1.10.
17 
18 **/
19 
20 #ifndef __SIMPLE_NETWORK_H__
21 #define __SIMPLE_NETWORK_H__
22 
23 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
24   { \
25     0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } \
26   }
27 
28 typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK_PROTOCOL;
29 
30 ///
31 /// Protocol defined in EFI1.1.
32 ///
33 typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK;
34 
35 ///
36 /// Simple Network Protocol data structures.
37 ///
38 typedef struct {
39   ///
40   /// Total number of frames received.  Includes frames with errors and
41   /// dropped frames.
42   ///
43   UINT64    RxTotalFrames;
44 
45   ///
46   /// Number of valid frames received and copied into receive buffers.
47   ///
48   UINT64    RxGoodFrames;
49 
50   ///
51   /// Number of frames below the minimum length for the media.
52   /// This would be <64 for ethernet.
53   ///
54   UINT64    RxUndersizeFrames;
55 
56   ///
57   /// Number of frames longer than the maxminum length for the
58   /// media.  This would be >1500 for ethernet.
59   ///
60   UINT64    RxOversizeFrames;
61 
62   ///
63   /// Valid frames that were dropped because receive buffers were full.
64   ///
65   UINT64    RxDroppedFrames;
66 
67   ///
68   /// Number of valid unicast frames received and not dropped.
69   ///
70   UINT64    RxUnicastFrames;
71 
72   ///
73   /// Number of valid broadcast frames received and not dropped.
74   ///
75   UINT64    RxBroadcastFrames;
76 
77   ///
78   /// Number of valid mutlicast frames received and not dropped.
79   ///
80   UINT64    RxMulticastFrames;
81 
82   ///
83   /// Number of frames w/ CRC or alignment errors.
84   ///
85   UINT64    RxCrcErrorFrames;
86 
87   ///
88   /// Total number of bytes received.  Includes frames with errors
89   /// and dropped frames.
90   //
91   UINT64    RxTotalBytes;
92 
93   ///
94   /// Transmit statistics.
95   ///
96   UINT64    TxTotalFrames;
97   UINT64    TxGoodFrames;
98   UINT64    TxUndersizeFrames;
99   UINT64    TxOversizeFrames;
100   UINT64    TxDroppedFrames;
101   UINT64    TxUnicastFrames;
102   UINT64    TxBroadcastFrames;
103   UINT64    TxMulticastFrames;
104   UINT64    TxCrcErrorFrames;
105   UINT64    TxTotalBytes;
106 
107   ///
108   /// Number of collisions detection on this subnet.
109   ///
110   UINT64    Collisions;
111 
112   ///
113   /// Number of frames destined for unsupported protocol.
114   ///
115   UINT64    UnsupportedProtocol;
116 
117   ///
118   /// Number of valid frames received that were duplicated.
119   ///
120   UINT64    RxDuplicatedFrames;
121 
122   ///
123   /// Number of encrypted frames received that failed to decrypt.
124   ///
125   UINT64    RxDecryptErrorFrames;
126 
127   ///
128   /// Number of frames that failed to transmit after exceeding the retry limit.
129   ///
130   UINT64    TxErrorFrames;
131 
132   ///
133   /// Number of frames transmitted successfully after more than one attempt.
134   ///
135   UINT64    TxRetryFrames;
136 } EFI_NETWORK_STATISTICS;
137 
138 ///
139 /// The state of the network interface.
140 /// When an EFI_SIMPLE_NETWORK_PROTOCOL driver initializes a
141 /// network interface, the network interface is left in the EfiSimpleNetworkStopped state.
142 ///
143 typedef enum {
144   EfiSimpleNetworkStopped,
145   EfiSimpleNetworkStarted,
146   EfiSimpleNetworkInitialized,
147   EfiSimpleNetworkMaxState
148 } EFI_SIMPLE_NETWORK_STATE;
149 
150 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST                0x01
151 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST              0x02
152 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST              0x04
153 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS            0x08
154 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST  0x10
155 
156 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT   0x01
157 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT  0x02
158 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT   0x04
159 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT  0x08
160 
161 #define MAX_MCAST_FILTER_CNT  16
162 typedef struct {
163   ///
164   /// Reports the current state of the network interface.
165   ///
166   UINT32             State;
167   ///
168   /// The size, in bytes, of the network interface's HW address.
169   ///
170   UINT32             HwAddressSize;
171   ///
172   /// The size, in bytes, of the network interface's media header.
173   ///
174   UINT32             MediaHeaderSize;
175   ///
176   /// The maximum size, in bytes, of the packets supported by the network interface.
177   ///
178   UINT32             MaxPacketSize;
179   ///
180   /// The size, in bytes, of the NVRAM device attached to the network interface.
181   ///
182   UINT32             NvRamSize;
183   ///
184   /// The size that must be used for all NVRAM reads and writes. The
185   /// start address for NVRAM read and write operations and the total
186   /// length of those operations, must be a multiple of this value. The
187   /// legal values for this field are 0, 1, 2, 4, and 8.
188   ///
189   UINT32             NvRamAccessSize;
190   ///
191   /// The multicast receive filter settings supported by the network interface.
192   ///
193   UINT32             ReceiveFilterMask;
194   ///
195   /// The current multicast receive filter settings.
196   ///
197   UINT32             ReceiveFilterSetting;
198   ///
199   /// The maximum number of multicast address receive filters supported by the driver.
200   ///
201   UINT32             MaxMCastFilterCount;
202   ///
203   /// The current number of multicast address receive filters.
204   ///
205   UINT32             MCastFilterCount;
206   ///
207   /// Array containing the addresses of the current multicast address receive filters.
208   ///
209   EFI_MAC_ADDRESS    MCastFilter[MAX_MCAST_FILTER_CNT];
210   ///
211   /// The current HW MAC address for the network interface.
212   ///
213   EFI_MAC_ADDRESS    CurrentAddress;
214   ///
215   /// The current HW MAC address for broadcast packets.
216   ///
217   EFI_MAC_ADDRESS    BroadcastAddress;
218   ///
219   /// The permanent HW MAC address for the network interface.
220   ///
221   EFI_MAC_ADDRESS    PermanentAddress;
222   ///
223   /// The interface type of the network interface.
224   ///
225   UINT8              IfType;
226   ///
227   /// TRUE if the HW MAC address can be changed.
228   ///
229   BOOLEAN            MacAddressChangeable;
230   ///
231   /// TRUE if the network interface can transmit more than one packet at a time.
232   ///
233   BOOLEAN            MultipleTxSupported;
234   ///
235   /// TRUE if the presence of media can be determined; otherwise FALSE.
236   ///
237   BOOLEAN            MediaPresentSupported;
238   ///
239   /// TRUE if media are connected to the network interface; otherwise FALSE.
240   ///
241   BOOLEAN            MediaPresent;
242 } EFI_SIMPLE_NETWORK_MODE;
243 
244 //
245 // Protocol Member Functions
246 //
247 
248 /**
249   Changes the state of a network interface from "stopped" to "started".
250 
251   @param  This Protocol instance pointer.
252 
253   @retval EFI_SUCCESS           The network interface was started.
254   @retval EFI_ALREADY_STARTED   The network interface is already in the started state.
255   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
256   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
257   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
258 
259 **/
260 typedef
261 EFI_STATUS
262 (EFIAPI *EFI_SIMPLE_NETWORK_START)(
263   IN EFI_SIMPLE_NETWORK_PROTOCOL  *This
264   );
265 
266 /**
267   Changes the state of a network interface from "started" to "stopped".
268 
269   @param  This Protocol instance pointer.
270 
271   @retval EFI_SUCCESS           The network interface was stopped.
272   @retval EFI_ALREADY_STARTED   The network interface is already in the stopped state.
273   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
274   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
275   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
276 
277 **/
278 typedef
279 EFI_STATUS
280 (EFIAPI *EFI_SIMPLE_NETWORK_STOP)(
281   IN EFI_SIMPLE_NETWORK_PROTOCOL  *This
282   );
283 
284 /**
285   Resets a network adapter and allocates the transmit and receive buffers
286   required by the network interface; optionally, also requests allocation
287   of additional transmit and receive buffers.
288 
289   @param  This              The protocol instance pointer.
290   @param  ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
291                             that the driver should allocate for the network interface.
292                             Some network interfaces will not be able to use the extra
293                             buffer, and the caller will not know if it is actually
294                             being used.
295   @param  ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
296                             that the driver should allocate for the network interface.
297                             Some network interfaces will not be able to use the extra
298                             buffer, and the caller will not know if it is actually
299                             being used.
300 
301   @retval EFI_SUCCESS           The network interface was initialized.
302   @retval EFI_NOT_STARTED       The network interface has not been started.
303   @retval EFI_OUT_OF_RESOURCES  There was not enough memory for the transmit and
304                                 receive buffers.
305   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
306   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
307   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
308 
309 **/
310 typedef
311 EFI_STATUS
312 (EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE)(
313   IN EFI_SIMPLE_NETWORK_PROTOCOL                    *This,
314   IN UINTN                                          ExtraRxBufferSize  OPTIONAL,
315   IN UINTN                                          ExtraTxBufferSize  OPTIONAL
316   );
317 
318 /**
319   Resets a network adapter and re-initializes it with the parameters that were
320   provided in the previous call to Initialize().
321 
322   @param  This                 The protocol instance pointer.
323   @param  ExtendedVerification Indicates that the driver may perform a more
324                                exhaustive verification operation of the device
325                                during reset.
326 
327   @retval EFI_SUCCESS           The network interface was reset.
328   @retval EFI_NOT_STARTED       The network interface has not been started.
329   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
330   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
331   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
332 
333 **/
334 typedef
335 EFI_STATUS
336 (EFIAPI *EFI_SIMPLE_NETWORK_RESET)(
337   IN EFI_SIMPLE_NETWORK_PROTOCOL   *This,
338   IN BOOLEAN                       ExtendedVerification
339   );
340 
341 /**
342   Resets a network adapter and leaves it in a state that is safe for
343   another driver to initialize.
344 
345   @param  This Protocol instance pointer.
346 
347   @retval EFI_SUCCESS           The network interface was shutdown.
348   @retval EFI_NOT_STARTED       The network interface has not been started.
349   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
350   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
351   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
352 
353 **/
354 typedef
355 EFI_STATUS
356 (EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN)(
357   IN EFI_SIMPLE_NETWORK_PROTOCOL  *This
358   );
359 
360 /**
361   Manages the multicast receive filters of a network interface.
362 
363   @param  This             The protocol instance pointer.
364   @param  Enable           A bit mask of receive filters to enable on the network interface.
365   @param  Disable          A bit mask of receive filters to disable on the network interface.
366   @param  ResetMCastFilter Set to TRUE to reset the contents of the multicast receive
367                            filters on the network interface to their default values.
368   @param  McastFilterCnt   Number of multicast HW MAC addresses in the new
369                            MCastFilter list. This value must be less than or equal to
370                            the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
371                            field is optional if ResetMCastFilter is TRUE.
372   @param  MCastFilter      A pointer to a list of new multicast receive filter HW MAC
373                            addresses. This list will replace any existing multicast
374                            HW MAC address list. This field is optional if
375                            ResetMCastFilter is TRUE.
376 
377   @retval EFI_SUCCESS           The multicast receive filter list was updated.
378   @retval EFI_NOT_STARTED       The network interface has not been started.
379   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
380   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
381   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
382 
383 **/
384 typedef
385 EFI_STATUS
386 (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS)(
387   IN EFI_SIMPLE_NETWORK_PROTOCOL                             *This,
388   IN UINT32                                                  Enable,
389   IN UINT32                                                  Disable,
390   IN BOOLEAN                                                 ResetMCastFilter,
391   IN UINTN                                                   MCastFilterCnt     OPTIONAL,
392   IN EFI_MAC_ADDRESS                                         *MCastFilter OPTIONAL
393   );
394 
395 /**
396   Modifies or resets the current station address, if supported.
397 
398   @param  This  The protocol instance pointer.
399   @param  Reset Flag used to reset the station address to the network interfaces
400                 permanent address.
401   @param  New   The new station address to be used for the network interface.
402 
403   @retval EFI_SUCCESS           The network interfaces station address was updated.
404   @retval EFI_NOT_STARTED       The network interface has not been started.
405   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
406   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
407   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
408 
409 **/
410 typedef
411 EFI_STATUS
412 (EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS)(
413   IN EFI_SIMPLE_NETWORK_PROTOCOL            *This,
414   IN BOOLEAN                                Reset,
415   IN EFI_MAC_ADDRESS                        *New OPTIONAL
416   );
417 
418 /**
419   Resets or collects the statistics on a network interface.
420 
421   @param  This            Protocol instance pointer.
422   @param  Reset           Set to TRUE to reset the statistics for the network interface.
423   @param  StatisticsSize  On input the size, in bytes, of StatisticsTable. On
424                           output the size, in bytes, of the resulting table of
425                           statistics.
426   @param  StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
427                           contains the statistics.
428 
429   @retval EFI_SUCCESS           The statistics were collected from the network interface.
430   @retval EFI_NOT_STARTED       The network interface has not been started.
431   @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer
432                                 size needed to hold the statistics is returned in
433                                 StatisticsSize.
434   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
435   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
436   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
437 
438 **/
439 typedef
440 EFI_STATUS
441 (EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS)(
442   IN EFI_SIMPLE_NETWORK_PROTOCOL          *This,
443   IN BOOLEAN                              Reset,
444   IN OUT UINTN                            *StatisticsSize   OPTIONAL,
445   OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL
446   );
447 
448 /**
449   Converts a multicast IP address to a multicast HW MAC address.
450 
451   @param  This The protocol instance pointer.
452   @param  IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
453                to FALSE if the multicast IP address is IPv4 [RFC 791].
454   @param  IP   The multicast IP address that is to be converted to a multicast
455                HW MAC address.
456   @param  MAC  The multicast HW MAC address that is to be generated from IP.
457 
458   @retval EFI_SUCCESS           The multicast IP address was mapped to the multicast
459                                 HW MAC address.
460   @retval EFI_NOT_STARTED       The network interface has not been started.
461   @retval EFI_BUFFER_TOO_SMALL  The Statistics buffer was too small. The current buffer
462                                 size needed to hold the statistics is returned in
463                                 StatisticsSize.
464   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
465   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
466   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
467 
468 **/
469 typedef
470 EFI_STATUS
471 (EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC)(
472   IN EFI_SIMPLE_NETWORK_PROTOCOL          *This,
473   IN BOOLEAN                              IPv6,
474   IN EFI_IP_ADDRESS                       *IP,
475   OUT EFI_MAC_ADDRESS                     *MAC
476   );
477 
478 /**
479   Performs read and write operations on the NVRAM device attached to a
480   network interface.
481 
482   @param  This       The protocol instance pointer.
483   @param  ReadWrite  TRUE for read operations, FALSE for write operations.
484   @param  Offset     Byte offset in the NVRAM device at which to start the read or
485                      write operation. This must be a multiple of NvRamAccessSize and
486                      less than NvRamSize.
487   @param  BufferSize The number of bytes to read or write from the NVRAM device.
488                      This must also be a multiple of NvramAccessSize.
489   @param  Buffer     A pointer to the data buffer.
490 
491   @retval EFI_SUCCESS           The NVRAM access was performed.
492   @retval EFI_NOT_STARTED       The network interface has not been started.
493   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
494   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
495   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
496 
497 **/
498 typedef
499 EFI_STATUS
500 (EFIAPI *EFI_SIMPLE_NETWORK_NVDATA)(
501   IN EFI_SIMPLE_NETWORK_PROTOCOL          *This,
502   IN BOOLEAN                              ReadWrite,
503   IN UINTN                                Offset,
504   IN UINTN                                BufferSize,
505   IN OUT VOID                             *Buffer
506   );
507 
508 /**
509   Reads the current interrupt status and recycled transmit buffer status from
510   a network interface.
511 
512   @param  This            The protocol instance pointer.
513   @param  InterruptStatus A pointer to the bit mask of the currently active interrupts
514                           If this is NULL, the interrupt status will not be read from
515                           the device. If this is not NULL, the interrupt status will
516                           be read from the device. When the  interrupt status is read,
517                           it will also be cleared. Clearing the transmit  interrupt
518                           does not empty the recycled transmit buffer array.
519   @param  TxBuf           Recycled transmit buffer address. The network interface will
520                           not transmit if its internal recycled transmit buffer array
521                           is full. Reading the transmit buffer does not clear the
522                           transmit interrupt. If this is NULL, then the transmit buffer
523                           status will not be read. If there are no transmit buffers to
524                           recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
525 
526   @retval EFI_SUCCESS           The status of the network interface was retrieved.
527   @retval EFI_NOT_STARTED       The network interface has not been started.
528   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
529   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
530   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
531 
532 **/
533 typedef
534 EFI_STATUS
535 (EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS)(
536   IN EFI_SIMPLE_NETWORK_PROTOCOL          *This,
537   OUT UINT32                              *InterruptStatus OPTIONAL,
538   OUT VOID                                **TxBuf OPTIONAL
539   );
540 
541 /**
542   Places a packet in the transmit queue of a network interface.
543 
544   @param  This       The protocol instance pointer.
545   @param  HeaderSize The size, in bytes, of the media header to be filled in by
546                      the Transmit() function. If HeaderSize is non-zero, then it
547                      must be equal to This->Mode->MediaHeaderSize and the DestAddr
548                      and Protocol parameters must not be NULL.
549   @param  BufferSize The size, in bytes, of the entire packet (media header and
550                      data) to be transmitted through the network interface.
551   @param  Buffer     A pointer to the packet (media header followed by data) to be
552                      transmitted. This parameter cannot be NULL. If HeaderSize is zero,
553                      then the media header in Buffer must already be filled in by the
554                      caller. If HeaderSize is non-zero, then the media header will be
555                      filled in by the Transmit() function.
556   @param  SrcAddr    The source HW MAC address. If HeaderSize is zero, then this parameter
557                      is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
558                      This->Mode->CurrentAddress is used for the source HW MAC address.
559   @param  DestAddr   The destination HW MAC address. If HeaderSize is zero, then this
560                      parameter is ignored.
561   @param  Protocol   The type of header to build. If HeaderSize is zero, then this
562                      parameter is ignored. See RFC 1700, section "Ether Types", for
563                      examples.
564 
565   @retval EFI_SUCCESS           The packet was placed on the transmit queue.
566   @retval EFI_NOT_STARTED       The network interface has not been started.
567   @retval EFI_NOT_READY         The network interface is too busy to accept this transmit request.
568   @retval EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.
569   @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
570   @retval EFI_DEVICE_ERROR      The command could not be sent to the network interface.
571   @retval EFI_UNSUPPORTED       This function is not supported by the network interface.
572 
573 **/
574 typedef
575 EFI_STATUS
576 (EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT)(
577   IN EFI_SIMPLE_NETWORK_PROTOCOL          *This,
578   IN UINTN                                HeaderSize,
579   IN UINTN                                BufferSize,
580   IN VOID                                 *Buffer,
581   IN EFI_MAC_ADDRESS                      *SrcAddr  OPTIONAL,
582   IN EFI_MAC_ADDRESS                      *DestAddr OPTIONAL,
583   IN UINT16                               *Protocol OPTIONAL
584   );
585 
586 /**
587   Receives a packet from a network interface.
588 
589   @param  This       The protocol instance pointer.
590   @param  HeaderSize The size, in bytes, of the media header received on the network
591                      interface. If this parameter is NULL, then the media header size
592                      will not be returned.
593   @param  BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in
594                      bytes, of the packet that was received on the network interface.
595   @param  Buffer     A pointer to the data buffer to receive both the media header and
596                      the data.
597   @param  SrcAddr    The source HW MAC address. If this parameter is NULL, the
598                      HW MAC source address will not be extracted from the media
599                      header.
600   @param  DestAddr   The destination HW MAC address. If this parameter is NULL,
601                      the HW MAC destination address will not be extracted from the
602                      media header.
603   @param  Protocol   The media header type. If this parameter is NULL, then the
604                      protocol will not be extracted from the media header. See
605                      RFC 1700 section "Ether Types" for examples.
606 
607   @retval  EFI_SUCCESS           The received data was stored in Buffer, and BufferSize has
608                                  been updated to the number of bytes received.
609   @retval  EFI_NOT_STARTED       The network interface has not been started.
610   @retval  EFI_NOT_READY         The network interface is too busy to accept this transmit
611                                  request.
612   @retval  EFI_BUFFER_TOO_SMALL  The BufferSize parameter is too small.
613   @retval  EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
614   @retval  EFI_DEVICE_ERROR      The command could not be sent to the network interface.
615   @retval  EFI_UNSUPPORTED       This function is not supported by the network interface.
616 
617 **/
618 typedef
619 EFI_STATUS
620 (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE)(
621   IN EFI_SIMPLE_NETWORK_PROTOCOL          *This,
622   OUT UINTN                               *HeaderSize OPTIONAL,
623   IN OUT UINTN                            *BufferSize,
624   OUT VOID                                *Buffer,
625   OUT EFI_MAC_ADDRESS                     *SrcAddr    OPTIONAL,
626   OUT EFI_MAC_ADDRESS                     *DestAddr   OPTIONAL,
627   OUT UINT16                              *Protocol   OPTIONAL
628   );
629 
630 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION  0x00010000
631 
632 //
633 // Revision defined in EFI1.1
634 //
635 #define EFI_SIMPLE_NETWORK_INTERFACE_REVISION  EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
636 
637 ///
638 /// The EFI_SIMPLE_NETWORK_PROTOCOL protocol is used to initialize access
639 /// to a network adapter. Once the network adapter initializes,
640 /// the EFI_SIMPLE_NETWORK_PROTOCOL protocol provides services that
641 /// allow packets to be transmitted and received.
642 ///
643 struct _EFI_SIMPLE_NETWORK_PROTOCOL {
644   ///
645   /// Revision of the EFI_SIMPLE_NETWORK_PROTOCOL. All future revisions must
646   /// be backwards compatible. If a future version is not backwards compatible
647   /// it is not the same GUID.
648   ///
649   UINT64                                Revision;
650   EFI_SIMPLE_NETWORK_START              Start;
651   EFI_SIMPLE_NETWORK_STOP               Stop;
652   EFI_SIMPLE_NETWORK_INITIALIZE         Initialize;
653   EFI_SIMPLE_NETWORK_RESET              Reset;
654   EFI_SIMPLE_NETWORK_SHUTDOWN           Shutdown;
655   EFI_SIMPLE_NETWORK_RECEIVE_FILTERS    ReceiveFilters;
656   EFI_SIMPLE_NETWORK_STATION_ADDRESS    StationAddress;
657   EFI_SIMPLE_NETWORK_STATISTICS         Statistics;
658   EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC    MCastIpToMac;
659   EFI_SIMPLE_NETWORK_NVDATA             NvData;
660   EFI_SIMPLE_NETWORK_GET_STATUS         GetStatus;
661   EFI_SIMPLE_NETWORK_TRANSMIT           Transmit;
662   EFI_SIMPLE_NETWORK_RECEIVE            Receive;
663   ///
664   /// Event used with WaitForEvent() to wait for a packet to be received.
665   ///
666   EFI_EVENT                             WaitForPacket;
667   ///
668   /// Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
669   ///
670   EFI_SIMPLE_NETWORK_MODE               *Mode;
671 };
672 
673 extern EFI_GUID  gEfiSimpleNetworkProtocolGuid;
674 
675 #endif
676