]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
e9698d2aacd8c0ad70d083875da0589e2222b27f
[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 - 2009, 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
74 UINT32 UnicastCount;
75 UINT32 BroadcastCount;
76 UINT32 MulticastCount;
77 UINT32 PromiscuousCount;
78
79 //
80 // The size of the data buffer in the MNP_PACKET_BUFFER used to
81 // store a packet.
82 //
83 UINT32 BufferLength;
84 UINT32 PaddingSize;
85 NET_BUF *RxNbufCache;
86 UINT8 *TxBuf;
87 } MNP_DEVICE_DATA;
88
89 #define MNP_DEVICE_DATA_FROM_THIS(a) \
90 CR ( \
91 (a), \
92 MNP_DEVICE_DATA, \
93 VlanConfig, \
94 MNP_DEVICE_DATA_SIGNATURE \
95 )
96
97 #define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
98
99 typedef struct {
100 UINT32 Signature;
101
102 LIST_ENTRY Link;
103
104 MNP_DEVICE_DATA *MnpDeviceData;
105 EFI_HANDLE ServiceHandle;
106 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
107 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
108
109 LIST_ENTRY ChildrenList;
110 UINTN ChildrenNumber;
111
112 UINT32 Mtu;
113
114 UINT16 VlanId;
115 UINT8 Priority;
116 } MNP_SERVICE_DATA;
117
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 /**
137 Test to see if this driver supports ControllerHandle. This service
138 is called by the EFI boot service ConnectController(). In
139 order to make drivers as small as possible, there are a few calling
140 restrictions for this service. ConnectController() must
141 follow these calling restrictions. If any other agent wishes to call
142 Supported() it must also follow these calling restrictions.
143
144 @param[in] This Protocol instance pointer.
145 @param[in] ControllerHandle Handle of device to test.
146 @param[in] RemainingDevicePath Optional parameter use to pick a specific
147 child device to start.
148
149 @retval EFI_SUCCESS This driver supports this device.
150 @retval EFI_ALREADY_STARTED This driver is already running on this device.
151 @retval Others This driver does not support this device.
152
153 **/
154 EFI_STATUS
155 EFIAPI
156 MnpDriverBindingSupported (
157 IN EFI_DRIVER_BINDING_PROTOCOL *This,
158 IN EFI_HANDLE ControllerHandle,
159 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
160 );
161
162 /**
163 Start this driver on ControllerHandle. This service is called by the
164 EFI boot service ConnectController(). In order to make drivers as small
165 as possible, there are a few calling restrictions for this service.
166 ConnectController() must follow these calling restrictions. If any other
167 agent wishes to call Start() it must also follow these calling restrictions.
168
169 @param[in] This Protocol instance pointer.
170 @param[in] ControllerHandle Handle of device to bind driver to.
171 @param[in] RemainingDevicePath Optional parameter use to pick a specific
172 child device to start.
173
174 @retval EFI_SUCCESS This driver is added to ControllerHandle.
175 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
176 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
177 @retval Others This driver does not support this device.
178
179 **/
180 EFI_STATUS
181 EFIAPI
182 MnpDriverBindingStart (
183 IN EFI_DRIVER_BINDING_PROTOCOL *This,
184 IN EFI_HANDLE ControllerHandle,
185 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
186 );
187
188
189 /**
190 Stop this driver on ControllerHandle. This service is called by the
191 EFI boot service DisconnectController(). In order to make drivers as
192 small as possible, there are a few calling restrictions for this service.
193 DisconnectController() must follow these calling restrictions. If any other
194 agent wishes to call Stop() it must also follow these calling restrictions.
195
196 @param[in] This Protocol instance pointer.
197 @param[in] ControllerHandle Handle of device to stop driver on.
198 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
199 number of children is zero stop the entire
200 bus driver.
201 @param[in] ChildHandleBuffer List of Child Handles to Stop.
202
203 @retval EFI_SUCCESS This driver is removed ControllerHandle.
204 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
205
206 **/
207 EFI_STATUS
208 EFIAPI
209 MnpDriverBindingStop (
210 IN EFI_DRIVER_BINDING_PROTOCOL *This,
211 IN EFI_HANDLE ControllerHandle,
212 IN UINTN NumberOfChildren,
213 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
214 );
215
216 /**
217 Creates a child handle with a set of I/O services.
218
219 @param[in] This Protocol instance pointer.
220 @param[in, out] ChildHandle Pointer to the handle of the child to create. If
221 it is NULL, then a new handle is created. If
222 it is not NULL, then the I/O services are added
223 to the existing child handle.
224
225 @retval EFI_SUCCES The protocol was added to ChildHandle.
226 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
227 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
228 create the child.
229 @retval Others The child handle was not created.
230
231 **/
232 EFI_STATUS
233 EFIAPI
234 MnpServiceBindingCreateChild (
235 IN EFI_SERVICE_BINDING_PROTOCOL *This,
236 IN OUT EFI_HANDLE *ChildHandle
237 );
238
239 /**
240 Destroys a child handle with a set of I/O services.
241
242 The DestroyChild() function does the opposite of CreateChild(). It removes a
243 protocol that was installed by CreateChild() from ChildHandle. If the removed
244 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
245
246 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
247 instance.
248 @param[in] ChildHandle Handle of the child to destroy.
249
250 @retval EFI_SUCCES The protocol was removed from ChildHandle.
251 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
252 is being removed.
253 @retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle.
254 @retval EFI_ACCESS_DENIED The protocol could not be removed from the
255 ChildHandle because its services are being
256 used.
257 @retval Others The child handle was not destroyed.
258
259 **/
260 EFI_STATUS
261 EFIAPI
262 MnpServiceBindingDestroyChild (
263 IN EFI_SERVICE_BINDING_PROTOCOL *This,
264 IN EFI_HANDLE ChildHandle
265 );
266
267 #endif