Explorar el Código

[e1000] Update e1000 driver

This commit replaces the current gPXE e1000 driver with one ported
from Intel source code available at

    http://sourceforge.net/projects/e1000/

which is upstream source for the Linux kernel e1000 drivers, and
should support most if not all PCI e1000 variants.

Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.20.1
Marty Connor hace 14 años
padre
commit
930a2ffac8

+ 6
- 1160
src/drivers/net/e1000/e1000.c
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 144
- 124
src/drivers/net/e1000/e1000.h Ver fichero

@@ -1,7 +1,7 @@
1 1
 /*******************************************************************************
2 2
 
3 3
   Intel PRO/1000 Linux driver
4
-  Copyright(c) 1999 - 2006 Intel Corporation.
4
+  Copyright(c) 1999 - 2008 Intel Corporation.
5 5
 
6 6
   This program is free software; you can redistribute it and/or modify it
7 7
   under the terms and conditions of the GNU General Public License,
@@ -33,19 +33,7 @@ FILE_LICENCE ( GPL2_ONLY );
33 33
 #ifndef _E1000_H_
34 34
 #define _E1000_H_
35 35
 
36
-#include <stdint.h>
37
-#include <stdlib.h>
38
-#include <stdio.h>
39
-#include <string.h>
40
-#include <gpxe/io.h>
41
-#include <errno.h>
42
-#include <byteswap.h>
43
-#include <gpxe/pci.h>
44
-#include <gpxe/malloc.h>
45
-#include <gpxe/if_ether.h>
46
-#include <gpxe/ethernet.h>
47
-#include <gpxe/iobuf.h>
48
-#include <gpxe/netdevice.h>
36
+#include "e1000_api.h"
49 37
 
50 38
 #define BAR_0		0
51 39
 #define BAR_1		1
@@ -53,11 +41,32 @@ FILE_LICENCE ( GPL2_ONLY );
53 41
 
54 42
 struct e1000_adapter;
55 43
 
56
-#include "e1000_hw.h"
44
+/* TX/RX descriptor defines */
45
+#define E1000_DEFAULT_TXD                  256
46
+#define E1000_MAX_TXD                      256
47
+#define E1000_MIN_TXD                       80
48
+#define E1000_MAX_82544_TXD               4096
49
+
50
+#define E1000_DEFAULT_TXD_PWR               12
51
+#define E1000_MAX_TXD_PWR                   12
52
+#define E1000_MIN_TXD_PWR                    7
53
+
54
+#define E1000_DEFAULT_RXD                  256
55
+#define E1000_MAX_RXD                      256
56
+
57
+#define E1000_MIN_RXD                       80
58
+#define E1000_MAX_82544_RXD               4096
59
+
60
+#define E1000_MIN_ITR_USECS                 10 /* 100000 irq/sec */
61
+#define E1000_MAX_ITR_USECS              10000 /* 100    irq/sec */
62
+
63
+
64
+/* this is the size past which hardware will drop packets when setting LPE=0 */
65
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
57 66
 
58 67
 /* Supported Rx Buffer Sizes */
59
-#define E1000_RXBUFFER_128   128    /* Used for packet split */
60
-#define E1000_RXBUFFER_256   256    /* Used for packet split */
68
+#define E1000_RXBUFFER_128   128
69
+#define E1000_RXBUFFER_256   256
61 70
 #define E1000_RXBUFFER_512   512
62 71
 #define E1000_RXBUFFER_1024  1024
63 72
 #define E1000_RXBUFFER_2048  2048
@@ -74,15 +83,11 @@ struct e1000_adapter;
74 83
 #define E1000_TX_HEAD_ADDR_SHIFT 7
75 84
 #define E1000_PBA_TX_MASK 0xFFFF0000
76 85
 
77
-/* Flow Control Watermarks */
78
-#define E1000_FC_HIGH_DIFF 0x1638  /* High: 5688 bytes below Rx FIFO size */
79
-#define E1000_FC_LOW_DIFF 0x1640   /* Low:  5696 bytes below Rx FIFO size */
86
+/* Early Receive defines */
87
+#define E1000_ERT_2048 0x100
80 88
 
81 89
 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
82 90
 
83
-/* this is the size past which hardware will drop packets when setting LPE=0 */
84
-#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
85
-
86 91
 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
87 92
 #define E1000_TX_QUEUE_WAKE	16
88 93
 /* How many Rx Buffers do we bundle into one write to the hardware ? */
@@ -90,26 +95,31 @@ struct e1000_adapter;
90 95
 
91 96
 #define AUTO_ALL_MODES            0
92 97
 #define E1000_EEPROM_82544_APM    0x0004
93
-#define E1000_EEPROM_ICH8_APME    0x0004
94 98
 #define E1000_EEPROM_APME         0x0400
95 99
 
96
-#ifndef E1000_MASTER_SLAVE
97
-/* Switch to override PHY master/slave setting */
98
-#define E1000_MASTER_SLAVE	e1000_ms_hw_default
99
-#endif
100
-
101 100
 /* wrapper around a pointer to a socket buffer,
102 101
  * so a DMA handle can be stored along with the buffer */
103 102
 struct e1000_buffer {
104 103
 	struct sk_buff *skb;
104
+	dma_addr_t dma;
105 105
 	unsigned long time_stamp;
106
-	uint16_t length;
107
-	uint16_t next_to_watch;
106
+	u16 length;
107
+	u16 next_to_watch;
108
+};
109
+
110
+struct e1000_rx_buffer {
111
+	struct sk_buff *skb;
112
+	dma_addr_t dma;
113
+	struct page *page;
108 114
 };
109 115
 
