| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 1 | /******************************************************************************* | 
 | 2 |  | 
 | 3 |   Intel(R) 82576 Virtual Function Linux driver | 
 | 4 |   Copyright(c) 2009 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 | 
 | 13 |   more details. | 
 | 14 |  | 
 | 15 |   You should have received a copy of the GNU General Public License along with | 
 | 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 |  | 
 | 22 |   Contact Information: | 
 | 23 |   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | 
 | 24 |   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | 
 | 25 |  | 
 | 26 | *******************************************************************************/ | 
 | 27 |  | 
 | 28 | /* Linux PRO/1000 Ethernet Driver main header file */ | 
 | 29 |  | 
 | 30 | #ifndef _IGBVF_H_ | 
 | 31 | #define _IGBVF_H_ | 
 | 32 |  | 
 | 33 | #include <linux/types.h> | 
 | 34 | #include <linux/timer.h> | 
 | 35 | #include <linux/io.h> | 
 | 36 | #include <linux/netdevice.h> | 
 | 37 |  | 
 | 38 |  | 
 | 39 | #include "vf.h" | 
 | 40 |  | 
 | 41 | /* Forward declarations */ | 
 | 42 | struct igbvf_info; | 
 | 43 | struct igbvf_adapter; | 
 | 44 |  | 
 | 45 | /* Interrupt defines */ | 
 | 46 | #define IGBVF_START_ITR                 648 /* ~6000 ints/sec */ | 
 | 47 |  | 
