2 Simple Network protocol as defined in the EFI 1.0 specification.
4 Basic network device abstraction.
11 Copyright (c) 2006, 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 EfiSimpleNetworkStopped
,
124 EfiSimpleNetworkStarted
,
125 EfiSimpleNetworkInitialized
,
126 EfiSimpleNetworkMaxState
127 } EFI_SIMPLE_NETWORK_STATE
;
129 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
130 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
131 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
132 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
133 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
135 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
136 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
137 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
138 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
140 #define MAX_MCAST_FILTER_CNT 16
143 UINT32 HwAddressSize
;
144 UINT32 MediaHeaderSize
;
145 UINT32 MaxPacketSize
;
147 UINT32 NvRamAccessSize
;
148 UINT32 ReceiveFilterMask
;
149 UINT32 ReceiveFilterSetting
;
150 UINT32 MaxMCastFilterCount
;
151 UINT32 MCastFilterCount
;
152 EFI_MAC_ADDRESS MCastFilter
[MAX_MCAST_FILTER_CNT
];
153 EFI_MAC_ADDRESS CurrentAddress
;
154 EFI_MAC_ADDRESS BroadcastAddress
;
155 EFI_MAC_ADDRESS PermanentAddress
;
157 BOOLEAN MacAddressChangeable
;
158 BOOLEAN MultipleTxSupported
;
159 BOOLEAN MediaPresentSupported
;
160 BOOLEAN MediaPresent
;
161 } EFI_SIMPLE_NETWORK_MODE
;
164 // Protocol Member Functions
167 Changes the state of a network interface from "stopped" to "started".
169 @param This Protocol instance pointer.
171 @retval EFI_SUCCESS The network interface was started.
172 @retval EFI_ALREADY_STARTED The network interface is already in the started state.
173 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
174 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
175 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
180 (EFIAPI
*EFI_SIMPLE_NETWORK_START
) (
181 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
186 Changes the state of a network interface from "started" to "stopped".
188 @param This Protocol instance pointer.
190 @retval EFI_SUCCESS The network interface was stopped.
191 @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.
192 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
193 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
194 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
199 (EFIAPI
*EFI_SIMPLE_NETWORK_STOP
) (
200 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
205 Resets a network adapter and allocates the transmit and receive buffers
206 required by the network interface; optionally, also requests allocation
207 of additional transmit and receive buffers.
209 @param This Protocol instance pointer.
210 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
211 that the driver should allocate for the network interface.
212 Some network interfaces will not be able to use the extra
213 buffer, and the caller will not know if it is actually
215 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
216 that the driver should allocate for the network interface.
217 Some network interfaces will not be able to use the extra
218 buffer, and the caller will not know if it is actually
221 @retval EFI_SUCCESS The network interface was initialized.
222 @retval EFI_NOT_STARTED The network interface has not been started
223 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and
225 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
226 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
227 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
232 (EFIAPI
*EFI_SIMPLE_NETWORK_INITIALIZE
) (
233 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
234 IN UINTN ExtraRxBufferSize OPTIONAL
,
235 IN UINTN ExtraTxBufferSize OPTIONAL
240 Resets a network adapter and re-initializes it with the parameters that were
241 provided in the previous call to Initialize().
243 @param This Protocol instance pointer.
244 @param ExtendedVerification Indicates that the driver may perform a more
245 exhaustive verification operation of the device
248 @retval EFI_SUCCESS The network interface was reset.
249 @retval EFI_NOT_STARTED The network interface has not been started
250 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
251 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
252 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
257 (EFIAPI
*EFI_SIMPLE_NETWORK_RESET
) (
258 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
259 IN BOOLEAN ExtendedVerification
264 Resets a network adapter and leaves it in a state that is safe for
265 another driver to initialize.
267 @param This Protocol instance pointer.
269 @retval EFI_SUCCESS The network interface was shutdown.
270 @retval EFI_NOT_STARTED The network interface has not been started
271 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
272 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
273 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
278 (EFIAPI
*EFI_SIMPLE_NETWORK_SHUTDOWN
) (
279 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
320 Modifies or resets the current station address, if supported.
322 @param This Protocol instance pointer.
323 @param Reset Flag used to reset the station address to the network interfaces
325 @param New New station address to be used for the network interface.
327 @retval EFI_SUCCESS The network interfaces station address was updated.
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_STATION_ADDRESS
) (
337 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
339 IN EFI_MAC_ADDRESS
*New OPTIONAL
344 Resets or collects the statistics on a network interface.
346 @param This Protocol instance pointer.
347 @param Reset Set to TRUE to reset the statistics for the network interface.
348 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
349 output the size, in bytes, of the resulting table of
351 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
352 contains the statistics.
354 @retval EFI_SUCCESS The statistics were collected from the network interface.
355 @retval EFI_NOT_STARTED The network interface has not been started.
356 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
357 size needed to hold the statistics is returned in
359 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
360 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
361 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
366 (EFIAPI
*EFI_SIMPLE_NETWORK_STATISTICS
) (
367 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
369 IN OUT UINTN
*StatisticsSize OPTIONAL
,
370 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
375 Converts a multicast IP address to a multicast HW MAC address.
377 @param This Protocol instance pointer.
378 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
379 to FALSE if the multicast IP address is IPv4 [RFC 791].
380 @param IP The multicast IP address that is to be converted to a multicast
382 @param MAC The multicast HW MAC address that is to be generated from IP.
384 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
386 @retval EFI_NOT_STARTED The network interface has not been started.
387 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
388 size needed to hold the statistics is returned in
390 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
391 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
392 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
397 (EFIAPI
*EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC
) (
398 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
400 IN EFI_IP_ADDRESS
*IP
,
401 OUT EFI_MAC_ADDRESS
*MAC
406 Performs read and write operations on the NVRAM device attached to a
409 @param This Protocol instance pointer.
410 @param ReadWrite TRUE for read operations, FALSE for write operations.
411 @param Offset Byte offset in the NVRAM device at which to start the read or
412 write operation. This must be a multiple of NvRamAccessSize and
414 @param BufferSize The number of bytes to read or write from the NVRAM device.
415 This must also be a multiple of NvramAccessSize.
416 @param Buffer A pointer to the data buffer.
418 @retval EFI_SUCCESS The NVRAM access was performed.
419 @retval EFI_NOT_STARTED The network interface has not been started.
420 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
421 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
422 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
427 (EFIAPI
*EFI_SIMPLE_NETWORK_NVDATA
) (
428 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
429 IN BOOLEAN ReadWrite
,
437 Reads the current interrupt status and recycled transmit buffer status from
440 @param This Protocol instance pointer.
441 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
442 If this is NULL, the interrupt status will not be read from
443 the device. If this is not NULL, the interrupt status will
444 be read from the device. When the interrupt status is read,
445 it will also be cleared. Clearing the transmit interrupt
446 does not empty the recycled transmit buffer array.
447 @param TxBuf Recycled transmit buffer address. The network interface will
448 not transmit if its internal recycled transmit buffer array
449 is full. Reading the transmit buffer does not clear the
450 transmit interrupt. If this is NULL, then the transmit buffer
451 status will not be read. If there are no transmit buffers to
452 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
454 @retval EFI_SUCCESS The status of the network interface was retrieved.
455 @retval EFI_NOT_STARTED The network interface has not been started.
456 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
457 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
458 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
463 (EFIAPI
*EFI_SIMPLE_NETWORK_GET_STATUS
) (
464 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
465 OUT UINT32
*InterruptStatus OPTIONAL
,
466 OUT VOID
**TxBuf OPTIONAL
471 Places a packet in the transmit queue of a network interface.
473 @param This Protocol instance pointer.
474 @param HeaderSize The size, in bytes, of the media header to be filled in by
475 the Transmit() function. If HeaderSize is non-zero, then it
476 must be equal to This->Mode->MediaHeaderSize and the DestAddr
477 and Protocol parameters must not be NULL.
478 @param BufferSize The size, in bytes, of the entire packet (media header and
479 data) to be transmitted through the network interface.
480 @param Buffer A pointer to the packet (media header followed by data) to be
481 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
482 then the media header in Buffer must already be filled in by the
483 caller. If HeaderSize is non-zero, then the media header will be
484 filled in by the Transmit() function.
485 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
486 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
487 This->Mode->CurrentAddress is used for the source HW MAC address.
488 @param DsetAddr The destination HW MAC address. If HeaderSize is zero, then this
489 parameter is ignored.
490 @param Protocol The type of header to build. If HeaderSize is zero, then this
491 parameter is ignored. See RFC 1700, section "Ether Types", for
494 @retval EFI_SUCCESS The packet was placed on the transmit queue.
495 @retval EFI_NOT_STARTED The network interface has not been started.
496 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
497 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
498 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
499 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
500 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
505 (EFIAPI
*EFI_SIMPLE_NETWORK_TRANSMIT
) (
506 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
510 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
511 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
512 IN UINT16
*Protocol OPTIONAL
517 Receives a packet from a network interface.
519 @param This Protocol instance pointer.
520 @param HeaderSize The size, in bytes, of the media header received on the network
521 interface. If this parameter is NULL, then the media header size
522 will not be returned.
523 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in
524 bytes, of the packet that was received on the network interface.
525 @param Buffer A pointer to the data buffer to receive both the media header and
527 @param SrcAddr The source HW MAC address. If this parameter is NULL, the
528 HW MAC source address will not be extracted from the media
530 @param DsetAddr The destination HW MAC address. If this parameter is NULL,
531 the HW MAC destination address will not be extracted from the
533 @param Protocol The media header type. If this parameter is NULL, then the
534 protocol will not be extracted from the media header. See
535 RFC 1700 section "Ether Types" for examples.
537 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
538 been updated to the number of bytes received.
539 @retval EFI_NOT_STARTED The network interface has not been started.
540 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
542 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
543 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
544 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
545 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
550 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE
) (
551 IN EFI_SIMPLE_NETWORK_PROTOCOL
*This
,
552 OUT UINTN
*HeaderSize OPTIONAL
,
553 IN OUT UINTN
*BufferSize
,
555 OUT EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
556 OUT EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
557 OUT UINT16
*Protocol OPTIONAL
561 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
564 // Revision defined in EFI1.1
566 #define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
568 struct _EFI_SIMPLE_NETWORK_PROTOCOL
{
570 EFI_SIMPLE_NETWORK_START Start
;
571 EFI_SIMPLE_NETWORK_STOP Stop
;
572 EFI_SIMPLE_NETWORK_INITIALIZE Initialize
;
573 EFI_SIMPLE_NETWORK_RESET Reset
;
574 EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown
;
575 EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters
;
576 EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress
;
577 EFI_SIMPLE_NETWORK_STATISTICS Statistics
;
578 EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac
;
579 EFI_SIMPLE_NETWORK_NVDATA NvData
;
580 EFI_SIMPLE_NETWORK_GET_STATUS GetStatus
;
581 EFI_SIMPLE_NETWORK_TRANSMIT Transmit
;
582 EFI_SIMPLE_NETWORK_RECEIVE Receive
;
583 EFI_EVENT WaitForPacket
;
584 EFI_SIMPLE_NETWORK_MODE
*Mode
;
587 extern EFI_GUID gEfiSimpleNetworkProtocolGuid
;