1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009 - 2018 Intel Corporation. */
4 /* Linux PRO/1000 Ethernet Driver main header file */
9 #include <linux/types.h>
10 #include <linux/timer.h>
12 #include <linux/netdevice.h>
13 #include <linux/if_vlan.h>
17 /* Forward declarations */
21 /* Interrupt defines */
22 #define IGBVF_START_ITR 488 /* ~8000 ints/sec */
23 #define IGBVF_4K_ITR 980
24 #define IGBVF_20K_ITR 196
25 #define IGBVF_70K_ITR 56
34 /* Interrupt modes, as used by the IntMode parameter */
35 #define IGBVF_INT_MODE_LEGACY 0
36 #define IGBVF_INT_MODE_MSI 1
37 #define IGBVF_INT_MODE_MSIX 2
39 /* Tx/Rx descriptor defines */
40 #define IGBVF_DEFAULT_TXD 256
41 #define IGBVF_MAX_TXD 4096
42 #define IGBVF_MIN_TXD 80
44 #define IGBVF_DEFAULT_RXD 256
45 #define IGBVF_MAX_RXD 4096
46 #define IGBVF_MIN_RXD 80
48 #define IGBVF_MIN_ITR_USECS 10 /* 100000 irq/sec */
49 #define IGBVF_MAX_ITR_USECS 10000 /* 100 irq/sec */
51 /* RX descriptor control thresholds.
52 * PTHRESH - MAC will consider prefetch if it has fewer than this number of
53 * descriptors available in its onboard memory.
54 * Setting this to 0 disables RX descriptor prefetch.
55 * HTHRESH - MAC will only prefetch if there are at least this many descriptors
56 * available in host memory.
57 * If PTHRESH is 0, this should also be 0.
58 * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
59 * descriptors until either it has this many to write back, or the
62 #define IGBVF_RX_PTHRESH 16
63 #define IGBVF_RX_HTHRESH 8
64 #define IGBVF_RX_WTHRESH 1
66 /* this is the size past which hardware will drop packets when setting LPE=0 */
67 #define MAXIMUM_ETHERNET_VLAN_SIZE 1522
69 #define IGBVF_FC_PAUSE_TIME 0x0680 /* 858 usec */
71 /* How many Tx Descriptors do we need to call netif_wake_queue ? */
72 #define IGBVF_TX_QUEUE_WAKE 32
73 /* How many Rx Buffers do we bundle into one write to the hardware ? */
74 #define IGBVF_RX_BUFFER_WRITE 16 /* Must be power of 2 */
76 #define AUTO_ALL_MODES 0
77 #define IGBVF_EEPROM_APME 0x0400
79 #define IGBVF_MNG_VLAN_NONE (-1)
81 #define IGBVF_MAX_MAC_FILTERS 3
83 /* Number of packet split data buffers (not including the header buffer) */
84 #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
91 struct igbvf_queue_stats
{
96 /* wrappers around a pointer to a socket buffer,
97 * so a DMA handle can be stored along with the buffer
105 unsigned long time_stamp
;
106 union e1000_adv_tx_desc
*next_to_watch
;
114 unsigned int page_offset
;
120 union e1000_adv_rx_desc rx_desc
;
121 union e1000_adv_tx_desc tx_desc
;
122 struct e1000_adv_tx_context_desc tx_context_desc
;
126 struct igbvf_adapter
*adapter
; /* backlink */
127 union igbvf_desc
*desc
; /* pointer to ring memory */
128 dma_addr_t dma
; /* phys address of ring */
129 unsigned int size
; /* length of ring in bytes */
130 unsigned int count
; /* number of desc. in ring */
138 /* array of buffer information structs */
139 struct igbvf_buffer
*buffer_info
;
140 struct napi_struct napi
;
142 char name
[IFNAMSIZ
+ 5];
145 enum latency_range itr_range
;
149 struct sk_buff
*rx_skb_top
;
151 struct igbvf_queue_stats stats
;
154 /* board specific private data structure */
155 struct igbvf_adapter
{
156 struct timer_list watchdog_timer
;
157 struct timer_list blink_timer
;
159 struct work_struct reset_task
;
160 struct work_struct watchdog_task
;
162 const struct igbvf_info
*ei
;
164 unsigned long active_vlans
[BITS_TO_LONGS(VLAN_N_VID
)];
167 u32 polling_interval
;
172 spinlock_t tx_queue_lock
; /* prevent concurrent tail updates */
174 /* track device up/down/testing state */
177 /* Interrupt Throttle Rate */
178 u32 requested_itr
; /* ints/sec or adaptive */
179 u32 current_itr
; /* Actual ITR register value, not ints/sec */
182 struct igbvf_ring
*tx_ring
/* One per active queue */
183 ____cacheline_aligned_in_smp
;
185 unsigned int restart_queue
;
189 u32 tx_abs_int_delay
;
191 unsigned int total_tx_bytes
;
192 unsigned int total_tx_packets
;
193 unsigned int total_rx_bytes
;
194 unsigned int total_rx_packets
;
197 u32 tx_timeout_count
;
204 struct igbvf_ring
*rx_ring
;
207 u32 rx_abs_int_delay
;
213 u32 alloc_rx_buff_failed
;
216 unsigned int rx_ps_hdr_size
;
220 /* OS defined structs */
221 struct net_device
*netdev
;
222 struct pci_dev
*pdev
;
223 spinlock_t stats_lock
; /* prevent concurrent stats updates */
225 /* structs defined in e1000_hw.h */
228 /* The VF counters don't clear on read so we have to get a base
229 * count on driver start up and always subtract that base on
230 * on the first update, thus the flag..
232 struct e1000_vf_stats stats
;
235 struct igbvf_ring test_tx_ring
;
236 struct igbvf_ring test_rx_ring
;
240 struct msix_entry
*msix_entries
;
242 u32 eims_enable_mask
;
253 unsigned long led_status
;
256 unsigned long last_reset
;
260 enum e1000_mac_type mac
;
263 void (*init_ops
)(struct e1000_hw
*);
264 s32 (*get_variants
)(struct igbvf_adapter
*);
267 /* hardware capability, feature, and workaround flags */
268 #define IGBVF_FLAG_RX_CSUM_DISABLED BIT(0)
269 #define IGBVF_FLAG_RX_LB_VLAN_BSWAP BIT(1)
270 #define IGBVF_RX_DESC_ADV(R, i) \
271 (&((((R).desc))[i].rx_desc))
272 #define IGBVF_TX_DESC_ADV(R, i) \
273 (&((((R).desc))[i].tx_desc))
274 #define IGBVF_TX_CTXTDESC_ADV(R, i) \
275 (&((((R).desc))[i].tx_context_desc))
283 extern char igbvf_driver_name
[];
285 void igbvf_check_options(struct igbvf_adapter
*);
286 void igbvf_set_ethtool_ops(struct net_device
*);
288 int igbvf_up(struct igbvf_adapter
*);
289 void igbvf_down(struct igbvf_adapter
*);
290 void igbvf_reinit_locked(struct igbvf_adapter
*);
291 int igbvf_setup_rx_resources(struct igbvf_adapter
*, struct igbvf_ring
*);
292 int igbvf_setup_tx_resources(struct igbvf_adapter
*, struct igbvf_ring
*);
293 void igbvf_free_rx_resources(struct igbvf_ring
*);
294 void igbvf_free_tx_resources(struct igbvf_ring
*);
295 void igbvf_update_stats(struct igbvf_adapter
*);
297 extern unsigned int copybreak
;
299 #endif /* _IGBVF_H_ */