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