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 |
| 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 |
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> |
| 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 | #ifdef _DEBUG_DRIVER_ |
| 81 | #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args) |
| 82 | #else |
| 83 | #define IXGB_DBG(args...) |
| 84 | #endif |
| 85 | |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 86 | #define PFX "ixgb: " |
| 87 | #define DPRINTK(nlevel, klevel, fmt, args...) \ |
| 88 | (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \ |
| 89 | printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \ |
| 90 | __FUNCTION__ , ## args)) |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
| 93 | /* TX/RX descriptor defines */ |
| 94 | #define DEFAULT_TXD 256 |
| 95 | #define MAX_TXD 4096 |
| 96 | #define MIN_TXD 64 |
| 97 | |
| 98 | /* hardware cannot reliably support more than 512 descriptors owned by |
| 99 | * hardware descrioptor cache otherwise an unreliable ring under heavy |
| 100 | * recieve load may result */ |
| 101 | /* #define DEFAULT_RXD 1024 */ |
| 102 | /* #define MAX_RXD 4096 */ |
| 103 | #define DEFAULT_RXD 512 |
| 104 | #define MAX_RXD 512 |
| 105 | #define MIN_RXD 64 |
| 106 | |
| 107 | /* Supported Rx Buffer Sizes */ |
| 108 | #define IXGB_RXBUFFER_2048 2048 |
| 109 | #define IXGB_RXBUFFER_4096 4096 |
| 110 | #define IXGB_RXBUFFER_8192 8192 |
| 111 | #define IXGB_RXBUFFER_16384 16384 |
| 112 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | /* 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] | 114 | #define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | /* only works for sizes that are powers of 2 */ |
| 117 | #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1))) |
| 118 | |
| 119 | /* wrapper around a pointer to a socket buffer, |
| 120 | * so a DMA handle can be stored along with the buffer */ |
| 121 | struct ixgb_buffer { |
| 122 | struct sk_buff *skb; |
Malli Chilakala | b40a1f0 | 2005-08-11 13:59:44 -0700 | [diff] [blame] | 123 | dma_addr_t dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | unsigned long time_stamp; |
| 125 | uint16_t length; |
| 126 | uint16_t next_to_watch; |
| 127 | }; |
| 128 | |
| 129 | struct ixgb_desc_ring { |
| 130 | /* pointer to the descriptor ring memory */ |
| 131 | void *desc; |
| 132 | /* physical address of the descriptor ring */ |
| 133 | dma_addr_t dma; |
| 134 | /* length of descriptor ring in bytes */ |
| 135 | unsigned int size; |
| 136 | /* number of descriptors in the ring */ |
| 137 | unsigned int count; |
| 138 | /* next descriptor to associate a buffer with */ |
| 139 | unsigned int next_to_use; |
| 140 | /* next descriptor to check for DD status bit */ |
| 141 | unsigned int next_to_clean; |
| 142 | /* array of buffer information structs */ |
| 143 | struct ixgb_buffer *buffer_info; |
| 144 | }; |
| 145 | |
| 146 | #define IXGB_DESC_UNUSED(R) \ |
| 147 | ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ |
| 148 | (R)->next_to_clean - (R)->next_to_use - 1) |
| 149 | |
| 150 | #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) |
| 151 | #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc) |
| 152 | #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc) |
| 153 | #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc) |
| 154 | |
| 155 | /* board specific private data structure */ |
| 156 | |
| 157 | struct ixgb_adapter { |
| 158 | struct timer_list watchdog_timer; |
| 159 | struct vlan_group *vlgrp; |
| 160 | uint32_t bd_number; |
| 161 | uint32_t rx_buffer_len; |
| 162 | uint32_t part_num; |
| 163 | uint16_t link_speed; |
| 164 | uint16_t link_duplex; |
| 165 | spinlock_t tx_lock; |
| 166 | atomic_t irq_sem; |
| 167 | struct work_struct tx_timeout_task; |
| 168 | |
| 169 | struct timer_list blink_timer; |
| 170 | unsigned long led_status; |
| 171 | |
| 172 | /* TX */ |
Jesse Brandeburg | 7a0eec3 | 2006-08-31 14:27:51 -0700 | [diff] [blame] | 173 | struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp; |
Jesse Brandeburg | dfd341e | 2007-01-06 09:51:38 -0800 | [diff] [blame^] | 174 | unsigned int restart_queue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | unsigned long timeo_start; |
| 176 | uint32_t tx_cmd_type; |
| 177 | uint64_t hw_csum_tx_good; |
| 178 | uint64_t hw_csum_tx_error; |
| 179 | uint32_t tx_int_delay; |
Auke Kok | 9b8118d | 2006-05-23 10:35:04 -0700 | [diff] [blame] | 180 | uint32_t tx_timeout_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | boolean_t tx_int_delay_enable; |
| 182 | boolean_t detect_tx_hung; |
| 183 | |
| 184 | /* RX */ |
| 185 | struct ixgb_desc_ring rx_ring; |
| 186 | uint64_t hw_csum_rx_error; |
| 187 | uint64_t hw_csum_rx_good; |
| 188 | uint32_t rx_int_delay; |
| 189 | boolean_t rx_csum; |
| 190 | |
| 191 | /* OS defined structs */ |
| 192 | struct net_device *netdev; |
| 193 | struct pci_dev *pdev; |
| 194 | struct net_device_stats net_stats; |
| 195 | |
| 196 | /* structs defined in ixgb_hw.h */ |
| 197 | struct ixgb_hw hw; |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 198 | u16 msg_enable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | struct ixgb_hw_stats stats; |
Auke Kok | 1dfdd7d | 2006-05-25 13:24:17 -0700 | [diff] [blame] | 200 | uint32_t alloc_rx_buff_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | #ifdef CONFIG_PCI_MSI |
| 202 | boolean_t have_msi; |
| 203 | #endif |
| 204 | }; |
| 205 | #endif /* _IXGB_H_ */ |