MnpImpl.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. /** @file
  2. Declaration of structures and functions of MnpDxe driver.
  3. Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _MNP_IMPL_H_
  7. #define _MNP_IMPL_H_
  8. #include "MnpDriver.h"
  9. #define NET_ETHER_FCS_SIZE 4
  10. #define MNP_SYS_POLL_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds
  11. #define MNP_TIMEOUT_CHECK_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds
  12. #define MNP_MEDIA_DETECT_INTERVAL (500 * TICKS_PER_MS) // 500 milliseconds
  13. #define MNP_TX_TIMEOUT_TIME (500 * TICKS_PER_MS) // 500 milliseconds
  14. #define MNP_INIT_NET_BUFFER_NUM 512
  15. #define MNP_NET_BUFFER_INCREASEMENT 64
  16. #define MNP_MAX_NET_BUFFER_NUM 65536
  17. #define MNP_TX_BUFFER_INCREASEMENT 32 // Same as the recycling Q length for xmit_done in UNDI command.
  18. #define MNP_MAX_TX_BUFFER_NUM 65536
  19. #define MNP_MAX_RCVD_PACKET_QUE_SIZE 256
  20. #define MNP_RECEIVE_UNICAST 0x01
  21. #define MNP_RECEIVE_BROADCAST 0x02
  22. #define UNICAST_PACKET MNP_RECEIVE_UNICAST
  23. #define BROADCAST_PACKET MNP_RECEIVE_BROADCAST
  24. #define MNP_INSTANCE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'I')
  25. #define MNP_INSTANCE_DATA_FROM_THIS(a) \
  26. CR ( \
  27. (a), \
  28. MNP_INSTANCE_DATA, \
  29. ManagedNetwork, \
  30. MNP_INSTANCE_DATA_SIGNATURE \
  31. )
  32. typedef struct {
  33. UINT32 Signature;
  34. MNP_SERVICE_DATA *MnpServiceData;
  35. EFI_HANDLE Handle;
  36. LIST_ENTRY InstEntry;
  37. EFI_MANAGED_NETWORK_PROTOCOL ManagedNetwork;
  38. BOOLEAN Configured;
  39. BOOLEAN Destroyed;
  40. LIST_ENTRY GroupCtrlBlkList;
  41. NET_MAP RxTokenMap;
  42. LIST_ENTRY RxDeliveredPacketQueue;
  43. LIST_ENTRY RcvdPacketQueue;
  44. UINTN RcvdPacketQueueSize;
  45. EFI_MANAGED_NETWORK_CONFIG_DATA ConfigData;
  46. UINT8 ReceiveFilter;
  47. } MNP_INSTANCE_DATA;
  48. typedef struct {
  49. LIST_ENTRY AddrEntry;
  50. EFI_MAC_ADDRESS Address;
  51. INTN RefCnt;
  52. } MNP_GROUP_ADDRESS;
  53. typedef struct {
  54. LIST_ENTRY CtrlBlkEntry;
  55. MNP_GROUP_ADDRESS *GroupAddress;
  56. } MNP_GROUP_CONTROL_BLOCK;
  57. typedef struct {
  58. LIST_ENTRY WrapEntry;
  59. MNP_INSTANCE_DATA *Instance;
  60. EFI_MANAGED_NETWORK_RECEIVE_DATA RxData;
  61. NET_BUF *Nbuf;
  62. UINT64 TimeoutTick;
  63. } MNP_RXDATA_WRAP;
  64. #define MNP_TX_BUF_WRAP_SIGNATURE SIGNATURE_32 ('M', 'T', 'B', 'W')
  65. typedef struct {
  66. UINT32 Signature;
  67. LIST_ENTRY WrapEntry; // Link to FreeTxBufList
  68. LIST_ENTRY AllEntry; // Link to AllTxBufList
  69. BOOLEAN InUse;
  70. UINT8 TxBuf[1];
  71. } MNP_TX_BUF_WRAP;
  72. /**
  73. Initialize the mnp device context data.
  74. @param[in, out] MnpDeviceData Pointer to the mnp device context data.
  75. @param[in] ImageHandle The driver image handle.
  76. @param[in] ControllerHandle Handle of device to bind driver to.
  77. @retval EFI_SUCCESS The mnp service context is initialized.
  78. @retval EFI_UNSUPPORTED ControllerHandle does not support Simple Network Protocol.
  79. @retval Others Other errors as indicated.
  80. **/
  81. EFI_STATUS
  82. MnpInitializeDeviceData (
  83. IN OUT MNP_DEVICE_DATA *MnpDeviceData,
  84. IN EFI_HANDLE ImageHandle,
  85. IN EFI_HANDLE ControllerHandle
  86. );
  87. /**
  88. Destroy the MNP device context data.
  89. @param[in, out] MnpDeviceData Pointer to the mnp device context data.
  90. @param[in] ImageHandle The driver image handle.
  91. **/
  92. VOID
  93. MnpDestroyDeviceData (
  94. IN OUT MNP_DEVICE_DATA *MnpDeviceData,
  95. IN EFI_HANDLE ImageHandle
  96. );
  97. /**
  98. Create mnp service context data.
  99. @param[in] MnpDeviceData Pointer to the mnp device context data.
  100. @param[in] VlanId The VLAN ID.
  101. @param[in] Priority The VLAN priority. If VlanId is 0,
  102. Priority is ignored.
  103. @return A pointer to MNP_SERVICE_DATA or NULL if failed to create MNP service context.
  104. **/
  105. MNP_SERVICE_DATA *
  106. MnpCreateServiceData (
  107. IN MNP_DEVICE_DATA *MnpDeviceData,
  108. IN UINT16 VlanId,
  109. IN UINT8 Priority OPTIONAL
  110. );
  111. /**
  112. Initialize the mnp service context data.
  113. @param[in, out] MnpServiceData Pointer to the mnp service context data.
  114. @param[in] ImageHandle The driver image handle.
  115. @param[in] ControllerHandle Handle of device to bind driver to.
  116. @retval EFI_SUCCESS The mnp service context is initialized.
  117. @retval EFI_UNSUPPORTED ControllerHandle does not support Simple Network Protocol.
  118. @retval Others Other errors as indicated.
  119. **/
  120. EFI_STATUS
  121. MnpInitializeServiceData (
  122. IN OUT MNP_SERVICE_DATA *MnpServiceData,
  123. IN EFI_HANDLE ImageHandle,
  124. IN EFI_HANDLE ControllerHandle
  125. );
  126. /**
  127. Destroy the MNP service context data.
  128. @param[in, out] MnpServiceData Pointer to the mnp service context data.
  129. @retval EFI_SUCCESS The mnp service context is destroyed.
  130. @retval Others Errors as indicated.
  131. **/
  132. EFI_STATUS
  133. MnpDestroyServiceData (
  134. IN OUT MNP_SERVICE_DATA *MnpServiceData
  135. );
  136. /**
  137. Destroy all child of the MNP service data.
  138. @param[in, out] MnpServiceData Pointer to the mnp service context data.
  139. @retval EFI_SUCCESS All child are destroyed.
  140. @retval Others Failed to destroy all child.
  141. **/
  142. EFI_STATUS
  143. MnpDestroyServiceChild (
  144. IN OUT MNP_SERVICE_DATA *MnpServiceData
  145. );
  146. /**
  147. Find the MNP Service Data for given VLAN ID.
  148. @param[in] MnpDeviceData Pointer to the mnp device context data.
  149. @param[in] VlanId The VLAN ID.
  150. @return A pointer to MNP_SERVICE_DATA or NULL if not found.
  151. **/
  152. MNP_SERVICE_DATA *
  153. MnpFindServiceData (
  154. IN MNP_DEVICE_DATA *MnpDeviceData,
  155. IN UINT16 VlanId
  156. );
  157. /**
  158. Initialize the mnp instance context data.
  159. @param[in] MnpServiceData Pointer to the mnp service context data.
  160. @param[in, out] Instance Pointer to the mnp instance context data
  161. to initialize.
  162. **/
  163. VOID
  164. MnpInitializeInstanceData (
  165. IN MNP_SERVICE_DATA *MnpServiceData,
  166. IN OUT MNP_INSTANCE_DATA *Instance
  167. );
  168. /**
  169. Check whether the token specified by Arg matches the token in Item.
  170. @param[in] Map Pointer to the NET_MAP.
  171. @param[in] Item Pointer to the NET_MAP_ITEM.
  172. @param[in] Arg Pointer to the Arg, it's a pointer to the token to
  173. check.
  174. @retval EFI_SUCCESS The token specified by Arg is different from the
  175. token in Item.
  176. @retval EFI_ACCESS_DENIED The token specified by Arg is the same as that in
  177. Item.
  178. **/
  179. EFI_STATUS
  180. EFIAPI
  181. MnpTokenExist (
  182. IN NET_MAP *Map,
  183. IN NET_MAP_ITEM *Item,
  184. IN VOID *Arg
  185. );
  186. /**
  187. Cancel the token specified by Arg if it matches the token in Item.
  188. @param[in, out] Map Pointer to the NET_MAP.
  189. @param[in, out] Item Pointer to the NET_MAP_ITEM.
  190. @param[in] Arg Pointer to the Arg, it's a pointer to the
  191. token to cancel.
  192. @retval EFI_SUCCESS The Arg is NULL, and the token in Item is cancelled,
  193. or the Arg isn't NULL, and the token in Item is
  194. different from the Arg.
  195. @retval EFI_ABORTED The Arg isn't NULL, the token in Item mathces the
  196. Arg, and the token is cancelled.
  197. **/
  198. EFI_STATUS
  199. EFIAPI
  200. MnpCancelTokens (
  201. IN OUT NET_MAP *Map,
  202. IN OUT NET_MAP_ITEM *Item,
  203. IN VOID *Arg
  204. );
  205. /**
  206. Flush the instance's received data.
  207. @param[in, out] Instance Pointer to the mnp instance context data.
  208. **/
  209. VOID
  210. MnpFlushRcvdDataQueue (
  211. IN OUT MNP_INSTANCE_DATA *Instance
  212. );
  213. /**
  214. Configure the Instance using ConfigData.
  215. @param[in, out] Instance Pointer to the mnp instance context data.
  216. @param[in] ConfigData Pointer to the configuration data used to configure
  217. the instance.
  218. @retval EFI_SUCCESS The Instance is configured.
  219. @retval EFI_UNSUPPORTED EnableReceiveTimestamps is on and the
  220. implementation doesn't support it.
  221. @retval Others Other errors as indicated.
  222. **/
  223. EFI_STATUS
  224. MnpConfigureInstance (
  225. IN OUT MNP_INSTANCE_DATA *Instance,
  226. IN EFI_MANAGED_NETWORK_CONFIG_DATA *ConfigData OPTIONAL
  227. );
  228. /**
  229. Do the group operations for this instance.
  230. @param[in, out] Instance Pointer to the instance context data.
  231. @param[in] JoinFlag Set to TRUE to join a group. Set to TRUE to
  232. leave a group/groups.
  233. @param[in] MacAddress Pointer to the group address to join or leave.
  234. @param[in] CtrlBlk Pointer to the group control block if JoinFlag
  235. is FALSE.
  236. @retval EFI_SUCCESS The group operation finished.
  237. @retval EFI_OUT_OF_RESOURCES Failed due to lack of memory resources.
  238. @retval Others Other errors as indicated.
  239. **/
  240. EFI_STATUS
  241. MnpGroupOp (
  242. IN OUT MNP_INSTANCE_DATA *Instance,
  243. IN BOOLEAN JoinFlag,
  244. IN EFI_MAC_ADDRESS *MacAddress OPTIONAL,
  245. IN MNP_GROUP_CONTROL_BLOCK *CtrlBlk OPTIONAL
  246. );
  247. /**
  248. Validates the Mnp transmit token.
  249. @param[in] Instance Pointer to the Mnp instance context data.
  250. @param[in] Token Pointer to the transmit token to check.
  251. @return The Token is valid or not.
  252. **/
  253. BOOLEAN
  254. MnpIsValidTxToken (
  255. IN MNP_INSTANCE_DATA *Instance,
  256. IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
  257. );
  258. /**
  259. Build the packet to transmit from the TxData passed in.
  260. @param[in] MnpServiceData Pointer to the mnp service context data.
  261. @param[in] TxData Pointer to the transmit data containing the information
  262. to build the packet.
  263. @param[out] PktBuf Pointer to record the address of the packet.
  264. @param[out] PktLen Pointer to a UINT32 variable used to record the packet's
  265. length.
  266. @retval EFI_SUCCESS TxPackage is built.
  267. @retval EFI_OUT_OF_RESOURCES The deliver fails due to lack of memory resource.
  268. **/
  269. EFI_STATUS
  270. MnpBuildTxPacket (
  271. IN MNP_SERVICE_DATA *MnpServiceData,
  272. IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData,
  273. OUT UINT8 **PktBuf,
  274. OUT UINT32 *PktLen
  275. );
  276. /**
  277. Synchronously send out the packet.
  278. This function places the packet buffer to SNP driver's tansmit queue. The packet
  279. can be considered successfully sent out once SNP accept the packet, while the
  280. packet buffer recycle is deferred for better performance.
  281. @param[in] MnpServiceData Pointer to the mnp service context data.
  282. @param[in] Packet Pointer to the packet buffer.
  283. @param[in] Length The length of the packet.
  284. @param[in, out] Token Pointer to the token the packet generated from.
  285. @retval EFI_SUCCESS The packet is sent out.
  286. @retval EFI_TIMEOUT Time out occurs, the packet isn't sent.
  287. @retval EFI_DEVICE_ERROR An unexpected network error occurs.
  288. **/
  289. EFI_STATUS
  290. MnpSyncSendPacket (
  291. IN MNP_SERVICE_DATA *MnpServiceData,
  292. IN UINT8 *Packet,
  293. IN UINT32 Length,
  294. IN OUT EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
  295. );
  296. /**
  297. Try to deliver the received packet to the instance.
  298. @param[in, out] Instance Pointer to the mnp instance context data.
  299. @retval EFI_SUCCESS The received packet is delivered, or there is no
  300. packet to deliver, or there is no available receive
  301. token.
  302. @retval EFI_OUT_OF_RESOURCES The deliver fails due to lack of memory resource.
  303. **/
  304. EFI_STATUS
  305. MnpInstanceDeliverPacket (
  306. IN OUT MNP_INSTANCE_DATA *Instance
  307. );
  308. /**
  309. Recycle the RxData and other resources used to hold and deliver the received
  310. packet.
  311. @param[in] Event The event this notify function registered to.
  312. @param[in] Context Pointer to the context data registered to the Event.
  313. **/
  314. VOID
  315. EFIAPI
  316. MnpRecycleRxData (
  317. IN EFI_EVENT Event,
  318. IN VOID *Context
  319. );
  320. /**
  321. Try to receive a packet and deliver it.
  322. @param[in, out] MnpDeviceData Pointer to the mnp device context data.
  323. @retval EFI_SUCCESS add return value to function comment
  324. @retval EFI_NOT_STARTED The simple network protocol is not started.
  325. @retval EFI_NOT_READY No packet received.
  326. @retval EFI_DEVICE_ERROR An unexpected error occurs.
  327. **/
  328. EFI_STATUS
  329. MnpReceivePacket (
  330. IN OUT MNP_DEVICE_DATA *MnpDeviceData
  331. );
  332. /**
  333. Allocate a free NET_BUF from MnpDeviceData->FreeNbufQue. If there is none
  334. in the queue, first try to allocate some and add them into the queue, then
  335. fetch the NET_BUF from the updated FreeNbufQue.
  336. @param[in, out] MnpDeviceData Pointer to the MNP_DEVICE_DATA.
  337. @return Pointer to the allocated free NET_BUF structure, if NULL the
  338. operation is failed.
  339. **/
  340. NET_BUF *
  341. MnpAllocNbuf (
  342. IN OUT MNP_DEVICE_DATA *MnpDeviceData
  343. );
  344. /**
  345. Try to reclaim the Nbuf into the buffer pool.
  346. @param[in, out] MnpDeviceData Pointer to the mnp device context data.
  347. @param[in, out] Nbuf Pointer to the NET_BUF to free.
  348. **/
  349. VOID
  350. MnpFreeNbuf (
  351. IN OUT MNP_DEVICE_DATA *MnpDeviceData,
  352. IN OUT NET_BUF *Nbuf
  353. );
  354. /**
  355. Allocate a free TX buffer from MnpDeviceData->FreeTxBufList. If there is none
  356. in the queue, first try to recycle some from SNP, then try to allocate some and add
  357. them into the queue, then fetch the NET_BUF from the updated FreeTxBufList.
  358. @param[in, out] MnpDeviceData Pointer to the MNP_DEVICE_DATA.
  359. @return Pointer to the allocated free NET_BUF structure, if NULL the
  360. operation is failed.
  361. **/
  362. UINT8 *
  363. MnpAllocTxBuf (
  364. IN OUT MNP_DEVICE_DATA *MnpDeviceData
  365. );
  366. /**
  367. Try to recycle all the transmitted buffer address from SNP.
  368. @param[in, out] MnpDeviceData Pointer to the mnp device context data.
  369. @retval EFI_SUCCESS Successed to recycle the transmitted buffer address.
  370. @retval Others Failed to recycle the transmitted buffer address.
  371. **/
  372. EFI_STATUS
  373. MnpRecycleTxBuf (
  374. IN OUT MNP_DEVICE_DATA *MnpDeviceData
  375. );
  376. /**
  377. Remove the received packets if timeout occurs.
  378. @param[in] Event The event this notify function registered to.
  379. @param[in] Context Pointer to the context data registered to the event.
  380. **/
  381. VOID
  382. EFIAPI
  383. MnpCheckPacketTimeout (
  384. IN EFI_EVENT Event,
  385. IN VOID *Context
  386. );
  387. /**
  388. Poll to update MediaPresent field in SNP ModeData by Snp.GetStatus().
  389. @param[in] Event The event this notify function registered to.
  390. @param[in] Context Pointer to the context data registered to the event.
  391. **/
  392. VOID
  393. EFIAPI
  394. MnpCheckMediaStatus (
  395. IN EFI_EVENT Event,
  396. IN VOID *Context
  397. );
  398. /**
  399. Poll to receive the packets from Snp. This function is either called by upperlayer
  400. protocols/applications or the system poll timer notify mechanism.
  401. @param[in] Event The event this notify function registered to.
  402. @param[in] Context Pointer to the context data registered to the event.
  403. **/
  404. VOID
  405. EFIAPI
  406. MnpSystemPoll (
  407. IN EFI_EVENT Event,
  408. IN VOID *Context
  409. );
  410. /**
  411. Returns the operational parameters for the current MNP child driver. May also
  412. support returning the underlying SNP driver mode data.
  413. The GetModeData() function is used to read the current mode data (operational
  414. parameters) from the MNP or the underlying SNP.
  415. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  416. @param[out] MnpConfigData Pointer to storage for MNP operational parameters. Type
  417. EFI_MANAGED_NETWORK_CONFIG_DATA is defined in "Related
  418. Definitions" below.
  419. @param[out] SnpModeData Pointer to storage for SNP operational parameters. This
  420. feature may be unsupported. Type EFI_SIMPLE_NETWORK_MODE
  421. is defined in the EFI_SIMPLE_NETWORK_PROTOCOL.
  422. @retval EFI_SUCCESS The operation completed successfully.
  423. @retval EFI_INVALID_PARAMETER This is NULL.
  424. @retval EFI_UNSUPPORTED The requested feature is unsupported in this
  425. MNP implementation.
  426. @retval EFI_NOT_STARTED This MNP child driver instance has not been
  427. configured. The default values are returned in
  428. MnpConfigData if it is not NULL.
  429. @retval Others The mode data could not be read.
  430. **/
  431. EFI_STATUS
  432. EFIAPI
  433. MnpGetModeData (
  434. IN EFI_MANAGED_NETWORK_PROTOCOL *This,
  435. OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
  436. OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
  437. );
  438. /**
  439. Sets or clears the operational parameters for the MNP child driver.
  440. The Configure() function is used to set, change, or reset the operational
  441. parameters for the MNP child driver instance. Until the operational parameters
  442. have been set, no network traffic can be sent or received by this MNP child
  443. driver instance. Once the operational parameters have been reset, no more
  444. traffic can be sent or received until the operational parameters have been set
  445. again.
  446. Each MNP child driver instance can be started and stopped independently of
  447. each other by setting or resetting their receive filter settings with the
  448. Configure() function.
  449. After any successful call to Configure(), the MNP child driver instance is
  450. started. The internal periodic timer (if supported) is enabled. Data can be
  451. transmitted and may be received if the receive filters have also been enabled.
  452. Note: If multiple MNP child driver instances will receive the same packet
  453. because of overlapping receive filter settings, then the first MNP child
  454. driver instance will receive the original packet and additional instances will
  455. receive copies of the original packet.
  456. Note: Warning: Receive filter settings that overlap will consume extra
  457. processor and/or DMA resources and degrade system and network performance.
  458. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  459. @param[in] MnpConfigData Pointer to configuration data that will be assigned
  460. to the MNP child driver instance. If NULL, the MNP
  461. child driver instance is reset to startup defaults
  462. and all pending transmit and receive requests are
  463. flushed. Type EFI_MANAGED_NETWORK_CONFIG_DATA is
  464. defined in EFI_MANAGED_NETWORK_PROTOCOL.GetModeData().
  465. @retval EFI_SUCCESS The operation completed successfully.
  466. @retval EFI_INVALID_PARAMETER One or more of the following conditions is
  467. TRUE:
  468. * This is NULL.
  469. * MnpConfigData.ProtocolTypeFilter is not
  470. valid.
  471. The operational data for the MNP child driver
  472. instance is unchanged.
  473. @retval EFI_OUT_OF_RESOURCES Required system resources (usually memory)
  474. could not be allocated.
  475. The MNP child driver instance has been reset to
  476. startup defaults.
  477. @retval EFI_UNSUPPORTED The requested feature is unsupported in
  478. this [MNP] implementation. The operational data
  479. for the MNP child driver instance is unchanged.
  480. @retval EFI_DEVICE_ERROR An unexpected network or system error
  481. occurred. The MNP child driver instance has
  482. been reset to startup defaults.
  483. @retval Others The MNP child driver instance has been reset to
  484. startup defaults.
  485. **/
  486. EFI_STATUS
  487. EFIAPI
  488. MnpConfigure (
  489. IN EFI_MANAGED_NETWORK_PROTOCOL *This,
  490. IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
  491. );
  492. /**
  493. Translates an IP multicast address to a hardware (MAC) multicast address. This
  494. function may be unsupported in some MNP implementations.
  495. The McastIpToMac() function translates an IP multicast address to a hardware
  496. (MAC) multicast address. This function may be implemented by calling the
  497. underlying EFI_SIMPLE_NETWORK. MCastIpToMac() function, which may also be
  498. unsupported in some MNP implementations.
  499. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  500. @param[in] Ipv6Flag Set to TRUE to if IpAddress is an IPv6 multicast address.
  501. Set to FALSE if IpAddress is an IPv4 multicast address.
  502. @param[in] IpAddress Pointer to the multicast IP address (in network byte
  503. order) to convert.
  504. @param[out] MacAddress Pointer to the resulting multicast MAC address.
  505. @retval EFI_SUCCESS The operation completed successfully.
  506. @retval EFI_INVALID_PARAMETER One of the following conditions is TRUE:
  507. * This is NULL.
  508. * IpAddress is NULL.
  509. * IpAddress is not a valid multicast IP
  510. address.
  511. * MacAddress is NULL.
  512. @retval EFI_NOT_STARTED This MNP child driver instance has not been
  513. configured.
  514. @retval EFI_UNSUPPORTED The requested feature is unsupported in this
  515. MNP implementation.
  516. @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
  517. @retval Others The address could not be converted.
  518. **/
  519. EFI_STATUS
  520. EFIAPI
  521. MnpMcastIpToMac (
  522. IN EFI_MANAGED_NETWORK_PROTOCOL *This,
  523. IN BOOLEAN Ipv6Flag,
  524. IN EFI_IP_ADDRESS *IpAddress,
  525. OUT EFI_MAC_ADDRESS *MacAddress
  526. );
  527. /**
  528. Enables and disables receive filters for multicast address. This function may
  529. be unsupported in some MNP implementations.
  530. The Groups() function only adds and removes multicast MAC addresses from the
  531. filter list. The MNP driver does not transmit or process Internet Group
  532. Management Protocol (IGMP) packets. If JoinFlag is FALSE and MacAddress is
  533. NULL, then all joined groups are left.
  534. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  535. @param[in] JoinFlag Set to TRUE to join this multicast group.
  536. Set to FALSE to leave this multicast group.
  537. @param[in] MacAddress Pointer to the multicast MAC group (address) to join or
  538. leave.
  539. @retval EFI_SUCCESS The requested operation completed successfully.
  540. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  541. * This is NULL.
  542. * JoinFlag is TRUE and MacAddress is NULL.
  543. * MacAddress is not a valid multicast MAC
  544. address.
  545. * The MNP multicast group settings are
  546. unchanged.
  547. @retval EFI_NOT_STARTED This MNP child driver instance has not been
  548. configured.
  549. @retval EFI_ALREADY_STARTED The supplied multicast group is already joined.
  550. @retval EFI_NOT_FOUND The supplied multicast group is not joined.
  551. @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.
  552. The MNP child driver instance has been reset to
  553. startup defaults.
  554. @retval EFI_UNSUPPORTED The requested feature is unsupported in this MNP
  555. implementation.
  556. @retval Others The requested operation could not be completed.
  557. The MNP multicast group settings are unchanged.
  558. **/
  559. EFI_STATUS
  560. EFIAPI
  561. MnpGroups (
  562. IN EFI_MANAGED_NETWORK_PROTOCOL *This,
  563. IN BOOLEAN JoinFlag,
  564. IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
  565. );
  566. /**
  567. Places asynchronous outgoing data packets into the transmit queue.
  568. The Transmit() function places a completion token into the transmit packet
  569. queue. This function is always asynchronous.
  570. The caller must fill in the Token.Event and Token.TxData fields in the
  571. completion token, and these fields cannot be NULL. When the transmit operation
  572. completes, the MNP updates the Token.Status field and the Token.Event is
  573. signaled.
  574. Note: There may be a performance penalty if the packet needs to be
  575. defragmented before it can be transmitted by the network device. Systems in
  576. which performance is critical should review the requirements and features of
  577. the underlying communications device and drivers.
  578. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  579. @param[in] Token Pointer to a token associated with the transmit data
  580. descriptor. Type EFI_MANAGED_NETWORK_COMPLETION_TOKEN
  581. is defined in "Related Definitions" below.
  582. @retval EFI_SUCCESS The transmit completion token was cached.
  583. @retval EFI_NOT_STARTED This MNP child driver instance has not been
  584. configured.
  585. @retval EFI_INVALID_PARAMETER One or more of the following conditions is
  586. TRUE:
  587. * This is NULL.
  588. * Token is NULL.
  589. * Token.Event is NULL.
  590. * Token.TxData is NULL.
  591. * Token.TxData.DestinationAddress is not
  592. NULL and Token.TxData.HeaderLength is zero.
  593. * Token.TxData.FragmentCount is zero.
  594. * (Token.TxData.HeaderLength +
  595. Token.TxData.DataLength) is not equal to the
  596. sum of the
  597. Token.TxData.FragmentTable[].FragmentLength
  598. fields.
  599. * One or more of the
  600. Token.TxData.FragmentTable[].FragmentLength
  601. fields is zero.
  602. * One or more of the
  603. Token.TxData.FragmentTable[].FragmentBufferfields
  604. is NULL.
  605. * Token.TxData.DataLength is greater than MTU.
  606. @retval EFI_ACCESS_DENIED The transmit completion token is already in the
  607. transmit queue.
  608. @retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a
  609. lack of system resources (usually memory).
  610. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  611. The MNP child driver instance has been reset to
  612. startup defaults.
  613. @retval EFI_NOT_READY The transmit request could not be queued because
  614. the transmit queue is full.
  615. **/
  616. EFI_STATUS
  617. EFIAPI
  618. MnpTransmit (
  619. IN EFI_MANAGED_NETWORK_PROTOCOL *This,
  620. IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
  621. );
  622. /**
  623. Aborts an asynchronous transmit or receive request.
  624. The Cancel() function is used to abort a pending transmit or receive request.
  625. If the token is in the transmit or receive request queues, after calling this
  626. function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
  627. signaled. If the token is not in one of the queues, which usually means that
  628. the asynchronous operation has completed, this function will not signal the
  629. token and EFI_NOT_FOUND is returned.
  630. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  631. @param[in] Token Pointer to a token that has been issued by
  632. EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or
  633. EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If NULL, all
  634. pending tokens are aborted.
  635. @retval EFI_SUCCESS The asynchronous I/O request was aborted and
  636. Token.Event was signaled. When Token is NULL,
  637. all pending requests were aborted and their
  638. events were signaled.
  639. @retval EFI_NOT_STARTED This MNP child driver instance has not been
  640. configured.
  641. @retval EFI_INVALID_PARAMETER This is NULL.
  642. @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O
  643. request was not found in the transmit or
  644. receive queue. It has either completed or was
  645. not issued by Transmit() and Receive().
  646. **/
  647. EFI_STATUS
  648. EFIAPI
  649. MnpCancel (
  650. IN EFI_MANAGED_NETWORK_PROTOCOL *This,
  651. IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
  652. );
  653. /**
  654. Places an asynchronous receiving request into the receiving queue.
  655. The Receive() function places a completion token into the receive packet
  656. queue. This function is always asynchronous.
  657. The caller must fill in the Token.Event field in the completion token, and
  658. this field cannot be NULL. When the receive operation completes, the MNP
  659. updates the Token.Status and Token.RxData fields and the Token.Event is
  660. signaled.
  661. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  662. @param[in] Token Pointer to a token associated with the receive
  663. data descriptor. Type
  664. EFI_MANAGED_NETWORK_COMPLETION_TOKEN is defined in
  665. EFI_MANAGED_NETWORK_PROTOCOL.Transmit().
  666. @retval EFI_SUCCESS The receive completion token was cached.
  667. @retval EFI_NOT_STARTED This MNP child driver instance has not been
  668. configured.
  669. @retval EFI_INVALID_PARAMETER One or more of the following conditions is
  670. TRUE:
  671. * This is NULL.
  672. * Token is NULL.
  673. * Token.Event is NULL
  674. @retval EFI_OUT_OF_RESOURCES The transmit data could not be queued due to a
  675. lack of system resources (usually memory).
  676. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
  677. The MNP child driver instance has been reset to
  678. startup defaults.
  679. @retval EFI_ACCESS_DENIED The receive completion token was already in the
  680. receive queue.
  681. @retval EFI_NOT_READY The receive request could not be queued because
  682. the receive queue is full.
  683. **/
  684. EFI_STATUS
  685. EFIAPI
  686. MnpReceive (
  687. IN EFI_MANAGED_NETWORK_PROTOCOL *This,
  688. IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
  689. );
  690. /**
  691. Polls for incoming data packets and processes outgoing data packets.
  692. The Poll() function can be used by network drivers and applications to
  693. increase the rate that data packets are moved between the communications
  694. device and the transmit and receive queues.
  695. Normally, a periodic timer event internally calls the Poll() function. But, in
  696. some systems, the periodic timer event may not call Poll() fast enough to
  697. transmit and/or receive all data packets without missing packets. Drivers and
  698. applications that are experiencing packet loss should try calling the Poll()
  699. function more often.
  700. @param[in] This Pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
  701. @retval EFI_SUCCESS Incoming or outgoing data was processed.
  702. @retval EFI_NOT_STARTED This MNP child driver instance has not been
  703. configured.
  704. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The
  705. MNP child driver instance has been reset to startup
  706. defaults.
  707. @retval EFI_NOT_READY No incoming or outgoing data was processed. Consider
  708. increasing the polling rate.
  709. @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive
  710. queue. Consider increasing the polling rate.
  711. **/
  712. EFI_STATUS
  713. EFIAPI
  714. MnpPoll (
  715. IN EFI_MANAGED_NETWORK_PROTOCOL *This
  716. );
  717. /**
  718. Configure the Snp receive filters according to the instances' receive filter
  719. settings.
  720. @param[in] MnpDeviceData Pointer to the mnp device context data.
  721. @retval EFI_SUCCESS The receive filters is configured.
  722. @retval EFI_OUT_OF_RESOURCES The receive filters can't be configured due
  723. to lack of memory resource.
  724. **/
  725. EFI_STATUS
  726. MnpConfigReceiveFilters (
  727. IN MNP_DEVICE_DATA *MnpDeviceData
  728. );
  729. #endif