VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/E1kNetDxe/E1kNet.h

Last change on this file was 106066, checked in by vboxsync, 7 weeks ago

Manual copyright year updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1/** @file
2
3 Internal definitions for the virtio-net driver, which produces Simple Network
4 Protocol instances for virtio-net devices.
5
6 Copyright (c) 2021-2024, Oracle and/or its affiliates.
7 Copyright (c) 2017, AMD Inc, All rights reserved.
8 Copyright (C) 2013, Red Hat, Inc.<BR>
9
10 SPDX-License-Identifier: BSD-2-Clause-Patent
11**/
12
13#ifndef _E1K_NET_DXE_H_
14#define _E1K_NET_DXE_H_
15
16#include <Library/DebugLib.h>
17#include <Protocol/PciIo.h>
18#include <Protocol/PciRootBridgeIo.h>
19#include <Protocol/ComponentName.h>
20#include <Protocol/ComponentName2.h>
21#include <Protocol/DevicePath.h>
22#include <Protocol/DriverBinding.h>
23#include <Protocol/SimpleNetwork.h>
24#include <Library/OrderedCollectionLib.h>
25
26#include "E1kNetHw.h"
27
28#define E1K_NET_DEV_SIGNATURE SIGNATURE_32 ('E','1','K','N')
29
30//
31// maximum number of pending packets, separately for each direction
32//
33#define E1K_NET_MAX_PENDING 64
34
35//
36// State diagram:
37//
38// | ^
39// | |
40// BindingStart BindingStop
41// +SnpPopulate |
42// ++GetFeatures |
43// | |
44// v |
45// +---------+ virtio-net device is reset, no resources are
46// | stopped | allocated for traffic, but MAC address has
47// +---------+ been retrieved
48// | ^
49// | |
50// SNP.Start SNP.Stop
51// | |
52// v |
53// +---------+
54// | started | functionally identical to stopped
55// +---------+
56// | ^
57// | |
58// SNP.Initialize SNP.Shutdown
59// | |
60// v |
61// +-------------+ Virtio-net setup complete, including DRIVER_OK
62// | initialized | bit. The receive queue is populated with
63// +-------------+ requests; McastIpToMac, GetStatus, Transmit,
64// Receive are callable.
65//
66
67typedef struct {
68 //
69 // Parts of this structure are initialized / torn down in various functions
70 // at various call depths. The table to the right should make it easier to
71 // track them.
72 //
73 // field init function
74 // ------------------ ------------------------------
75 UINT32 Signature; // VirtioNetDriverBindingStart
76 EFI_PCI_IO_PROTOCOL *PciIo; // VirtioNetDriverBindingStart
77 UINT64 OriginalPciAttributes; // VirtioNetDriverBindingStart
78 EFI_SIMPLE_NETWORK_PROTOCOL Snp; // VirtioNetSnpPopulate
79 EFI_SIMPLE_NETWORK_MODE Snm; // VirtioNetSnpPopulate
80 EFI_EVENT ExitBoot; // VirtioNetSnpPopulate
81 EFI_DEVICE_PATH_PROTOCOL *MacDevicePath; // VirtioNetDriverBindingStart
82 EFI_HANDLE MacHandle; // VirtioNetDriverBindingStart
83
84 E1K_RX_DESC *RxRing; // VirtioNetInitRing
85 UINT8 *RxBuf; // E1kNetInitRx
86 UINT32 RdhLastSeen; // E1kNetInitRx
87 UINTN RxBufNrPages; // E1kNetInitRx
88 EFI_PHYSICAL_ADDRESS RxBufDeviceBase; // E1kNetInitRx
89 EFI_PHYSICAL_ADDRESS RxDeviceBase; // E1kNetInitRx
90 VOID *RxMap; // E1kNetInitRx
91
92 UINT16 TxMaxPending; // E1kNetInitTx
93 UINT16 TxCurPending; // E1kNetInitTx
94 E1K_TX_DESC *TxRing; // E1kNetInitTx
95 VOID *TxRingMap; // E1kNetInitTx
96 UINT16 TxLastUsed; // E1kNetInitTx
97 UINT32 TdhLastSeen; // E1kNetInitTx
98 ORDERED_COLLECTION *TxBufCollection; // E1kNetInitTx
99} E1K_NET_DEV;
100
101
102//
103// In order to avoid duplication of interface documentation, please find all
104// leading comments near the respective function / variable definitions (not
105// the declarations here), which is where your code editor of choice takes you
106// anyway when jumping to a function.
107//
108
109//
110// utility macros
111//
112#define E1K_NET_FROM_SNP(SnpPointer) \
113 CR (SnpPointer, E1K_NET_DEV, Snp, E1K_NET_DEV_SIGNATURE)
114
115//
116// component naming
117//
118extern EFI_COMPONENT_NAME_PROTOCOL gE1kNetComponentName;
119extern EFI_COMPONENT_NAME2_PROTOCOL gE1kNetComponentName2;
120
121//
122// driver binding
123//
124extern EFI_DRIVER_BINDING_PROTOCOL gE1kNetDriverBinding;
125
126//
127// member functions implementing the Simple Network Protocol
128//
129EFI_STATUS
130EFIAPI
131E1kNetStart (
132 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
133 );
134
135EFI_STATUS
136EFIAPI
137E1kNetStop (
138 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
139 );
140
141EFI_STATUS
142EFIAPI
143E1kNetInitialize (
144 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
145 IN UINTN ExtraRxBufferSize OPTIONAL,
146 IN UINTN ExtraTxBufferSize OPTIONAL
147 );
148
149EFI_STATUS
150EFIAPI
151E1kNetReset (
152 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
153 IN BOOLEAN ExtendedVerification
154 );
155
156EFI_STATUS
157EFIAPI
158E1kNetShutdown (
159 IN EFI_SIMPLE_NETWORK_PROTOCOL *This
160 );
161
162EFI_STATUS
163EFIAPI
164E1kNetReceiveFilters (
165 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
166 IN UINT32 Enable,
167 IN UINT32 Disable,
168 IN BOOLEAN ResetMCastFilter,
169 IN UINTN MCastFilterCnt OPTIONAL,
170 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL
171 );
172
173EFI_STATUS
174EFIAPI
175E1kNetStationAddress (
176 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
177 IN BOOLEAN Reset,
178 IN EFI_MAC_ADDRESS *New OPTIONAL
179 );
180
181EFI_STATUS
182EFIAPI
183E1kNetStatistics (
184 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
185 IN BOOLEAN Reset,
186 IN OUT UINTN *StatisticsSize OPTIONAL,
187 OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL
188 );
189
190EFI_STATUS
191EFIAPI
192E1kNetMcastIpToMac (
193 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
194 IN BOOLEAN IPv6,
195 IN EFI_IP_ADDRESS *Ip,
196 OUT EFI_MAC_ADDRESS *Mac
197 );
198
199EFI_STATUS
200EFIAPI
201E1kNetNvData (
202 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
203 IN BOOLEAN ReadWrite,
204 IN UINTN Offset,
205 IN UINTN BufferSize,
206 IN OUT VOID *Buffer
207 );
208
209EFI_STATUS
210EFIAPI
211E1kNetGetStatus (
212 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
213 OUT UINT32 *InterruptStatus OPTIONAL,
214 OUT VOID **TxBuf OPTIONAL
215 );
216
217EFI_STATUS
218EFIAPI
219E1kNetTransmit (
220 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
221 IN UINTN HeaderSize,
222 IN UINTN BufferSize,
223 IN /* +OUT! */ VOID *Buffer,
224 IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
225 IN EFI_MAC_ADDRESS *DestAddr OPTIONAL,
226 IN UINT16 *Protocol OPTIONAL
227 );
228
229EFI_STATUS
230EFIAPI
231E1kNetReceive (
232 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
233 OUT UINTN *HeaderSize OPTIONAL,
234 IN OUT UINTN *BufferSize,
235 OUT VOID *Buffer,
236 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL,
237 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL,
238 OUT UINT16 *Protocol OPTIONAL
239 );
240
241//
242// utility functions shared by various SNP member functions
243//
244VOID
245EFIAPI
246E1kNetShutdownRx (
247 IN OUT E1K_NET_DEV *Dev
248 );
249
250VOID
251EFIAPI
252E1kNetShutdownTx (
253 IN OUT E1K_NET_DEV *Dev
254 );
255
256//
257// utility functions to map caller-supplied Tx buffer system physical address
258// to a device address and vice versa
259//
260EFI_STATUS
261EFIAPI
262E1kNetMapTxBuf (
263 IN E1K_NET_DEV *Dev,
264 IN VOID *Buffer,
265 IN UINTN NumberOfBytes,
266 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress
267 );
268
269EFI_STATUS
270EFIAPI
271E1kNetUnmapTxBuf (
272 IN E1K_NET_DEV *Dev,
273 OUT VOID **Buffer,
274 IN EFI_PHYSICAL_ADDRESS DeviceAddress
275 );
276
277INTN
278EFIAPI
279E1kNetTxBufMapInfoCompare (
280 IN CONST VOID *UserStruct1,
281 IN CONST VOID *UserStruct2
282 );
283
284INTN
285EFIAPI
286E1kNetTxBufDeviceAddressCompare (
287 IN CONST VOID *StandaloneKey,
288 IN CONST VOID *UserStruct
289 );
290
291
292//
293// event callbacks
294//
295VOID
296EFIAPI
297E1kNetIsPacketAvailable (
298 IN EFI_EVENT Event,
299 IN VOID *Context
300 );
301
302VOID
303EFIAPI
304E1kNetExitBoot (
305 IN EFI_EVENT Event,
306 IN VOID *Context
307 );
308
309//
310// Hardware I/O functions.
311//
312EFI_STATUS
313EFIAPI
314E1kNetRegWrite32 (
315 IN E1K_NET_DEV *Dev,
316 IN UINT32 Addr,
317 IN UINT32 Data
318 );
319
320EFI_STATUS
321EFIAPI
322E1kNetRegRead32 (
323 IN E1K_NET_DEV *Dev,
324 IN UINT32 Addr,
325 OUT UINT32 *Data
326 );
327
328EFI_STATUS
329EFIAPI
330E1kNetRegSet32 (
331 IN E1K_NET_DEV *Dev,
332 IN UINT32 Addr,
333 IN UINT32 Set
334 );
335
336EFI_STATUS
337EFIAPI
338E1kNetRegClear32 (
339 IN E1K_NET_DEV *Dev,
340 IN UINT32 Addr,
341 IN UINT32 Clear
342 );
343
344EFI_STATUS
345EFIAPI
346E1kNetDevReset (
347 IN E1K_NET_DEV *Dev
348 );
349
350#endif // _E1K_NET_DXE_H_
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette