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 - 2010, 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.
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.
21 @par Revision Reference:
22 This Protocol is introduced in EFI Specification 1.10.
26 #ifndef __SIMPLE_NETWORK_H__
27 #define __SIMPLE_NETWORK_H__
29 FILE_LICENCE ( BSD3 );
31 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
33 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } \
36 typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK_PROTOCOL;
40 /// Protocol defined in EFI1.1.
42 typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK;
45 /// Simple Network Protocol data structures.
49 /// Total number of frames received. Includes frames with errors and
55 /// Number of valid frames received and copied into receive buffers.
60 /// Number of frames below the minimum length for the media.
61 /// This would be <64 for ethernet.
63 UINT64 RxUndersizeFrames;
66 /// Number of frames longer than the maxminum length for the
67 /// media. This would be >1500 for ethernet.
69 UINT64 RxOversizeFrames;
72 /// Valid frames that were dropped because receive buffers were full.
74 UINT64 RxDroppedFrames;
77 /// Number of valid unicast frames received and not dropped.
79 UINT64 RxUnicastFrames;
82 /// Number of valid broadcast frames received and not dropped.
84 UINT64 RxBroadcastFrames;
87 /// Number of valid mutlicast frames received and not dropped.
89 UINT64 RxMulticastFrames;
92 /// Number of frames w/ CRC or alignment errors.
94 UINT64 RxCrcErrorFrames;
97 /// Total number of bytes received. Includes frames with errors
98 /// and dropped frames.
103 /// Transmit statistics.
105 UINT64 TxTotalFrames;
107 UINT64 TxUndersizeFrames;
108 UINT64 TxOversizeFrames;
109 UINT64 TxDroppedFrames;
110 UINT64 TxUnicastFrames;
111 UINT64 TxBroadcastFrames;
112 UINT64 TxMulticastFrames;
113 UINT64 TxCrcErrorFrames;
117 /// Number of collisions detection on this subnet.
122 /// Number of frames destined for unsupported protocol.
124 UINT64 UnsupportedProtocol;
126 } EFI_NETWORK_STATISTICS;
129 /// The state of the network interface.
130 /// When an EFI_SIMPLE_NETWORK_PROTOCOL driver initializes a
131 /// network interface, the network interface is left in the EfiSimpleNetworkStopped state.
134 EfiSimpleNetworkStopped,
135 EfiSimpleNetworkStarted,
136 EfiSimpleNetworkInitialized,
137 EfiSimpleNetworkMaxState
138 } EFI_SIMPLE_NETWORK_STATE;
140 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
141 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
142 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
143 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
144 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
146 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
147 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
148 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
149 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
151 #define MAX_MCAST_FILTER_CNT 16
154 /// Reports the current state of the network interface.
158 /// The size, in bytes, of the network interface's HW address.
160 UINT32 HwAddressSize;
162 /// The size, in bytes, of the network interface's media header.
164 UINT32 MediaHeaderSize;
166 /// The maximum size, in bytes, of the packets supported by the network interface.
168 UINT32 MaxPacketSize;
170 /// The size, in bytes, of the NVRAM device attached to the network interface.
174 /// The size that must be used for all NVRAM reads and writes. The
175 /// start address for NVRAM read and write operations and the total
176 /// length of those operations, must be a multiple of this value. The
177 /// legal values for this field are 0, 1, 2, 4, and 8.
179 UINT32 NvRamAccessSize;
181 /// The multicast receive filter settings supported by the network interface.
183 UINT32 ReceiveFilterMask;
185 /// The current multicast receive filter settings.
187 UINT32 ReceiveFilterSetting;
189 /// The maximum number of multicast address receive filters supported by the driver.
191 UINT32 MaxMCastFilterCount;
193 /// The current number of multicast address receive filters.
195 UINT32 MCastFilterCount;
197 /// Array containing the addresses of the current multicast address receive filters.
199 EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT];
201 /// The current HW MAC address for the network interface.
203 EFI_MAC_ADDRESS CurrentAddress;
205 /// The current HW MAC address for broadcast packets.
207 EFI_MAC_ADDRESS BroadcastAddress;
209 /// The permanent HW MAC address for the network interface.
211 EFI_MAC_ADDRESS PermanentAddress;
213 /// The interface type of the network interface.
217 /// TRUE if the HW MAC address can be changed.
219 BOOLEAN MacAddressChangeable;
221 /// TRUE if the network interface can transmit more than one packet at a time.
223 BOOLEAN MultipleTxSupported;
225 /// TRUE if the presence of media can be determined; otherwise FALSE.
227 BOOLEAN MediaPresentSupported;
229 /// TRUE if media are connected to the network interface; otherwise FALSE.
231 BOOLEAN MediaPresent;
232 } EFI_SIMPLE_NETWORK_MODE;
235 // Protocol Member Functions
238 Changes the state of a network interface from "stopped" to "started".
240 @param This Protocol instance pointer.
242 @retval EFI_SUCCESS The network interface was started.
243 @retval EFI_ALREADY_STARTED The network interface is already in the started state.
244 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
245 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
246 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
251 (EFIAPI *EFI_SIMPLE_NETWORK_START)(
252 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
256 Changes the state of a network interface from "started" to "stopped".
258 @param This Protocol instance pointer.
260 @retval EFI_SUCCESS The network interface was stopped.
261 @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.
262 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
263 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
264 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
269 (EFIAPI *EFI_SIMPLE_NETWORK_STOP)(
270 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
274 Resets a network adapter and allocates the transmit and receive buffers
275 required by the network interface; optionally, also requests allocation
276 of additional transmit and receive buffers.
278 @param This The protocol instance pointer.
279 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
280 that the driver should allocate for the network interface.
281 Some network interfaces will not be able to use the extra
282 buffer, and the caller will not know if it is actually
284 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
285 that the driver should allocate for the network interface.
286 Some network interfaces will not be able to use the extra
287 buffer, and the caller will not know if it is actually
290 @retval EFI_SUCCESS The network interface was initialized.
291 @retval EFI_NOT_STARTED The network interface has not been started.
292 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and
294 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
295 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
296 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
301 (EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE)(
302 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
303 IN UINTN ExtraRxBufferSize OPTIONAL,
304 IN UINTN ExtraTxBufferSize OPTIONAL
308 Resets a network adapter and re-initializes it with the parameters that were
309 provided in the previous call to Initialize().
311 @param This The protocol instance pointer.
312 @param ExtendedVerification Indicates that the driver may perform a more
313 exhaustive verification operation of the device
316 @retval EFI_SUCCESS The network interface was reset.
317 @retval EFI_NOT_STARTED The network interface has not been started.
318 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
319 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
320 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
325 (EFIAPI *EFI_SIMPLE_NETWORK_RESET)(
326 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
327 IN BOOLEAN ExtendedVerification
331 Resets a network adapter and leaves it in a state that is safe for
332 another driver to initialize.
334 @param This Protocol instance pointer.
336 @retval EFI_SUCCESS The network interface was shutdown.
337 @retval EFI_NOT_STARTED The network interface has not been started.
338 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
339 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
340 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
345 (EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN)(
346 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
350 Manages the multicast receive filters of a network interface.
352 @param This The protocol instance pointer.
353 @param Enable A bit mask of receive filters to enable on the network interface.
354 @param Disable A bit mask of receive filters to disable on the network interface.
355 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive
356 filters on the network interface to their default values.
357 @param McastFilterCnt Number of multicast HW MAC addresses in the new
358 MCastFilter list. This value must be less than or equal to
359 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
360 field is optional if ResetMCastFilter is TRUE.
361 @param MCastFilter A pointer to a list of new multicast receive filter HW MAC
362 addresses. This list will replace any existing multicast
363 HW MAC address list. This field is optional if
364 ResetMCastFilter is TRUE.
366 @retval EFI_SUCCESS The multicast receive filter list was updated.
367 @retval EFI_NOT_STARTED The network interface has not been started.
368 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
369 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
370 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
375 (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS)(
376 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
379 IN BOOLEAN ResetMCastFilter,
380 IN UINTN MCastFilterCnt OPTIONAL,
381 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
385 Modifies or resets the current station address, if supported.
387 @param This The protocol instance pointer.
388 @param Reset Flag used to reset the station address to the network interfaces
390 @param New The new station address to be used for the network interface.
392 @retval EFI_SUCCESS The network interfaces station address was updated.
393 @retval EFI_NOT_STARTED The network interface has not been started.
394 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
395 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
396 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
401 (EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS)(
402 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
404 IN EFI_MAC_ADDRESS *New OPTIONAL
408 Resets or collects the statistics on a network interface.
410 @param This Protocol instance pointer.
411 @param Reset Set to TRUE to reset the statistics for the network interface.
412 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
413 output the size, in bytes, of the resulting table of
415 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
416 contains the statistics.
418 @retval EFI_SUCCESS The statistics were collected from the network interface.
419 @retval EFI_NOT_STARTED The network interface has not been started.
420 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
421 size needed to hold the statistics is returned in
423 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
424 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
425 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
430 (EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS)(
431 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
433 IN OUT UINTN *StatisticsSize OPTIONAL,
434 OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
438 Converts a multicast IP address to a multicast HW MAC address.
440 @param This The protocol instance pointer.
441 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
442 to FALSE if the multicast IP address is IPv4 [RFC 791].
443 @param IP The multicast IP address that is to be converted to a multicast
445 @param MAC The multicast HW MAC address that is to be generated from IP.
447 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
449 @retval EFI_NOT_STARTED The network interface has not been started.
450 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
451 size needed to hold the statistics is returned in
453 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
454 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
455 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
460 (EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC)(
461 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
463 IN EFI_IP_ADDRESS *IP,
464 OUT EFI_MAC_ADDRESS *MAC
468 Performs read and write operations on the NVRAM device attached to a
471 @param This The protocol instance pointer.
472 @param ReadWrite TRUE for read operations, FALSE for write operations.
473 @param Offset Byte offset in the NVRAM device at which to start the read or
474 write operation. This must be a multiple of NvRamAccessSize and
476 @param BufferSize The number of bytes to read or write from the NVRAM device.
477 This must also be a multiple of NvramAccessSize.
478 @param Buffer A pointer to the data buffer.
480 @retval EFI_SUCCESS The NVRAM access was performed.
481 @retval EFI_NOT_STARTED The network interface has not been started.
482 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
483 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
484 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
489 (EFIAPI *EFI_SIMPLE_NETWORK_NVDATA)(
490 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
491 IN BOOLEAN ReadWrite,
498 Reads the current interrupt status and recycled transmit buffer status from
501 @param This The protocol instance pointer.
502 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
503 If this is NULL, the interrupt status will not be read from
504 the device. If this is not NULL, the interrupt status will
505 be read from the device. When the interrupt status is read,
506 it will also be cleared. Clearing the transmit interrupt
507 does not empty the recycled transmit buffer array.
508 @param TxBuf Recycled transmit buffer address. The network interface will
509 not transmit if its internal recycled transmit buffer array
510 is full. Reading the transmit buffer does not clear the
511 transmit interrupt. If this is NULL, then the transmit buffer
512 status will not be read. If there are no transmit buffers to
513 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
515 @retval EFI_SUCCESS The status of the network interface was retrieved.
516 @retval EFI_NOT_STARTED The network interface has not been started.
517 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
518 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
519 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
524 (EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS)(
525 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
526 OUT UINT32 *InterruptStatus OPTIONAL,
527 OUT VOID **TxBuf OPTIONAL
531 Places a packet in the transmit queue of a network interface.
533 @param This The protocol instance pointer.
534 @param HeaderSize The size, in bytes, of the media header to be filled in by
535 the Transmit() function. If HeaderSize is non-zero, then it
536 must be equal to This->Mode->MediaHeaderSize and the DestAddr
537 and Protocol parameters must not be NULL.
538 @param BufferSize The size, in bytes, of the entire packet (media header and
539 data) to be transmitted through the network interface.
540 @param Buffer A pointer to the packet (media header followed by data) to be
541 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
542 then the media header in Buffer must already be filled in by the
543 caller. If HeaderSize is non-zero, then the media header will be
544 filled in by the Transmit() function.
545 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
546 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
547 This->Mode->CurrentAddress is used for the source HW MAC address.
548 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this
549 parameter is ignored.
550 @param Protocol The type of header to build. If HeaderSize is zero, then this
551 parameter is ignored. See RFC 1700, section "Ether Types", for
554 @retval EFI_SUCCESS The packet was placed on the transmit queue.
555 @retval EFI_NOT_STARTED The network interface has not been started.
556 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
557 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
558 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
559 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
560 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
565 (EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT)(
566 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
570 IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
571 IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
572 IN UINT16 *Protocol OPTIONAL
576 Receives a packet from a network interface.
578 @param This The protocol instance pointer.
579 @param HeaderSize The size, in bytes, of the media header received on the network
580 interface. If this parameter is NULL, then the media header size
581 will not be returned.
582 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in
583 bytes, of the packet that was received on the network interface.
584 @param Buffer A pointer to the data buffer to receive both the media header and
586 @param SrcAddr The source HW MAC address. If this parameter is NULL, the
587 HW MAC source address will not be extracted from the media
589 @param DestAddr The destination HW MAC address. If this parameter is NULL,
590 the HW MAC destination address will not be extracted from the
592 @param Protocol The media header type. If this parameter is NULL, then the
593 protocol will not be extracted from the media header. See
594 RFC 1700 section "Ether Types" for examples.
596 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
597 been updated to the number of bytes received.
598 @retval EFI_NOT_STARTED The network interface has not been started.
599 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
601 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
602 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
603 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
604 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
609 (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE)(
610 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
611 OUT UINTN *HeaderSize OPTIONAL,
612 IN OUT UINTN *BufferSize,
614 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
615 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
616 OUT UINT16 *Protocol OPTIONAL
619 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
622 // Revision defined in EFI1.1
624 #define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
627 /// The EFI_SIMPLE_NETWORK_PROTOCOL protocol is used to initialize access
628 /// to a network adapter. Once the network adapter initializes,
629 /// the EFI_SIMPLE_NETWORK_PROTOCOL protocol provides services that
630 /// allow packets to be transmitted and received.
632 struct _EFI_SIMPLE_NETWORK_PROTOCOL {
634 /// Revision of the EFI_SIMPLE_NETWORK_PROTOCOL. All future revisions must
635 /// be backwards compatible. If a future version is not backwards compatible
636 /// it is not the same GUID.
639 EFI_SIMPLE_NETWORK_START Start;
640 EFI_SIMPLE_NETWORK_STOP Stop;
641 EFI_SIMPLE_NETWORK_INITIALIZE Initialize;
642 EFI_SIMPLE_NETWORK_RESET Reset;
643 EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown;
644 EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters;
645 EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress;
646 EFI_SIMPLE_NETWORK_STATISTICS Statistics;
647 EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac;
648 EFI_SIMPLE_NETWORK_NVDATA NvData;
649 EFI_SIMPLE_NETWORK_GET_STATUS GetStatus;
650 EFI_SIMPLE_NETWORK_TRANSMIT Transmit;
651 EFI_SIMPLE_NETWORK_RECEIVE Receive;
653 /// Event used with WaitForEvent() to wait for a packet to be received.
655 EFI_EVENT WaitForPacket;
657 /// Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
659 EFI_SIMPLE_NETWORK_MODE *Mode;
662 extern EFI_GUID gEfiSimpleNetworkProtocolGuid;