116
+
117
+
110 118
 struct e1000_tx_ring {
111 119
 	/* pointer to the descriptor ring memory */
112 120
 	void *desc;
121
+	/* physical address of the descriptor ring */
122
+	dma_addr_t dma;
113 123
 	/* length of descriptor ring in bytes */
114 124
 	unsigned int size;
115 125
 	/* number of descriptors in the ring */
@@ -121,14 +131,27 @@ struct e1000_tx_ring {
121 131
 	/* array of buffer information structs */
122 132
 	struct e1000_buffer *buffer_info;
123 133
 
124
-	uint16_t tdh;
125
-	uint16_t tdt;
126
-	boolean_t last_tx_tso;
134
+	spinlock_t tx_lock;
135
+	u16 tdh;
136
+	u16 tdt;
137
+
138
+	/* TXDdescriptor index increment to be used when advancing
139
+	* to the next descriptor. This is normally one, but on some
140
+	* architectures, but on some architectures there are cache
141
+	* coherency issues that require only the first descriptor in
142
+	* cache line can be used.
143
+	*/
144
+	unsigned int step;
145
+
146
+	bool last_tx_tso;
127 147
 };
128 148
 
129 149
 struct e1000_rx_ring {
150
+	struct e1000_adapter *adapter; /* back link */
130 151
 	/* pointer to the descriptor ring memory */
131 152
 	void *desc;
153
+	/* physical address of the descriptor ring */
154
+	dma_addr_t dma;
132 155
 	/* length of descriptor ring in bytes */
133 156
 	unsigned int size;
134 157
 	/* number of descriptors in the ring */
@@ -138,24 +161,28 @@ struct e1000_rx_ring {
138 161
 	/* next descriptor to check for DD status bit */
139 162
 	unsigned int next_to_clean;
140 163
 	/* array of buffer information structs */
141
-	struct e1000_buffer *buffer_info;
142
-	/* arrays of page information for packet split */
143
-	struct e1000_ps_page *ps_page;
144
-	struct e1000_ps_page_dma *ps_page_dma;
164
+	struct e1000_rx_buffer *buffer_info;
165
+	struct sk_buff *rx_skb_top;
145 166
 
146 167
 	/* cpu for rx queue */
147 168
 	int cpu;
148 169
 
149
-	uint16_t rdh;
150
-	uint16_t rdt;
170
+	u16 rdh;
171
+	u16 rdt;
151 172
 };
152 173
 
174
+
175
+#define E1000_TX_DESC_INC(R,index) \
176
+	{index += (R)->step; if (index == (R)->count) index = 0; }
177
+
178
+#define E1000_TX_DESC_DEC(R,index) \
179
+	{ if (index == 0) index = (R)->count - (R)->step; \
180
+	else index -= (R)->step; }
181
+
153 182
 #define E1000_DESC_UNUSED(R) \
154 183
 	((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
155 184
 	(R)->next_to_clean - (R)->next_to_use - 1)
156 185
 
157
-#define E1000_RX_DESC_PS(R, i)	    \
158
-	(&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
159 186
 #define E1000_RX_DESC_EXT(R, i)	    \
160 187
 	(&(((union e1000_rx_desc_extended *)((R).desc))[i]))
161 188
 #define E1000_GET_DESC(R, i, type)	(&(((struct type *)((R).desc))[i]))
@@ -166,70 +193,63 @@ struct e1000_rx_ring {
166 193
 /* board specific private data structure */
167 194
 
168 195
 struct e1000_adapter {
169
-	struct vlan_group *vlgrp;
170
-	uint16_t mng_vlan_id;
171
-	uint32_t bd_number;
172
-	uint32_t rx_buffer_len;
173
-	uint32_t wol;
174
-	uint32_t smartspeed;
175
-	uint32_t en_mng_pt;
176
-	uint16_t link_speed;
177
-	uint16_t link_duplex;
178
-
196
+	u32 bd_number;
197
+	u32 rx_buffer_len;
198
+	u32 wol;
199
+	u32 smartspeed;
200
+	u32 en_mng_pt;
201
+	u16 link_speed;
202
+	u16 link_duplex;
203
+	spinlock_t stats_lock;
179 204
 	unsigned int total_tx_bytes;
180 205
 	unsigned int total_tx_packets;
181 206
 	unsigned int total_rx_bytes;
182 207
 	unsigned int total_rx_packets;
183 208
 	/* Interrupt Throttle Rate */
184
-	uint32_t itr;
185
-	uint32_t itr_setting;
186
-	uint16_t tx_itr;
187
-	uint16_t rx_itr;
209
+	u32 itr;
210
+	u32 itr_setting;
211
+	u16 tx_itr;
212
+	u16 rx_itr;
188 213
 
189
-	uint8_t fc_autoneg;
190
-
191
-	unsigned long led_status;
214
+	bool fc_autoneg;
192 215
 
193 216
 	/* TX */
194
-	struct e1000_tx_ring *tx_ring;      /* One per active queue */
217
+	struct e1000_tx_ring *tx_ring;
195 218
 	unsigned int restart_queue;
196 219
 	unsigned long tx_queue_len;
197
-	uint32_t txd_cmd;
198
-	uint32_t tx_int_delay;
199
-	uint32_t tx_abs_int_delay;
200
-	uint32_t gotcl;
201
-	uint64_t gotcl_old;
202
-	uint64_t tpt_old;
203
-	uint64_t colc_old;
204
-	uint32_t tx_timeout_count;
205
-	uint32_t tx_fifo_head;
206
-	uint32_t tx_head_addr;
207
-	uint32_t tx_fifo_size;
208
-	uint8_t  tx_timeout_factor;
209
-	boolean_t pcix_82544;
210
-	boolean_t detect_tx_hung;
220
+	u32 txd_cmd;
221
+	u32 tx_int_delay;
222
+	u32 tx_abs_int_delay;
223
+	u32 gotc;
224
+	u64 gotc_old;
225
+	u64 tpt_old;
226
+	u64 colc_old;
227
+	u32 tx_timeout_count;
228
+	u32 tx_fifo_head;
229
+	u32 tx_head_addr;
230
+	u32 tx_fifo_size;
231
+	u8 tx_timeout_factor;
232
+	bool pcix_82544;
233
+	bool detect_tx_hung;
211 234
 
212 235
 	/* RX */
213
-	boolean_t (*clean_rx) (struct e1000_adapter *adapter,
236
+	bool (*clean_rx) (struct e1000_adapter *adapter,
214 237
 			       struct e1000_rx_ring *rx_ring);
215 238
 	void (*alloc_rx_buf) (struct e1000_adapter *adapter,
216 239
 			      struct e1000_rx_ring *rx_ring,
217 240
 				int cleaned_count);
218
-	struct e1000_rx_ring *rx_ring;      /* One per active queue */
219
-	int num_tx_queues;
220
-	int num_rx_queues;
221
-
222
-	uint64_t hw_csum_err;
223
-	uint64_t hw_csum_good;
224
-	uint64_t rx_hdr_split;
225
-	uint32_t alloc_rx_buff_failed;
226
-	uint32_t rx_int_delay;
227
-	uint32_t rx_abs_int_delay;
228
-	boolean_t rx_csum;
229
-	unsigned int rx_ps_pages;
230
-	uint32_t gorcl;
231
-	uint64_t gorcl_old;
232
-	uint16_t rx_ps_bsize0;
241
+	struct e1000_rx_ring *rx_ring;
242
+
243
+	u64 hw_csum_err;
244
+	u64 hw_csum_good;
245
+	u32 alloc_rx_buff_failed;
246
+	u32 rx_int_delay;
247
+	u32 rx_abs_int_delay;
248
+	bool rx_csum;
249
+	u32 gorc;
250
+	u64 gorc_old;
251
+	u32 max_frame_size;
252
+	u32 min_frame_size;
233 253
 
234 254
 
235 255
 	/* OS defined structs */
@@ -243,20 +263,19 @@ struct e1000_adapter {
243 263
 	struct e1000_phy_info phy_info;
244 264
 	struct e1000_phy_stats phy_stats;
245 265
 
246
-	uint32_t test_icr;
247
-	struct e1000_tx_ring test_tx_ring;
248
-	struct e1000_rx_ring test_rx_ring;
249
-
250 266
 	int msg_enable;
251
-	boolean_t have_msi;
252
-
253 267
 	/* to not mess up cache alignment, always add to the bottom */
254
-	boolean_t tso_force;
255
-	boolean_t smart_power_down;	/* phy smart power down */
256
-	boolean_t quad_port_a;
257
-	unsigned long flags;
258
-	uint32_t eeprom_wol;
259
-	
268
+	unsigned long state;
269
+	u32 eeprom_wol;
270
+
271
+	u32 *config_space;
272
+
273
+	/* hardware capability, feature, and workaround flags */
274
+	unsigned int flags;
275
+
276
+	/* upper limit parameter for tx desc size */
277
+	u32 tx_desc_pwr;
278
+
260 279
 #define NUM_TX_DESC	8
261 280
 #define NUM_RX_DESC	8
262 281
 
@@ -265,42 +284,43 @@ struct e1000_adapter {
265 284
 
266 285
 	struct e1000_tx_desc *tx_base;
267 286
 	struct e1000_rx_desc *rx_base;
268
-	
287
+
269 288
 	uint32_t tx_ring_size;
270 289
 	uint32_t rx_ring_size;
271 290
 
272 291
 	uint32_t tx_head;
273 292
 	uint32_t tx_tail;
274 293
 	uint32_t tx_fill_ctr;
275
-	
294
+
276 295
 	uint32_t rx_curr;
277 296
 
278 297
 	uint32_t ioaddr;
279 298
 	uint32_t irqno;
280
-
281 299
 };
282 300
 
283
-enum e1000_state_t {
284
-	__E1000_TESTING,
285
-	__E1000_RESETTING,
286
-	__E1000_DOWN
287
-};
301
+#define E1000_FLAG_HAS_SMBUS                (1 << 0)
302
+#define E1000_FLAG_HAS_INTR_MODERATION      (1 << 4)
303
+#define E1000_FLAG_BAD_TX_CARRIER_STATS_FD  (1 << 6)
304
+#define E1000_FLAG_QUAD_PORT_A              (1 << 8)
305
+#define E1000_FLAG_SMART_POWER_DOWN         (1 << 9)
288 306
 
289
-#define E1000_MNG2HOST_PORT_623 (1 << 5)
290
-#define E1000_MNG2HOST_PORT_664 (1 << 6)
307
+extern char e1000_driver_name[];
308
+extern const char e1000_driver_version[];
291 309
 
292
-#define E1000_ERT_2048 0x100
310
+extern void e1000_power_up_phy(struct e1000_hw *hw);
293 311
 
294
-#define IORESOURCE_IO		0x00000100
295
-#define IORESOURCE_MEM          0x00000200
296
-#define IORESOURCE_PREFETCH     0x00001000
312
+extern void e1000_set_ethtool_ops(struct net_device *netdev);
313
+extern void e1000_check_options(struct e1000_adapter *adapter);
297 314
 
298
-#endif /* _E1000_H_ */
315
+extern int e1000_up(struct e1000_adapter *adapter);
316
+extern void e1000_down(struct e1000_adapter *adapter);
317
+extern void e1000_reinit_locked(struct e1000_adapter *adapter);
318
+extern void e1000_reset(struct e1000_adapter *adapter);
319
+extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
320
+extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
321
+extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
322
+extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
323
+extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
324
+extern void e1000_update_stats(struct e1000_adapter *adapter);
299 325
 
300
-/*
301
- * Local variables:
302
- *  c-basic-offset: 8
303
- *  c-indent-level: 8
304
- *  tab-width: 8
305
- * End:
306
- */
326
+#endif /* _E1000_H_ */

+ 754
- 0
src/drivers/net/e1000/e1000_82540.c Ver fichero

@@ -0,0 +1,754 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+/*
32
+ * 82540EM Gigabit Ethernet Controller
33
+ * 82540EP Gigabit Ethernet Controller
34
+ * 82545EM Gigabit Ethernet Controller (Copper)
35
+ * 82545EM Gigabit Ethernet Controller (Fiber)
36
+ * 82545GM Gigabit Ethernet Controller
37
+ * 82546EB Gigabit Ethernet Controller (Copper)
38
+ * 82546EB Gigabit Ethernet Controller (Fiber)
39
+ * 82546GB Gigabit Ethernet Controller
40
+ */
41
+
42
+#include "e1000_api.h"
43
+
44
+static s32  e1000_init_phy_params_82540(struct e1000_hw *hw);
45
+static s32  e1000_init_nvm_params_82540(struct e1000_hw *hw);
46
+static s32  e1000_init_mac_params_82540(struct e1000_hw *hw);
47
+static s32  e1000_adjust_serdes_amplitude_82540(struct e1000_hw *hw);
48
+static void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw);
49
+static s32  e1000_init_hw_82540(struct e1000_hw *hw);
50
+static s32  e1000_reset_hw_82540(struct e1000_hw *hw);
51
+static s32  e1000_set_phy_mode_82540(struct e1000_hw *hw);
52
+static s32  e1000_set_vco_speed_82540(struct e1000_hw *hw);
53
+static s32  e1000_setup_copper_link_82540(struct e1000_hw *hw);
54
+static s32  e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw);
55
+static void e1000_power_down_phy_copper_82540(struct e1000_hw *hw);
56
+static s32  e1000_read_mac_addr_82540(struct e1000_hw *hw);
57
+
58
+/**
59
+ * e1000_init_phy_params_82540 - Init PHY func ptrs.
60
+ * @hw: pointer to the HW structure
61
+ **/
62
+static s32 e1000_init_phy_params_82540(struct e1000_hw *hw)
63
+{
64
+	struct e1000_phy_info *phy = &hw->phy;
65
+	s32 ret_val = E1000_SUCCESS;
66
+
67
+	phy->addr                      = 1;
68
+	phy->autoneg_mask              = AUTONEG_ADVERTISE_SPEED_DEFAULT;
69
+	phy->reset_delay_us            = 10000;
70
+	phy->type                      = e1000_phy_m88;
71
+
72
+	/* Function Pointers */
73
+	phy->ops.check_polarity        = e1000_check_polarity_m88;
74
+	phy->ops.commit                = e1000_phy_sw_reset_generic;
75
+#if 0
76
+	phy->ops.force_speed_duplex    = e1000_phy_force_speed_duplex_m88;
77
+#endif
78
+#if 0
79
+	phy->ops.get_cable_length      = e1000_get_cable_length_m88;
80
+#endif
81
+	phy->ops.get_cfg_done          = e1000_get_cfg_done_generic;
82
+	phy->ops.read_reg              = e1000_read_phy_reg_m88;
83
+	phy->ops.reset                 = e1000_phy_hw_reset_generic;
84
+	phy->ops.write_reg             = e1000_write_phy_reg_m88;
85
+	phy->ops.get_info              = e1000_get_phy_info_m88;
86
+	phy->ops.power_up              = e1000_power_up_phy_copper;
87
+	phy->ops.power_down            = e1000_power_down_phy_copper_82540;
88
+
89
+	ret_val = e1000_get_phy_id(hw);
90
+	if (ret_val)
91
+		goto out;
92
+
93
+	/* Verify phy id */
94
+	switch (hw->mac.type) {
95
+	case e1000_82540:
96
+	case e1000_82545:
97
+	case e1000_82545_rev_3:
98
+	case e1000_82546:
99
+	case e1000_82546_rev_3:
100
+		if (phy->id == M88E1011_I_PHY_ID)
101
+			break;
102
+		/* Fall Through */
103
+	default:
104
+		ret_val = -E1000_ERR_PHY;
105
+		goto out;
106
+		break;
107
+	}
108
+
109
+out:
110
+	return ret_val;
111
+}
112
+
113
+/**
114
+ * e1000_init_nvm_params_82540 - Init NVM func ptrs.
115
+ * @hw: pointer to the HW structure
116
+ **/
117
+static s32 e1000_init_nvm_params_82540(struct e1000_hw *hw)
118
+{
119
+	struct e1000_nvm_info *nvm = &hw->nvm;
120
+	u32 eecd = E1000_READ_REG(hw, E1000_EECD);
121
+
122
+	DEBUGFUNC("e1000_init_nvm_params_82540");
123
+
124
+	nvm->type               = e1000_nvm_eeprom_microwire;
125
+	nvm->delay_usec         = 50;
126
+	nvm->opcode_bits        = 3;
127
+	switch (nvm->override) {
128
+	case e1000_nvm_override_microwire_large:
129
+		nvm->address_bits       = 8;
130
+		nvm->word_size          = 256;
131
+		break;
132
+	case e1000_nvm_override_microwire_small:
133
+		nvm->address_bits       = 6;
134
+		nvm->word_size          = 64;
135
+		break;
136
+	default:
137
+		nvm->address_bits       = eecd & E1000_EECD_SIZE ? 8 : 6;
138
+		nvm->word_size          = eecd & E1000_EECD_SIZE ? 256 : 64;
139
+		break;
140
+	}
141
+
142
+	/* Function Pointers */
143
+	nvm->ops.acquire            = e1000_acquire_nvm_generic;
144
+	nvm->ops.read               = e1000_read_nvm_microwire;
145
+	nvm->ops.release            = e1000_release_nvm_generic;
146
+	nvm->ops.update             = e1000_update_nvm_checksum_generic;
147
+	nvm->ops.valid_led_default  = e1000_valid_led_default_generic;
148
+	nvm->ops.validate           = e1000_validate_nvm_checksum_generic;
149
+	nvm->ops.write              = e1000_write_nvm_microwire;
150
+
151
+	return E1000_SUCCESS;
152
+}
153
+
154
+/**
155
+ * e1000_init_mac_params_82540 - Init MAC func ptrs.
156
+ * @hw: pointer to the HW structure
157
+ **/
158
+static s32 e1000_init_mac_params_82540(struct e1000_hw *hw)
159
+{
160
+	struct e1000_mac_info *mac = &hw->mac;
161
+	s32 ret_val = E1000_SUCCESS;
162
+
163
+	DEBUGFUNC("e1000_init_mac_params_82540");
164
+
165
+	/* Set media type */
166
+	switch (hw->device_id) {
167
+	case E1000_DEV_ID_82545EM_FIBER:
168
+	case E1000_DEV_ID_82545GM_FIBER:
169
+	case E1000_DEV_ID_82546EB_FIBER:
170
+	case E1000_DEV_ID_82546GB_FIBER:
171
+		hw->phy.media_type = e1000_media_type_fiber;
172
+		break;
173
+	case E1000_DEV_ID_82545GM_SERDES:
174
+	case E1000_DEV_ID_82546GB_SERDES:
175
+		hw->phy.media_type = e1000_media_type_internal_serdes;
176
+		break;
177
+	default:
178
+		hw->phy.media_type = e1000_media_type_copper;
179
+		break;
180
+	}
181
+
182
+	/* Set mta register count */
183
+	mac->mta_reg_count = 128;
184
+	/* Set rar entry count */
185
+	mac->rar_entry_count = E1000_RAR_ENTRIES;
186
+
187
+	/* Function pointers */
188
+
189
+	/* bus type/speed/width */
190
+	mac->ops.get_bus_info = e1000_get_bus_info_pci_generic;
191
+	/* function id */
192
+	mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
193
+	/* reset */
194
+	mac->ops.reset_hw = e1000_reset_hw_82540;
195
+	/* hw initialization */
196
+	mac->ops.init_hw = e1000_init_hw_82540;
197
+	/* link setup */
198
+	mac->ops.setup_link = e1000_setup_link_generic;
199
+	/* physical interface setup */
200
+	mac->ops.setup_physical_interface =
201
+	        (hw->phy.media_type == e1000_media_type_copper)
202
+	                ? e1000_setup_copper_link_82540
203
+	                : e1000_setup_fiber_serdes_link_82540;
204
+	/* check for link */
205
+	switch (hw->phy.media_type) {
206
+	case e1000_media_type_copper:
207
+		mac->ops.check_for_link = e1000_check_for_copper_link_generic;
208
+		break;
209
+	case e1000_media_type_fiber:
210
+		mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
211
+		break;
212
+	case e1000_media_type_internal_serdes:
213
+		mac->ops.check_for_link = e1000_check_for_serdes_link_generic;
214
+		break;
215
+	default:
216
+		ret_val = -E1000_ERR_CONFIG;
217
+		goto out;
218
+		break;
219
+	}
220
+	/* link info */
221
+	mac->ops.get_link_up_info =
222
+	        (hw->phy.media_type == e1000_media_type_copper)
223
+	                ? e1000_get_speed_and_duplex_copper_generic
224
+	                : e1000_get_speed_and_duplex_fiber_serdes_generic;
225
+	/* multicast address update */
226
+	mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
227
+	/* writing VFTA */
228
+	mac->ops.write_vfta = e1000_write_vfta_generic;
229
+	/* clearing VFTA */
230
+	mac->ops.clear_vfta = e1000_clear_vfta_generic;
231
+	/* setting MTA */
232
+	mac->ops.mta_set = e1000_mta_set_generic;
233
+	/* read mac address */
234
+	mac->ops.read_mac_addr = e1000_read_mac_addr_82540;
235
+	/* ID LED init */
236
+	mac->ops.id_led_init = e1000_id_led_init_generic;
237
+	/* setup LED */
238
+	mac->ops.setup_led = e1000_setup_led_generic;
239
+	/* cleanup LED */
240
+	mac->ops.cleanup_led = e1000_cleanup_led_generic;
241
+	/* turn on/off LED */
242
+	mac->ops.led_on = e1000_led_on_generic;
243
+	mac->ops.led_off = e1000_led_off_generic;
244
+	/* clear hardware counters */
245
+	mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82540;
246
+
247
+out:
248
+	return ret_val;
249
+}
250
+
251
+/**
252
+ * e1000_init_function_pointers_82540 - Init func ptrs.
253
+ * @hw: pointer to the HW structure
254
+ *
255
+ * Called to initialize all function pointers and parameters.
256
+ **/
257
+void e1000_init_function_pointers_82540(struct e1000_hw *hw)
258
+{
259
+	DEBUGFUNC("e1000_init_function_pointers_82540");
260
+
261
+	hw->mac.ops.init_params = e1000_init_mac_params_82540;
262
+	hw->nvm.ops.init_params = e1000_init_nvm_params_82540;
263
+	hw->phy.ops.init_params = e1000_init_phy_params_82540;
264
+}
265
+
266
+/**
267
+ *  e1000_reset_hw_82540 - Reset hardware
268
+ *  @hw: pointer to the HW structure
269
+ *
270
+ *  This resets the hardware into a known state.
271
+ **/
272
+static s32 e1000_reset_hw_82540(struct e1000_hw *hw)
273
+{
274
+	u32 ctrl, icr, manc;
275
+	s32 ret_val = E1000_SUCCESS;
276
+
277
+	DEBUGFUNC("e1000_reset_hw_82540");
278
+
279
+	DEBUGOUT("Masking off all interrupts\n");
280
+	E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
281
+
282
+	E1000_WRITE_REG(hw, E1000_RCTL, 0);
283
+	E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
284
+	E1000_WRITE_FLUSH(hw);
285
+
286
+	/*
287
+	 * Delay to allow any outstanding PCI transactions to complete
288
+	 * before resetting the device.
289
+	 */
290
+	msec_delay(10);
291
+
292
+	ctrl = E1000_READ_REG(hw, E1000_CTRL);
293
+
294
+	DEBUGOUT("Issuing a global reset to 82540/82545/82546 MAC\n");
295
+	switch (hw->mac.type) {
296
+	case e1000_82545_rev_3:
297
+	case e1000_82546_rev_3:
298
+		E1000_WRITE_REG(hw, E1000_CTRL_DUP, ctrl | E1000_CTRL_RST);
299
+		break;
300
+	default:
301
+		/*
302
+		 * These controllers can't ack the 64-bit write when
303
+		 * issuing the reset, so we use IO-mapping as a
304
+		 * workaround to issue the reset.
305
+		 */
306
+		E1000_WRITE_REG_IO(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
307
+		break;
308
+	}
309
+
310
+	/* Wait for EEPROM reload */
311
+	msec_delay(5);
312
+
313
+	/* Disable HW ARPs on ASF enabled adapters */
314
+	manc = E1000_READ_REG(hw, E1000_MANC);
315
+	manc &= ~E1000_MANC_ARP_EN;
316
+	E1000_WRITE_REG(hw, E1000_MANC, manc);
317
+
318
+	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
319
+	icr = E1000_READ_REG(hw, E1000_ICR);
320
+
321
+	return ret_val;
322
+}
323
+
324
+/**
325
+ *  e1000_init_hw_82540 - Initialize hardware
326
+ *  @hw: pointer to the HW structure
327
+ *
328
+ *  This inits the hardware readying it for operation.
329
+ **/
330
+static s32 e1000_init_hw_82540(struct e1000_hw *hw)
331
+{
332
+	struct e1000_mac_info *mac = &hw->mac;
333
+	u32 txdctl, ctrl_ext;
334
+	s32 ret_val = E1000_SUCCESS;
335
+	u16 i;
336
+
337
+	DEBUGFUNC("e1000_init_hw_82540");
338
+
339
+	/* Initialize identification LED */
340
+	ret_val = mac->ops.id_led_init(hw);
341
+	if (ret_val) {
342
+		DEBUGOUT("Error initializing identification LED\n");
343
+		/* This is not fatal and we should not stop init due to this */
344
+	}
345
+
346
+	/* Disabling VLAN filtering */
347
+	DEBUGOUT("Initializing the IEEE VLAN\n");
348
+	if (mac->type < e1000_82545_rev_3)
349
+		E1000_WRITE_REG(hw, E1000_VET, 0);
350
+
351
+	mac->ops.clear_vfta(hw);
352
+
353
+	/* Setup the receive address. */
354
+	e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
355
+
356
+	/* Zero out the Multicast HASH table */
357
+	DEBUGOUT("Zeroing the MTA\n");
358
+	for (i = 0; i < mac->mta_reg_count; i++) {
359
+		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
360
+		/*
361
+		 * Avoid back to back register writes by adding the register
362
+		 * read (flush).  This is to protect against some strange
363
+		 * bridge configurations that may issue Memory Write Block
364
+		 * (MWB) to our register space.  The *_rev_3 hardware at
365
+		 * least doesn't respond correctly to every other dword in an
366
+		 * MWB to our register space.
367
+		 */
368
+		E1000_WRITE_FLUSH(hw);
369
+	}
370
+
371
+	if (mac->type < e1000_82545_rev_3)
372
+		e1000_pcix_mmrbc_workaround_generic(hw);
373
+
374
+	/* Setup link and flow control */
375
+	ret_val = mac->ops.setup_link(hw);
376
+
377
+	txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
378
+	txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
379
+	         E1000_TXDCTL_FULL_TX_DESC_WB;
380
+	E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
381
+
382
+	/*
383
+	 * Clear all of the statistics registers (clear on read).  It is
384
+	 * important that we do this after we have tried to establish link
385
+	 * because the symbol error count will increment wildly if there
386
+	 * is no link.
387
+	 */
388
+	e1000_clear_hw_cntrs_82540(hw);
389
+
390
+	if ((hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER) ||
391
+	    (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3)) {
392
+		ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
393
+		/*
394
+		 * Relaxed ordering must be disabled to avoid a parity
395
+		 * error crash in a PCI slot.
396
+		 */
397
+		ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
398
+		E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
399
+	}
400
+
401
+	return ret_val;
402
+}
403
+
404
+/**
405
+ *  e1000_setup_copper_link_82540 - Configure copper link settings
406
+ *  @hw: pointer to the HW structure
407
+ *
408
+ *  Calls the appropriate function to configure the link for auto-neg or forced
409
+ *  speed and duplex.  Then we check for link, once link is established calls
410
+ *  to configure collision distance and flow control are called.  If link is
411
+ *  not established, we return -E1000_ERR_PHY (-2).
412
+ **/
413
+static s32 e1000_setup_copper_link_82540(struct e1000_hw *hw)
414
+{
415
+	u32 ctrl;
416
+	s32 ret_val = E1000_SUCCESS;
417
+	u16 data;
418
+
419
+	DEBUGFUNC("e1000_setup_copper_link_82540");
420
+
421
+	ctrl = E1000_READ_REG(hw, E1000_CTRL);
422
+	ctrl |= E1000_CTRL_SLU;
423
+	ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
424
+	E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
425
+
426
+	ret_val = e1000_set_phy_mode_82540(hw);
427
+	if (ret_val)
428
+		goto out;
429
+
430
+	if (hw->mac.type == e1000_82545_rev_3 ||
431
+	    hw->mac.type == e1000_82546_rev_3) {
432
+		ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &data);
433
+		if (ret_val)
434
+			goto out;
435
+		data |= 0x00000008;
436
+		ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, data);
437
+		if (ret_val)
438
+			goto out;
439
+	}
440
+
441
+	ret_val = e1000_copper_link_setup_m88(hw);
442
+	if (ret_val)
443
+		goto out;
444
+
445
+	ret_val = e1000_setup_copper_link_generic(hw);
446
+
447
+out:
448
+	return ret_val;
449
+}
450
+
451
+/**
452
+ *  e1000_setup_fiber_serdes_link_82540 - Setup link for fiber/serdes
453
+ *  @hw: pointer to the HW structure
454
+ *
455
+ *  Set the output amplitude to the value in the EEPROM and adjust the VCO
456
+ *  speed to improve Bit Error Rate (BER) performance.  Configures collision
457
+ *  distance and flow control for fiber and serdes links.  Upon successful
458
+ *  setup, poll for link.
459
+ **/
460
+static s32 e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw)
461
+{
462
+	struct e1000_mac_info *mac = &hw->mac;
463
+	s32 ret_val = E1000_SUCCESS;
464
+
465
+	DEBUGFUNC("e1000_setup_fiber_serdes_link_82540");
466
+
467
+	switch (mac->type) {
468
+	case e1000_82545_rev_3:
469
+	case e1000_82546_rev_3:
470
+		if (hw->phy.media_type == e1000_media_type_internal_serdes) {
471
+			/*
472
+			 * If we're on serdes media, adjust the output
473
+			 * amplitude to value set in the EEPROM.
474
+			 */
475
+			ret_val = e1000_adjust_serdes_amplitude_82540(hw);
476
+			if (ret_val)
477
+				goto out;
478
+		}
479
+		/* Adjust VCO speed to improve BER performance */
480
+		ret_val = e1000_set_vco_speed_82540(hw);
481
+		if (ret_val)
482
+			goto out;
483
+	default:
484
+		break;
485
+	}
486
+
487
+	ret_val = e1000_setup_fiber_serdes_link_generic(hw);
488
+
489
+out:
490
+	return ret_val;
491
+}
492
+
493
+/**
494
+ *  e1000_adjust_serdes_amplitude_82540 - Adjust amplitude based on EEPROM
495
+ *  @hw: pointer to the HW structure
496
+ *
497
+ *  Adjust the SERDES output amplitude based on the EEPROM settings.
498
+ **/
499
+static s32 e1000_adjust_serdes_amplitude_82540(struct e1000_hw *hw)
500
+{
501
+	s32 ret_val = E1000_SUCCESS;
502
+	u16 nvm_data;
503
+
504
+	DEBUGFUNC("e1000_adjust_serdes_amplitude_82540");
505
+
506
+	ret_val = hw->nvm.ops.read(hw, NVM_SERDES_AMPLITUDE, 1, &nvm_data);
507
+	if (ret_val)
508
+		goto out;
509
+
510
+	if (nvm_data != NVM_RESERVED_WORD) {
511
+		/* Adjust serdes output amplitude only. */
512
+		nvm_data &= NVM_SERDES_AMPLITUDE_MASK;
513
+		ret_val = hw->phy.ops.write_reg(hw,
514
+		                             M88E1000_PHY_EXT_CTRL,
515
+		                             nvm_data);
516
+		if (ret_val)
517
+			goto out;
518
+	}
519
+
520
+out:
521
+	return ret_val;
522
+}
523
+
524
+/**
525
+ *  e1000_set_vco_speed_82540 - Set VCO speed for better performance
526
+ *  @hw: pointer to the HW structure
527
+ *
528
+ *  Set the VCO speed to improve Bit Error Rate (BER) performance.
529
+ **/
530
+static s32 e1000_set_vco_speed_82540(struct e1000_hw *hw)
531
+{
532
+	s32  ret_val = E1000_SUCCESS;
533
+	u16 default_page = 0;
534
+	u16 phy_data;
535
+
536
+	DEBUGFUNC("e1000_set_vco_speed_82540");
537
+
538
+	/* Set PHY register 30, page 5, bit 8 to 0 */
539
+
540
+	ret_val = hw->phy.ops.read_reg(hw,
541
+	                            M88E1000_PHY_PAGE_SELECT,
542
+	                            &default_page);
543
+	if (ret_val)
544
+		goto out;
545
+
546
+	ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0005);
547
+	if (ret_val)
548
+		goto out;
549
+
550
+	ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
551
+	if (ret_val)
552
+		goto out;
553
+
554
+	phy_data &= ~M88E1000_PHY_VCO_REG_BIT8;
555
+	ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
556
+	if (ret_val)
557
+		goto out;
558
+
559
+	/* Set PHY register 30, page 4, bit 11 to 1 */
560
+
561
+	ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0004);
562
+	if (ret_val)
563
+		goto out;
564
+
565
+	ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
566
+	if (ret_val)
567
+		goto out;
568
+
569
+	phy_data |= M88E1000_PHY_VCO_REG_BIT11;
570
+	ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
571
+	if (ret_val)
572
+		goto out;
573
+
574
+	ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT,
575
+	                              default_page);
576
+
577
+out:
578
+	return ret_val;
579
+}
580
+
581
+/**
582
+ *  e1000_set_phy_mode_82540 - Set PHY to class A mode
583
+ *  @hw: pointer to the HW structure
584
+ *
585
+ *  Sets the PHY to class A mode and assumes the following operations will
586
+ *  follow to enable the new class mode:
587
+ *    1.  Do a PHY soft reset.
588
+ *    2.  Restart auto-negotiation or force link.
589
+ **/
590
+static s32 e1000_set_phy_mode_82540(struct e1000_hw *hw)
591
+{
592
+	struct e1000_phy_info *phy = &hw->phy;
593
+	s32 ret_val = E1000_SUCCESS;
594
+	u16 nvm_data;
595
+
596
+	DEBUGFUNC("e1000_set_phy_mode_82540");
597
+
598
+	if (hw->mac.type != e1000_82545_rev_3)
599
+		goto out;
600
+
601
+	ret_val = hw->nvm.ops.read(hw, NVM_PHY_CLASS_WORD, 1, &nvm_data);
602
+	if (ret_val) {
603
+		ret_val = -E1000_ERR_PHY;
604
+		goto out;
605
+	}
606
+
607
+	if ((nvm_data != NVM_RESERVED_WORD) && (nvm_data & NVM_PHY_CLASS_A)) {
608
+		ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT,
609
+		                              0x000B);
610
+		if (ret_val) {
611
+			ret_val = -E1000_ERR_PHY;
612
+			goto out;
613
+		}
614
+		ret_val = hw->phy.ops.write_reg(hw,
615
+		                              M88E1000_PHY_GEN_CONTROL,
616
+		                              0x8104);
617
+		if (ret_val) {
618
+			ret_val = -E1000_ERR_PHY;
619
+			goto out;
620
+		}
621
+
622
+		phy->reset_disable = false;
623
+	}
624
+
625
+out:
626
+	return ret_val;
627
+}
628
+
629
+/**
630
+ * e1000_power_down_phy_copper_82540 - Remove link in case of PHY power down
631
+ * @hw: pointer to the HW structure
632
+ *
633
+ * In the case of a PHY power down to save power, or to turn off link during a
634
+ * driver unload, or wake on lan is not enabled, remove the link.
635
+ **/
636
+static void e1000_power_down_phy_copper_82540(struct e1000_hw *hw)
637
+{
638
+	/* If the management interface is not enabled, then power down */
639
+	if (!(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_SMBUS_EN))
640
+		e1000_power_down_phy_copper(hw);
641
+
642
+	return;
643
+}
644
+
645
+/**
646
+ *  e1000_clear_hw_cntrs_82540 - Clear device specific hardware counters
647
+ *  @hw: pointer to the HW structure
648
+ *
649
+ *  Clears the hardware counters by reading the counter registers.
650
+ **/
651
+static void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw)
652
+{
653
+	DEBUGFUNC("e1000_clear_hw_cntrs_82540");
654
+
655
+	e1000_clear_hw_cntrs_base_generic(hw);
656
+
657
+#if 0
658
+	E1000_READ_REG(hw, E1000_PRC64);
659
+	E1000_READ_REG(hw, E1000_PRC127);
660
+	E1000_READ_REG(hw, E1000_PRC255);
661
+	E1000_READ_REG(hw, E1000_PRC511);
662
+	E1000_READ_REG(hw, E1000_PRC1023);
663
+	E1000_READ_REG(hw, E1000_PRC1522);
664
+	E1000_READ_REG(hw, E1000_PTC64);
665
+	E1000_READ_REG(hw, E1000_PTC127);
666
+	E1000_READ_REG(hw, E1000_PTC255);
667
+	E1000_READ_REG(hw, E1000_PTC511);
668
+	E1000_READ_REG(hw, E1000_PTC1023);
669
+	E1000_READ_REG(hw, E1000_PTC1522);
670
+
671
+	E1000_READ_REG(hw, E1000_ALGNERRC);
672
+	E1000_READ_REG(hw, E1000_RXERRC);
673
+	E1000_READ_REG(hw, E1000_TNCRS);
674
+	E1000_READ_REG(hw, E1000_CEXTERR);
675
+	E1000_READ_REG(hw, E1000_TSCTC);
676
+	E1000_READ_REG(hw, E1000_TSCTFC);
677
+
678
+	E1000_READ_REG(hw, E1000_MGTPRC);
679
+	E1000_READ_REG(hw, E1000_MGTPDC);
680
+	E1000_READ_REG(hw, E1000_MGTPTC);
681
+#endif
682
+}
683
+
684
+/**
685
+ *  e1000_read_mac_addr_82540 - Read device MAC address
686
+ *  @hw: pointer to the HW structure
687
+ *
688
+ *  Reads the device MAC address from the EEPROM and stores the value.
689
+ *  Since devices with two ports use the same EEPROM, we increment the
690
+ *  last bit in the MAC address for the second port.
691
+ *
692
+ *  This version is being used over generic because of customer issues
693
+ *  with VmWare and Virtual Box when using generic. It seems in
694
+ *  the emulated 82545, RAR[0] does NOT have a valid address after a
695
+ *  reset, this older method works and using this breaks nothing for
696
+ *  these legacy adapters.
697
+ **/
698
+s32 e1000_read_mac_addr_82540(struct e1000_hw *hw)
699
+{
700
+	s32  ret_val = E1000_SUCCESS;
701
+	u16 offset, nvm_data, i;
702
+
703
+	DEBUGFUNC("e1000_read_mac_addr");
704
+
705
+	for (i = 0; i < ETH_ADDR_LEN; i += 2) {
706
+		offset = i >> 1;
707
+		ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
708
+		if (ret_val) {
709
+			DEBUGOUT("NVM Read Error\n");
710
+			goto out;
711
+		}
712
+		hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF);
713
+		hw->mac.perm_addr[i+1] = (u8)(nvm_data >> 8);
714
+	}
715
+
716
+	/* Flip last bit of mac address if we're on second port */
717
+	if (hw->bus.func == E1000_FUNC_1)
718
+		hw->mac.perm_addr[5] ^= 1;
719
+
720
+	for (i = 0; i < ETH_ADDR_LEN; i++)
721
+		hw->mac.addr[i] = hw->mac.perm_addr[i];
722
+
723
+out:
724
+	return ret_val;
725
+}
726
+
727
+static struct pci_device_id e1000_82540_nics[] = {
728
+     PCI_ROM(0x8086, 0x100E, "E1000_DEV_ID_82540EM", "E1000_DEV_ID_82540EM", e1000_82540),
729
+     PCI_ROM(0x8086, 0x1015, "E1000_DEV_ID_82540EM_LOM", "E1000_DEV_ID_82540EM_LOM", e1000_82540),
730
+     PCI_ROM(0x8086, 0x1016, "E1000_DEV_ID_82540EP_LOM", "E1000_DEV_ID_82540EP_LOM", e1000_82540),
731
+     PCI_ROM(0x8086, 0x1017, "E1000_DEV_ID_82540EP", "E1000_DEV_ID_82540EP", e1000_82540),
732
+     PCI_ROM(0x8086, 0x101E, "E1000_DEV_ID_82540EP_LP", "E1000_DEV_ID_82540EP_LP", e1000_82540),
733
+     PCI_ROM(0x8086, 0x100F, "E1000_DEV_ID_82545EM_COPPER", "E1000_DEV_ID_82545EM_COPPER", e1000_82545),
734
+     PCI_ROM(0x8086, 0x1011, "E1000_DEV_ID_82545EM_FIBER", "E1000_DEV_ID_82545EM_FIBER", e1000_82545),
735
+     PCI_ROM(0x8086, 0x1026, "E1000_DEV_ID_82545GM_COPPER", "E1000_DEV_ID_82545GM_COPPER", e1000_82545_rev_3),
736
+     PCI_ROM(0x8086, 0x1027, "E1000_DEV_ID_82545GM_FIBER", "E1000_DEV_ID_82545GM_FIBER", e1000_82545_rev_3),
737
+     PCI_ROM(0x8086, 0x1028, "E1000_DEV_ID_82545GM_SERDES", "E1000_DEV_ID_82545GM_SERDES", e1000_82545_rev_3),
738
+     PCI_ROM(0x8086, 0x1010, "E1000_DEV_ID_82546EB_COPPER", "E1000_DEV_ID_82546EB_COPPER", e1000_82546),
739
+     PCI_ROM(0x8086, 0x1012, "E1000_DEV_ID_82546EB_FIBER", "E1000_DEV_ID_82546EB_FIBER", e1000_82546),
740
+     PCI_ROM(0x8086, 0x101D, "E1000_DEV_ID_82546EB_QUAD_COPPER", "E1000_DEV_ID_82546EB_QUAD_COPPER", e1000_82546),
741
+     PCI_ROM(0x8086, 0x1079, "E1000_DEV_ID_82546GB_COPPER", "E1000_DEV_ID_82546GB_COPPER", e1000_82546_rev_3),
742
+     PCI_ROM(0x8086, 0x107A, "E1000_DEV_ID_82546GB_FIBER", "E1000_DEV_ID_82546GB_FIBER", e1000_82546_rev_3),
743
+     PCI_ROM(0x8086, 0x107B, "E1000_DEV_ID_82546GB_SERDES", "E1000_DEV_ID_82546GB_SERDES", e1000_82546_rev_3),
744
+     PCI_ROM(0x8086, 0x108A, "E1000_DEV_ID_82546GB_PCIE", "E1000_DEV_ID_82546GB_PCIE", e1000_82546_rev_3),
745
+     PCI_ROM(0x8086, 0x1099, "E1000_DEV_ID_82546GB_QUAD_COPPER", "E1000_DEV_ID_82546GB_QUAD_COPPER", e1000_82546_rev_3),
746
+     PCI_ROM(0x8086, 0x10B5, "E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3", "E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3", e1000_82546_rev_3),
747
+};
748
+
749
+struct pci_driver e1000_82540_driver __pci_driver = {
750
+	.ids = e1000_82540_nics,
751
+	.id_count = (sizeof (e1000_82540_nics) / sizeof (e1000_82540_nics[0])),
752
+	.probe = e1000_probe,
753
+	.remove = e1000_remove,
754
+};

+ 1314
- 0
src/drivers/net/e1000/e1000_82541.c
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 86
- 0
src/drivers/net/e1000/e1000_82541.h Ver fichero

@@ -0,0 +1,86 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_82541_H_
32
+#define _E1000_82541_H_
33
+
34
+#define NVM_WORD_SIZE_BASE_SHIFT_82541 (NVM_WORD_SIZE_BASE_SHIFT + 1)
35
+
36
+#define IGP01E1000_PHY_CHANNEL_NUM                    4
37
+
38
+#define IGP01E1000_PHY_AGC_A                     0x1172
39
+#define IGP01E1000_PHY_AGC_B                     0x1272
40
+#define IGP01E1000_PHY_AGC_C                     0x1472
41
+#define IGP01E1000_PHY_AGC_D                     0x1872
42
+
43
+#define IGP01E1000_PHY_AGC_PARAM_A               0x1171
44
+#define IGP01E1000_PHY_AGC_PARAM_B               0x1271
45
+#define IGP01E1000_PHY_AGC_PARAM_C               0x1471
46
+#define IGP01E1000_PHY_AGC_PARAM_D               0x1871
47
+
48
+#define IGP01E1000_PHY_EDAC_MU_INDEX             0xC000
49
+#define IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS      0x8000
50
+
51
+#define IGP01E1000_PHY_DSP_RESET                 0x1F33
52
+
53
+#define IGP01E1000_PHY_DSP_FFE                   0x1F35
54
+#define IGP01E1000_PHY_DSP_FFE_CM_CP             0x0069
55
+#define IGP01E1000_PHY_DSP_FFE_DEFAULT           0x002A
56
+
57
+#define IGP01E1000_IEEE_FORCE_GIG                0x0140
58
+#define IGP01E1000_IEEE_RESTART_AUTONEG          0x3300
59
+
60
+#define IGP01E1000_AGC_LENGTH_SHIFT                   7
61
+#define IGP01E1000_AGC_RANGE                         10
62
+
63
+#define FFE_IDLE_ERR_COUNT_TIMEOUT_20                20
64
+#define FFE_IDLE_ERR_COUNT_TIMEOUT_100              100
65
+
66
+#define IGP01E1000_ANALOG_FUSE_STATUS            0x20D0
67
+#define IGP01E1000_ANALOG_SPARE_FUSE_STATUS      0x20D1
68
+#define IGP01E1000_ANALOG_FUSE_CONTROL           0x20DC
69
+#define IGP01E1000_ANALOG_FUSE_BYPASS            0x20DE
70
+
71
+#define IGP01E1000_ANALOG_SPARE_FUSE_ENABLED     0x0100
72
+#define IGP01E1000_ANALOG_FUSE_FINE_MASK         0x0F80
73
+#define IGP01E1000_ANALOG_FUSE_COARSE_MASK       0x0070
74
+#define IGP01E1000_ANALOG_FUSE_COARSE_THRESH     0x0040
75
+#define IGP01E1000_ANALOG_FUSE_COARSE_10         0x0010
76
+#define IGP01E1000_ANALOG_FUSE_FINE_1            0x0080
77
+#define IGP01E1000_ANALOG_FUSE_FINE_10           0x0500
78
+#define IGP01E1000_ANALOG_FUSE_POLY_MASK         0xF000
79
+#define IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL 0x0002
80
+
81
+#define IGP01E1000_MSE_CHANNEL_D                 0x000F
82
+#define IGP01E1000_MSE_CHANNEL_C                 0x00F0
83
+#define IGP01E1000_MSE_CHANNEL_B                 0x0F00
84
+#define IGP01E1000_MSE_CHANNEL_A                 0xF000
85
+
86
+#endif

+ 571
- 0
src/drivers/net/e1000/e1000_82542.c Ver fichero

