-
Notifications
You must be signed in to change notification settings - Fork 4
/
AppleIntelE1000e.h
executable file
·197 lines (154 loc) · 5.62 KB
/
AppleIntelE1000e.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#ifndef __INTEL_E1000E_H__
#define __INTEL_E1000E_H__
#define MBit 1000000
enum {
eePowerStateOff = 0,
eePowerStateOn,
eePowerStateCount
};
enum {
kFiveSeconds = 5000000
};
enum
{
MEDIUM_INDEX_AUTO = 0,
MEDIUM_INDEX_10HD,
MEDIUM_INDEX_10FD,
MEDIUM_INDEX_100HD,
MEDIUM_INDEX_100FD,
MEDIUM_INDEX_1000FD,
MEDIUM_INDEX_COUNT
};
enum
{
kActivationLevelNone = 0, /* adapter shut off */
kActivationLevelKDP, /* adapter partially up to support KDP */
kActivationLevelBSD /* adapter fully up to support KDP and BSD */
};
enum
{
kFullInitialization = 0,
kResetChip = 1
};
#define MAX_RX_SIZE (kIOEthernetAddressSize+kIOEthernetMaxPacketSize)
#define SIZE_RING_DESC PAGE_SIZE
#define NUM_RING_FRAME 256
class AppleIntelE1000e: public IOEthernetController
{
OSDeclareDefaultStructors(AppleIntelE1000e);
public:
// --------------------------------------------------
// IOService (or its superclass) methods.
// --------------------------------------------------
virtual bool start(IOService * provider);
virtual void stop(IOService * provider);
virtual bool init(OSDictionary *properties);
virtual void free();
virtual IOService* probe(IOService* provider,SInt32* score );
// --------------------------------------------------
// Power Management Support
// --------------------------------------------------
virtual IOReturn registerWithPolicyMaker(IOService* policyMaker);
virtual IOReturn setPowerState( unsigned long powerStateOrdinal, IOService *policyMaker );
// --------------------------------------------------
// IONetworkController methods.
// --------------------------------------------------
virtual IOReturn enable(IONetworkInterface * netif);
virtual IOReturn disable(IONetworkInterface * netif);
virtual UInt32 outputPacket(mbuf_t m, void * param);
virtual void getPacketBufferConstraints(IOPacketBufferConstraints * constraints) const;
virtual IOOutputQueue * createOutputQueue();
virtual const OSString * newVendorString() const;
virtual const OSString * newModelString() const;
virtual IOReturn selectMedium(const IONetworkMedium * medium);
virtual bool configureInterface(IONetworkInterface * interface);
virtual bool createWorkLoop();
virtual IOWorkLoop * getWorkLoop() const;
//-----------------------------------------------------------------------
// Methods inherited from IOEthernetController.
//-----------------------------------------------------------------------
virtual IOReturn getHardwareAddress(IOEthernetAddress * addr);
virtual IOReturn setHardwareAddress(const IOEthernetAddress * addr);
virtual IOReturn setPromiscuousMode(bool active);
virtual IOReturn setMulticastMode(bool active);
virtual IOReturn setMulticastList(IOEthernetAddress * addrs, UInt32 count);
virtual IOReturn getChecksumSupport(UInt32 *checksumMask, UInt32 checksumFamily, bool isOutput);
virtual IOReturn setMaxPacketSize (UInt32 maxSize);
virtual IOReturn getMaxPacketSize (UInt32 *maxSize) const;
virtual IOReturn getMinPacketSize (UInt32 *minSize) const;
virtual IOReturn setWakeOnMagicPacket(bool active);
virtual IOReturn getPacketFilters(const OSSymbol * group, UInt32 * filters) const;
virtual UInt32 getFeatures() const;
private:
IOWorkLoop* workLoop;
IOPCIDevice* pciDevice;
OSDictionary * mediumDict;
IONetworkMedium * mediumTable[MEDIUM_INDEX_COUNT];
IOOutputQueue * transmitQueue;
IOInterruptEventSource * interruptSource;
IOTimerEventSource * watchdogSource;
IOTimerEventSource * resetSource;
IOEthernetInterface * netif;
IONetworkStats * netStats;
IOEthernetStats * etherStats;
IOMemoryMap * csrPCIAddress;
IOMemoryMap * flashPCIAddress;
IOMbufNaturalMemoryCursor * rxMbufCursor;
IOMbufNaturalMemoryCursor * txMbufCursor;
bool enabledForNetif;
bool promiscusMode;
bool multicastMode;
bool stalled;
bool useTSO;
UInt32 mcCount;
UInt32 preLinkStatus;
UInt32 powerState;
struct e1000_adapter priv_adapter;
struct pci_dev priv_pdev;
struct net_device priv_netdev;
UInt32 netdev_features;
private:
void interruptOccurred(IOInterruptEventSource * src);
void timeoutOccurred(IOTimerEventSource* src);
void doReset();
bool addNetworkMedium(UInt32 type, UInt32 bps, UInt32 index);
bool initEventSources( IOService* provider );
bool initPCIConfigSpace(IOPCIDevice* provider);
void e1000_clean_rx_ring();
void e1000_clean_tx_ring();
void e1000e_free_tx_resources();
void e1000e_free_rx_resources();
void e1000e_enable_receives();
bool e1000_clean_tx_irq();
bool e1000_clean_rx_irq();
bool e1000_clean_jumbo_rx_irq();
void e1000_print_hw_hang();
void e1000_put_txbuf(e1000_buffer *buffer_info);
void e1000_alloc_rx_buffers(int cleaned_count);
void e1000_alloc_jumbo_rx_buffers(int cleaned_count);
void e1000_configure_rx();
void e1000_setup_rctl();
void e1000_init_manageability_pt();
void e1000_configure_tx();
void e1000e_set_rx_mode();
bool e1000_tx_csum(mbuf_t skb);
void e1000_rx_checksum(mbuf_t skb, u32 status);
void e1000_receive_skb(mbuf_t skb, u32 length, u32 staterr, __le16 vlan);
void e1000_configure();
void e1000e_up();
void e1000e_down(bool reset);
void e1000_change_mtu(UInt32 maxSize);
int __e1000_shutdown(bool runtime);
bool getBoolOption(const char *name, bool defVal);
int getIntOption(const char *name, int defVal, int maxVal, int minVal );
private:
bool clean_rx_irq();
void alloc_rx_buf(int cleaned_count);
public:
static void interruptHandler(OSObject * target,
IOInterruptEventSource * src,
int count );
static void timeoutHandler(OSObject * target, IOTimerEventSource * src);
static void resetHandler(OSObject * target, IOTimerEventSource * src);
};
#endif //__INTEL_E1000E_H__