1 /*******************************************************************************
3 Intel PRO/10GbE 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 *******************************************************************************/
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>
64 #include <net/checksum.h>
66 #include <linux/ethtool.h>
67 #include <linux/if_vlan.h>
79 #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
81 #define IXGB_DBG(args...)
85 #define DPRINTK(nlevel, klevel, fmt, args...) \
86 (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
87 printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
88 __FUNCTION__ , ## args))
91 /* TX/RX descriptor defines */
92 #define DEFAULT_TXD 256
96 /* hardware cannot reliably support more than 512 descriptors owned by
97 * hardware descrioptor cache otherwise an unreliable ring under heavy
98 * recieve load may result */
99 /* #define DEFAULT_RXD 1024 */
100 /* #define MAX_RXD 4096 */
101 #define DEFAULT_RXD 512
105 /* Supported Rx Buffer Sizes */
106 #define IXGB_RXBUFFER_2048 2048
107 #define IXGB_RXBUFFER_4096 4096
108 #define IXGB_RXBUFFER_8192 8192
109 #define IXGB_RXBUFFER_16384 16384
111 /* How many Rx Buffers do we bundle into one write to the hardware ? */
112 #define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
114 /* wrapper around a pointer to a socket buffer,
115 * so a DMA handle can be stored along with the buffer */
119 unsigned long time_stamp;
121 uint16_t next_to_watch;
124 struct ixgb_desc_ring {
125 /* pointer to the descriptor ring memory */
127 /* physical address of the descriptor ring */
129 /* length of descriptor ring in bytes */
131 /* number of descriptors in the ring */
133 /* next descriptor to associate a buffer with */
134 unsigned int next_to_use;
135 /* next descriptor to check for DD status bit */
136 unsigned int next_to_clean;
137 /* array of buffer information structs */
138 struct ixgb_buffer *buffer_info;
141 #define IXGB_DESC_UNUSED(R) \
142 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
143 (R)->next_to_clean - (R)->next_to_use - 1)
145 #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
146 #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
147 #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
148 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
150 /* board specific private data structure */
152 struct ixgb_adapter {
153 struct timer_list watchdog_timer;
154 struct vlan_group *vlgrp;
156 uint32_t rx_buffer_len;
159 uint16_t link_duplex;
162 struct work_struct tx_timeout_task;
164 struct timer_list blink_timer;
165 unsigned long led_status;
168 struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
169 unsigned int restart_queue;
170 unsigned long timeo_start;
171 uint32_t tx_cmd_type;
172 uint64_t hw_csum_tx_good;
173 uint64_t hw_csum_tx_error;
174 uint32_t tx_int_delay;
175 uint32_t tx_timeout_count;
176 boolean_t tx_int_delay_enable;
177 boolean_t detect_tx_hung;
180 struct ixgb_desc_ring rx_ring;
181 uint64_t hw_csum_rx_error;
182 uint64_t hw_csum_rx_good;
183 uint32_t rx_int_delay;
186 /* OS defined structs */
187 struct napi_struct napi;
188 struct net_device *netdev;
189 struct pci_dev *pdev;
190 struct net_device_stats net_stats;
192 /* structs defined in ixgb_hw.h */
195 struct ixgb_hw_stats stats;
196 uint32_t alloc_rx_buff_failed;
200 /* Exported from other modules */
201 extern void ixgb_check_options(struct ixgb_adapter *adapter);
202 extern void ixgb_set_ethtool_ops(struct net_device *netdev);
203 extern char ixgb_driver_name[];
204 extern const char ixgb_driver_version[];
206 #endif /* _IXGB_H_ */