@@ -0,0 +1,571 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+/*
32
+ * 82542 Gigabit Ethernet Controller
33
+ */
34
+
35
+#include "e1000_api.h"
36
+
37
+static s32  e1000_init_phy_params_82542(struct e1000_hw *hw);
38
+static s32  e1000_init_nvm_params_82542(struct e1000_hw *hw);
39
+static s32  e1000_init_mac_params_82542(struct e1000_hw *hw);
40
+static s32  e1000_get_bus_info_82542(struct e1000_hw *hw);
41
+static s32  e1000_reset_hw_82542(struct e1000_hw *hw);
42
+static s32  e1000_init_hw_82542(struct e1000_hw *hw);
43
+static s32  e1000_setup_link_82542(struct e1000_hw *hw);
44
+static s32  e1000_led_on_82542(struct e1000_hw *hw);
45
+static s32  e1000_led_off_82542(struct e1000_hw *hw);
46
+static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index);
47
+static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw);
48
+
49
+/**
50
+ *  e1000_init_phy_params_82542 - Init PHY func ptrs.
51
+ *  @hw: pointer to the HW structure
52
+ **/
53
+static s32 e1000_init_phy_params_82542(struct e1000_hw *hw)
54
+{
55
+	struct e1000_phy_info *phy = &hw->phy;
56
+	s32 ret_val = E1000_SUCCESS;
57
+
58
+	DEBUGFUNC("e1000_init_phy_params_82542");
59
+
60
+	phy->type               = e1000_phy_none;
61
+
62
+	return ret_val;
63
+}
64
+
65
+/**
66
+ *  e1000_init_nvm_params_82542 - Init NVM func ptrs.
67
+ *  @hw: pointer to the HW structure
68
+ **/
69
+static s32 e1000_init_nvm_params_82542(struct e1000_hw *hw)
70
+{
71
+	struct e1000_nvm_info *nvm = &hw->nvm;
72
+
73
+	DEBUGFUNC("e1000_init_nvm_params_82542");
74
+
75
+	nvm->address_bits       =  6;
76
+	nvm->delay_usec         = 50;
77
+	nvm->opcode_bits        =  3;
78
+	nvm->type               = e1000_nvm_eeprom_microwire;
79
+	nvm->word_size          = 64;
80
+
81
+	/* Function Pointers */
82
+	nvm->ops.read           = e1000_read_nvm_microwire;
83
+	nvm->ops.release        = e1000_stop_nvm;
84
+	nvm->ops.write          = e1000_write_nvm_microwire;
85
+	nvm->ops.update         = e1000_update_nvm_checksum_generic;
86
+	nvm->ops.validate       = e1000_validate_nvm_checksum_generic;
87
+
88
+	return E1000_SUCCESS;
89
+}
90
+
91
+/**
92
+ *  e1000_init_mac_params_82542 - Init MAC func ptrs.
93
+ *  @hw: pointer to the HW structure
94
+ **/
95
+static s32 e1000_init_mac_params_82542(struct e1000_hw *hw)
96
+{
97
+	struct e1000_mac_info *mac = &hw->mac;
98
+
99
+	DEBUGFUNC("e1000_init_mac_params_82542");
100
+
101
+	/* Set media type */
102
+	hw->phy.media_type = e1000_media_type_fiber;
103
+
104
+	/* Set mta register count */
105
+	mac->mta_reg_count = 128;
106
+	/* Set rar entry count */
107
+	mac->rar_entry_count = E1000_RAR_ENTRIES;
108
+
109
+	/* Function pointers */
110
+
111
+	/* bus type/speed/width */
112
+	mac->ops.get_bus_info = e1000_get_bus_info_82542;
113
+	/* function id */
114
+	mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
115
+	/* reset */
116
+	mac->ops.reset_hw = e1000_reset_hw_82542;
117
+	/* hw initialization */
118
+	mac->ops.init_hw = e1000_init_hw_82542;
119
+	/* link setup */
120
+	mac->ops.setup_link = e1000_setup_link_82542;
121
+	/* phy/fiber/serdes setup */
122
+	mac->ops.setup_physical_interface = e1000_setup_fiber_serdes_link_generic;
123
+	/* check for link */
124
+	mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
125
+	/* multicast address update */
126
+	mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
127
+	/* writing VFTA */
128
+	mac->ops.write_vfta = e1000_write_vfta_generic;
129
+	/* clearing VFTA */
130
+	mac->ops.clear_vfta = e1000_clear_vfta_generic;
131
+	/* setting MTA */
132
+	mac->ops.mta_set = e1000_mta_set_generic;
133
+	/* set RAR */
134
+	mac->ops.rar_set = e1000_rar_set_82542;
135
+	/* turn on/off LED */
136
+	mac->ops.led_on = e1000_led_on_82542;
137
+	mac->ops.led_off = e1000_led_off_82542;
138
+	/* clear hardware counters */
139
+	mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82542;
140
+	/* link info */
141
+	mac->ops.get_link_up_info = e1000_get_speed_and_duplex_fiber_serdes_generic;
142
+
143
+	return E1000_SUCCESS;
144
+}
145
+
146
+/**
147
+ *  e1000_init_function_pointers_82542 - Init func ptrs.
148
+ *  @hw: pointer to the HW structure
149
+ *
150
+ *  Called to initialize all function pointers and parameters.
151
+ **/
152
+void e1000_init_function_pointers_82542(struct e1000_hw *hw)
153
+{
154
+	DEBUGFUNC("e1000_init_function_pointers_82542");
155
+
156
+	hw->mac.ops.init_params = e1000_init_mac_params_82542;
157
+	hw->nvm.ops.init_params = e1000_init_nvm_params_82542;
158
+	hw->phy.ops.init_params = e1000_init_phy_params_82542;
159
+}
160
+
161
+/**
162
+ *  e1000_get_bus_info_82542 - Obtain bus information for adapter
163
+ *  @hw: pointer to the HW structure
164
+ *
165
+ *  This will obtain information about the HW bus for which the
166
+ *  adapter is attached and stores it in the hw structure.
167
+ **/
168
+static s32 e1000_get_bus_info_82542(struct e1000_hw *hw)
169
+{
170
+	DEBUGFUNC("e1000_get_bus_info_82542");
171
+
172
+	hw->bus.type = e1000_bus_type_pci;
173
+	hw->bus.speed = e1000_bus_speed_unknown;
174
+	hw->bus.width = e1000_bus_width_unknown;
175
+
176
+	return E1000_SUCCESS;
177
+}
178
+
179
+/**
180
+ *  e1000_reset_hw_82542 - Reset hardware
181
+ *  @hw: pointer to the HW structure
182
+ *
183
+ *  This resets the hardware into a known state.
184
+ **/
185
+static s32 e1000_reset_hw_82542(struct e1000_hw *hw)
186
+{
187
+	struct e1000_bus_info *bus = &hw->bus;
188
+	s32 ret_val = E1000_SUCCESS;
189
+	u32 ctrl, icr;
190
+
191
+	DEBUGFUNC("e1000_reset_hw_82542");
192
+
193
+	if (hw->revision_id == E1000_REVISION_2) {
194
+		DEBUGOUT("Disabling MWI on 82542 rev 2\n");
195
+		e1000_pci_clear_mwi(hw);
196
+	}
197
+
198
+	DEBUGOUT("Masking off all interrupts\n");
199
+	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
200
+
201
+	E1000_WRITE_REG(hw, E1000_RCTL, 0);
202
+	E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
203
+	E1000_WRITE_FLUSH(hw);
204
+
205
+	/*
206
+	 * Delay to allow any outstanding PCI transactions to complete before
207
+	 * resetting the device
208
+	 */
209
+	msec_delay(10);
210
+
211
+	ctrl = E1000_READ_REG(hw, E1000_CTRL);
212
+
213
+	DEBUGOUT("Issuing a global reset to 82542/82543 MAC\n");
214
+	E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
215
+
216
+	hw->nvm.ops.reload(hw);
217
+	msec_delay(2);
218
+
219
+	E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
220
+	icr = E1000_READ_REG(hw, E1000_ICR);
221
+
222
+	if (hw->revision_id == E1000_REVISION_2) {
223
+		if (bus->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
224
+			e1000_pci_set_mwi(hw);
225
+	}
226
+
227
+	return ret_val;
228
+}
229
+
230
+/**
231
+ *  e1000_init_hw_82542 - Initialize hardware
232
+ *  @hw: pointer to the HW structure
233
+ *
234
+ *  This inits the hardware readying it for operation.
235
+ **/
236
+static s32 e1000_init_hw_82542(struct e1000_hw *hw)
237
+{
238
+	struct e1000_mac_info *mac = &hw->mac;
239
+	struct e1000_dev_spec_82542 *dev_spec = &hw->dev_spec._82542;
240
+	s32 ret_val = E1000_SUCCESS;
241
+	u32 ctrl;
242
+	u16 i;
243
+
244
+	DEBUGFUNC("e1000_init_hw_82542");
245
+
246
+	/* Disabling VLAN filtering */
247
+	E1000_WRITE_REG(hw, E1000_VET, 0);
248
+	mac->ops.clear_vfta(hw);
249
+
250
+	/* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
251
+	if (hw->revision_id == E1000_REVISION_2) {
252
+		DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
253
+		e1000_pci_clear_mwi(hw);
254
+		E1000_WRITE_REG(hw, E1000_RCTL, E1000_RCTL_RST);
255
+		E1000_WRITE_FLUSH(hw);
256
+		msec_delay(5);
257
+	}
258
+
259
+	/* Setup the receive address. */
260
+	e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
261
+
262
+	/* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
263
+	if (hw->revision_id == E1000_REVISION_2) {
264
+		E1000_WRITE_REG(hw, E1000_RCTL, 0);
265
+		E1000_WRITE_FLUSH(hw);
266
+		msec_delay(1);
267
+		if (hw->bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
268
+			e1000_pci_set_mwi(hw);
269
+	}
270
+
271
+	/* Zero out the Multicast HASH table */
272
+	DEBUGOUT("Zeroing the MTA\n");
273
+	for (i = 0; i < mac->mta_reg_count; i++)
274
+		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
275
+
276
+	/*
277
+	 * Set the PCI priority bit correctly in the CTRL register.  This
278
+	 * determines if the adapter gives priority to receives, or if it
279
+	 * gives equal priority to transmits and receives.
280
+	 */
281
+	if (dev_spec->dma_fairness) {
282
+		ctrl = E1000_READ_REG(hw, E1000_CTRL);
283
+		E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PRIOR);
284
+	}
285
+
286
+	/* Setup link and flow control */
287
+	ret_val = e1000_setup_link_82542(hw);
288
+
289
+	/*
290
+	 * Clear all of the statistics registers (clear on read).  It is
291
+	 * important that we do this after we have tried to establish link
292
+	 * because the symbol error count will increment wildly if there
293
+	 * is no link.
294
+	 */
295
+	e1000_clear_hw_cntrs_82542(hw);
296
+
297
+	return ret_val;
298
+}
299
+
300
+/**
301
+ *  e1000_setup_link_82542 - Setup flow control and link settings
302
+ *  @hw: pointer to the HW structure
303
+ *
304
+ *  Determines which flow control settings to use, then configures flow
305
+ *  control.  Calls the appropriate media-specific link configuration
306
+ *  function.  Assuming the adapter has a valid link partner, a valid link
307
+ *  should be established.  Assumes the hardware has previously been reset
308
+ *  and the transmitter and receiver are not enabled.
309
+ **/
310
+static s32 e1000_setup_link_82542(struct e1000_hw *hw)
311
+{
312
+	struct e1000_mac_info *mac = &hw->mac;
313
+	s32 ret_val = E1000_SUCCESS;
314
+
315
+	DEBUGFUNC("e1000_setup_link_82542");
316
+
317
+	ret_val = e1000_set_default_fc_generic(hw);
318
+	if (ret_val)
319
+		goto out;
320
+
321
+	hw->fc.requested_mode &= ~e1000_fc_tx_pause;
322
+
323
+	if (mac->report_tx_early == 1)
324
+		hw->fc.requested_mode &= ~e1000_fc_rx_pause;
325
+
326
+	/*
327
+	 * Save off the requested flow control mode for use later.  Depending
328
+	 * on the link partner's capabilities, we may or may not use this mode.
329
+	 */
330
+	hw->fc.current_mode = hw->fc.requested_mode;
331
+
332
+	DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
333
+	                                             hw->fc.current_mode);
334
+
335
+	/* Call the necessary subroutine to configure the link. */
336
+	ret_val = mac->ops.setup_physical_interface(hw);
337
+	if (ret_val)
338
+		goto out;
339
+
340
+	/*
341
+	 * Initialize the flow control address, type, and PAUSE timer
342
+	 * registers to their default values.  This is done even if flow
343
+	 * control is disabled, because it does not hurt anything to
344
+	 * initialize these registers.
345
+	 */
346
+	DEBUGOUT("Initializing Flow Control address, type and timer regs\n");
347
+
348
+	E1000_WRITE_REG(hw, E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
349
+	E1000_WRITE_REG(hw, E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
350
+	E1000_WRITE_REG(hw, E1000_FCT, FLOW_CONTROL_TYPE);
351
+
352
+	E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
353
+
354
+	ret_val = e1000_set_fc_watermarks_generic(hw);
355
+
356
+out:
357
+	return ret_val;
358
+}
359
+
360
+/**
361
+ *  e1000_led_on_82542 - Turn on SW controllable LED
362
+ *  @hw: pointer to the HW structure
363
+ *
364
+ *  Turns the SW defined LED on.
365
+ **/
366
+static s32 e1000_led_on_82542(struct e1000_hw *hw __unused)
367
+{
368
+#if 0
369
+	u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
370
+
371
+	DEBUGFUNC("e1000_led_on_82542");
372
+
373
+	ctrl |= E1000_CTRL_SWDPIN0;
374
+	ctrl |= E1000_CTRL_SWDPIO0;
375
+	E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
376
+
377
+	return E1000_SUCCESS;
378
+#endif
379
+	return 0;
380
+}
381
+
382
+/**
383
+ *  e1000_led_off_82542 - Turn off SW controllable LED
384
+ *  @hw: pointer to the HW structure
385
+ *
386
+ *  Turns the SW defined LED off.
387
+ **/
388
+static s32 e1000_led_off_82542(struct e1000_hw *hw __unused)
389
+{
390
+#if 0
391
+	u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
392
+
393
+	DEBUGFUNC("e1000_led_off_82542");
394
+
395
+	ctrl &= ~E1000_CTRL_SWDPIN0;
396
+	ctrl |= E1000_CTRL_SWDPIO0;
397
+	E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
398
+
399
+	return E1000_SUCCESS;
400
+#endif
401
+	return 0;
402
+}
403
+
404
+/**
405
+ *  e1000_rar_set_82542 - Set receive address register
406
+ *  @hw: pointer to the HW structure
407
+ *  @addr: pointer to the receive address
408
+ *  @index: receive address array register
409
+ *
410
+ *  Sets the receive address array register at index to the address passed
411
+ *  in by addr.
412
+ **/
413
+static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index)
414
+{
415
+	u32 rar_low, rar_high;
416
+
417
+	DEBUGFUNC("e1000_rar_set_82542");
418
+
419
+	/*
420
+	 * HW expects these in little endian so we reverse the byte order
421
+	 * from network order (big endian) to little endian
422
+	 */
423
+	rar_low = ((u32) addr[0] |
424
+	           ((u32) addr[1] << 8) |
425
+	           ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
426
+
427
+	rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
428
+
429
+	/* If MAC address zero, no need to set the AV bit */
430
+	if (rar_low || rar_high)
431
+		rar_high |= E1000_RAH_AV;
432
+
433
+	E1000_WRITE_REG_ARRAY(hw, E1000_RA, (index << 1), rar_low);
434
+	E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
435
+}
436
+
437
+/**
438
+ *  e1000_translate_register_82542 - Translate the proper register offset
439
+ *  @reg: e1000 register to be read
440
+ *
441
+ *  Registers in 82542 are located in different offsets than other adapters
442
+ *  even though they function in the same manner.  This function takes in
443
+ *  the name of the register to read and returns the correct offset for
444
+ *  82542 silicon.
445
+ **/
446
+u32 e1000_translate_register_82542(u32 reg)
447
+{
448
+	/*
449
+	 * Some of the 82542 registers are located at different
450
+	 * offsets than they are in newer adapters.
451
+	 * Despite the difference in location, the registers
452
+	 * function in the same manner.
453
+	 */
454
+	switch (reg) {
455
+	case E1000_RA:
456
+		reg = 0x00040;
457
+		break;
458
+	case E1000_RDTR:
459
+		reg = 0x00108;
460
+		break;
461
+	case E1000_RDBAL(0):
462
+		reg = 0x00110;
463
+		break;
464
+	case E1000_RDBAH(0):
465
+		reg = 0x00114;
466
+		break;
467
+	case E1000_RDLEN(0):
468
+		reg = 0x00118;
469
+		break;
470
+	case E1000_RDH(0):
471
+		reg = 0x00120;
472
+		break;
473
+	case E1000_RDT(0):
474
+		reg = 0x00128;
475
+		break;
476
+	case E1000_RDBAL(1):
477
+		reg = 0x00138;
478
+		break;
479
+	case E1000_RDBAH(1):
480
+		reg = 0x0013C;
481
+		break;
482
+	case E1000_RDLEN(1):
483
+		reg = 0x00140;
484
+		break;
485
+	case E1000_RDH(1):
486
+		reg = 0x00148;
487
+		break;
488
+	case E1000_RDT(1):
489
+		reg = 0x00150;
490
+		break;
491
+	case E1000_FCRTH:
492
+		reg = 0x00160;
493
+		break;
494
+	case E1000_FCRTL:
495
+		reg = 0x00168;
496
+		break;
497
+	case E1000_MTA:
498
+		reg = 0x00200;
499
+		break;
500
+	case E1000_TDBAL(0):
501
+		reg = 0x00420;
502
+		break;
503
+	case E1000_TDBAH(0):
504
+		reg = 0x00424;
505
+		break;
506
+	case E1000_TDLEN(0):
507
+		reg = 0x00428;
508
+		break;
509
+	case E1000_TDH(0):
510
+		reg = 0x00430;
511
+		break;
512
+	case E1000_TDT(0):
513
+		reg = 0x00438;
514
+		break;
515
+	case E1000_TIDV:
516
+		reg = 0x00440;
517
+		break;
518
+	case E1000_VFTA:
519
+		reg = 0x00600;
520
+		break;
521
+	case E1000_TDFH:
522
+		reg = 0x08010;
523
+		break;
524
+	case E1000_TDFT:
525
+		reg = 0x08018;
526
+		break;
527
+	default:
528
+		break;
529
+	}
530
+
531
+	return reg;
532
+}
533
+
534
+/**
535
+ *  e1000_clear_hw_cntrs_82542 - Clear device specific hardware counters
536
+ *  @hw: pointer to the HW structure
537
+ *
538
+ *  Clears the hardware counters by reading the counter registers.
539
+ **/
540
+static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw)
541
+{
542
+	DEBUGFUNC("e1000_clear_hw_cntrs_82542");
543
+
544
+	e1000_clear_hw_cntrs_base_generic(hw);
545
+
546
+#if 0
547
+	E1000_READ_REG(hw, E1000_PRC64);
548
+	E1000_READ_REG(hw, E1000_PRC127);
549
+	E1000_READ_REG(hw, E1000_PRC255);
550
+	E1000_READ_REG(hw, E1000_PRC511);
551
+	E1000_READ_REG(hw, E1000_PRC1023);
552
+	E1000_READ_REG(hw, E1000_PRC1522);
553
+	E1000_READ_REG(hw, E1000_PTC64);
554
+	E1000_READ_REG(hw, E1000_PTC127);
555
+	E1000_READ_REG(hw, E1000_PTC255);
556
+	E1000_READ_REG(hw, E1000_PTC511);
557
+	E1000_READ_REG(hw, E1000_PTC1023);
558
+	E1000_READ_REG(hw, E1000_PTC1522);
559
+#endif
560
+}
561
+
562
+static struct pci_device_id e1000_82542_nics[] = {
563
+     PCI_ROM(0x8086, 0x1000, "E1000_DEV_ID_82542", "E1000_DEV_ID_82542", e1000_82542),
564
+};
565
+
566
+struct pci_driver e1000_82542_driver __pci_driver = {
567
+	.ids = e1000_82542_nics,
568
+	.id_count = (sizeof (e1000_82542_nics) / sizeof (e1000_82542_nics[0])),
569
+	.probe = e1000_probe,
570
+	.remove = e1000_remove,
571
+};

+ 1635
- 0
src/drivers/net/e1000/e1000_82543.c
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 45
- 0
src/drivers/net/e1000/e1000_82543.h Ver fichero

@@ -0,0 +1,45 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_82543_H_
32
+#define _E1000_82543_H_
33
+
34
+#define PHY_PREAMBLE      0xFFFFFFFF
35
+#define PHY_PREAMBLE_SIZE 32
36
+#define PHY_SOF           0x1
37
+#define PHY_OP_READ       0x2
38
+#define PHY_OP_WRITE      0x1
39
+#define PHY_TURNAROUND    0x2
40
+
41
+#define TBI_COMPAT_ENABLED 0x1 /* Global "knob" for the workaround */
42
+/* If TBI_COMPAT_ENABLED, then this is the current state (on/off) */
43
+#define TBI_SBP_ENABLED    0x2
44
+
45
+#endif

+ 1108
- 0
src/drivers/net/e1000/e1000_api.c
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 128
- 0
src/drivers/net/e1000/e1000_api.h Ver fichero

@@ -0,0 +1,128 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_API_H_
32
+#define _E1000_API_H_
33
+
34
+#include <stdint.h>
35
+#include <stdlib.h>
36
+#include <stdio.h>
37
+#include <string.h>
38
+#include <unistd.h>
39
+#include <gpxe/io.h>
40
+#include <errno.h>
41
+#include <byteswap.h>
42
+#include <gpxe/pci.h>
43
+#include <gpxe/malloc.h>
44
+#include <gpxe/if_ether.h>
45
+#include <gpxe/ethernet.h>
46
+#include <gpxe/iobuf.h>
47
+#include <gpxe/netdevice.h>
48
+
49
+#include "e1000_hw.h"
50
+
51
+extern void    e1000_init_function_pointers_82542(struct e1000_hw *hw) __attribute__((weak));
52
+extern void    e1000_init_function_pointers_82543(struct e1000_hw *hw) __attribute__((weak));
53
+extern void    e1000_init_function_pointers_82540(struct e1000_hw *hw) __attribute__((weak));
54
+extern void    e1000_init_function_pointers_82541(struct e1000_hw *hw) __attribute__((weak));
55
+
56
+s32  e1000_set_mac_type(struct e1000_hw *hw);
57
+s32  e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device);
58
+s32  e1000_init_mac_params(struct e1000_hw *hw);
59
+s32  e1000_init_nvm_params(struct e1000_hw *hw);
60
+s32  e1000_init_phy_params(struct e1000_hw *hw);
61
+s32  e1000_get_bus_info(struct e1000_hw *hw);
62
+void e1000_clear_vfta(struct e1000_hw *hw);
63
+void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
64
+s32  e1000_force_mac_fc(struct e1000_hw *hw);
65
+s32  e1000_check_for_link(struct e1000_hw *hw);
66
+s32  e1000_reset_hw(struct e1000_hw *hw);
67
+s32  e1000_init_hw(struct e1000_hw *hw);
68
+s32  e1000_setup_link(struct e1000_hw *hw);
69
+s32  e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed,
70
+                                u16 *duplex);
71
+s32  e1000_disable_pcie_master(struct e1000_hw *hw);
72
+void e1000_config_collision_dist(struct e1000_hw *hw);
73
+void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
74
+void e1000_mta_set(struct e1000_hw *hw, u32 hash_value);
75
+u32  e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr);
76
+void e1000_update_mc_addr_list(struct e1000_hw *hw,
77
+                               u8 *mc_addr_list, u32 mc_addr_count);
78
+s32  e1000_setup_led(struct e1000_hw *hw);
79
+s32  e1000_cleanup_led(struct e1000_hw *hw);
80
+s32  e1000_check_reset_block(struct e1000_hw *hw);
81
+s32  e1000_blink_led(struct e1000_hw *hw);
82
+s32  e1000_led_on(struct e1000_hw *hw);
83
+s32  e1000_led_off(struct e1000_hw *hw);
84
+s32 e1000_id_led_init(struct e1000_hw *hw);
85
+void e1000_reset_adaptive(struct e1000_hw *hw);
86
+void e1000_update_adaptive(struct e1000_hw *hw);
87
+#if 0
88
+s32  e1000_get_cable_length(struct e1000_hw *hw);
89
+#endif
90
+s32  e1000_validate_mdi_setting(struct e1000_hw *hw);
91
+s32  e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data);
92
+s32  e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data);
93
+s32  e1000_get_phy_info(struct e1000_hw *hw);
94
+void e1000_release_phy(struct e1000_hw *hw);
95
+s32  e1000_acquire_phy(struct e1000_hw *hw);
96
+s32  e1000_phy_hw_reset(struct e1000_hw *hw);
97
+s32  e1000_phy_commit(struct e1000_hw *hw);
98
+void e1000_power_up_phy(struct e1000_hw *hw);
99
+void e1000_power_down_phy(struct e1000_hw *hw);
100
+s32  e1000_read_mac_addr(struct e1000_hw *hw);
101
+s32  e1000_read_pba_num(struct e1000_hw *hw, u32 *part_num);
102
+void e1000_reload_nvm(struct e1000_hw *hw);
103
+s32  e1000_update_nvm_checksum(struct e1000_hw *hw);
104
+s32  e1000_validate_nvm_checksum(struct e1000_hw *hw);
105
+s32  e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
106
+s32  e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data);
107
+s32  e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data);
108
+s32  e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words,
109
+                     u16 *data);
110
+s32  e1000_wait_autoneg(struct e1000_hw *hw);
111
+s32  e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active);
112
+s32  e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);
113
+bool e1000_check_mng_mode(struct e1000_hw *hw);
114
+bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
115
+s32  e1000_mng_enable_host_if(struct e1000_hw *hw);
116
+s32  e1000_mng_host_if_write(struct e1000_hw *hw,
117
+                             u8 *buffer, u16 length, u16 offset, u8 *sum);
118
+s32  e1000_mng_write_cmd_header(struct e1000_hw *hw,
119
+                                struct e1000_host_mng_command_header *hdr);
120
+s32  e1000_mng_write_dhcp_info(struct e1000_hw * hw,
121
+                                    u8 *buffer, u16 length);
122
+u32  e1000_translate_register_82542(u32 reg) __attribute__((weak));
123
+
124
+extern int e1000_probe(struct pci_device *pdev,
125
+		       const struct pci_device_id *id __unused);
126
+extern void e1000_remove(struct pci_device *pdev);
127
+
128
+#endif

+ 1416
- 0
src/drivers/net/e1000/e1000_defines.h
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 0
- 9174
src/drivers/net/e1000/e1000_hw.c
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 619
- 3322
src/drivers/net/e1000/e1000_hw.h
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 2196
- 0
src/drivers/net/e1000/e1000_mac.c
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 94
- 0
src/drivers/net/e1000/e1000_mac.h Ver fichero

