-
Notifications
You must be signed in to change notification settings - Fork 7
/
adapter.h
152 lines (120 loc) · 3.56 KB
/
adapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#pragma once
#include "bsd.h"
#include "if_rereg.h"
#include "bsdexport.h"
// multicast list size
#define RT_MAX_MCAST_LIST 32
// supported filters
#define RT_SUPPORTED_FILTERS ( \
NetPacketFilterFlagDirected | \
NetPacketFilterFlagMulticast | \
NetPacketFilterFlagBroadcast | \
NetPacketFilterFlagPromiscuous | \
NetPacketFilterFlagAllMulticast)
#define RT_MAX_TX_QUEUES (2)
#define RT_MAX_RX_QUEUES (4)
#define RT_MAX_QUEUES RT_MAX_RX_QUEUES
#define RT_GSO_OFFLOAD_MAX_SIZE 64000
#define RT_GSO_OFFLOAD_MIN_SEGMENT_COUNT 2
#define RT_GSO_OFFLOAD_LAYER_4_HEADER_OFFSET_LIMIT 127
#define RT_CHECKSUM_OFFLOAD_LAYER_4_HEADER_OFFSET_LIMIT 1023
typedef enum REG_SPEED_SETTING {
RtSpeedDuplexModeAutoNegotiation = 0,
RtSpeedDuplexMode10MHalfDuplex = 1,
RtSpeedDuplexMode10MFullDuplex = 2,
RtSpeedDuplexMode100MHalfDuplex = 3,
RtSpeedDuplexMode100MFullDuplex = 4,
RtSpeedDuplexMode1GHalfDuplex = 5,
RtSpeedDuplexMode1GFullDuplex = 6,
RtSpeedDuplexMode2GFullDuplex = 7,
RtSpeedDuplexMode5GFullDuplex = 8
} REG_SPEED_SETTING;
typedef enum _FLOW_CTRL {
NoFlowControl = 0,
FlowControlTxOnly = 1,
FlowControlRxOnly = 2,
FlowControlTxRx = 3
} FLOW_CTRL;
typedef struct _RT_TAG_802_1Q
{
union
{
struct
{
USHORT VLanID1 : 4;
USHORT CFI : 1;
USHORT Priority : 3;
USHORT VLanID2 : 8;
} TagHeader;
USHORT Value;
};
} RT_TAG_802_1Q;
typedef struct _RT_ADAPTER
{
// WDF handles associated with this context
NETADAPTER NetAdapter;
WDFDEVICE WdfDevice;
//Handle to default Tx and Rx Queues
NETPACKETQUEUE TxQueues[RT_MAX_TX_QUEUES];
NETPACKETQUEUE RxQueues[RT_MAX_RX_QUEUES];
// spin locks
WDFSPINLOCK Lock;
WDFDMAENABLER DmaEnabler;
// MMIO
PVOID MMIOAddress;
SIZE_T MMIOSize;
BUS_INTERFACE_STANDARD PciConfig;
// Pointer to interrupt object
RT_INTERRUPT* Interrupt;
// Multicast list
NET_PACKET_FILTER_FLAGS PacketFilterFlags;
UINT MCAddressCount;
NET_ADAPTER_LINK_LAYER_ADDRESS MCList[RT_MAX_MCAST_LIST];
// Configuration
REG_SPEED_SETTING SpeedDuplex;
NET_ADAPTER_LINK_LAYER_ADDRESS PermanentAddress;
NET_ADAPTER_LINK_LAYER_ADDRESS CurrentAddress;
BOOLEAN OverrideAddress;
FLOW_CTRL FlowControl;
UINT16 VlanID;
BOOLEAN isRTL8125;
ULONG64 MaxSpeed;
BOOLEAN TxIpHwChkSum;
BOOLEAN TxTcpHwChkSum;
BOOLEAN TxUdpHwChkSum;
BOOLEAN RxIpHwChkSum;
BOOLEAN RxTcpHwChkSum;
BOOLEAN RxUdpHwChkSum;
BOOLEAN LSOv4;
BOOLEAN LSOv6;
BOOLEAN EEEEnable;
struct re_softc bsdData;
} RT_ADAPTER, * PRT_ADAPTER;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(RT_ADAPTER, RtGetAdapterContext);
EVT_NET_ADAPTER_CREATE_TXQUEUE EvtAdapterCreateTxQueue;
EVT_NET_ADAPTER_CREATE_RXQUEUE EvtAdapterCreateRxQueue;
NTSTATUS
RtInitializeAdapterContext(
_In_ RT_ADAPTER* adapter,
_In_ WDFDEVICE device,
_In_ NETADAPTER netAdapter);
NTSTATUS
RtAdapterStart(
_In_ RT_ADAPTER* adapter);
UINT8 ConfigRead8(_In_ RT_ADAPTER* adapter, UINT32 reg);
UINT16 ConfigRead16(_In_ RT_ADAPTER* adapter, UINT32 reg);
void ConfigWrite8(_In_ RT_ADAPTER* adapter, UINT32 reg, UINT8 val);
void ConfigWrite16(_In_ RT_ADAPTER* adapter, UINT32 reg, UINT16 val);
void RtResetQueues(_In_ RT_ADAPTER* adapter);
#ifdef __cplusplus
extern "C" {
#endif
void
GetMulticastBit(
_In_ NET_ADAPTER_LINK_LAYER_ADDRESS const* address,
_Out_ _Post_satisfies_(*byte < MAX_NIC_MULTICAST_REG) UCHAR* byte,
_Out_ UCHAR* value
);
#ifdef __cplusplus
}
#endif