]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
3fc7da1920e2421d0e2bad0cd9726d54f61970c6
[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
31 #include "ComponentName.h"
32
33 #define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
34
35 typedef struct {
36 UINT32 Signature;
37
38 EFI_HANDLE ControllerHandle;
39
40 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
41 EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
42
43 UINT32 Mtu;
44
45 LIST_ENTRY ChildrenList;
46 UINTN ChildrenNumber;
47 UINTN ConfiguredChildrenNumber;
48
49 LIST_ENTRY GroupAddressList;
50 UINT32 GroupAddressCount;
51
52 EFI_EVENT TxTimeoutEvent;
53
54 NET_BUF_QUEUE FreeNbufQue;
55 INTN NbufCnt;
56
57 EFI_EVENT PollTimer;
58 BOOLEAN EnableSystemPoll;
59
60 EFI_EVENT TimeoutCheckTimer;
61
62 UINT32 UnicastCount;
63 UINT32 BroadcastCount;
64 UINT32 MulticastCount;
65 UINT32 PromiscuousCount;
66
67 //
68 // The size of the data buffer in the MNP_PACKET_BUFFER used to
69 // store a packet.
70 //
71 UINT32 BufferLength;
72 UINT32 PaddingSize;
73 NET_BUF *RxNbufCache;
74 UINT8 *TxBuf;
75 } MNP_SERVICE_DATA;
76
77 #define MNP_SERVICE_DATA_FROM_THIS(a) \
78 CR ( \
79 (a), \
80 MNP_SERVICE_DATA, \
81 ServiceBinding, \
82 MNP_SERVICE_DATA_SIGNATURE \
83 )
84
85 /**
86 Test to see if this driver supports ControllerHandle. This service
87 is called by the EFI boot service ConnectController(). In
88 order to make drivers as small as possible, there are a few calling
89 restrictions for this service. ConnectController() must
90 follow these calling restrictions. If any other agent wishes to call
91 Supported() it must also follow these calling restrictions.
92
93 @param[in] This Protocol instance pointer.
94 @param[in] ControllerHandle Handle of device to test.
95 @param[in] RemainingDevicePath Optional parameter use to pick a specific
96 child device to start.
97
98 @retval EFI_SUCCESS This driver supports this device.
99 @retval EFI_ALREADY_STARTED This driver is already running on this device.
100 @retval Others This driver does not support this device.
101
102 **/
103 EFI_STATUS
104 EFIAPI
105 MnpDriverBindingSupported (
106 IN EFI_DRIVER_BINDING_PROTOCOL *This,
107 IN EFI_HANDLE ControllerHandle,
108 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
109 );
110
111 /**
112 Start this driver on ControllerHandle. This service is called by the
113 EFI boot service ConnectController(). In order to make drivers as small
114 as possible, there are a few calling restrictions for this service.
115 ConnectController() must follow these calling restrictions. If any other
116 agent wishes to call Start() it must also follow these calling restrictions.
117
118 @param[in] This Protocol instance pointer.
119 @param[in] ControllerHandle Handle of device to bind driver to.
120 @param[in] RemainingDevicePath Optional parameter use to pick a specific
121 child device to start.
122
123 @retval EFI_SUCCESS This driver is added to ControllerHandle.
124 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
125 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for Mnp Service Data.
126 @retval Others This driver does not support this device.
127
128 **/
129 EFI_STATUS
130 EFIAPI
131 MnpDriverBindingStart (
132 IN EFI_DRIVER_BINDING_PROTOCOL *This,
133 IN EFI_HANDLE ControllerHandle,
134 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
135 );
136
137
138 /**
139 Stop this driver on ControllerHandle. This service is called by the
140 EFI boot service DisconnectController(). In order to make drivers as
141 small as possible, there are a few calling restrictions for this service.
142 DisconnectController() must follow these calling restrictions. If any other
143 agent wishes to call Stop() it must also follow these calling restrictions.
144
145 @param[in] This Protocol instance pointer.
146 @param[in] ControllerHandle Handle of device to stop driver on.
147 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If
148 number of children is zero stop the entire
149 bus driver.
150 @param[in] ChildHandleBuffer List of Child Handles to Stop.
151
152 @retval EFI_SUCCESS This driver is removed ControllerHandle.
153 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
154
155 **/
156 EFI_STATUS
157 EFIAPI
158 MnpDriverBindingStop (
159 IN EFI_DRIVER_BINDING_PROTOCOL *This,
160 IN EFI_HANDLE ControllerHandle,
161 IN UINTN NumberOfChildren,
162 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
163 );
164
165 /**
166 Creates a child handle with a set of I/O services.
167
168 @param[in] This Protocol instance pointer.
169 @param[in, out] ChildHandle Pointer to the handle of the child to create. If
170 it is NULL, then a new handle is created. If
171 it is not NULL, then the I/O services are added
172 to the existing child handle.
173
174 @retval EFI_SUCCES The protocol was added to ChildHandle.
175 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
176 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to
177 create the child.
178 @retval Others The child handle was not created.
179
180 **/
181 EFI_STATUS
182 EFIAPI
183 MnpServiceBindingCreateChild (
184 IN EFI_SERVICE_BINDING_PROTOCOL *This,
185 IN OUT EFI_HANDLE *ChildHandle
186 );
187
188 /**
189 Destroys a child handle with a set of I/O services.
190
191 The DestroyChild() function does the opposite of CreateChild(). It removes a
192 protocol that was installed by CreateChild() from ChildHandle. If the removed
193 protocol is the last protocol on ChildHandle, then ChildHandle is destroyed.
194
195 @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL
196 instance.
197 @param[in] ChildHandle Handle of the child to destroy.
198
199 @retval EFI_SUCCES The protocol was removed from ChildHandle.
200 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that
201 is being removed.
202 @retval EFI_INVALID_PARAMETER ChildHandle is not a valid UEFI handle.
203 @retval EFI_ACCESS_DENIED The protocol could not be removed from the
204 ChildHandle because its services are being
205 used.
206 @retval Others The child handle was not destroyed.
207
208 **/
209 EFI_STATUS
210 EFIAPI
211 MnpServiceBindingDestroyChild (
212 IN EFI_SERVICE_BINDING_PROTOCOL *This,
213 IN EFI_HANDLE ChildHandle
214 );
215
216 #endif