2 The EFI_SIMPLE_NETWORK_PROTOCOL provides services to initialize a network interface,
3 transmit packets, receive packets, and close a network interface.
5 Basic network device abstraction.
12 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
13 SPDX-License-Identifier: BSD-2-Clause-Patent
15 @par Revision Reference:
16 This Protocol is introduced in EFI Specification 1.10.
20 #ifndef __SIMPLE_NETWORK_H__
21 #define __SIMPLE_NETWORK_H__
23 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
25 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } \
28 typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK_PROTOCOL
;
31 /// Protocol defined in EFI1.1.
33 typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK
;
36 /// Simple Network Protocol data structures.
40 /// Total number of frames received. Includes frames with errors and
46 /// Number of valid frames received and copied into receive buffers.
51 /// Number of frames below the minimum length for the media.
52 /// This would be <64 for ethernet.
54 UINT64 RxUndersizeFrames
;
57 /// Number of frames longer than the maxminum length for the
58 /// media. This would be >1500 for ethernet.
60 UINT64 RxOversizeFrames
;
63 /// Valid frames that were dropped because receive buffers were full.
65 UINT64 RxDroppedFrames
;
68 /// Number of valid unicast frames received and not dropped.
70 UINT64 RxUnicastFrames
;
73 /// Number of valid broadcast frames received and not dropped.
75 UINT64 RxBroadcastFrames
;
78 /// Number of valid mutlicast frames received and not dropped.
80 UINT64 RxMulticastFrames
;
83 /// Number of frames w/ CRC or alignment errors.
85 UINT64 RxCrcErrorFrames
;
88 /// Total number of bytes received. Includes frames with errors
89 /// and dropped frames.
94 /// Transmit statistics.
98 UINT64 TxUndersizeFrames
;
99 UINT64 TxOversizeFrames
;
100 UINT64 TxDroppedFrames
;
101 UINT64 TxUnicastFrames
;
102 UINT64 TxBroadcastFrames
;
103 UINT64 TxMulticastFrames
;
104 UINT64 TxCrcErrorFrames
;
108 /// Number of collisions detection on this subnet.
113 /// Number of frames destined for unsupported protocol.
115 UINT64 UnsupportedProtocol
;
118 /// Number of valid frames received that were duplicated.
120 UINT64 RxDuplicatedFrames
;
123 /// Number of encrypted frames received that failed to decrypt.
125 UINT64 RxDecryptErrorFrames
;
128 /// Number of frames that failed to transmit after exceeding the retry limit.
130 UINT64 TxErrorFrames
;
133 /// Number of frames transmitted successfully after more than one attempt.
135 UINT64 TxRetryFrames
;
136 } EFI_NETWORK_STATISTICS
;
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.
144 EfiSimpleNetworkStopped
,
145 EfiSimpleNetworkStarted
,
146 EfiSimpleNetworkInitialized
,
147 EfiSimpleNetworkMaxState
148 } EFI_SIMPLE_NETWORK_STATE
;
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
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
161 #define MAX_MCAST_FILTER_CNT 16
164 /// Reports the current state of the network interface.
168 /// The size, in bytes, of the network interface's HW address.
170 UINT32 HwAddressSize
;
172 /// The size, in bytes, of the network interface's media header.
174 UINT32 MediaHeaderSize
;
176 /// The maximum size, in bytes, of the packets supported by the network interface.
178 UINT32 MaxPacketSize
;
180 /// The size, in bytes, of the NVRAM device attached to the network interface.
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.
189 UINT32 NvRamAccessSize
;
191 /// The multicast receive filter settings supported by the network interface.
193 UINT32 ReceiveFilterMask
;
195 /// The current multicast receive filter settings.
197 UINT32 ReceiveFilterSetting
;
199 /// The maximum number of multicast address receive filters supported by the driver.
201 UINT32 MaxMCastFilterCount
;
203 /// The current number of multicast address receive filters.
205 UINT32 MCastFilterCount
;
207 /// Array containing the addresses of the current multicast address receive filters.
209 EFI_MAC_ADDRESS MCastFilter
[MAX_MCAST_FILTER_CNT
];
211 /// The current HW MAC address for the network interface.
213 EFI_MAC_ADDRESS CurrentAddress
;
215 /// The current HW MAC address for broadcast packets.
217 EFI_MAC_ADDRESS BroadcastAddress
;
219 /// The permanent HW MAC address for the network interface.
221 EFI_MAC_ADDRESS PermanentAddress
;
223 /// The interface type of the network interface.
227 /// TRUE if the HW MAC address can be changed.
229 BOOLEAN MacAddressChangeable
;
231 /// TRUE if the network interface can transmit more than one packet at a time.
233 BOOLEAN MultipleTxSupported
;
235 /// TRUE if the presence of media can be determined; otherwise FALSE.
237 BOOLEAN MediaPresentSupported
;
239 /// TRUE if media are connected to the network interface; otherwise FALSE.
241 BOOLEAN MediaPresent
;
242 } EFI_SIMPLE_NETWORK_MODE
;
245 // Protocol Member Functions
249 Changes the state of a network interface from "stopped" to "started".
251 @param This Protocol instance pointer.
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.
262 (EFIAPI
*EFI_SIMPLE_NETWORK_START
)(
263 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
267 Changes the state of a network interface from "started" to "stopped".
269 @param This Protocol instance pointer.
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.
280 (EFIAPI
*EFI_SIMPLE_NETWORK_STOP
)(
281 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
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.
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
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
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
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.
312 (EFIAPI
*EFI_SIMPLE_NETWORK_INITIALIZE
)(
313 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
314 IN UINTN ExtraRxBufferSize OPTIONAL
,
315 IN UINTN ExtraTxBufferSize OPTIONAL
319 Resets a network adapter and re-initializes it with the parameters that were
320 provided in the previous call to Initialize().
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
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.
336 (EFIAPI
*EFI_SIMPLE_NETWORK_RESET
)(
337 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
338 IN BOOLEAN ExtendedVerification
342 Resets a network adapter and leaves it in a state that is safe for
343 another driver to initialize.
345 @param This Protocol instance pointer.
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.
356 (EFIAPI
*EFI_SIMPLE_NETWORK_SHUTDOWN
)(
357 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
361 Manages the multicast receive filters of a network interface.
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.
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.
386 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE_FILTERS
)(
387 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
390 IN BOOLEAN ResetMCastFilter
,
391 IN UINTN MCastFilterCnt OPTIONAL
,
392 IN EFI_MAC_ADDRESS
*MCastFilter OPTIONAL
396 Modifies or resets the current station address, if supported.
398 @param This The protocol instance pointer.
399 @param Reset Flag used to reset the station address to the network interfaces
401 @param New The new station address to be used for the network interface.
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.
412 (EFIAPI
*EFI_SIMPLE_NETWORK_STATION_ADDRESS
)(
413 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
415 IN EFI_MAC_ADDRESS
*New OPTIONAL
419 Resets or collects the statistics on a network interface.
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
426 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
427 contains the statistics.
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
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.
441 (EFIAPI
*EFI_SIMPLE_NETWORK_STATISTICS
)(
442 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
444 IN OUT UINTN
*StatisticsSize OPTIONAL
,
445 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
449 Converts a multicast IP address to a multicast HW MAC address.
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
456 @param MAC The multicast HW MAC address that is to be generated from IP.
458 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
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
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.
471 (EFIAPI
*EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC
)(
472 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
474 IN EFI_IP_ADDRESS
*IP
,
475 OUT EFI_MAC_ADDRESS
*MAC
479 Performs read and write operations on the NVRAM device attached to a
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
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.
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.
500 (EFIAPI
*EFI_SIMPLE_NETWORK_NVDATA
)(
501 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
502 IN BOOLEAN ReadWrite
,
509 Reads the current interrupt status and recycled transmit buffer status from
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.
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.
535 (EFIAPI
*EFI_SIMPLE_NETWORK_GET_STATUS
)(
536 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
537 OUT UINT32
*InterruptStatus OPTIONAL
,
538 OUT VOID
**TxBuf OPTIONAL
542 Places a packet in the transmit queue of a network interface.
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
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.
576 (EFIAPI
*EFI_SIMPLE_NETWORK_TRANSMIT
)(
577 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
581 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
582 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
583 IN UINT16
*Protocol OPTIONAL
587 Receives a packet from a network interface.
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
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
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
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.
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
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.
620 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE
)(
621 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
622 OUT UINTN
*HeaderSize OPTIONAL
,
623 IN OUT UINTN
*BufferSize
,
625 OUT EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
626 OUT EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
627 OUT UINT16
*Protocol OPTIONAL
630 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
633 // Revision defined in EFI1.1
635 #define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
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.
643 struct _EFI_SIMPLE_NETWORK_PROTOCOL
{
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.
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
;
664 /// Event used with WaitForEvent() to wait for a packet to be received.
666 EFI_EVENT WaitForPacket
;
668 /// Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
670 EFI_SIMPLE_NETWORK_MODE
*Mode
;
673 extern EFI_GUID gEfiSimpleNetworkProtocolGuid
;