1 /*******************************************************************************
4 Copyright(c) 1999 - 2006 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/module.h>
34 #include <linux/types.h>
35 #include <asm/byteorder.h>
36 #include <linux/init.h>
38 #include <linux/errno.h>
39 #include <linux/ioport.h>
40 #include <linux/pci.h>
41 #include <linux/kernel.h>
42 #include <linux/netdevice.h>
43 #include <linux/etherdevice.h>
44 #include <linux/skbuff.h>
45 #include <linux/delay.h>
46 #include <linux/timer.h>
47 #include <linux/slab.h>
48 #include <linux/vmalloc.h>
49 #include <linux/interrupt.h>
50 #include <linux/string.h>
51 #include <linux/pagemap.h>
52 #include <linux/dma-mapping.h>
53 #include <linux/bitops.h>
56 #include <linux/capability.h>
59 #include <linux/tcp.h>
60 #include <linux/udp.h>
61 #include <net/pkt_sched.h>
62 #include <linux/list.h>
63 #include <linux/reboot.h>
65 #include <net/checksum.h>
68 #include <linux/ethtool.h>
69 #include <linux/if_vlan.h>
81 #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
83 #define IXGB_DBG(args...)
87 #define DPRINTK(nlevel, klevel, fmt, args...) \
88 (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
89 printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
90 __FUNCTION__ , ## args))
93 /* TX/RX descriptor defines */
94 #define DEFAULT_TXD 256
98 /* hardware cannot reliably support more than 512 descriptors owned by
99 * hardware descrioptor cache otherwise an unreliable ring under heavy
100 * recieve load may result */
101 /* #define DEFAULT_RXD 1024 */
102 /* #define MAX_RXD 4096 */
103 #define DEFAULT_RXD 512
107 /* Supported Rx Buffer Sizes */
108 #define IXGB_RXBUFFER_2048 2048
109 #define IXGB_RXBUFFER_4096 4096
110 #define IXGB_RXBUFFER_8192 8192
111 #define IXGB_RXBUFFER_16384 16384
113 /* How many Tx Descriptors do we need to call netif_wake_queue? */
114 #define IXGB_TX_QUEUE_WAKE 16
116 /* How many Rx Buffers do we bundle into one write to the hardware ? */
117 #define IXGB_RX_BUFFER_WRITE 4 /* Must be power of 2 */
119 /* only works for sizes that are powers of 2 */
120 #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
122 /* wrapper around a pointer to a socket buffer,
123 * so a DMA handle can be stored along with the buffer */
127 unsigned long time_stamp;
129 uint16_t next_to_watch;
132 struct ixgb_desc_ring {
133 /* pointer to the descriptor ring memory */
135 /* physical address of the descriptor ring */
137 /* length of descriptor ring in bytes */
139 /* number of descriptors in the ring */
141 /* next descriptor to associate a buffer with */
142 unsigned int next_to_use;
143 /* next descriptor to check for DD status bit */
144 unsigned int next_to_clean;
145 /* array of buffer information structs */
146 struct ixgb_buffer *buffer_info;
149 #define IXGB_DESC_UNUSED(R) \
150 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
151 (R)->next_to_clean - (R)->next_to_use - 1)
153 #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
154 #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
155 #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
156 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
158 /* board specific private data structure */
160 struct ixgb_adapter {
161 struct timer_list watchdog_timer;
162 struct vlan_group *vlgrp;
164 uint32_t rx_buffer_len;
167 uint16_t link_duplex;
170 struct work_struct tx_timeout_task;
172 struct timer_list blink_timer;
173 unsigned long led_status;
176 struct ixgb_desc_ring tx_ring;
177 unsigned long timeo_start;
178 uint32_t tx_cmd_type;
179 uint64_t hw_csum_tx_good;
180 uint64_t hw_csum_tx_error;
181 uint32_t tx_int_delay;
182 uint32_t tx_timeout_count;
183 boolean_t tx_int_delay_enable;
184 boolean_t detect_tx_hung;
187 struct ixgb_desc_ring rx_ring;
188 uint64_t hw_csum_rx_error;
189 uint64_t hw_csum_rx_good;
190 uint32_t rx_int_delay;
193 /* OS defined structs */
194 struct net_device *netdev;
195 struct pci_dev *pdev;
196 struct net_device_stats net_stats;
198 /* structs defined in ixgb_hw.h */
201 struct ixgb_hw_stats stats;
202 uint32_t alloc_rx_buff_failed;
203 #ifdef CONFIG_PCI_MSI
207 #endif /* _IXGB_H_ */