2 The EMU_SNP_PROTOCOL provides services to initialize a network interface,
3 transmit packets, receive packets, and close a network interface.
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
7 Portitions copyright (c) 2011, Apple Inc. All rights reserved.
8 SPDX-License-Identifier: BSD-2-Clause-Patent
15 #include <Protocol/SimpleNetwork.h>
17 #define EMU_SNP_PROTOCOL_GUID \
18 { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }
20 typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL
;
24 Register storage for SNP Mode.
26 @param This Protocol instance pointer.
27 @param Mode SimpleNetworkProtocol Mode structure passed into driver.
29 @retval EFI_SUCCESS The network interface was started.
30 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
35 (EFIAPI
*EMU_SNP_CREATE_MAPPING
)(
36 IN EMU_SNP_PROTOCOL
*This
,
37 IN EFI_SIMPLE_NETWORK_MODE
*Mode
42 Changes the state of a network interface from "stopped" to "started".
44 @param This Protocol instance pointer.
46 @retval EFI_SUCCESS The network interface was started.
47 @retval EFI_ALREADY_STARTED The network interface is already in the started state.
48 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
49 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
50 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
55 (EFIAPI
*EMU_SNP_START
)(
56 IN EMU_SNP_PROTOCOL
*This
60 Changes the state of a network interface from "started" to "stopped".
62 @param This Protocol instance pointer.
64 @retval EFI_SUCCESS The network interface was stopped.
65 @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.
66 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
67 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
68 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
73 (EFIAPI
*EMU_SNP_STOP
)(
74 IN EMU_SNP_PROTOCOL
*This
78 Resets a network adapter and allocates the transmit and receive buffers
79 required by the network interface; optionally, also requests allocation
80 of additional transmit and receive buffers.
82 @param This The protocol instance pointer.
83 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
84 that the driver should allocate for the network interface.
85 Some network interfaces will not be able to use the extra
86 buffer, and the caller will not know if it is actually
88 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
89 that the driver should allocate for the network interface.
90 Some network interfaces will not be able to use the extra
91 buffer, and the caller will not know if it is actually
94 @retval EFI_SUCCESS The network interface was initialized.
95 @retval EFI_NOT_STARTED The network interface has not been started.
96 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and
98 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
99 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
100 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
105 (EFIAPI
*EMU_SNP_INITIALIZE
)(
106 IN EMU_SNP_PROTOCOL
*This
,
107 IN UINTN ExtraRxBufferSize OPTIONAL
,
108 IN UINTN ExtraTxBufferSize OPTIONAL
112 Resets a network adapter and re-initializes it with the parameters that were
113 provided in the previous call to Initialize().
115 @param This The protocol instance pointer.
116 @param ExtendedVerification Indicates that the driver may perform a more
117 exhaustive verification operation of the device
120 @retval EFI_SUCCESS The network interface was reset.
121 @retval EFI_NOT_STARTED The network interface has not been started.
122 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
123 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
124 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
129 (EFIAPI
*EMU_SNP_RESET
)(
130 IN EMU_SNP_PROTOCOL
*This
,
131 IN BOOLEAN ExtendedVerification
135 Resets a network adapter and leaves it in a state that is safe for
136 another driver to initialize.
138 @param This Protocol instance pointer.
140 @retval EFI_SUCCESS The network interface was shutdown.
141 @retval EFI_NOT_STARTED The network interface has not been started.
142 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
143 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
144 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
149 (EFIAPI
*EMU_SNP_SHUTDOWN
)(
150 IN EMU_SNP_PROTOCOL
*This
154 Manages the multicast receive filters of a network interface.
156 @param This The protocol instance pointer.
157 @param Enable A bit mask of receive filters to enable on the network interface.
158 @param Disable A bit mask of receive filters to disable on the network interface.
159 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive
160 filters on the network interface to their default values.
161 @param McastFilterCnt Number of multicast HW MAC addresses in the new
162 MCastFilter list. This value must be less than or equal to
163 the MCastFilterCnt field of EMU_SNP_MODE. This
164 field is optional if ResetMCastFilter is TRUE.
165 @param MCastFilter A pointer to a list of new multicast receive filter HW MAC
166 addresses. This list will replace any existing multicast
167 HW MAC address list. This field is optional if
168 ResetMCastFilter is TRUE.
170 @retval EFI_SUCCESS The multicast receive filter list was updated.
171 @retval EFI_NOT_STARTED The network interface has not been started.
172 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
173 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
174 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
179 (EFIAPI
*EMU_SNP_RECEIVE_FILTERS
)(
180 IN EMU_SNP_PROTOCOL
*This
,
183 IN BOOLEAN ResetMCastFilter
,
184 IN UINTN MCastFilterCnt OPTIONAL
,
185 IN EFI_MAC_ADDRESS
*MCastFilter OPTIONAL
189 Modifies or resets the current station address, if supported.
191 @param This The protocol instance pointer.
192 @param Reset Flag used to reset the station address to the network interfaces
194 @param New The new station address to be used for the network interface.
196 @retval EFI_SUCCESS The network interfaces station address was updated.
197 @retval EFI_NOT_STARTED The network interface has not been started.
198 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
199 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
200 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
205 (EFIAPI
*EMU_SNP_STATION_ADDRESS
)(
206 IN EMU_SNP_PROTOCOL
*This
,
208 IN EFI_MAC_ADDRESS
*New OPTIONAL
212 Resets or collects the statistics on a network interface.
214 @param This Protocol instance pointer.
215 @param Reset Set to TRUE to reset the statistics for the network interface.
216 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
217 output the size, in bytes, of the resulting table of
219 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
220 contains the statistics.
222 @retval EFI_SUCCESS The statistics were collected from the network interface.
223 @retval EFI_NOT_STARTED The network interface has not been started.
224 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
225 size needed to hold the statistics is returned in
227 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
228 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
229 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
234 (EFIAPI
*EMU_SNP_STATISTICS
)(
235 IN EMU_SNP_PROTOCOL
*This
,
237 IN OUT UINTN
*StatisticsSize OPTIONAL
,
238 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
242 Converts a multicast IP address to a multicast HW MAC address.
244 @param This The protocol instance pointer.
245 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
246 to FALSE if the multicast IP address is IPv4 [RFC 791].
247 @param IP The multicast IP address that is to be converted to a multicast
249 @param MAC The multicast HW MAC address that is to be generated from IP.
251 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
253 @retval EFI_NOT_STARTED The network interface has not been started.
254 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
255 size needed to hold the statistics is returned in
257 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
258 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
259 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
264 (EFIAPI
*EMU_SNP_MCAST_IP_TO_MAC
)(
265 IN EMU_SNP_PROTOCOL
*This
,
267 IN EFI_IP_ADDRESS
*IP
,
268 OUT EFI_MAC_ADDRESS
*MAC
272 Performs read and write operations on the NVRAM device attached to a
275 @param This The protocol instance pointer.
276 @param ReadWrite TRUE for read operations, FALSE for write operations.
277 @param Offset Byte offset in the NVRAM device at which to start the read or
278 write operation. This must be a multiple of NvRamAccessSize and
280 @param BufferSize The number of bytes to read or write from the NVRAM device.
281 This must also be a multiple of NvramAccessSize.
282 @param Buffer A pointer to the data buffer.
284 @retval EFI_SUCCESS The NVRAM access was performed.
285 @retval EFI_NOT_STARTED The network interface has not been started.
286 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
287 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
288 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
293 (EFIAPI
*EMU_SNP_NVDATA
)(
294 IN EMU_SNP_PROTOCOL
*This
,
295 IN BOOLEAN ReadWrite
,
302 Reads the current interrupt status and recycled transmit buffer status from
305 @param This The protocol instance pointer.
306 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
307 If this is NULL, the interrupt status will not be read from
308 the device. If this is not NULL, the interrupt status will
309 be read from the device. When the interrupt status is read,
310 it will also be cleared. Clearing the transmit interrupt
311 does not empty the recycled transmit buffer array.
312 @param TxBuf Recycled transmit buffer address. The network interface will
313 not transmit if its internal recycled transmit buffer array
314 is full. Reading the transmit buffer does not clear the
315 transmit interrupt. If this is NULL, then the transmit buffer
316 status will not be read. If there are no transmit buffers to
317 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
319 @retval EFI_SUCCESS The status of the network interface was retrieved.
320 @retval EFI_NOT_STARTED The network interface has not been started.
321 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
322 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
323 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
328 (EFIAPI
*EMU_SNP_GET_STATUS
)(
329 IN EMU_SNP_PROTOCOL
*This
,
330 OUT UINT32
*InterruptStatus OPTIONAL
,
331 OUT VOID
**TxBuf OPTIONAL
335 Places a packet in the transmit queue of a network interface.
337 @param This The protocol instance pointer.
338 @param HeaderSize The size, in bytes, of the media header to be filled in by
339 the Transmit() function. If HeaderSize is non-zero, then it
340 must be equal to This->Mode->MediaHeaderSize and the DestAddr
341 and Protocol parameters must not be NULL.
342 @param BufferSize The size, in bytes, of the entire packet (media header and
343 data) to be transmitted through the network interface.
344 @param Buffer A pointer to the packet (media header followed by data) to be
345 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
346 then the media header in Buffer must already be filled in by the
347 caller. If HeaderSize is non-zero, then the media header will be
348 filled in by the Transmit() function.
349 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
350 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
351 This->Mode->CurrentAddress is used for the source HW MAC address.
352 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this
353 parameter is ignored.
354 @param Protocol The type of header to build. If HeaderSize is zero, then this
355 parameter is ignored. See RFC 1700, section "Ether Types", for
358 @retval EFI_SUCCESS The packet was placed on the transmit queue.
359 @retval EFI_NOT_STARTED The network interface has not been started.
360 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
361 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
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
*EMU_SNP_TRANSMIT
)(
370 IN EMU_SNP_PROTOCOL
*This
,
374 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
375 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
376 IN UINT16
*Protocol OPTIONAL
380 Receives a packet from a network interface.
382 @param This The protocol instance pointer.
383 @param HeaderSize The size, in bytes, of the media header received on the network
384 interface. If this parameter is NULL, then the media header size
385 will not be returned.
386 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in
387 bytes, of the packet that was received on the network interface.
388 @param Buffer A pointer to the data buffer to receive both the media header and
390 @param SrcAddr The source HW MAC address. If this parameter is NULL, the
391 HW MAC source address will not be extracted from the media
393 @param DestAddr The destination HW MAC address. If this parameter is NULL,
394 the HW MAC destination address will not be extracted from the
396 @param Protocol The media header type. If this parameter is NULL, then the
397 protocol will not be extracted from the media header. See
398 RFC 1700 section "Ether Types" for examples.
400 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
401 been updated to the number of bytes received.
402 @retval EFI_NOT_STARTED The network interface has not been started.
403 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
405 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
406 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
407 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
408 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
413 (EFIAPI
*EMU_SNP_RECEIVE
)(
414 IN EMU_SNP_PROTOCOL
*This
,
415 OUT UINTN
*HeaderSize OPTIONAL
,
416 IN OUT UINTN
*BufferSize
,
418 OUT EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
419 OUT EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
420 OUT UINT16
*Protocol OPTIONAL
423 #define EMU_SNP_PROTOCOL_REVISION 0x00010000
426 // Revision defined in EFI1.1
428 #define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION
431 /// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices
432 /// from the EFI driver that produces EFI Simple Network Protocol.
434 struct _EMU_SNP_PROTOCOL
{
435 EMU_SNP_CREATE_MAPPING CreateMapping
;
438 EMU_SNP_INITIALIZE Initialize
;
440 EMU_SNP_SHUTDOWN Shutdown
;
441 EMU_SNP_RECEIVE_FILTERS ReceiveFilters
;
442 EMU_SNP_STATION_ADDRESS StationAddress
;
443 EMU_SNP_STATISTICS Statistics
;
444 EMU_SNP_MCAST_IP_TO_MAC MCastIpToMac
;
445 EMU_SNP_NVDATA NvData
;
446 EMU_SNP_GET_STATUS GetStatus
;
447 EMU_SNP_TRANSMIT Transmit
;
448 EMU_SNP_RECEIVE Receive
;
451 extern EFI_GUID gEmuSnpProtocolGuid
;