Commit | Line | Data |
---|---|---|
d4e0fe01 AD |
1 | /******************************************************************************* |
2 | ||
3 | Intel(R) 82576 Virtual Function Linux driver | |
2a06ed92 | 4 | Copyright(c) 2009 - 2012 Intel Corporation. |
d4e0fe01 AD |
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 | |
0340501b | 16 | this program; if not, see <http://www.gnu.org/licenses/>. |
d4e0fe01 AD |
17 | |
18 | The full GNU General Public License is included in this distribution in | |
19 | the file called "COPYING". | |
20 | ||
21 | Contact Information: | |
22 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | |
23 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
24 | ||
25 | *******************************************************************************/ | |
26 | ||
27 | /* Linux PRO/1000 Ethernet Driver main header file */ | |
28 | ||
29 | #ifndef _IGBVF_H_ | |
30 | #define _IGBVF_H_ | |
31 | ||
32 | #include <linux/types.h> | |
33 | #include <linux/timer.h> | |
34 | #include <linux/io.h> | |
35 | #include <linux/netdevice.h> | |
a0f1d603 | 36 | #include <linux/if_vlan.h> |
d4e0fe01 AD |
37 | |
38 | #include "vf.h" | |
39 | ||
40 | /* Forward declarations */ | |
41 | struct igbvf_info; | |
42 | struct igbvf_adapter; | |
43 | ||
44 | /* Interrupt defines */ | |
0340501b JK |
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 | |
ab50a2a4 MW |
49 | |
50 | enum latency_range { | |
51 | lowest_latency = 0, | |
52 | low_latency = 1, | |
53 | bulk_latency = 2, | |
54 | latency_invalid = 255 | |
55 | }; | |
56 | ||
98a1708d | 57 | /* Interrupt modes, as used by the IntMode parameter */ |
0340501b JK |
58 | #define IGBVF_INT_MODE_LEGACY 0 |
59 | #define IGBVF_INT_MODE_MSI 1 | |
60 | #define IGBVF_INT_MODE_MSIX 2 | |
d4e0fe01 AD |
61 | |
62 | /* Tx/Rx descriptor defines */ | |
0340501b JK |
63 | #define IGBVF_DEFAULT_TXD 256 |
64 | #define IGBVF_MAX_TXD 4096 | |
65 | #define IGBVF_MIN_TXD 80 | |
d4e0fe01 | 66 | |
0340501b JK |
67 | #define IGBVF_DEFAULT_RXD 256 |
68 | #define IGBVF_MAX_RXD 4096 | |
69 | #define IGBVF_MIN_RXD 80 | |
d4e0fe01 | 70 | |
0340501b JK |
71 | #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */ |
72 | #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */ | |
d4e0fe01 AD |
73 | |
74 | /* RX descriptor control thresholds. | |
75 | * PTHRESH - MAC will consider prefetch if it has fewer than this number of | |
0340501b JK |
76 | * descriptors available in its onboard memory. |
77 | * Setting this to 0 disables RX descriptor prefetch. | |
d4e0fe01 | 78 | * HTHRESH - MAC will only prefetch if there are at least this many descriptors |
0340501b JK |
79 | * available in host memory. |
80 | * If PTHRESH is 0, this should also be 0. | |
d4e0fe01 | 81 | * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back |
0340501b JK |
82 | * descriptors until either it has this many to write back, or the |
83 | * ITR timer expires. | |
d4e0fe01 | 84 | */ |
0340501b JK |
85 | #define IGBVF_RX_PTHRESH 16 |
86 | #define IGBVF_RX_HTHRESH 8 | |
87 | #define IGBVF_RX_WTHRESH 1 | |
d4e0fe01 AD |
88 | |
89 | /* this is the size past which hardware will drop packets when setting LPE=0 */ | |
0340501b | 90 | #define MAXIMUM_ETHERNET_VLAN_SIZE 1522 |
d4e0fe01 | 91 | |
0340501b | 92 | #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */ |
d4e0fe01 AD |
93 | |
94 | /* How many Tx Descriptors do we need to call netif_wake_queue ? */ | |
0340501b | 95 | #define IGBVF_TX_QUEUE_WAKE 32 |
d4e0fe01 | 96 | /* How many Rx Buffers do we bundle into one write to the hardware ? */ |
0340501b | 97 | #define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */ |
d4e0fe01 | 98 | |
0340501b JK |
99 | #define AUTO_ALL_MODES 0 |
100 | #define IGBVF_EEPROM_APME 0x0400 | |
d4e0fe01 | 101 | |
0340501b | 102 | #define IGBVF_MNG_VLAN_NONE (-1) |
d4e0fe01 AD |
103 | |
104 | /* Number of packet split data buffers (not including the header buffer) */ | |
0340501b | 105 | #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1) |
d4e0fe01 AD |
106 | |
107 | enum igbvf_boards { | |
108 | board_vf, | |
031d7952 | 109 | board_i350_vf, |
d4e0fe01 AD |
110 | }; |
111 | ||
112 | struct igbvf_queue_stats { | |
113 | u64 packets; | |
114 | u64 bytes; | |
115 | }; | |
116 | ||
0340501b | 117 | /* wrappers around a pointer to a socket buffer, |
d4e0fe01 AD |
118 | * so a DMA handle can be stored along with the buffer |
119 | */ | |
120 | struct igbvf_buffer { | |
121 | dma_addr_t dma; | |
122 | struct sk_buff *skb; | |
123 | union { | |
124 | /* Tx */ | |
125 | struct { | |
126 | unsigned long time_stamp; | |
3eb1a40f | 127 | union e1000_adv_tx_desc *next_to_watch; |
d4e0fe01 | 128 | u16 length; |
a7d5ca40 | 129 | u16 mapped_as_page; |
d4e0fe01 AD |
130 | }; |
131 | /* Rx */ | |
132 | struct { | |
133 | struct page *page; | |
134 | u64 page_dma; | |
135 | unsigned int page_offset; | |
136 | }; | |
137 | }; | |
d4e0fe01 AD |
138 | }; |
139 | ||
140 | union igbvf_desc { | |
141 | union e1000_adv_rx_desc rx_desc; | |
142 | union e1000_adv_tx_desc tx_desc; | |
143 | struct e1000_adv_tx_context_desc tx_context_desc; | |
144 | }; | |
145 | ||
146 | struct igbvf_ring { | |
147 | struct igbvf_adapter *adapter; /* backlink */ | |
0340501b JK |
148 | union igbvf_desc *desc; /* pointer to ring memory */ |
149 | dma_addr_t dma; /* phys address of ring */ | |
150 | unsigned int size; /* length of ring in bytes */ | |
151 | unsigned int count; /* number of desc. in ring */ | |
d4e0fe01 AD |
152 | |
153 | u16 next_to_use; | |
154 | u16 next_to_clean; | |
155 | ||
156 | u16 head; | |
157 | u16 tail; | |
158 | ||
159 | /* array of buffer information structs */ | |
160 | struct igbvf_buffer *buffer_info; | |
161 | struct napi_struct napi; | |
162 | ||
163 | char name[IFNAMSIZ + 5]; | |
164 | u32 eims_value; | |
165 | u32 itr_val; | |
ab50a2a4 | 166 | enum latency_range itr_range; |
d4e0fe01 AD |
167 | u16 itr_register; |
168 | int set_itr; | |
169 | ||
170 | struct sk_buff *rx_skb_top; | |
171 | ||
172 | struct igbvf_queue_stats stats; | |
173 | }; | |
174 | ||
175 | /* board specific private data structure */ | |
176 | struct igbvf_adapter { | |
177 | struct timer_list watchdog_timer; | |
178 | struct timer_list blink_timer; | |
179 | ||
180 | struct work_struct reset_task; | |
181 | struct work_struct watchdog_task; | |
182 | ||
183 | const struct igbvf_info *ei; | |
184 | ||
a0f1d603 | 185 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
d4e0fe01 AD |
186 | u32 bd_number; |
187 | u32 rx_buffer_len; | |
188 | u32 polling_interval; | |
189 | u16 mng_vlan_id; | |
190 | u16 link_speed; | |
191 | u16 link_duplex; | |
192 | ||
193 | spinlock_t tx_queue_lock; /* prevent concurrent tail updates */ | |
194 | ||
195 | /* track device up/down/testing state */ | |
196 | unsigned long state; | |
197 | ||
198 | /* Interrupt Throttle Rate */ | |
ab50a2a4 MW |
199 | u32 requested_itr; /* ints/sec or adaptive */ |
200 | u32 current_itr; /* Actual ITR register value, not ints/sec */ | |
d4e0fe01 | 201 | |
0340501b | 202 | /* Tx */ |
d4e0fe01 AD |
203 | struct igbvf_ring *tx_ring /* One per active queue */ |
204 | ____cacheline_aligned_in_smp; | |
205 | ||
d4e0fe01 AD |
206 | unsigned int restart_queue; |
207 | u32 txd_cmd; | |
208 | ||
d4e0fe01 AD |
209 | u32 tx_int_delay; |
210 | u32 tx_abs_int_delay; | |
211 | ||
212 | unsigned int total_tx_bytes; | |
213 | unsigned int total_tx_packets; | |
214 | unsigned int total_rx_bytes; | |
215 | unsigned int total_rx_packets; | |
216 | ||
217 | /* Tx stats */ | |
218 | u32 tx_timeout_count; | |
219 | u32 tx_fifo_head; | |
220 | u32 tx_head_addr; | |
221 | u32 tx_fifo_size; | |
222 | u32 tx_dma_failed; | |
223 | ||
0340501b | 224 | /* Rx */ |
d4e0fe01 AD |
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; | |
0340501b | 245 | spinlock_t stats_lock; /* prevent concurrent stats updates */ |
d4e0fe01 AD |
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; | |
72279093 | 278 | unsigned long last_reset; |
d4e0fe01 AD |
279 | }; |
280 | ||
281 | struct igbvf_info { | |
0340501b JK |
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 *); | |
d4e0fe01 AD |
287 | }; |
288 | ||
289 | /* hardware capability, feature, and workaround flags */ | |
0340501b JK |
290 | #define IGBVF_FLAG_RX_CSUM_DISABLED (1 << 0) |
291 | #define IGBVF_FLAG_RX_LB_VLAN_BSWAP (1 << 1) | |
d4e0fe01 AD |
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 | ||
d4e0fe01 AD |
305 | extern char igbvf_driver_name[]; |
306 | extern const char igbvf_driver_version[]; | |
307 | ||
5ccc921a JP |
308 | void igbvf_check_options(struct igbvf_adapter *); |
309 | void igbvf_set_ethtool_ops(struct net_device *); | |
310 | ||
311 | int igbvf_up(struct igbvf_adapter *); | |
312 | void igbvf_down(struct igbvf_adapter *); | |
313 | void igbvf_reinit_locked(struct igbvf_adapter *); | |
314 | int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *); | |
315 | int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *); | |
316 | void igbvf_free_rx_resources(struct igbvf_ring *); | |
317 | void igbvf_free_tx_resources(struct igbvf_ring *); | |
318 | void igbvf_update_stats(struct igbvf_adapter *); | |
d4e0fe01 AD |
319 | |
320 | extern unsigned int copybreak; | |
321 | ||
322 | #endif /* _IGBVF_H_ */ |