Browse Source

Introduce files for new e1000 driver

tags/v0.9.3
Marty Connor 16 years ago
parent
commit
0fea19c398

+ 0
- 3742
src/drivers/net/e1000.c
File diff suppressed because it is too large
View File


+ 303
- 0
src/drivers/net/e1000/e1000.h View File

@@ -0,0 +1,303 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2006 Intel Corporation.
5
+
6
+  This program is free software; you can redistribute it and/or modify it
7
+  under the terms and conditions of the GNU General Public License,
8
+  version 2, as published by the Free Software Foundation.
9
+
10
+  This program is distributed in the hope it will be useful, but WITHOUT
11
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13
+  more details.
14
+
15
+  You should have received a copy of the GNU General Public License along with
16
+  this program; if not, write to the Free Software Foundation, Inc.,
17
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
+
19
+  The full GNU General Public License is included in this distribution in
20
+  the file called "COPYING".
21
+
22
+  Contact Information:
23
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+/* Linux PRO/1000 Ethernet Driver main header file */
30
+
31
+#ifndef _E1000_H_
32
+#define _E1000_H_
33
+
34
+#include <stdint.h>
35
+#include <stdlib.h>
36
+#include <stdio.h>
37
+#include <io.h>
38
+#include <errno.h>
39
+#include <timer.h>
40
+#include <byteswap.h>
41
+#include <gpxe/pci.h>
42
+#include <gpxe/malloc.h>
43
+#include <gpxe/if_ether.h>
44
+#include <gpxe/ethernet.h>
45
+#include <gpxe/iobuf.h>
46
+#include <gpxe/netdevice.h>
47
+
48
+#define BAR_0		0
49
+#define BAR_1		1
50
+#define BAR_5		5
51
+
52
+struct e1000_adapter;
53
+
54
+#include "e1000_hw.h"
55
+
56
+/* Supported Rx Buffer Sizes */
57
+#define E1000_RXBUFFER_128   128    /* Used for packet split */
58
+#define E1000_RXBUFFER_256   256    /* Used for packet split */
59
+#define E1000_RXBUFFER_512   512
60
+#define E1000_RXBUFFER_1024  1024
61
+#define E1000_RXBUFFER_2048  2048
62
+#define E1000_RXBUFFER_4096  4096
63
+#define E1000_RXBUFFER_8192  8192
64
+#define E1000_RXBUFFER_16384 16384
65
+
66
+/* SmartSpeed delimiters */
67
+#define E1000_SMARTSPEED_DOWNSHIFT 3
68
+#define E1000_SMARTSPEED_MAX       15
69
+
70
+/* Packet Buffer allocations */
71
+#define E1000_PBA_BYTES_SHIFT 0xA
72
+#define E1000_TX_HEAD_ADDR_SHIFT 7
73
+#define E1000_PBA_TX_MASK 0xFFFF0000
74
+
75
+/* Flow Control Watermarks */
76
+#define E1000_FC_HIGH_DIFF 0x1638  /* High: 5688 bytes below Rx FIFO size */
77
+#define E1000_FC_LOW_DIFF 0x1640   /* Low:  5696 bytes below Rx FIFO size */
78
+
79
+#define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
80
+
81
+/* How many Tx Descriptors do we need to call netif_wake_queue ? */
82
+#define E1000_TX_QUEUE_WAKE	16
83
+/* How many Rx Buffers do we bundle into one write to the hardware ? */
84
+#define E1000_RX_BUFFER_WRITE	16	/* Must be power of 2 */
85
+
86
+#define AUTO_ALL_MODES            0
87
+#define E1000_EEPROM_82544_APM    0x0004
88
+#define E1000_EEPROM_ICH8_APME    0x0004
89
+#define E1000_EEPROM_APME         0x0400
90
+
91
+#ifndef E1000_MASTER_SLAVE
92
+/* Switch to override PHY master/slave setting */
93
+#define E1000_MASTER_SLAVE	e1000_ms_hw_default
94
+#endif
95
+
96
+/* wrapper around a pointer to a socket buffer,
97
+ * so a DMA handle can be stored along with the buffer */
98
+struct e1000_buffer {
99
+	struct sk_buff *skb;
100
+	unsigned long time_stamp;
101
+	uint16_t length;
102
+	uint16_t next_to_watch;
103
+};
104
+
105
+struct e1000_tx_ring {
106
+	/* pointer to the descriptor ring memory */
107
+	void *desc;
108
+	/* length of descriptor ring in bytes */
109
+	unsigned int size;
110
+	/* number of descriptors in the ring */
111
+	unsigned int count;
112
+	/* next descriptor to associate a buffer with */
113
+	unsigned int next_to_use;
114
+	/* next descriptor to check for DD status bit */
115
+	unsigned int next_to_clean;
116
+	/* array of buffer information structs */
117
+	struct e1000_buffer *buffer_info;
118
+
119
+	uint16_t tdh;
120
+	uint16_t tdt;
121
+	boolean_t last_tx_tso;
122
+};
123
+
124
+struct e1000_rx_ring {
125
+	/* pointer to the descriptor ring memory */
126
+	void *desc;
127
+	/* length of descriptor ring in bytes */
128
+	unsigned int size;
129
+	/* number of descriptors in the ring */
130
+	unsigned int count;
131
+	/* next descriptor to associate a buffer with */
132
+	unsigned int next_to_use;
133
+	/* next descriptor to check for DD status bit */
134
+	unsigned int next_to_clean;
135
+	/* array of buffer information structs */
136
+	struct e1000_buffer *buffer_info;
137
+	/* arrays of page information for packet split */
138
+	struct e1000_ps_page *ps_page;
139
+	struct e1000_ps_page_dma *ps_page_dma;
140
+
141
+	/* cpu for rx queue */
142
+	int cpu;
143
+
144
+	uint16_t rdh;
145
+	uint16_t rdt;
146
+};
147
+
148
+#define E1000_DESC_UNUSED(R) \
149
+	((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
150
+	(R)->next_to_clean - (R)->next_to_use - 1)
151
+
152
+#define E1000_RX_DESC_PS(R, i)	    \
153
+	(&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
154
+#define E1000_RX_DESC_EXT(R, i)	    \
155
+	(&(((union e1000_rx_desc_extended *)((R).desc))[i]))
156
+#define E1000_GET_DESC(R, i, type)	(&(((struct type *)((R).desc))[i]))
157
+#define E1000_RX_DESC(R, i)		E1000_GET_DESC(R, i, e1000_rx_desc)
158
+#define E1000_TX_DESC(R, i)		E1000_GET_DESC(R, i, e1000_tx_desc)
159
+#define E1000_CONTEXT_DESC(R, i)	E1000_GET_DESC(R, i, e1000_context_desc)
160
+
161
+/* board specific private data structure */
162
+
163
+struct e1000_adapter {
164
+	struct vlan_group *vlgrp;
165
+	uint16_t mng_vlan_id;
166
+	uint32_t bd_number;
167
+	uint32_t rx_buffer_len;
168
+	uint32_t wol;
169
+	uint32_t smartspeed;
170
+	uint32_t en_mng_pt;
171
+	uint16_t link_speed;
172
+	uint16_t link_duplex;
173
+
174
+	unsigned int total_tx_bytes;
175
+	unsigned int total_tx_packets;
176
+	unsigned int total_rx_bytes;
177
+	unsigned int total_rx_packets;
178
+	/* Interrupt Throttle Rate */
179
+	uint32_t itr;
180
+	uint32_t itr_setting;
181
+	uint16_t tx_itr;
182
+	uint16_t rx_itr;
183
+
184
+	uint8_t fc_autoneg;
185
+
186
+	unsigned long led_status;
187
+
188
+	/* TX */
189
+	struct e1000_tx_ring *tx_ring;      /* One per active queue */
190
+	unsigned int restart_queue;
191
+	unsigned long tx_queue_len;
192
+	uint32_t txd_cmd;
193
+	uint32_t tx_int_delay;
194
+	uint32_t tx_abs_int_delay;
195
+	uint32_t gotcl;
196
+	uint64_t gotcl_old;
197
+	uint64_t tpt_old;
198
+	uint64_t colc_old;
199
+	uint32_t tx_timeout_count;
200
+	uint32_t tx_fifo_head;
201
+	uint32_t tx_head_addr;
202
+	uint32_t tx_fifo_size;
203
+	uint8_t  tx_timeout_factor;
204
+	boolean_t pcix_82544;
205
+	boolean_t detect_tx_hung;
206
+
207
+	/* RX */
208
+	boolean_t (*clean_rx) (struct e1000_adapter *adapter,
209
+			       struct e1000_rx_ring *rx_ring);
210
+	void (*alloc_rx_buf) (struct e1000_adapter *adapter,
211
+			      struct e1000_rx_ring *rx_ring,
212
+				int cleaned_count);
213
+	struct e1000_rx_ring *rx_ring;      /* One per active queue */
214
+	int num_tx_queues;
215
+	int num_rx_queues;
216
+
217
+	uint64_t hw_csum_err;
218
+	uint64_t hw_csum_good;
219
+	uint64_t rx_hdr_split;
220
+	uint32_t alloc_rx_buff_failed;
221
+	uint32_t rx_int_delay;
222
+	uint32_t rx_abs_int_delay;
223
+	boolean_t rx_csum;
224
+	unsigned int rx_ps_pages;
225
+	uint32_t gorcl;
226
+	uint64_t gorcl_old;
227
+	uint16_t rx_ps_bsize0;
228
+
229
+
230
+	/* OS defined structs */
231
+	struct net_device *netdev;
232
+	struct pci_device *pdev;
233
+	struct net_device_stats net_stats;
234
+
235
+	/* structs defined in e1000_hw.h */
236
+	struct e1000_hw hw;
237
+	struct e1000_hw_stats stats;
238
+	struct e1000_phy_info phy_info;
239
+	struct e1000_phy_stats phy_stats;
240
+
241
+	uint32_t test_icr;
242
+	struct e1000_tx_ring test_tx_ring;
243
+	struct e1000_rx_ring test_rx_ring;
244
+
245
+	int msg_enable;
246
+	boolean_t have_msi;
247
+
248
+	/* to not mess up cache alignment, always add to the bottom */
249
+	boolean_t tso_force;
250
+	boolean_t smart_power_down;	/* phy smart power down */
251
+	boolean_t quad_port_a;
252
+	unsigned long flags;
253
+	uint32_t eeprom_wol;
254
+	
255
+#define NUM_TX_DESC	8
256
+#define NUM_RX_DESC	8
257
+
258
+	char *tx_desc_ring;
259
+	char *rx_desc_ring;
260
+
261
+	struct io_buffer *tx_iobuf[NUM_TX_DESC];
262
+	struct io_buffer *rx_iobuf[NUM_RX_DESC];
263
+
264
+	struct e1000_tx_desc *tx_desc[NUM_TX_DESC];
265
+	struct e1000_rx_desc *rx_desc[NUM_RX_DESC];
266
+	
267
+	struct e1000_tx_desc *tx_base;
268
+	struct e1000_rx_desc *rx_base;
269
+
270
+	uint32_t tx_head;
271
+	uint32_t tx_tail;
272
+	uint32_t tx_fill_ctr;
273
+	uint32_t rx_tail;
274
+
275
+	uint32_t ioaddr;
276
+	uint32_t irqno;
277
+
278
+};
279
+
280
+enum e1000_state_t {
281
+	__E1000_TESTING,
282
+	__E1000_RESETTING,
283
+	__E1000_DOWN
284
+};
285
+
286
+#define E1000_MNG2HOST_PORT_623 (1 << 5)
287
+#define E1000_MNG2HOST_PORT_664 (1 << 6)
288
+
289
+#define E1000_ERT_2048 0x100
290
+
291
+#define IORESOURCE_IO		0x00000100
292
+#define IORESOURCE_MEM          0x00000200
293
+#define IORESOURCE_PREFETCH     0x00001000
294
+
295
+#endif /* _E1000_H_ */
296
+
297
+/*
298
+ * Local variables:
299
+ *  c-basic-offset: 8
300
+ *  c-indent-level: 8
301
+ *  tab-width: 8
302
+ * End:
303
+ */

+ 9050
- 0
src/drivers/net/e1000/e1000_hw.c
File diff suppressed because it is too large
View File


+ 3413
- 0
src/drivers/net/e1000/e1000_hw.h
File diff suppressed because it is too large
View File


+ 1167
- 0
src/drivers/net/e1000/e1000_main.c
File diff suppressed because it is too large
View File


+ 141
- 0
src/drivers/net/e1000/e1000_osdep.h View File

@@ -0,0 +1,141 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2006 Intel Corporation.
5
+
6
+  This program is free software; you can redistribute it and/or modify it
7
+  under the terms and conditions of the GNU General Public License,
8
+  version 2, as published by the Free Software Foundation.
9
+
10
+  This program is distributed in the hope it will be useful, but WITHOUT
11
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13
+  more details.
14
+
15
+  You should have received a copy of the GNU General Public License along with
16
+  this program; if not, write to the Free Software Foundation, Inc.,
17
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
+
19
+  The full GNU General Public License is included in this distribution in
20
+  the file called "COPYING".
21
+
22
+  Contact Information:
23
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+/* glue for the OS independent part of e1000
30
+ * includes register access macros
31
+ */
32
+
33
+#ifndef _E1000_OSDEP_H_
34
+#define _E1000_OSDEP_H_
35
+
36
+#include <stdint.h>
37
+#include <stdlib.h>
38
+#include <stdio.h>
39
+#include <io.h>
40
+#include <errno.h>
41
+#include <timer.h>
42
+#include <byteswap.h>
43
+#include <gpxe/pci.h>
44
+#include <gpxe/if_ether.h>
45
+#include <gpxe/ethernet.h>
46
+#include <gpxe/iobuf.h>
47
+#include <gpxe/netdevice.h>
48
+
49
+typedef enum {
50
+#undef FALSE
51
+    FALSE = 0,
52
+#undef TRUE
53
+    TRUE = 1
54
+} boolean_t;
55
+
56
+/* Debugging #defines */
57
+
58
+#if 1
59
+#define DEBUGFUNC(F) DBG(F "\n")
60
+#else
61
+#define DEBUGFUNC(F)
62
+#endif
63
+
64
+#if 1
65
+#define DEBUGOUT(S)             DBG(S)
66
+#define DEBUGOUT1(S, A...)      DBG(S, A)
67
+#else
68
+#define DEBUGOUT(S)
69
+#define DEBUGOUT1(S, A...)
70
+#endif
71
+
72
+#define DEBUGOUT2 DEBUGOUT1
73
+#define DEBUGOUT3 DEBUGOUT1
74
+#define DEBUGOUT7 DEBUGOUT1
75
+
76
+#define E1000_WRITE_REG(a, reg, value) ( \
77
+    writel((value), ((a)->hw_addr + \
78
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))))
79
+
80
+#define E1000_READ_REG(a, reg) ( \
81
+    readl((a)->hw_addr + \
82
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))
83
+
84
+#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
85
+    writel((value), ((a)->hw_addr + \
86
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
87
+        ((offset) << 2))))
88
+
89
+#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
90
+    readl((a)->hw_addr + \
91
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
92
+        ((offset) << 2)))
93
+
94
+#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
95
+#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
96
+
97
+#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
98
+    writew((value), ((a)->hw_addr + \
99
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
100
+        ((offset) << 1))))
101
+
102
+#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
103
+    readw((a)->hw_addr + \
104
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
105
+        ((offset) << 1)))
106
+
107
+#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
108
+    writeb((value), ((a)->hw_addr + \
109
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
110
+        (offset))))
111
+
112
+#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
113
+    readb((a)->hw_addr + \
114
+        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
115
+        (offset)))
116
+
117
+#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
118
+
119
+#define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
120
+    writel((value), ((a)->flash_address + reg)))
121
+
122
+#define E1000_READ_ICH_FLASH_REG(a, reg) ( \
123
+    readl((a)->flash_address + reg))
124
+
125
+#define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
126
+    writew((value), ((a)->flash_address + reg)))
127
+
128
+#define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
129
+    readw((a)->flash_address + reg))
130
+
131
+#define	msleep(n) 	mdelay(n)
132
+
133
+#endif /* _E1000_OSDEP_H_ */
134
+
135
+/*
136
+ * Local variables:
137
+ *  c-basic-offset: 8
138
+ *  c-indent-level: 8
139
+ *  tab-width: 8
140
+ * End:
141
+ */

+ 0
- 2058
src/drivers/net/e1000_hw.h
File diff suppressed because it is too large
View File


Loading…
Cancel
Save