| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* | 
 | 2 |  | 
| Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 3 |   Intel PRO/10GbE Linux driver | 
| Jesse Brandeburg | f731a9e | 2008-07-08 15:53:09 -0700 | [diff] [blame] | 4 |   Copyright(c) 1999 - 2008 Intel Corporation. | 
| Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 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 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 |   more details. | 
| Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 14 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 |   You should have received a copy of the GNU General Public License along with | 
| Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 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 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 |   Contact Information: | 
 | 23 |   Linux NICS <linux.nics@intel.com> | 
| Auke Kok | 0abb6eb | 2006-09-27 12:53:14 -0700 | [diff] [blame] | 24 |   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #include <net/checksum.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Joe Perches | 6909c66 | 2010-02-15 08:34:20 +0000 | [diff] [blame] | 78 | #define PFX "ixgb: " | 
 | 79 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #ifdef _DEBUG_DRIVER_ | 
| Joe Perches | d328bc8 | 2010-04-27 00:50:58 +0000 | [diff] [blame] | 81 | #define IXGB_DBG(fmt, args...) printk(KERN_DEBUG PFX fmt, ##args) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #else | 
| Joe Perches | d328bc8 | 2010-04-27 00:50:58 +0000 | [diff] [blame] | 83 | #define IXGB_DBG(fmt, args...)				\ | 
 | 84 | do {							\ | 
 | 85 | 	if (0)						\ | 
 | 86 | 		printk(KERN_DEBUG PFX fmt, ##args);	\ | 
 | 87 | } while (0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | #endif | 
 | 89 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | /* TX/RX descriptor defines */ | 
| Jesse Brandeburg | 2c21fc6 | 2008-07-08 15:52:58 -0700 | [diff] [blame] | 91 | #define DEFAULT_TXD      256 | 
 | 92 | #define MAX_TXD         4096 | 
 | 93 | #define MIN_TXD           64 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 |  | 
 | 95 | /* hardware cannot reliably support more than 512 descriptors owned by | 
| Jesse Brandeburg | 52035bd | 2008-07-08 15:52:28 -0700 | [diff] [blame] | 96 |  * hardware descriptor cache otherwise an unreliable ring under heavy | 
 | 97 |  * receive load may result */ | 
| Jesse Brandeburg | 2c21fc6 | 2008-07-08 15:52:58 -0700 | [diff] [blame] | 98 | #define DEFAULT_RXD      512 | 
 | 99 | #define MAX_RXD          512 | 
 | 100 | #define MIN_RXD           64 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 |  | 
 | 102 | /* Supported Rx Buffer Sizes */ | 
 | 103 | #define IXGB_RXBUFFER_2048  2048 | 
 | 104 | #define IXGB_RXBUFFER_4096  4096 | 
 | 105 | #define IXGB_RXBUFFER_8192  8192 | 
 | 106 | #define IXGB_RXBUFFER_16384 16384 | 
 | 107 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | /* How many Rx Buffers do we bundle into one write to the hardware ? */ | 
| Jesse Brandeburg | a4d3c54 | 2006-09-27 12:54:17 -0700 | [diff] [blame] | 109 | #define IXGB_RX_BUFFER_WRITE	8	/* Must be power of 2 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | /* wrapper around a pointer to a socket buffer, | 
 | 112 |  * so a DMA handle can be stored along with the buffer */ | 
 | 113 | struct ixgb_buffer { | 
 | 114 | 	struct sk_buff *skb; | 
| Malli Chilakala | b40a1f0 | 2005-08-11 13:59:44 -0700 | [diff] [blame] | 115 | 	dma_addr_t dma; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | 	unsigned long time_stamp; | 
| Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 117 | 	u16 length; | 
 | 118 | 	u16 next_to_watch; | 
| Alexander Duyck | adeaa90 | 2009-12-02 16:46:31 +0000 | [diff] [blame] | 119 | 	u16 mapped_as_page; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | }; | 
 | 121 |  | 
 | 122 | struct ixgb_desc_ring { | 
 | 123 | 	/* pointer to the descriptor ring memory */ | 
 | 124 | 	void *desc; | 
 | 125 | 	/* physical address of the descriptor ring */ | 
 | 126 | 	dma_addr_t dma; | 
 | 127 | 	/* length of descriptor ring in bytes */ | 
 | 128 | 	unsigned int size; | 
 | 129 | 	/* number of descriptors in the ring */ | 
 | 130 | 	unsigned int count; | 
 | 131 | 	/* next descriptor to associate a buffer with */ | 
 | 132 | 	unsigned int next_to_use; | 
 | 133 | 	/* next descriptor to check for DD status bit */ | 
 | 134 | 	unsigned int next_to_clean; | 
 | 135 | 	/* array of buffer information structs */ | 
 | 136 | 	struct ixgb_buffer *buffer_info; | 
 | 137 | }; | 
 | 138 |  | 
 | 139 | #define IXGB_DESC_UNUSED(R) \ | 
 | 140 | 	((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ | 
 | 141 | 	(R)->next_to_clean - (R)->next_to_use - 1) | 
 | 142 |  | 
 | 143 | #define IXGB_GET_DESC(R, i, type)	(&(((struct type *)((R).desc))[i])) | 
 | 144 | #define IXGB_RX_DESC(R, i)		IXGB_GET_DESC(R, i, ixgb_rx_desc) | 
 | 145 | #define IXGB_TX_DESC(R, i)		IXGB_GET_DESC(R, i, ixgb_tx_desc) | 
 | 146 | #define IXGB_CONTEXT_DESC(R, i)	IXGB_GET_DESC(R, i, ixgb_context_desc) | 
 | 147 |  | 
 | 148 | /* board specific private data structure */ | 
 | 149 |  | 
 | 150 | struct ixgb_adapter { | 
 | 151 | 	struct timer_list watchdog_timer; | 
| Emil Tantilov | e2444d9 | 2011-01-27 09:14:18 +0000 | [diff] [blame] | 152 | 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; | 
| Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 153 | 	u32 bd_number; | 
 | 154 | 	u32 rx_buffer_len; | 
 | 155 | 	u32 part_num; | 
 | 156 | 	u16 link_speed; | 
 | 157 | 	u16 link_duplex; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | 	struct work_struct tx_timeout_task; | 
 | 159 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | 	/* TX */ | 
| Jesse Brandeburg | 7a0eec3 | 2006-08-31 14:27:51 -0700 | [diff] [blame] | 161 | 	struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp; | 
| Jesse Brandeburg | dfd341e | 2007-01-06 09:51:38 -0800 | [diff] [blame] | 162 | 	unsigned int restart_queue; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | 	unsigned long timeo_start; | 
| Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 164 | 	u32 tx_cmd_type; | 
 | 165 | 	u64 hw_csum_tx_good; | 
 | 166 | 	u64 hw_csum_tx_error; | 
 | 167 | 	u32 tx_int_delay; | 
 | 168 | 	u32 tx_timeout_count; | 
| Joe Perches | 446490c | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 169 | 	bool tx_int_delay_enable; | 
 | 170 | 	bool detect_tx_hung; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 |  | 
 | 172 | 	/* RX */ | 
 | 173 | 	struct ixgb_desc_ring rx_ring; | 
| Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 174 | 	u64 hw_csum_rx_error; | 
 | 175 | 	u64 hw_csum_rx_good; | 
 | 176 | 	u32 rx_int_delay; | 
| Joe Perches | 446490c | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 177 | 	bool rx_csum; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 |  | 
 | 179 | 	/* OS defined structs */ | 
| Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 180 | 	struct napi_struct napi; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | 	struct net_device *netdev; | 
 | 182 | 	struct pci_dev *pdev; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 |  | 
 | 184 | 	/* structs defined in ixgb_hw.h */ | 
 | 185 | 	struct ixgb_hw hw; | 
| Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 186 | 	u16 msg_enable; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | 	struct ixgb_hw_stats stats; | 
| Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 188 | 	u32 alloc_rx_buff_failed; | 
| Joe Perches | 446490c | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 189 | 	bool have_msi; | 
| Jesse Brandeburg | bab2bce | 2008-03-21 11:06:32 -0700 | [diff] [blame] | 190 | 	unsigned long flags; | 
 | 191 | }; | 
 | 192 |  | 
 | 193 | enum ixgb_state_t { | 
 | 194 | 	/* TBD | 
 | 195 | 	__IXGB_TESTING, | 
 | 196 | 	__IXGB_RESETTING, | 
 | 197 | 	*/ | 
 | 198 | 	__IXGB_DOWN | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | }; | 
| Stephen Hemminger | 273dc74 | 2007-10-29 10:46:13 -0700 | [diff] [blame] | 200 |  | 
 | 201 | /* Exported from other modules */ | 
 | 202 | extern void ixgb_check_options(struct ixgb_adapter *adapter); | 
 | 203 | extern void ixgb_set_ethtool_ops(struct net_device *netdev); | 
 | 204 | extern char ixgb_driver_name[]; | 
 | 205 | extern const char ixgb_driver_version[]; | 
 | 206 |  | 
| Auke Kok | a9340b8 | 2008-03-21 11:06:42 -0700 | [diff] [blame] | 207 | extern int ixgb_up(struct ixgb_adapter *adapter); | 
 | 208 | extern void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog); | 
 | 209 | extern void ixgb_reset(struct ixgb_adapter *adapter); | 
 | 210 | extern int ixgb_setup_rx_resources(struct ixgb_adapter *adapter); | 
 | 211 | extern int ixgb_setup_tx_resources(struct ixgb_adapter *adapter); | 
 | 212 | extern void ixgb_free_rx_resources(struct ixgb_adapter *adapter); | 
 | 213 | extern void ixgb_free_tx_resources(struct ixgb_adapter *adapter); | 
 | 214 | extern void ixgb_update_stats(struct ixgb_adapter *adapter); | 
 | 215 |  | 
 | 216 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | #endif /* _IXGB_H_ */ |