]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
d410af2726ac82ad07fc611a36d04d7ea1bc5c7d
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpDriver.h
1 /** @file
2 Declaration of strctures and functions for MnpDxe driver.
3
4 Copyright (c) 2005 - 2010, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The full
8 text of the license may be found at<BR>
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _MNP_DRIVER_H_
17 #define _MNP_DRIVER_H_
18
19 #include <Uefi.h>
20
21 #include <Protocol/ManagedNetwork.h>
22 #include <Protocol/SimpleNetwork.h>
23 #include <Protocol/ServiceBinding.h>
24 #include <Protocol/VlanConfig.h>
25
26 #include <Library/BaseLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/NetLib.h>
33 #include <Library/DpcLib.h>
34 #include <Library/UefiRuntimeServicesTableLib.h>
35 #include <Library/DevicePathLib.h>
36
37 #include "ComponentName.h"
38
39 #define MNP_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'D')
40
41 typedef struct {
42 UINT32 Signature;
43
44 EFI_HANDLE ControllerHandle;
45 EFI_HANDLE ImageHandle;
46
47 EFI_VLAN_CONFIG_PROTOCOL VlanConfig;
48 UINTN NumberOfVlan;
49 CHAR16 *MacString;
50 EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
51
52 //
53 // List of MNP_SERVICE_DATA
54 //
55 LIST_ENTRY ServiceList;
56 //
57 // Number of configured MNP Service Binding child
58 //
59 UINTN ConfiguredChildrenNumber;
60
61 LIST_ENTRY GroupAddressList;
62 UINT32 GroupAddressCount;
63
64 EFI_EVENT TxTimeoutEvent;
65
66 NET_BUF_QUEUE FreeNbufQue;
67 INTN NbufCnt;
68
69 EFI_EVENT PollTimer;
70 BOOLEAN EnableSystemPoll;
71
72 EFI_EVENT TimeoutCheckTimer;
73 EFI_EVENT MediaDetectTimer;
74
75 UINT32 UnicastCount;
76 UINT32 BroadcastCount;
77 UINT32 MulticastCount;
78 UINT32 PromiscuousCount;
79
80 //
81 // The size of the data buffer in the MNP_PACKET_BUFFER used to
82 // store a packet.
83 //
84 UINT32 BufferLength;
85 UINT32 PaddingSize;
86 NET_BUF *RxNbufCache;
87 UINT8 *TxBuf;
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
120 #define MNP_SERVICE_DATA_FROM_THIS(a) \
121 CR ( \
122 (a), \
123 MNP_SERVICE_DATA, \
124 ServiceBinding, \
125 MNP_SERVICE_DATA_SIGNATURE \
126 )
127
128 #define MNP_SERVICE_DATA_FROM_LINK(a) \
129 CR ( \
130 (a), \
131 MNP_SERVICE_DATA, \
132 Link, \
133 MNP_SERVICE_DATA_SIGNATURE \
134 )
135
136
137 /**
138 Test to see if this driver supports ControllerHandle. This service
139 is called by the EFI boot service ConnectController(). In
140 order to make drivers as small as possible, there are a few calling
141 restrictions for this service. ConnectController() must
142 follow these calling restrictions. If any other agent wishes to call
143 Supported() it must also follow these calling restrictions.
144
145 @param[in] This Protocol instance pointer.
146 @param[in] ControllerHandle Handle of device to test.
147 @param[in] RemainingDevicePath Optional parameter use to pick a specific
148 child device to start.
149
150 @retval EFI_SUCCESS This driver supports this device.
151 @retval EFI_ALREADY_STARTED This driver is already running on this device.
152 @retval Others This driver does not support this device.
153
154 **/
155 EFI_STATUS
156 EFIAPI
157 MnpDriverBindingSupported (
158 IN EFI_DRIVER_BINDING_PROTOCOL *This,
159 IN EFI_HANDLE ControllerHandle,
160 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
161 );
162
163 /**
164 Start this driver on ControllerHandle. This service is called by the
165 EFI boot service ConnectController(). In order to make drivers as small
166 as possible, there are a few calling restrictions for this service.
167 ConnectController() must follow these calling restrictions. If any other
168 agent wishes to call Start() it must also follow these calling restrictions.
169
170 @param[in] This Protocol instance pointer.
171 @param[in] ControllerHandle Handle of device to bind driver to.
172 @param[in] RemainingDevicePath Optional parameter use to pick a specific
173 child device to start.
174
175 @retval EFI_SUCCESS This driver is added to ControllerHandle.
176 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
177 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
178 @retval Others This driver does not support this device.
179
180 **/
181 EFI_STATUS
182 EFIAPI
183 MnpDriverBindingStart (
184 IN EFI_DRIVER_BINDING_PROTOCOL *This,
185 IN EFI_HANDLE ControllerHandle,
186 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
187 );
188
189
190 /**
191 Stop this driver on ControllerHandle. This service is called by the
192 EFI boot service DisconnectController(). In order to make drivers as
193 small as possible, there are a few calling restrictions for this service.
194 DisconnectController() must follow these calling restrictions. If any other
195 agent wishes to call Stop() it must also follow these calling restrictions.
196
197 @param[in] This Protocol instance pointer.
198 @param[in] ControllerHandle Handle of device to stop driver on.
199 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
200 number of children is zero stop the entire
201 bus driver.
202 @param[in] ChildHandleBuffer List of Child Handles to Stop.
203
204 @retval EFI_SUCCESS This driver is removed ControllerHandle.
205 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
206
207 **/
208 EFI_STATUS
209 EFIAPI
210 MnpDriverBindingStop (
211 IN EFI_DRIVER_BINDING_PROTOCOL *This,
212 IN EFI_HANDLE ControllerHandle,
213 IN UINTN NumberOfChildren,
214 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
215 );
216
217 /**
218 Creates a child handle with a set of I/O services.
219
220 @param[in] This Protocol instance pointer.
221 @param[in, out] ChildHandle Pointer to the handle of the child to create. If
222 it is NULL, then a new handle is created. If
223 it is not NULL, then the I/O services are added
224 to the existing child handle.
225
226 @retval EFI_SUCCES The protocol was added to ChildHandle.
227 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
228 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
229 create the child.
230 @retval Others The child handle was not created.
231
232 **/
233 EFI_STATUS
234 EFIAPI
235 MnpServiceBindingCreateChild (
236 IN EFI_SERVICE_BINDING_PROTOCOL *This,
237 IN OUT EFI_HANDLE *ChildHandle
238 );
239
240 /**
241 Destroys a child handle with a set of I/O services.
242
243 The DestroyChild() function does the opposite of CreateChild(). It removes a
244 protocol that was installed by CreateChild() from ChildHandle. If the removed
245 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
246
247 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
248 instance.
249 @param[in] ChildHandle Handle of the child to destroy.
250
251 @retval EFI_SUCCES The protocol was removed from ChildHandle.
252 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
253 is being removed.
254 @retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle.
255 @retval EFI_ACCESS_DENIED The protocol could not be removed from the
256 ChildHandle because its services are being
257 used.
258 @retval Others The child handle was not destroyed.
259
260 **/
261 EFI_STATUS
262 EFIAPI
263 MnpServiceBindingDestroyChild (
264 IN EFI_SERVICE_BINDING_PROTOCOL *This,
265 IN EFI_HANDLE ChildHandle
266 );
267
268 #endif