1 /*******************************************************************************
3 Intel(R) 82576 Virtual Function Linux driver
4 Copyright(c) 2009 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 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
28 /* Linux PRO/1000 Ethernet Driver main header file */
33 #include <linux/types.h>
34 #include <linux/timer.h>
36 #include <linux/netdevice.h>
41 /* Forward declarations */
45 /* Interrupt defines */
46 #define IGBVF_START_ITR 648 /* ~6000 ints/sec */
48 /* Interrupt modes, as used by the IntMode paramter */
49 #define IGBVF_INT_MODE_LEGACY 0
50 #define IGBVF_INT_MODE_MSI 1
51 #define IGBVF_INT_MODE_MSIX 2
53 /* Tx/Rx descriptor defines */
54 #define IGBVF_DEFAULT_TXD 256
55 #define IGBVF_MAX_TXD 4096
56 #define IGBVF_MIN_TXD 80
58 #define IGBVF_DEFAULT_RXD 256
59 #define IGBVF_MAX_RXD 4096
60 #define IGBVF_MIN_RXD 80
62 #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
63 #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
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
76 #define IGBVF_RX_PTHRESH 16
77 #define IGBVF_RX_HTHRESH 8
78 #define IGBVF_RX_WTHRESH 1
80 /* this is the size past which hardware will drop packets when setting LPE=0 */
81 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
83 #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
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 */
90 #define AUTO_ALL_MODES 0
91 #define IGBVF_EEPROM_APME 0x0400
93 #define IGBVF_MNG_VLAN_NONE (-1)
95 /* Number of packet split data buffers (not including the header buffer) */
96 #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
102 struct igbvf_queue_stats {
108 * wrappers around a pointer to a socket buffer,
109 * so a DMA handle can be stored along with the buffer
111 struct igbvf_buffer {
117 unsigned long time_stamp;
125 unsigned int page_offset;
132 union e1000_adv_rx_desc rx_desc;
133 union e1000_adv_tx_desc tx_desc;
134 struct e1000_adv_tx_context_desc tx_context_desc;
138 struct igbvf_adapter *adapter; /* backlink */
139 union igbvf_desc *desc; /* pointer to ring memory */
140 dma_addr_t dma; /* phys address of ring */
141 unsigned int size; /* length of ring in bytes */
142 unsigned int count; /* number of desc. in ring */
150 /* array of buffer information structs */
151 struct igbvf_buffer *buffer_info;
152 struct napi_struct napi;
154 char name[IFNAMSIZ + 5];
160 struct sk_buff *rx_skb_top;
162 struct igbvf_queue_stats stats;
165 /* board specific private data structure */
166 struct igbvf_adapter {
167 struct timer_list watchdog_timer;
168 struct timer_list blink_timer;
170 struct work_struct reset_task;
171 struct work_struct watchdog_task;
173 const struct igbvf_info *ei;
175 struct vlan_group *vlgrp;
178 u32 polling_interval;
183 spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
185 /* track device up/down/testing state */
188 /* Interrupt Throttle Rate */
197 struct igbvf_ring *tx_ring /* One per active queue */
198 ____cacheline_aligned_in_smp;
200 unsigned long tx_queue_len;
201 unsigned int restart_queue;
205 u8 tx_timeout_factor;
208 u32 tx_abs_int_delay;
210 unsigned int total_tx_bytes;
211 unsigned int total_tx_packets;
212 unsigned int total_rx_bytes;
213 unsigned int total_rx_packets;
216 u32 tx_timeout_count;
225 struct igbvf_ring *rx_ring;
228 u32 rx_abs_int_delay;
234 u32 alloc_rx_buff_failed;
237 unsigned int rx_ps_hdr_size;
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 */
247 /* structs defined in e1000_hw.h */
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..
254 struct e1000_vf_stats stats;
257 struct igbvf_ring test_tx_ring;
258 struct igbvf_ring test_rx_ring;
262 struct msix_entry *msix_entries;
264 u32 eims_enable_mask;
275 unsigned long led_status;
281 enum e1000_mac_type mac;
284 void (*init_ops)(struct e1000_hw *);
285 s32 (*get_variants)(struct igbvf_adapter *);
288 /* hardware capability, feature, and workaround flags */
289 #define FLAG_HAS_HW_VLAN_FILTER (1 << 0)
290 #define FLAG_HAS_JUMBO_FRAMES (1 << 1)
291 #define FLAG_MSI_ENABLED (1 << 2)
292 #define FLAG_RX_CSUM_ENABLED (1 << 3)
293 #define FLAG_TSO_FORCE (1 << 4)
295 #define IGBVF_RX_DESC_ADV(R, i) \
296 (&((((R).desc))[i].rx_desc))
297 #define IGBVF_TX_DESC_ADV(R, i) \
298 (&((((R).desc))[i].tx_desc))
299 #define IGBVF_TX_CTXTDESC_ADV(R, i) \
300 (&((((R).desc))[i].tx_context_desc))
312 latency_invalid = 255
315 extern char igbvf_driver_name[];
316 extern const char igbvf_driver_version[];
318 extern void igbvf_check_options(struct igbvf_adapter *);
319 extern void igbvf_set_ethtool_ops(struct net_device *);
321 extern int igbvf_up(struct igbvf_adapter *);
322 extern void igbvf_down(struct igbvf_adapter *);
323 extern void igbvf_reinit_locked(struct igbvf_adapter *);
324 extern int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *);
325 extern int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *);
326 extern void igbvf_free_rx_resources(struct igbvf_ring *);
327 extern void igbvf_free_tx_resources(struct igbvf_ring *);
328 extern void igbvf_update_stats(struct igbvf_adapter *);
330 extern unsigned int copybreak;
332 #endif /* _IGBVF_H_ */