1 /*******************************************************************************
3 Intel(R) 82576 Virtual Function Linux driver
4 Copyright(c) 2009 - 2012 Intel Corporation.
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.
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
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, see <http://www.gnu.org/licenses/>.
18 The full GNU General Public License is included in this distribution in
19 the file called "COPYING".
22 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *******************************************************************************/
27 /* Linux PRO/1000 Ethernet Driver main header file */
32 #include <linux/types.h>
33 #include <linux/timer.h>
35 #include <linux/netdevice.h>
36 #include <linux/if_vlan.h>
40 /* Forward declarations */
44 /* Interrupt defines */
45 #define IGBVF_START_ITR 488 /* ~8000 ints/sec */
46 #define IGBVF_4K_ITR 980
47 #define IGBVF_20K_ITR 196
48 #define IGBVF_70K_ITR 56
57 /* Interrupt modes, as used by the IntMode parameter */
58 #define IGBVF_INT_MODE_LEGACY 0
59 #define IGBVF_INT_MODE_MSI 1
60 #define IGBVF_INT_MODE_MSIX 2
62 /* Tx/Rx descriptor defines */
63 #define IGBVF_DEFAULT_TXD 256
64 #define IGBVF_MAX_TXD 4096
65 #define IGBVF_MIN_TXD 80
67 #define IGBVF_DEFAULT_RXD 256
68 #define IGBVF_MAX_RXD 4096
69 #define IGBVF_MIN_RXD 80
71 #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
72 #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
74 /* RX descriptor control thresholds.
75 * PTHRESH - MAC will consider prefetch if it has fewer than this number of
76 * descriptors available in its onboard memory.
77 * Setting this to 0 disables RX descriptor prefetch.
78 * HTHRESH - MAC will only prefetch if there are at least this many descriptors
79 * available in host memory.
80 * If PTHRESH is 0, this should also be 0.
81 * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
82 * descriptors until either it has this many to write back, or the
85 #define IGBVF_RX_PTHRESH 16
86 #define IGBVF_RX_HTHRESH 8
87 #define IGBVF_RX_WTHRESH 1
89 /* this is the size past which hardware will drop packets when setting LPE=0 */
90 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
92 #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
94 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
95 #define IGBVF_TX_QUEUE_WAKE 32
96 /* How many Rx Buffers do we bundle into one write to the hardware ? */
97 #define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */
99 #define AUTO_ALL_MODES 0
100 #define IGBVF_EEPROM_APME 0x0400
102 #define IGBVF_MNG_VLAN_NONE (-1)
104 #define IGBVF_MAX_MAC_FILTERS 3
106 /* Number of packet split data buffers (not including the header buffer) */
107 #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
114 struct igbvf_queue_stats
{
119 /* wrappers around a pointer to a socket buffer,
120 * so a DMA handle can be stored along with the buffer
122 struct igbvf_buffer
{
128 unsigned long time_stamp
;
129 union e1000_adv_tx_desc
*next_to_watch
;
137 unsigned int page_offset
;
143 union e1000_adv_rx_desc rx_desc
;
144 union e1000_adv_tx_desc tx_desc
;
145 struct e1000_adv_tx_context_desc tx_context_desc
;
149 struct igbvf_adapter
*adapter
; /* backlink */
150 union igbvf_desc
*desc
; /* pointer to ring memory */
151 dma_addr_t dma
; /* phys address of ring */
152 unsigned int size
; /* length of ring in bytes */
153 unsigned int count
; /* number of desc. in ring */
161 /* array of buffer information structs */
162 struct igbvf_buffer
*buffer_info
;
163 struct napi_struct napi
;
165 char name
[IFNAMSIZ
+ 5];
168 enum latency_range itr_range
;
172 struct sk_buff
*rx_skb_top
;
174 struct igbvf_queue_stats stats
;
177 /* board specific private data structure */
178 struct igbvf_adapter
{
179 struct timer_list watchdog_timer
;
180 struct timer_list blink_timer
;
182 struct work_struct reset_task
;
183 struct work_struct watchdog_task
;
185 const struct igbvf_info
*ei
;
187 unsigned long active_vlans
[BITS_TO_LONGS(VLAN_N_VID
)];
190 u32 polling_interval
;
195 spinlock_t tx_queue_lock
; /* prevent concurrent tail updates */
197 /* track device up/down/testing state */
200 /* Interrupt Throttle Rate */
201 u32 requested_itr
; /* ints/sec or adaptive */
202 u32 current_itr
; /* Actual ITR register value, not ints/sec */
205 struct igbvf_ring
*tx_ring
/* One per active queue */
206 ____cacheline_aligned_in_smp
;
208 unsigned int restart_queue
;
212 u32 tx_abs_int_delay
;
214 unsigned int total_tx_bytes
;
215 unsigned int total_tx_packets
;
216 unsigned int total_rx_bytes
;
217 unsigned int total_rx_packets
;
220 u32 tx_timeout_count
;
227 struct igbvf_ring
*rx_ring
;
230 u32 rx_abs_int_delay
;
236 u32 alloc_rx_buff_failed
;
239 unsigned int rx_ps_hdr_size
;
243 /* OS defined structs */
244 struct net_device
*netdev
;
245 struct pci_dev
*pdev
;
246 spinlock_t stats_lock
; /* prevent concurrent stats updates */
248 /* structs defined in e1000_hw.h */
251 /* The VF counters don't clear on read so we have to get a base
252 * count on driver start up and always subtract that base on
253 * on the first update, thus the flag..
255 struct e1000_vf_stats stats
;
258 struct igbvf_ring test_tx_ring
;
259 struct igbvf_ring test_rx_ring
;
263 struct msix_entry
*msix_entries
;
265 u32 eims_enable_mask
;
276 unsigned long led_status
;
279 unsigned long last_reset
;
283 enum e1000_mac_type mac
;
286 void (*init_ops
)(struct e1000_hw
*);
287 s32 (*get_variants
)(struct igbvf_adapter
*);
290 /* hardware capability, feature, and workaround flags */
291 #define IGBVF_FLAG_RX_CSUM_DISABLED BIT(0)
292 #define IGBVF_FLAG_RX_LB_VLAN_BSWAP BIT(1)
293 #define IGBVF_RX_DESC_ADV(R, i) \
294 (&((((R).desc))[i].rx_desc))
295 #define IGBVF_TX_DESC_ADV(R, i) \
296 (&((((R).desc))[i].tx_desc))
297 #define IGBVF_TX_CTXTDESC_ADV(R, i) \
298 (&((((R).desc))[i].tx_context_desc))
306 extern char igbvf_driver_name
[];
307 extern const char igbvf_driver_version
[];
309 void igbvf_check_options(struct igbvf_adapter
*);
310 void igbvf_set_ethtool_ops(struct net_device
*);
312 int igbvf_up(struct igbvf_adapter
*);
313 void igbvf_down(struct igbvf_adapter
*);
314 void igbvf_reinit_locked(struct igbvf_adapter
*);
315 int igbvf_setup_rx_resources(struct igbvf_adapter
*, struct igbvf_ring
*);
316 int igbvf_setup_tx_resources(struct igbvf_adapter
*, struct igbvf_ring
*);
317 void igbvf_free_rx_resources(struct igbvf_ring
*);
318 void igbvf_free_tx_resources(struct igbvf_ring
*);
319 void igbvf_update_stats(struct igbvf_adapter
*);
321 extern unsigned int copybreak
;
323 #endif /* _IGBVF_H_ */