Linux Audio

Check our new training course

Yocto / OpenEmbedded training

Feb 10-13, 2025
Register
Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/* Copyright(c) 2009 - 2018 Intel Corporation. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  3
  4/* Linux PRO/1000 Ethernet Driver main header file */
  5
  6#ifndef _IGBVF_H_
  7#define _IGBVF_H_
  8
  9#include <linux/types.h>
 10#include <linux/timer.h>
 11#include <linux/io.h>
 12#include <linux/netdevice.h>
 13#include <linux/if_vlan.h>
 14
 15#include "vf.h"
 16
 17/* Forward declarations */
 18struct igbvf_info;
 19struct igbvf_adapter;
 20
 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
 26
 27enum latency_range {
 28	lowest_latency = 0,
 29	low_latency = 1,
 30	bulk_latency = 2,
 31	latency_invalid = 255
 32};
 33
 
 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
 38
 39/* Tx/Rx descriptor defines */
 40#define IGBVF_DEFAULT_TXD	256
 41#define IGBVF_MAX_TXD		4096
 42#define IGBVF_MIN_TXD		64
 43
 44#define IGBVF_DEFAULT_RXD	256
 45#define IGBVF_MAX_RXD		4096
 46#define IGBVF_MIN_RXD		64
 47
 48#define IGBVF_MIN_ITR_USECS	10 /* 100000 irq/sec */
 49#define IGBVF_MAX_ITR_USECS	10000 /* 100    irq/sec */
 50
 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
 60 *	   ITR timer expires.
 61 */
 62#define IGBVF_RX_PTHRESH	16
 63#define IGBVF_RX_HTHRESH	8
 64#define IGBVF_RX_WTHRESH	1
 65
 66/* this is the size past which hardware will drop packets when setting LPE=0 */
 67#define MAXIMUM_ETHERNET_VLAN_SIZE	1522
 68
 69#define IGBVF_FC_PAUSE_TIME	0x0680 /* 858 usec */
 70
 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 */
 75
 76#define AUTO_ALL_MODES		0
 77#define IGBVF_EEPROM_APME	0x0400
 78
 79#define IGBVF_MNG_VLAN_NONE	(-1)
 
 80
 81#define IGBVF_MAX_MAC_FILTERS	3
 82
 83/* Number of packet split data buffers (not including the header buffer) */
 84#define PS_PAGE_BUFFERS		(MAX_PS_BUFFERS - 1)
 85
 86enum igbvf_boards {
 87	board_vf,
 88	board_i350_vf,
 89};
 90
 91struct igbvf_queue_stats {
 92	u64 packets;
 93	u64 bytes;
 94};
 95
 96/* wrappers around a pointer to a socket buffer,
 
 97 * so a DMA handle can be stored along with the buffer
 98 */
 99struct igbvf_buffer {
100	dma_addr_t dma;
101	struct sk_buff *skb;
102	union {
103		/* Tx */
104		struct {
105			unsigned long time_stamp;
106			union e1000_adv_tx_desc *next_to_watch;
107			u16 length;
 
108			u16 mapped_as_page;
109		};
110		/* Rx */
111		struct {
112			struct page *page;
113			u64 page_dma;
114			unsigned int page_offset;
115		};
116	};
117};
118
119union igbvf_desc {
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;
123};
124
125struct igbvf_ring {
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 */
131
132	u16 next_to_use;
133	u16 next_to_clean;
134
135	u16 head;
136	u16 tail;
137
138	/* array of buffer information structs */
139	struct igbvf_buffer *buffer_info;
140	struct napi_struct napi;
141
142	char name[IFNAMSIZ + 5];
143	u32 eims_value;
144	u32 itr_val;
145	enum latency_range itr_range;
146	u16 itr_register;
147	int set_itr;
148
149	struct sk_buff *rx_skb_top;
150
151	struct igbvf_queue_stats stats;
152};
153
154/* board specific private data structure */
155struct igbvf_adapter {
156	struct timer_list watchdog_timer;
157	struct timer_list blink_timer;
158
159	struct work_struct reset_task;
160	struct work_struct watchdog_task;
161
162	const struct igbvf_info *ei;
163
164	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
165	u32 bd_number;
166	u32 rx_buffer_len;
167	u32 polling_interval;
168	u16 mng_vlan_id;
169	u16 link_speed;
170	u16 link_duplex;
171
172	spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
173
174	/* track device up/down/testing state */
175	unsigned long state;
176
177	/* Interrupt Throttle Rate */
178	u32 requested_itr; /* ints/sec or adaptive */
179	u32 current_itr; /* Actual ITR register value, not ints/sec */
180
181	/* Tx */
 
 
182	struct igbvf_ring *tx_ring /* One per active queue */
183	____cacheline_aligned_in_smp;
184
185	unsigned int restart_queue;
186	u32 txd_cmd;
187
188	u32 tx_int_delay;
189	u32 tx_abs_int_delay;
190
191	unsigned int total_tx_bytes;
192	unsigned int total_tx_packets;
193	unsigned int total_rx_bytes;
194	unsigned int total_rx_packets;
195
196	/* Tx stats */
197	u32 tx_timeout_count;
198	u32 tx_fifo_head;
199	u32 tx_head_addr;
200	u32 tx_fifo_size;
201	u32 tx_dma_failed;
202
203	/* Rx */
 
 
204	struct igbvf_ring *rx_ring;
205
206	u32 rx_int_delay;
207	u32 rx_abs_int_delay;
208
209	/* Rx stats */
210	u64 hw_csum_err;
211	u64 hw_csum_good;
212	u64 rx_hdr_split;
213	u32 alloc_rx_buff_failed;
214	u32 rx_dma_failed;
215
216	unsigned int rx_ps_hdr_size;
217	u32 max_frame_size;
218	u32 min_frame_size;
219
220	/* OS defined structs */
221	struct net_device *netdev;
222	struct pci_dev *pdev;
223	spinlock_t stats_lock; /* prevent concurrent stats updates */
 
224
225	/* structs defined in e1000_hw.h */
226	struct e1000_hw hw;
227
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	 * the first update, thus the flag..
231	 */
232	struct e1000_vf_stats stats;
233	u64 zero_base;
234
235	struct igbvf_ring test_tx_ring;
236	struct igbvf_ring test_rx_ring;
237	u32 test_icr;
238
239	u32 msg_enable;
240	struct msix_entry *msix_entries;
241	int int_mode;
242	u32 eims_enable_mask;
243	u32 eims_other;
244	u32 int_counter0;
245	u32 int_counter1;
246
247	u32 eeprom_wol;
248	u32 wol;
249	u32 pba;
250
251	bool fc_autoneg;
252
253	unsigned long led_status;
254
255	unsigned int flags;
256	unsigned long last_reset;
257};
258
259struct igbvf_info {
260	enum e1000_mac_type	mac;
261	unsigned int		flags;
262	u32			pba;
263	void			(*init_ops)(struct e1000_hw *);
264	s32			(*get_variants)(struct igbvf_adapter *);
265};
266
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))
276
277enum igbvf_state_t {
278	__IGBVF_TESTING,
279	__IGBVF_RESETTING,
280	__IGBVF_DOWN
281};
282
283extern char igbvf_driver_name[];
 
