3 Copyright (c) 2004, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Simple Network protocol as defined in the EFI 1.0 specification.
20 Basic network device abstraction.
29 #ifndef _SIMPLE_NETWORK_H_
30 #define _SIMPLE_NETWORK_H_
32 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
34 0xA19832B9, 0xAC25, 0x11D3, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \
37 EFI_FORWARD_DECLARATION (EFI_SIMPLE_NETWORK_PROTOCOL
);
40 // Simple Network Protocol data structures
44 // Total number of frames received. Includes frames with errors and
50 // Number of valid frames received and copied into receive buffers.
55 // Number of frames below the minimum length for the media.
56 // This would be <64 for ethernet.
58 UINT64 RxUndersizeFrames
;
61 // Number of frames longer than the maxminum length for the
62 // media. This would be >1500 for ethernet.
64 UINT64 RxOversizeFrames
;
67 // Valid frames that were dropped because receive buffers were full.
69 UINT64 RxDroppedFrames
;
72 // Number of valid unicast frames received and not dropped.
74 UINT64 RxUnicastFrames
;
77 // Number of valid broadcast frames received and not dropped.
79 UINT64 RxBroadcastFrames
;
82 // Number of valid mutlicast frames received and not dropped.
84 UINT64 RxMulticastFrames
;
87 // Number of frames w/ CRC or alignment errors.
89 UINT64 RxCrcErrorFrames
;
92 // Total number of bytes received. Includes frames with errors
93 // and dropped frames.
98 // Transmit statistics.
100 UINT64 TxTotalFrames
;
102 UINT64 TxUndersizeFrames
;
103 UINT64 TxOversizeFrames
;
104 UINT64 TxDroppedFrames
;
105 UINT64 TxUnicastFrames
;
106 UINT64 TxBroadcastFrames
;
107 UINT64 TxMulticastFrames
;
108 UINT64 TxCrcErrorFrames
;
112 // Number of collisions detection on this subnet.
117 // Number of frames destined for unsupported protocol.
119 UINT64 UnsupportedProtocol
;
121 } EFI_NETWORK_STATISTICS
;
124 EfiSimpleNetworkStopped
,
125 EfiSimpleNetworkStarted
,
126 EfiSimpleNetworkInitialized
,
127 EfiSimpleNetworkMaxState
128 } EFI_SIMPLE_NETWORK_STATE
;
130 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
131 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
132 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
133 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
134 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
136 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
137 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
138 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
139 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
141 #define MAX_MCAST_FILTER_CNT 16
144 UINT32 HwAddressSize
;
145 UINT32 MediaHeaderSize
;
146 UINT32 MaxPacketSize
;
148 UINT32 NvRamAccessSize
;
149 UINT32 ReceiveFilterMask
;
150 UINT32 ReceiveFilterSetting
;
151 UINT32 MaxMCastFilterCount
;
152 UINT32 MCastFilterCount
;
153 EFI_MAC_ADDRESS MCastFilter
[MAX_MCAST_FILTER_CNT
];
154 EFI_MAC_ADDRESS CurrentAddress
;
155 EFI_MAC_ADDRESS BroadcastAddress
;
156 EFI_MAC_ADDRESS PermanentAddress
;
158 BOOLEAN MacAddressChangeable
;
159 BOOLEAN MultipleTxSupported
;
160 BOOLEAN MediaPresentSupported
;
161 BOOLEAN MediaPresent
;
162 } EFI_SIMPLE_NETWORK_MODE
;
165 // Protocol Member Functions
169 (EFIAPI
*EFI_SIMPLE_NETWORK_START
) (
170 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
175 Changes the state of a network interface from "stopped" to "started".
178 This - Protocol instance pointer.
181 EFI_SUCCESS - The network interface was started.
182 EFI_ALREADY_STARTED - The network interface is already in the started state.
183 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
184 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
185 EFI_UNSUPPORTED - This function is not supported by the network interface.
192 (EFIAPI
*EFI_SIMPLE_NETWORK_STOP
) (
193 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
198 Changes the state of a network interface from "started" to "stopped".
201 This - Protocol instance pointer.
204 EFI_SUCCESS - The network interface was stopped.
205 EFI_ALREADY_STARTED - The network interface is already in the stopped state.
206 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
207 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
208 EFI_UNSUPPORTED - This function is not supported by the network interface.
215 (EFIAPI
*EFI_SIMPLE_NETWORK_INITIALIZE
) (
216 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
217 IN UINTN ExtraRxBufferSize OPTIONAL
,
218 IN UINTN ExtraTxBufferSize OPTIONAL
223 Resets a network adapter and allocates the transmit and receive buffers
224 required by the network interface; optionally, also requests allocation
225 of additional transmit and receive buffers.
228 This - Protocol instance pointer.
229 ExtraRxBufferSize - The size, in bytes, of the extra receive buffer space
230 that the driver should allocate for the network interface.
231 Some network interfaces will not be able to use the extra
232 buffer, and the caller will not know if it is actually
234 ExtraTxBufferSize - The size, in bytes, of the extra transmit buffer space
235 that the driver should allocate for the network interface.
236 Some network interfaces will not be able to use the extra
237 buffer, and the caller will not know if it is actually
241 EFI_SUCCESS - The network interface was initialized.
242 EFI_NOT_STARTED - The network interface has not been started
243 EFI_OUT_OF_RESOURCES - There was not enough memory for the transmit and
245 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
246 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
247 EFI_UNSUPPORTED - This function is not supported by the network interface.
254 (EFIAPI
*EFI_SIMPLE_NETWORK_RESET
) (
255 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
256 IN BOOLEAN ExtendedVerification
261 Resets a network adapter and re-initializes it with the parameters that were
262 provided in the previous call to Initialize().
265 This - Protocol instance pointer.
266 ExtendedVerification - Indicates that the driver may perform a more
267 exhaustive verification operation of the device
272 EFI_SUCCESS - The network interface was reset.
273 EFI_NOT_STARTED - The network interface has not been started
274 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
275 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
276 EFI_UNSUPPORTED - This function is not supported by the network interface.
283 (EFIAPI
*EFI_SIMPLE_NETWORK_SHUTDOWN
) (
284 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
289 Resets a network adapter and leaves it in a state that is safe for
290 another driver to initialize.
293 This - Protocol instance pointer.
296 EFI_SUCCESS - The network interface was shutdown.
297 EFI_NOT_STARTED - The network interface has not been started
298 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
299 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
300 EFI_UNSUPPORTED - This function is not supported by the network interface.
307 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE_FILTERS
) (
308 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
311 IN BOOLEAN ResetMCastFilter
,
312 IN UINTN MCastFilterCnt OPTIONAL
,
313 IN EFI_MAC_ADDRESS
* MCastFilter OPTIONAL
318 Manages the multicast receive filters of a network interface.
321 This - Protocol instance pointer.
322 Enable - A bit mask of receive filters to enable on the network interface.
323 Disable - A bit mask of receive filters to disable on the network interface.
324 ResetMCastFilter - Set to TRUE to reset the contents of the multicast receive
325 filters on the network interface to their default values.
326 McastFilterCnt - Number of multicast HW MAC addresses in the new
327 MCastFilter list. This value must be less than or equal to
328 the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
329 field is optional if ResetMCastFilter is TRUE.
330 MCastFilter - A pointer to a list of new multicast receive filter HW MAC
331 addresses. This list will replace any existing multicast
332 HW MAC address list. This field is optional if
333 ResetMCastFilter is TRUE.
336 EFI_SUCCESS - The multicast receive filter list was updated.
337 EFI_NOT_STARTED - The network interface has not been started
338 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
339 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
340 EFI_UNSUPPORTED - This function is not supported by the network interface.
347 (EFIAPI
*EFI_SIMPLE_NETWORK_STATION_ADDRESS
) (
348 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
350 IN EFI_MAC_ADDRESS
* New OPTIONAL
355 Modifies or resets the current station address, if supported.
358 This - Protocol instance pointer.
359 Reset - Flag used to reset the station address to the network interfaces
361 New - New station address to be used for the network interface.
364 EFI_SUCCESS - The network interfaces station address was updated.
365 EFI_NOT_STARTED - The network interface has not been started
366 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
367 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
368 EFI_UNSUPPORTED - This function is not supported by the network interface.
375 (EFIAPI
*EFI_SIMPLE_NETWORK_STATISTICS
) (
376 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
378 IN OUT UINTN
*StatisticsSize OPTIONAL
,
379 OUT EFI_NETWORK_STATISTICS
* StatisticsTable OPTIONAL
384 Resets or collects the statistics on a network interface.
387 This - Protocol instance pointer.
388 Reset - Set to TRUE to reset the statistics for the network interface.
389 StatisticsSize - On input the size, in bytes, of StatisticsTable. On
390 output the size, in bytes, of the resulting table of
392 StatisticsTable - A pointer to the EFI_NETWORK_STATISTICS structure that
393 contains the statistics.
396 EFI_SUCCESS - The statistics were collected from the network interface.
397 EFI_NOT_STARTED - The network interface has not been started.
398 EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer
399 size needed to hold the statistics is returned in
401 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
402 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
403 EFI_UNSUPPORTED - This function is not supported by the network interface.
410 (EFIAPI
*EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC
) (
411 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
413 IN EFI_IP_ADDRESS
* IP
,
414 OUT EFI_MAC_ADDRESS
* MAC
419 Converts a multicast IP address to a multicast HW MAC address.
422 This - Protocol instance pointer.
423 IPv6 - Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
424 to FALSE if the multicast IP address is IPv4 [RFC 791].
425 IP - The multicast IP address that is to be converted to a multicast
427 MAC - The multicast HW MAC address that is to be generated from IP.
430 EFI_SUCCESS - The multicast IP address was mapped to the multicast
432 EFI_NOT_STARTED - The network interface has not been started.
433 EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer
434 size needed to hold the statistics is returned in
436 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
437 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
438 EFI_UNSUPPORTED - This function is not supported by the network interface.
445 (EFIAPI
*EFI_SIMPLE_NETWORK_NVDATA
) (
446 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
447 IN BOOLEAN ReadWrite
,
455 Performs read and write operations on the NVRAM device attached to a
459 This - Protocol instance pointer.
460 ReadWrite - TRUE for read operations, FALSE for write operations.
461 Offset - Byte offset in the NVRAM device at which to start the read or
462 write operation. This must be a multiple of NvRamAccessSize and
464 BufferSize - The number of bytes to read or write from the NVRAM device.
465 This must also be a multiple of NvramAccessSize.
466 Buffer - A pointer to the data buffer.
469 EFI_SUCCESS - The NVRAM access was performed.
470 EFI_NOT_STARTED - The network interface has not been started.
471 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
472 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
473 EFI_UNSUPPORTED - This function is not supported by the network interface.
480 (EFIAPI
*EFI_SIMPLE_NETWORK_GET_STATUS
) (
481 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
482 OUT UINT32
*InterruptStatus OPTIONAL
,
483 OUT VOID
**TxBuf OPTIONAL
488 Reads the current interrupt status and recycled transmit buffer status from
492 This - Protocol instance pointer.
493 InterruptStatus - A pointer to the bit mask of the currently active interrupts
494 If this is NULL, the interrupt status will not be read from
495 the device. If this is not NULL, the interrupt status will
496 be read from the device. When the interrupt status is read,
497 it will also be cleared. Clearing the transmit interrupt
498 does not empty the recycled transmit buffer array.
499 TxBuf - Recycled transmit buffer address. The network interface will
500 not transmit if its internal recycled transmit buffer array
501 is full. Reading the transmit buffer does not clear the
502 transmit interrupt. If this is NULL, then the transmit buffer
503 status will not be read. If there are no transmit buffers to
504 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
507 EFI_SUCCESS - The status of the network interface was retrieved.
508 EFI_NOT_STARTED - The network interface has not been started.
509 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
510 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
511 EFI_UNSUPPORTED - This function is not supported by the network interface.
518 (EFIAPI
*EFI_SIMPLE_NETWORK_TRANSMIT
) (
519 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
523 IN EFI_MAC_ADDRESS
* SrcAddr OPTIONAL
,
524 IN EFI_MAC_ADDRESS
* DestAddr OPTIONAL
,
525 IN UINT16
*Protocol OPTIONAL
530 Places a packet in the transmit queue of a network interface.
533 This - Protocol instance pointer.
534 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 BufferSize - The size, in bytes, of the entire packet (media header and
539 data) to be transmitted through the network interface.
540 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 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 DsetAddr - The destination HW MAC address. If HeaderSize is zero, then this
549 parameter is ignored.
550 Protocol - The type of header to build. If HeaderSize is zero, then this
551 parameter is ignored. See RFC 1700, section "Ether Types", for
555 EFI_SUCCESS - The packet was placed on the transmit queue.
556 EFI_NOT_STARTED - The network interface has not been started.
557 EFI_NOT_READY - The network interface is too busy to accept this transmit
559 EFI_BUFFER_TOO_SMALL - The BufferSize parameter is too small.
560 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
561 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
562 EFI_UNSUPPORTED - This function is not supported by the network interface.
569 (EFIAPI
*EFI_SIMPLE_NETWORK_RECEIVE
) (
570 IN EFI_SIMPLE_NETWORK_PROTOCOL
* This
,
571 OUT UINTN
*HeaderSize OPTIONAL
,
572 IN OUT UINTN
*BufferSize
,
574 OUT EFI_MAC_ADDRESS
* SrcAddr OPTIONAL
,
575 OUT EFI_MAC_ADDRESS
* DestAddr OPTIONAL
,
576 OUT UINT16
*Protocol OPTIONAL
581 Receives a packet from a network interface.
584 This - Protocol instance pointer.
585 HeaderSize - The size, in bytes, of the media header received on the network
586 interface. If this parameter is NULL, then the media header size
587 will not be returned.
588 BufferSize - On entry, the size, in bytes, of Buffer. On exit, the size, in
589 bytes, of the packet that was received on the network interface.
590 Buffer - A pointer to the data buffer to receive both the media header and
592 SrcAddr - The source HW MAC address. If this parameter is NULL, the
593 HW MAC source address will not be extracted from the media
595 DsetAddr - The destination HW MAC address. If this parameter is NULL,
596 the HW MAC destination address will not be extracted from the
598 Protocol - The media header type. If this parameter is NULL, then the
599 protocol will not be extracted from the media header. See
600 RFC 1700 section "Ether Types" for examples.
603 EFI_SUCCESS - The received data was stored in Buffer, and BufferSize has
604 been updated to the number of bytes received.
605 EFI_NOT_STARTED - The network interface has not been started.
606 EFI_NOT_READY - The network interface is too busy to accept this transmit
608 EFI_BUFFER_TOO_SMALL - The BufferSize parameter is too small.
609 EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
610 EFI_DEVICE_ERROR - The command could not be sent to the network interface.
611 EFI_UNSUPPORTED - This function is not supported by the network interface.
616 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
618 typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL
{
620 EFI_SIMPLE_NETWORK_START Start
;
621 EFI_SIMPLE_NETWORK_STOP Stop
;
622 EFI_SIMPLE_NETWORK_INITIALIZE Initialize
;
623 EFI_SIMPLE_NETWORK_RESET Reset
;
624 EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown
;
625 EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters
;
626 EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress
;
627 EFI_SIMPLE_NETWORK_STATISTICS Statistics
;
628 EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac
;
629 EFI_SIMPLE_NETWORK_NVDATA NvData
;
630 EFI_SIMPLE_NETWORK_GET_STATUS GetStatus
;
631 EFI_SIMPLE_NETWORK_TRANSMIT Transmit
;
632 EFI_SIMPLE_NETWORK_RECEIVE Receive
;
633 EFI_EVENT WaitForPacket
;
634 EFI_SIMPLE_NETWORK_MODE
*Mode
;
635 } EFI_SIMPLE_NETWORK_PROTOCOL
;
637 extern EFI_GUID gEfiSimpleNetworkProtocolGuid
;