]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Include/Protocol/EmuSnp.h
EmulatorPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmulatorPkg / Include / Protocol / EmuSnp.h
CommitLineData
572287f8 1/** @file\r
d18d8a1d 2 The EMU_SNP_PROTOCOL provides services to initialize a network interface,\r
572287f8 3 transmit packets, receive packets, and close a network interface.\r
4\r
5\r
6Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
d18d8a1d 7Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
e3ba31da 8SPDX-License-Identifier: BSD-2-Clause-Patent\r
572287f8 9\r
10**/\r
11\r
12#ifndef __EMU_SNP_H__\r
13#define __EMU_SNP_H__\r
14\r
2b59fcd5 15#include <Protocol/SimpleNetwork.h>\r
16\r
572287f8 17#define EMU_SNP_PROTOCOL_GUID \\r
18 { 0xFD5FBE54, 0x8C35, 0xB345, { 0x8A, 0x0F, 0x7A, 0xC8, 0xA5, 0xFD, 0x05, 0x21 } }\r
19\r
20typedef struct _EMU_SNP_PROTOCOL EMU_SNP_PROTOCOL;\r
21\r
22\r
23/**\r
2b59fcd5 24 Register storage for SNP Mode.\r
572287f8 25\r
26 @param This Protocol instance pointer.\r
27 @param Mode SimpleNetworkProtocol Mode structure passed into driver.\r
28\r
29 @retval EFI_SUCCESS The network interface was started.\r
572287f8 30 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
31\r
32**/\r
33typedef\r
34EFI_STATUS\r
35(EFIAPI *EMU_SNP_CREATE_MAPPING)(\r
36 IN EMU_SNP_PROTOCOL *This,\r
37 IN EFI_SIMPLE_NETWORK_MODE *Mode\r
38 );\r
39\r
40\r
41/**\r
42 Changes the state of a network interface from "stopped" to "started".\r
43\r
44 @param This Protocol instance pointer.\r
45\r
46 @retval EFI_SUCCESS The network interface was started.\r
47 @retval EFI_ALREADY_STARTED The network interface is already in the started state.\r
48 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
49 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
50 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
51\r
52**/\r
53typedef\r
54EFI_STATUS\r
55(EFIAPI *EMU_SNP_START)(\r
56 IN EMU_SNP_PROTOCOL *This\r
57 );\r
58\r
59/**\r
60 Changes the state of a network interface from "started" to "stopped".\r
61\r
62 @param This Protocol instance pointer.\r
63\r
64 @retval EFI_SUCCESS The network interface was stopped.\r
65 @retval EFI_ALREADY_STARTED The network interface is already in the stopped state.\r
66 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
67 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
68 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
69\r
70**/\r
71typedef\r
72EFI_STATUS\r
73(EFIAPI *EMU_SNP_STOP)(\r
74 IN EMU_SNP_PROTOCOL *This\r
75 );\r
76\r
77/**\r
d18d8a1d 78 Resets a network adapter and allocates the transmit and receive buffers\r
79 required by the network interface; optionally, also requests allocation\r
572287f8 80 of additional transmit and receive buffers.\r
81\r
82 @param This The protocol instance pointer.\r
83 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer space\r
84 that the driver should allocate for the network interface.\r
85 Some network interfaces will not be able to use the extra\r
86 buffer, and the caller will not know if it is actually\r
87 being used.\r
88 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer space\r
89 that the driver should allocate for the network interface.\r
90 Some network interfaces will not be able to use the extra\r
91 buffer, and the caller will not know if it is actually\r
92 being used.\r
93\r
94 @retval EFI_SUCCESS The network interface was initialized.\r
95 @retval EFI_NOT_STARTED The network interface has not been started.\r
96 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit and\r
97 receive buffers.\r
98 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
99 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
100 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
101\r
102**/\r
103typedef\r
104EFI_STATUS\r
105(EFIAPI *EMU_SNP_INITIALIZE)(\r
106 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 107 IN UINTN ExtraRxBufferSize OPTIONAL,\r
108 IN UINTN ExtraTxBufferSize OPTIONAL\r
572287f8 109 );\r
110\r
111/**\r
d18d8a1d 112 Resets a network adapter and re-initializes it with the parameters that were\r
113 provided in the previous call to Initialize().\r
572287f8 114\r
115 @param This The protocol instance pointer.\r
116 @param ExtendedVerification Indicates that the driver may perform a more\r
117 exhaustive verification operation of the device\r
118 during reset.\r
119\r
120 @retval EFI_SUCCESS The network interface was reset.\r
121 @retval EFI_NOT_STARTED The network interface has not been started.\r
122 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
123 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
124 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
125\r
126**/\r
127typedef\r
128EFI_STATUS\r
129(EFIAPI *EMU_SNP_RESET)(\r
130 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 131 IN BOOLEAN ExtendedVerification\r
572287f8 132 );\r
133\r
134/**\r
d18d8a1d 135 Resets a network adapter and leaves it in a state that is safe for\r
572287f8 136 another driver to initialize.\r
137\r
138 @param This Protocol instance pointer.\r
139\r
140 @retval EFI_SUCCESS The network interface was shutdown.\r
141 @retval EFI_NOT_STARTED The network interface has not been started.\r
142 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
143 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
144 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
145\r
146**/\r
147typedef\r
148EFI_STATUS\r
149(EFIAPI *EMU_SNP_SHUTDOWN)(\r
150 IN EMU_SNP_PROTOCOL *This\r
151 );\r
152\r
153/**\r
154 Manages the multicast receive filters of a network interface.\r
155\r
156 @param This The protocol instance pointer.\r
157 @param Enable A bit mask of receive filters to enable on the network interface.\r
158 @param Disable A bit mask of receive filters to disable on the network interface.\r
159 @param ResetMCastFilter Set to TRUE to reset the contents of the multicast receive\r
160 filters on the network interface to their default values.\r
161 @param McastFilterCnt Number of multicast HW MAC addresses in the new\r
162 MCastFilter list. This value must be less than or equal to\r
163 the MCastFilterCnt field of EMU_SNP_MODE. This\r
164 field is optional if ResetMCastFilter is TRUE.\r
165 @param MCastFilter A pointer to a list of new multicast receive filter HW MAC\r
166 addresses. This list will replace any existing multicast\r
167 HW MAC address list. This field is optional if\r
168 ResetMCastFilter is TRUE.\r
169\r
170 @retval EFI_SUCCESS The multicast receive filter list was updated.\r
171 @retval EFI_NOT_STARTED The network interface has not been started.\r
172 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
173 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
174 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
175\r
176**/\r
177typedef\r
178EFI_STATUS\r
179(EFIAPI *EMU_SNP_RECEIVE_FILTERS)(\r
180 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 181 IN UINT32 Enable,\r
182 IN UINT32 Disable,\r
183 IN BOOLEAN ResetMCastFilter,\r
184 IN UINTN MCastFilterCnt OPTIONAL,\r
185 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL\r
572287f8 186 );\r
187\r
188/**\r
189 Modifies or resets the current station address, if supported.\r
190\r
191 @param This The protocol instance pointer.\r
192 @param Reset Flag used to reset the station address to the network interfaces\r
193 permanent address.\r
194 @param New The new station address to be used for the network interface.\r
195\r
196 @retval EFI_SUCCESS The network interfaces station address was updated.\r
197 @retval EFI_NOT_STARTED The network interface has not been started.\r
198 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
199 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
200 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
201\r
202**/\r
203typedef\r
204EFI_STATUS\r
205(EFIAPI *EMU_SNP_STATION_ADDRESS)(\r
206 IN EMU_SNP_PROTOCOL *This,\r
2b59fcd5 207 IN BOOLEAN Reset,\r
208 IN EFI_MAC_ADDRESS *New OPTIONAL\r
572287f8 209 );\r
210\r
211/**\r
212 Resets or collects the statistics on a network interface.\r
213\r
214 @param This Protocol instance pointer.\r
215 @param Reset Set to TRUE to reset the statistics for the network interface.\r
216 @param StatisticsSize On input the size, in bytes, of StatisticsTable. On\r
217 output the size, in bytes, of the resulting table of\r
218 statistics.\r
219 @param StatisticsTable A pointer to the EFI_NETWORK_STATISTICS structure that\r
220 contains the statistics.\r
221\r
222 @retval EFI_SUCCESS The statistics were collected from the network interface.\r
223 @retval EFI_NOT_STARTED The network interface has not been started.\r
224 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
225 size needed to hold the statistics is returned in\r
226 StatisticsSize.\r
227 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
228 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
229 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
230\r
231**/\r
232typedef\r
233EFI_STATUS\r
234(EFIAPI *EMU_SNP_STATISTICS)(\r
235 IN EMU_SNP_PROTOCOL *This,\r
236 IN BOOLEAN Reset,\r
237 IN OUT UINTN *StatisticsSize OPTIONAL,\r
238 OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL\r
239 );\r
240\r
241/**\r
242 Converts a multicast IP address to a multicast HW MAC address.\r
243\r
244 @param This The protocol instance pointer.\r
245 @param IPv6 Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set\r
246 to FALSE if the multicast IP address is IPv4 [RFC 791].\r
247 @param IP The multicast IP address that is to be converted to a multicast\r
248 HW MAC address.\r
249 @param MAC The multicast HW MAC address that is to be generated from IP.\r
250\r
251 @retval EFI_SUCCESS The multicast IP address was mapped to the multicast\r
252 HW MAC address.\r
253 @retval EFI_NOT_STARTED The network interface has not been started.\r
254 @retval EFI_BUFFER_TOO_SMALL The Statistics buffer was too small. The current buffer\r
255 size needed to hold the statistics is returned in\r
256 StatisticsSize.\r
257 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
258 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
259 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
260\r
261**/\r
262typedef\r
263EFI_STATUS\r
264(EFIAPI *EMU_SNP_MCAST_IP_TO_MAC)(\r
265 IN EMU_SNP_PROTOCOL *This,\r
266 IN BOOLEAN IPv6,\r
267 IN EFI_IP_ADDRESS *IP,\r
268 OUT EFI_MAC_ADDRESS *MAC\r
269 );\r
270\r
271/**\r
d18d8a1d 272 Performs read and write operations on the NVRAM device attached to a\r
572287f8 273 network interface.\r
274\r
275 @param This The protocol instance pointer.\r
276 @param ReadWrite TRUE for read operations, FALSE for write operations.\r
277 @param Offset Byte offset in the NVRAM device at which to start the read or\r
278 write operation. This must be a multiple of NvRamAccessSize and\r
279 less than NvRamSize.\r
280 @param BufferSize The number of bytes to read or write from the NVRAM device.\r
281 This must also be a multiple of NvramAccessSize.\r
282 @param Buffer A pointer to the data buffer.\r
283\r
284 @retval EFI_SUCCESS The NVRAM access was performed.\r
285 @retval EFI_NOT_STARTED The network interface has not been started.\r
286 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
287 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
288 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
289\r
290**/\r
291typedef\r
292EFI_STATUS\r
293(EFIAPI *EMU_SNP_NVDATA)(\r
294 IN EMU_SNP_PROTOCOL *This,\r
295 IN BOOLEAN ReadWrite,\r
296 IN UINTN Offset,\r
297 IN UINTN BufferSize,\r
298 IN OUT VOID *Buffer\r
299 );\r
300\r
301/**\r
d18d8a1d 302 Reads the current interrupt status and recycled transmit buffer status from\r
572287f8 303 a network interface.\r
304\r
305 @param This The protocol instance pointer.\r
306 @param InterruptStatus A pointer to the bit mask of the currently active interrupts\r
307 If this is NULL, the interrupt status will not be read from\r
308 the device. If this is not NULL, the interrupt status will\r
309 be read from the device. When the interrupt status is read,\r
310 it will also be cleared. Clearing the transmit interrupt\r
311 does not empty the recycled transmit buffer array.\r
312 @param TxBuf Recycled transmit buffer address. The network interface will\r
313 not transmit if its internal recycled transmit buffer array\r
314 is full. Reading the transmit buffer does not clear the\r
315 transmit interrupt. If this is NULL, then the transmit buffer\r
316 status will not be read. If there are no transmit buffers to\r
317 recycle and TxBuf is not NULL, * TxBuf will be set to NULL.\r
318\r
319 @retval EFI_SUCCESS The status of the network interface was retrieved.\r
320 @retval EFI_NOT_STARTED The network interface has not been started.\r
321 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
322 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
323 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
324\r
325**/\r
326typedef\r
327EFI_STATUS\r
328(EFIAPI *EMU_SNP_GET_STATUS)(\r
329 IN EMU_SNP_PROTOCOL *This,\r
330 OUT UINT32 *InterruptStatus OPTIONAL,\r
331 OUT VOID **TxBuf OPTIONAL\r
332 );\r
333\r
334/**\r
335 Places a packet in the transmit queue of a network interface.\r
336\r
337 @param This The protocol instance pointer.\r
338 @param HeaderSize The size, in bytes, of the media header to be filled in by\r
339 the Transmit() function. If HeaderSize is non-zero, then it\r
340 must be equal to This->Mode->MediaHeaderSize and the DestAddr\r
341 and Protocol parameters must not be NULL.\r
342 @param BufferSize The size, in bytes, of the entire packet (media header and\r
343 data) to be transmitted through the network interface.\r
344 @param Buffer A pointer to the packet (media header followed by data) to be\r
345 transmitted. This parameter cannot be NULL. If HeaderSize is zero,\r
346 then the media header in Buffer must already be filled in by the\r
347 caller. If HeaderSize is non-zero, then the media header will be\r
348 filled in by the Transmit() function.\r
349 @param SrcAddr The source HW MAC address. If HeaderSize is zero, then this parameter\r
350 is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then\r
351 This->Mode->CurrentAddress is used for the source HW MAC address.\r
352 @param DestAddr The destination HW MAC address. If HeaderSize is zero, then this\r
353 parameter is ignored.\r
354 @param Protocol The type of header to build. If HeaderSize is zero, then this\r
355 parameter is ignored. See RFC 1700, section "Ether Types", for\r
356 examples.\r
357\r
358 @retval EFI_SUCCESS The packet was placed on the transmit queue.\r
359 @retval EFI_NOT_STARTED The network interface has not been started.\r
d18d8a1d 360 @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.\r
572287f8 361 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
362 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
363 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
364 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
365\r
366**/\r
367typedef\r
368EFI_STATUS\r
369(EFIAPI *EMU_SNP_TRANSMIT)(\r
370 IN EMU_SNP_PROTOCOL *This,\r
371 IN UINTN HeaderSize,\r
372 IN UINTN BufferSize,\r
373 IN VOID *Buffer,\r
374 IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r
375 IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r
376 IN UINT16 *Protocol OPTIONAL\r
377 );\r
378\r
379/**\r
380 Receives a packet from a network interface.\r
381\r
382 @param This The protocol instance pointer.\r
383 @param HeaderSize The size, in bytes, of the media header received on the network\r
384 interface. If this parameter is NULL, then the media header size\r
385 will not be returned.\r
386 @param BufferSize On entry, the size, in bytes, of Buffer. On exit, the size, in\r
387 bytes, of the packet that was received on the network interface.\r
388 @param Buffer A pointer to the data buffer to receive both the media header and\r
389 the data.\r
390 @param SrcAddr The source HW MAC address. If this parameter is NULL, the\r
391 HW MAC source address will not be extracted from the media\r
392 header.\r
393 @param DestAddr The destination HW MAC address. If this parameter is NULL,\r
394 the HW MAC destination address will not be extracted from the\r
395 media header.\r
396 @param Protocol The media header type. If this parameter is NULL, then the\r
397 protocol will not be extracted from the media header. See\r
398 RFC 1700 section "Ether Types" for examples.\r
399\r
400 @retval EFI_SUCCESS The received data was stored in Buffer, and BufferSize has\r
401 been updated to the number of bytes received.\r
402 @retval EFI_NOT_STARTED The network interface has not been started.\r
403 @retval EFI_NOT_READY The network interface is too busy to accept this transmit\r
404 request.\r
405 @retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
406 @retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
407 @retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
408 @retval EFI_UNSUPPORTED This function is not supported by the network interface.\r
409\r
410**/\r
411typedef\r
412EFI_STATUS\r
413(EFIAPI *EMU_SNP_RECEIVE)(\r
414 IN EMU_SNP_PROTOCOL *This,\r
415 OUT UINTN *HeaderSize OPTIONAL,\r
416 IN OUT UINTN *BufferSize,\r
417 OUT VOID *Buffer,\r
418 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,\r
419 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,\r
420 OUT UINT16 *Protocol OPTIONAL\r
421 );\r
422\r
423#define EMU_SNP_PROTOCOL_REVISION 0x00010000\r
424\r
425//\r
426// Revision defined in EFI1.1\r
d18d8a1d 427//\r
572287f8 428#define EMU_SNP_INTERFACE_REVISION EMU_SNP_PROTOCOL_REVISION\r
429\r
430///\r
d18d8a1d 431/// The EMU_SNP_PROTOCOL protocol abstracts OS network sercices\r
572287f8 432/// from the EFI driver that produces EFI Simple Network Protocol.\r
433///\r
434struct _EMU_SNP_PROTOCOL {\r
435 EMU_SNP_CREATE_MAPPING CreateMapping;\r
436 EMU_SNP_START Start;\r
437 EMU_SNP_STOP Stop;\r
438 EMU_SNP_INITIALIZE Initialize;\r
439 EMU_SNP_RESET Reset;\r
440 EMU_SNP_SHUTDOWN Shutdown;\r
441 EMU_SNP_RECEIVE_FILTERS ReceiveFilters;\r
442 EMU_SNP_STATION_ADDRESS StationAddress;\r
443 EMU_SNP_STATISTICS Statistics;\r
444 EMU_SNP_MCAST_IP_TO_MAC MCastIpToMac;\r
445 EMU_SNP_NVDATA NvData;\r
446 EMU_SNP_GET_STATUS GetStatus;\r
447 EMU_SNP_TRANSMIT Transmit;\r
448 EMU_SNP_RECEIVE Receive;\r
449};\r
450\r
451extern EFI_GUID gEmuSnpProtocolGuid;\r
452\r
453#endif\r