xref: /netbsd/sys/external/bsd/gnu-efi/dist/inc/efinet.h (revision 974f52d2)
1 /*	$NetBSD: efinet.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $	*/
2 
3 #ifndef _EFINET_H
4 #define _EFINET_H
5 
6 
7 /*++
8 Copyright (c) 1999  Intel Corporation
9 
10 Module Name:
11     efinet.h
12 
13 Abstract:
14     EFI Simple Network protocol
15 
16 Revision History
17 --*/
18 
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 //
22 //      Simple Network Protocol
23 //
24 
25 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
26     { 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} }
27 
28 INTERFACE_DECL(_EFI_SIMPLE_NETWORK_PROTOCOL);
29 
30 ///////////////////////////////////////////////////////////////////////////////
31 //
32 
33 typedef struct {
34     //
35     // Total number of frames received.  Includes frames with errors and
36     // dropped frames.
37     //
38     UINT64  RxTotalFrames;
39 
40     //
41     // Number of valid frames received and copied into receive buffers.
42     //
43     UINT64  RxGoodFrames;
44 
45     //
46     // Number of frames below the minimum length for the media.
47     // This would be <64 for ethernet.
48     //
49     UINT64  RxUndersizeFrames;
50 
51     //
52     // Number of frames longer than the maxminum length for the
53     // media.  This would be >1500 for ethernet.
54     //
55     UINT64  RxOversizeFrames;
56 
57     //
58     // Valid frames that were dropped because receive buffers were full.
59     //
60     UINT64  RxDroppedFrames;
61 
62     //
63     // Number of valid unicast frames received and not dropped.
64     //
65     UINT64  RxUnicastFrames;
66 
67     //
68     // Number of valid broadcast frames received and not dropped.
69     //
70     UINT64  RxBroadcastFrames;
71 
72     //
73     // Number of valid mutlicast frames received and not dropped.
74     //
75     UINT64  RxMulticastFrames;
76 
77     //
78     // Number of frames w/ CRC or alignment errors.
79     //
80     UINT64  RxCrcErrorFrames;
81 
82     //
83     // Total number of bytes received.  Includes frames with errors
84     // and dropped frames.
85     //
86     UINT64  RxTotalBytes;
87 
88     //
89     // Transmit statistics.
90     //
91     UINT64  TxTotalFrames;
92     UINT64  TxGoodFrames;
93     UINT64  TxUndersizeFrames;
94     UINT64  TxOversizeFrames;
95     UINT64  TxDroppedFrames;
96     UINT64  TxUnicastFrames;
97     UINT64  TxBroadcastFrames;
98     UINT64  TxMulticastFrames;
99     UINT64  TxCrcErrorFrames;
100     UINT64  TxTotalBytes;
101 
102     //
103     // Number of collisions detection on this subnet.
104     //
105     UINT64  Collisions;
106 
107     //
108     // Number of frames destined for unsupported protocol.
109     //
110     UINT64  UnsupportedProtocol;
111 
112 } EFI_NETWORK_STATISTICS;
113 
114 ///////////////////////////////////////////////////////////////////////////////
115 //
116 
117 typedef enum {
118     EfiSimpleNetworkStopped,
119     EfiSimpleNetworkStarted,
120     EfiSimpleNetworkInitialized,
121     EfiSimpleNetworkMaxState
122 } EFI_SIMPLE_NETWORK_STATE;
123 
124 ///////////////////////////////////////////////////////////////////////////////
125 //
126 
127 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST               0x01
128 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST             0x02
129 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST             0x04
130 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS           0x08
131 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
132 
133 ///////////////////////////////////////////////////////////////////////////////
134 //
135 
136 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT        0x01
137 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT       0x02
138 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT        0x04
139 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT       0x08
140 
141 ///////////////////////////////////////////////////////////////////////////////
142 //
143 #define MAX_MCAST_FILTER_CNT    16
144 typedef struct {
145     UINT32                      State;
146     UINT32                      HwAddressSize;
147     UINT32                      MediaHeaderSize;
148     UINT32                      MaxPacketSize;
149     UINT32                      NvRamSize;
150     UINT32                      NvRamAccessSize;
151     UINT32                      ReceiveFilterMask;
152     UINT32                      ReceiveFilterSetting;
153     UINT32                      MaxMCastFilterCount;
154     UINT32                      MCastFilterCount;
155     EFI_MAC_ADDRESS             MCastFilter[MAX_MCAST_FILTER_CNT];
156     EFI_MAC_ADDRESS             CurrentAddress;
157     EFI_MAC_ADDRESS             BroadcastAddress;
158     EFI_MAC_ADDRESS             PermanentAddress;
159     UINT8                       IfType;
160     BOOLEAN                     MacAddressChangeable;
161     BOOLEAN                     MultipleTxSupported;
162     BOOLEAN                     MediaPresentSupported;
163     BOOLEAN                     MediaPresent;
164 } EFI_SIMPLE_NETWORK_MODE;
165 
166 ///////////////////////////////////////////////////////////////////////////////
167 //
168 
169 typedef
170 EFI_STATUS
171 (EFIAPI *EFI_SIMPLE_NETWORK_START) (
172     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This
173 );
174 
175 ///////////////////////////////////////////////////////////////////////////////
176 //
177 
178 typedef
179 EFI_STATUS
180 (EFIAPI *EFI_SIMPLE_NETWORK_STOP) (
181     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This
182 );
183 
184 ///////////////////////////////////////////////////////////////////////////////
185 //
186 
187 typedef
188 EFI_STATUS
189 (EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE) (
190     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
191     IN UINTN                                ExtraRxBufferSize  OPTIONAL,
192     IN UINTN                                ExtraTxBufferSize  OPTIONAL
193 );
194 
195 ///////////////////////////////////////////////////////////////////////////////
196 //
197 
198 typedef
199 EFI_STATUS
200 (EFIAPI *EFI_SIMPLE_NETWORK_RESET) (
201     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
202     IN BOOLEAN                              ExtendedVerification
203 );
204 
205 ///////////////////////////////////////////////////////////////////////////////
206 //
207 
208 typedef
209 EFI_STATUS
210 (EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN) (
211     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This
212 );
213 
214 ///////////////////////////////////////////////////////////////////////////////
215 //
216 
217 typedef
218 EFI_STATUS
219 (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS) (
220     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
221     IN UINT32                               Enable,
222     IN UINT32                               Disable,
223     IN BOOLEAN                              ResetMCastFilter,
224     IN UINTN                                MCastFilterCnt     OPTIONAL,
225     IN EFI_MAC_ADDRESS                      *MCastFilter       OPTIONAL
226 );
227 
228 ///////////////////////////////////////////////////////////////////////////////
229 //
230 
231 typedef
232 EFI_STATUS
233 (EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS) (
234     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
235     IN BOOLEAN                              Reset,
236     IN EFI_MAC_ADDRESS                      *New      OPTIONAL
237 );
238 
239 ///////////////////////////////////////////////////////////////////////////////
240 //
241 
242 typedef
243 EFI_STATUS
244 (EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS) (
245     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
246     IN BOOLEAN                              Reset,
247     IN OUT UINTN                            *StatisticsSize   OPTIONAL,
248     OUT EFI_NETWORK_STATISTICS              *StatisticsTable  OPTIONAL
249 );
250 
251 ///////////////////////////////////////////////////////////////////////////////
252 //
253 
254 typedef
255 EFI_STATUS
256 (EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC) (
257     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
258     IN BOOLEAN                              IPv6,
259     IN EFI_IP_ADDRESS                       *IP,
260     OUT EFI_MAC_ADDRESS                     *MAC
261 );
262 
263 ///////////////////////////////////////////////////////////////////////////////
264 //
265 
266 typedef
267 EFI_STATUS
268 (EFIAPI *EFI_SIMPLE_NETWORK_NVDATA) (
269     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
270     IN BOOLEAN                              ReadWrite,
271     IN UINTN                                Offset,
272     IN UINTN                                BufferSize,
273     IN OUT VOID                             *Buffer
274 );
275 
276 ///////////////////////////////////////////////////////////////////////////////
277 //
278 
279 typedef
280 EFI_STATUS
281 (EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS) (
282     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
283     OUT UINT32                              *InterruptStatus  OPTIONAL,
284     OUT VOID                                **TxBuf           OPTIONAL
285 );
286 
287 ///////////////////////////////////////////////////////////////////////////////
288 //
289 
290 typedef
291 EFI_STATUS
292 (EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT) (
293     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
294     IN UINTN                                HeaderSize,
295     IN UINTN                                BufferSize,
296     IN VOID                                 *Buffer,
297     IN EFI_MAC_ADDRESS                      *SrcAddr     OPTIONAL,
298     IN EFI_MAC_ADDRESS                      *DestAddr    OPTIONAL,
299     IN UINT16                               *Protocol    OPTIONAL
300 );
301 
302 ///////////////////////////////////////////////////////////////////////////////
303 //
304 
305 typedef
306 EFI_STATUS
307 (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE) (
308     IN struct _EFI_SIMPLE_NETWORK_PROTOCOL  *This,
309     OUT UINTN                               *HeaderSize  OPTIONAL,
310     IN OUT UINTN                            *BufferSize,
311     OUT VOID                                *Buffer,
312     OUT EFI_MAC_ADDRESS                     *SrcAddr     OPTIONAL,
313     OUT EFI_MAC_ADDRESS                     *DestAddr    OPTIONAL,
314     OUT UINT16                              *Protocol    OPTIONAL
315 );
316 
317 ///////////////////////////////////////////////////////////////////////////////
318 //
319 
320 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION  0x00010000
321 #define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION
322 
323 typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL {
324     UINT64                              Revision;
325     EFI_SIMPLE_NETWORK_START            Start;
326     EFI_SIMPLE_NETWORK_STOP             Stop;
327     EFI_SIMPLE_NETWORK_INITIALIZE       Initialize;
328     EFI_SIMPLE_NETWORK_RESET            Reset;
329     EFI_SIMPLE_NETWORK_SHUTDOWN         Shutdown;
330     EFI_SIMPLE_NETWORK_RECEIVE_FILTERS  ReceiveFilters;
331     EFI_SIMPLE_NETWORK_STATION_ADDRESS  StationAddress;
332     EFI_SIMPLE_NETWORK_STATISTICS       Statistics;
333     EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC  MCastIpToMac;
334     EFI_SIMPLE_NETWORK_NVDATA           NvData;
335     EFI_SIMPLE_NETWORK_GET_STATUS       GetStatus;
336     EFI_SIMPLE_NETWORK_TRANSMIT         Transmit;
337     EFI_SIMPLE_NETWORK_RECEIVE          Receive;
338     EFI_EVENT                           WaitForPacket;
339     EFI_SIMPLE_NETWORK_MODE             *Mode;
340 } EFI_SIMPLE_NETWORK_PROTOCOL;
341 
342 // Note: Because it conflicted with the EDK2 struct name, the
343 // 'EFI_SIMPLE_NETWORK_PROTOCOL' GUID definition, from older
344 // versions of gnu-efi, is now obsoleted.
345 // Use 'EFI_SIMPLE_NETWORK_PROTOCOL_GUID' instead.
346 
347 typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL _EFI_SIMPLE_NETWORK;
348 typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK;
349 
350 #endif /* _EFINET_H */
351