patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / net / ixgb / ixgb.h
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2004 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
29 #ifndef _IXGB_H_
30 #define _IXGB_H_
31
32 #include <linux/stddef.h>
33 #include <linux/config.h>
34 #include <linux/module.h>
35 #include <linux/types.h>
36 #include <asm/byteorder.h>
37 #include <linux/init.h>
38 #include <linux/mm.h>
39 #include <linux/errno.h>
40 #include <linux/ioport.h>
41 #include <linux/pci.h>
42 #include <linux/kernel.h>
43 #include <linux/netdevice.h>
44 #include <linux/etherdevice.h>
45 #include <linux/skbuff.h>
46 #include <linux/delay.h>
47 #include <linux/timer.h>
48 #include <linux/slab.h>
49 #include <linux/interrupt.h>
50 #include <linux/string.h>
51 #include <linux/pagemap.h>
52 #include <linux/dma-mapping.h>
53 #include <asm/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 #ifdef NETIF_F_TSO
65 #include <net/checksum.h>
66 #endif
67
68 #include <linux/ethtool.h>
69 #include <linux/if_vlan.h>
70
71 #define BAR_0           0
72 #define BAR_1           1
73 #define BAR_5           5
74
75 struct ixgb_adapter;
76 #include "ixgb_hw.h"
77 #include "ixgb_ee.h"
78 #include "ixgb_ids.h"
79
80 #if _DEBUG_DRIVER_
81 #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args)
82 #else
83 #define IXGB_DBG(args...)
84 #endif
85
86 #define IXGB_ERR(args...) printk(KERN_ERR "ixgb: " args)
87
88 /* Supported Rx Buffer Sizes */
89 #define IXGB_RXBUFFER_2048  2048
90 #define IXGB_RXBUFFER_4096  4096
91 #define IXGB_RXBUFFER_8192  8192
92 #define IXGB_RXBUFFER_16384 16384
93
94 /* How many Tx Descriptors do we need to call netif_wake_queue? */
95 #define IXGB_TX_QUEUE_WAKE 16
96
97 /* How many Rx Buffers do we bundle into one write to the hardware ? */
98 #define IXGB_RX_BUFFER_WRITE    16      /* Must be power of 2 */
99
100 /* only works for sizes that are powers of 2 */
101 #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
102
103 /* wrapper around a pointer to a socket buffer,
104  * so a DMA handle can be stored along with the buffer */
105 struct ixgb_buffer {
106         struct sk_buff *skb;
107         uint64_t dma;
108         unsigned long length;
109         unsigned long time_stamp;
110         unsigned int next_to_watch;
111 };
112
113 struct ixgb_desc_ring {
114         /* pointer to the descriptor ring memory */
115         void *desc;
116         /* physical address of the descriptor ring */
117         dma_addr_t dma;
118         /* length of descriptor ring in bytes */
119         unsigned int size;
120         /* number of descriptors in the ring */
121         unsigned int count;
122         /* next descriptor to associate a buffer with */
123         unsigned int next_to_use;
124         /* next descriptor to check for DD status bit */
125         unsigned int next_to_clean;
126         /* array of buffer information structs */
127         struct ixgb_buffer *buffer_info;
128 };
129
130 #define IXGB_DESC_UNUSED(R) \
131         ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
132         (R)->next_to_clean - (R)->next_to_use - 1)
133
134 #define IXGB_GET_DESC(R, i, type)       (&(((struct type *)((R).desc))[i]))
135 #define IXGB_RX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_rx_desc)
136 #define IXGB_TX_DESC(R, i)              IXGB_GET_DESC(R, i, ixgb_tx_desc)
137 #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
138
139 /* board specific private data structure */
140
141 struct ixgb_adapter {
142         struct timer_list watchdog_timer;
143         struct vlan_group *vlgrp;
144         uint32_t bd_number;
145         uint32_t rx_buffer_len;
146         uint32_t part_num;
147         uint16_t link_speed;
148         uint16_t link_duplex;
149         spinlock_t tx_lock;
150         atomic_t irq_sem;
151         struct work_struct tx_timeout_task;
152
153         struct timer_list blink_timer;
154         unsigned long led_status;
155
156         /* TX */
157         struct ixgb_desc_ring tx_ring;
158         unsigned long timeo_start;
159         uint32_t tx_cmd_type;
160         uint64_t hw_csum_tx_good;
161         uint64_t hw_csum_tx_error;
162         uint32_t tx_int_delay;
163         boolean_t tx_int_delay_enable;
164
165         /* RX */
166         struct ixgb_desc_ring rx_ring;
167         uint64_t hw_csum_rx_error;
168         uint64_t hw_csum_rx_good;
169         uint32_t rx_int_delay;
170         boolean_t raidc;
171         boolean_t rx_csum;
172
173         /* OS defined structs */
174         struct net_device *netdev;
175         struct pci_dev *pdev;
176         struct net_device_stats net_stats;
177
178         /* structs defined in ixgb_hw.h */
179         struct ixgb_hw hw;
180         struct ixgb_hw_stats stats;
181         uint32_t pci_state[16];
182 };
183 #endif                          /* _IXGB_H_ */