@@ -0,0 +1,94 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_MAC_H_
32
+#define _E1000_MAC_H_
33
+
34
+/*
35
+ * Functions that should not be called directly from drivers but can be used
36
+ * by other files in this 'shared code'
37
+ */
38
+void e1000_init_mac_ops_generic(struct e1000_hw *hw);
39
+void e1000_null_mac_generic(struct e1000_hw *hw);
40
+s32  e1000_null_ops_generic(struct e1000_hw *hw);
41
+s32  e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d);
42
+bool e1000_null_mng_mode(struct e1000_hw *hw);
43
+void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a);
44
+void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b);
45
+void e1000_null_mta_set(struct e1000_hw *hw, u32 a);
46
+void e1000_null_rar_set(struct e1000_hw *hw, u8 *h, u32 a);
47
+s32  e1000_blink_led_generic(struct e1000_hw *hw);
48
+s32  e1000_check_for_copper_link_generic(struct e1000_hw *hw);
49
+s32  e1000_check_for_fiber_link_generic(struct e1000_hw *hw);
50
+s32  e1000_check_for_serdes_link_generic(struct e1000_hw *hw);
51
+s32  e1000_cleanup_led_generic(struct e1000_hw *hw);
52
+s32  e1000_commit_fc_settings_generic(struct e1000_hw *hw);
53
+s32  e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw);
54
+s32  e1000_config_fc_after_link_up_generic(struct e1000_hw *hw);
55
+s32  e1000_disable_pcie_master_generic(struct e1000_hw *hw);
56
+s32  e1000_force_mac_fc_generic(struct e1000_hw *hw);
57
+s32  e1000_get_auto_rd_done_generic(struct e1000_hw *hw);
58
+s32  e1000_get_bus_info_pci_generic(struct e1000_hw *hw);
59
+s32  e1000_get_bus_info_pcie_generic(struct e1000_hw *hw);
60
+void e1000_set_lan_id_single_port(struct e1000_hw *hw);
61
+void e1000_set_lan_id_multi_port_pci(struct e1000_hw *hw);
62
+s32  e1000_get_hw_semaphore_generic(struct e1000_hw *hw);
63
+s32  e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
64
+                                               u16 *duplex);
65
+s32  e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw,
66
+                                                     u16 *speed, u16 *duplex);
67
+s32  e1000_id_led_init_generic(struct e1000_hw *hw);
68
+s32  e1000_led_on_generic(struct e1000_hw *hw);
69
+s32  e1000_led_off_generic(struct e1000_hw *hw);
70
+void e1000_update_mc_addr_list_generic(struct e1000_hw *hw,
71
+	                               u8 *mc_addr_list, u32 mc_addr_count);
72
+s32  e1000_set_default_fc_generic(struct e1000_hw *hw);
73
+s32  e1000_set_fc_watermarks_generic(struct e1000_hw *hw);
74
+s32  e1000_setup_fiber_serdes_link_generic(struct e1000_hw *hw);
75
+s32  e1000_setup_led_generic(struct e1000_hw *hw);
76
+s32  e1000_setup_link_generic(struct e1000_hw *hw);
77
+
78
+u32  e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr);
79
+
80
+void e1000_clear_hw_cntrs_base_generic(struct e1000_hw *hw);
81
+void e1000_clear_vfta_generic(struct e1000_hw *hw);
82
+void e1000_config_collision_dist_generic(struct e1000_hw *hw);
83
+void e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count);
84
+void e1000_mta_set_generic(struct e1000_hw *hw, u32 hash_value);
85
+void e1000_pcix_mmrbc_workaround_generic(struct e1000_hw *hw);
86
+void e1000_put_hw_semaphore_generic(struct e1000_hw *hw);
87
+void e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index);
88
+s32  e1000_check_alt_mac_addr_generic(struct e1000_hw *hw);
89
+void e1000_reset_adaptive_generic(struct e1000_hw *hw);
90
+void e1000_set_pcie_no_snoop_generic(struct e1000_hw *hw, u32 no_snoop);
91
+void e1000_update_adaptive_generic(struct e1000_hw *hw);
92
+void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value);
93
+
94
+#endif

+ 912
- 0
src/drivers/net/e1000/e1000_main.c Ver fichero

@@ -0,0 +1,912 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 Intel Corporation.
5
+
6
+  Portions Copyright(c) 2010 Marty Connor <mdc@etherboot.org>
7
+  Portions Copyright(c) 2010 Entity Cyber, Inc.
8
+
9
+  This program is free software; you can redistribute it and/or modify it
10
+  under the terms and conditions of the GNU General Public License,
11
+  version 2, as published by the Free Software Foundation.
12
+
13
+  This program is distributed in the hope it will be useful, but WITHOUT
14
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16
+  more details.
17
+
18
+  You should have received a copy of the GNU General Public License along with
19
+  this program; if not, write to the Free Software Foundation, Inc.,
20
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21
+
22
+  The full GNU General Public License is included in this distribution in
23
+  the file called "COPYING".
24
+
25
+  Contact Information:
26
+  Linux NICS <linux.nics@intel.com>
27
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
28
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
29
+
30
+*******************************************************************************/
31
+
32
+FILE_LICENCE ( GPL2_ONLY );
33
+
34
+#include "e1000.h"
35
+
36
+/**
37
+ * e1000_irq_disable - Disable interrupt generation
38
+ *
39
+ * @adapter: board private structure
40
+ **/
41
+static void e1000_irq_disable ( struct e1000_adapter *adapter )
42
+{
43
+	E1000_WRITE_REG ( &adapter->hw, E1000_IMC, ~0 );
44
+	E1000_WRITE_FLUSH ( &adapter->hw );
45
+}
46
+
47
+/**
48
+ * e1000_irq_enable - Enable interrupt generation
49
+ *
50
+ * @adapter: board private structure
51
+ **/
52
+static void e1000_irq_enable ( struct e1000_adapter *adapter )
53
+{
54
+	E1000_WRITE_REG(&adapter->hw, E1000_IMS, IMS_ENABLE_MASK);
55
+	E1000_WRITE_FLUSH(&adapter->hw);
56
+}
57
+
58
+/**
59
+ * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
60
+ * @adapter: board private structure to initialize
61
+ *
62
+ * e1000_sw_init initializes the Adapter private data structure.
63
+ * Fields are initialized based on PCI device information and
64
+ * OS network device settings (MTU size).
65
+ **/
66
+static int e1000_sw_init(struct e1000_adapter *adapter)
67
+{
68
+	struct e1000_hw *hw = &adapter->hw;
69
+	struct pci_device  *pdev = adapter->pdev;
70
+
71
+	/* PCI config space info */
72
+
73
+	hw->vendor_id = pdev->vendor;
74
+	hw->device_id = pdev->device;
75
+
76
+	pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &hw->subsystem_vendor_id);
77
+	pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &hw->subsystem_device_id);
78
+
79
+	pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
80
+
81
+	pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word);
82
+
83
+	adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
84
+	adapter->max_frame_size = MAXIMUM_ETHERNET_VLAN_SIZE +
85
+                                  ETH_HLEN + ETH_FCS_LEN;
86
+	adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
87
+
88
+	hw->fc.requested_mode = e1000_fc_none;
89
+
90
+	/* Initialize the hardware-specific values */
91
+	if (e1000_setup_init_funcs(hw, false)) {
92
+		DBG ("Hardware Initialization Failure\n");
93
+		return -EIO;
94
+	}
95
+
96
+	/* Explicitly disable IRQ since the NIC can be in any state. */
97
+	e1000_irq_disable ( adapter );
98
+
99
+	return 0;
100
+}
101
+
102
+int32_t e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
103
+{
104
+    struct e1000_adapter *adapter = hw->back;
105
+    uint16_t cap_offset;
106
+
107
+#define  PCI_CAP_ID_EXP        0x10    /* PCI Express */
108
+    cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
109
+    if (!cap_offset)
110
+        return -E1000_ERR_CONFIG;
111
+
112
+    pci_read_config_word(adapter->pdev, cap_offset + reg, value);
113
+
114
+    return 0;
115
+}
116
+
117
+void e1000_pci_clear_mwi ( struct e1000_hw *hw )
118
+{
119
+	struct e1000_adapter *adapter = hw->back;
120
+
121
+	pci_write_config_word ( adapter->pdev, PCI_COMMAND,
122
+			        hw->bus.pci_cmd_word & ~PCI_COMMAND_INVALIDATE );
123
+}
124
+
125
+void e1000_pci_set_mwi ( struct e1000_hw *hw )
126
+{
127
+	struct e1000_adapter *adapter = hw->back;
128
+
129
+	pci_write_config_word ( adapter->pdev, PCI_COMMAND,
130
+                                hw->bus.pci_cmd_word );
131
+}
132
+
133
+void e1000_read_pci_cfg ( struct e1000_hw *hw, uint32_t reg, uint16_t *value )
134
+{
135
+	struct e1000_adapter *adapter = hw->back;
136
+
137
+	pci_read_config_word ( adapter->pdev, reg, value );
138
+}
139
+
140
+void e1000_write_pci_cfg ( struct e1000_hw *hw, uint32_t reg, uint16_t *value )
141
+{
142
+	struct e1000_adapter *adapter = hw->back;
143
+
144
+	pci_write_config_word ( adapter->pdev, reg, *value );
145
+}
146
+
147
+/**
148
+ * e1000_init_manageability - disable interception of ARP packets
149
+ *
150
+ * @v adapter	e1000 private structure
151
+ **/
152
+static void e1000_init_manageability ( struct e1000_adapter *adapter )
153
+{
154
+	if (adapter->en_mng_pt) {
155
+		u32 manc = E1000_READ_REG(&adapter->hw, E1000_MANC);
156
+
157
+		/* disable hardware interception of ARP */
158
+		manc &= ~(E1000_MANC_ARP_EN);
159
+
160
+		E1000_WRITE_REG(&adapter->hw, E1000_MANC, manc);
161
+	}
162
+}
163
+
164
+/**
165
+ * e1000_setup_tx_resources - allocate Tx resources (Descriptors)
166
+ *
167
+ * @v adapter	e1000 private structure
168
+ *
169
+ * @ret rc       Returns 0 on success, negative on failure
170
+ **/
171
+static int e1000_setup_tx_resources ( struct e1000_adapter *adapter )
172
+{
173
+	DBG ( "e1000_setup_tx_resources\n" );
174
+
175
+	/* Allocate transmit descriptor ring memory.
176
+	   It must not cross a 64K boundary because of hardware errata #23
177
+	   so we use malloc_dma() requesting a 128 byte block that is
178
+	   128 byte aligned. This should guarantee that the memory
179
+	   allocated will not cross a 64K boundary, because 128 is an
180
+	   even multiple of 65536 ( 65536 / 128 == 512 ), so all possible
181
+	   allocations of 128 bytes on a 128 byte boundary will not
182
+	   cross 64K bytes.
183
+	 */
184
+
185
+        adapter->tx_base =
186
+		malloc_dma ( adapter->tx_ring_size, adapter->tx_ring_size );
187
+
188
+	if ( ! adapter->tx_base ) {
189
+		return -ENOMEM;
190
+	}
191
+
192
+	memset ( adapter->tx_base, 0, adapter->tx_ring_size );
193
+
194
+	DBG ( "adapter->tx_base = %#08lx\n", virt_to_bus ( adapter->tx_base ) );
195
+
196
+	return 0;
197
+}
198
+
199
+/**
200
+ * e1000_process_tx_packets - process transmitted packets
201
+ *
202
+ * @v netdev	network interface device structure
203
+ **/
204
+static void e1000_process_tx_packets ( struct net_device *netdev )
205
+{
206
+	struct e1000_adapter *adapter = netdev_priv ( netdev );
207
+	uint32_t i;
208
+	uint32_t tx_status;
209
+	struct e1000_tx_desc *tx_curr_desc;
210
+
211
+	/* Check status of transmitted packets
212
+	 */
213
+	while ( ( i = adapter->tx_head ) != adapter->tx_tail ) {
214
+
215
+		tx_curr_desc = ( void * )  ( adapter->tx_base ) +
216
+					   ( i * sizeof ( *adapter->tx_base ) );
217
+
218
+		tx_status = tx_curr_desc->upper.data;
219
+
220
+		/* if the packet at tx_head is not owned by hardware it is for us */
221
+		if ( ! ( tx_status & E1000_TXD_STAT_DD ) )
222
+			break;
223
+
224
+		DBG ( "Sent packet. tx_head: %d tx_tail: %d tx_status: %#08x\n",
225
+		      adapter->tx_head, adapter->tx_tail, tx_status );
226
+
227
+		if ( tx_status & ( E1000_TXD_STAT_EC | E1000_TXD_STAT_LC |
228
+				   E1000_TXD_STAT_TU ) ) {
229
+			netdev_tx_complete_err ( netdev, adapter->tx_iobuf[i], -EINVAL );
230
+			DBG ( "Error transmitting packet, tx_status: %#08x\n",
231
+			      tx_status );
232
+		} else {
233
+			netdev_tx_complete ( netdev, adapter->tx_iobuf[i] );
234
+			DBG ( "Success transmitting packet, tx_status: %#08x\n",
235
+			      tx_status );
236
+		}
237
+
238
+		/* Decrement count of used descriptors, clear this descriptor
239
+		 */
240
+		adapter->tx_fill_ctr--;
241
+		memset ( tx_curr_desc, 0, sizeof ( *tx_curr_desc ) );
242
+
243
+		adapter->tx_head = ( adapter->tx_head + 1 ) % NUM_TX_DESC;
244
+	}
245
+}
246
+
247
+static void e1000_free_tx_resources ( struct e1000_adapter *adapter )
248
+{
249
+	DBG ( "e1000_free_tx_resources\n" );
250
+
251
+        free_dma ( adapter->tx_base, adapter->tx_ring_size );
252
+}
253
+
254
+/**
255
+ * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
256
+ * @adapter: board private structure
257
+ *
258
+ * Configure the Tx unit of the MAC after a reset.
259
+ **/
260
+static void e1000_configure_tx ( struct e1000_adapter *adapter )
261
+{
262
+	struct e1000_hw *hw = &adapter->hw;
263
+	uint32_t tctl;
264
+
265
+	DBG ( "e1000_configure_tx\n" );
266
+
267
+	E1000_WRITE_REG ( hw, E1000_TDBAH(0), 0 );
268
+	E1000_WRITE_REG ( hw, E1000_TDBAL(0), virt_to_bus ( adapter->tx_base ) );
269
+	E1000_WRITE_REG ( hw, E1000_TDLEN(0), adapter->tx_ring_size );
270
+
271
+        DBG ( "E1000_TDBAL(0): %#08x\n",  E1000_READ_REG ( hw, E1000_TDBAL(0) ) );
272
+        DBG ( "E1000_TDLEN(0): %d\n",     E1000_READ_REG ( hw, E1000_TDLEN(0) ) );
273
+
274
+	/* Setup the HW Tx Head and Tail descriptor pointers */
275
+	E1000_WRITE_REG ( hw, E1000_TDH(0), 0 );
276
+	E1000_WRITE_REG ( hw, E1000_TDT(0), 0 );
277
+
278
+	adapter->tx_head = 0;
279
+	adapter->tx_tail = 0;
280
+	adapter->tx_fill_ctr = 0;
281
+
282
+	/* Setup Transmit Descriptor Settings for eop descriptor */
283
+	tctl = E1000_TCTL_PSP | E1000_TCTL_EN |
284
+		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT) |
285
+		(E1000_COLLISION_DISTANCE  << E1000_COLD_SHIFT);
286
+
287
+	e1000_config_collision_dist ( hw );
288
+
289
+	E1000_WRITE_REG ( hw, E1000_TCTL, tctl );
290
+        E1000_WRITE_FLUSH ( hw );
291
+}
292
+
293
+static void e1000_free_rx_resources ( struct e1000_adapter *adapter )
294
+{
295
+	int i;
296
+
297
+	DBG ( "e1000_free_rx_resources\n" );
298
+
299
+	free_dma ( adapter->rx_base, adapter->rx_ring_size );
300
+
301
+	for ( i = 0; i < NUM_RX_DESC; i++ ) {
302
+		free_iob ( adapter->rx_iobuf[i] );
303
+	}
304
+}
305
+
306
+/**
307
+ * e1000_refill_rx_ring - allocate Rx io_buffers
308
+ *
309
+ * @v adapter	e1000 private structure
310
+ *
311
+ * @ret rc       Returns 0 on success, negative on failure
312
+ **/
313
+static int e1000_refill_rx_ring ( struct e1000_adapter *adapter )
314
+{
315
+	int i, rx_curr;
316
+	int rc = 0;
317
+	struct e1000_rx_desc *rx_curr_desc;
318
+	struct e1000_hw *hw = &adapter->hw;
319
+	struct io_buffer *iob;
320
+
321
+	DBG ("e1000_refill_rx_ring\n");
322
+
323
+	for ( i = 0; i < NUM_RX_DESC; i++ ) {
324
+		rx_curr = ( ( adapter->rx_curr + i ) % NUM_RX_DESC );
325
+		rx_curr_desc = adapter->rx_base + rx_curr;
326
+
327
+		if ( rx_curr_desc->status & E1000_RXD_STAT_DD )
328
+			continue;
329
+
330
+		if ( adapter->rx_iobuf[rx_curr] != NULL )
331
+			continue;
332
+
333
+		DBG2 ( "Refilling rx desc %d\n", rx_curr );
334
+
335
+		iob = alloc_iob ( MAXIMUM_ETHERNET_VLAN_SIZE );
336
+		adapter->rx_iobuf[rx_curr] = iob;
337
+
338
+		if ( ! iob ) {
339
+			DBG ( "alloc_iob failed\n" );
340
+			rc = -ENOMEM;
341
+			break;
342
+		} else {
343
+			rx_curr_desc->buffer_addr = virt_to_bus ( iob->data );
344
+
345
+			E1000_WRITE_REG ( hw, E1000_RDT(0), rx_curr );
346
+		}
347
+	}
348
+	return rc;
349
+}
350
+
351
+/**
352
+ * e1000_setup_rx_resources - allocate Rx resources (Descriptors)
353
+ *
354
+ * @v adapter	e1000 private structure
355
+ *
356
+ * @ret rc       Returns 0 on success, negative on failure
357
+ **/
358
+static int e1000_setup_rx_resources ( struct e1000_adapter *adapter )
359
+{
360
+	int i, rc = 0;
361
+
362
+	DBG ( "e1000_setup_rx_resources\n" );
363
+
364
+	/* Allocate receive descriptor ring memory.
365
+	   It must not cross a 64K boundary because of hardware errata
366
+	 */
367
+
368
+        adapter->rx_base =
369
+		malloc_dma ( adapter->rx_ring_size, adapter->rx_ring_size );
370
+
371
+	if ( ! adapter->rx_base ) {
372
+		return -ENOMEM;
373
+	}
374
+	memset ( adapter->rx_base, 0, adapter->rx_ring_size );
375
+
376
+	for ( i = 0; i < NUM_RX_DESC; i++ ) {
377
+		/* let e1000_refill_rx_ring() io_buffer allocations */
378
+		adapter->rx_iobuf[i] = NULL;
379
+	}
380
+
381
+	/* allocate io_buffers */
382
+	rc = e1000_refill_rx_ring ( adapter );
383
+	if ( rc < 0 )
384
+		e1000_free_rx_resources ( adapter );
385
+
386
+	return rc;
387
+}
388
+
389
+/**
390
+ * e1000_configure_rx - Configure 8254x Receive Unit after Reset
391
+ * @adapter: board private structure
392
+ *
393
+ * Configure the Rx unit of the MAC after a reset.
394
+ **/
395
+static void e1000_configure_rx ( struct e1000_adapter *adapter )
396
+{
397
+	struct e1000_hw *hw = &adapter->hw;
398
+	uint32_t rctl;
399
+
400
+	DBG ( "e1000_configure_rx\n" );
401
+
402
+	/* disable receives while setting up the descriptors */
403
+	rctl = E1000_READ_REG ( hw, E1000_RCTL );
404
+	E1000_WRITE_REG ( hw, E1000_RCTL, rctl & ~E1000_RCTL_EN );
405
+	E1000_WRITE_FLUSH ( hw );
406
+	mdelay(10);
407
+
408
+	adapter->rx_curr = 0;
409
+
410
+	/* Setup the HW Rx Head and Tail Descriptor Pointers and
411
+	 * the Base and Length of the Rx Descriptor Ring */
412
+
413
+	E1000_WRITE_REG ( hw, E1000_RDBAL(0), virt_to_bus ( adapter->rx_base ) );
414
+	E1000_WRITE_REG ( hw, E1000_RDBAH(0), 0 );
415
+	E1000_WRITE_REG ( hw, E1000_RDLEN(0), adapter->rx_ring_size );
416
+
417
+	E1000_WRITE_REG ( hw, E1000_RDH(0), 0 );
418
+	E1000_WRITE_REG ( hw, E1000_RDT(0), NUM_RX_DESC - 1 );
419
+
420
+	/* Enable Receives */
421
+	rctl |=  E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
422
+		 E1000_RCTL_MPE;
423
+	E1000_WRITE_REG ( hw, E1000_RCTL, rctl );
424
+	E1000_WRITE_FLUSH ( hw );
425
+
426
+        DBG ( "E1000_RDBAL(0): %#08x\n",  E1000_READ_REG ( hw, E1000_RDBAL(0) ) );
427
+        DBG ( "E1000_RDLEN(0): %d\n",     E1000_READ_REG ( hw, E1000_RDLEN(0) ) );
428
+        DBG ( "E1000_RCTL:  %#08x\n",  E1000_READ_REG ( hw, E1000_RCTL ) );
429
+}
430
+
431
+/**
432
+ * e1000_process_rx_packets - process received packets
433
+ *
434
+ * @v netdev	network interface device structure
435
+ **/
436
+static void e1000_process_rx_packets ( struct net_device *netdev )
437
+{
438
+	struct e1000_adapter *adapter = netdev_priv ( netdev );
439
+	uint32_t i;
440
+	uint32_t rx_status;
441
+	uint32_t rx_len;
442
+	uint32_t rx_err;
443
+	struct e1000_rx_desc *rx_curr_desc;
444
+
445
+	/* Process received packets
446
+	 */
447
+	while ( 1 ) {
448
+
449
+		i = adapter->rx_curr;
450
+
451
+		rx_curr_desc = ( void * )  ( adapter->rx_base ) +
452
+			          ( i * sizeof ( *adapter->rx_base ) );
453
+		rx_status = rx_curr_desc->status;
454
+
455
+		DBG2 ( "Before DD Check RX_status: %#08x\n", rx_status );
456
+
457
+		if ( ! ( rx_status & E1000_RXD_STAT_DD ) )
458
+			break;
459
+
460
+		if ( adapter->rx_iobuf[i] == NULL )
461
+			break;
462
+
463
+		DBG ( "E1000_RCTL = %#08x\n", E1000_READ_REG ( &adapter->hw, E1000_RCTL ) );
464
+
465
+		rx_len = rx_curr_desc->length;
466
+
467
+                DBG ( "Received packet, rx_curr: %d  rx_status: %#08x  rx_len: %d\n",
468
+                      i, rx_status, rx_len );
469
+
470
+                rx_err = rx_curr_desc->errors;
471
+
472
+		iob_put ( adapter->rx_iobuf[i], rx_len );
473
+
474
+		if ( rx_err & E1000_RXD_ERR_FRAME_ERR_MASK ) {
475
+
476
+			netdev_rx_err ( netdev, adapter->rx_iobuf[i], -EINVAL );
477
+			DBG ( "e1000_poll: Corrupted packet received!"
478
+			      " rx_err: %#08x\n", rx_err );
479
+		} else {
480
+			/* Add this packet to the receive queue. */
481
+			netdev_rx ( netdev, adapter->rx_iobuf[i] );
482
+		}
483
+		adapter->rx_iobuf[i] = NULL;
484
+
485
+		memset ( rx_curr_desc, 0, sizeof ( *rx_curr_desc ) );
486
+
487
+		adapter->rx_curr = ( adapter->rx_curr + 1 ) % NUM_RX_DESC;
488
+	}
489
+}
490
+
491
+/**
492
+ * e1000_reset - Put e1000 NIC in known initial state
493
+ *
494
+ * @v adapter	e1000 private structure
495
+ **/
496
+void e1000_reset ( struct e1000_adapter *adapter )
497
+{
498
+	struct e1000_mac_info *mac = &adapter->hw.mac;
499
+	u32 pba = 0;
500
+
501
+	DBG ( "e1000_reset\n" );
502
+
503
+	switch (mac->type) {
504
+	case e1000_82542:
505
+	case e1000_82543:
506
+	case e1000_82544:
507
+	case e1000_82540:
508
+	case e1000_82541:
509
+	case e1000_82541_rev_2:
510
+		pba = E1000_PBA_48K;
511
+		break;
512
+	case e1000_82545:
513
+	case e1000_82545_rev_3:
514
+	case e1000_82546:
515
+	case e1000_82546_rev_3:
516
+		pba = E1000_PBA_48K;
517
+		break;
518
+	case e1000_82547:
519
+	case e1000_82547_rev_2:
520
+		pba = E1000_PBA_30K;
521
+		break;
522
+	case e1000_undefined:
523
+	case e1000_num_macs:
524
+		break;
525
+	}
526
+
527
+	E1000_WRITE_REG ( &adapter->hw, E1000_PBA, pba );
528
+
529
+	/* Allow time for pending master requests to run */
530
+	e1000_reset_hw ( &adapter->hw );
531
+
532
+	if ( mac->type >= e1000_82544 )
533
+		E1000_WRITE_REG ( &adapter->hw, E1000_WUC, 0 );
534
+
535
+	if ( e1000_init_hw ( &adapter->hw ) )
536
+		DBG ( "Hardware Error\n" );
537
+
538
+	e1000_reset_adaptive ( &adapter->hw );
539
+	e1000_get_phy_info ( &adapter->hw );
540
+
541
+	e1000_init_manageability ( adapter );
542
+}
543
+
544
+/** Functions that implement the gPXE driver API **/
545
+
546
+/**
547
+ * e1000_close - Disables a network interface
548
+ *
549
+ * @v netdev	network interface device structure
550
+ *
551
+ **/
552
+static void e1000_close ( struct net_device *netdev )
553
+{
554
+	struct e1000_adapter *adapter = netdev_priv ( netdev );
555
+	struct e1000_hw *hw = &adapter->hw;
556
+	uint32_t rctl;
557
+	uint32_t icr;
558
+
559
+	DBG ( "e1000_close\n" );
560
+
561
+	/* Acknowledge interrupts */
562
+	icr = E1000_READ_REG ( hw, E1000_ICR );
563
+
564
+	e1000_irq_disable ( adapter );
565
+
566
+	/* disable receives */
567
+	rctl = E1000_READ_REG ( hw, E1000_RCTL );
568
+	E1000_WRITE_REG ( hw, E1000_RCTL, rctl & ~E1000_RCTL_EN );
569
+	E1000_WRITE_FLUSH ( hw );
570
+
571
+	e1000_reset_hw ( hw );
572
+
573
+	e1000_free_tx_resources ( adapter );
574
+	e1000_free_rx_resources ( adapter );
575
+}
576
+
577
+/**
578
+ * e1000_transmit - Transmit a packet
579
+ *
580
+ * @v netdev	Network device
581
+ * @v iobuf	I/O buffer
582
+ *
583
+ * @ret rc       Returns 0 on success, negative on failure
584
+ */
585
+static int e1000_transmit ( struct net_device *netdev, struct io_buffer *iobuf )
586
+{
587
+	struct e1000_adapter *adapter = netdev_priv( netdev );
588
+	struct e1000_hw *hw = &adapter->hw;
589
+	uint32_t tx_curr = adapter->tx_tail;
590
+	struct e1000_tx_desc *tx_curr_desc;
591
+
592
+	DBG ("e1000_transmit\n");
593
+
594
+	if ( adapter->tx_fill_ctr == NUM_TX_DESC ) {
595
+		DBG ("TX overflow\n");
596
+		return -ENOBUFS;
597
+	}
598
+
599
+	/* Save pointer to iobuf we have been given to transmit,
600
+	   netdev_tx_complete() will need it later
601
+	 */
602
+	adapter->tx_iobuf[tx_curr] = iobuf;
603
+
604
+	tx_curr_desc = ( void * ) ( adapter->tx_base ) +
605
+		       ( tx_curr * sizeof ( *adapter->tx_base ) );
606
+
607
+	DBG ( "tx_curr_desc = %#08lx\n", virt_to_bus ( tx_curr_desc ) );
608
+	DBG ( "tx_curr_desc + 16 = %#08lx\n", virt_to_bus ( tx_curr_desc ) + 16 );
609
+	DBG ( "iobuf->data = %#08lx\n", virt_to_bus ( iobuf->data ) );
610
+
611
+	/* Add the packet to TX ring
612
+	 */
613
+	tx_curr_desc->buffer_addr =
614
+		virt_to_bus ( iobuf->data );
615
+	tx_curr_desc->lower.data =
616
+		E1000_TXD_CMD_RPS  | E1000_TXD_CMD_EOP |
617
+		E1000_TXD_CMD_IFCS | iob_len ( iobuf );
618
+	tx_curr_desc->upper.data = 0;
619
+
620
+	DBG ( "TX fill: %d tx_curr: %d addr: %#08lx len: %zd\n", adapter->tx_fill_ctr,
621
+	      tx_curr, virt_to_bus ( iobuf->data ), iob_len ( iobuf ) );
622
+
623
+	/* Point to next free descriptor */
624
+	adapter->tx_tail = ( adapter->tx_tail + 1 ) % NUM_TX_DESC;
625
+	adapter->tx_fill_ctr++;
626
+
627
+	/* Write new tail to NIC, making packet available for transmit
628
+	 */
629
+	wmb();
630
+	E1000_WRITE_REG ( hw, E1000_TDT(0), adapter->tx_tail );
631
+
632
+	return 0;
633
+}
634
+
635
+/**
636
+ * e1000_poll - Poll for received packets
637
+ *
638
+ * @v netdev	Network device
639
+ */
640
+static void e1000_poll ( struct net_device *netdev )
641
+{
642
+	struct e1000_adapter *adapter = netdev_priv( netdev );
643
+	struct e1000_hw *hw = &adapter->hw;
644
+
645
+	uint32_t icr;
646
+
647
+	DBGP ( "e1000_poll\n" );
648
+
649
+	/* Acknowledge interrupts */
650
+	icr = E1000_READ_REG ( hw, E1000_ICR );
651
+	if ( ! icr )
652
+		return;
653
+
654
+        DBG ( "e1000_poll: intr_status = %#08x\n", icr );
655
+
656
+	e1000_process_tx_packets ( netdev );
657
+
658
+	e1000_process_rx_packets ( netdev );
659
+
660
+	e1000_refill_rx_ring(adapter);
661
+}
662
+
663
+/**
664
+ * e1000_irq - enable or Disable interrupts
665
+ *
666
+ * @v adapter   e1000 adapter
667
+ * @v action    requested interrupt action
668
+ **/
669
+static void e1000_irq ( struct net_device *netdev, int enable )
670
+{
671
+	struct e1000_adapter *adapter = netdev_priv ( netdev );
672
+
673
+	DBG ( "e1000_irq\n" );
674
+
675
+	if ( enable ) {
676
+		e1000_irq_enable ( adapter );
677
+	} else {
678
+		e1000_irq_disable ( adapter );
679
+	}
680
+}
681
+
682
+static struct net_device_operations e1000_operations;
683
+
684
+/**
685
+ * e1000_probe - Initial configuration of e1000 NIC
686
+ *
687
+ * @v pci	PCI device
688
+ * @v id	PCI IDs
689
+ *
690
+ * @ret rc	Return status code
691
+ **/
692
+int e1000_probe ( struct pci_device *pdev,
693
+	      const struct pci_device_id *id __unused )
694
+{
695
+	int i, err;
696
+	struct net_device *netdev;
697
+	struct e1000_adapter *adapter;
698
+	unsigned long mmio_start, mmio_len;
699
+
700
+	DBG ( "e1000_probe\n" );
701
+
702
+	err = -ENOMEM;
703
+
704
+	/* Allocate net device ( also allocates memory for netdev->priv
705
+	   and makes netdev-priv point to it ) */
706
+	netdev = alloc_etherdev ( sizeof ( struct e1000_adapter ) );
707
+	if ( ! netdev )
708
+		goto err_alloc_etherdev;
709
+
710
+	/* Associate e1000-specific network operations operations with
711
+	 * generic network device layer */
712
+	netdev_init ( netdev, &e1000_operations );
713
+
714
+	/* Associate this network device with given PCI device */
715
+	pci_set_drvdata ( pdev, netdev );
716
+	netdev->dev = &pdev->dev;
717
+
718
+	/* Initialize driver private storage */
719
+	adapter = netdev_priv ( netdev );
720
+        memset ( adapter, 0, ( sizeof ( *adapter ) ) );
721
+
722
+	adapter->pdev       = pdev;
723
+
724
+	adapter->ioaddr     = pdev->ioaddr;
725
+        adapter->hw.io_base = pdev->ioaddr;
726
+
727
+        adapter->irqno      = pdev->irq;
728
+	adapter->netdev     = netdev;
729
+	adapter->hw.back    = adapter;
730
+
731
+	adapter->tx_ring_size = sizeof ( *adapter->tx_base ) * NUM_TX_DESC;
732
+	adapter->rx_ring_size = sizeof ( *adapter->rx_base ) * NUM_RX_DESC;
733
+
734
+	mmio_start = pci_bar_start ( pdev, PCI_BASE_ADDRESS_0 );
735
+	mmio_len   = pci_bar_size  ( pdev, PCI_BASE_ADDRESS_0 );
736
+
737
+	DBG ( "mmio_start: %#08lx\n", mmio_start );
738
+	DBG ( "mmio_len: %#08lx\n", mmio_len );
739
+
740
+	/* Fix up PCI device */
741
+	adjust_pci_device ( pdev );
742
+
743
+	err = -EIO;
744
+
745
+	adapter->hw.hw_addr = ioremap ( mmio_start, mmio_len );
746
+	DBG ( "adapter->hw.hw_addr: %p\n", adapter->hw.hw_addr );
747
+
748
+	if ( ! adapter->hw.hw_addr )
749
+		goto err_ioremap;
750
+
751
+	/* Hardware features, flags and workarounds */
752
+	if (adapter->hw.mac.type >= e1000_82540) {
753
+		adapter->flags |= E1000_FLAG_HAS_SMBUS;
754
+		adapter->flags |= E1000_FLAG_HAS_INTR_MODERATION;
755
+	}
756
+
757
+	if (adapter->hw.mac.type == e1000_82543)
758
+		adapter->flags |= E1000_FLAG_BAD_TX_CARRIER_STATS_FD;
759
+
760
+	adapter->hw.phy.autoneg_wait_to_complete = true;
761
+	adapter->hw.mac.adaptive_ifs = true;
762
+
763
+	/* setup the private structure */
764
+	if ( ( err = e1000_sw_init ( adapter ) ) )
765
+		goto err_sw_init;
766
+
767
+	if ((err = e1000_init_mac_params(&adapter->hw)))
768
+		goto err_hw_init;
769
+
770
+	if ((err = e1000_init_nvm_params(&adapter->hw)))
771
+		goto err_hw_init;
772
+
773
+        /* Force auto-negotiated speed and duplex */
774
+        adapter->hw.mac.autoneg = 1;
775
+
776
+	if ((err = e1000_init_phy_params(&adapter->hw)))
777
+		goto err_hw_init;
778
+
779
+	DBG ( "adapter->hw.mac.type: %#08x\n", adapter->hw.mac.type );
780
+
781
+	/* before reading the EEPROM, reset the controller to
782
+	 * put the device in a known good starting state
783
+	 */
784
+	err = e1000_reset_hw ( &adapter->hw );
785
+	if ( err < 0 ) {
786
+		DBG ( "Hardware Initialization Failed\n" );
787
+		goto err_reset;
788
+	}
789
+	/* make sure the NVM is good */
790
+
791
+	if ( e1000_validate_nvm_checksum(&adapter->hw) < 0 ) {
792
+		DBG ( "The NVM Checksum Is Not Valid\n" );
793
+		err = -EIO;
794
+		goto err_eeprom;
795
+	}
796
+
797
+	/* copy the MAC address out of the EEPROM */
798
+	if ( e1000_read_mac_addr ( &adapter->hw ) )
799
+		DBG ( "EEPROM Read Error\n" );
800
+
801
+        memcpy ( netdev->hw_addr, adapter->hw.mac.perm_addr, ETH_ALEN );
802
+
803
+	/* reset the hardware with the new settings */
804
+	e1000_reset ( adapter );
805
+
806
+	/* Mark as link up; we don't yet handle link state */
807
+	netdev_link_up ( netdev );
808
+
809
+	if ( ( err = register_netdev ( netdev ) ) != 0)
810
+		goto err_register;
811
+
812
+	for (i = 0; i < 6; i++)
813
+		DBG ("%02x%s", netdev->ll_addr[i], i == 5 ? "\n" : ":");
814
+
815
+	DBG ( "e1000_probe succeeded!\n" );
816
+
817
+	/* No errors, return success */
818
+	return 0;
819
+
820
+/* Error return paths */
821
+err_reset:
822
+err_register:
823
+err_hw_init:
824
+err_eeprom:
825
+	if (!e1000_check_reset_block(&adapter->hw))
826
+		e1000_phy_hw_reset(&adapter->hw);
827
+	if (adapter->hw.flash_address)
828
+		iounmap(adapter->hw.flash_address);
829
+err_sw_init:
830
+	iounmap ( adapter->hw.hw_addr );
831
+err_ioremap:
832
+	netdev_put ( netdev );
833
+err_alloc_etherdev:
834
+	return err;
835
+}
836
+
837
+/**
838
+ * e1000_remove - Device Removal Routine
839
+ *
840
+ * @v pdev PCI device information struct
841
+ *
842
+ **/
843
+void e1000_remove ( struct pci_device *pdev )
844
+{
845
+	struct net_device *netdev = pci_get_drvdata ( pdev );
846
+	struct e1000_adapter *adapter = netdev_priv ( netdev );
847
+
848
+	DBG ( "e1000_remove\n" );
849
+
850
+	if ( adapter->hw.flash_address )
851
+		iounmap ( adapter->hw.flash_address );
852
+	if  ( adapter->hw.hw_addr )
853
+		iounmap ( adapter->hw.hw_addr );
854
+
855
+	unregister_netdev ( netdev );
856
+	e1000_reset_hw ( &adapter->hw );
857
+	netdev_nullify ( netdev );
858
+	netdev_put ( netdev );
859
+}
860
+
861
+/**
862
+ * e1000_open - Called when a network interface is made active
863
+ *
864
+ * @v netdev	network interface device structure
865
+ * @ret rc	Return status code, 0 on success, negative value on failure
866
+ *
867
+ **/
868
+static int e1000_open ( struct net_device *netdev )
869
+{
870
+	struct e1000_adapter *adapter = netdev_priv(netdev);
871
+	int err;
872
+
873
+	DBG ( "e1000_open\n" );
874
+
875
+	/* allocate transmit descriptors */
876
+	err = e1000_setup_tx_resources ( adapter );
877
+	if ( err ) {
878
+		DBG ( "Error setting up TX resources!\n" );
879
+		goto err_setup_tx;
880
+	}
881
+
882
+	/* allocate receive descriptors */
883
+	err = e1000_setup_rx_resources ( adapter );
884
+	if ( err ) {
885
+		DBG ( "Error setting up RX resources!\n" );
886
+		goto err_setup_rx;
887
+	}
888
+
889
+	e1000_configure_tx ( adapter );
890
+
891
+	e1000_configure_rx ( adapter );
892
+
893
+        DBG ( "E1000_RXDCTL(0): %#08x\n",  E1000_READ_REG ( &adapter->hw, E1000_RXDCTL(0) ) );
894
+
895
+	return 0;
896
+
897
+err_setup_rx:
898
+	e1000_free_tx_resources ( adapter );
899
+err_setup_tx:
900
+	e1000_reset ( adapter );
901
+
902
+	return err;
903
+}
904
+
905
+/** e1000 net device operations */
906
+static struct net_device_operations e1000_operations = {
907
+        .open           = e1000_open,
908
+        .close          = e1000_close,
909
+        .transmit       = e1000_transmit,
910
+        .poll           = e1000_poll,
911
+        .irq            = e1000_irq,
912
+};

