1 /*******************************************************************************
4 Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 The full GNU General Public License is included in this distribution in the
24 Linux NICS <linux.nics@intel.com>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
30 /* Linux PRO/1000 Ethernet Driver main header file */
35 #include <linux/stddef.h>
36 #include <linux/config.h>
37 #include <linux/module.h>
38 #include <linux/types.h>
39 #include <asm/byteorder.h>
40 #include <linux/init.h>
42 #include <linux/errno.h>
43 #include <linux/ioport.h>
44 #include <linux/pci.h>
45 #include <linux/kernel.h>
46 #include <linux/netdevice.h>
47 #include <linux/etherdevice.h>
48 #include <linux/skbuff.h>
49 #include <linux/delay.h>
50 #include <linux/timer.h>
51 #include <linux/slab.h>
52 #include <linux/interrupt.h>
53 #include <linux/string.h>
54 #include <linux/pagemap.h>
55 #include <asm/bitops.h>
58 #include <linux/capability.h>
61 #include <linux/tcp.h>
62 #include <linux/udp.h>
63 #include <net/pkt_sched.h>
64 #include <linux/list.h>
65 #include <linux/reboot.h>
66 #include <linux/tqueue.h>
67 #include <linux/ethtool.h>
68 #include <linux/if_vlan.h>
73 #define PCI_DMA_64BIT 0xffffffffffffffffULL
74 #define PCI_DMA_32BIT 0x00000000ffffffffULL
82 #define E1000_DBG(args...) printk(KERN_DEBUG "e1000: " args)
84 #define E1000_DBG(args...)
87 #define E1000_ERR(args...) printk(KERN_ERR "e1000: " args)
89 #define E1000_MAX_INTR 10
91 /* Supported Rx Buffer Sizes */
92 #define E1000_RXBUFFER_2048 2048
93 #define E1000_RXBUFFER_4096 4096
94 #define E1000_RXBUFFER_8192 8192
95 #define E1000_RXBUFFER_16384 16384
97 /* Flow Control High-Watermark: 43464 bytes */
98 #define E1000_FC_HIGH_THRESH 0xA9C8
100 /* Flow Control Low-Watermark: 43456 bytes */
101 #define E1000_FC_LOW_THRESH 0xA9C0
103 /* Flow Control Pause Time: 858 usec */
104 #define E1000_FC_PAUSE_TIME 0x0680
106 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
107 #define E1000_TX_QUEUE_WAKE 16
108 /* How many Rx Buffers do we bundle into one write to the hardware ? */
109 #define E1000_RX_BUFFER_WRITE 16
111 #define E1000_JUMBO_PBA 0x00000028
112 #define E1000_DEFAULT_PBA 0x00000030
114 #define AUTO_ALL_MODES 0
115 #define E1000_EEPROM_APME 4
117 /* only works for sizes that are powers of 2 */
118 #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
120 /* wrapper around a pointer to a socket buffer,
121 * so a DMA handle can be stored along with the buffer */
122 struct e1000_buffer {
125 unsigned long length;
126 unsigned long time_stamp;
129 struct e1000_desc_ring {
130 /* pointer to the descriptor ring memory */
132 /* physical address of the descriptor ring */
134 /* length of descriptor ring in bytes */
136 /* number of descriptors in the ring */
138 /* next descriptor to associate a buffer with */
139 unsigned int next_to_use;
140 /* next descriptor to check for DD status bit */
141 unsigned int next_to_clean;
142 /* array of buffer information structs */
143 struct e1000_buffer *buffer_info;
146 #define E1000_DESC_UNUSED(R) \
147 ((((R)->next_to_clean + (R)->count) - ((R)->next_to_use + 1)) % ((R)->count))
149 #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
150 #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
151 #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
152 #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
154 /* board specific private data structure */
156 struct e1000_adapter {
157 struct timer_list watchdog_timer;
158 struct timer_list phy_info_timer;
159 struct vlan_group *vlgrp;
162 uint32_t rx_buffer_len;
166 uint16_t link_duplex;
167 spinlock_t stats_lock;
169 struct tq_struct tx_timeout_task;
171 struct timer_list blink_timer;
172 unsigned long led_status;
175 struct e1000_desc_ring tx_ring;
177 uint32_t tx_int_delay;
178 uint32_t tx_abs_int_delay;
179 int max_data_per_txd;
182 struct e1000_desc_ring rx_ring;
183 uint64_t hw_csum_err;
184 uint64_t hw_csum_good;
185 uint32_t rx_int_delay;
186 uint32_t rx_abs_int_delay;
189 /* OS defined structs */
190 struct net_device *netdev;
191 struct pci_dev *pdev;
192 struct net_device_stats net_stats;
194 /* structs defined in e1000_hw.h */
196 struct e1000_hw_stats stats;
197 struct e1000_phy_info phy_info;
198 struct e1000_phy_stats phy_stats;
202 uint32_t pci_state[16];
203 char ifname[IFNAMSIZ];
205 #endif /* _E1000_H_ */