Merge master.kernel.org:/pub/scm/linux/kernel/git/kyle/parisc-2.6
[pandora-kernel.git] / drivers / net / ixgb / ixgb.h
1 /*******************************************************************************
2
3   Intel PRO/10GbE Linux driver
4   Copyright(c) 1999 - 2006 Intel Corporation.
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
13   more details.
14
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.
18
19   The full GNU General Public License is included in this distribution in
20   the file called "COPYING".
21
22   Contact Information:
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
26
27 *******************************************************************************/
28
29 #ifndef _IXGB_H_
30 #define _IXGB_H_
31
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>
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>
64 #include <net/checksum.h>
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
73 struct ixgb_adapter;
74 #include "ixgb_hw.h"
75 #include "ixgb_ee.h"
76 #include "ixgb_ids.h"
77
78 #ifdef _DEBUG_DRIVER_
79 #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
80 #else
81 #define IXGB_DBG(args...)
82 #endif
83
84 #define PFX "ixgb: "
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))
89
90
91 /* TX/RX descriptor defines */
92 #define DEFAULT_TXD      256
93 #define MAX_TXD         4096
94 #define MIN_TXD   64
95
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
102 #define MAX_RXD 512
103 #define MIN_RXD  64
104
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
110
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 */
113
114 /* only works for sizes that are powers of 2 */
115 #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
116
117 /* wrapper around a pointer to a socket buffer,
118  * so a DMA handle can be stored along with the buffer */
119 struct ixgb_buffer {
120         struct sk_buff *skb;
121         dma_addr_t dma;
122         unsigned long time_stamp;
123         uint16_t length;
124         uint16_t next_to_watch;
125 };
126
127 struct ixgb_desc_ring {
128         /* pointer to the descriptor ring memory */
129         void *desc;
130         /* physical address of the descriptor ring */
131         dma_addr_t dma;
132         /* length of descriptor ring in bytes */
133         unsigned int size;
134         /* number of descriptors in the ring */
135         unsigned int count;
136         /* next descriptor to associate a buffer with */
137         unsigned int next_to_use;
138         /* next descriptor to check for DD status bit */
139         unsigned int next_to_clean;
140         /* array of buffer information structs */
141         struct ixgb_buffer *buffer_info;
142 };
143
144 #define IXGB_DESC_UNUSED(R) \
145         ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
146         (R)->next_to_clean - (R)->next_to_use - 1)
147
148 #define IXGB_GET_DESC(R, i, type)       (&(((struct type *)((R).desc))[i]))
149 #define IXGB_RX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_rx_desc)
150 #define IXGB_TX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_tx_desc)
151 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
152
153 /* board specific private data structure */
154
155 struct ixgb_adapter {
156         struct timer_list watchdog_timer;
157         struct vlan_group *vlgrp;
158         uint32_t bd_number;
159         uint32_t rx_buffer_len;
160         uint32_t part_num;
161         uint16_t link_speed;
162         uint16_t link_duplex;
163         spinlock_t tx_lock;
164         atomic_t irq_sem;
165         struct work_struct tx_timeout_task;
166
167         struct timer_list blink_timer;
168         unsigned long led_status;
169
170         /* TX */
171         struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
172         unsigned int restart_queue;
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         uint32_t tx_timeout_count;
179         boolean_t tx_int_delay_enable;
180         boolean_t detect_tx_hung;
181
182         /* RX */
183         struct ixgb_desc_ring rx_ring;
184         uint64_t hw_csum_rx_error;
185         uint64_t hw_csum_rx_good;
186         uint32_t rx_int_delay;
187         boolean_t rx_csum;
188
189         /* OS defined structs */
190         struct net_device *netdev;
191         struct pci_dev *pdev;
192         struct net_device_stats net_stats;
193
194         /* structs defined in ixgb_hw.h */
195         struct ixgb_hw hw;
196         u16 msg_enable;
197         struct ixgb_hw_stats stats;
198         uint32_t alloc_rx_buff_failed;
199 #ifdef CONFIG_PCI_MSI
200         boolean_t have_msi;
201 #endif
202 };
203 #endif /* _IXGB_H_ */