+ 389
- 0
src/drivers/net/e1000/e1000_manage.c Ver fichero

@@ -0,0 +1,389 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#if 0
32
+
33
+#include "e1000_api.h"
34
+
35
+static u8 e1000_calculate_checksum(u8 *buffer, u32 length);
36
+
37
+/**
38
+ *  e1000_calculate_checksum - Calculate checksum for buffer
39
+ *  @buffer: pointer to EEPROM
40
+ *  @length: size of EEPROM to calculate a checksum for
41
+ *
42
+ *  Calculates the checksum for some buffer on a specified length.  The
43
+ *  checksum calculated is returned.
44
+ **/
45
+static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
46
+{
47
+	u32 i;
48
+	u8  sum = 0;
49
+
50
+	DEBUGFUNC("e1000_calculate_checksum");
51
+
52
+	if (!buffer)
53
+		return 0;
54
+
55
+	for (i = 0; i < length; i++)
56
+		sum += buffer[i];
57
+
58
+	return (u8) (0 - sum);
59
+}
60
+
61
+/**
62
+ *  e1000_mng_enable_host_if_generic - Checks host interface is enabled
63
+ *  @hw: pointer to the HW structure
64
+ *
65
+ *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
66
+ *
67
+ *  This function checks whether the HOST IF is enabled for command operation
68
+ *  and also checks whether the previous command is completed.  It busy waits
69
+ *  in case of previous command is not completed.
70
+ **/
71
+s32 e1000_mng_enable_host_if_generic(struct e1000_hw *hw)
72
+{
73
+	u32 hicr;
74
+	s32 ret_val = E1000_SUCCESS;
75
+	u8  i;
76
+
77
+	DEBUGFUNC("e1000_mng_enable_host_if_generic");
78
+
79
+	/* Check that the host interface is enabled. */
80
+	hicr = E1000_READ_REG(hw, E1000_HICR);
81
+	if ((hicr & E1000_HICR_EN) == 0) {
82
+		DEBUGOUT("E1000_HOST_EN bit disabled.\n");
83
+		ret_val = -E1000_ERR_HOST_INTERFACE_COMMAND;
84
+		goto out;
85
+	}
86
+	/* check the previous command is completed */
87
+	for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
88
+		hicr = E1000_READ_REG(hw, E1000_HICR);
89
+		if (!(hicr & E1000_HICR_C))
90
+			break;
91
+		msec_delay_irq(1);
92
+	}
93
+
94
+	if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
95
+		DEBUGOUT("Previous command timeout failed .\n");
96
+		ret_val = -E1000_ERR_HOST_INTERFACE_COMMAND;
97
+		goto out;
98
+	}
99
+
100
+out:
101
+	return ret_val;
102
+}
103
+
104
+/**
105
+ *  e1000_check_mng_mode_generic - Generic check management mode
106
+ *  @hw: pointer to the HW structure
107
+ *
108
+ *  Reads the firmware semaphore register and returns true (>0) if
109
+ *  manageability is enabled, else false (0).
110
+ **/
111
+bool e1000_check_mng_mode_generic(struct e1000_hw *hw)
112
+{
113
+	u32 fwsm;
114
+
115
+	DEBUGFUNC("e1000_check_mng_mode_generic");
116
+
117
+	fwsm = E1000_READ_REG(hw, E1000_FWSM);
118
+
119
+	return (fwsm & E1000_FWSM_MODE_MASK) ==
120
+	        (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
121
+}
122
+
123
+/**
124
+ *  e1000_enable_tx_pkt_filtering_generic - Enable packet filtering on TX
125
+ *  @hw: pointer to the HW structure
126
+ *
127
+ *  Enables packet filtering on transmit packets if manageability is enabled
128
+ *  and host interface is enabled.
129
+ **/
130
+bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
131
+{
132
+	struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
133
+	u32 *buffer = (u32 *)&hw->mng_cookie;
134
+	u32 offset;
135
+	s32 ret_val, hdr_csum, csum;
136
+	u8 i, len;
137
+	bool tx_filter = true;
138
+
139
+	DEBUGFUNC("e1000_enable_tx_pkt_filtering_generic");
140
+
141
+	/* No manageability, no filtering */
142
+	if (!hw->mac.ops.check_mng_mode(hw)) {
143
+		tx_filter = false;
144
+		goto out;
145
+	}
146
+
147
+	/*
148
+	 * If we can't read from the host interface for whatever
149
+	 * reason, disable filtering.
150
+	 */
151
+	ret_val = hw->mac.ops.mng_enable_host_if(hw);
152
+	if (ret_val != E1000_SUCCESS) {
153
+		tx_filter = false;
154
+		goto out;
155
+	}
156
+
157
+	/* Read in the header.  Length and offset are in dwords. */
158
+	len    = E1000_MNG_DHCP_COOKIE_LENGTH >> 2;
159
+	offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2;
160
+	for (i = 0; i < len; i++) {
161
+		*(buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw,
162
+		                                           E1000_HOST_IF,
163
+		                                           offset + i);
164
+	}
165
+	hdr_csum = hdr->checksum;
166
+	hdr->checksum = 0;
167
+	csum = e1000_calculate_checksum((u8 *)hdr,
168
+	                                E1000_MNG_DHCP_COOKIE_LENGTH);
169
+	/*
170
+	 * If either the checksums or signature don't match, then
171
+	 * the cookie area isn't considered valid, in which case we
172
+	 * take the safe route of assuming Tx filtering is enabled.
173
+	 */
174
+	if (hdr_csum != csum)
175
+		goto out;
176
+	if (hdr->signature != E1000_IAMT_SIGNATURE)
177
+		goto out;
178
+
179
+	/* Cookie area is valid, make the final check for filtering. */
180
+	if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING))
181
+		tx_filter = false;
182
+
183
+out:
184
+	hw->mac.tx_pkt_filtering = tx_filter;
185
+	return tx_filter;
186
+}
187
+
188
+/**
189
+ *  e1000_mng_write_dhcp_info_generic - Writes DHCP info to host interface
190
+ *  @hw: pointer to the HW structure
191
+ *  @buffer: pointer to the host interface
192
+ *  @length: size of the buffer
193
+ *
194
+ *  Writes the DHCP information to the host interface.
195
+ **/
196
+s32 e1000_mng_write_dhcp_info_generic(struct e1000_hw *hw, u8 *buffer,
197
+                                      u16 length)
198
+{
199
+	struct e1000_host_mng_command_header hdr;
200
+	s32 ret_val;
201
+	u32 hicr;
202
+
203
+	DEBUGFUNC("e1000_mng_write_dhcp_info_generic");
204
+
205
+	hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
206
+	hdr.command_length = length;
207
+	hdr.reserved1 = 0;
208
+	hdr.reserved2 = 0;
209
+	hdr.checksum = 0;
210
+
211
+	/* Enable the host interface */
212
+	ret_val = hw->mac.ops.mng_enable_host_if(hw);
213
+	if (ret_val)
214
+		goto out;
215
+
216
+	/* Populate the host interface with the contents of "buffer". */
217
+	ret_val = hw->mac.ops.mng_host_if_write(hw, buffer, length,
218
+	                                  sizeof(hdr), &(hdr.checksum));
219
+	if (ret_val)
220
+		goto out;
221
+
222
+	/* Write the manageability command header */
223
+	ret_val = hw->mac.ops.mng_write_cmd_header(hw, &hdr);
224
+	if (ret_val)
225
+		goto out;
226
+
227
+	/* Tell the ARC a new command is pending. */
228
+	hicr = E1000_READ_REG(hw, E1000_HICR);
229
+	E1000_WRITE_REG(hw, E1000_HICR, hicr | E1000_HICR_C);
230
+
231
+out:
232
+	return ret_val;
233
+}
234
+
235
+/**
236
+ *  e1000_mng_write_cmd_header_generic - Writes manageability command header
237
+ *  @hw: pointer to the HW structure
238
+ *  @hdr: pointer to the host interface command header
239
+ *
240
+ *  Writes the command header after does the checksum calculation.
241
+ **/
242
+s32 e1000_mng_write_cmd_header_generic(struct e1000_hw *hw,
243
+                                    struct e1000_host_mng_command_header *hdr)
244
+{
245
+	u16 i, length = sizeof(struct e1000_host_mng_command_header);
246
+
247
+	DEBUGFUNC("e1000_mng_write_cmd_header_generic");
248
+
249
+	/* Write the whole command header structure with new checksum. */
250
+
251
+	hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
252
+
253
+	length >>= 2;
254
+	/* Write the relevant command block into the ram area. */
255
+	for (i = 0; i < length; i++) {
256
+		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, i,
257
+		                            *((u32 *) hdr + i));
258
+		E1000_WRITE_FLUSH(hw);
259
+	}
260
+
261
+	return E1000_SUCCESS;
262
+}
263
+
264
+/**
265
+ *  e1000_mng_host_if_write_generic - Write to the manageability host interface
266
+ *  @hw: pointer to the HW structure
267
+ *  @buffer: pointer to the host interface buffer
268
+ *  @length: size of the buffer
269
+ *  @offset: location in the buffer to write to
270
+ *  @sum: sum of the data (not checksum)
271
+ *
272
+ *  This function writes the buffer content at the offset given on the host if.
273
+ *  It also does alignment considerations to do the writes in most efficient
274
+ *  way.  Also fills up the sum of the buffer in *buffer parameter.
275
+ **/
276
+s32 e1000_mng_host_if_write_generic(struct e1000_hw *hw, u8 *buffer,
277
+                                    u16 length, u16 offset, u8 *sum)
278
+{
279
+	u8 *tmp;
280
+	u8 *bufptr = buffer;
281
+	u32 data = 0;
282
+	s32 ret_val = E1000_SUCCESS;
283
+	u16 remaining, i, j, prev_bytes;
284
+
285
+	DEBUGFUNC("e1000_mng_host_if_write_generic");
286
+
287
+	/* sum = only sum of the data and it is not checksum */
288
+
289
+	if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH) {
290
+		ret_val = -E1000_ERR_PARAM;
291
+		goto out;
292
+	}
293
+
294
+	tmp = (u8 *)&data;
295
+	prev_bytes = offset & 0x3;
296
+	offset >>= 2;
297
+
298
+	if (prev_bytes) {
299
+		data = E1000_READ_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset);
300
+		for (j = prev_bytes; j < sizeof(u32); j++) {
301
+			*(tmp + j) = *bufptr++;
302
+			*sum += *(tmp + j);
303
+		}
304
+		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset, data);
305
+		length -= j - prev_bytes;
306
+		offset++;
307
+	}
308
+
309
+	remaining = length & 0x3;
310
+	length -= remaining;
311
+
312
+	/* Calculate length in DWORDs */
313
+	length >>= 2;
314
+
315
+	/*
316
+	 * The device driver writes the relevant command block into the
317
+	 * ram area.
318
+	 */
319
+	for (i = 0; i < length; i++) {
320
+		for (j = 0; j < sizeof(u32); j++) {
321
+			*(tmp + j) = *bufptr++;
322
+			*sum += *(tmp + j);
323
+		}
324
+
325
+		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i,
326
+		                            data);
327
+	}
328
+	if (remaining) {
329
+		for (j = 0; j < sizeof(u32); j++) {
330
+			if (j < remaining)
331
+				*(tmp + j) = *bufptr++;
332
+			else
333
+				*(tmp + j) = 0;
334
+
335
+			*sum += *(tmp + j);
336
+		}
337
+		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i, data);
338
+	}
339
+
340
+out:
341
+	return ret_val;
342
+}
343
+
344
+/**
345
+ *  e1000_enable_mng_pass_thru - Enable processing of ARP's
346
+ *  @hw: pointer to the HW structure
347
+ *
348
+ *  Verifies the hardware needs to allow ARPs to be processed by the host.
349
+ **/
350
+bool e1000_enable_mng_pass_thru(struct e1000_hw *hw)
351
+{
352
+	u32 manc;
353
+	u32 fwsm, factps;
354
+	bool ret_val = false;
355
+
356
+	DEBUGFUNC("e1000_enable_mng_pass_thru");
357
+
358
+	if (!hw->mac.asf_firmware_present)
359
+		goto out;
360
+
361
+	manc = E1000_READ_REG(hw, E1000_MANC);
362
+
363
+	if (!(manc & E1000_MANC_RCV_TCO_EN) ||
364
+	    !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
365
+		goto out;
366
+
367
+	if (hw->mac.arc_subsystem_valid) {
368
+		fwsm = E1000_READ_REG(hw, E1000_FWSM);
369
+		factps = E1000_READ_REG(hw, E1000_FACTPS);
370
+
371
+		if (!(factps & E1000_FACTPS_MNGCG) &&
372
+		    ((fwsm & E1000_FWSM_MODE_MASK) ==
373
+		     (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
374
+			ret_val = true;
375
+			goto out;
376
+		}
377
+	} else {
378
+		if ((manc & E1000_MANC_SMBUS_EN) &&
379
+		    !(manc & E1000_MANC_ASF_EN)) {
380
+			ret_val = true;
381
+			goto out;
382
+		}
383
+	}
384
+
385
+out:
386
+	return ret_val;
387
+}
388
+
389
+#endif

+ 84
- 0
src/drivers/net/e1000/e1000_manage.h Ver fichero

@@ -0,0 +1,84 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_MANAGE_H_
32
+#define _E1000_MANAGE_H_
33
+
34
+bool e1000_check_mng_mode_generic(struct e1000_hw *hw);
35
+bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw);
36
+s32  e1000_mng_enable_host_if_generic(struct e1000_hw *hw);
37
+s32  e1000_mng_host_if_write_generic(struct e1000_hw *hw, u8 *buffer,
38
+                                     u16 length, u16 offset, u8 *sum);
39
+s32  e1000_mng_write_cmd_header_generic(struct e1000_hw *hw,
40
+                                    struct e1000_host_mng_command_header *hdr);
41
+s32  e1000_mng_write_dhcp_info_generic(struct e1000_hw *hw,
42
+                                       u8 *buffer, u16 length);
43
+bool e1000_enable_mng_pass_thru(struct e1000_hw *hw);
44
+
45
+enum e1000_mng_mode {
46
+	e1000_mng_mode_none = 0,
47
+	e1000_mng_mode_asf,
48
+	e1000_mng_mode_pt,
49
+	e1000_mng_mode_ipmi,
50
+	e1000_mng_mode_host_if_only
51
+};
52
+
53
+#define E1000_FACTPS_MNGCG    0x20000000
54
+
55
+#define E1000_FWSM_MODE_MASK  0xE
56
+#define E1000_FWSM_MODE_SHIFT 1
57
+
58
+#define E1000_MNG_IAMT_MODE                  0x3
59
+#define E1000_MNG_DHCP_COOKIE_LENGTH         0x10
60
+#define E1000_MNG_DHCP_COOKIE_OFFSET         0x6F0
61
+#define E1000_MNG_DHCP_COMMAND_TIMEOUT       10
62
+#define E1000_MNG_DHCP_TX_PAYLOAD_CMD        64
63
+#define E1000_MNG_DHCP_COOKIE_STATUS_PARSING 0x1
64
+#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN    0x2
65
+
66
+#define E1000_VFTA_ENTRY_SHIFT               5
67
+#define E1000_VFTA_ENTRY_MASK                0x7F
68
+#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK      0x1F
69
+
70
+#define E1000_HI_MAX_BLOCK_BYTE_LENGTH       1792 /* Num of bytes in range */
71
+#define E1000_HI_MAX_BLOCK_DWORD_LENGTH      448 /* Num of dwords in range */
72
+#define E1000_HI_COMMAND_TIMEOUT             500 /* Process HI command limit */
73
+
74
+#define E1000_HICR_EN              0x01  /* Enable bit - RO */
75
+/* Driver sets this bit when done to put command in RAM */
76
+#define E1000_HICR_C               0x02
77
+#define E1000_HICR_SV              0x04  /* Status Validity */
78
+#define E1000_HICR_FW_RESET_ENABLE 0x40
79
+#define E1000_HICR_FW_RESET        0x80
80
+
81
+/* Intel(R) Active Management Technology signature */
82
+#define E1000_IAMT_SIGNATURE  0x544D4149
83
+
84
+#endif

+ 923
- 0
src/drivers/net/e1000/e1000_nvm.c Ver fichero

@@ -0,0 +1,923 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#include "e1000_api.h"
32
+
33
+static void e1000_reload_nvm_generic(struct e1000_hw *hw);
34
+
35
+/**
36
+ *  e1000_init_nvm_ops_generic - Initialize NVM function pointers
37
+ *  @hw: pointer to the HW structure
38
+ *
39
+ *  Setups up the function pointers to no-op functions
40
+ **/
41
+void e1000_init_nvm_ops_generic(struct e1000_hw *hw)
42
+{
43
+	struct e1000_nvm_info *nvm = &hw->nvm;
44
+	DEBUGFUNC("e1000_init_nvm_ops_generic");
45
+
46
+	/* Initialize function pointers */
47
+	nvm->ops.init_params = e1000_null_ops_generic;
48
+	nvm->ops.acquire = e1000_null_ops_generic;
49
+	nvm->ops.read = e1000_null_read_nvm;
50
+	nvm->ops.release = e1000_null_nvm_generic;
51
+	nvm->ops.reload = e1000_reload_nvm_generic;
52
+	nvm->ops.update = e1000_null_ops_generic;
53
+	nvm->ops.valid_led_default = e1000_null_led_default;
54
+	nvm->ops.validate = e1000_null_ops_generic;
55
+	nvm->ops.write = e1000_null_write_nvm;
56
+}
57
+
58
+/**
59
+ *  e1000_null_nvm_read - No-op function, return 0
60
+ *  @hw: pointer to the HW structure
61
+ **/
62
+s32 e1000_null_read_nvm(struct e1000_hw *hw __unused, u16 a __unused,
63
+                        u16 b __unused, u16 *c __unused)
64
+{
65
+	DEBUGFUNC("e1000_null_read_nvm");
66
+	return E1000_SUCCESS;
67
+}
68
+
69
+/**
70
+ *  e1000_null_nvm_generic - No-op function, return void
71
+ *  @hw: pointer to the HW structure
72
+ **/
73
+void e1000_null_nvm_generic(struct e1000_hw *hw __unused)
74
+{
75
+	DEBUGFUNC("e1000_null_nvm_generic");
76
+	return;
77
+}
78
+
79
+/**
80
+ *  e1000_null_led_default - No-op function, return 0
81
+ *  @hw: pointer to the HW structure
82
+ **/
83
+s32 e1000_null_led_default(struct e1000_hw *hw __unused,
84
+                           u16 *data __unused)
85
+{
86
+	DEBUGFUNC("e1000_null_led_default");
87
+	return E1000_SUCCESS;
88
+}
89
+
90
+/**
91
+ *  e1000_null_write_nvm - No-op function, return 0
92
+ *  @hw: pointer to the HW structure
93
+ **/
94
+s32 e1000_null_write_nvm(struct e1000_hw *hw __unused, u16 a __unused,
95
+                         u16 b __unused, u16 *c __unused)
96
+{
97
+	DEBUGFUNC("e1000_null_write_nvm");
98
+	return E1000_SUCCESS;
99
+}
100
+
101
+/**
102
+ *  e1000_raise_eec_clk - Raise EEPROM clock
103
+ *  @hw: pointer to the HW structure
104
+ *  @eecd: pointer to the EEPROM
105
+ *
106
+ *  Enable/Raise the EEPROM clock bit.
107
+ **/
108
+static void e1000_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
109
+{
110
+	*eecd = *eecd | E1000_EECD_SK;
111
+	E1000_WRITE_REG(hw, E1000_EECD, *eecd);
112
+	E1000_WRITE_FLUSH(hw);
113
+	usec_delay(hw->nvm.delay_usec);
114
+}
115
+
116
+/**
117
+ *  e1000_lower_eec_clk - Lower EEPROM clock
118
+ *  @hw: pointer to the HW structure
119
+ *  @eecd: pointer to the EEPROM
120
+ *
121
+ *  Clear/Lower the EEPROM clock bit.
122
+ **/
123
+static void e1000_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
124
+{
125
+	*eecd = *eecd & ~E1000_EECD_SK;
126
+	E1000_WRITE_REG(hw, E1000_EECD, *eecd);
127
+	E1000_WRITE_FLUSH(hw);
128
+	usec_delay(hw->nvm.delay_usec);
129
+}
130
+
131
+/**
132
+ *  e1000_shift_out_eec_bits - Shift data bits our to the EEPROM
133
+ *  @hw: pointer to the HW structure
134
+ *  @data: data to send to the EEPROM
135
+ *  @count: number of bits to shift out
136
+ *
137
+ *  We need to shift 'count' bits out to the EEPROM.  So, the value in the
138
+ *  "data" parameter will be shifted out to the EEPROM one bit at a time.
139
+ *  In order to do this, "data" must be broken down into bits.
140
+ **/
141
+static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
142
+{
143
+	struct e1000_nvm_info *nvm = &hw->nvm;
144
+	u32 eecd = E1000_READ_REG(hw, E1000_EECD);
145
+	u32 mask;
146
+
147
+	DEBUGFUNC("e1000_shift_out_eec_bits");
148
+
149
+	mask = 0x01 << (count - 1);
150
+	if (nvm->type == e1000_nvm_eeprom_microwire)
151
+		eecd &= ~E1000_EECD_DO;
152
+	else
153
+	if (nvm->type == e1000_nvm_eeprom_spi)
154
+		eecd |= E1000_EECD_DO;
155
+
156
+	do {
157
+		eecd &= ~E1000_EECD_DI;
158
+
159
+		if (data & mask)
160
+			eecd |= E1000_EECD_DI;
161
+
162
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
163
+		E1000_WRITE_FLUSH(hw);
164
+
165
+		usec_delay(nvm->delay_usec);
166
+
167
+		e1000_raise_eec_clk(hw, &eecd);
168
+		e1000_lower_eec_clk(hw, &eecd);
169
+
170
+		mask >>= 1;
171
+	} while (mask);
172
+
173
+	eecd &= ~E1000_EECD_DI;
174
+	E1000_WRITE_REG(hw, E1000_EECD, eecd);
175
+}
176
+
177
+/**
178
+ *  e1000_shift_in_eec_bits - Shift data bits in from the EEPROM
179
+ *  @hw: pointer to the HW structure
180
+ *  @count: number of bits to shift in
181
+ *
182
+ *  In order to read a register from the EEPROM, we need to shift 'count' bits
183
+ *  in from the EEPROM.  Bits are "shifted in" by raising the clock input to
184
+ *  the EEPROM (setting the SK bit), and then reading the value of the data out
185
+ *  "DO" bit.  During this "shifting in" process the data in "DI" bit should
186
+ *  always be clear.
187
+ **/
188
+static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
189
+{
190
+	u32 eecd;
191
+	u32 i;
192
+	u16 data;
193
+
194
+	DEBUGFUNC("e1000_shift_in_eec_bits");
195
+
196
+	eecd = E1000_READ_REG(hw, E1000_EECD);
197
+
198
+	eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
199
+	data = 0;
200
+
201
+	for (i = 0; i < count; i++) {
202
+		data <<= 1;
203
+		e1000_raise_eec_clk(hw, &eecd);
204
+
205
+		eecd = E1000_READ_REG(hw, E1000_EECD);
206
+
207
+		eecd &= ~E1000_EECD_DI;
208
+		if (eecd & E1000_EECD_DO)
209
+			data |= 1;
210
+
211
+		e1000_lower_eec_clk(hw, &eecd);
212
+	}
213
+
214
+	return data;
215
+}
216
+
217
+/**
218
+ *  e1000_poll_eerd_eewr_done - Poll for EEPROM read/write completion
219
+ *  @hw: pointer to the HW structure
220
+ *  @ee_reg: EEPROM flag for polling
221
+ *
222
+ *  Polls the EEPROM status bit for either read or write completion based
223
+ *  upon the value of 'ee_reg'.
224
+ **/
225
+s32 e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg)
226
+{
227
+	u32 attempts = 100000;
228
+	u32 i, reg = 0;
229
+	s32 ret_val = -E1000_ERR_NVM;
230
+
231
+	DEBUGFUNC("e1000_poll_eerd_eewr_done");
232
+
233
+	for (i = 0; i < attempts; i++) {
234
+		if (ee_reg == E1000_NVM_POLL_READ)
235
+			reg = E1000_READ_REG(hw, E1000_EERD);
236
+		else
237
+			reg = E1000_READ_REG(hw, E1000_EEWR);
238
+
239
+		if (reg & E1000_NVM_RW_REG_DONE) {
240
+			ret_val = E1000_SUCCESS;
241
+			break;
242
+		}
243
+
244
+		usec_delay(5);
245
+	}
246
+
247
+	return ret_val;
248
+}
249
+
250
+/**
251
+ *  e1000_acquire_nvm_generic - Generic request for access to EEPROM
252
+ *  @hw: pointer to the HW structure
253
+ *
254
+ *  Set the EEPROM access request bit and wait for EEPROM access grant bit.
255
+ *  Return successful if access grant bit set, else clear the request for
256
+ *  EEPROM access and return -E1000_ERR_NVM (-1).
257
+ **/
258
+s32 e1000_acquire_nvm_generic(struct e1000_hw *hw)
259
+{
260
+	u32 eecd = E1000_READ_REG(hw, E1000_EECD);
261
+	s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
262
+	s32 ret_val = E1000_SUCCESS;
263
+
264
+	DEBUGFUNC("e1000_acquire_nvm_generic");
265
+
266
+	E1000_WRITE_REG(hw, E1000_EECD, eecd | E1000_EECD_REQ);
267
+	eecd = E1000_READ_REG(hw, E1000_EECD);
268
+
269
+	while (timeout) {
270
+		if (eecd & E1000_EECD_GNT)
271
+			break;
272
+		usec_delay(5);
273
+		eecd = E1000_READ_REG(hw, E1000_EECD);
274
+		timeout--;
275
+	}
276
+
277
+	if (!timeout) {
278
+		eecd &= ~E1000_EECD_REQ;
279
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
280
+		DEBUGOUT("Could not acquire NVM grant\n");
281
+		ret_val = -E1000_ERR_NVM;
282
+	}
283
+
284
+	return ret_val;
285
+}
286
+
287
+/**
288
+ *  e1000_standby_nvm - Return EEPROM to standby state
289
+ *  @hw: pointer to the HW structure
290
+ *
291
+ *  Return the EEPROM to a standby state.
292
+ **/
293
+static void e1000_standby_nvm(struct e1000_hw *hw)
294
+{
295
+	struct e1000_nvm_info *nvm = &hw->nvm;
296
+	u32 eecd = E1000_READ_REG(hw, E1000_EECD);
297
+
298
+	DEBUGFUNC("e1000_standby_nvm");
299
+
300
+	if (nvm->type == e1000_nvm_eeprom_microwire) {
301
+		eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
302
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
303
+		E1000_WRITE_FLUSH(hw);
304
+		usec_delay(nvm->delay_usec);
305
+
306
+		e1000_raise_eec_clk(hw, &eecd);
307
+
308
+		/* Select EEPROM */
309
+		eecd |= E1000_EECD_CS;
310
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
311
+		E1000_WRITE_FLUSH(hw);
312
+		usec_delay(nvm->delay_usec);
313
+
314
+		e1000_lower_eec_clk(hw, &eecd);
315
+	} else
316
+	if (nvm->type == e1000_nvm_eeprom_spi) {
317
+		/* Toggle CS to flush commands */
318
+		eecd |= E1000_EECD_CS;
319
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
320
+		E1000_WRITE_FLUSH(hw);
321
+		usec_delay(nvm->delay_usec);
322
+		eecd &= ~E1000_EECD_CS;
323
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
324
+		E1000_WRITE_FLUSH(hw);
325
+		usec_delay(nvm->delay_usec);
326
+	}
327
+}
328
+
329
+/**
330
+ *  e1000_stop_nvm - Terminate EEPROM command
331
+ *  @hw: pointer to the HW structure
332
+ *
333
+ *  Terminates the current command by inverting the EEPROM's chip select pin.
334
+ **/
335
+void e1000_stop_nvm(struct e1000_hw *hw)
336
+{
337
+	u32 eecd;
338
+
339
+	DEBUGFUNC("e1000_stop_nvm");
340
+
341
+	eecd = E1000_READ_REG(hw, E1000_EECD);
342
+	if (hw->nvm.type == e1000_nvm_eeprom_spi) {
343
+		/* Pull CS high */
344
+		eecd |= E1000_EECD_CS;
345
+		e1000_lower_eec_clk(hw, &eecd);
346
+	} else if (hw->nvm.type == e1000_nvm_eeprom_microwire) {
347
+		/* CS on Microwire is active-high */
348
+		eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
349
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
350
+		e1000_raise_eec_clk(hw, &eecd);
351
+		e1000_lower_eec_clk(hw, &eecd);
352
+	}
353
+}
354
+
355
+/**
356
+ *  e1000_release_nvm_generic - Release exclusive access to EEPROM
357
+ *  @hw: pointer to the HW structure
358
+ *
359
+ *  Stop any current commands to the EEPROM and clear the EEPROM request bit.
360
+ **/
361
+void e1000_release_nvm_generic(struct e1000_hw *hw)
362
+{
363
+	u32 eecd;
364
+
365
+	DEBUGFUNC("e1000_release_nvm_generic");
366
+
367
+	e1000_stop_nvm(hw);
368
+
369
+	eecd = E1000_READ_REG(hw, E1000_EECD);
370
+	eecd &= ~E1000_EECD_REQ;
371
+	E1000_WRITE_REG(hw, E1000_EECD, eecd);
372
+}
373
+
374
+/**
375
+ *  e1000_ready_nvm_eeprom - Prepares EEPROM for read/write
376
+ *  @hw: pointer to the HW structure
377
+ *
378
+ *  Setups the EEPROM for reading and writing.
379
+ **/
380
+static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
381
+{
382
+	struct e1000_nvm_info *nvm = &hw->nvm;
383
+	u32 eecd = E1000_READ_REG(hw, E1000_EECD);
384
+	s32 ret_val = E1000_SUCCESS;
385
+	u16 timeout = 0;
386
+	u8 spi_stat_reg;
387
+
388
+	DEBUGFUNC("e1000_ready_nvm_eeprom");
389
+
390
+	if (nvm->type == e1000_nvm_eeprom_microwire) {
391
+		/* Clear SK and DI */
392
+		eecd &= ~(E1000_EECD_DI | E1000_EECD_SK);
393
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
394
+		/* Set CS */
395
+		eecd |= E1000_EECD_CS;
396
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
397
+	} else
398
+	if (nvm->type == e1000_nvm_eeprom_spi) {
399
+		/* Clear SK and CS */
400
+		eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
401
+		E1000_WRITE_REG(hw, E1000_EECD, eecd);
402
+		usec_delay(1);
403
+		timeout = NVM_MAX_RETRY_SPI;
404
+
405
+		/*
406
+		 * Read "Status Register" repeatedly until the LSB is cleared.
407
+		 * The EEPROM will signal that the command has been completed
408
+		 * by clearing bit 0 of the internal status register.  If it's
409
+		 * not cleared within 'timeout', then error out.
410
+		 */
411
+		while (timeout) {
412
+			e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
413
+			                         hw->nvm.opcode_bits);
414
+			spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8);
415
+			if (!(spi_stat_reg & NVM_STATUS_RDY_SPI))
416
+				break;
417
+
418
+			usec_delay(5);
419
+			e1000_standby_nvm(hw);
420
+			timeout--;
421
+		}
422
+
423
+		if (!timeout) {
424
+			DEBUGOUT("SPI NVM Status error\n");
425
+			ret_val = -E1000_ERR_NVM;
426
+			goto out;
427
+		}
428
+	}
429
+
430
+out:
431
+	return ret_val;
432
+}
433
+
434
+/**
435
+ *  e1000_read_nvm_spi - Read EEPROM's using SPI
436
+ *  @hw: pointer to the HW structure
437
+ *  @offset: offset of word in the EEPROM to read
438
+ *  @words: number of words to read
439
+ *  @data: word read from the EEPROM
440
+ *
441
+ *  Reads a 16 bit word from the EEPROM.
442
+ **/
443
+s32 e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
444
+{
445
+	struct e1000_nvm_info *nvm = &hw->nvm;
446
+	u32 i = 0;
447
+	s32 ret_val;
448
+	u16 word_in;
449
+	u8 read_opcode = NVM_READ_OPCODE_SPI;
450
+
451
+	DEBUGFUNC("e1000_read_nvm_spi");
452
+
453
+	/*
454
+	 * A check for invalid values:  offset too large, too many words,
455
+	 * and not enough words.
456
+	 */
457
+	if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
458
+	    (words == 0)) {
459
+		DEBUGOUT("nvm parameter(s) out of bounds\n");
460
+		ret_val = -E1000_ERR_NVM;
461
+		goto out;
462
+	}
463
+
464
+	ret_val = nvm->ops.acquire(hw);
465
+	if (ret_val)
466
+		goto out;
467
+
468
+	ret_val = e1000_ready_nvm_eeprom(hw);
469
+	if (ret_val)
470
+		goto release;
471
+
472
+	e1000_standby_nvm(hw);
473
+
474
+	if ((nvm->address_bits == 8) && (offset >= 128))
475
+		read_opcode |= NVM_A8_OPCODE_SPI;
476
+
477
+	/* Send the READ command (opcode + addr) */
478
+	e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
479
+	e1000_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits);
480
+
481
+	/*
482
+	 * Read the data.  SPI NVMs increment the address with each byte
483
+	 * read and will roll over if reading beyond the end.  This allows
484
+	 * us to read the whole NVM from any offset
485
+	 */
486
+	for (i = 0; i < words; i++) {
487
+		word_in = e1000_shift_in_eec_bits(hw, 16);
488
+		data[i] = (word_in >> 8) | (word_in << 8);
489
+	}
490
+
491
+release:
492
+	nvm->ops.release(hw);
493
+
494
+out:
495
+	return ret_val;
496
+}
497
+
498
+/**
499
+ *  e1000_read_nvm_microwire - Reads EEPROM's using microwire
500
+ *  @hw: pointer to the HW structure
501
+ *  @offset: offset of word in the EEPROM to read
502
+ *  @words: number of words to read
503
+ *  @data: word read from the EEPROM
504
+ *
505
+ *  Reads a 16 bit word from the EEPROM.
506
+ **/
507
+s32 e1000_read_nvm_microwire(struct e1000_hw *hw, u16 offset, u16 words,
508
+                             u16 *data)
509
+{
510
+	struct e1000_nvm_info *nvm = &hw->nvm;
511
+	u32 i = 0;
512
+	s32 ret_val;
513
+	u8 read_opcode = NVM_READ_OPCODE_MICROWIRE;
514
+
515
+	DEBUGFUNC("e1000_read_nvm_microwire");
516
+
517
+	/*
518
+	 * A check for invalid values:  offset too large, too many words,
519
+	 * and not enough words.
520
+	 */
521
+	if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
522
+	    (words == 0)) {
523
+		DEBUGOUT("nvm parameter(s) out of bounds\n");
524
+		ret_val = -E1000_ERR_NVM;
525
+		goto out;
526
+	}
527
+
528
+	ret_val = nvm->ops.acquire(hw);
529
+	if (ret_val)
530
+		goto out;
531
+
532
+	ret_val = e1000_ready_nvm_eeprom(hw);
533
+	if (ret_val)
534
+		goto release;
535
+
536
+	for (i = 0; i < words; i++) {
537
+		/* Send the READ command (opcode + addr) */
538
+		e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
539
+		e1000_shift_out_eec_bits(hw, (u16)(offset + i),
540
+					nvm->address_bits);
541
+
542
+		/*
543
+		 * Read the data.  For microwire, each word requires the
544
+		 * overhead of setup and tear-down.
545
+		 */
546
+		data[i] = e1000_shift_in_eec_bits(hw, 16);
547
+		e1000_standby_nvm(hw);
548
+	}
549
+
550
+release:
551
+	nvm->ops.release(hw);
552
+
553
+out:
554
+	return ret_val;
555
+}
556
+
557
+/**
558
+ *  e1000_read_nvm_eerd - Reads EEPROM using EERD register
559
+ *  @hw: pointer to the HW structure
560
+ *  @offset: offset of word in the EEPROM to read
561
+ *  @words: number of words to read
562
+ *  @data: word read from the EEPROM
563
+ *
564
+ *  Reads a 16 bit word from the EEPROM using the EERD register.
565
+ **/
566
+s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
567
+{
568
+	struct e1000_nvm_info *nvm = &hw->nvm;
569
+	u32 i, eerd = 0;
570
+	s32 ret_val = E1000_SUCCESS;
571
+
572
+	DEBUGFUNC("e1000_read_nvm_eerd");
573
+
574
+	/*
575
+	 * A check for invalid values:  offset too large, too many words,
576
+	 * too many words for the offset, and not enough words.
577
+	 */
578
+	if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
579
+	    (words == 0)) {
580
+		DEBUGOUT("nvm parameter(s) out of bounds\n");
581
+		ret_val = -E1000_ERR_NVM;
582
+		goto out;
583
+	}
584
+
585
+	for (i = 0; i < words; i++) {
586
+		eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
587
+		       E1000_NVM_RW_REG_START;
588
+
589
+		E1000_WRITE_REG(hw, E1000_EERD, eerd);
590
+		ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
591
+		if (ret_val)
592
+			break;
593
+
594
+		data[i] = (E1000_READ_REG(hw, E1000_EERD) >>
595
+		           E1000_NVM_RW_REG_DATA);
596
+	}
597
+
598
+out:
599
+	return ret_val;
600
+}
601
+
602
+/**
603
+ *  e1000_write_nvm_spi - Write to EEPROM using SPI
604
+ *  @hw: pointer to the HW structure
605
+ *  @offset: offset within the EEPROM to be written to
606
+ *  @words: number of words to write
607
+ *  @data: 16 bit word(s) to be written to the EEPROM
608
+ *
609
+ *  Writes data to EEPROM at offset using SPI interface.
610
+ *
611
+ *  If e1000_update_nvm_checksum is not called after this function , the
612
+ *  EEPROM will most likely contain an invalid checksum.
613
+ **/
614
+s32 e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
615
+{
616
+	struct e1000_nvm_info *nvm = &hw->nvm;
617
+	s32 ret_val;
618
+	u16 widx = 0;
619
+
620
+	DEBUGFUNC("e1000_write_nvm_spi");
621
+
622
+	/*
623
+	 * A check for invalid values:  offset too large, too many words,
624
+	 * and not enough words.
625
+	 */
626
+	if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
627
+	    (words == 0)) {
628
+		DEBUGOUT("nvm parameter(s) out of bounds\n");
629
+		ret_val = -E1000_ERR_NVM;
630
+		goto out;
631
+	}
632
+
633
+	ret_val = nvm->ops.acquire(hw);
634
+	if (ret_val)
635
+		goto out;
636
+
637
+	while (widx < words) {
638
+		u8 write_opcode = NVM_WRITE_OPCODE_SPI;
639
+
640
+		ret_val = e1000_ready_nvm_eeprom(hw);
641
+		if (ret_val)
642
+			goto release;
643
+
644
+		e1000_standby_nvm(hw);
645
+
646
+		/* Send the WRITE ENABLE command (8 bit opcode) */
647
+		e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
648
+		                         nvm->opcode_bits);
649
+
650
+		e1000_standby_nvm(hw);
651
+
652
+		/*
653
+		 * Some SPI eeproms use the 8th address bit embedded in the
654
+		 * opcode
655
+		 */
656
+		if ((nvm->address_bits == 8) && (offset >= 128))
657
+			write_opcode |= NVM_A8_OPCODE_SPI;
658
+
659
+		/* Send the Write command (8-bit opcode + addr) */
660
+		e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
661
+		e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
662
+		                         nvm->address_bits);
663
+
664
+		/* Loop to allow for up to whole page write of eeprom */
665
+		while (widx < words) {
666
+			u16 word_out = data[widx];
667
+			word_out = (word_out >> 8) | (word_out << 8);
668
+			e1000_shift_out_eec_bits(hw, word_out, 16);
669
+			widx++;
670
+
671
+			if ((((offset + widx) * 2) % nvm->page_size) == 0) {
672
+				e1000_standby_nvm(hw);
673
+				break;
674
+			}
675
+		}
676
+	}
677
+
678
+	msec_delay(10);
679
+release:
680
+	nvm->ops.release(hw);
681
+
682
+out:
683
+	return ret_val;
684
+}
685
+
686
+/**
687
+ *  e1000_write_nvm_microwire - Writes EEPROM using microwire
688
+ *  @hw: pointer to the HW structure
689
+ *  @offset: offset within the EEPROM to be written to
690
+ *  @words: number of words to write
691
+ *  @data: 16 bit word(s) to be written to the EEPROM
692
+ *
693
+ *  Writes data to EEPROM at offset using microwire interface.
694
+ *
695
+ *  If e1000_update_nvm_checksum is not called after this function , the
696
+ *  EEPROM will most likely contain an invalid checksum.
697
+ **/
698
+s32 e1000_write_nvm_microwire(struct e1000_hw *hw, u16 offset, u16 words,
699
+                              u16 *data)
700
+{
701
+	struct e1000_nvm_info *nvm = &hw->nvm;
702
+	s32  ret_val;
703
+	u32 eecd;
704
+	u16 words_written = 0;
705
+	u16 widx = 0;
706
+
707
+	DEBUGFUNC("e1000_write_nvm_microwire");
708
+
709
+	/*
710
+	 * A check for invalid values:  offset too large, too many words,
711
+	 * and not enough words.
712
+	 */
713
+	if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
714
+	    (words == 0)) {
715
+		DEBUGOUT("nvm parameter(s) out of bounds\n");
716
+		ret_val = -E1000_ERR_NVM;
717
+		goto out;
718
+	}
719
+
720
+	ret_val = nvm->ops.acquire(hw);
721
+	if (ret_val)
722
+		goto out;
723
+
724
+	ret_val = e1000_ready_nvm_eeprom(hw);
725
+	if (ret_val)
726
+		goto release;
727
+
728
+	e1000_shift_out_eec_bits(hw, NVM_EWEN_OPCODE_MICROWIRE,
729
+	                         (u16)(nvm->opcode_bits + 2));
730
+
731
+	e1000_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));
732
+
733
+	e1000_standby_nvm(hw);
734
+
735
+	while (words_written < words) {
736
+		e1000_shift_out_eec_bits(hw, NVM_WRITE_OPCODE_MICROWIRE,
737
+		                         nvm->opcode_bits);
738
+
739
+		e1000_shift_out_eec_bits(hw, (u16)(offset + words_written),
740
+		                         nvm->address_bits);
741
+
742
+		e1000_shift_out_eec_bits(hw, data[words_written], 16);
743
+
744
+		e1000_standby_nvm(hw);
745
+
746
+		for (widx = 0; widx < 200; widx++) {
747
+			eecd = E1000_READ_REG(hw, E1000_EECD);
748
+			if (eecd & E1000_EECD_DO)
749
+				break;
750
+			usec_delay(50);
751
+		}
752
+
753
+		if (widx == 200) {
754
+			DEBUGOUT("NVM Write did not complete\n");
755
+			ret_val = -E1000_ERR_NVM;
756
+			goto release;
757
+		}
758
+
759
+		e1000_standby_nvm(hw);
760
+
761
+		words_written++;
762
+	}
763
+
764
+	e1000_shift_out_eec_bits(hw, NVM_EWDS_OPCODE_MICROWIRE,
765
+	                         (u16)(nvm->opcode_bits + 2));
766
+
767
+	e1000_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));
768
+
769
+release:
770
+	nvm->ops.release(hw);
771
+
772
+out:
773
+	return ret_val;
774
+}
775
+
776
+/**
777
+ *  e1000_read_pba_num_generic - Read device part number
778
+ *  @hw: pointer to the HW structure
779
+ *  @pba_num: pointer to device part number
780
+ *
781
+ *  Reads the product board assembly (PBA) number from the EEPROM and stores
782
+ *  the value in pba_num.
783
+ **/
784
+s32 e1000_read_pba_num_generic(struct e1000_hw *hw, u32 *pba_num)
785
+{
786
+	s32  ret_val;
787
+	u16 nvm_data;
788
+
789
+	DEBUGFUNC("e1000_read_pba_num_generic");
790
+
791
+	ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
792
+	if (ret_val) {
793
+		DEBUGOUT("NVM Read Error\n");
794
+		goto out;
795
+	}
796
+	*pba_num = (u32)(nvm_data << 16);
797
+
798
+	ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
799
+	if (ret_val) {
800
+		DEBUGOUT("NVM Read Error\n");
801
+		goto out;
802
+	}
803
+	*pba_num |= nvm_data;
804
+
805
+out:
806
+	return ret_val;
807
+}
808
+
809
+/**
810
+ *  e1000_read_mac_addr_generic - Read device MAC address
811
+ *  @hw: pointer to the HW structure
812
+ *
813
+ *  Reads the device MAC address from the EEPROM and stores the value.
814
+ *  Since devices with two ports use the same EEPROM, we increment the
815
+ *  last bit in the MAC address for the second port.
816
+ **/
817
+s32 e1000_read_mac_addr_generic(struct e1000_hw *hw)
818
+{
819
+	u32 rar_high;
820
+	u32 rar_low;
821
+	u16 i;
822
+
823
+	rar_high = E1000_READ_REG(hw, E1000_RAH(0));
824
+	rar_low = E1000_READ_REG(hw, E1000_RAL(0));
825
+
826
+	for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
827
+		hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8));
828
+
829
+	for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
830
+		hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8));
831
+
832
+	for (i = 0; i < ETH_ADDR_LEN; i++)
833
+		hw->mac.addr[i] = hw->mac.perm_addr[i];
834
+
835
+	return E1000_SUCCESS;
836
+}
837
+
838
+/**
839
+ *  e1000_validate_nvm_checksum_generic - Validate EEPROM checksum
840
+ *  @hw: pointer to the HW structure
841
+ *
842
+ *  Calculates the EEPROM checksum by reading/adding each word of the EEPROM
843
+ *  and then verifies that the sum of the EEPROM is equal to 0xBABA.
844
+ **/
845
+s32 e1000_validate_nvm_checksum_generic(struct e1000_hw *hw)
846
+{
847
+	s32 ret_val = E1000_SUCCESS;
848
+	u16 checksum = 0;
849
+	u16 i, nvm_data;
850
+
851
+	DEBUGFUNC("e1000_validate_nvm_checksum_generic");
852
+
853
+	for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
854
+		ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
855
+		if (ret_val) {
856
+			DEBUGOUT("NVM Read Error\n");
857
+			goto out;
858
+		}
859
+		checksum += nvm_data;
860
+	}
861
+
862
+	if (checksum != (u16) NVM_SUM) {
863
+		DEBUGOUT("NVM Checksum Invalid\n");
864
+		ret_val = -E1000_ERR_NVM;
865
+		goto out;
866
+	}
867
+
868
+out:
869
+	return ret_val;
870
+}
871
+
872
+/**
873
+ *  e1000_update_nvm_checksum_generic - Update EEPROM checksum
874
+ *  @hw: pointer to the HW structure
875
+ *
876
+ *  Updates the EEPROM checksum by reading/adding each word of the EEPROM
877
+ *  up to the checksum.  Then calculates the EEPROM checksum and writes the
878
+ *  value to the EEPROM.
879
+ **/
880
+s32 e1000_update_nvm_checksum_generic(struct e1000_hw *hw)
881
+{
882
+	s32  ret_val;
883
+	u16 checksum = 0;
884
+	u16 i, nvm_data;
885
+
886
+	DEBUGFUNC("e1000_update_nvm_checksum");
887
+
888
+	for (i = 0; i < NVM_CHECKSUM_REG; i++) {
889
+		ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
890
+		if (ret_val) {
891
+			DEBUGOUT("NVM Read Error while updating checksum.\n");
892
+			goto out;
893
+		}
894
+		checksum += nvm_data;
895
+	}
896
+	checksum = (u16) NVM_SUM - checksum;
897
+	ret_val = hw->nvm.ops.write(hw, NVM_CHECKSUM_REG, 1, &checksum);
898
+	if (ret_val)
899
+		DEBUGOUT("NVM Write Error while updating checksum.\n");
900
+
901
+out:
902
+	return ret_val;
903
+}
904
+
905
+/**
906
+ *  e1000_reload_nvm_generic - Reloads EEPROM
907
+ *  @hw: pointer to the HW structure
908
+ *
909
+ *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
910
+ *  extended control register.
911
+ **/
912
+static void e1000_reload_nvm_generic(struct e1000_hw *hw)
913
+{
914
+	u32 ctrl_ext;
915
+
916
+	DEBUGFUNC("e1000_reload_nvm_generic");
917
+
918
+	usec_delay(10);
919
+	ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
920
+	ctrl_ext |= E1000_CTRL_EXT_EE_RST;
921
+	E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
922
+	E1000_WRITE_FLUSH(hw);
923
+}

