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