| Martin Olsson | 98a1708 | 2009-04-22 18:21:29 +0200 | [diff] [blame] | 48 | /* Interrupt modes, as used by the IntMode parameter */ | 
| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 49 | #define IGBVF_INT_MODE_LEGACY           0 | 
 | 50 | #define IGBVF_INT_MODE_MSI              1 | 
 | 51 | #define IGBVF_INT_MODE_MSIX             2 | 
 | 52 |  | 
 | 53 | /* Tx/Rx descriptor defines */ | 
 | 54 | #define IGBVF_DEFAULT_TXD               256 | 
 | 55 | #define IGBVF_MAX_TXD                   4096 | 
 | 56 | #define IGBVF_MIN_TXD                   80 | 
 | 57 |  | 
 | 58 | #define IGBVF_DEFAULT_RXD               256 | 
 | 59 | #define IGBVF_MAX_RXD                   4096 | 
 | 60 | #define IGBVF_MIN_RXD                   80 | 
 | 61 |  | 
 | 62 | #define IGBVF_MIN_ITR_USECS             10 /* 100000 irq/sec */ | 
 | 63 | #define IGBVF_MAX_ITR_USECS             10000 /* 100    irq/sec */ | 
 | 64 |  | 
 | 65 | /* RX descriptor control thresholds. | 
 | 66 |  * PTHRESH - MAC will consider prefetch if it has fewer than this number of | 
 | 67 |  *           descriptors available in its onboard memory. | 
 | 68 |  *           Setting this to 0 disables RX descriptor prefetch. | 
 | 69 |  * HTHRESH - MAC will only prefetch if there are at least this many descriptors | 
 | 70 |  *           available in host memory. | 
 | 71 |  *           If PTHRESH is 0, this should also be 0. | 
 | 72 |  * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back | 
 | 73 |  *           descriptors until either it has this many to write back, or the | 
 | 74 |  *           ITR timer expires. | 
 | 75 |  */ | 
 | 76 | #define IGBVF_RX_PTHRESH                16 | 
 | 77 | #define IGBVF_RX_HTHRESH                8 | 
 | 78 | #define IGBVF_RX_WTHRESH                1 | 
 | 79 |  | 
 | 80 | /* this is the size past which hardware will drop packets when setting LPE=0 */ | 
 | 81 | #define MAXIMUM_ETHERNET_VLAN_SIZE      1522 | 
 | 82 |  | 
 | 83 | #define IGBVF_FC_PAUSE_TIME             0x0680 /* 858 usec */ | 
 | 84 |  | 
 | 85 | /* How many Tx Descriptors do we need to call netif_wake_queue ? */ | 
 | 86 | #define IGBVF_TX_QUEUE_WAKE             32 | 
 | 87 | /* How many Rx Buffers do we bundle into one write to the hardware ? */ | 
 | 88 | #define IGBVF_RX_BUFFER_WRITE           16 /* Must be power of 2 */ | 
 | 89 |  | 
 | 90 | #define AUTO_ALL_MODES                  0 | 
 | 91 | #define IGBVF_EEPROM_APME               0x0400 | 
 | 92 |  | 
 | 93 | #define IGBVF_MNG_VLAN_NONE             (-1) | 
 | 94 |  | 
 | 95 | /* Number of packet split data buffers (not including the header buffer) */ | 
 | 96 | #define PS_PAGE_BUFFERS                 (MAX_PS_BUFFERS - 1) | 
 | 97 |  | 
 | 98 | enum igbvf_boards { | 
 | 99 | 	board_vf, | 
 | 100 | }; | 
 | 101 |  | 
 | 102 | struct igbvf_queue_stats { | 
 | 103 | 	u64 packets; | 
 | 104 | 	u64 bytes; | 
 | 105 | }; | 
 | 106 |  | 
 | 107 | /* | 
 | 108 |  * wrappers around a pointer to a socket buffer, | 
 | 109 |  * so a DMA handle can be stored along with the buffer | 
 | 110 |  */ | 
 | 111 | struct igbvf_buffer { | 
 | 112 | 	dma_addr_t dma; | 
 | 113 | 	struct sk_buff *skb; | 
 | 114 | 	union { | 
 | 115 | 		/* Tx */ | 
 | 116 | 		struct { | 
 | 117 | 			unsigned long time_stamp; | 
 | 118 | 			u16 length; | 
 | 119 | 			u16 next_to_watch; | 
| Alexander Duyck | a7d5ca4 | 2009-12-02 16:47:37 +0000 | [diff] [blame] | 120 | 			u16 mapped_as_page; | 
| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 121 | 		}; | 
 | 122 | 		/* Rx */ | 
 | 123 | 		struct { | 
 | 124 | 			struct page *page; | 
 | 125 | 			u64 page_dma; | 
 | 126 | 			unsigned int page_offset; | 
 | 127 | 		}; | 
 | 128 | 	}; | 
 | 129 | 	struct page *page; | 
 | 130 | }; | 
 | 131 |  | 
 | 132 | union igbvf_desc { | 
 | 133 | 	union e1000_adv_rx_desc rx_desc; | 
 | 134 | 	union e1000_adv_tx_desc tx_desc; | 
 | 135 | 	struct e1000_adv_tx_context_desc tx_context_desc; | 
 | 136 | }; | 
 | 137 |  | 
 | 138 | struct igbvf_ring { | 
 | 139 | 	struct igbvf_adapter *adapter;  /* backlink */ | 
 | 140 | 	union igbvf_desc *desc;         /* pointer to ring memory  */ | 
 | 141 | 	dma_addr_t dma;                 /* phys address of ring    */ | 
 | 142 | 	unsigned int size;              /* length of ring in bytes */ | 
 | 143 | 	unsigned int count;             /* number of desc. in ring */ | 
 | 144 |  | 
 | 145 | 	u16 next_to_use; | 
 | 146 | 	u16 next_to_clean; | 
 | 147 |  | 
 | 148 | 	u16 head; | 
 | 149 | 	u16 tail; | 
 | 150 |  | 
 | 151 | 	/* array of buffer information structs */ | 
 | 152 | 	struct igbvf_buffer *buffer_info; | 
 | 153 | 	struct napi_struct napi; | 
 | 154 |  | 
 | 155 | 	char name[IFNAMSIZ + 5]; | 
 | 156 | 	u32 eims_value; | 
 | 157 | 	u32 itr_val; | 
 | 158 | 	u16 itr_register; | 
 | 159 | 	int set_itr; | 
 | 160 |  | 
 | 161 | 	struct sk_buff *rx_skb_top; | 
 | 162 |  | 
 | 163 | 	struct igbvf_queue_stats stats; | 
 | 164 | }; | 
 | 165 |  | 
 | 166 | /* board specific private data structure */ | 
 | 167 | struct igbvf_adapter { | 
 | 168 | 	struct timer_list watchdog_timer; | 
 | 169 | 	struct timer_list blink_timer; | 
 | 170 |  | 
 | 171 | 	struct work_struct reset_task; | 
 | 172 | 	struct work_struct watchdog_task; | 
 | 173 |  | 
 | 174 | 	const struct igbvf_info *ei; | 
 | 175 |  | 
 | 176 | 	struct vlan_group *vlgrp; | 
 | 177 | 	u32 bd_number; | 
 | 178 | 	u32 rx_buffer_len; | 
 | 179 | 	u32 polling_interval; | 
 | 180 | 	u16 mng_vlan_id; | 
 | 181 | 	u16 link_speed; | 
 | 182 | 	u16 link_duplex; | 
 | 183 |  | 
 | 184 | 	spinlock_t tx_queue_lock; /* prevent concurrent tail updates */ | 
 | 185 |  | 
 | 186 | 	/* track device up/down/testing state */ | 
 | 187 | 	unsigned long state; | 
 | 188 |  | 
 | 189 | 	/* Interrupt Throttle Rate */ | 
 | 190 | 	u32 itr; | 
 | 191 | 	u32 itr_setting; | 
 | 192 | 	u16 tx_itr; | 
 | 193 | 	u16 rx_itr; | 
 | 194 |  | 
 | 195 | 	/* | 
 | 196 | 	 * Tx | 
 | 197 | 	 */ | 
 | 198 | 	struct igbvf_ring *tx_ring /* One per active queue */ | 
 | 199 | 	____cacheline_aligned_in_smp; | 
 | 200 |  | 
| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 201 | 	unsigned int restart_queue; | 
 | 202 | 	u32 txd_cmd; | 
 | 203 |  | 
 | 204 | 	bool detect_tx_hung; | 
 | 205 | 	u8 tx_timeout_factor; | 
 | 206 |  | 
 | 207 | 	u32 tx_int_delay; | 
 | 208 | 	u32 tx_abs_int_delay; | 
 | 209 |  | 
 | 210 | 	unsigned int total_tx_bytes; | 
 | 211 | 	unsigned int total_tx_packets; | 
 | 212 | 	unsigned int total_rx_bytes; | 
 | 213 | 	unsigned int total_rx_packets; | 
 | 214 |  | 
 | 215 | 	/* Tx stats */ | 
 | 216 | 	u32 tx_timeout_count; | 
 | 217 | 	u32 tx_fifo_head; | 
 | 218 | 	u32 tx_head_addr; | 
 | 219 | 	u32 tx_fifo_size; | 
 | 220 | 	u32 tx_dma_failed; | 
 | 221 |  | 
 | 222 | 	/* | 
 | 223 | 	 * Rx | 
 | 224 | 	 */ | 
 | 225 | 	struct igbvf_ring *rx_ring; | 
 | 226 |  | 
 | 227 | 	u32 rx_int_delay; | 
 | 228 | 	u32 rx_abs_int_delay; | 
 | 229 |  | 
 | 230 | 	/* Rx stats */ | 
 | 231 | 	u64 hw_csum_err; | 
 | 232 | 	u64 hw_csum_good; | 
 | 233 | 	u64 rx_hdr_split; | 
 | 234 | 	u32 alloc_rx_buff_failed; | 
 | 235 | 	u32 rx_dma_failed; | 
 | 236 |  | 
 | 237 | 	unsigned int rx_ps_hdr_size; | 
 | 238 | 	u32 max_frame_size; | 
 | 239 | 	u32 min_frame_size; | 
 | 240 |  | 
 | 241 | 	/* OS defined structs */ | 
 | 242 | 	struct net_device *netdev; | 
 | 243 | 	struct pci_dev *pdev; | 
 | 244 | 	struct net_device_stats net_stats; | 
 | 245 | 	spinlock_t stats_lock;      /* prevent concurrent stats updates */ | 
 | 246 |  | 
 | 247 | 	/* structs defined in e1000_hw.h */ | 
 | 248 | 	struct e1000_hw hw; | 
 | 249 |  | 
 | 250 | 	/* The VF counters don't clear on read so we have to get a base | 
 | 251 | 	 * count on driver start up and always subtract that base on | 
 | 252 | 	 * on the first update, thus the flag.. | 
 | 253 | 	 */ | 
 | 254 | 	struct e1000_vf_stats stats; | 
 | 255 | 	u64 zero_base; | 
 | 256 |  | 
 | 257 | 	struct igbvf_ring test_tx_ring; | 
 | 258 | 	struct igbvf_ring test_rx_ring; | 
 | 259 | 	u32 test_icr; | 
 | 260 |  | 
 | 261 | 	u32 msg_enable; | 
 | 262 | 	struct msix_entry *msix_entries; | 
 | 263 | 	int int_mode; | 
 | 264 | 	u32 eims_enable_mask; | 
 | 265 | 	u32 eims_other; | 
 | 266 | 	u32 int_counter0; | 
 | 267 | 	u32 int_counter1; | 
 | 268 |  | 
 | 269 | 	u32 eeprom_wol; | 
 | 270 | 	u32 wol; | 
 | 271 | 	u32 pba; | 
 | 272 |  | 
 | 273 | 	bool fc_autoneg; | 
 | 274 |  | 
 | 275 | 	unsigned long led_status; | 
 | 276 |  | 
 | 277 | 	unsigned int flags; | 
| Alexander Duyck | 7227909 | 2009-12-11 22:58:14 -0800 | [diff] [blame] | 278 | 	unsigned long last_reset; | 
| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 279 | }; | 
 | 280 |  | 
 | 281 | struct igbvf_info { | 
 | 282 | 	enum e1000_mac_type     mac; | 
 | 283 | 	unsigned int            flags; | 
 | 284 | 	u32                     pba; | 
 | 285 | 	void                    (*init_ops)(struct e1000_hw *); | 
 | 286 | 	s32                     (*get_variants)(struct igbvf_adapter *); | 
 | 287 | }; | 
 | 288 |  | 
 | 289 | /* hardware capability, feature, and workaround flags */ | 
