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
;
23 Register storage for SNP Mode.
25 @param This Protocol instance pointer.
26 @param Mode SimpleNetworkProtocol Mode structure passed into driver.
28 @retval EFI_SUCCESS The network interface was started.
29 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
34 (EFIAPI
*EMU_SNP_CREATE_MAPPING
)(
35 IN EMU_SNP_PROTOCOL
*This
,
36 IN EFI_SIMPLE_NETWORK_MODE
*Mode
40 Changes the state of a network interface from "stopped" to "started".
42 @param This Protocol instance pointer.
44 @retval EFI_SUCCESS The network interface was started.
45 @retval EFI_ALREADY_STARTED The network interface is already in the started state.
46 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
47 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
48 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
53 (EFIAPI
*EMU_SNP_START
)(
54 IN EMU_SNP_PROTOCOL
*This
58 Changes the state of a network interface from "started" to "stopped".
60 @param This Protocol instance pointer.
62 @retval EFI_SUCCESS The network interface was stopped.
63 @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.
64 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
65 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
66 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
71 (EFIAPI
*EMU_SNP_STOP
)(
72 IN EMU_SNP_PROTOCOL
*This
76 Resets a network adapter and allocates the transmit and receive buffers
77 required by the network interface; optionally, also requests allocation
78 of additional transmit and receive buffers.
80 @param This The protocol instance pointer.
81 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space
82 that the driver should allocate for the network interface.
83 Some network interfaces will not be able to use the extra
84 buffer, and the caller will not know if it is actually
86 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space
87 that the driver should allocate for the network interface.
88 Some network interfaces will not be able to use the extra
89 buffer, and the caller will not know if it is actually
92 @retval EFI_SUCCESS The network interface was initialized.
93 @retval EFI_NOT_STARTED The network interface has not been started.
94 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and
96 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
97 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
98 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
103 (EFIAPI
*EMU_SNP_INITIALIZE
)(
104 IN EMU_SNP_PROTOCOL
*This
,
105 IN UINTN ExtraRxBufferSize OPTIONAL
,
106 IN UINTN ExtraTxBufferSize OPTIONAL
110 Resets a network adapter and re-initializes it with the parameters that were
111 provided in the previous call to Initialize().
113 @param This The protocol instance pointer.
114 @param ExtendedVerification Indicates that the driver may perform a more
115 exhaustive verification operation of the device
118 @retval EFI_SUCCESS The network interface was reset.
119 @retval EFI_NOT_STARTED The network interface has not been started.
120 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
121 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
122 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
127 (EFIAPI
*EMU_SNP_RESET
)(
128 IN EMU_SNP_PROTOCOL
*This
,
129 IN BOOLEAN ExtendedVerification
133 Resets a network adapter and leaves it in a state that is safe for
134 another driver to initialize.
136 @param This Protocol instance pointer.
138 @retval EFI_SUCCESS The network interface was shutdown.
139 @retval EFI_NOT_STARTED The network interface has not been started.
140 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
141 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
142 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
147 (EFIAPI
*EMU_SNP_SHUTDOWN
)(
148 IN EMU_SNP_PROTOCOL
*This
152 Manages the multicast receive filters of a network interface.
154 @param This The protocol instance pointer.
155 @param Enable A bit mask of receive filters to enable on the network interface.
156 @param Disable A bit mask of receive filters to disable on the network interface.
157 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive
158 filters on the network interface to their default values.
159 @param McastFilterCnt Number of multicast HW MAC addresses in the new
160 MCastFilter list. This value must be less than or equal to
161 the MCastFilterCnt field of EMU_SNP_MODE. This
162 field is optional if ResetMCastFilter is TRUE.
163 @param MCastFilter A pointer to a list of new multicast receive filter HW MAC
164 addresses. This list will replace any existing multicast
165 HW MAC address list. This field is optional if
166 ResetMCastFilter is TRUE.
168 @retval EFI_SUCCESS The multicast receive filter list was updated.
169 @retval EFI_NOT_STARTED The network interface has not been started.
170 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
171 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
172 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
177 (EFIAPI
*EMU_SNP_RECEIVE_FILTERS
)(
178 IN EMU_SNP_PROTOCOL
*This
,
181 IN BOOLEAN ResetMCastFilter
,
182 IN UINTN MCastFilterCnt OPTIONAL
,
183 IN EFI_MAC_ADDRESS
*MCastFilter OPTIONAL
187 Modifies or resets the current station address, if supported.
189 @param This The protocol instance pointer.
190 @param Reset Flag used to reset the station address to the network interfaces
192 @param New The new station address to be used for the network interface.
194 @retval EFI_SUCCESS The network interfaces station address was updated.
195 @retval EFI_NOT_STARTED The network interface has not been started.
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
*EMU_SNP_STATION_ADDRESS
)(
204 IN EMU_SNP_PROTOCOL
*This
,
206 IN EFI_MAC_ADDRESS
*New OPTIONAL
210 Resets or collects the statistics on a network interface.
212 @param This Protocol instance pointer.
213 @param Reset Set to TRUE to reset the statistics for the network interface.
214 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On
215 output the size, in bytes, of the resulting table of
217 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
218 contains the statistics.
220 @retval EFI_SUCCESS The statistics were collected from the network interface.
221 @retval EFI_NOT_STARTED The network interface has not been started.
222 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
223 size needed to hold the statistics is returned in
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
*EMU_SNP_STATISTICS
)(
233 IN EMU_SNP_PROTOCOL
*This
,
235 IN OUT UINTN
*StatisticsSize OPTIONAL
,
236 OUT EFI_NETWORK_STATISTICS
*StatisticsTable OPTIONAL
240 Converts a multicast IP address to a multicast HW MAC address.
242 @param This The protocol instance pointer.
243 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
244 to FALSE if the multicast IP address is IPv4 [RFC 791].
245 @param IP The multicast IP address that is to be converted to a multicast
247 @param MAC The multicast HW MAC address that is to be generated from IP.
249 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
251 @retval EFI_NOT_STARTED The network interface has not been started.
252 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer
253 size needed to hold the statistics is returned in
255 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
256 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
257 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
262 (EFIAPI
*EMU_SNP_MCAST_IP_TO_MAC
)(
263 IN EMU_SNP_PROTOCOL
*This
,
265 IN EFI_IP_ADDRESS
*IP
,
266 OUT EFI_MAC_ADDRESS
*MAC
270 Performs read and write operations on the NVRAM device attached to a
273 @param This The protocol instance pointer.
274 @param ReadWrite TRUE for read operations, FALSE for write operations.
275 @param Offset Byte offset in the NVRAM device at which to start the read or
276 write operation. This must be a multiple of NvRamAccessSize and
278 @param BufferSize The number of bytes to read or write from the NVRAM device.
279 This must also be a multiple of NvramAccessSize.
280 @param Buffer A pointer to the data buffer.
282 @retval EFI_SUCCESS The NVRAM access was performed.
283 @retval EFI_NOT_STARTED The network interface has not been started.
284 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
285 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
286 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
291 (EFIAPI
*EMU_SNP_NVDATA
)(
292 IN EMU_SNP_PROTOCOL
*This
,
293 IN BOOLEAN ReadWrite
,
300 Reads the current interrupt status and recycled transmit buffer status from
303 @param This The protocol instance pointer.
304 @param InterruptStatus A pointer to the bit mask of the currently active interrupts
305 If this is NULL, the interrupt status will not be read from
306 the device. If this is not NULL, the interrupt status will
307 be read from the device. When the interrupt status is read,
308 it will also be cleared. Clearing the transmit interrupt
309 does not empty the recycled transmit buffer array.
310 @param TxBuf Recycled transmit buffer address. The network interface will
311 not transmit if its internal recycled transmit buffer array
312 is full. Reading the transmit buffer does not clear the
313 transmit interrupt. If this is NULL, then the transmit buffer
314 status will not be read. If there are no transmit buffers to
315 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
317 @retval EFI_SUCCESS The status of the network interface was retrieved.
318 @retval EFI_NOT_STARTED The network interface has not been started.
319 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
320 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
321 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
326 (EFIAPI
*EMU_SNP_GET_STATUS
)(
327 IN EMU_SNP_PROTOCOL
*This
,
328 OUT UINT32
*InterruptStatus OPTIONAL
,
329 OUT VOID
**TxBuf OPTIONAL
333 Places a packet in the transmit queue of a network interface.
335 @param This The protocol instance pointer.
336 @param HeaderSize The size, in bytes, of the media header to be filled in by
337 the Transmit() function. If HeaderSize is non-zero, then it
338 must be equal to This->Mode->MediaHeaderSize and the DestAddr
339 and Protocol parameters must not be NULL.
340 @param BufferSize The size, in bytes, of the entire packet (media header and
341 data) to be transmitted through the network interface.
342 @param Buffer A pointer to the packet (media header followed by data) to be
343 transmitted. This parameter cannot be NULL. If HeaderSize is zero,
344 then the media header in Buffer must already be filled in by the
345 caller. If HeaderSize is non-zero, then the media header will be
346 filled in by the Transmit() function.
347 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter
348 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
349 This->Mode->CurrentAddress is used for the source HW MAC address.
350 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this
351 parameter is ignored.
352 @param Protocol The type of header to build. If HeaderSize is zero, then this
353 parameter is ignored. See RFC 1700, section "Ether Types", for
356 @retval EFI_SUCCESS The packet was placed on the transmit queue.
357 @retval EFI_NOT_STARTED The network interface has not been started.
358 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.
359 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
360 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
361 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
362 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
367 (EFIAPI
*EMU_SNP_TRANSMIT
)(
368 IN EMU_SNP_PROTOCOL
*This
,
372 IN EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
373 IN EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
374 IN UINT16
*Protocol OPTIONAL
378 Receives a packet from a network interface.
380 @param This The protocol instance pointer.
381 @param HeaderSize The size, in bytes, of the media header received on the network
382 interface. If this parameter is NULL, then the media header size
383 will not be returned.
384 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in
385 bytes, of the packet that was received on the network interface.
386 @param Buffer A pointer to the data buffer to receive both the media header and
388 @param SrcAddr The source HW MAC address. If this parameter is NULL, the
389 HW MAC source address will not be extracted from the media
391 @param DestAddr The destination HW MAC address. If this parameter is NULL,
392 the HW MAC destination address will not be extracted from the
394 @param Protocol The media header type. If this parameter is NULL, then the
395 protocol will not be extracted from the media header. See
396 RFC 1700 section "Ether Types" for examples.
398 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has
399 been updated to the number of bytes received.
400 @retval EFI_NOT_STARTED The network interface has not been started.
401 @retval EFI_NOT_READY The network interface is too busy to accept this transmit
403 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.
404 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
405 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.
406 @retval EFI_UNSUPPORTED This function is not supported by the network interface.
411 (EFIAPI
*EMU_SNP_RECEIVE
)(
412 IN EMU_SNP_PROTOCOL
*This
,
413 OUT UINTN
*HeaderSize OPTIONAL
,
414 IN OUT UINTN
*BufferSize
,
416 OUT EFI_MAC_ADDRESS
*SrcAddr OPTIONAL
,
417 OUT EFI_MAC_ADDRESS
*DestAddr OPTIONAL
,
418 OUT UINT16
*Protocol OPTIONAL
421 #define EMU_SNP_PROTOCOL_REVISION 0x00010000
424 // Revision defined in EFI1.1
426 #define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION
429 /// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices
430 /// from the EFI driver that produces EFI Simple Network Protocol.
432 struct _EMU_SNP_PROTOCOL
{
433 EMU_SNP_CREATE_MAPPING CreateMapping
;
436 EMU_SNP_INITIALIZE Initialize
;
438 EMU_SNP_SHUTDOWN Shutdown
;
439 EMU_SNP_RECEIVE_FILTERS ReceiveFilters
;
440 EMU_SNP_STATION_ADDRESS StationAddress
;
441 EMU_SNP_STATISTICS Statistics
;
442 EMU_SNP_MCAST_IP_TO_MAC MCastIpToMac
;
443 EMU_SNP_NVDATA NvData
;
444 EMU_SNP_GET_STATUS GetStatus
;
445 EMU_SNP_TRANSMIT Transmit
;
446 EMU_SNP_RECEIVE Receive
;
449 extern EFI_GUID gEmuSnpProtocolGuid
;