1 /*******************************************************************************
3 Intel(R) 82576 Virtual Function Linux driver
4 Copyright(c) 1999 - 2008 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, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
29 FILE_LICENCE ( GPL2_ONLY );
31 /* Linux PRO/1000 Ethernet Driver main header file */
38 /* Forward declarations */
42 /* Interrupt defines */
43 #define IGBVF_START_ITR 648 /* ~6000 ints/sec */
45 /* Tx/Rx descriptor defines */
46 #define IGBVF_DEFAULT_TXD 256
47 #define IGBVF_MAX_TXD 4096
48 #define IGBVF_MIN_TXD 80
50 #define IGBVF_DEFAULT_RXD 256
51 #define IGBVF_MAX_RXD 4096
52 #define IGBVF_MIN_RXD 80
54 #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
55 #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
57 /* RX descriptor control thresholds.
58 * PTHRESH - MAC will consider prefetch if it has fewer than this number of
59 * descriptors available in its onboard memory.
60 * Setting this to 0 disables RX descriptor prefetch.
61 * HTHRESH - MAC will only prefetch if there are at least this many descriptors
62 * available in host memory.
63 * If PTHRESH is 0, this should also be 0.
64 * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
65 * descriptors until either it has this many to write back, or the
68 #define IGBVF_RX_PTHRESH 16
69 #define IGBVF_RX_HTHRESH 8
70 #define IGBVF_RX_WTHRESH 1
72 #define IGBVF_TX_PTHRESH 8
73 #define IGBVF_TX_HTHRESH 1
74 #define IGBVF_TX_WTHRESH 1
76 /* this is the size past which hardware will drop packets when setting LPE=0 */
77 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
79 #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
81 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
82 #define IGBVF_TX_QUEUE_WAKE 32
83 /* How many Rx Buffers do we bundle into one write to the hardware ? */
84 #define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */
86 #define AUTO_ALL_MODES 0
87 #define IGBVF_EEPROM_APME 0x0400
89 #define IGBVF_MNG_VLAN_NONE (-1)
95 struct igbvf_queue_stats {
101 * wrappers around a pointer to a socket buffer,
102 * so a DMA handle can be stored along with the buffer
104 struct igbvf_buffer {
112 unsigned long time_stamp;
119 unsigned int page_offset;
128 struct igbvf_adapter *adapter; /* backlink */
129 void *desc; /* pointer to ring memory */
130 dma_addr_t dma; /* phys address of ring */
131 unsigned int size; /* length of ring in bytes */
132 unsigned int count; /* number of desc. in ring */
140 /* array of buffer information structs */
141 struct igbvf_buffer *buffer_info;
142 struct napi_struct napi;
144 char name[IFNAMSIZ + 5];
150 struct sk_buff *rx_skb_top;
152 struct igbvf_queue_stats stats;
156 /* board specific private data structure */
157 struct igbvf_adapter {
159 struct timer_list watchdog_timer;
160 struct timer_list blink_timer;
162 struct work_struct reset_task;
163 struct work_struct watchdog_task;
165 const struct igbvf_info *ei;
167 struct vlan_group *vlgrp;
170 u32 polling_interval;
175 spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
177 /* track device up/down/testing state */
180 /* Interrupt Throttle Rate */
189 struct igbvf_ring *tx_ring /* One per active queue */
190 ____cacheline_aligned_in_smp;
192 unsigned long tx_queue_len;
193 unsigned int restart_queue;
197 u8 tx_timeout_factor;
199 unsigned int total_tx_bytes;
200 unsigned int total_tx_packets;
201 unsigned int total_rx_bytes;
202 unsigned int total_rx_packets;
205 u32 tx_timeout_count;
214 struct igbvf_ring *rx_ring;
220 u32 alloc_rx_buff_failed;
223 unsigned int rx_ps_hdr_size;
227 /* OS defined structs */
228 struct net_device *netdev;
229 struct pci_dev *pdev;
230 struct net_device_stats net_stats;
231 spinlock_t stats_lock; /* prevent concurrent stats updates */
233 /* structs defined in e1000_hw.h */
236 /* The VF counters don't clear on read so we have to get a base
237 * count on driver start up and always subtract that base on
238 * on the first update, thus the flag..
240 struct e1000_vf_stats stats;
243 struct igbvf_ring test_tx_ring;
244 struct igbvf_ring test_rx_ring;
248 struct msix_entry *msix_entries;
250 u32 eims_enable_mask;
261 unsigned long led_status;
264 unsigned long last_reset;
267 /* OS defined structs */
268 struct net_device *netdev;
269 struct pci_device *pdev;
270 struct net_device_stats net_stats;
272 /* structs defined in e1000_hw.h */
278 u32 max_hw_frame_size;
280 #define NUM_TX_DESC 8
281 #define NUM_RX_DESC 8
283 struct io_buffer *tx_iobuf[NUM_TX_DESC];
284 struct io_buffer *rx_iobuf[NUM_RX_DESC];
286 union e1000_adv_tx_desc *tx_base;
287 union e1000_adv_rx_desc *rx_base;
289 uint32_t tx_ring_size;
290 uint32_t rx_ring_size;
294 uint32_t tx_fill_ctr;
301 uint32_t tx_int_delay;
302 uint32_t tx_abs_int_delay;
307 enum e1000_mac_type mac;
310 void (*init_ops)(struct e1000_hw *);
311 s32 (*get_variants)(struct igbvf_adapter *);
314 /* hardware capability, feature, and workaround flags */
315 #define IGBVF_FLAG_RX_CSUM_DISABLED (1 << 0)
317 #define IGBVF_DESC_UNUSED(R) \
318 ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
319 (R)->next_to_clean - (R)->next_to_use - 1)
321 #define IGBVF_RX_DESC_ADV(R, i) \
322 (&(((union e1000_adv_rx_desc *)((R).desc))[i]))
323 #define IGBVF_TX_DESC_ADV(R, i) \
324 (&(((union e1000_adv_tx_desc *)((R).desc))[i]))
325 #define IGBVF_TX_CTXTDESC_ADV(R, i) \
326 (&(((struct e1000_adv_tx_context_desc *)((R).desc))[i]))
338 latency_invalid = 255
341 extern char igbvf_driver_name[];
342 extern const char igbvf_driver_version[];
344 extern void igbvf_check_options(struct igbvf_adapter *adapter);
345 extern void igbvf_set_ethtool_ops(struct net_device *netdev);
346 #ifdef ETHTOOL_OPS_COMPAT
347 extern int ethtool_ioctl(struct ifreq *ifr);
350 extern int igbvf_up(struct igbvf_adapter *adapter);
351 extern void igbvf_down(struct igbvf_adapter *adapter);
352 extern void igbvf_reinit_locked(struct igbvf_adapter *adapter);
353 extern void igbvf_reset(struct igbvf_adapter *adapter);
354 extern int igbvf_setup_rx_resources(struct igbvf_adapter *adapter);
355 extern int igbvf_setup_tx_resources(struct igbvf_adapter *adapter);
356 extern void igbvf_free_rx_resources(struct igbvf_adapter *adapter);
357 extern void igbvf_free_tx_resources(struct igbvf_adapter *adapter);
358 extern void igbvf_update_stats(struct igbvf_adapter *adapter);
359 extern void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter);
360 extern void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter);
362 extern unsigned int copybreak;
364 static inline u32 __er32(struct e1000_hw *hw, unsigned long reg)
366 return readl(hw->hw_addr + reg);
369 static inline void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
371 writel(val, hw->hw_addr + reg);
373 #define er32(reg) E1000_READ_REG(hw, E1000_##reg)
374 #define ew32(reg,val) E1000_WRITE_REG(hw, E1000_##reg, (val))
375 #define e1e_flush() er32(STATUS)
377 #endif /* _IGBVF_H_ */