+ 63
- 0
src/drivers/net/e1000/e1000_nvm.h Ver fichero

@@ -0,0 +1,63 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_NVM_H_
32
+#define _E1000_NVM_H_
33
+
34
+void e1000_init_nvm_ops_generic(struct e1000_hw *hw);
35
+s32  e1000_null_read_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c);
36
+void e1000_null_nvm_generic(struct e1000_hw *hw);
37
+s32  e1000_null_led_default(struct e1000_hw *hw, u16 *data);
38
+s32  e1000_null_write_nvm(struct e1000_hw *hw, u16 a, u16 b, u16 *c);
39
+s32  e1000_acquire_nvm_generic(struct e1000_hw *hw);
40
+
41
+s32  e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg);
42
+s32  e1000_read_mac_addr_generic(struct e1000_hw *hw);
43
+s32  e1000_read_pba_num_generic(struct e1000_hw *hw, u32 *pba_num);
44
+s32  e1000_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
45
+s32  e1000_read_nvm_microwire(struct e1000_hw *hw, u16 offset,
46
+                              u16 words, u16 *data);
47
+s32  e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words,
48
+                         u16 *data);
49
+s32  e1000_valid_led_default_generic(struct e1000_hw *hw, u16 *data);
50
+s32  e1000_validate_nvm_checksum_generic(struct e1000_hw *hw);
51
+s32  e1000_write_nvm_eewr(struct e1000_hw *hw, u16 offset,
52
+                          u16 words, u16 *data);
53
+s32  e1000_write_nvm_microwire(struct e1000_hw *hw, u16 offset,
54
+                               u16 words, u16 *data);
55
+s32  e1000_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words,
56
+                         u16 *data);
57
+s32  e1000_update_nvm_checksum_generic(struct e1000_hw *hw);
58
+void e1000_stop_nvm(struct e1000_hw *hw);
59
+void e1000_release_nvm_generic(struct e1000_hw *hw);
60
+
61
+#define E1000_STM_OPCODE  0xDB00
62
+
63
+#endif

