1 /*******************************************************************************
4 Copyright(c) 1999 - 2005 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 *******************************************************************************/
32 #include <linux/stddef.h>
33 #include <linux/config.h>
34 #include <linux/module.h>
35 #include <linux/types.h>
36 #include <asm/byteorder.h>
37 #include <linux/init.h>
39 #include <linux/errno.h>
40 #include <linux/ioport.h>
41 #include <linux/pci.h>
42 #include <linux/kernel.h>
43 #include <linux/netdevice.h>
44 #include <linux/etherdevice.h>
45 #include <linux/skbuff.h>
46 #include <linux/delay.h>
47 #include <linux/timer.h>
48 #include <linux/slab.h>
49 #include <linux/vmalloc.h>
50 #include <linux/interrupt.h>
51 #include <linux/string.h>
52 #include <linux/pagemap.h>
53 #include <linux/dma-mapping.h>
54 #include <linux/bitops.h>
57 #include <linux/capability.h>
60 #include <linux/tcp.h>
61 #include <linux/udp.h>
62 #include <net/pkt_sched.h>
63 #include <linux/list.h>
64 #include <linux/reboot.h>
66 #include <net/checksum.h>
69 #include <linux/ethtool.h>
70 #include <linux/if_vlan.h>
82 #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
84 #define IXGB_DBG(args...)
87 #define IXGB_ERR(args...) printk(KERN_ERR "ixgb: " args)
89 /* TX/RX descriptor defines */
90 #define DEFAULT_TXD 256
94 /* hardware cannot reliably support more than 512 descriptors owned by
95 * hardware descrioptor cache otherwise an unreliable ring under heavy
96 * recieve load may result */
97 /* #define DEFAULT_RXD 1024 */
98 /* #define MAX_RXD 4096 */
99 #define DEFAULT_RXD 512
103 /* Supported Rx Buffer Sizes */
104 #define IXGB_RXBUFFER_2048 2048
105 #define IXGB_RXBUFFER_4096 4096
106 #define IXGB_RXBUFFER_8192 8192
107 #define IXGB_RXBUFFER_16384 16384
109 /* How many Tx Descriptors do we need to call netif_wake_queue? */
110 #define IXGB_TX_QUEUE_WAKE 16
112 /* How many Rx Buffers do we bundle into one write to the hardware ? */
113 #define IXGB_RX_BUFFER_WRITE 16 /* Must be power of 2 */
115 /* only works for sizes that are powers of 2 */
116 #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
118 /* wrapper around a pointer to a socket buffer,
119 * so a DMA handle can be stored along with the buffer */
123 unsigned long time_stamp
;
125 uint16_t next_to_watch
;
128 struct ixgb_desc_ring
{
129 /* pointer to the descriptor ring memory */
131 /* physical address of the descriptor ring */
133 /* length of descriptor ring in bytes */
135 /* number of descriptors in the ring */
137 /* next descriptor to associate a buffer with */
138 unsigned int next_to_use
;
139 /* next descriptor to check for DD status bit */
140 unsigned int next_to_clean
;
141 /* array of buffer information structs */
142 struct ixgb_buffer
*buffer_info
;
145 #define IXGB_DESC_UNUSED(R) \
146 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
147 (R)->next_to_clean - (R)->next_to_use - 1)
149 #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
150 #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
151 #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
152 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
154 /* board specific private data structure */
156 struct ixgb_adapter
{
157 struct timer_list watchdog_timer
;
158 struct vlan_group
*vlgrp
;
160 uint32_t rx_buffer_len
;
163 uint16_t link_duplex
;
166 struct work_struct tx_timeout_task
;
168 struct timer_list blink_timer
;
169 unsigned long led_status
;
172 struct ixgb_desc_ring tx_ring
;
173 unsigned long timeo_start
;
174 uint32_t tx_cmd_type
;
175 uint64_t hw_csum_tx_good
;
176 uint64_t hw_csum_tx_error
;
177 uint32_t tx_int_delay
;
178 boolean_t tx_int_delay_enable
;
179 boolean_t detect_tx_hung
;
182 struct ixgb_desc_ring rx_ring
;
183 uint64_t hw_csum_rx_error
;
184 uint64_t hw_csum_rx_good
;
185 uint32_t rx_int_delay
;
188 /* OS defined structs */
189 struct net_device
*netdev
;
190 struct pci_dev
*pdev
;
191 struct net_device_stats net_stats
;
193 /* structs defined in ixgb_hw.h */
195 struct ixgb_hw_stats stats
;
196 #ifdef CONFIG_PCI_MSI
200 #endif /* _IXGB_H_ */