]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/Include/Protocol/EmuSnp.h
EmulatorPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmulatorPkg / Include / Protocol / EmuSnp.h
1 /** @file
2 The EMU_SNP_PROTOCOL provides services to initialize a network interface,
3 transmit packets, receive packets, and close a network interface.
4
5
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
9
10 **/
11
12 #ifndef __EMU_SNP_H__
13 #define __EMU_SNP_H__
14
15 #include <Protocol/SimpleNetwork.h>
16
17 #define EMU_SNP_PROTOCOL_GUID \
18 { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }
19
20 typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL;
21
22
23 /**
24 Register storage for SNP Mode.
25
26 @param This Protocol instance pointer.
27 @param Mode SimpleNetworkProtocol Mode structure passed into driver.
28
29 @retval EFI_SUCCESS The network interface was started.
30 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.
31
32 **/
33 typedef
34 EFI_STATUS
35 (EFIAPI *EMU_SNP_CREATE_MAPPING)(
36 IN EMU_SNP_PROTOCOL *This,
37 IN EFI_SIMPLE_NETWORK_MODE *Mode
38 );
39
40
41 /**
42 Changes the state of a network interface from "stopped" to "started".
43
44 @param This Protocol instance pointer.
45
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.
51
52 **/
53 typedef
54 EFI_STATUS
55 (EFIAPI *EMU_SNP_START)(
56 IN EMU_SNP_PROTOCOL *This
57 );
58
59 /**
60 Changes the state of a network interface from "started" to "stopped".
61
62 @param This Protocol instance pointer.
63
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.
69
70 **/
71 typedef
72 EFI_STATUS
73 (EFIAPI *EMU_SNP_STOP)(
74 IN EMU_SNP_PROTOCOL *This
75 );
76
77 /**
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.
81
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
87 being used.
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
92 being used.
93
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
97 receive buffers.
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.
101
102 **/
103 typedef
104 EFI_STATUS
105 (EFIAPI *EMU_SNP_INITIALIZE)(
106 IN EMU_SNP_PROTOCOL *This,
107 IN UINTN ExtraRxBufferSize OPTIONAL,
108 IN UINTN ExtraTxBufferSize OPTIONAL
109 );
110
111 /**
112 Resets a network adapter and re-initializes it with the parameters that were
113 provided in the previous call to Initialize().
114
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
118 during reset.
119
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.
125
126 **/
127 typedef
128 EFI_STATUS
129 (EFIAPI *EMU_SNP_RESET)(
130 IN EMU_SNP_PROTOCOL *This,
131 IN BOOLEAN ExtendedVerification
132 );
133
134 /**
135 Resets a network adapter and leaves it in a state that is safe for
136 another driver to initialize.
137
138 @param This Protocol instance pointer.
139
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.
145
146 **/
147 typedef
148 EFI_STATUS
149 (EFIAPI *EMU_SNP_SHUTDOWN)(
150 IN EMU_SNP_PROTOCOL *This
151 );
152
153 /**
154 Manages the multicast receive filters of a network interface.
155
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.
169
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.
175
176 **/
177 typedef
178 EFI_STATUS
179 (EFIAPI *EMU_SNP_RECEIVE_FILTERS)(
180 IN EMU_SNP_PROTOCOL *This,
181 IN UINT32 Enable,
182 IN UINT32 Disable,
183 IN BOOLEAN ResetMCastFilter,
184 IN UINTN MCastFilterCnt OPTIONAL,
185 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
186 );
187
188 /**
189 Modifies or resets the current station address, if supported.
190
191 @param This The protocol instance pointer.
192 @param Reset Flag used to reset the station address to the network interfaces
193 permanent address.
194 @param New The new station address to be used for the network interface.
195
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.
201
202 **/
203 typedef
204 EFI_STATUS
205 (EFIAPI *EMU_SNP_STATION_ADDRESS)(
206 IN EMU_SNP_PROTOCOL *This,
207 IN BOOLEAN Reset,
208 IN EFI_MAC_ADDRESS *New OPTIONAL
209 );
210
211 /**
212 Resets or collects the statistics on a network interface.
213
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
218 statistics.
219 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that
220 contains the statistics.
221
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
226 StatisticsSize.
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.
230
231 **/
232 typedef
233 EFI_STATUS
234 (EFIAPI *EMU_SNP_STATISTICS)(
235 IN EMU_SNP_PROTOCOL *This,
236 IN BOOLEAN Reset,
237 IN OUT UINTN *StatisticsSize OPTIONAL,
238 OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
239 );
240
241 /**
242 Converts a multicast IP address to a multicast HW MAC address.
243
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
248 HW MAC address.
249 @param MAC The multicast HW MAC address that is to be generated from IP.
250
251 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast
252 HW MAC address.
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
256 StatisticsSize.
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.
260
261 **/
262 typedef
263 EFI_STATUS
264 (EFIAPI *EMU_SNP_MCAST_IP_TO_MAC)(
265 IN EMU_SNP_PROTOCOL *This,
266 IN BOOLEAN IPv6,
267 IN EFI_IP_ADDRESS *IP,
268 OUT EFI_MAC_ADDRESS *MAC
269 );
270
271 /**
272 Performs read and write operations on the NVRAM device attached to a
273 network interface.
274
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
279 less than NvRamSize.
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.
283
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.
289
290 **/
291 typedef
292 EFI_STATUS
293 (EFIAPI *EMU_SNP_NVDATA)(
294 IN EMU_SNP_PROTOCOL *This,
295 IN BOOLEAN ReadWrite,
296 IN UINTN Offset,
297 IN UINTN BufferSize,
298 IN OUT VOID *Buffer
299 );
300
301 /**
302 Reads the current interrupt status and recycled transmit buffer status from
303 a network interface.
304
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.
318
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.
324
325 **/
326 typedef
327 EFI_STATUS
328 (EFIAPI *EMU_SNP_GET_STATUS)(
329 IN EMU_SNP_PROTOCOL *This,
330 OUT UINT32 *InterruptStatus OPTIONAL,
331 OUT VOID **TxBuf OPTIONAL
332 );
333
334 /**
335 Places a packet in the transmit queue of a network interface.
336
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
356 examples.
357
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.
365
366 **/
367 typedef
368 EFI_STATUS
369 (EFIAPI *EMU_SNP_TRANSMIT)(
370 IN EMU_SNP_PROTOCOL *This,
371 IN UINTN HeaderSize,
372 IN UINTN BufferSize,
373 IN VOID *Buffer,
374 IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
375 IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
376 IN UINT16 *Protocol OPTIONAL
377 );
378
379 /**
380 Receives a packet from a network interface.
381
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
389 the data.
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
392 header.
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
395 media header.
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.
399
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
404 request.
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.
409
410 **/
411 typedef
412 EFI_STATUS
413 (EFIAPI *EMU_SNP_RECEIVE)(
414 IN EMU_SNP_PROTOCOL *This,
415 OUT UINTN *HeaderSize OPTIONAL,
416 IN OUT UINTN *BufferSize,
417 OUT VOID *Buffer,
418 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
419 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
420 OUT UINT16 *Protocol OPTIONAL
421 );
422
423 #define EMU_SNP_PROTOCOL_REVISION 0x00010000
424
425 //
426 // Revision defined in EFI1.1
427 //
428 #define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION
429
430 ///
431 /// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices
432 /// from the EFI driver that produces EFI Simple Network Protocol.
433 ///
434 struct _EMU_SNP_PROTOCOL {
435 EMU_SNP_CREATE_MAPPING CreateMapping;
436 EMU_SNP_START Start;
437 EMU_SNP_STOP Stop;
438 EMU_SNP_INITIALIZE Initialize;
439 EMU_SNP_RESET Reset;
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;
449 };
450
451 extern EFI_GUID gEmuSnpProtocolGuid;
452
453 #endif