Jeff Kirsher | ae06c70 | 2018-03-22 10:08:48 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jeff Kirsher | 51dce24 | 2018-04-26 08:08:09 -0700 | [diff] [blame] | 2 | /* Copyright(c) 1999 - 2008 Intel Corporation. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
| 4 | #ifndef _IXGB_H_ |
| 5 | #define _IXGB_H_ |
| 6 | |
| 7 | #include <linux/stddef.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/module.h> |
| 9 | #include <linux/types.h> |
| 10 | #include <asm/byteorder.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/mm.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/ioport.h> |
| 14 | #include <linux/pci.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/netdevice.h> |
| 17 | #include <linux/etherdevice.h> |
| 18 | #include <linux/skbuff.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/timer.h> |
| 21 | #include <linux/slab.h> |
| 22 | #include <linux/vmalloc.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/string.h> |
| 25 | #include <linux/pagemap.h> |
| 26 | #include <linux/dma-mapping.h> |
| 27 | #include <linux/bitops.h> |
| 28 | #include <asm/io.h> |
| 29 | #include <asm/irq.h> |
| 30 | #include <linux/capability.h> |
| 31 | #include <linux/in.h> |
| 32 | #include <linux/ip.h> |
| 33 | #include <linux/tcp.h> |
| 34 | #include <linux/udp.h> |
| 35 | #include <net/pkt_sched.h> |
| 36 | #include <linux/list.h> |
| 37 | #include <linux/reboot.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <net/checksum.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | #include <linux/ethtool.h> |
| 41 | #include <linux/if_vlan.h> |
| 42 | |
| 43 | #define BAR_0 0 |
| 44 | #define BAR_1 1 |
| 45 | #define BAR_5 5 |
| 46 | |
| 47 | struct ixgb_adapter; |
| 48 | #include "ixgb_hw.h" |
| 49 | #include "ixgb_ee.h" |
| 50 | #include "ixgb_ids.h" |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | /* TX/RX descriptor defines */ |
Jesse Brandeburg | 2c21fc6 | 2008-07-08 15:52:58 -0700 | [diff] [blame] | 53 | #define DEFAULT_TXD 256 |
| 54 | #define MAX_TXD 4096 |
| 55 | #define MIN_TXD 64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | /* hardware cannot reliably support more than 512 descriptors owned by |
Jesse Brandeburg | 52035bd | 2008-07-08 15:52:28 -0700 | [diff] [blame] | 58 | * hardware descriptor cache otherwise an unreliable ring under heavy |
| 59 | * receive load may result */ |
Jesse Brandeburg | 2c21fc6 | 2008-07-08 15:52:58 -0700 | [diff] [blame] | 60 | #define DEFAULT_RXD 512 |
| 61 | #define MAX_RXD 512 |
| 62 | #define MIN_RXD 64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | /* Supported Rx Buffer Sizes */ |
| 65 | #define IXGB_RXBUFFER_2048 2048 |
| 66 | #define IXGB_RXBUFFER_4096 4096 |
| 67 | #define IXGB_RXBUFFER_8192 8192 |
| 68 | #define IXGB_RXBUFFER_16384 16384 |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | /* 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] | 71 | #define IXGB_RX_BUFFER_WRITE 8 /* Must be power of 2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | /* wrapper around a pointer to a socket buffer, |
| 74 | * so a DMA handle can be stored along with the buffer */ |
| 75 | struct ixgb_buffer { |
| 76 | struct sk_buff *skb; |
Malli Chilakala | b40a1f0 | 2005-08-11 13:59:44 -0700 | [diff] [blame] | 77 | dma_addr_t dma; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | unsigned long time_stamp; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 79 | u16 length; |
| 80 | u16 next_to_watch; |
Alexander Duyck | adeaa90 | 2009-12-02 16:46:31 +0000 | [diff] [blame] | 81 | u16 mapped_as_page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | struct ixgb_desc_ring { |
| 85 | /* pointer to the descriptor ring memory */ |
| 86 | void *desc; |
| 87 | /* physical address of the descriptor ring */ |
| 88 | dma_addr_t dma; |
| 89 | /* length of descriptor ring in bytes */ |
| 90 | unsigned int size; |
| 91 | /* number of descriptors in the ring */ |
| 92 | unsigned int count; |
| 93 | /* next descriptor to associate a buffer with */ |
| 94 | unsigned int next_to_use; |
| 95 | /* next descriptor to check for DD status bit */ |
| 96 | unsigned int next_to_clean; |
| 97 | /* array of buffer information structs */ |
| 98 | struct ixgb_buffer *buffer_info; |
| 99 | }; |
| 100 | |
| 101 | #define IXGB_DESC_UNUSED(R) \ |
| 102 | ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ |
| 103 | (R)->next_to_clean - (R)->next_to_use - 1) |
| 104 | |
| 105 | #define IXGB_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) |
| 106 | #define IXGB_RX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_rx_desc) |
| 107 | #define IXGB_TX_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_tx_desc) |
| 108 | #define IXGB_CONTEXT_DESC(R, i) IXGB_GET_DESC(R, i, ixgb_context_desc) |
| 109 | |
| 110 | /* board specific private data structure */ |
| 111 | |
| 112 | struct ixgb_adapter { |
| 113 | struct timer_list watchdog_timer; |
Emil Tantilov | e2444d9 | 2011-01-27 09:14:18 +0000 | [diff] [blame] | 114 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 115 | u32 bd_number; |
| 116 | u32 rx_buffer_len; |
| 117 | u32 part_num; |
| 118 | u16 link_speed; |
| 119 | u16 link_duplex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | struct work_struct tx_timeout_task; |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | /* TX */ |
Jesse Brandeburg | 7a0eec3 | 2006-08-31 14:27:51 -0700 | [diff] [blame] | 123 | struct ixgb_desc_ring tx_ring ____cacheline_aligned_in_smp; |
Jesse Brandeburg | dfd341e | 2007-01-06 09:51:38 -0800 | [diff] [blame] | 124 | unsigned int restart_queue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | unsigned long timeo_start; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 126 | u32 tx_cmd_type; |
| 127 | u64 hw_csum_tx_good; |
| 128 | u64 hw_csum_tx_error; |
| 129 | u32 tx_int_delay; |
| 130 | u32 tx_timeout_count; |
Joe Perches | 446490ca | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 131 | bool tx_int_delay_enable; |
| 132 | bool detect_tx_hung; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | /* RX */ |
| 135 | struct ixgb_desc_ring rx_ring; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 136 | u64 hw_csum_rx_error; |
| 137 | u64 hw_csum_rx_good; |
| 138 | u32 rx_int_delay; |
Joe Perches | 446490ca | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 139 | bool rx_csum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | /* OS defined structs */ |
Stephen Hemminger | bea3348 | 2007-10-03 16:41:36 -0700 | [diff] [blame] | 142 | struct napi_struct napi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | struct net_device *netdev; |
| 144 | struct pci_dev *pdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | /* structs defined in ixgb_hw.h */ |
| 147 | struct ixgb_hw hw; |
Auke Kok | ec9c3f5 | 2006-05-23 10:34:59 -0700 | [diff] [blame] | 148 | u16 msg_enable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | struct ixgb_hw_stats stats; |
Joe Perches | 222441a | 2008-04-03 10:06:25 -0700 | [diff] [blame] | 150 | u32 alloc_rx_buff_failed; |
Joe Perches | 446490ca | 2008-03-21 11:06:37 -0700 | [diff] [blame] | 151 | bool have_msi; |
Jesse Brandeburg | bab2bce | 2008-03-21 11:06:32 -0700 | [diff] [blame] | 152 | unsigned long flags; |
| 153 | }; |
| 154 | |
| 155 | enum ixgb_state_t { |
| 156 | /* TBD |
| 157 | __IXGB_TESTING, |
| 158 | __IXGB_RESETTING, |
| 159 | */ |
| 160 | __IXGB_DOWN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | }; |
Stephen Hemminger | 273dc74 | 2007-10-29 10:46:13 -0700 | [diff] [blame] | 162 | |
| 163 | /* Exported from other modules */ |
Joe Perches | 5ccc921 | 2013-09-23 11:37:59 -0700 | [diff] [blame] | 164 | void ixgb_check_options(struct ixgb_adapter *adapter); |
| 165 | void ixgb_set_ethtool_ops(struct net_device *netdev); |
Stephen Hemminger | 273dc74 | 2007-10-29 10:46:13 -0700 | [diff] [blame] | 166 | extern char ixgb_driver_name[]; |
| 167 | extern const char ixgb_driver_version[]; |
| 168 | |
Joe Perches | 5ccc921 | 2013-09-23 11:37:59 -0700 | [diff] [blame] | 169 | void ixgb_set_speed_duplex(struct net_device *netdev); |
Michał Mirosław | d7ccb8c | 2011-06-08 08:39:40 +0000 | [diff] [blame] | 170 | |
Joe Perches | 5ccc921 | 2013-09-23 11:37:59 -0700 | [diff] [blame] | 171 | int ixgb_up(struct ixgb_adapter *adapter); |
| 172 | void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog); |
| 173 | void ixgb_reset(struct ixgb_adapter *adapter); |
| 174 | int ixgb_setup_rx_resources(struct ixgb_adapter *adapter); |
| 175 | int ixgb_setup_tx_resources(struct ixgb_adapter *adapter); |
| 176 | void ixgb_free_rx_resources(struct ixgb_adapter *adapter); |
| 177 | void ixgb_free_tx_resources(struct ixgb_adapter *adapter); |
| 178 | void ixgb_update_stats(struct ixgb_adapter *adapter); |
Auke Kok | a9340b8 | 2008-03-21 11:06:42 -0700 | [diff] [blame] | 179 | |
| 180 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | #endif /* _IXGB_H_ */ |