Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
igbvf.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  Intel(R) 82576 Virtual Function Linux driver
4  Copyright(c) 2009 - 2012 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 <[email protected]>
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 #include <linux/if_vlan.h>
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 488 /* ~8000 ints/sec */
47 #define IGBVF_4K_ITR 980
48 #define IGBVF_20K_ITR 196
49 #define IGBVF_70K_ITR 56
50 
56 };
57 
58 
59 /* Interrupt modes, as used by the IntMode parameter */
60 #define IGBVF_INT_MODE_LEGACY 0
61 #define IGBVF_INT_MODE_MSI 1
62 #define IGBVF_INT_MODE_MSIX 2
63 
64 /* Tx/Rx descriptor defines */
65 #define IGBVF_DEFAULT_TXD 256
66 #define IGBVF_MAX_TXD 4096
67 #define IGBVF_MIN_TXD 80
68 
69 #define IGBVF_DEFAULT_RXD 256
70 #define IGBVF_MAX_RXD 4096
71 #define IGBVF_MIN_RXD 80
72 
73 #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
74 #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
75 
76 /* RX descriptor control thresholds.
77  * PTHRESH - MAC will consider prefetch if it has fewer than this number of
78  * descriptors available in its onboard memory.
79  * Setting this to 0 disables RX descriptor prefetch.
80  * HTHRESH - MAC will only prefetch if there are at least this many descriptors
81  * available in host memory.
82  * If PTHRESH is 0, this should also be 0.
83  * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
84  * descriptors until either it has this many to write back, or the
85  * ITR timer expires.
86  */
87 #define IGBVF_RX_PTHRESH 16
88 #define IGBVF_RX_HTHRESH 8
89 #define IGBVF_RX_WTHRESH 1
90 
91 /* this is the size past which hardware will drop packets when setting LPE=0 */
92 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
93 
94 #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
95 
96 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
97 #define IGBVF_TX_QUEUE_WAKE 32
98 /* How many Rx Buffers do we bundle into one write to the hardware ? */
99 #define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */
100 
101 #define AUTO_ALL_MODES 0
102 #define IGBVF_EEPROM_APME 0x0400
103 
104 #define IGBVF_MNG_VLAN_NONE (-1)
105 
106 /* Number of packet split data buffers (not including the header buffer) */
107 #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
108 
112 };
113 
117 };
118 
119 /*
120  * wrappers around a pointer to a socket buffer,
121  * so a DMA handle can be stored along with the buffer
122  */
123 struct igbvf_buffer {
125  struct sk_buff *skb;
126  union {
127  /* Tx */
128  struct {
129  unsigned long time_stamp;
133  };
134  /* Rx */
135  struct {
136  struct page *page;
138  unsigned int page_offset;
139  };
140  };
141 };
142 
143 union igbvf_desc {
147 };
148 
149 struct igbvf_ring {
150  struct igbvf_adapter *adapter; /* backlink */
151  union igbvf_desc *desc; /* pointer to ring memory */
152  dma_addr_t dma; /* phys address of ring */
153  unsigned int size; /* length of ring in bytes */
154  unsigned int count; /* number of desc. in ring */
155 
158 
161 
162  /* array of buffer information structs */
165 
166  char name[IFNAMSIZ + 5];
171  int set_itr;
172 
174 
176 };
177 
178 /* board specific private data structure */
182 
185 
186  const struct igbvf_info *ei;
187 
195 
196  spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
197 
198  /* track device up/down/testing state */
199  unsigned long state;
200 
201  /* Interrupt Throttle Rate */
202  u32 requested_itr; /* ints/sec or adaptive */
203  u32 current_itr; /* Actual ITR register value, not ints/sec */
204 
205  /*
206  * Tx
207  */
208  struct igbvf_ring *tx_ring /* One per active queue */
210 
211  unsigned int restart_queue;
213 
216 
217  unsigned int total_tx_bytes;
218  unsigned int total_tx_packets;
219  unsigned int total_rx_bytes;
220  unsigned int total_rx_packets;
221 
222  /* Tx stats */
228 
229  /*
230  * Rx
231  */
233 
236 
237  /* Rx stats */
243 
244  unsigned int rx_ps_hdr_size;
247 
248  /* OS defined structs */
250  struct pci_dev *pdev;
252  spinlock_t stats_lock; /* prevent concurrent stats updates */
253 
254  /* structs defined in e1000_hw.h */
255  struct e1000_hw hw;
256 
257  /* The VF counters don't clear on read so we have to get a base
258  * count on driver start up and always subtract that base on
259  * on the first update, thus the flag..
260  */
263 
267 
269  struct msix_entry *msix_entries;
270  int int_mode;
275 
279 
281 
282  unsigned long led_status;
283 
284  unsigned int flags;
285  unsigned long last_reset;
286 };
287 
288 struct igbvf_info {
290  unsigned int flags;
292  void (*init_ops)(struct e1000_hw *);
294 };
295 
296 /* hardware capability, feature, and workaround flags */
297 #define IGBVF_FLAG_RX_CSUM_DISABLED (1 << 0)
298 
299 #define IGBVF_RX_DESC_ADV(R, i) \
300  (&((((R).desc))[i].rx_desc))
301 #define IGBVF_TX_DESC_ADV(R, i) \
302  (&((((R).desc))[i].tx_desc))
303 #define IGBVF_TX_CTXTDESC_ADV(R, i) \
304  (&((((R).desc))[i].tx_context_desc))
305 
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 *);
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 *);
326 
327 extern unsigned int copybreak;
328 
329 #endif /* _IGBVF_H_ */