|
|
1.1 root 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 <[email protected]>
24: e1000-devel Mailing List <[email protected]>
25: Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26:
27: *******************************************************************************/
28:
29: FILE_LICENCE ( GPL2_ONLY );
30:
31: /* Linux PRO/1000 Ethernet Driver main header file */
32:
33: #ifndef _E1000_H_
34: #define _E1000_H_
35:
36: #include "e1000_api.h"
37:
38: #define BAR_0 0
39: #define BAR_1 1
40: #define BAR_5 5
41:
42: struct e1000_adapter;
43:
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
66:
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
76:
77: /* SmartSpeed delimiters */
78: #define E1000_SMARTSPEED_DOWNSHIFT 3
79: #define E1000_SMARTSPEED_MAX 15
80:
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
85:
86: /* Early Receive defines */
87: #define E1000_ERT_2048 0x100
88:
89: #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
90:
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 */
95:
96: #define AUTO_ALL_MODES 0
97: #define E1000_EEPROM_82544_APM 0x0004
98: #define E1000_EEPROM_APME 0x0400
99:
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 {
103: struct sk_buff *skb;
104: dma_addr_t dma;
105: unsigned long time_stamp;
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;
114: };
115:
116:
117:
118: struct e1000_tx_ring {
119: /* pointer to the descriptor ring memory */
120: void *desc;
121: /* physical address of the descriptor ring */
122: dma_addr_t dma;
123: /* length of descriptor ring in bytes */
124: unsigned int size;
125: /* number of descriptors in the ring */
126: unsigned int count;
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;
133:
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;
147: };
148:
149: struct e1000_rx_ring {
150: struct e1000_adapter *adapter; /* back link */
151: /* pointer to the descriptor ring memory */
152: void *desc;
153: /* physical address of the descriptor ring */
154: dma_addr_t dma;
155: /* length of descriptor ring in bytes */
156: unsigned int size;
157: /* number of descriptors in the ring */
158: unsigned int count;
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;
166:
167: /* cpu for rx queue */
168: int cpu;
169:
170: u16 rdh;
171: u16 rdt;
172: };
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:
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)
185:
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)
192:
193: /* board specific private data structure */
194:
195: struct e1000_adapter {
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;
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 */
209: u32 itr;
210: u32 itr_setting;
211: u16 tx_itr;
212: u16 rx_itr;
213:
214: bool fc_autoneg;
215:
216: /* TX */
217: struct e1000_tx_ring *tx_ring;
218: unsigned int restart_queue;
219: unsigned long tx_queue_len;
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;
234:
235: /* RX */
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,
240: int cleaned_count);
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;
253:
254:
255: /* OS defined structs */
256: struct net_device *netdev;
257: struct pci_device *pdev;
258: struct net_device_stats net_stats;
259:
260: /* structs defined in e1000_hw.h */
261: struct e1000_hw hw;
262: struct e1000_hw_stats stats;
263: struct e1000_phy_info phy_info;
264: struct e1000_phy_stats phy_stats;
265:
266: int msg_enable;
267: /* to not mess up cache alignment, always add to the bottom */
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:
279: #define NUM_TX_DESC 8
280: #define NUM_RX_DESC 8
281:
282: struct io_buffer *tx_iobuf[NUM_TX_DESC];
283: struct io_buffer *rx_iobuf[NUM_RX_DESC];
284:
285: struct e1000_tx_desc *tx_base;
286: struct e1000_rx_desc *rx_base;
287:
288: uint32_t tx_ring_size;
289: uint32_t rx_ring_size;
290:
291: uint32_t tx_head;
292: uint32_t tx_tail;
293: uint32_t tx_fill_ctr;
294:
295: uint32_t rx_curr;
296:
297: uint32_t ioaddr;
298: uint32_t irqno;
299: };
300:
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)
306:
307: extern char e1000_driver_name[];
308: extern const char e1000_driver_version[];
309:
310: extern void e1000_power_up_phy(struct e1000_hw *hw);
311:
312: extern void e1000_set_ethtool_ops(struct net_device *netdev);
313: extern void e1000_check_options(struct e1000_adapter *adapter);
314:
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);
325:
326: #endif /* _E1000_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.