blob: 2224cc2edf1396d338b9786a2dd23af8b77aa581 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2
Auke Kok0abb6eb2006-09-27 12:53:14 -07003 Intel PRO/10GbE Linux driver
Jesse Brandeburgf731a9e2008-07-08 15:53:09 -07004 Copyright(c) 1999 - 2008 Intel Corporation.
Auke Kok0abb6eb2006-09-27 12:53:14 -07005
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 more details.
Auke Kok0abb6eb2006-09-27 12:53:14 -070014
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 You should have received a copy of the GNU General Public License along with
Auke Kok0abb6eb2006-09-27 12:53:14 -070016 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 Contact Information:
23 Linux NICS <linux.nics@intel.com>
Auke Kok0abb6eb2006-09-27 12:53:14 -070024 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#include <net/checksum.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070078/* TX/RX descriptor defines */
Jesse Brandeburg2c21fc62008-07-08 15:52:58 -070079#define DEFAULT_TXD 256
80#define MAX_TXD 4096
81#define MIN_TXD 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/* hardware cannot reliably support more than 512 descriptors owned by
Jesse Brandeburg52035bd2008-07-08 15:52:28 -070084 * hardware descriptor cache otherwise an unreliable ring under heavy
85 * receive load may result */
Jesse Brandeburg2c21fc62008-07-08 15:52:58 -070086#define DEFAULT_RXD 512
87#define MAX_RXD 512
88#define MIN_RXD 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90/* Supported Rx Buffer Sizes */
91#define IXGB_RXBUFFER_2048 2048
92#define IXGB_RXBUFFER_4096 4096
93#define IXGB_RXBUFFER_8192 8192
94#define IXGB_RXBUFFER_16384 16384
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096/* How many Rx Buffers do we bundle into one write to the hardware ? */
Jesse Brandeburga4d3c542006-09-27 12:54:17 -070097#define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Linus Torvalds1da177e2005-04-16 15:20:36 -070099/* wrapper around a pointer to a socket buffer,
100 * so a DMA handle can be stored along with the buffer */
101struct ixgb_buffer {
102 struct sk_buff *skb;
Malli Chilakalab40a1f02005-08-11 13:59:44 -0700103 dma_addr_t dma;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 unsigned long time_stamp;
Joe Perches222441a2008-04-03 10:06:25 -0700105 u16 length;
106 u16 next_to_watch;
Alexander Duyckadeaa902009-12-02 16:46:31 +0000107 u16 mapped_as_page;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108};
109
110struct ixgb_desc_ring {
111 /* pointer to the descriptor ring memory */
112 void *desc;
113 /* physical address of the descriptor ring */
114 dma_addr_t dma;
115 /* length of descriptor ring in bytes */
116 unsigned int size;
117 /* number of descriptors in the ring */
118 unsigned int count;
119 /* next descriptor to associate a buffer with */
120 unsigned int next_to_use;
121 /* next descriptor to check for DD status bit */
122 unsigned int next_to_clean;
123 /* array of buffer information structs */
124 struct ixgb_buffer *buffer_info;
125};
126
127#define IXGB_DESC_UNUSED(R) \
128 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
129 (R)->next_to_clean - (R)->next_to_use - 1)
130
131#define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
132#define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc)
133#define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc)
134#define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc)
135
136/* board specific private data structure */
137
138struct ixgb_adapter {
139 struct timer_list watchdog_timer;
Emil Tantilove2444d92011-01-27 09:14:18 +0000140 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
Joe Perches222441a2008-04-03 10:06:25 -0700141 u32 bd_number;
142 u32 rx_buffer_len;
143 u32 part_num;
144 u16 link_speed;
145 u16 link_duplex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 struct work_struct tx_timeout_task;
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 /* TX */
Jesse Brandeburg7a0eec32006-08-31 14:27:51 -0700149 struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp;
Jesse Brandeburgdfd341e2007-01-06 09:51:38 -0800150 unsigned int restart_queue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 unsigned long timeo_start;
Joe Perches222441a2008-04-03 10:06:25 -0700152 u32 tx_cmd_type;
153 u64 hw_csum_tx_good;
154 u64 hw_csum_tx_error;
155 u32 tx_int_delay;
156 u32 tx_timeout_count;
Joe Perches446490c2008-03-21 11:06:37 -0700157 bool tx_int_delay_enable;
158 bool detect_tx_hung;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
160 /* RX */
161 struct ixgb_desc_ring rx_ring;
Joe Perches222441a2008-04-03 10:06:25 -0700162 u64 hw_csum_rx_error;
163 u64 hw_csum_rx_good;
164 u32 rx_int_delay;
Joe Perches446490c2008-03-21 11:06:37 -0700165 bool rx_csum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167 /* OS defined structs */
Stephen Hemmingerbea33482007-10-03 16:41:36 -0700168 struct napi_struct napi;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 struct net_device *netdev;
170 struct pci_dev *pdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172 /* structs defined in ixgb_hw.h */
173 struct ixgb_hw hw;
Auke Kokec9c3f52006-05-23 10:34:59 -0700174 u16 msg_enable;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 struct ixgb_hw_stats stats;
Joe Perches222441a2008-04-03 10:06:25 -0700176 u32 alloc_rx_buff_failed;
Joe Perches446490c2008-03-21 11:06:37 -0700177 bool have_msi;
Jesse Brandeburgbab2bce2008-03-21 11:06:32 -0700178 unsigned long flags;
179};
180
181enum ixgb_state_t {
182 /* TBD
183 __IXGB_TESTING,
184 __IXGB_RESETTING,
185 */
186 __IXGB_DOWN
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187};
Stephen Hemminger273dc742007-10-29 10:46:13 -0700188
189/* Exported from other modules */
Joe Perches5ccc9212013-09-23 11:37:59 -0700190void ixgb_check_options(struct ixgb_adapter *adapter);
191void ixgb_set_ethtool_ops(struct net_device *netdev);
Stephen Hemminger273dc742007-10-29 10:46:13 -0700192extern char ixgb_driver_name[];
193extern const char ixgb_driver_version[];
194
Joe Perches5ccc9212013-09-23 11:37:59 -0700195void ixgb_set_speed_duplex(struct net_device *netdev);
Michał Mirosławd7ccb8c2011-06-08 08:39:40 +0000196
Joe Perches5ccc9212013-09-23 11:37:59 -0700197int ixgb_up(struct ixgb_adapter *adapter);
198void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog);
199void ixgb_reset(struct ixgb_adapter *adapter);
200int ixgb_setup_rx_resources(struct ixgb_adapter *adapter);
201int ixgb_setup_tx_resources(struct ixgb_adapter *adapter);
202void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
203void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
204void ixgb_update_stats(struct ixgb_adapter *adapter);
Auke Koka9340b82008-03-21 11:06:42 -0700205
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207#endif /* _IXGB_H_ */