]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
1. Fix timer unit bug in MNP: default rx/tx timeout value should be 10,000,000 (10s...
[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 - 2007, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials are licensed
6 and made available under the terms and conditions of the BSD License which
7 accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _MNP_DRIVER_H_
16 #define _MNP_DRIVER_H_
17 #include <Uefi.h>
18
19 #include <Protocol/ManagedNetwork.h>
20 #include <Protocol/SimpleNetwork.h>
21 #include <Protocol/ServiceBinding.h>
22
23 #include <Library/BaseLib.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/UefiLib.h>
29 #include <Library/NetLib.h>
30 #include <Library/DpcLib.h>
31
32 #include "ComponentName.h"
33
34 #define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
35
36 typedef struct {
37 UINT32 Signature;
38
39 EFI_HANDLE ControllerHandle;
40
41 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
42 EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
43
44 UINT32 Mtu;
45
46 LIST_ENTRY ChildrenList;
47 UINTN ChildrenNumber;
48 UINTN ConfiguredChildrenNumber;
49
50 LIST_ENTRY GroupAddressList;
51 UINT32 GroupAddressCount;
52
53 EFI_EVENT TxTimeoutEvent;
54
55 NET_BUF_QUEUE FreeNbufQue;
56 INTN NbufCnt;
57
58 EFI_EVENT PollTimer;
59 BOOLEAN EnableSystemPoll;
60
61 EFI_EVENT TimeoutCheckTimer;
62
63 UINT32 UnicastCount;
64 UINT32 BroadcastCount;
65 UINT32 MulticastCount;
66 UINT32 PromiscuousCount;
67
68 //
69 // The size of the data buffer in the MNP_PACKET_BUFFER used to
70 // store a packet.
71 //
72 UINT32 BufferLength;
73 UINT32 PaddingSize;
74 NET_BUF *RxNbufCache;
75 UINT8 *TxBuf;
76 } MNP_SERVICE_DATA;
77
78 #define MNP_SERVICE_DATA_FROM_THIS(a) \
79 CR ( \
80 (a), \
81 MNP_SERVICE_DATA, \
82 ServiceBinding, \
83 MNP_SERVICE_DATA_SIGNATURE \
84 )
85
86 /**
87 Test to see if this driver supports ControllerHandle. This service
88 is called by the EFI boot service ConnectController(). In
89 order to make drivers as small as possible, there are a few calling
90 restrictions for this service. ConnectController() must
91 follow these calling restrictions. If any other agent wishes to call
92 Supported() it must also follow these calling restrictions.
93
94 @param[in] This Protocol instance pointer.
95 @param[in] ControllerHandle Handle of device to test.
96 @param[in] RemainingDevicePath Optional parameter use to pick a specific
97 child device to start.
98
99 @retval EFI_SUCCESS This driver supports this device.
100 @retval EFI_ALREADY_STARTED This driver is already running on this device.
101 @retval Others This driver does not support this device.
102
103 **/
104 EFI_STATUS
105 EFIAPI
106 MnpDriverBindingSupported (
107 IN EFI_DRIVER_BINDING_PROTOCOL *This,
108 IN EFI_HANDLE ControllerHandle,
109 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
110 );
111
112 /**
113 Start this driver on ControllerHandle. This service is called by the
114 EFI boot service ConnectController(). In order to make drivers as small
115 as possible, there are a few calling restrictions for this service.
116 ConnectController() must follow these calling restrictions. If any other
117 agent wishes to call Start() it must also follow these calling restrictions.
118
119 @param[in] This Protocol instance pointer.
120 @param[in] ControllerHandle Handle of device to bind driver to.
121 @param[in] RemainingDevicePath Optional parameter use to pick a specific
122 child device to start.
123
124 @retval EFI_SUCCESS This driver is added to ControllerHandle.
125 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
126 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
127 @retval Others This driver does not support this device.
128
129 **/
130 EFI_STATUS
131 EFIAPI
132 MnpDriverBindingStart (
133 IN EFI_DRIVER_BINDING_PROTOCOL *This,
134 IN EFI_HANDLE ControllerHandle,
135 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
136 );
137
138
139 /**
140 Stop this driver on ControllerHandle. This service is called by the
141 EFI boot service DisconnectController(). In order to make drivers as
142 small as possible, there are a few calling restrictions for this service.
143 DisconnectController() must follow these calling restrictions. If any other
144 agent wishes to call Stop() it must also follow these calling restrictions.
145
146 @param[in] This Protocol instance pointer.
147 @param[in] ControllerHandle Handle of device to stop driver on.
148 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
149 number of children is zero stop the entire
150 bus driver.
151 @param[in] ChildHandleBuffer List of Child Handles to Stop.
152
153 @retval EFI_SUCCESS This driver is removed ControllerHandle.
154 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
155
156 **/
157 EFI_STATUS
158 EFIAPI
159 MnpDriverBindingStop (
160 IN EFI_DRIVER_BINDING_PROTOCOL *This,
161 IN EFI_HANDLE ControllerHandle,
162 IN UINTN NumberOfChildren,
163 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
164 );
165
166 /**
167 Creates a child handle with a set of I/O services.
168
169 @param[in] This Protocol instance pointer.
170 @param[in, out] ChildHandle Pointer to the handle of the child to create. If
171 it is NULL, then a new handle is created. If
172 it is not NULL, then the I/O services are added
173 to the existing child handle.
174
175 @retval EFI_SUCCES The protocol was added to ChildHandle.
176 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
177 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
178 create the child.
179 @retval Others The child handle was not created.
180
181 **/
182 EFI_STATUS
183 EFIAPI
184 MnpServiceBindingCreateChild (
185 IN EFI_SERVICE_BINDING_PROTOCOL *This,
186 IN OUT EFI_HANDLE *ChildHandle
187 );
188
189 /**
190 Destroys a child handle with a set of I/O services.
191
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
196 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
197 instance.
198 @param[in] ChildHandle Handle of the child to destroy.
199
200 @retval EFI_SUCCES The protocol was removed from ChildHandle.
201 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
202 is being removed.
203 @retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle.
204 @retval EFI_ACCESS_DENIED The protocol could not be removed from the
205 ChildHandle because its services are being
206 used.
207 @retval Others The child handle was not destroyed.
208
209 **/
210 EFI_STATUS
211 EFIAPI
212 MnpServiceBindingDestroyChild (
213 IN EFI_SERVICE_BINDING_PROTOCOL *This,
214 IN EFI_HANDLE ChildHandle
215 );
216
217 #endif