| Alexander Duyck | 0364d6f | 2009-05-06 10:25:01 +0000 | [diff] [blame] | 290 | #define IGBVF_FLAG_RX_CSUM_DISABLED             (1 << 0) | 
| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 291 |  | 
 | 292 | #define IGBVF_RX_DESC_ADV(R, i)     \ | 
 | 293 | 	(&((((R).desc))[i].rx_desc)) | 
 | 294 | #define IGBVF_TX_DESC_ADV(R, i)     \ | 
 | 295 | 	(&((((R).desc))[i].tx_desc)) | 
 | 296 | #define IGBVF_TX_CTXTDESC_ADV(R, i) \ | 
 | 297 | 	(&((((R).desc))[i].tx_context_desc)) | 
 | 298 |  | 
 | 299 | enum igbvf_state_t { | 
 | 300 | 	__IGBVF_TESTING, | 
 | 301 | 	__IGBVF_RESETTING, | 
 | 302 | 	__IGBVF_DOWN | 
 | 303 | }; | 
 | 304 |  | 
 | 305 | enum latency_range { | 
 | 306 | 	lowest_latency = 0, | 
 | 307 | 	low_latency = 1, | 
 | 308 | 	bulk_latency = 2, | 
 | 309 | 	latency_invalid = 255 | 
 | 310 | }; | 
 | 311 |  | 
 | 312 | extern char igbvf_driver_name[]; | 
 | 313 | extern const char igbvf_driver_version[]; | 
 | 314 |  | 
 | 315 | extern void igbvf_check_options(struct igbvf_adapter *); | 
 | 316 | extern void igbvf_set_ethtool_ops(struct net_device *); | 
 | 317 |  | 
 | 318 | extern int igbvf_up(struct igbvf_adapter *); | 
 | 319 | extern void igbvf_down(struct igbvf_adapter *); | 
 | 320 | extern void igbvf_reinit_locked(struct igbvf_adapter *); | 
| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 321 | extern int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *); | 
 | 322 | extern int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *); | 
 | 323 | extern void igbvf_free_rx_resources(struct igbvf_ring *); | 
 | 324 | extern void igbvf_free_tx_resources(struct igbvf_ring *); | 
 | 325 | extern void igbvf_update_stats(struct igbvf_adapter *); | 
| Alexander Duyck | d4e0fe0 | 2009-04-07 14:37:34 +0000 | [diff] [blame] | 326 |  | 
 | 327 | extern unsigned int copybreak; | 
 | 328 |  | 
 | 329 | #endif /* _IGBVF_H_ */ |