Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | |
Auke Kok | d3f464b | 2006-05-26 09:38:10 -0700 | [diff] [blame] | 4 | Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
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 | |
| 113 | /* How many Tx Descriptors do we need to call netif_wake_queue? */ |
| 114 | #define IXGB_TX_QUEUE_WAKE 16 |
| 115 | |
| 116 | /* How many Rx Buffers do we bundle into one write to the hardware ? */ |
Malli Chilakala | 0c73f58 | 2005-04-28 18:48:06 -0700 | [diff] [blame] | 117 | #define IXGB_RX_BUFFER_WRITE 4 /* Must be power of 2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
| 119 | /* only works for sizes that are powers of 2 */ |
| 120 | #define IXGB_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1))) |
| 121 | |
| 122 | /* wrapper around a pointer to a socket buffer, |
| 123 | * so a DMA handle can be stored along with the buffer */ |
| 124 | struct ixgb_buffer { |
| 125 | struct sk_buff *skb; |
Malli Chilakala | b40a1f0 | 2005-08-11 13:59:44 -0700 | [diff] [blame] | 126 | dma_addr_t dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | unsigned long time_stamp; |
| 128 | uint16_t length; |
| 129 | uint16_t next_to_watch; |
| 130 | }; |
| 131 | |
| 132 | struct ixgb_desc_ring { |
| 133 | /* pointer to the descriptor ring memory */ |
| 134 | void *desc; |
| 135 | /* physical address of the descriptor ring */ |
| 136 | dma_addr_t dma; |
| 137 | /* length of descriptor ring in bytes */ |
| 138 | unsigned int size; |
| 139 | /* number of descriptors in the ring */ |
| 140 | unsigned int count; |
| 141 | /* next descriptor to associate a buffer with */ |
| 142 | unsigned int next_to_use; |
| 143 | /* next descriptor to check for DD status bit */ |
| 144 | unsigned int next_to_clean; |
| 145 | /* array of buffer information structs */ |
| 146 | struct ixgb_buffer *buffer_info; |
| 147 | }; |
| 148 | |
| 149 | #define IXGB_DESC_UNUSED(R) \ |
| 150 | ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ |
| 151 | (R)->next_to_clean - (R)->next_to_use - 1) |
| 152 | |
| 153 | #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) |
| 154 | #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc) |
| 155 | #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc) |
| 156 | #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc) |
| 157 | |
| 158 | /* board specific private data structure */ |
| 159 | |
| 160 | struct ixgb_adapter { |
| 161 | struct timer_list watchdog_timer; |
| 162 | struct vlan_group *vlgrp; |
| 163 | uint32_t bd_number; |
| 164 | uint32_t rx_buffer_len; |
| 165 | uint32_t part_num; |
| 166 | uint16_t link_speed; |
| 167 | uint16_t link_duplex; |
| 168 | spinlock_t tx_lock; |
| 169 | atomic_t irq_sem; |
| 170 | struct work_struct tx_timeout_task; |
| 171 | |
| 172 | struct timer_list blink_timer; |
| 173 | unsigned long led_status; |
| 174 | |
| 175 | /* TX */ |
| 176 | struct ixgb_desc_ring tx_ring; |
| 177 | unsigned long timeo_start; |
| 178 | uint32_t tx_cmd_type; |
| 179 | uint64_t hw_csum_tx_good; |
| 180 | uint64_t hw_csum_tx_error; |
| 181 | uint32_t tx_int_delay; |
Auke Kok | 9b8118d | 2006-05-23 10:35:04 -0700 | [diff] [blame] | 182 | uint32_t tx_timeout_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | boolean_t tx_int_delay_enable; |
| 184 | boolean_t detect_tx_hung; |
| 185 | |
| 186 | /* RX */ |
| 187 | struct ixgb_desc_ring rx_ring; |
| 188 | uint64_t hw_csum_rx_error; |
| 189 | uint64_t hw_csum_rx_good; |
| 190 | uint32_t rx_int_delay; |
| 191 | boolean_t rx_csum; |
| 192 | |
| 193 | /* OS defined structs */ |
| 194 | struct net_device *netdev; |
| 195 | struct pci_dev *pdev; |
| 196 | struct net_device_stats net_stats; |
| 197 | |
| 198 | /* structs defined in ixgb_hw.h */ |
| 199 | struct ixgb_hw hw; |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 200 | u16 msg_enable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | struct ixgb_hw_stats stats; |
Auke Kok | 1dfdd7d | 2006-05-25 13:24:17 -0700 | [diff] [blame] | 202 | uint32_t alloc_rx_buff_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | #ifdef CONFIG_PCI_MSI |
| 204 | boolean_t have_msi; |
| 205 | #endif |
| 206 | }; |
| 207 | #endif /* _IXGB_H_ */ |