1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2006 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 /* Linux PRO/1000 Ethernet Driver main header file */
42 #include <gpxe/malloc.h>
43 #include <gpxe/if_ether.h>
44 #include <gpxe/ethernet.h>
45 #include <gpxe/iobuf.h>
46 #include <gpxe/netdevice.h>
56 /* Supported Rx Buffer Sizes */
57 #define E1000_RXBUFFER_128 128 /* Used for packet split */
58 #define E1000_RXBUFFER_256 256 /* Used for packet split */
59 #define E1000_RXBUFFER_512 512
60 #define E1000_RXBUFFER_1024 1024
61 #define E1000_RXBUFFER_2048 2048
62 #define E1000_RXBUFFER_4096 4096
63 #define E1000_RXBUFFER_8192 8192
64 #define E1000_RXBUFFER_16384 16384
66 /* SmartSpeed delimiters */
67 #define E1000_SMARTSPEED_DOWNSHIFT 3
68 #define E1000_SMARTSPEED_MAX 15
70 /* Packet Buffer allocations */
71 #define E1000_PBA_BYTES_SHIFT 0xA
72 #define E1000_TX_HEAD_ADDR_SHIFT 7
73 #define E1000_PBA_TX_MASK 0xFFFF0000
75 /* Flow Control Watermarks */
76 #define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */
77 #define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */
79 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
81 /* this is the size past which hardware will drop packets when setting LPE=0 */
82 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
84 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
85 #define E1000_TX_QUEUE_WAKE 16
86 /* How many Rx Buffers do we bundle into one write to the hardware ? */
87 #define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
89 #define AUTO_ALL_MODES 0
90 #define E1000_EEPROM_82544_APM 0x0004
91 #define E1000_EEPROM_ICH8_APME 0x0004
92 #define E1000_EEPROM_APME 0x0400
94 #ifndef E1000_MASTER_SLAVE
95 /* Switch to override PHY master/slave setting */
96 #define E1000_MASTER_SLAVE e1000_ms_hw_default
99 /* wrapper around a pointer to a socket buffer,
100 * so a DMA handle can be stored along with the buffer */
101 struct e1000_buffer {
103 unsigned long time_stamp;
105 uint16_t next_to_watch;
108 struct e1000_tx_ring {
109 /* pointer to the descriptor ring memory */
111 /* length of descriptor ring in bytes */
113 /* number of descriptors in the ring */
115 /* next descriptor to associate a buffer with */
116 unsigned int next_to_use;
117 /* next descriptor to check for DD status bit */
118 unsigned int next_to_clean;
119 /* array of buffer information structs */
120 struct e1000_buffer *buffer_info;
124 boolean_t last_tx_tso;
127 struct e1000_rx_ring {
128 /* pointer to the descriptor ring memory */
130 /* length of descriptor ring in bytes */
132 /* number of descriptors in the ring */
134 /* next descriptor to associate a buffer with */
135 unsigned int next_to_use;
136 /* next descriptor to check for DD status bit */
137 unsigned int next_to_clean;
138 /* array of buffer information structs */
139 struct e1000_buffer *buffer_info;
140 /* arrays of page information for packet split */
141 struct e1000_ps_page *ps_page;
142 struct e1000_ps_page_dma *ps_page_dma;
144 /* cpu for rx queue */
151 #define E1000_DESC_UNUSED(R) \
152 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
153 (R)->next_to_clean - (R)->next_to_use - 1)
155 #define E1000_RX_DESC_PS(R, i) \
156 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
157 #define E1000_RX_DESC_EXT(R, i) \
158 (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
159 #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
160 #define E1000_RX_DESC(R, i) E1000_GET_DESC(R, i, e1000_rx_desc)
161 #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
162 #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
164 /* board specific private data structure */
166 struct e1000_adapter {
167 struct vlan_group *vlgrp;
168 uint16_t mng_vlan_id;
170 uint32_t rx_buffer_len;
175 uint16_t link_duplex;
177 unsigned int total_tx_bytes;
178 unsigned int total_tx_packets;
179 unsigned int total_rx_bytes;
180 unsigned int total_rx_packets;
181 /* Interrupt Throttle Rate */
183 uint32_t itr_setting;
189 unsigned long led_status;
192 struct e1000_tx_ring *tx_ring; /* One per active queue */
193 unsigned int restart_queue;
194 unsigned long tx_queue_len;
196 uint32_t tx_int_delay;
197 uint32_t tx_abs_int_delay;
202 uint32_t tx_timeout_count;
203 uint32_t tx_fifo_head;
204 uint32_t tx_head_addr;
205 uint32_t tx_fifo_size;
206 uint8_t tx_timeout_factor;
207 boolean_t pcix_82544;
208 boolean_t detect_tx_hung;
211 boolean_t (*clean_rx) (struct e1000_adapter *adapter,
212 struct e1000_rx_ring *rx_ring);
213 void (*alloc_rx_buf) (struct e1000_adapter *adapter,
214 struct e1000_rx_ring *rx_ring,
216 struct e1000_rx_ring *rx_ring; /* One per active queue */
220 uint64_t hw_csum_err;
221 uint64_t hw_csum_good;
222 uint64_t rx_hdr_split;
223 uint32_t alloc_rx_buff_failed;
224 uint32_t rx_int_delay;
225 uint32_t rx_abs_int_delay;
227 unsigned int rx_ps_pages;
230 uint16_t rx_ps_bsize0;
233 /* OS defined structs */
234 struct net_device *netdev;
235 struct pci_device *pdev;
236 struct net_device_stats net_stats;
238 /* structs defined in e1000_hw.h */
240 struct e1000_hw_stats stats;
241 struct e1000_phy_info phy_info;
242 struct e1000_phy_stats phy_stats;
245 struct e1000_tx_ring test_tx_ring;
246 struct e1000_rx_ring test_rx_ring;
251 /* to not mess up cache alignment, always add to the bottom */
253 boolean_t smart_power_down; /* phy smart power down */
254 boolean_t quad_port_a;
258 #define NUM_TX_DESC 8
259 #define NUM_RX_DESC 8
261 struct io_buffer *tx_iobuf[NUM_TX_DESC];
262 struct io_buffer *rx_iobuf[NUM_RX_DESC];
264 struct e1000_tx_desc *tx_base;
265 struct e1000_rx_desc *rx_base;
267 uint32_t tx_ring_size;
268 uint32_t rx_ring_size;
272 uint32_t tx_fill_ctr;
287 #define E1000_MNG2HOST_PORT_623 (1 << 5)
288 #define E1000_MNG2HOST_PORT_664 (1 << 6)
290 #define E1000_ERT_2048 0x100
292 #define IORESOURCE_IO 0x00000100
293 #define IORESOURCE_MEM 0x00000200
294 #define IORESOURCE_PREFETCH 0x00001000
296 #endif /* _E1000_H_ */