284
285void igbvf_check_options(struct igbvf_adapter *);
286void igbvf_set_ethtool_ops(struct net_device *);
287
288int igbvf_up(struct igbvf_adapter *);
289void igbvf_down(struct igbvf_adapter *);
290void igbvf_reinit_locked(struct igbvf_adapter *);
291int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *);
292int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *);
293void igbvf_free_rx_resources(struct igbvf_ring *);
294void igbvf_free_tx_resources(struct igbvf_ring *);
295void igbvf_update_stats(struct igbvf_adapter *);
296
297extern unsigned int copybreak;
298
299#endif /* _IGBVF_H_ */
v3.5.6
  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 <e1000-devel@lists.sourceforge.net>
 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 */
 42struct igbvf_info;
 43struct 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
 51enum latency_range {
 52	lowest_latency = 0,
 53	low_latency = 1,
 54	bulk_latency = 2,
 55	latency_invalid = 255
 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
109enum igbvf_boards {
110	board_vf,
111	board_i350_vf,
112};
113
114struct igbvf_queue_stats {
115	u64 packets;
116	u64 bytes;
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 */
123struct igbvf_buffer {
124	dma_addr_t dma;
125	struct sk_buff *skb;
126	union {
127		/* Tx */
128		struct {
129			unsigned long time_stamp;
 
130			u16 length;
131			u16 next_to_watch;
132			u16 mapped_as_page;
133		};
134		/* Rx */
135		struct {
136			struct page *page;
137			u64 page_dma;
138			unsigned int page_offset;
139		};
140	};
141};
142
143union igbvf_desc {
144	union e1000_adv_rx_desc rx_desc;
145	union e1000_adv_tx_desc tx_desc;
146	struct e1000_adv_tx_context_desc tx_context_desc;
147};
148
149struct 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
156	u16 next_to_use;
157	u16 next_to_clean;
158
159	u16 head;
160	u16 tail;
161
162	/* array of buffer information structs */
163	struct igbvf_buffer *buffer_info;
164	struct napi_struct napi;
165
166	char name[IFNAMSIZ + 5];
167	u32 eims_value;
168	u32 itr_val;
169	enum latency_range itr_range;
170	u16 itr_register;
171	int set_itr;
172
173	struct sk_buff *rx_skb_top;
174
175	struct igbvf_queue_stats stats;
176};
177
178/* board specific private data structure */
179struct igbvf_adapter {
180	struct timer_list watchdog_timer;
181	struct timer_list blink_timer;
182
183	struct work_struct reset_task;
184	struct work_struct watchdog_task;
185
186	const struct igbvf_info *ei;
187
188	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
189	u32 bd_number;
190	u32 rx_buffer_len;
191	u32 polling_interval;
192	u16 mng_vlan_id;
193	u16 link_speed;
194	u16 link_duplex;
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 */
209	____cacheline_aligned_in_smp;
210
211	unsigned int restart_queue;
212	u32 txd_cmd;
213
214	u32 tx_int_delay;
215	u32 tx_abs_int_delay;
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 */
223	u32 tx_timeout_count;
224	u32 tx_fifo_head;
225	u32 tx_head_addr;
226	u32 tx_fifo_size;
227	u32 tx_dma_failed;
228
229	/*
230	 * Rx
231	 */
232	struct igbvf_ring *rx_ring;
233
234	u32 rx_int_delay;
235	u32 rx_abs_int_delay;
236
237	/* Rx stats */
238	u64 hw_csum_err;
239	u64 hw_csum_good;
240	u64 rx_hdr_split;
241	u32 alloc_rx_buff_failed;
242	u32 rx_dma_failed;
243
244	unsigned int rx_ps_hdr_size;
245	u32 max_frame_size;
246	u32 min_frame_size;
247
248	/* OS defined structs */
249	struct net_device *netdev;
250	struct pci_dev *pdev;
251	struct net_device_stats net_stats;
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	 */
261	struct e1000_vf_stats stats;
262	u64 zero_base;
263
264	struct igbvf_ring test_tx_ring;
265	struct igbvf_ring test_rx_ring;
266	u32 test_icr;
267
268	u32 msg_enable;
269	struct msix_entry *msix_entries;
270	int int_mode;
271	u32 eims_enable_mask;
272	u32 eims_other;
273	u32 int_counter0;
274	u32 int_counter1;
275
276	u32 eeprom_wol;
277	u32 wol;
278	u32 pba;
279
280	bool fc_autoneg;
281
282	unsigned long led_status;
283
284	unsigned int flags;
285	unsigned long last_reset;
286};
287
288struct igbvf_info {
289	enum e1000_mac_type     mac;
290	unsigned int            flags;
291	u32                     pba;
292	void                    (*init_ops)(struct e1000_hw *);
293	s32                     (*get_variants)(struct igbvf_adapter *);
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
306enum igbvf_state_t {
307	__IGBVF_TESTING,
308	__IGBVF_RESETTING,
309	__IGBVF_DOWN
310};
311
312extern char igbvf_driver_name[];
313extern const char igbvf_driver_version[];
314
315extern void igbvf_check_options(struct igbvf_adapter *);
316extern void igbvf_set_ethtool_ops(struct net_device *);
317
318extern int igbvf_up(struct igbvf_adapter *);
319extern void igbvf_down(struct igbvf_adapter *);
320extern void igbvf_reinit_locked(struct igbvf_adapter *);
321extern int igbvf_setup_rx_resources(struct igbvf_adapter *, struct igbvf_ring *);
322extern int igbvf_setup_tx_resources(struct igbvf_adapter *, struct igbvf_ring *);
323extern void igbvf_free_rx_resources(struct igbvf_ring *);
324extern void igbvf_free_tx_resources(struct igbvf_ring *);
325extern void igbvf_update_stats(struct igbvf_adapter *);
326
327extern unsigned int copybreak;
328
329#endif /* _IGBVF_H_ */