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