xref: /haiku/headers/private/kernel/platform/efi/protocol/simple-network.h (revision 485b5cf8bc00ab5aaee5db81a91d135dc61d9cc3)
1 // Copyright 2016 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include <stdbool.h>
8 #include <efi/types.h>
9 
10 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
11     {0xa19832b9, 0xac25, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d}}
12 extern efi_guid SimpleNetworkProtocol;
13 
14 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
15 
16 #define MAX_MCAST_FILTER_CNT 16
17 typedef struct {
18     uint32_t State;
19     uint32_t HwAddressSize;
20     uint32_t MediaHeaderSize;
21     uint32_t MaxPacketSize;
22     uint32_t NvRamSize;
23     uint32_t NvRamAccessSize;
24     uint32_t ReceiveFilterMask;
25     uint32_t ReceiveFilterSetting;
26     uint32_t MaxMCastFilterCount;
27     uint32_t MCastFilterCount;
28     efi_mac_addr MCastFilter[MAX_MCAST_FILTER_CNT];
29     efi_mac_addr CurrentAddress;
30     efi_mac_addr BroadcastAddress;
31     efi_mac_addr PermanentAddress;
32     uint8_t IfType;
33     bool MacAddressChangeable;
34     bool MultipleTxSupported;
35     bool MediaPresentSupported;
36     bool MediaPresent;
37 } efi_simple_network_mode;
38 
39 typedef enum {
40     EfiSimpleNetworkStopped,
41     EfiSimpleNetworkStarted,
42     EfiSimpleNetworkInitialized,
43     EfiSimpleNetworkMaxState
44 } efi_simple_network_state;
45 
46 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST               0x01
47 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST             0x02
48 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST             0x04
49 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS           0x08
50 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
51 
52 typedef struct {
53     uint64_t RxTotalFrames;
54     uint64_t RxGoodFrames;
55     uint64_t RxUndersizeFrames;
56     uint64_t RxOversizeFrames;
57     uint64_t RxDroppedFrames;
58     uint64_t RxUnicastFrames;
59     uint64_t RxBroadcastFrames;
60     uint64_t RxMulticastFrames;
61     uint64_t RxCrcErrorFrames;
62     uint64_t RxTotalBytes;
63     uint64_t TxTotalFrames;
64     uint64_t TxGoodFrames;
65     uint64_t TxUndersizeFrames;
66     uint64_t TxOversizeFrames;
67     uint64_t TxDroppedFrames;
68     uint64_t TxUnicastFrames;
69     uint64_t TxBroadcastFrames;
70     uint64_t TxMulticastFrames;
71     uint64_t TxCrcErrorFrames;
72     uint64_t TxTotalBytes;
73     uint64_t Collisions;
74     uint64_t UnsupportedProtocol;
75     uint64_t RxDuplicatedFrames;
76     uint64_t RxDecryptErrorFrames;
77     uint64_t TxErrorFrames;
78     uint64_t TxRetryFrames;
79 } efi_network_statistics;
80 
81 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT  0x01
82 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
83 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT  0x04
84 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
85 
86 typedef struct efi_simple_network_protocol {
87     uint64_t Revision;
88 
89     efi_status (*Start) (struct efi_simple_network_protocol* self) EFIAPI;
90 
91     efi_status (*Stop) (struct efi_simple_network_protocol* self) EFIAPI;
92 
93     efi_status (*Initialize) (struct efi_simple_network_protocol* self,
94                               size_t extra_rx_buf_size, size_t extra_tx_buf_size) EFIAPI;
95 
96     efi_status (*Reset) (struct efi_simple_network_protocol* self,
97                          bool extended_verification) EFIAPI;
98 
99     efi_status (*Shutdown) (struct efi_simple_network_protocol* self) EFIAPI;
100 
101     efi_status (*ReceiveFilters) (struct efi_simple_network_protocol* self,
102                                   uint32_t enable, uint32_t disable,
103                                   bool reset_mcast_filter, size_t mcast_filter_count,
104                                   efi_mac_addr* mcast_filter) EFIAPI;
105 
106     efi_status (*StationAddress) (struct efi_simple_network_protocol* self,
107                                   bool reset, efi_mac_addr* new_addr) EFIAPI;
108 
109     efi_status (*Statistics) (struct efi_simple_network_protocol* self,
110                               bool reset, size_t* stats_size,
111                               efi_network_statistics* stats_table) EFIAPI;
112 
113     efi_status (*MCastIpToMac) (struct efi_simple_network_protocol* self,
114                                 bool ipv6, efi_ip_addr* ip, efi_mac_addr* mac) EFIAPI;
115 
116     efi_status (*NvData) (struct efi_simple_network_protocol* self,
117                           bool read_write, size_t offset, size_t buf_size, void* buf) EFIAPI;
118 
119     efi_status (*GetStatus) (struct efi_simple_network_protocol* self,
120                              uint32_t* interrupt_status, void** tx_buf) EFIAPI;
121 
122     efi_status (*Transmit) (struct efi_simple_network_protocol* self,
123                             size_t header_size, size_t buf_size, void* buf,
124                             efi_mac_addr* src, efi_mac_addr* dest, uint16_t* protocol) EFIAPI;
125 
126     efi_status (*Receive) (struct efi_simple_network_protocol* self,
127                            size_t* header_size, size_t* buf_size, void* buf,
128                            efi_mac_addr* src, efi_mac_addr* dest, uint16_t* protocol) EFIAPI;
129 
130     efi_event WaitForPacket;
131     efi_simple_network_mode* Mode;
132 } efi_simple_network_protocol;
133