make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / drivers / net / e1000 / e1000.h
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved.
5   
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) 
9   any later version.
10   
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 
14   more details.
15   
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.
19   
20   The full GNU General Public License is included in this distribution in the
21   file called LICENSE.
22   
23   Contact Information:
24   Linux NICS <linux.nics@intel.com>
25   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27 *******************************************************************************/
28
29
30 /* Linux PRO/1000 Ethernet Driver main header file */
31
32 #ifndef _E1000_H_
33 #define _E1000_H_
34
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>
41 #include <linux/mm.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>
56 #include <asm/io.h>
57 #include <asm/irq.h>
58 #include <linux/capability.h>
59 #include <linux/in.h>
60 #include <linux/ip.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>
69
70 #define BAR_0           0
71 #define BAR_1           1
72 #define BAR_5           5
73 #define PCI_DMA_64BIT   0xffffffffffffffffULL
74 #define PCI_DMA_32BIT   0x00000000ffffffffULL
75
76
77 struct e1000_adapter;
78
79 #include "e1000_hw.h"
80
81 #if DBG
82 #define E1000_DBG(args...) printk(KERN_DEBUG "e1000: " args)
83 #else
84 #define E1000_DBG(args...)
85 #endif
86
87 #define E1000_ERR(args...) printk(KERN_ERR "e1000: " args)
88
89 #define E1000_MAX_INTR 10
90
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
96
97 /* Flow Control High-Watermark: 43464 bytes */
98 #define E1000_FC_HIGH_THRESH 0xA9C8
99
100 /* Flow Control Low-Watermark: 43456 bytes */
101 #define E1000_FC_LOW_THRESH 0xA9C0
102
103 /* Flow Control Pause Time: 858 usec */
104 #define E1000_FC_PAUSE_TIME 0x0680
105
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
110
111 #define E1000_JUMBO_PBA      0x00000028
112 #define E1000_DEFAULT_PBA    0x00000030
113
114 #define AUTO_ALL_MODES       0
115 #define E1000_EEPROM_APME    4
116
117 /* only works for sizes that are powers of 2 */
118 #define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
119
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 {
123         struct sk_buff *skb;
124         uint64_t dma;
125         unsigned long length;
126         unsigned long time_stamp;
127 };
128
129 struct e1000_desc_ring {
130         /* pointer to the descriptor ring memory */
131         void *desc;
132         /* physical address of the descriptor ring */
133         dma_addr_t dma;
134         /* length of descriptor ring in bytes */
135         unsigned int size;
136         /* number of descriptors in the ring */
137         unsigned int count;
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;
144 };
145
146 #define E1000_DESC_UNUSED(R) \
147 ((((R)->next_to_clean + (R)->count) - ((R)->next_to_use + 1)) % ((R)->count))
148
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)
153
154 /* board specific private data structure */
155
156 struct e1000_adapter {
157         struct timer_list watchdog_timer;
158         struct timer_list phy_info_timer;
159         struct vlan_group *vlgrp;
160         char *id_string;
161         uint32_t bd_number;
162         uint32_t rx_buffer_len;
163         uint32_t part_num;
164         uint32_t wol;
165         uint16_t link_speed;
166         uint16_t link_duplex;
167         spinlock_t stats_lock;
168         atomic_t irq_sem;
169         struct tq_struct tx_timeout_task;
170
171         struct timer_list blink_timer;
172         unsigned long led_status;
173
174         /* TX */
175         struct e1000_desc_ring tx_ring;
176         uint32_t txd_cmd;
177         uint32_t tx_int_delay;
178         uint32_t tx_abs_int_delay;
179         int max_data_per_txd;
180
181         /* RX */
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;
187         boolean_t rx_csum;
188
189         /* OS defined structs */
190         struct net_device *netdev;
191         struct pci_dev *pdev;
192         struct net_device_stats net_stats;
193
194         /* structs defined in e1000_hw.h */
195         struct e1000_hw hw;
196         struct e1000_hw_stats stats;
197         struct e1000_phy_info phy_info;
198         struct e1000_phy_stats phy_stats;
199
200
201
202         uint32_t pci_state[16];
203         char ifname[IFNAMSIZ];
204 };
205 #endif /* _E1000_H_ */