2 Simple Network protocol as defined in the UEFI 2.0 specification.
4 Basic network device abstraction.
11 Copyright (c) 2006 - 2008, Intel Corporation
12 All rights reserved. This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #ifndef __SIMPLE_NETWORK_H__
23 #define __SIMPLE_NETWORK_H__
25 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
27 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D } \
30 typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK_PROTOCOL
;
34 /// Protocol defined in EFI1.1.
36 typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK
;
39 /// Simple Network Protocol data structures
43 /// Total number of frames received. Includes frames with errors and
49 /// Number of valid frames received and copied into receive buffers.
54 /// Number of frames below the minimum length for the media.
55 /// This would be <64 for ethernet.
57 UINT64 RxUndersizeFrames
;
60 /// Number of frames longer than the maxminum length for the
61 /// media. This would be >1500 for ethernet.
63 UINT64 RxOversizeFrames
;
66 /// Valid frames that were dropped because receive buffers were full.
68 UINT64 RxDroppedFrames
;
71 /// Number of valid unicast frames received and not dropped.
73 UINT64 RxUnicastFrames
;
76 /// Number of valid broadcast frames received and not dropped.
78 UINT64 RxBroadcastFrames
;
81 /// Number of valid mutlicast frames received and not dropped.
83 UINT64 RxMulticastFrames
;
86 /// Number of frames w/ CRC or alignment errors.
88 UINT64 RxCrcErrorFrames
;
91 /// Total number of bytes received. Includes frames with errors
92 /// and dropped frames.
97 /// Transmit statistics.
101 UINT64 TxUndersizeFrames
;
102 UINT64 TxOversizeFrames
;
103 UINT64 TxDroppedFrames
;
104 UINT64 TxUnicastFrames
;
105 UINT64 TxBroadcastFrames
;
106 UINT64 TxMulticastFrames
;
107 UINT64 TxCrcErrorFrames
;
111 /// Number of collisions detection on this subnet.
116 /// Number of frames destined for unsupported protocol.
118 UINT64 UnsupportedProtocol
;
120 } EFI_NETWORK_STATISTICS
;
123 /// State of the network interface
124 /// When an EFI_SIMPLE_NETWORK_PROTOCOL driver initializes a
125 /// network interface, the network interface is left in the EfiSimpleNetworkStopped state.
128 EfiSimpleNetworkStopped
,
129 EfiSimpleNetworkStarted
,
130 EfiSimpleNetworkInitialized
,
131 EfiSimpleNetworkMaxState
132 } EFI_SIMPLE_NETWORK_STATE
;
134 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
135 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
136 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
137 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
138 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
140 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
141 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
142 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
143 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
145 #define MAX_MCAST_FILTER_CNT 16
148 /// Reports the current state of the network interface.
152 /// The size, in bytes, of the network interface's HW address.
154 UINT32 HwAddressSize
;
156 /// The size, in bytes, of the network interface's media header.
158 UINT32 MediaHeaderSize
;
160 /// The maximum size, in bytes, of the packets supported by the network interface.
162 UINT32 MaxPacketSize
;
164 /// The size, in bytes, of the NVRAM device attached to the network interface.
168 /// The size that must be used for all NVRAM reads and writes. The
169 /// start address for NVRAM read and write operations and the total
170 /// length of those operations, must be a multiple of this value. The
171 /// legal values for this field are 0, 1, 2, 4, and 8.
173 UINT32 NvRamAccessSize
;
175 /// The multicast receive filter settings supported by the network interface.
177 UINT32 ReceiveFilterMask
;
179 /// The current multicast receive filter settings.
181 UINT32 ReceiveFilterSetting
;
183 /// The maximum number of multicast address receive filters supported by the driver.
185 UINT32 MaxMCastFilterCount
;
187 /// The current number of multicast address receive filters.
189 UINT32 MCastFilterCount
;
191 /// Array containing the addresses of the current multicast address receive filters.
193 EFI_MAC_ADDRESS MCastFilter
[MAX_MCAST_FILTER_CNT
];
195 /// The current HW MAC address for the network interface.
197 EFI_MAC_ADDRESS CurrentAddress
;
199 /// The current HW MAC address for broadcast packets.
201 EFI_MAC_ADDRESS BroadcastAddress
;
203 /// The permanent HW MAC address for the network interface.
205 EFI_MAC_ADDRESS PermanentAddress
;
207 /// The interface type of the network interface.
211 /// TRUE if the HW MAC address can be changed.
213 BOOLEAN MacAddressChangeable
;
215 /// TRUE if the network interface can transmit more than one packet at a time.
217 BOOLEAN MultipleTxSupported
;
219 /// TRUE if the presence of media can be determined; otherwise FALSE.
221 BOOLEAN MediaPresentSupported
;
223 /// TRUE if media are connected to the network interface; otherwise FALSE.
225 BOOLEAN MediaPresent
;
226 } EFI_SIMPLE_NETWORK_MODE
;
229 // Protocol Member Functions
232 Changes the state of a network interface from "stopped" to "started".
234 @param This Protocol instance pointer.
236 @retval EFI_SUCCESS The network interface was started.
237 @retval EFI_ALREADY_STARTED The network interface is already in the started state.
238 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
239 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
240 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
245 (EFIAPI
*EFI_SIMPLE_NETWORK_START
)(
246 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
250 Changes the state of a network interface from "started" to "stopped".
252 @param This Protocol instance pointer.
254 @retval EFI_SUCCESS The network interface was stopped.
255 @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.
256 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
257 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
258 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
263 (EFIAPI
*EFI_SIMPLE_NETWORK_STOP
)(
264 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
268 Resets a network adapter and allocates the transmit and receive buffers
269 required by the network interface; optionally, also requests allocation
270 of additional transmit and receive buffers.
272 @param This Protocol instance pointer.
273 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
274 that the driver should allocate for the network interface.
275 Some network interfaces will not be able to use the extra
276 buffer, and the caller will not know if it is actually
278 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
279 that the driver should allocate for the network interface.
280 Some network interfaces will not be able to use the extra
281 buffer, and the caller will not know if it is actually
284 @retval EFI_SUCCESS The network interface was initialized.
285 @retval EFI_NOT_STARTED The network interface has not been started
286 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and
288 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
289 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
290 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
295 (EFIAPI
*EFI_SIMPLE_NETWORK_INITIALIZE
)(
296 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
297 IN UINTN ExtraRxBufferSize OPTIONAL
,
298 IN UINTN ExtraTxBufferSize OPTIONAL
302 Resets a network adapter and re-initializes it with the parameters that were
303 provided in the previous call to Initialize().
305 @param This Protocol instance pointer.
306 @param ExtendedVerification Indicates that the driver may perform a more
307 exhaustive verification operation of the device
310 @retval EFI_SUCCESS The network interface was reset.
311 @retval EFI_NOT_STARTED The network interface has not been started
312 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
313 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
314 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
319 (EFIAPI
*EFI_SIMPLE_NETWORK_RESET
)(
320 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
321 IN BOOLEAN ExtendedVerification
325 Resets a network adapter and leaves it in a state that is safe for
326 another driver to initialize.
328 @param This Protocol instance pointer.
330 @retval EFI_SUCCESS The network interface was shutdown.
331 @retval EFI_NOT_STARTED The network interface has not been started
332 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
333 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
334 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
339 (EFIAPI
*EFI_SIMPLE_NETWORK_SHUTDOWN
)(
340 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
344 Manages the multicast receive filters of a network interface.
346 @param This Protocol instance pointer.
347 @param Enable A bit mask of receive filters to enable on the network interface.
348 @param Disable A bit mask of receive filters to disable on the network interface.
349 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive
350 filters on the network interface to their default values.
351 @param McastFilterCnt Number of multicast HW MAC addresses in the new
352 MCastFilter list. This value must be less than or equal to
353 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
354 field is optional if ResetMCastFilter is TRUE.
355 @param MCastFilter A pointer to a list of new multicast receive filter HW MAC
356 addresses. This list will replace any existing multicast
357 HW MAC address list. This field is optional if
358 ResetMCastFilter is TRUE.
360 @retval EFI_SUCCESS The multicast receive filter list was updated.
361 @retval EFI_NOT_STARTED The network interface has not been started
362 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
363 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
364 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
369 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE_FILTERS
)(
370 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
373 IN BOOLEAN ResetMCastFilter
,
374 IN UINTN MCastFilterCnt OPTIONAL
,
375 IN EFI_MAC_ADDRESS
*MCastFilter OPTIONAL
379 Modifies or resets the current station address, if supported.
381 @param This Protocol instance pointer.
382 @param Reset Flag used to reset the station address to the network interfaces
384 @param New New station address to be used for the network interface.
386 @retval EFI_SUCCESS The network interfaces station address was updated.
387 @retval EFI_NOT_STARTED The network interface has not been started
388 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
389 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
390 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
395 (EFIAPI
*EFI_SIMPLE_NETWORK_STATION_ADDRESS
)(
396 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
398 IN EFI_MAC_ADDRESS
*New OPTIONAL
402 Resets or collects the statistics on a network interface.
404 @param This Protocol instance pointer.
405 @param Reset Set to TRUE to reset the statistics for the network interface.
406 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
407 output the size, in bytes, of the resulting table of
409 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
410 contains the statistics.
412 @retval EFI_SUCCESS The statistics were collected from the network interface.
413 @retval EFI_NOT_STARTED The network interface has not been started.
414 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
415 size needed to hold the statistics is returned in
417 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
418 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
419 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
424 (EFIAPI
*EFI_SIMPLE_NETWORK_STATISTICS
)(
425 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
427 IN OUT UINTN
*StatisticsSize OPTIONAL
,
428 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
432 Converts a multicast IP address to a multicast HW MAC address.
434 @param This Protocol instance pointer.
435 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
436 to FALSE if the multicast IP address is IPv4 [RFC 791].
437 @param IP The multicast IP address that is to be converted to a multicast
439 @param MAC The multicast HW MAC address that is to be generated from IP.
441 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
443 @retval EFI_NOT_STARTED The network interface has not been started.
444 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
445 size needed to hold the statistics is returned in
447 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
448 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
449 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
454 (EFIAPI
*EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC
)(
455 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
457 IN EFI_IP_ADDRESS
*IP
,
458 OUT EFI_MAC_ADDRESS
*MAC
462 Performs read and write operations on the NVRAM device attached to a
465 @param This Protocol instance pointer.
466 @param ReadWrite TRUE for read operations, FALSE for write operations.
467 @param Offset Byte offset in the NVRAM device at which to start the read or
468 write operation. This must be a multiple of NvRamAccessSize and
470 @param BufferSize The number of bytes to read or write from the NVRAM device.
471 This must also be a multiple of NvramAccessSize.
472 @param Buffer A pointer to the data buffer.
474 @retval EFI_SUCCESS The NVRAM access was performed.
475 @retval EFI_NOT_STARTED The network interface has not been started.
476 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
477 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
478 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
483 (EFIAPI
*EFI_SIMPLE_NETWORK_NVDATA
)(
484 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
485 IN BOOLEAN ReadWrite
,
492 Reads the current interrupt status and recycled transmit buffer status from
495 @param This Protocol instance pointer.
496 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
497 If this is NULL, the interrupt status will not be read from
498 the device. If this is not NULL, the interrupt status will
499 be read from the device. When the interrupt status is read,
500 it will also be cleared. Clearing the transmit interrupt
501 does not empty the recycled transmit buffer array.
502 @param TxBuf Recycled transmit buffer address. The network interface will
503 not transmit if its internal recycled transmit buffer array
504 is full. Reading the transmit buffer does not clear the
505 transmit interrupt. If this is NULL, then the transmit buffer
506 status will not be read. If there are no transmit buffers to
507 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
509 @retval EFI_SUCCESS The status of the network interface was retrieved.
510 @retval EFI_NOT_STARTED The network interface has not been started.
511 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
512 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
513 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
518 (EFIAPI
*EFI_SIMPLE_NETWORK_GET_STATUS
)(
519 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
520 OUT UINT32
*InterruptStatus OPTIONAL
,
521 OUT VOID
**TxBuf OPTIONAL
525 Places a packet in the transmit queue of a network interface.
527 @param This Protocol instance pointer.
528 @param HeaderSize The size, in bytes, of the media header to be filled in by
529 the Transmit() function. If HeaderSize is non-zero, then it
530 must be equal to This->Mode->MediaHeaderSize and the DestAddr
531 and Protocol parameters must not be NULL.
532 @param BufferSize The size, in bytes, of the entire packet (media header and
533 data) to be transmitted through the network interface.
534 @param Buffer A pointer to the packet (media header followed by data) to be
535 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
536 then the media header in Buffer must already be filled in by the
537 caller. If HeaderSize is non-zero, then the media header will be
538 filled in by the Transmit() function.
539 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
540 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
541 This->Mode->CurrentAddress is used for the source HW MAC address.
542 @param DsetAddr The destination HW MAC address. If HeaderSize is zero, then this
543 parameter is ignored.
544 @param Protocol The type of header to build. If HeaderSize is zero, then this
545 parameter is ignored. See RFC 1700, section "Ether Types", for
548 @retval EFI_SUCCESS The packet was placed on the transmit queue.
549 @retval EFI_NOT_STARTED The network interface has not been started.
550 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
551 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
552 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
553 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
554 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
559 (EFIAPI
*EFI_SIMPLE_NETWORK_TRANSMIT
)(
560 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
564 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
565 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
566 IN UINT16
*Protocol OPTIONAL
570 Receives a packet from a network interface.
572 @param This Protocol instance pointer.
573 @param HeaderSize The size, in bytes, of the media header received on the network
574 interface. If this parameter is NULL, then the media header size
575 will not be returned.
576 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in
577 bytes, of the packet that was received on the network interface.
578 @param Buffer A pointer to the data buffer to receive both the media header and
580 @param SrcAddr The source HW MAC address. If this parameter is NULL, the
581 HW MAC source address will not be extracted from the media
583 @param DsetAddr The destination HW MAC address. If this parameter is NULL,
584 the HW MAC destination address will not be extracted from the
586 @param Protocol The media header type. If this parameter is NULL, then the
587 protocol will not be extracted from the media header. See
588 RFC 1700 section "Ether Types" for examples.
590 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
591 been updated to the number of bytes received.
592 @retval EFI_NOT_STARTED The network interface has not been started.
593 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
595 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
596 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
597 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
598 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
603 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE
)(
604 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
605 OUT UINTN
*HeaderSize OPTIONAL
,
606 IN OUT UINTN
*BufferSize
,
608 OUT EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
609 OUT EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
610 OUT UINT16
*Protocol OPTIONAL
613 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
616 // Revision defined in EFI1.1
618 #define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
621 /// The EFI_SIMPLE_NETWORK_PROTOCOL protocol is used to initialize access
622 /// to a network adapter. Once the network adapter initializes,
623 /// the EFI_SIMPLE_NETWORK_PROTOCOL protocol provides services that
624 /// allow packets to be transmitted and received.
626 struct _EFI_SIMPLE_NETWORK_PROTOCOL
{
628 /// Revision of the EFI_SIMPLE_NETWORK_PROTOCOL. All future revisions must
629 /// be backwards compatible. If a future version is not backwards compatible
630 /// it is not the same GUID.
633 EFI_SIMPLE_NETWORK_START Start
;
634 EFI_SIMPLE_NETWORK_STOP Stop
;
635 EFI_SIMPLE_NETWORK_INITIALIZE Initialize
;
636 EFI_SIMPLE_NETWORK_RESET Reset
;
637 EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown
;
638 EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters
;
639 EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress
;
640 EFI_SIMPLE_NETWORK_STATISTICS Statistics
;
641 EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac
;
642 EFI_SIMPLE_NETWORK_NVDATA NvData
;
643 EFI_SIMPLE_NETWORK_GET_STATUS GetStatus
;
644 EFI_SIMPLE_NETWORK_TRANSMIT Transmit
;
645 EFI_SIMPLE_NETWORK_RECEIVE Receive
;
647 /// Event used with WaitForEvent() to wait for a packet to be received.
649 EFI_EVENT WaitForPacket
;
651 /// Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
653 EFI_SIMPLE_NETWORK_MODE
*Mode
;
656 extern EFI_GUID gEfiSimpleNetworkProtocolGuid
;