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