1 /*******************************************************************************
3 Intel PRO/10GbE Linux driver
4 Copyright(c) 1999 - 2008 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".
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>
37 #include <linux/errno.h>
38 #include <linux/ioport.h>
39 #include <linux/pci.h>
40 #include <linux/kernel.h>
41 #include <linux/netdevice.h>
42 #include <linux/etherdevice.h>
43 #include <linux/skbuff.h>
44 #include <linux/delay.h>
45 #include <linux/timer.h>
46 #include <linux/slab.h>
47 #include <linux/vmalloc.h>
48 #include <linux/interrupt.h>
49 #include <linux/string.h>
50 #include <linux/pagemap.h>
51 #include <linux/dma-mapping.h>
52 #include <linux/bitops.h>
55 #include <linux/capability.h>
58 #include <linux/tcp.h>
59 #include <linux/udp.h>
60 #include <net/pkt_sched.h>
61 #include <linux/list.h>
62 #include <linux/reboot.h>
63 #include <net/checksum.h>
65 #include <linux/ethtool.h>
66 #include <linux/if_vlan.h>
77 /* TX/RX descriptor defines */
78 #define DEFAULT_TXD 256
82 /* hardware cannot reliably support more than 512 descriptors owned by
83 * hardware descriptor cache otherwise an unreliable ring under heavy
84 * receive load may result */
85 #define DEFAULT_RXD 512
89 /* Supported Rx Buffer Sizes */
90 #define IXGB_RXBUFFER_2048 2048
91 #define IXGB_RXBUFFER_4096 4096
92 #define IXGB_RXBUFFER_8192 8192
93 #define IXGB_RXBUFFER_16384 16384
95 /* How many Rx Buffers do we bundle into one write to the hardware ? */
96 #define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
98 /* wrapper around a pointer to a socket buffer,
99 * so a DMA handle can be stored along with the buffer */
103 unsigned long time_stamp;
109 struct ixgb_desc_ring {
110 /* pointer to the descriptor ring memory */
112 /* physical address of the descriptor ring */
114 /* length of descriptor ring in bytes */
116 /* number of descriptors in the ring */
118 /* next descriptor to associate a buffer with */
119 unsigned int next_to_use;
120 /* next descriptor to check for DD status bit */
121 unsigned int next_to_clean;
122 /* array of buffer information structs */
123 struct ixgb_buffer *buffer_info;
126 #define IXGB_DESC_UNUSED(R) \
127 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
128 (R)->next_to_clean - (R)->next_to_use - 1)
130 #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
131 #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
132 #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
133 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
135 /* board specific private data structure */
137 struct ixgb_adapter {
138 struct timer_list watchdog_timer;
139 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
145 struct work_struct tx_timeout_task;
148 struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
149 unsigned int restart_queue;
150 unsigned long timeo_start;
153 u64 hw_csum_tx_error;
155 u32 tx_timeout_count;
156 bool tx_int_delay_enable;
160 struct ixgb_desc_ring rx_ring;
161 u64 hw_csum_rx_error;
166 /* OS defined structs */
167 struct napi_struct napi;
168 struct net_device *netdev;
169 struct pci_dev *pdev;
171 /* structs defined in ixgb_hw.h */
174 struct ixgb_hw_stats stats;
175 u32 alloc_rx_buff_failed;
188 /* Exported from other modules */
189 void ixgb_check_options(struct ixgb_adapter *adapter);
190 void ixgb_set_ethtool_ops(struct net_device *netdev);
191 extern char ixgb_driver_name[];
192 extern const char ixgb_driver_version[];
194 void ixgb_set_speed_duplex(struct net_device *netdev);
196 int ixgb_up(struct ixgb_adapter *adapter);
197 void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
198 void ixgb_reset(struct ixgb_adapter *adapter);
199 int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
200 int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
201 void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
202 void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
203 void ixgb_update_stats(struct ixgb_adapter *adapter);
206 #endif /* _IXGB_H_ */