1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
29 FILE_LICENCE ( GPL2_ONLY
);
31 /* Linux PRO/1000 Ethernet Driver main header file */
36 #include "e1000_api.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
50 #define E1000_DEFAULT_TXD_PWR 12
51 #define E1000_MAX_TXD_PWR 12
52 #define E1000_MIN_TXD_PWR 7
54 #define E1000_DEFAULT_RXD 256
55 #define E1000_MAX_RXD 256
57 #define E1000_MIN_RXD 80
58 #define E1000_MAX_82544_RXD 4096
60 #define E1000_MIN_ITR_USECS 10 /* 100000 irq/sec */
61 #define E1000_MAX_ITR_USECS 10000 /* 100 irq/sec */
64 /* this is the size past which hardware will drop packets when setting LPE=0 */
65 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
67 /* Supported Rx Buffer Sizes */
68 #define E1000_RXBUFFER_128 128
69 #define E1000_RXBUFFER_256 256
70 #define E1000_RXBUFFER_512 512
71 #define E1000_RXBUFFER_1024 1024
72 #define E1000_RXBUFFER_2048 2048
73 #define E1000_RXBUFFER_4096 4096
74 #define E1000_RXBUFFER_8192 8192
75 #define E1000_RXBUFFER_16384 16384
77 /* SmartSpeed delimiters */
78 #define E1000_SMARTSPEED_DOWNSHIFT 3
79 #define E1000_SMARTSPEED_MAX 15
81 /* Packet Buffer allocations */
82 #define E1000_PBA_BYTES_SHIFT 0xA
83 #define E1000_TX_HEAD_ADDR_SHIFT 7
84 #define E1000_PBA_TX_MASK 0xFFFF0000
86 /* Early Receive defines */
87 #define E1000_ERT_2048 0x100
89 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
91 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
92 #define E1000_TX_QUEUE_WAKE 16
93 /* How many Rx Buffers do we bundle into one write to the hardware ? */
94 #define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
96 #define AUTO_ALL_MODES 0
97 #define E1000_EEPROM_82544_APM 0x0004
98 #define E1000_EEPROM_APME 0x0400
100 /* wrapper around a pointer to a socket buffer,
101 * so a DMA handle can be stored along with the buffer */
102 struct e1000_buffer
{
105 unsigned long time_stamp
;
110 struct e1000_rx_buffer
{
118 struct e1000_tx_ring
{
119 /* pointer to the descriptor ring memory */
121 /* physical address of the descriptor ring */
123 /* length of descriptor ring in bytes */
125 /* number of descriptors in the ring */
127 /* next descriptor to associate a buffer with */
128 unsigned int next_to_use
;
129 /* next descriptor to check for DD status bit */
130 unsigned int next_to_clean
;
131 /* array of buffer information structs */
132 struct e1000_buffer
*buffer_info
;
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.
149 struct e1000_rx_ring
{
150 struct e1000_adapter
*adapter
; /* back link */
151 /* pointer to the descriptor ring memory */
153 /* physical address of the descriptor ring */
155 /* length of descriptor ring in bytes */
157 /* number of descriptors in the ring */
159 /* next descriptor to associate a buffer with */
160 unsigned int next_to_use
;
161 /* next descriptor to check for DD status bit */
162 unsigned int next_to_clean
;
163 /* array of buffer information structs */
164 struct e1000_rx_buffer
*buffer_info
;
165 struct sk_buff
*rx_skb_top
;
167 /* cpu for rx queue */
175 #define E1000_TX_DESC_INC(R,index) \
176 {index += (R)->step; if (index == (R)->count) index = 0; }
178 #define E1000_TX_DESC_DEC(R,index) \
179 { if (index == 0) index = (R)->count - (R)->step; \
180 else index -= (R)->step; }
182 #define E1000_DESC_UNUSED(R) \
183 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
184 (R)->next_to_clean - (R)->next_to_use - 1)
186 #define E1000_RX_DESC_EXT(R, i) \
187 (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
188 #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
189 #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
190 #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
191 #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
193 /* board specific private data structure */
195 struct e1000_adapter
{
203 spinlock_t stats_lock
;
204 unsigned int total_tx_bytes
;
205 unsigned int total_tx_packets
;
206 unsigned int total_rx_bytes
;
207 unsigned int total_rx_packets
;
208 /* Interrupt Throttle Rate */
217 struct e1000_tx_ring
*tx_ring
;
218 unsigned int restart_queue
;
219 unsigned long tx_queue_len
;
222 u32 tx_abs_int_delay
;
227 u32 tx_timeout_count
;
231 u8 tx_timeout_factor
;
236 bool (*clean_rx
) (struct e1000_adapter
*adapter
,
237 struct e1000_rx_ring
*rx_ring
);
238 void (*alloc_rx_buf
) (struct e1000_adapter
*adapter
,
239 struct e1000_rx_ring
*rx_ring
,
241 struct e1000_rx_ring
*rx_ring
;
245 u32 alloc_rx_buff_failed
;
247 u32 rx_abs_int_delay
;
255 /* OS defined structs */
256 struct net_device
*netdev
;
257 struct pci_device
*pdev
;
258 struct net_device_stats net_stats
;
260 /* structs defined in e1000_hw.h */
262 struct e1000_hw_stats stats
;
263 struct e1000_phy_info phy_info
;
264 struct e1000_phy_stats phy_stats
;
267 /* to not mess up cache alignment, always add to the bottom */
273 /* hardware capability, feature, and workaround flags */
276 /* upper limit parameter for tx desc size */
279 #define NUM_TX_DESC 8
280 #define NUM_RX_DESC 8
282 struct io_buffer
*tx_iobuf
[NUM_TX_DESC
];
283 struct io_buffer
*rx_iobuf
[NUM_RX_DESC
];
285 struct e1000_tx_desc
*tx_base
;
286 struct e1000_rx_desc
*rx_base
;
288 uint32_t tx_ring_size
;
289 uint32_t rx_ring_size
;
293 uint32_t tx_fill_ctr
;
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)
307 extern char e1000_driver_name
[];
308 extern const char e1000_driver_version
[];
310 extern void e1000_power_up_phy(struct e1000_hw
*hw
);
312 extern void e1000_set_ethtool_ops(struct net_device
*netdev
);
313 extern void e1000_check_options(struct e1000_adapter
*adapter
);
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
);
326 #endif /* _E1000_H_ */