MnpDriver.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /** @file
  2. Declaration of structures and functions for MnpDxe driver.
  3. Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _MNP_DRIVER_H_
  7. #define _MNP_DRIVER_H_
  8. #include <Uefi.h>
  9. #include <Protocol/ManagedNetwork.h>
  10. #include <Protocol/SimpleNetwork.h>
  11. #include <Protocol/ServiceBinding.h>
  12. #include <Protocol/VlanConfig.h>
  13. #include <Library/BaseLib.h>
  14. #include <Library/BaseMemoryLib.h>
  15. #include <Library/DebugLib.h>
  16. #include <Library/MemoryAllocationLib.h>
  17. #include <Library/UefiBootServicesTableLib.h>
  18. #include <Library/UefiLib.h>
  19. #include <Library/NetLib.h>
  20. #include <Library/DpcLib.h>
  21. #include <Library/UefiRuntimeServicesTableLib.h>
  22. #include <Library/DevicePathLib.h>
  23. #include <Library/PrintLib.h>
  24. #include "ComponentName.h"
  25. #define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')
  26. //
  27. // Global Variables
  28. //
  29. extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;
  30. typedef struct {
  31. UINT32 Signature;
  32. EFI_HANDLE ControllerHandle;
  33. EFI_HANDLE ImageHandle;
  34. EFI_VLAN_CONFIG_PROTOCOL VlanConfig;
  35. UINTN NumberOfVlan;
  36. CHAR16 *MacString;
  37. EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
  38. //
  39. // List of MNP_SERVICE_DATA
  40. //
  41. LIST_ENTRY ServiceList;
  42. //
  43. // Number of configured MNP Service Binding child
  44. //
  45. UINTN ConfiguredChildrenNumber;
  46. LIST_ENTRY GroupAddressList;
  47. UINT32 GroupAddressCount;
  48. LIST_ENTRY FreeTxBufList;
  49. LIST_ENTRY AllTxBufList;
  50. UINT32 TxBufCount;
  51. NET_BUF_QUEUE FreeNbufQue;
  52. INTN NbufCnt;
  53. EFI_EVENT PollTimer;
  54. BOOLEAN EnableSystemPoll;
  55. EFI_EVENT TimeoutCheckTimer;
  56. EFI_EVENT MediaDetectTimer;
  57. UINT32 UnicastCount;
  58. UINT32 BroadcastCount;
  59. UINT32 MulticastCount;
  60. UINT32 PromiscuousCount;
  61. //
  62. // The size of the data buffer in the MNP_PACKET_BUFFER used to
  63. // store a packet.
  64. //
  65. UINT32 BufferLength;
  66. UINT32 PaddingSize;
  67. NET_BUF *RxNbufCache;
  68. } MNP_DEVICE_DATA;
  69. #define MNP_DEVICE_DATA_FROM_THIS(a) \
  70. CR ( \
  71. (a), \
  72. MNP_DEVICE_DATA, \
  73. VlanConfig, \
  74. MNP_DEVICE_DATA_SIGNATURE \
  75. )
  76. #define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
  77. typedef struct {
  78. UINT32 Signature;
  79. LIST_ENTRY Link;
  80. MNP_DEVICE_DATA *MnpDeviceData;
  81. EFI_HANDLE ServiceHandle;
  82. EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
  83. EFI_DEVICE_PATH_PROTOCOL *DevicePath;
  84. LIST_ENTRY ChildrenList;
  85. UINTN ChildrenNumber;
  86. UINT32 Mtu;
  87. UINT16 VlanId;
  88. UINT8 Priority;
  89. } MNP_SERVICE_DATA;
  90. #define MNP_SERVICE_DATA_FROM_THIS(a) \
  91. CR ( \
  92. (a), \
  93. MNP_SERVICE_DATA, \
  94. ServiceBinding, \
  95. MNP_SERVICE_DATA_SIGNATURE \
  96. )
  97. #define MNP_SERVICE_DATA_FROM_LINK(a) \
  98. CR ( \
  99. (a), \
  100. MNP_SERVICE_DATA, \
  101. Link, \
  102. MNP_SERVICE_DATA_SIGNATURE \
  103. )
  104. /**
  105. Test to see if this driver supports ControllerHandle. This service
  106. is called by the EFI boot service ConnectController(). In
  107. order to make drivers as small as possible, there are a few calling
  108. restrictions for this service. ConnectController() must
  109. follow these calling restrictions. If any other agent wishes to call
  110. Supported() it must also follow these calling restrictions.
  111. @param[in] This Protocol instance pointer.
  112. @param[in] ControllerHandle Handle of device to test.
  113. @param[in] RemainingDevicePath Optional parameter use to pick a specific
  114. child device to start.
  115. @retval EFI_SUCCESS This driver supports this device.
  116. @retval EFI_ALREADY_STARTED This driver is already running on this device.
  117. @retval Others This driver does not support this device.
  118. **/
  119. EFI_STATUS
  120. EFIAPI
  121. MnpDriverBindingSupported (
  122. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  123. IN EFI_HANDLE ControllerHandle,
  124. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  125. );
  126. /**
  127. Start this driver on ControllerHandle. This service is called by the
  128. EFI boot service ConnectController(). In order to make drivers as small
  129. as possible, there are a few calling restrictions for this service.
  130. ConnectController() must follow these calling restrictions. If any other
  131. agent wishes to call Start() it must also follow these calling restrictions.
  132. @param[in] This Protocol instance pointer.
  133. @param[in] ControllerHandle Handle of device to bind driver to.
  134. @param[in] RemainingDevicePath Optional parameter use to pick a specific
  135. child device to start.
  136. @retval EFI_SUCCESS This driver is added to ControllerHandle.
  137. @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
  138. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
  139. @retval Others This driver does not support this device.
  140. **/
  141. EFI_STATUS
  142. EFIAPI
  143. MnpDriverBindingStart (
  144. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  145. IN EFI_HANDLE ControllerHandle,
  146. IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
  147. );
  148. /**
  149. Stop this driver on ControllerHandle. This service is called by the
  150. EFI boot service DisconnectController(). In order to make drivers as
  151. small as possible, there are a few calling restrictions for this service.
  152. DisconnectController() must follow these calling restrictions. If any other
  153. agent wishes to call Stop() it must also follow these calling restrictions.
  154. @param[in] This Protocol instance pointer.
  155. @param[in] ControllerHandle Handle of device to stop driver on.
  156. @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
  157. number of children is zero stop the entire
  158. bus driver.
  159. @param[in] ChildHandleBuffer List of Child Handles to Stop.
  160. @retval EFI_SUCCESS This driver is removed ControllerHandle.
  161. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
  162. **/
  163. EFI_STATUS
  164. EFIAPI
  165. MnpDriverBindingStop (
  166. IN EFI_DRIVER_BINDING_PROTOCOL *This,
  167. IN EFI_HANDLE ControllerHandle,
  168. IN UINTN NumberOfChildren,
  169. IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
  170. );
  171. /**
  172. Creates a child handle with a set of I/O services.
  173. @param[in] This Protocol instance pointer.
  174. @param[in, out] ChildHandle Pointer to the handle of the child to create. If
  175. it is NULL, then a new handle is created. If
  176. it is not NULL, then the I/O services are added
  177. to the existing child handle.
  178. @retval EFI_SUCCESS The protocol was added to ChildHandle.
  179. @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
  180. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
  181. create the child.
  182. @retval Others The child handle was not created.
  183. **/
  184. EFI_STATUS
  185. EFIAPI
  186. MnpServiceBindingCreateChild (
  187. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  188. IN OUT EFI_HANDLE *ChildHandle
  189. );
  190. /**
  191. Destroys a child handle with a set of I/O services.
  192. The DestroyChild() function does the opposite of CreateChild(). It removes a
  193. protocol that was installed by CreateChild() from ChildHandle. If the removed
  194. protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
  195. @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
  196. instance.
  197. @param[in] ChildHandle Handle of the child to destroy.
  198. @retval EFI_SUCCESS The protocol was removed from ChildHandle.
  199. @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
  200. is being removed.
  201. @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
  202. @retval EFI_ACCESS_DENIED The protocol could not be removed from the
  203. ChildHandle because its services are being
  204. used.
  205. @retval Others The child handle was not destroyed.
  206. **/
  207. EFI_STATUS
  208. EFIAPI
  209. MnpServiceBindingDestroyChild (
  210. IN EFI_SERVICE_BINDING_PROTOCOL *This,
  211. IN EFI_HANDLE ChildHandle
  212. );
  213. #endif