+ 52
- 77
src/drivers/net/e1000/e1000_osdep.h Ver fichero

@@ -1,7 +1,7 @@
1 1
 /*******************************************************************************
2 2
 
3 3
   Intel PRO/1000 Linux driver
4
-  Copyright(c) 1999 - 2006 Intel Corporation.
4
+  Copyright(c) 1999 - 2008 Intel Corporation.
5 5
 
6 6
   This program is free software; you can redistribute it and/or modify it
7 7
   under the terms and conditions of the GNU General Public License,
@@ -26,118 +26,93 @@
26 26
 
27 27
 *******************************************************************************/
28 28
 
29
-FILE_LICENCE ( GPL2_ONLY );
29
+FILE_LICENCE ( GPL2_OR_LATER );
30 30
 
31
-/* glue for the OS independent part of e1000
31
+/* glue for the OS-dependent part of e1000
32 32
  * includes register access macros
33 33
  */
34 34
 
35 35
 #ifndef _E1000_OSDEP_H_
36 36
 #define _E1000_OSDEP_H_
37 37
 
38
-#include <stdint.h>
39
-#include <stdlib.h>
40
-#include <stdio.h>
41
-#include <gpxe/io.h>
42
-#include <errno.h>
43
-#include <unistd.h>
44
-#include <byteswap.h>
45
-#include <gpxe/pci.h>
46
-#include <gpxe/if_ether.h>
47
-#include <gpxe/ethernet.h>
48
-#include <gpxe/iobuf.h>
49
-#include <gpxe/netdevice.h>
38
+#define u8         unsigned char
39
+#define bool       boolean_t
40
+#define dma_addr_t unsigned long
41
+#define __le16     uint16_t
42
+#define __le32     uint32_t
43
+#define __le64     uint64_t
50 44
 
45
+#define __iomem
46
+
47
+#define ETH_FCS_LEN 4
48
+
49
+typedef int spinlock_t;
51 50
 typedef enum {
52
-#undef FALSE
53
-    FALSE = 0,
54
-#undef TRUE
55
-    TRUE = 1
51
+    false = 0,
52
+    true = 1
56 53
 } boolean_t;
57 54
 
58
-/* Debugging #defines */
55
+#define usec_delay(x) udelay(x)
56
+#define msec_delay(x) mdelay(x)
57
+#define msec_delay_irq(x) mdelay(x)
58
+
59
+#define PCI_COMMAND_REGISTER   PCI_COMMAND
60
+#define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
61
+#define ETH_ADDR_LEN           ETH_ALEN
59 62
 
60
-#if 1
61 63
 #define DEBUGFUNC(F) DBG(F "\n")
62
-#else
63
-#define DEBUGFUNC(F)
64
-#endif
65 64
 
66
-#if 1
67 65
 #define DEBUGOUT(S)             DBG(S)
68 66
 #define DEBUGOUT1(S, A...)      DBG(S, A)
69
-#else
70
-#define DEBUGOUT(S)
71
-#define DEBUGOUT1(S, A...)
72
-#endif
73 67
 
74 68
 #define DEBUGOUT2 DEBUGOUT1
75
-#define DEBUGOUT3 DEBUGOUT1
76
-#define DEBUGOUT7 DEBUGOUT1
69
+#define DEBUGOUT3 DEBUGOUT2
70
+#define DEBUGOUT7 DEBUGOUT3
71
+
72
+#define E1000_REGISTER(a, reg) (((a)->mac.type >= e1000_82543) \
73
+                               ? reg                           \
74
+                               : e1000_translate_register_82542(reg))
77 75
 
78 76
 #define E1000_WRITE_REG(a, reg, value) \
79
-    writel((value), ((a)->hw_addr + \
80
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))
77
+    writel((value), ((a)->hw_addr + E1000_REGISTER(a, reg)))
81 78
 
82
-#define E1000_READ_REG(a, reg) \
83
-    readl((a)->hw_addr + \
84
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))
79
+#define E1000_READ_REG(a, reg) (readl((a)->hw_addr + E1000_REGISTER(a, reg)))
85 80
 
86 81
 #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) \
87
-    writel((value), ((a)->hw_addr + \
88
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
89
-        ((offset) << 2)))
82
+    writel((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 2)))
90 83
 
91
-#define E1000_READ_REG_ARRAY(a, reg, offset) \
92
-    readl((a)->hw_addr + \
93
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
94
-        ((offset) << 2))
84
+#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
85
+    readl((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 2)))
95 86
 
96 87
 #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
97 88
 #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
98 89
 
99
-#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) \
100
-    writew((value), ((a)->hw_addr + \
101
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
102
-        ((offset) << 1)))
90
+#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
91
+    writew((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 1))))
103 92
 
104
-#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) \
105
-    readw((a)->hw_addr + \
106
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
107
-        ((offset) << 1))
93
+#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
94
+    readw((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 1)))
108 95
 
109
-#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) \
110
-    writeb((value), ((a)->hw_addr + \
111
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
112
-        (offset)))
96
+#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
97
+    writeb((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + (offset))))
113 98
 
114
-#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) \
115
-    readb((a)->hw_addr + \
116
-        (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
117
-        (offset))
99
+#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
100
+    readb((a)->hw_addr + E1000_REGISTER(a, reg) + (offset)))
118 101
 
119
-#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
102
+#define E1000_WRITE_REG_IO(a, reg, offset) do { \
103
+    outl(reg, ((a)->io_base));                  \
104
+    outl(offset, ((a)->io_base + 4));      } while(0)
120 105
 
121
-#define E1000_WRITE_ICH_FLASH_REG(a, reg, value) \
122
-    writel((value), ((a)->flash_address + reg))
106
+#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, E1000_STATUS)
123 107
 
124
-#define E1000_READ_ICH_FLASH_REG(a, reg) \
125
-    readl((a)->flash_address + reg)
108
+#define E1000_WRITE_FLASH_REG(a, reg, value) ( \
109
+    writel((value), ((a)->flash_address + reg)))
126 110
 
127
-#define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) \
128
-    writew((value), ((a)->flash_address + reg))
111
+#define E1000_WRITE_FLASH_REG16(a, reg, value) ( \
112
+    writew((value), ((a)->flash_address + reg)))
129 113
 
130
-#define E1000_READ_ICH_FLASH_REG16(a, reg) \
131
-    readw((a)->flash_address + reg)
114
+#define E1000_READ_FLASH_REG(a, reg) (readl((a)->flash_address + reg))
132 115
 
133
-#define	msleep(n) 	mdelay(n)
116
+#define E1000_READ_FLASH_REG16(a, reg) (readw((a)->flash_address + reg))
134 117
 
135 118
 #endif /* _E1000_OSDEP_H_ */
136
-
137
-/*
138
- * Local variables:
139
- *  c-basic-offset: 8
140
- *  c-indent-level: 8
141
- *  tab-width: 8
142
- * End:
143
- */

+ 2308
- 0
src/drivers/net/e1000/e1000_phy.c
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 171
- 0
src/drivers/net/e1000/e1000_phy.h Ver fichero

@@ -0,0 +1,171 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_PHY_H_
32
+#define _E1000_PHY_H_
33
+
34
+void e1000_init_phy_ops_generic(struct e1000_hw *hw);
35
+s32  e1000_null_read_reg(struct e1000_hw *hw, u32 offset, u16 *data);
36
+void e1000_null_phy_generic(struct e1000_hw *hw);
37
+s32  e1000_null_lplu_state(struct e1000_hw *hw, bool active);
38
+s32  e1000_null_write_reg(struct e1000_hw *hw, u32 offset, u16 data);
39
+s32  e1000_check_downshift_generic(struct e1000_hw *hw);
40
+s32  e1000_check_polarity_m88(struct e1000_hw *hw);
41
+s32  e1000_check_polarity_igp(struct e1000_hw *hw);
42
+s32  e1000_check_polarity_ife(struct e1000_hw *hw);
43
+s32  e1000_check_reset_block_generic(struct e1000_hw *hw);
44
+s32  e1000_copper_link_autoneg(struct e1000_hw *hw);
45
+s32  e1000_copper_link_setup_igp(struct e1000_hw *hw);
46
+s32  e1000_copper_link_setup_m88(struct e1000_hw *hw);
47
+#if 0
48
+s32  e1000_phy_force_speed_duplex_igp(struct e1000_hw *hw);
49
+s32  e1000_phy_force_speed_duplex_m88(struct e1000_hw *hw);
50
+s32  e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw);
51
+#endif
52
+#if 0
53
+s32  e1000_get_cable_length_m88(struct e1000_hw *hw);
54
+s32  e1000_get_cable_length_igp_2(struct e1000_hw *hw);
55
+#endif
56
+s32  e1000_get_cfg_done_generic(struct e1000_hw *hw);
57
+s32  e1000_get_phy_id(struct e1000_hw *hw);
58
+s32  e1000_get_phy_info_igp(struct e1000_hw *hw);
59
+s32  e1000_get_phy_info_m88(struct e1000_hw *hw);
60
+s32  e1000_phy_sw_reset_generic(struct e1000_hw *hw);
61
+#if 0
62
+void e1000_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl);
63
+#endif
64
+s32  e1000_phy_hw_reset_generic(struct e1000_hw *hw);
65
+s32  e1000_phy_reset_dsp_generic(struct e1000_hw *hw);
66
+s32  e1000_phy_setup_autoneg(struct e1000_hw *hw);
67
+s32  e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data);
68
+s32  e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data);
69
+s32  e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data);
70
+s32  e1000_set_d3_lplu_state_generic(struct e1000_hw *hw, bool active);
71
+s32  e1000_setup_copper_link_generic(struct e1000_hw *hw);
72
+s32  e1000_wait_autoneg_generic(struct e1000_hw *hw);
73
+s32  e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data);
74
+s32  e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data);
75
+s32  e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data);
76
+s32  e1000_phy_reset_dsp(struct e1000_hw *hw);
77
+s32  e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
78
+                                u32 usec_interval, bool *success);
79
+s32  e1000_phy_init_script_igp3(struct e1000_hw *hw);
80
+enum e1000_phy_type e1000_get_phy_type_from_id(u32 phy_id);
81
+s32  e1000_determine_phy_address(struct e1000_hw *hw);
82
+void e1000_power_up_phy_copper(struct e1000_hw *hw);
83
+void e1000_power_down_phy_copper(struct e1000_hw *hw);
84
+s32  e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data);
85
+s32  e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data);
86
+
87
+#define E1000_MAX_PHY_ADDR                4
88
+
89
+/* IGP01E1000 Specific Registers */
90
+#define IGP01E1000_PHY_PORT_CONFIG        0x10 /* Port Config */
91
+#define IGP01E1000_PHY_PORT_STATUS        0x11 /* Status */
92
+#define IGP01E1000_PHY_PORT_CTRL          0x12 /* Control */
93
+#define IGP01E1000_PHY_LINK_HEALTH        0x13 /* PHY Link Health */
94
+#define IGP01E1000_GMII_FIFO              0x14 /* GMII FIFO */
95
+#define IGP01E1000_PHY_CHANNEL_QUALITY    0x15 /* PHY Channel Quality */
96
+#define IGP02E1000_PHY_POWER_MGMT         0x19 /* Power Management */
97
+#define IGP01E1000_PHY_PAGE_SELECT        0x1F /* Page Select */
98
+#define BM_PHY_PAGE_SELECT                22   /* Page Select for BM */
99
+#define IGP_PAGE_SHIFT                    5
100
+#define PHY_REG_MASK                      0x1F
101
+
102
+#define IGP01E1000_PHY_PCS_INIT_REG       0x00B4
103
+#define IGP01E1000_PHY_POLARITY_MASK      0x0078
104
+
105
+#define IGP01E1000_PSCR_AUTO_MDIX         0x1000
106
+#define IGP01E1000_PSCR_FORCE_MDI_MDIX    0x2000 /* 0=MDI, 1=MDIX */
107
+
108
+#define IGP01E1000_PSCFR_SMART_SPEED      0x0080
109
+
110
+/* Enable flexible speed on link-up */
111
+#define IGP01E1000_GMII_FLEX_SPD          0x0010
112
+#define IGP01E1000_GMII_SPD               0x0020 /* Enable SPD */
113
+
114
+#define IGP02E1000_PM_SPD                 0x0001 /* Smart Power Down */
115
+#define IGP02E1000_PM_D0_LPLU             0x0002 /* For D0a states */
116
+#define IGP02E1000_PM_D3_LPLU             0x0004 /* For all other states */
117
+
118
+#define IGP01E1000_PLHR_SS_DOWNGRADE      0x8000
119
+
120
+#define IGP01E1000_PSSR_POLARITY_REVERSED 0x0002
121
+#define IGP01E1000_PSSR_MDIX              0x0800
122
+#define IGP01E1000_PSSR_SPEED_MASK        0xC000
123
+#define IGP01E1000_PSSR_SPEED_1000MBPS    0xC000
124
+
125
+#define IGP02E1000_PHY_CHANNEL_NUM        4
126
+#define IGP02E1000_PHY_AGC_A              0x11B1
127
+#define IGP02E1000_PHY_AGC_B              0x12B1
128
+#define IGP02E1000_PHY_AGC_C              0x14B1
129
+#define IGP02E1000_PHY_AGC_D              0x18B1
130
+
131
+#define IGP02E1000_AGC_LENGTH_SHIFT       9   /* Course - 15:13, Fine - 12:9 */
132
+#define IGP02E1000_AGC_LENGTH_MASK        0x7F
133
+#define IGP02E1000_AGC_RANGE              15
134
+
135
+#define IGP03E1000_PHY_MISC_CTRL          0x1B
136
+#define IGP03E1000_PHY_MISC_DUPLEX_MANUAL_SET  0x1000 /* Manually Set Duplex */
137
+
138
+#define E1000_CABLE_LENGTH_UNDEFINED      0xFF
139
+
140
+#define E1000_KMRNCTRLSTA_OFFSET          0x001F0000
141
+#define E1000_KMRNCTRLSTA_OFFSET_SHIFT    16
142
+#define E1000_KMRNCTRLSTA_REN             0x00200000
143
+#define E1000_KMRNCTRLSTA_DIAG_OFFSET     0x3    /* Kumeran Diagnostic */
144
+#define E1000_KMRNCTRLSTA_TIMEOUTS        0x4    /* Kumeran Timeouts */
145
+#define E1000_KMRNCTRLSTA_INBAND_PARAM    0x9    /* Kumeran InBand Parameters */
146
+#define E1000_KMRNCTRLSTA_DIAG_NELPBK     0x1000 /* Nearend Loopback mode */
147
+
148
+#define IFE_PHY_EXTENDED_STATUS_CONTROL 0x10
149
+#define IFE_PHY_SPECIAL_CONTROL     0x11 /* 100BaseTx PHY Special Control */
150
+#define IFE_PHY_SPECIAL_CONTROL_LED 0x1B /* PHY Special and LED Control */
151
+#define IFE_PHY_MDIX_CONTROL        0x1C /* MDI/MDI-X Control */
152
+
153
+/* IFE PHY Extended Status Control */
154
+#define IFE_PESC_POLARITY_REVERSED    0x0100
155
+
156
+/* IFE PHY Special Control */
157
+#define IFE_PSC_AUTO_POLARITY_DISABLE      0x0010
158
+#define IFE_PSC_FORCE_POLARITY             0x0020
159
+#define IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN 0x0100
160
+
161
+/* IFE PHY Special Control and LED Control */
162
+#define IFE_PSCL_PROBE_MODE            0x0020
163
+#define IFE_PSCL_PROBE_LEDS_OFF        0x0006 /* Force LEDs 0 and 2 off */
164
+#define IFE_PSCL_PROBE_LEDS_ON         0x0007 /* Force LEDs 0 and 2 on */
165
+
166
+/* IFE PHY MDIX Control */
167
+#define IFE_PMC_MDIX_STATUS      0x0020 /* 1=MDI-X, 0=MDI */
168
+#define IFE_PMC_FORCE_MDIX       0x0040 /* 1=force MDI-X, 0=force MDI */
169
+#define IFE_PMC_AUTO_MDIX        0x0080 /* 1=enable auto MDI/MDI-X, 0=disable */
170
+
171
+#endif

+ 329
- 0
src/drivers/net/e1000/e1000_regs.h Ver fichero

