]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/ixgb/ixgb.h
Merge branch 'ebt_config_compat_v4' of git://git.breakpoint.cc/fw/nf-next-2.6
[net-next-2.6.git] / drivers / net / ixgb / ixgb.h
CommitLineData
1da177e4
LT
1/*******************************************************************************
2
0abb6eb1 3 Intel PRO/10GbE Linux driver
f731a9ef 4 Copyright(c) 1999 - 2008 Intel Corporation.
0abb6eb1
AK
5
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.
9
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
1da177e4 13 more details.
0abb6eb1 14
1da177e4 15 You should have received a copy of the GNU General Public License along with
0abb6eb1
AK
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
1da177e4
LT
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
0abb6eb1 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
1da177e4
LT
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
29#ifndef _IXGB_H_
30#define _IXGB_H_
31
32#include <linux/stddef.h>
1da177e4
LT
33#include <linux/module.h>
34#include <linux/types.h>
35#include <asm/byteorder.h>
36#include <linux/init.h>
37#include <linux/mm.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>
54#include <asm/io.h>
55#include <asm/irq.h>
56#include <linux/capability.h>
57#include <linux/in.h>
58#include <linux/ip.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>
1da177e4 64#include <net/checksum.h>
1da177e4
LT
65
66#include <linux/ethtool.h>
67#include <linux/if_vlan.h>
68
69#define BAR_0 0
70#define BAR_1 1
71#define BAR_5 5
72
73struct ixgb_adapter;
74#include "ixgb_hw.h"
75#include "ixgb_ee.h"
76#include "ixgb_ids.h"
77
6909c66d
JP
78#define PFX "ixgb: "
79
1da177e4 80#ifdef _DEBUG_DRIVER_
6909c66d 81#define IXGB_DBG(args...) printk(KERN_DEBUG PFX args)
1da177e4
LT
82#else
83#define IXGB_DBG(args...)
84#endif
85
1da177e4 86/* TX/RX descriptor defines */
2c21fc6e
JB
87#define DEFAULT_TXD 256
88#define MAX_TXD 4096
89#define MIN_TXD 64
1da177e4
LT
90
91/* hardware cannot reliably support more than 512 descriptors owned by
52035bdb
JB
92 * hardware descriptor cache otherwise an unreliable ring under heavy
93 * receive load may result */
2c21fc6e
JB
94#define DEFAULT_RXD 512
95#define MAX_RXD 512
96#define MIN_RXD 64
1da177e4
LT
97
98/* Supported Rx Buffer Sizes */
99#define IXGB_RXBUFFER_2048 2048
100#define IXGB_RXBUFFER_4096 4096
101#define IXGB_RXBUFFER_8192 8192
102#define IXGB_RXBUFFER_16384 16384
103
1da177e4 104/* How many Rx Buffers do we bundle into one write to the hardware ? */
a4d3c540 105#define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
1da177e4 106
1da177e4
LT
107/* wrapper around a pointer to a socket buffer,
108 * so a DMA handle can be stored along with the buffer */
109struct ixgb_buffer {
110 struct sk_buff *skb;
b40a1f06 111 dma_addr_t dma;
1da177e4 112 unsigned long time_stamp;
222441a6
JP
113 u16 length;
114 u16 next_to_watch;
adeaa908 115 u16 mapped_as_page;
1da177e4
LT
116};
117
118struct ixgb_desc_ring {
119 /* pointer to the descriptor ring memory */
120 void *desc;
121 /* physical address of the descriptor ring */
122 dma_addr_t dma;
123 /* length of descriptor ring in bytes */
124 unsigned int size;
125 /* number of descriptors in the ring */
126 unsigned int count;
127 /* next descriptor to associate a buffer with */
128 unsigned int next_to_use;
129 /* next descriptor to check for DD status bit */
130 unsigned int next_to_clean;
131 /* array of buffer information structs */
132 struct ixgb_buffer *buffer_info;
133};
134
135#define IXGB_DESC_UNUSED(R) \
136 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
137 (R)->next_to_clean - (R)->next_to_use - 1)
138
139#define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
140#define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
141#define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
142#define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
143
144/* board specific private data structure */
145
146struct ixgb_adapter {
147 struct timer_list watchdog_timer;
148 struct vlan_group *vlgrp;
222441a6
JP
149 u32 bd_number;
150 u32 rx_buffer_len;
151 u32 part_num;
152 u16 link_speed;
153 u16 link_duplex;
1da177e4
LT
154 struct work_struct tx_timeout_task;
155
156 struct timer_list blink_timer;
157 unsigned long led_status;
158
159 /* TX */
7a0eec3b 160 struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
dfd341e4 161 unsigned int restart_queue;
1da177e4 162 unsigned long timeo_start;
222441a6
JP
163 u32 tx_cmd_type;
164 u64 hw_csum_tx_good;
165 u64 hw_csum_tx_error;
166 u32 tx_int_delay;
167 u32 tx_timeout_count;
446490ca
JP
168 bool tx_int_delay_enable;
169 bool detect_tx_hung;
1da177e4
LT
170
171 /* RX */
172 struct ixgb_desc_ring rx_ring;
222441a6
JP
173 u64 hw_csum_rx_error;
174 u64 hw_csum_rx_good;
175 u32 rx_int_delay;
446490ca 176 bool rx_csum;
1da177e4
LT
177
178 /* OS defined structs */
bea3348e 179 struct napi_struct napi;
1da177e4
LT
180 struct net_device *netdev;
181 struct pci_dev *pdev;
1da177e4
LT
182
183 /* structs defined in ixgb_hw.h */
184 struct ixgb_hw hw;
ec9c3f5d 185 u16 msg_enable;
1da177e4 186 struct ixgb_hw_stats stats;
222441a6 187 u32 alloc_rx_buff_failed;
446490ca 188 bool have_msi;
bab2bce7
JB
189 unsigned long flags;
190};
191
192enum ixgb_state_t {
193 /* TBD
194 __IXGB_TESTING,
195 __IXGB_RESETTING,
196 */
197 __IXGB_DOWN
1da177e4 198};
273dc74e
SH
199
200/* Exported from other modules */
201extern void ixgb_check_options(struct ixgb_adapter *adapter);
202extern void ixgb_set_ethtool_ops(struct net_device *netdev);
203extern char ixgb_driver_name[];
204extern const char ixgb_driver_version[];
205
a9340b86
AK
206extern int ixgb_up(struct ixgb_adapter *adapter);
207extern void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
208extern void ixgb_reset(struct ixgb_adapter *adapter);
209extern int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
210extern int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
211extern void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
212extern void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
213extern void ixgb_update_stats(struct ixgb_adapter *adapter);
214
215
1da177e4 216#endif /* _IXGB_H_ */