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 UINT32 HwAddressSize
;
149 UINT32 MediaHeaderSize
;
150 UINT32 MaxPacketSize
;
152 UINT32 NvRamAccessSize
;
153 UINT32 ReceiveFilterMask
;
154 UINT32 ReceiveFilterSetting
;
155 UINT32 MaxMCastFilterCount
;
156 UINT32 MCastFilterCount
;
157 EFI_MAC_ADDRESS MCastFilter
[MAX_MCAST_FILTER_CNT
];
158 EFI_MAC_ADDRESS CurrentAddress
;
159 EFI_MAC_ADDRESS BroadcastAddress
;
160 EFI_MAC_ADDRESS PermanentAddress
;
162 BOOLEAN MacAddressChangeable
;
163 BOOLEAN MultipleTxSupported
;
164 BOOLEAN MediaPresentSupported
;
165 BOOLEAN MediaPresent
;
166 } EFI_SIMPLE_NETWORK_MODE
;
169 // Protocol Member Functions
172 Changes the state of a network interface from "stopped" to "started".
174 @param This Protocol instance pointer.
176 @retval EFI_SUCCESS The network interface was started.
177 @retval EFI_ALREADY_STARTED The network interface is already in the started state.
178 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
179 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
180 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
185 (EFIAPI
*EFI_SIMPLE_NETWORK_START
)(
186 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
190 Changes the state of a network interface from "started" to "stopped".
192 @param This Protocol instance pointer.
194 @retval EFI_SUCCESS The network interface was stopped.
195 @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.
196 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
197 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
198 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
203 (EFIAPI
*EFI_SIMPLE_NETWORK_STOP
)(
204 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
208 Resets a network adapter and allocates the transmit and receive buffers
209 required by the network interface; optionally, also requests allocation
210 of additional transmit and receive buffers.
212 @param This Protocol instance pointer.
213 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
214 that the driver should allocate for the network interface.
215 Some network interfaces will not be able to use the extra
216 buffer, and the caller will not know if it is actually
218 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
219 that the driver should allocate for the network interface.
220 Some network interfaces will not be able to use the extra
221 buffer, and the caller will not know if it is actually
224 @retval EFI_SUCCESS The network interface was initialized.
225 @retval EFI_NOT_STARTED The network interface has not been started
226 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and
228 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
229 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
230 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
235 (EFIAPI
*EFI_SIMPLE_NETWORK_INITIALIZE
)(
236 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
237 IN UINTN ExtraRxBufferSize OPTIONAL
,
238 IN UINTN ExtraTxBufferSize OPTIONAL
242 Resets a network adapter and re-initializes it with the parameters that were
243 provided in the previous call to Initialize().
245 @param This Protocol instance pointer.
246 @param ExtendedVerification Indicates that the driver may perform a more
247 exhaustive verification operation of the device
250 @retval EFI_SUCCESS The network interface was reset.
251 @retval EFI_NOT_STARTED The network interface has not been started
252 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
253 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
254 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
259 (EFIAPI
*EFI_SIMPLE_NETWORK_RESET
)(
260 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
261 IN BOOLEAN ExtendedVerification
265 Resets a network adapter and leaves it in a state that is safe for
266 another driver to initialize.
268 @param This Protocol instance pointer.
270 @retval EFI_SUCCESS The network interface was shutdown.
271 @retval EFI_NOT_STARTED The network interface has not been started
272 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
273 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
274 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
279 (EFIAPI
*EFI_SIMPLE_NETWORK_SHUTDOWN
)(
280 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
284 Manages the multicast receive filters of a network interface.
286 @param This Protocol instance pointer.
287 @param Enable A bit mask of receive filters to enable on the network interface.
288 @param Disable A bit mask of receive filters to disable on the network interface.
289 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive
290 filters on the network interface to their default values.
291 @param McastFilterCnt Number of multicast HW MAC addresses in the new
292 MCastFilter list. This value must be less than or equal to
293 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
294 field is optional if ResetMCastFilter is TRUE.
295 @param MCastFilter A pointer to a list of new multicast receive filter HW MAC
296 addresses. This list will replace any existing multicast
297 HW MAC address list. This field is optional if
298 ResetMCastFilter is TRUE.
300 @retval EFI_SUCCESS The multicast receive filter list was updated.
301 @retval EFI_NOT_STARTED The network interface has not been started
302 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
303 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
304 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
309 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE_FILTERS
)(
310 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
313 IN BOOLEAN ResetMCastFilter
,
314 IN UINTN MCastFilterCnt OPTIONAL
,
315 IN EFI_MAC_ADDRESS
*MCastFilter OPTIONAL
319 Modifies or resets the current station address, if supported.
321 @param This Protocol instance pointer.
322 @param Reset Flag used to reset the station address to the network interfaces
324 @param New New station address to be used for the network interface.
326 @retval EFI_SUCCESS The network interfaces station address was updated.
327 @retval EFI_NOT_STARTED The network interface has not been started
328 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
329 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
330 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
335 (EFIAPI
*EFI_SIMPLE_NETWORK_STATION_ADDRESS
)(
336 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
338 IN EFI_MAC_ADDRESS
*New OPTIONAL
342 Resets or collects the statistics on a network interface.
344 @param This Protocol instance pointer.
345 @param Reset Set to TRUE to reset the statistics for the network interface.
346 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
347 output the size, in bytes, of the resulting table of
349 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
350 contains the statistics.
352 @retval EFI_SUCCESS The statistics were collected from the network interface.
353 @retval EFI_NOT_STARTED The network interface has not been started.
354 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
355 size needed to hold the statistics is returned in
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.
364 (EFIAPI
*EFI_SIMPLE_NETWORK_STATISTICS
)(
365 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
367 IN OUT UINTN
*StatisticsSize OPTIONAL
,
368 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
372 Converts a multicast IP address to a multicast HW MAC address.
374 @param This Protocol instance pointer.
375 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
376 to FALSE if the multicast IP address is IPv4 [RFC 791].
377 @param IP The multicast IP address that is to be converted to a multicast
379 @param MAC The multicast HW MAC address that is to be generated from IP.
381 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
383 @retval EFI_NOT_STARTED The network interface has not been started.
384 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
385 size needed to hold the statistics is returned in
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.
394 (EFIAPI
*EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC
)(
395 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
397 IN EFI_IP_ADDRESS
*IP
,
398 OUT EFI_MAC_ADDRESS
*MAC
402 Performs read and write operations on the NVRAM device attached to a
405 @param This Protocol instance pointer.
406 @param ReadWrite TRUE for read operations, FALSE for write operations.
407 @param Offset Byte offset in the NVRAM device at which to start the read or
408 write operation. This must be a multiple of NvRamAccessSize and
410 @param BufferSize The number of bytes to read or write from the NVRAM device.
411 This must also be a multiple of NvramAccessSize.
412 @param Buffer A pointer to the data buffer.
414 @retval EFI_SUCCESS The NVRAM access was performed.
415 @retval EFI_NOT_STARTED The network interface has not been started.
416 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
417 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
418 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
423 (EFIAPI
*EFI_SIMPLE_NETWORK_NVDATA
)(
424 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
425 IN BOOLEAN ReadWrite
,
432 Reads the current interrupt status and recycled transmit buffer status from
435 @param This Protocol instance pointer.
436 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
437 If this is NULL, the interrupt status will not be read from
438 the device. If this is not NULL, the interrupt status will
439 be read from the device. When the interrupt status is read,
440 it will also be cleared. Clearing the transmit interrupt
441 does not empty the recycled transmit buffer array.
442 @param TxBuf Recycled transmit buffer address. The network interface will
443 not transmit if its internal recycled transmit buffer array
444 is full. Reading the transmit buffer does not clear the
445 transmit interrupt. If this is NULL, then the transmit buffer
446 status will not be read. If there are no transmit buffers to
447 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
449 @retval EFI_SUCCESS The status of the network interface was retrieved.
450 @retval EFI_NOT_STARTED The network interface has not been started.
451 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
452 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
453 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
458 (EFIAPI
*EFI_SIMPLE_NETWORK_GET_STATUS
)(
459 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
460 OUT UINT32
*InterruptStatus OPTIONAL
,
461 OUT VOID
**TxBuf OPTIONAL
465 Places a packet in the transmit queue of a network interface.
467 @param This Protocol instance pointer.
468 @param HeaderSize The size, in bytes, of the media header to be filled in by
469 the Transmit() function. If HeaderSize is non-zero, then it
470 must be equal to This->Mode->MediaHeaderSize and the DestAddr
471 and Protocol parameters must not be NULL.
472 @param BufferSize The size, in bytes, of the entire packet (media header and
473 data) to be transmitted through the network interface.
474 @param Buffer A pointer to the packet (media header followed by data) to be
475 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
476 then the media header in Buffer must already be filled in by the
477 caller. If HeaderSize is non-zero, then the media header will be
478 filled in by the Transmit() function.
479 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
480 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
481 This->Mode->CurrentAddress is used for the source HW MAC address.
482 @param DsetAddr The destination HW MAC address. If HeaderSize is zero, then this
483 parameter is ignored.
484 @param Protocol The type of header to build. If HeaderSize is zero, then this
485 parameter is ignored. See RFC 1700, section "Ether Types", for
488 @retval EFI_SUCCESS The packet was placed on the transmit queue.
489 @retval EFI_NOT_STARTED The network interface has not been started.
490 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
491 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
492 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
493 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
494 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
499 (EFIAPI
*EFI_SIMPLE_NETWORK_TRANSMIT
)(
500 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
504 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
505 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
506 IN UINT16
*Protocol OPTIONAL
510 Receives a packet from a network interface.
512 @param This Protocol instance pointer.
513 @param HeaderSize The size, in bytes, of the media header received on the network
514 interface. If this parameter is NULL, then the media header size
515 will not be returned.
516 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in
517 bytes, of the packet that was received on the network interface.
518 @param Buffer A pointer to the data buffer to receive both the media header and
520 @param SrcAddr The source HW MAC address. If this parameter is NULL, the
521 HW MAC source address will not be extracted from the media
523 @param DsetAddr The destination HW MAC address. If this parameter is NULL,
524 the HW MAC destination address will not be extracted from the
526 @param Protocol The media header type. If this parameter is NULL, then the
527 protocol will not be extracted from the media header. See
528 RFC 1700 section "Ether Types" for examples.
530 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
531 been updated to the number of bytes received.
532 @retval EFI_NOT_STARTED The network interface has not been started.
533 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
535 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
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.
543 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE
)(
544 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
545 OUT UINTN
*HeaderSize OPTIONAL
,
546 IN OUT UINTN
*BufferSize
,
548 OUT EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
549 OUT EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
550 OUT UINT16
*Protocol OPTIONAL
553 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
556 // Revision defined in EFI1.1
558 #define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
561 /// The EFI_SIMPLE_NETWORK_PROTOCOL protocol is used to initialize access
562 /// to a network adapter. Once the network adapter initializes,
563 /// the EFI_SIMPLE_NETWORK_PROTOCOL protocol provides services that
564 /// allow packets to be transmitted and received.
566 struct _EFI_SIMPLE_NETWORK_PROTOCOL
{
568 /// Revision of the EFI_SIMPLE_NETWORK_PROTOCOL. All future revisions must
569 /// be backwards compatible. If a future version is not backwards compatible
570 /// it is not the same GUID.
573 EFI_SIMPLE_NETWORK_START Start
;
574 EFI_SIMPLE_NETWORK_STOP Stop
;
575 EFI_SIMPLE_NETWORK_INITIALIZE Initialize
;
576 EFI_SIMPLE_NETWORK_RESET Reset
;
577 EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown
;
578 EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters
;
579 EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress
;
580 EFI_SIMPLE_NETWORK_STATISTICS Statistics
;
581 EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac
;
582 EFI_SIMPLE_NETWORK_NVDATA NvData
;
583 EFI_SIMPLE_NETWORK_GET_STATUS GetStatus
;
584 EFI_SIMPLE_NETWORK_TRANSMIT Transmit
;
585 EFI_SIMPLE_NETWORK_RECEIVE Receive
;
587 /// Event used with WaitForEvent() to wait for a packet to be received.
589 EFI_EVENT WaitForPacket
;
591 /// Pointer to the EFI_SIMPLE_NETWORK_MODE data for the device.
593 EFI_SIMPLE_NETWORK_MODE
*Mode
;
596 extern EFI_GUID gEfiSimpleNetworkProtocolGuid
;