@@ -0,0 +1,329 @@
1
+/*******************************************************************************
2
+
3
+  Intel PRO/1000 Linux driver
4
+  Copyright(c) 1999 - 2008 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
+FILE_LICENCE ( GPL2_OR_LATER );
30
+
31
+#ifndef _E1000_REGS_H_
32
+#define _E1000_REGS_H_
33
+
34
+#define E1000_CTRL     0x00000  /* Device Control - RW */
35
+#define E1000_CTRL_DUP 0x00004  /* Device Control Duplicate (Shadow) - RW */
36
+#define E1000_STATUS   0x00008  /* Device Status - RO */
37
+#define E1000_EECD     0x00010  /* EEPROM/Flash Control - RW */
38
+#define E1000_EERD     0x00014  /* EEPROM Read - RW */
39
+#define E1000_CTRL_EXT 0x00018  /* Extended Device Control - RW */
40
+#define E1000_FLA      0x0001C  /* Flash Access - RW */
41
+#define E1000_MDIC     0x00020  /* MDI Control - RW */
42
+#define E1000_SCTL     0x00024  /* SerDes Control - RW */
43
+#define E1000_FCAL     0x00028  /* Flow Control Address Low - RW */
44
+#define E1000_FCAH     0x0002C  /* Flow Control Address High -RW */
45
+#define E1000_FEXT     0x0002C  /* Future Extended - RW */
46
+#define E1000_FEXTNVM  0x00028  /* Future Extended NVM - RW */
47
+#define E1000_FCT      0x00030  /* Flow Control Type - RW */
48
+#define E1000_CONNSW   0x00034  /* Copper/Fiber switch control - RW */
49
+#define E1000_VET      0x00038  /* VLAN Ether Type - RW */
50
+#define E1000_ICR      0x000C0  /* Interrupt Cause Read - R/clr */
51
+#define E1000_ITR      0x000C4  /* Interrupt Throttling Rate - RW */
52
+#define E1000_ICS      0x000C8  /* Interrupt Cause Set - WO */
53
+#define E1000_IMS      0x000D0  /* Interrupt Mask Set - RW */
54
+#define E1000_IMC      0x000D8  /* Interrupt Mask Clear - WO */
55
+#define E1000_IAM      0x000E0  /* Interrupt Acknowledge Auto Mask */
56
+#define E1000_RCTL     0x00100  /* Rx Control - RW */
57
+#define E1000_FCTTV    0x00170  /* Flow Control Transmit Timer Value - RW */
58
+#define E1000_TXCW     0x00178  /* Tx Configuration Word - RW */
59
+#define E1000_RXCW     0x00180  /* Rx Configuration Word - RO */
60
+#define E1000_TCTL     0x00400  /* Tx Control - RW */
61
+#define E1000_TCTL_EXT 0x00404  /* Extended Tx Control - RW */
62
+#define E1000_TIPG     0x00410  /* Tx Inter-packet gap -RW */
63
+#define E1000_TBT      0x00448  /* Tx Burst Timer - RW */
64
+#define E1000_AIT      0x00458  /* Adaptive Interframe Spacing Throttle - RW */
65
+#define E1000_LEDCTL   0x00E00  /* LED Control - RW */
66
+#define E1000_EXTCNF_CTRL  0x00F00  /* Extended Configuration Control */
67
+#define E1000_EXTCNF_SIZE  0x00F08  /* Extended Configuration Size */
68
+#define E1000_PHY_CTRL     0x00F10  /* PHY Control Register in CSR */
69
+#define E1000_PBA      0x01000  /* Packet Buffer Allocation - RW */
70
+#define E1000_PBS      0x01008  /* Packet Buffer Size */
71
+#define E1000_EEMNGCTL 0x01010  /* MNG EEprom Control */
72
+#define E1000_EEARBC   0x01024  /* EEPROM Auto Read Bus Control */
73
+#define E1000_FLASHT   0x01028  /* FLASH Timer Register */
74
+#define E1000_EEWR     0x0102C  /* EEPROM Write Register - RW */
75
+#define E1000_FLSWCTL  0x01030  /* FLASH control register */
76
+#define E1000_FLSWDATA 0x01034  /* FLASH data register */
77
+#define E1000_FLSWCNT  0x01038  /* FLASH Access Counter */
78
+#define E1000_FLOP     0x0103C  /* FLASH Opcode Register */
79
+#define E1000_I2CCMD   0x01028  /* SFPI2C Command Register - RW */
80
+#define E1000_I2CPARAMS 0x0102C /* SFPI2C Parameters Register - RW */
81
+#define E1000_WDSTP    0x01040  /* Watchdog Setup - RW */
82
+#define E1000_SWDSTS   0x01044  /* SW Device Status - RW */
83
+#define E1000_FRTIMER  0x01048  /* Free Running Timer - RW */
84
+#define E1000_ERT      0x02008  /* Early Rx Threshold - RW */
85
+#define E1000_FCRTL    0x02160  /* Flow Control Receive Threshold Low - RW */
86
+#define E1000_FCRTH    0x02168  /* Flow Control Receive Threshold High - RW */
87
+#define E1000_PSRCTL   0x02170  /* Packet Split Receive Control - RW */
88
+#define E1000_RDFPCQ(_n)  (0x02430 + (0x4 * (_n)))
89
+#define E1000_PBRTH    0x02458  /* PB Rx Arbitration Threshold - RW */
90
+#define E1000_FCRTV    0x02460  /* Flow Control Refresh Timer Value - RW */
91
+/* Split and Replication Rx Control - RW */
92
+#define E1000_RDPUMB   0x025CC  /* DMA Rx Descriptor uC Mailbox - RW */
93
+#define E1000_RDPUAD   0x025D0  /* DMA Rx Descriptor uC Addr Command - RW */
94
+#define E1000_RDPUWD   0x025D4  /* DMA Rx Descriptor uC Data Write - RW */
95
+#define E1000_RDPURD   0x025D8  /* DMA Rx Descriptor uC Data Read - RW */
96
+#define E1000_RDPUCTL  0x025DC  /* DMA Rx Descriptor uC Control - RW */
97
+#define E1000_RXCTL(_n)   (0x0C014 + (0x40 * (_n)))
98
+#define E1000_RQDPC(_n)   (0x0C030 + (0x40 * (_n)))
99
+#define E1000_RDTR     0x02820  /* Rx Delay Timer - RW */
100
+#define E1000_RADV     0x0282C  /* Rx Interrupt Absolute Delay Timer - RW */
101
+/*
102
+ * Convenience macros
103
+ *
104
+ * Note: "_n" is the queue number of the register to be written to.
105
+ *
106
+ * Example usage:
107
+ * E1000_RDBAL_REG(current_rx_queue)
108
+ */
109
+#define E1000_RDBAL(_n)      ((_n) < 4 ? (0x02800 + ((_n) * 0x100)) : \
110
+                                         (0x0C000 + ((_n) * 0x40)))
111
+#define E1000_RDBAH(_n)      ((_n) < 4 ? (0x02804 + ((_n) * 0x100)) : \
112
+                                         (0x0C004 + ((_n) * 0x40)))
113
+#define E1000_RDLEN(_n)      ((_n) < 4 ? (0x02808 + ((_n) * 0x100)) : \
114
+                                         (0x0C008 + ((_n) * 0x40)))
115
+#define E1000_SRRCTL(_n)     ((_n) < 4 ? (0x0280C + ((_n) * 0x100)) : \
116
+                                         (0x0C00C + ((_n) * 0x40)))
117
+#define E1000_RDH(_n)        ((_n) < 4 ? (0x02810 + ((_n) * 0x100)) : \
118
+                                         (0x0C010 + ((_n) * 0x40)))
119
+#define E1000_RDT(_n)        ((_n) < 4 ? (0x02818 + ((_n) * 0x100)) : \
120
+                                         (0x0C018 + ((_n) * 0x40)))
121
+#define E1000_RXDCTL(_n)     ((_n) < 4 ? (0x02828 + ((_n) * 0x100)) : \
122
+                                         (0x0C028 + ((_n) * 0x40)))
123
+#define E1000_TDBAL(_n)      ((_n) < 4 ? (0x03800 + ((_n) * 0x100)) : \
124
+                                         (0x0E000 + ((_n) * 0x40)))
125
+#define E1000_TDBAH(_n)      ((_n) < 4 ? (0x03804 + ((_n) * 0x100)) : \
126
+                                         (0x0E004 + ((_n) * 0x40)))
127
+#define E1000_TDLEN(_n)      ((_n) < 4 ? (0x03808 + ((_n) * 0x100)) : \
128
+                                         (0x0E008 + ((_n) * 0x40)))
129
+#define E1000_TDH(_n)        ((_n) < 4 ? (0x03810 + ((_n) * 0x100)) : \
130
+                                         (0x0E010 + ((_n) * 0x40)))
131
+#define E1000_TDT(_n)        ((_n) < 4 ? (0x03818 + ((_n) * 0x100)) : \
132
+                                         (0x0E018 + ((_n) * 0x40)))
133
+#define E1000_TXDCTL(_n)     ((_n) < 4 ? (0x03828 + ((_n) * 0x100)) : \
134
+                                         (0x0E028 + ((_n) * 0x40)))
135
+#define E1000_TARC(_n)       (0x03840 + (_n << 8))
136
+#define E1000_DCA_TXCTRL(_n) (0x03814 + (_n << 8))
137
+#define E1000_DCA_RXCTRL(_n) (0x02814 + (_n << 8))
138
+#define E1000_TDWBAL(_n)     ((_n) < 4 ? (0x03838 + ((_n) * 0x100)) : \
139
+                                         (0x0E038 + ((_n) * 0x40)))
140
+#define E1000_TDWBAH(_n)     ((_n) < 4 ? (0x0383C + ((_n) * 0x100)) : \
141
+                                         (0x0E03C + ((_n) * 0x40)))
142
+#define E1000_RSRPD    0x02C00  /* Rx Small Packet Detect - RW */
143
+#define E1000_RAID     0x02C08  /* Receive Ack Interrupt Delay - RW */
144
+#define E1000_TXDMAC   0x03000  /* Tx DMA Control - RW */
145
+#define E1000_KABGTXD  0x03004  /* AFE Band Gap Transmit Ref Data */
146
+#define E1000_PSRTYPE(_i)       (0x05480 + ((_i) * 4))
147
+#define E1000_RAL(_i)  (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \
148
+                                       (0x054E0 + ((_i - 16) * 8)))
149
+#define E1000_RAH(_i)  (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \
150
+                                       (0x054E4 + ((_i - 16) * 8)))
151
+#define E1000_IP4AT_REG(_i)     (0x05840 + ((_i) * 8))
152
+#define E1000_IP6AT_REG(_i)     (0x05880 + ((_i) * 4))
153
+#define E1000_WUPM_REG(_i)      (0x05A00 + ((_i) * 4))
154
+#define E1000_FFMT_REG(_i)      (0x09000 + ((_i) * 8))
155
+#define E1000_FFVT_REG(_i)      (0x09800 + ((_i) * 8))
156
+#define E1000_FFLT_REG(_i)      (0x05F00 + ((_i) * 8))
157
+#define E1000_TDFH     0x03410  /* Tx Data FIFO Head - RW */
158
+#define E1000_TDFT     0x03418  /* Tx Data FIFO Tail - RW */
159
+#define E1000_TDFHS    0x03420  /* Tx Data FIFO Head Saved - RW */
160
+#define E1000_TDFTS    0x03428  /* Tx Data FIFO Tail Saved - RW */
161
+#define E1000_TDFPC    0x03430  /* Tx Data FIFO Packet Count - RW */
162
+#define E1000_TDPUMB   0x0357C  /* DMA Tx Descriptor uC Mail Box - RW */
163
+#define E1000_TDPUAD   0x03580  /* DMA Tx Descriptor uC Addr Command - RW */
164
+#define E1000_TDPUWD   0x03584  /* DMA Tx Descriptor uC Data Write - RW */
165
+#define E1000_TDPURD   0x03588  /* DMA Tx Descriptor uC Data  Read  - RW */
166
+#define E1000_TDPUCTL  0x0358C  /* DMA Tx Descriptor uC Control - RW */
167
+#define E1000_DTXCTL   0x03590  /* DMA Tx Control - RW */
168
+#define E1000_TIDV     0x03820  /* Tx Interrupt Delay Value - RW */
169
+#define E1000_TADV     0x0382C  /* Tx Interrupt Absolute Delay Val - RW */
170
+#define E1000_TSPMT    0x03830  /* TCP Segmentation PAD & Min Threshold - RW */
171
+#define E1000_CRCERRS  0x04000  /* CRC Error Count - R/clr */
172
+#define E1000_ALGNERRC 0x04004  /* Alignment Error Count - R/clr */
173
+#define E1000_SYMERRS  0x04008  /* Symbol Error Count - R/clr */
174
+#define E1000_RXERRC   0x0400C  /* Receive Error Count - R/clr */
175
+#define E1000_MPC      0x04010  /* Missed Packet Count - R/clr */
176
+#define E1000_SCC      0x04014  /* Single Collision Count - R/clr */
177
+#define E1000_ECOL     0x04018  /* Excessive Collision Count - R/clr */
178
+#define E1000_MCC      0x0401C  /* Multiple Collision Count - R/clr */
179
+#define E1000_LATECOL  0x04020  /* Late Collision Count - R/clr */
180
+#define E1000_COLC     0x04028  /* Collision Count - R/clr */
181
+#define E1000_DC       0x04030  /* Defer Count - R/clr */
182
+#define E1000_TNCRS    0x04034  /* Tx-No CRS - R/clr */
183
+#define E1000_SEC      0x04038  /* Sequence Error Count - R/clr */
184
+#define E1000_CEXTERR  0x0403C  /* Carrier Extension Error Count - R/clr */
185
+#define E1000_RLEC     0x04040  /* Receive Length Error Count - R/clr */
186
+#define E1000_XONRXC   0x04048  /* XON Rx Count - R/clr */
187
+#define E1000_XONTXC   0x0404C  /* XON Tx Count - R/clr */
188
+#define E1000_XOFFRXC  0x04050  /* XOFF Rx Count - R/clr */
189
+#define E1000_XOFFTXC  0x04054  /* XOFF Tx Count - R/clr */
190
+#define E1000_FCRUC    0x04058  /* Flow Control Rx Unsupported Count- R/clr */
191
+#define E1000_PRC64    0x0405C  /* Packets Rx (64 bytes) - R/clr */
192
+#define E1000_PRC127   0x04060  /* Packets Rx (65-127 bytes) - R/clr */
193
+#define E1000_PRC255   0x04064  /* Packets Rx (128-255 bytes) - R/clr */
194
+#define E1000_PRC511   0x04068  /* Packets Rx (255-511 bytes) - R/clr */
195
+#define E1000_PRC1023  0x0406C  /* Packets Rx (512-1023 bytes) - R/clr */
196
+#define E1000_PRC1522  0x04070  /* Packets Rx (1024-1522 bytes) - R/clr */
197
+#define E1000_GPRC     0x04074  /* Good Packets Rx Count - R/clr */
198
+#define E1000_BPRC     0x04078  /* Broadcast Packets Rx Count - R/clr */
199
+#define E1000_MPRC     0x0407C  /* Multicast Packets Rx Count - R/clr */
200
+#define E1000_GPTC     0x04080  /* Good Packets Tx Count - R/clr */
201
+#define E1000_GORCL    0x04088  /* Good Octets Rx Count Low - R/clr */
202
+#define E1000_GORCH    0x0408C  /* Good Octets Rx Count High - R/clr */
203
+#define E1000_GOTCL    0x04090  /* Good Octets Tx Count Low - R/clr */
204
+#define E1000_GOTCH    0x04094  /* Good Octets Tx Count High - R/clr */
205
+#define E1000_RNBC     0x040A0  /* Rx No Buffers Count - R/clr */
206
+#define E1000_RUC      0x040A4  /* Rx Undersize Count - R/clr */
207
+#define E1000_RFC      0x040A8  /* Rx Fragment Count - R/clr */
208
+#define E1000_ROC      0x040AC  /* Rx Oversize Count - R/clr */
209
+#define E1000_RJC      0x040B0  /* Rx Jabber Count - R/clr */
210
+#define E1000_MGTPRC   0x040B4  /* Management Packets Rx Count - R/clr */
211
+#define E1000_MGTPDC   0x040B8  /* Management Packets Dropped Count - R/clr */
212
+#define E1000_MGTPTC   0x040BC  /* Management Packets Tx Count - R/clr */
213
+#define E1000_TORL     0x040C0  /* Total Octets Rx Low - R/clr */
214
+#define E1000_TORH     0x040C4  /* Total Octets Rx High - R/clr */
215
+#define E1000_TOTL     0x040C8  /* Total Octets Tx Low - R/clr */
216
+#define E1000_TOTH     0x040CC  /* Total Octets Tx High - R/clr */
217
+#define E1000_TPR      0x040D0  /* Total Packets Rx - R/clr */
218
+#define E1000_TPT      0x040D4  /* Total Packets Tx - R/clr */
219
+#define E1000_PTC64    0x040D8  /* Packets Tx (64 bytes) - R/clr */
220
+#define E1000_PTC127   0x040DC  /* Packets Tx (65-127 bytes) - R/clr */
221
+#define E1000_PTC255   0x040E0  /* Packets Tx (128-255 bytes) - R/clr */
222
+#define E1000_PTC511   0x040E4  /* Packets Tx (256-511 bytes) - R/clr */
223
+#define E1000_PTC1023  0x040E8  /* Packets Tx (512-1023 bytes) - R/clr */
224
+#define E1000_PTC1522  0x040EC  /* Packets Tx (1024-1522 Bytes) - R/clr */
225
+#define E1000_MPTC     0x040F0  /* Multicast Packets Tx Count - R/clr */
226
+#define E1000_BPTC     0x040F4  /* Broadcast Packets Tx Count - R/clr */
227
+#define E1000_TSCTC    0x040F8  /* TCP Segmentation Context Tx - R/clr */
228
+#define E1000_TSCTFC   0x040FC  /* TCP Segmentation Context Tx Fail - R/clr */
229
+#define E1000_IAC      0x04100  /* Interrupt Assertion Count */
230
+#define E1000_ICRXPTC  0x04104  /* Interrupt Cause Rx Pkt Timer Expire Count */
231
+#define E1000_ICRXATC  0x04108  /* Interrupt Cause Rx Abs Timer Expire Count */
232
+#define E1000_ICTXPTC  0x0410C  /* Interrupt Cause Tx Pkt Timer Expire Count */
233
+#define E1000_ICTXATC  0x04110  /* Interrupt Cause Tx Abs Timer Expire Count */
234
+#define E1000_ICTXQEC  0x04118  /* Interrupt Cause Tx Queue Empty Count */
235
+#define E1000_ICTXQMTC 0x0411C  /* Interrupt Cause Tx Queue Min Thresh Count */
236
+#define E1000_ICRXDMTC 0x04120  /* Interrupt Cause Rx Desc Min Thresh Count */
237
+#define E1000_ICRXOC   0x04124  /* Interrupt Cause Receiver Overrun Count */
238
+
239
+#define E1000_PCS_CFG0    0x04200  /* PCS Configuration 0 - RW */
240
+#define E1000_PCS_LCTL    0x04208  /* PCS Link Control - RW */
241
+#define E1000_PCS_LSTAT   0x0420C  /* PCS Link Status - RO */
242
+#define E1000_CBTMPC      0x0402C  /* Circuit Breaker Tx Packet Count */
243
+#define E1000_HTDPMC      0x0403C  /* Host Transmit Discarded Packets */
244
+#define E1000_CBRDPC      0x04044  /* Circuit Breaker Rx Dropped Count */
245
+#define E1000_CBRMPC      0x040FC  /* Circuit Breaker Rx Packet Count */
246
+#define E1000_RPTHC       0x04104  /* Rx Packets To Host */
247
+#define E1000_HGPTC       0x04118  /* Host Good Packets Tx Count */
248
+#define E1000_HTCBDPC     0x04124  /* Host Tx Circuit Breaker Dropped Count */
249
+#define E1000_HGORCL      0x04128  /* Host Good Octets Received Count Low */
250
+#define E1000_HGORCH      0x0412C  /* Host Good Octets Received Count High */
251
+#define E1000_HGOTCL      0x04130  /* Host Good Octets Transmit Count Low */
252
+#define E1000_HGOTCH      0x04134  /* Host Good Octets Transmit Count High */
253
+#define E1000_LENERRS     0x04138  /* Length Errors Count */
254
+#define E1000_SCVPC       0x04228  /* SerDes/SGMII Code Violation Pkt Count */
255
+#define E1000_HRMPC       0x0A018  /* Header Redirection Missed Packet Count */
256
+#define E1000_PCS_ANADV   0x04218  /* AN advertisement - RW */
257
+#define E1000_PCS_LPAB    0x0421C  /* Link Partner Ability - RW */
258
+#define E1000_PCS_NPTX    0x04220  /* AN Next Page Transmit - RW */
259
+#define E1000_PCS_LPABNP  0x04224  /* Link Partner Ability Next Page - RW */
260
+#define E1000_1GSTAT_RCV  0x04228  /* 1GSTAT Code Violation Packet Count - RW */
261
+#define E1000_RXCSUM   0x05000  /* Rx Checksum Control - RW */
262
+#define E1000_RLPML    0x05004  /* Rx Long Packet Max Length */
263
+#define E1000_RFCTL    0x05008  /* Receive Filter Control*/
264
+#define E1000_MTA      0x05200  /* Multicast Table Array - RW Array */
265
+#define E1000_RA       0x05400  /* Receive Address - RW Array */
266
+#define E1000_VFTA     0x05600  /* VLAN Filter Table Array - RW Array */
267
+#define E1000_VT_CTL   0x0581C  /* VMDq Control - RW */
268
+#define E1000_VFQA0    0x0B000  /* VLAN Filter Queue Array 0 - RW Array */
269
+#define E1000_VFQA1    0x0B200  /* VLAN Filter Queue Array 1 - RW Array */
270
+#define E1000_WUC      0x05800  /* Wakeup Control - RW */
271
+#define E1000_WUFC     0x05808  /* Wakeup Filter Control - RW */
272
+#define E1000_WUS      0x05810  /* Wakeup Status - RO */
273
+#define E1000_MANC     0x05820  /* Management Control - RW */
274
+#define E1000_IPAV     0x05838  /* IP Address Valid - RW */
275
+#define E1000_IP4AT    0x05840  /* IPv4 Address Table - RW Array */
276
+#define E1000_IP6AT    0x05880  /* IPv6 Address Table - RW Array */
277
+#define E1000_WUPL     0x05900  /* Wakeup Packet Length - RW */
278
+#define E1000_WUPM     0x05A00  /* Wakeup Packet Memory - RO A */
279
+#define E1000_PBACL    0x05B68  /* MSIx PBA Clear - Read/Write 1's to clear */
280
+#define E1000_FFLT     0x05F00  /* Flexible Filter Length Table - RW Array */
281
+#define E1000_HOST_IF  0x08800  /* Host Interface */
282
+#define E1000_FFMT     0x09000  /* Flexible Filter Mask Table - RW Array */
283
+#define E1000_FFVT     0x09800  /* Flexible Filter Value Table - RW Array */
284
+
285
+#define E1000_KMRNCTRLSTA 0x00034 /* MAC-PHY interface - RW */
286
+#define E1000_MDPHYA      0x0003C /* PHY address - RW */
287
+#define E1000_MANC2H      0x05860 /* Management Control To Host - RW */
288
+#define E1000_SW_FW_SYNC  0x05B5C /* Software-Firmware Synchronization - RW */
289
+#define E1000_CCMCTL      0x05B48 /* CCM Control Register */
290
+#define E1000_GIOCTL      0x05B44 /* GIO Analog Control Register */
291
+#define E1000_SCCTL       0x05B4C /* PCIc PLL Configuration Register */
292
+#define E1000_GCR         0x05B00 /* PCI-Ex Control */
293
+#define E1000_GCR2        0x05B64 /* PCI-Ex Control #2 */
294
+#define E1000_GSCL_1    0x05B10 /* PCI-Ex Statistic Control #1 */
295
+#define E1000_GSCL_2    0x05B14 /* PCI-Ex Statistic Control #2 */
296
+#define E1000_GSCL_3    0x05B18 /* PCI-Ex Statistic Control #3 */
297
+#define E1000_GSCL_4    0x05B1C /* PCI-Ex Statistic Control #4 */
298
+#define E1000_FACTPS    0x05B30 /* Function Active and Power State to MNG */
299
+#define E1000_SWSM      0x05B50 /* SW Semaphore */
300
+#define E1000_FWSM      0x05B54 /* FW Semaphore */
301
+#define E1000_SWSM2     0x05B58 /* Driver-only SW semaphore (not used by BOOT agents) */
302
+#define E1000_DCA_ID    0x05B70 /* DCA Requester ID Information - RO */
303
+#define E1000_DCA_CTRL  0x05B74 /* DCA Control - RW */
304
+#define E1000_FFLT_DBG  0x05F04 /* Debug Register */
305
+#define E1000_HICR      0x08F00 /* Host Interface Control */
306
+
307
+/* RSS registers */
308
+#define E1000_CPUVEC    0x02C10 /* CPU Vector Register - RW */
309
+#define E1000_MRQC      0x05818 /* Multiple Receive Control - RW */
310
+#define E1000_IMIR(_i)      (0x05A80 + ((_i) * 4))  /* Immediate Interrupt */
311
+#define E1000_IMIREXT(_i)   (0x05AA0 + ((_i) * 4))  /* Immediate Interrupt Ext*/
312
+#define E1000_IMIRVP    0x05AC0 /* Immediate Interrupt Rx VLAN Priority - RW */
313
+#define E1000_MSIXBM(_i)    (0x01600 + ((_i) * 4)) /* MSI-X Allocation Register
314
+                                                    * (_i) - RW */
315
+#define E1000_MSIXTADD(_i)  (0x0C000 + ((_i) * 0x10)) /* MSI-X Table entry addr
316
+                                                       * low reg - RW */
317
+#define E1000_MSIXTUADD(_i) (0x0C004 + ((_i) * 0x10)) /* MSI-X Table entry addr
318
+                                                       * upper reg - RW */
319
+#define E1000_MSIXTMSG(_i)  (0x0C008 + ((_i) * 0x10)) /* MSI-X Table entry
320
+                                                       * message reg - RW */
321
+#define E1000_MSIXVCTRL(_i) (0x0C00C + ((_i) * 0x10)) /* MSI-X Table entry
322
+                                                       * vector ctrl reg - RW */
323
+#define E1000_MSIXPBA    0x0E000 /* MSI-X Pending bit array */
324
+#define E1000_RETA(_i)  (0x05C00 + ((_i) * 4)) /* Redirection Table - RW */
325
+#define E1000_RSSRK(_i) (0x05C80 + ((_i) * 4)) /* RSS Random Key - RW */
326
+#define E1000_RSSIM     0x05864 /* RSS Interrupt Mask */
327
+#define E1000_RSSIR     0x05868 /* RSS Interrupt Request */
328
+
329
+#endif

+ 1
- 2
src/include/gpxe/errfile.h Ver fichero

@@ -104,8 +104,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
104 104
 #define ERRFILE_via_velocity	     ( ERRFILE_DRIVER | 0x00450000 )
105 105
 #define ERRFILE_w89c840		     ( ERRFILE_DRIVER | 0x00460000 )
106 106
 #define ERRFILE_ipoib		     ( ERRFILE_DRIVER | 0x00470000 )
107
-#define ERRFILE_e1000		     ( ERRFILE_DRIVER | 0x00480000 )
108
-#define ERRFILE_e1000_hw	     ( ERRFILE_DRIVER | 0x00490000 )
107
+#define ERRFILE_e1000_main	     ( ERRFILE_DRIVER | 0x00480000 )
109 108
 #define ERRFILE_mtnic		     ( ERRFILE_DRIVER | 0x004a0000 )
110 109
 #define ERRFILE_phantom		     ( ERRFILE_DRIVER | 0x004b0000 )
111 110
 #define ERRFILE_ne2k_isa	     ( ERRFILE_DRIVER | 0x004c0000 )

Loading…
Cancelar
Guardar