ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / net / ixgb / ixgb.h
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
5   
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) 
9   any later version.
10   
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 
14   more details.
15   
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.
19   
20   The full GNU General Public License is included in this distribution in the
21   file called LICENSE.
22   
23   Contact Information:
24   Linux NICS <linux.nics@intel.com>
25   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
27
28 #ifndef _IXGB_H_
29 #define _IXGB_H_
30
31 #include <linux/stddef.h>
32 #include <linux/config.h>
33 #include <linux/module.h>
34 #include <linux/types.h>
35 #include <asm/byteorder.h>
36 #include <linux/init.h>
37 #include <linux/ioport.h>
38 #include <linux/pci.h>
39 #include <linux/netdevice.h>
40 #include <linux/etherdevice.h>
41 #include <linux/skbuff.h>
42 #include <linux/delay.h>
43 #include <linux/timer.h>
44 #include <linux/string.h>
45 #include <linux/pagemap.h>
46 #include <linux/dma-mapping.h>
47 #include <linux/bitops.h>
48 #include <linux/in.h>
49 #include <linux/ip.h>
50 #include <linux/tcp.h>
51 #include <linux/udp.h>
52 #include <net/pkt_sched.h>
53 #include <linux/list.h>
54 #include <linux/workqueue.h>
55 #include <linux/reboot.h>
56 #ifdef NETIF_F_TSO
57 #include <net/checksum.h>
58 #endif
59
60 /* ethtool support */
61 #include <linux/ethtool.h>
62 #include <linux/if_vlan.h>
63
64 struct ixgb_adapter;
65
66 #define BAR_0           0
67 #define BAR_1           1
68 #define BAR_5           5
69
70 #include "ixgb_hw.h"
71 #include "ixgb_ee.h"
72 #include "ixgb_ids.h"
73
74 #if _DEBUG_DRIVER_
75 #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
76 #else
77 #define IXGB_DBG(args...)
78 #endif
79
80 #define IXGB_ERR(args...) printk(KERN_ERR "ixgb: " args)
81
82 /* Supported Rx Buffer Sizes */
83 #define IXGB_RXBUFFER_2048  2048
84 #define IXGB_RXBUFFER_4096  4096
85 #define IXGB_RXBUFFER_8192  8192
86 #define IXGB_RXBUFFER_16384 16384
87
88 /* How many Tx Descriptors do we need to call netif_wake_queue? */
89 #define IXGB_TX_QUEUE_WAKE 16
90
91 /* How many Rx Buffers do we bundle into one write to the hardware ? */
92 #define IXGB_RX_BUFFER_WRITE    16
93
94 /* only works for sizes that are powers of 2 */
95 #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
96
97 /* wrapper around a pointer to a socket buffer,
98  * so a DMA handle can be stored along with the buffer */
99 struct ixgb_buffer {
100         struct sk_buff *skb;
101         uint64_t dma;
102         unsigned long length;
103         unsigned long time_stamp;
104 };
105
106 struct ixgb_desc_ring {
107         /* pointer to the descriptor ring memory  */
108         void *desc;
109         /* physical address of the descriptor ring  */
110         dma_addr_t dma;
111         /* length of descriptor ring in bytes  */
112         unsigned int size;
113         /* number of descriptors in the ring  */
114         unsigned int count;
115         /* next descriptor to associate a buffer with  */
116         unsigned int next_to_use;
117         /* next descriptor to check for DD status bit  */
118         unsigned int next_to_clean;
119         /* array of buffer information structs  */
120         struct ixgb_buffer *buffer_info;
121 };
122
123 #define IXGB_DESC_UNUSED(R) \
124 ((((R)->next_to_clean + (R)->count) - ((R)->next_to_use + 1)) % ((R)->count))
125
126 #define IXGB_GET_DESC(R, i, type)       (&(((struct type *)((R).desc))[i]))
127 #define IXGB_RX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_rx_desc)
128 #define IXGB_TX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_tx_desc)
129 #define IXGB_CONTEXT_DESC(R, i)         IXGB_GET_DESC(R, i, ixgb_context_desc)
130
131 /* board specific private data structure */
132
133 struct ixgb_adapter {
134         struct timer_list watchdog_timer;
135         struct vlan_group *vlgrp;
136         char *id_string;
137         u32 bd_number;
138         u32 rx_buffer_len;
139         u32 part_num;
140         u16 link_speed;
141         u16 link_duplex;
142         atomic_t irq_sem;
143         struct work_struct tx_timeout_task;
144
145 #ifdef ETHTOOL_PHYS_ID
146         struct timer_list blink_timer;
147         unsigned long led_status;
148 #endif
149 #ifdef _INTERNAL_LOOPBACK_DRIVER_
150         struct ixgb_desc_ring diag_tx_ring;
151         struct ixgb_desc_ring diag_rx_ring;
152 #endif
153         /* TX */
154         struct ixgb_desc_ring tx_ring;
155         unsigned long timeo_start;
156         u32 tx_cmd_type;
157         int max_data_per_txd;
158         uint64_t hw_csum_tx_good;
159         uint64_t hw_csum_tx_error;
160         boolean_t tx_csum;
161         u32 tx_int_delay;
162         boolean_t tx_int_delay_enable;
163
164         /* RX */
165         struct ixgb_desc_ring rx_ring;
166         uint64_t hw_csum_rx_error;
167         uint64_t hw_csum_rx_good;
168         u32 rx_int_delay;
169         boolean_t raidc;
170         boolean_t rx_csum;
171
172         /* OS defined structs */
173         struct net_device *netdev;
174         struct pci_dev *pdev;
175         struct net_device_stats net_stats;
176
177         /* structs defined in ixgb_hw.h */
178         struct ixgb_hw hw;
179         struct ixgb_hw_stats stats;
180         u32 pci_state[16];
181         char ifname[IFNAMSIZ];
182 };
183
184 #endif                          /* _IXGB_H_ */