EmuSnp.h 21 KB

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