Browse Source

[igbvf] Add igbvf driver

Driver for Intel 82576 based virtual functions, based on Intel source
code available at:

    http://sourceforge.net/projects/e1000  (igbvf-1.0.7)

Based on initial port from Eric Keller <ekeller@princeton.edu>.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Alex Williamson 13 years ago
parent
commit
c080de1a60

+ 1
- 0
src/Makefile View File

@@ -64,6 +64,7 @@ SRCDIRS		+= drivers/net
64 64
 SRCDIRS		+= drivers/net/e1000
65 65
 SRCDIRS		+= drivers/net/e1000e
66 66
 SRCDIRS		+= drivers/net/igb
67
+SRCDIRS		+= drivers/net/igbvf
67 68
 SRCDIRS		+= drivers/net/phantom
68 69
 SRCDIRS		+= drivers/net/rtl818x
69 70
 SRCDIRS		+= drivers/net/ath5k

+ 375
- 0
src/drivers/net/igbvf/igbvf.h View File

@@ -0,0 +1,375 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 1999 - 2008 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
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+FILE_LICENCE ( GPL2_ONLY );
30
+
31
+/* Linux PRO/1000 Ethernet Driver main header file */
32
+
33
+#ifndef _IGBVF_H_
34
+#define _IGBVF_H_
35
+
36
+#include "igbvf_vf.h"
37
+
38
+/* Forward declarations */
39
+struct igbvf_info;
40
+struct igbvf_adapter;
41
+
42
+/* Interrupt defines */
43
+#define IGBVF_START_ITR                    648 /* ~6000 ints/sec */
44
+
45
+/* Tx/Rx descriptor defines */
46
+#define IGBVF_DEFAULT_TXD		256
47
+#define IGBVF_MAX_TXD			4096
48
+#define IGBVF_MIN_TXD			80
49
+
50
+#define IGBVF_DEFAULT_RXD		256
51
+#define IGBVF_MAX_RXD			4096
52
+#define IGBVF_MIN_RXD			80
53
+
54
+#define IGBVF_MIN_ITR_USECS		10 /* 100000 irq/sec */
55
+#define IGBVF_MAX_ITR_USECS		10000 /* 100    irq/sec */
56
+
57
+/* RX descriptor control thresholds.
58
+ * PTHRESH - MAC will consider prefetch if it has fewer than this number of
59
+ *           descriptors available in its onboard memory.
60
+ *           Setting this to 0 disables RX descriptor prefetch.
61
+ * HTHRESH - MAC will only prefetch if there are at least this many descriptors
62
+ *           available in host memory.
63
+ *           If PTHRESH is 0, this should also be 0.
64
+ * WTHRESH - RX descriptor writeback threshold - MAC will delay writing back
65
+ *           descriptors until either it has this many to write back, or the
66
+ *           ITR timer expires.
67
+ */
68
+#define IGBVF_RX_PTHRESH                    16
69
+#define IGBVF_RX_HTHRESH                     8
70
+#define IGBVF_RX_WTHRESH                     1
71
+
72
+#define IGBVF_TX_PTHRESH                     8
73
+#define IGBVF_TX_HTHRESH                     1
74
+#define IGBVF_TX_WTHRESH                     1
75
+
76
+/* this is the size past which hardware will drop packets when setting LPE=0 */
77
+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
78
+
79
+#define IGBVF_FC_PAUSE_TIME		0x0680 /* 858 usec */
80
+
81
+/* How many Tx Descriptors do we need to call netif_wake_queue ? */
82
+#define IGBVF_TX_QUEUE_WAKE	32
83
+/* How many Rx Buffers do we bundle into one write to the hardware ? */
84
+#define IGBVF_RX_BUFFER_WRITE		16 /* Must be power of 2 */
85
+
86
+#define AUTO_ALL_MODES			0
87
+#define IGBVF_EEPROM_APME		0x0400
88
+
89
+#define IGBVF_MNG_VLAN_NONE		(-1)
90
+
91
+enum igbvf_boards {
92
+	board_vf,
93
+};
94
+
95
+struct igbvf_queue_stats {
96
+	u64 packets;
97
+	u64 bytes;
98
+};
99
+
100
+/*
101
+ * wrappers around a pointer to a socket buffer,
102
+ * so a DMA handle can be stored along with the buffer
103
+ */
104
+struct igbvf_buffer {
105
+	dma_addr_t dma;
106
+	dma_addr_t page_dma;
107
+	struct sk_buff *skb;
108
+	union {
109
+		/* Tx */
110
+		struct {
111
+			unsigned long time_stamp;
112
+			u16 length;
113
+			u16 next_to_watch;
114
+		};
115
+		/* Rx */
116
+		struct {
117
+			struct page *page;
118
+			unsigned int page_offset;
119
+		};
120
+	};
121
+	struct page *page;
122
+};
123
+
124
+struct igbvf_ring {
125
+	struct igbvf_adapter *adapter;  /* backlink */
126
+	void *desc;			/* pointer to ring memory  */
127
+	dma_addr_t dma;			/* phys address of ring    */
128
+	unsigned int size;		/* length of ring in bytes */
129
+	unsigned int count;		/* number of desc. in ring */
130
+
131
+	u16 next_to_use;
132
+	u16 next_to_clean;
133
+
134
+	u16 head;
135
+	u16 tail;
136
+
137
+	/* array of buffer information structs */
138
+	struct igbvf_buffer *buffer_info;
139
+#if 0
140
+	struct napi_struct napi;
141
+
142
+	char name[IFNAMSIZ + 5];
143
+#endif
144
+	u32 eims_value;
145
+	u32 itr_val;
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 */
155
+struct igbvf_adapter {
156
+#if 0
157
+	struct timer_list watchdog_timer;
158
+	struct timer_list blink_timer;
159
+
160
+	struct work_struct reset_task;
161
+	struct work_struct watchdog_task;
162
+
163
+	const struct igbvf_info *ei;
164
+
165
+	struct vlan_group *vlgrp;
166
+	u32 bd_number;
167
+	u32 rx_buffer_len;
168
+	u32 polling_interval;
169
+	u16 mng_vlan_id;
170
+	u16 link_speed;
171
+	u16 link_duplex;
172
+
173
+	spinlock_t tx_queue_lock; /* prevent concurrent tail updates */
174
+
175
+	/* track device up/down/testing state */
176
+	unsigned long state;
177
+
178
+	/* Interrupt Throttle Rate */
179
+	u32 itr;
180
+	u32 itr_setting;
181
+	u16 tx_itr;
182
+	u16 rx_itr;
183
+
184
+	/*
185
+	 * Tx
186
+	 */
187
+	struct igbvf_ring *tx_ring /* One per active queue */
188
+						____cacheline_aligned_in_smp;
189
+
190
+	unsigned long tx_queue_len;
191
+	unsigned int restart_queue;
192
+	u32 txd_cmd;
193
+
194
+	bool detect_tx_hung;
195
+	u8 tx_timeout_factor;
196
+
197
+	unsigned int total_tx_bytes;
198
+	unsigned int total_tx_packets;
199
+	unsigned int total_rx_bytes;
200
+	unsigned int total_rx_packets;
201
+
202
+	/* Tx stats */
203
+	u32 tx_timeout_count;
204
+	u32 tx_fifo_head;
205
+	u32 tx_head_addr;
206
+	u32 tx_fifo_size;
207
+	u32 tx_dma_failed;
208
+
209
+	/*
210
+	 * Rx
211
+	 */
212
+	struct igbvf_ring *rx_ring;
213
+
214
+	/* Rx stats */
215
+	u64 hw_csum_err;
216
+	u64 hw_csum_good;
217
+	u64 rx_hdr_split;
218
+	u32 alloc_rx_buff_failed;
219
+	u32 rx_dma_failed;
220
+
221
+	unsigned int rx_ps_hdr_size;
222
+	u32 max_frame_size;
223
+	u32 min_frame_size;
224
+
225
+	/* OS defined structs */
226
+	struct net_device *netdev;
227
+	struct pci_dev *pdev;
228
+	struct net_device_stats net_stats;
229
+	spinlock_t stats_lock;      /* prevent concurrent stats updates */
230
+
231
+	/* structs defined in e1000_hw.h */
232
+	struct e1000_hw hw;
233
+
234
+	/* The VF counters don't clear on read so we have to get a base
235
+	 * count on driver start up and always subtract that base on
236
+	 * on the first update, thus the flag..
237
+	 */
238
+	struct e1000_vf_stats stats;
239
+	u64 zero_base;
240
+
241
+	struct igbvf_ring test_tx_ring;
242
+	struct igbvf_ring test_rx_ring;
243
+	u32 test_icr;
244
+
245
+	u32 msg_enable;
246
+	struct msix_entry *msix_entries;
247
+	int int_mode;
248
+	u32 eims_enable_mask;
249
+	u32 eims_other;
250
+	u32 int_counter0;
251
+	u32 int_counter1;
252
+
253
+	u32 eeprom_wol;
254
+	u32 wol;
255
+	u32 pba;
256
+
257
+	bool fc_autoneg;
258
+
259
+	unsigned long led_status;
260
+
261
+	unsigned int flags;
262
+	unsigned long last_reset;
263
+	u32 *config_space;
264
+#endif
265
+        /* OS defined structs */
266
+        struct net_device *netdev;
267
+        struct pci_device *pdev;
268
+        struct net_device_stats net_stats;
269
+
270
+        /* structs defined in e1000_hw.h */
271
+        struct e1000_hw hw;
272
+
273
+        u32 min_frame_size;
274
+        u32 max_frame_size;
275
+
276
+        u32 max_hw_frame_size;
277
+
278
+#define NUM_TX_DESC     8
279
+#define NUM_RX_DESC     8
280
+
281
+        struct io_buffer *tx_iobuf[NUM_TX_DESC];
282
+        struct io_buffer *rx_iobuf[NUM_RX_DESC];
283
+
284
+        union e1000_adv_tx_desc *tx_base;
285
+        union e1000_adv_rx_desc *rx_base;
286
+
287
+        uint32_t tx_ring_size;
288
+        uint32_t rx_ring_size;
289
+
290
+        uint32_t tx_head;
291
+        uint32_t tx_tail;
292
+        uint32_t tx_fill_ctr;
293
+
294
+        uint32_t rx_curr;
295
+
296
+        uint32_t ioaddr;
297
+        uint32_t irqno;
298
+
299
+        uint32_t tx_int_delay;
300
+        uint32_t tx_abs_int_delay;
301
+        uint32_t txd_cmd;
302
+};
303
+
304
+struct igbvf_info {
305
+	enum e1000_mac_type	mac;
306
+	unsigned int		flags;
307
+	u32			pba;
308
+	void			(*init_ops)(struct e1000_hw *);
309
+	s32			(*get_variants)(struct igbvf_adapter *);
310
+};
311
+
312
+/* hardware capability, feature, and workaround flags */
313
+#define IGBVF_FLAG_RX_CSUM_DISABLED       (1 << 0)
314
+
315
+#define IGBVF_DESC_UNUSED(R) \
316
+	((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
317
+	(R)->next_to_clean - (R)->next_to_use - 1)
318
+
319
+#define IGBVF_RX_DESC_ADV(R, i)	    \
320
+	(&(((union e1000_adv_rx_desc *)((R).desc))[i]))
321
+#define IGBVF_TX_DESC_ADV(R, i)	    \
322
+	(&(((union e1000_adv_tx_desc *)((R).desc))[i]))
323
+#define IGBVF_TX_CTXTDESC_ADV(R, i)	    \
324
+	(&(((struct e1000_adv_tx_context_desc *)((R).desc))[i]))
325
+
326
+enum igbvf_state_t {
327
+	__IGBVF_TESTING,
328
+	__IGBVF_RESETTING,
329
+	__IGBVF_DOWN
330
+};
331
+
332
+enum latency_range {
333
+	lowest_latency = 0,
334
+	low_latency = 1,
335
+	bulk_latency = 2,
336
+	latency_invalid = 255
337
+};
338
+
339
+extern char igbvf_driver_name[];
340
+extern const char igbvf_driver_version[];
341
+
342
+extern void igbvf_check_options(struct igbvf_adapter *adapter);
343
+extern void igbvf_set_ethtool_ops(struct net_device *netdev);
344
+#ifdef ETHTOOL_OPS_COMPAT
345
+extern int ethtool_ioctl(struct ifreq *ifr);
346
+#endif
347
+
348
+extern int igbvf_up(struct igbvf_adapter *adapter);
349
+extern void igbvf_down(struct igbvf_adapter *adapter);
350
+extern void igbvf_reinit_locked(struct igbvf_adapter *adapter);
351
+extern void igbvf_reset(struct igbvf_adapter *adapter);
352
+extern int igbvf_setup_rx_resources(struct igbvf_adapter *adapter);
353
+extern int igbvf_setup_tx_resources(struct igbvf_adapter *adapter);
354
+extern void igbvf_free_rx_resources(struct igbvf_adapter *adapter);
355
+extern void igbvf_free_tx_resources(struct igbvf_adapter *adapter);
356
+extern void igbvf_update_stats(struct igbvf_adapter *adapter);
357
+extern void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter);
358
+extern void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter);
359
+
360
+extern unsigned int copybreak;
361
+
362
+static inline u32 __er32(struct e1000_hw *hw, unsigned long reg)
363
+{
364
+	return readl(hw->hw_addr + reg);
365
+}
366
+
367
+static inline void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
368
+{
369
+	writel(val, hw->hw_addr + reg);
370
+}
371
+#define er32(reg)	E1000_READ_REG(hw, E1000_##reg)
372
+#define ew32(reg,val)	E1000_WRITE_REG(hw, E1000_##reg, (val))
373
+#define e1e_flush()	er32(STATUS)
374
+
375
+#endif /* _IGBVF_H_ */

+ 1395
- 0
src/drivers/net/igbvf/igbvf_defines.h
File diff suppressed because it is too large
View File


+ 955
- 0
src/drivers/net/igbvf/igbvf_main.c View File

@@ -0,0 +1,955 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 2009 Intel Corporation.
5
+
6
+  Copyright(c) 2010 Eric Keller <ekeller@princeton.edu>
7
+  Copyright(c) 2010 Red Hat Inc.
8
+	Alex Williamson <alex.williamson@redhat.com>
9
+
10
+  This program is free software; you can redistribute it and/or modify it
11
+  under the terms and conditions of the GNU General Public License,
12
+  version 2, as published by the Free Software Foundation.
13
+
14
+  This program is distributed in the hope it will be useful, but WITHOUT
15
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17
+  more details.
18
+
19
+  You should have received a copy of the GNU General Public License along with
20
+  this program; if not, write to the Free Software Foundation, Inc.,
21
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
22
+
23
+  The full GNU General Public License is included in this distribution in
24
+  the file called "COPYING".
25
+
26
+  Contact Information:
27
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
28
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
29
+
30
+*******************************************************************************/
31
+
32
+FILE_LICENCE ( GPL2_ONLY );
33
+
34
+#include "igbvf.h"
35
+
36
+/**
37
+ * igbvf_setup_tx_resources - allocate Tx resources (Descriptors)
38
+ *
39
+ * @v adapter   e1000 private structure
40
+ *
41
+ * @ret rc       Returns 0 on success, negative on failure
42
+ **/
43
+int igbvf_setup_tx_resources ( struct igbvf_adapter *adapter )
44
+{
45
+	DBG ( "igbvf_setup_tx_resources\n" );
46
+
47
+	/* Allocate transmit descriptor ring memory.
48
+	   It must not cross a 64K boundary because of hardware errata #23
49
+	   so we use malloc_dma() requesting a 128 byte block that is
50
+	   128 byte aligned. This should guarantee that the memory
51
+	   allocated will not cross a 64K boundary, because 128 is an
52
+	   even multiple of 65536 ( 65536 / 128 == 512 ), so all possible
53
+	   allocations of 128 bytes on a 128 byte boundary will not
54
+	   cross 64K bytes.
55
+	 */
56
+
57
+	adapter->tx_base =
58
+		malloc_dma ( adapter->tx_ring_size, adapter->tx_ring_size );
59
+
60
+	if ( ! adapter->tx_base ) {
61
+		return -ENOMEM;
62
+	}
63
+
64
+	memset ( adapter->tx_base, 0, adapter->tx_ring_size );
65
+
66
+	DBG ( "adapter->tx_base = %#08lx\n", virt_to_bus ( adapter->tx_base ) );
67
+
68
+	return 0;
69
+}
70
+
71
+/**
72
+ * igbvf_free_tx_resources - Free Tx Resources per Queue
73
+ * @adapter: board private structure
74
+ *
75
+ * Free all transmit software resources
76
+ **/
77
+void igbvf_free_tx_resources ( struct igbvf_adapter *adapter )
78
+{
79
+	DBG ( "igbvf_free_tx_resources\n" );
80
+
81
+	free_dma ( adapter->tx_base, adapter->tx_ring_size );
82
+}
83
+
84
+/**
85
+ * igbvf_free_rx_resources - Free Rx Resources
86
+ * @adapter: board private structure
87
+ *
88
+ * Free all receive software resources
89
+ **/
90
+void igbvf_free_rx_resources ( struct igbvf_adapter *adapter )
91
+{
92
+	int i;
93
+
94
+	DBG ( "igbvf_free_rx_resources\n" );
95
+
96
+	free_dma ( adapter->rx_base, adapter->rx_ring_size );
97
+
98
+	for ( i = 0; i < NUM_RX_DESC; i++ ) {
99
+		free_iob ( adapter->rx_iobuf[i] );
100
+	}
101
+}
102
+
103
+/**
104
+ * igbvf_refill_rx_ring - allocate Rx io_buffers
105
+ *
106
+ * @v adapter   e1000 private structure
107
+ *
108
+ * @ret rc       Returns 0 on success, negative on failure
109
+ **/
110
+static int igbvf_refill_rx_ring ( struct igbvf_adapter *adapter )
111
+{
112
+	int i, rx_curr;
113
+	int rc = 0;
114
+	union e1000_adv_rx_desc *rx_curr_desc;
115
+	struct e1000_hw *hw = &adapter->hw;
116
+	struct io_buffer *iob;
117
+
118
+	DBGP ("igbvf_refill_rx_ring\n");
119
+
120
+	for ( i = 0; i < NUM_RX_DESC; i++ ) {
121
+		rx_curr = ( ( adapter->rx_curr + i ) % NUM_RX_DESC );
122
+		rx_curr_desc = adapter->rx_base + rx_curr;
123
+
124
+		if ( rx_curr_desc->wb.upper.status_error & E1000_RXD_STAT_DD )
125
+			continue;
126
+
127
+		if ( adapter->rx_iobuf[rx_curr] != NULL )
128
+			continue;
129
+
130
+		DBG2 ( "Refilling rx desc %d\n", rx_curr );
131
+
132
+		iob = alloc_iob ( MAXIMUM_ETHERNET_VLAN_SIZE );
133
+		adapter->rx_iobuf[rx_curr] = iob;
134
+
135
+		rx_curr_desc->wb.upper.status_error = 0;
136
+
137
+		if ( ! iob ) {
138
+			DBG ( "alloc_iob failed\n" );
139
+			rc = -ENOMEM;
140
+			break;
141
+		} else {
142
+			rx_curr_desc->read.pkt_addr = virt_to_bus ( iob->data );
143
+			rx_curr_desc->read.hdr_addr = 0;
144
+			ew32 ( RDT(0), rx_curr );
145
+		}
146
+	}
147
+	return rc;
148
+}
149
+
150
+/**
151
+ * igbvf_irq_disable - Mask off interrupt generation on the NIC
152
+ * @adapter: board private structure
153
+ **/
154
+static void igbvf_irq_disable ( struct igbvf_adapter *adapter )
155
+{
156
+	struct e1000_hw *hw = &adapter->hw;
157
+
158
+	ew32 ( EIMC, ~0 );
159
+}
160
+
161
+/**
162
+ * igbvf_irq_enable - Enable default interrupt generation settings
163
+ * @adapter: board private structure
164
+ **/
165
+static void igbvf_irq_enable ( struct igbvf_adapter *adapter )
166
+{
167
+	struct e1000_hw *hw = &adapter->hw;
168
+
169
+	ew32 ( EIAC, IMS_ENABLE_MASK );
170
+	ew32 ( EIAM, IMS_ENABLE_MASK );
171
+	ew32 ( EIMS, IMS_ENABLE_MASK );
172
+}
173
+
174
+/**
175
+ * igbvf_irq - enable or Disable interrupts
176
+ *
177
+ * @v adapter   e1000 adapter
178
+ * @v action    requested interrupt action
179
+ **/
180
+static void igbvf_irq ( struct net_device *netdev, int enable )
181
+{
182
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
183
+
184
+	DBG ( "igbvf_irq\n" );
185
+
186
+	if ( enable ) {
187
+		igbvf_irq_enable ( adapter );
188
+	} else {
189
+		igbvf_irq_disable ( adapter );
190
+	}
191
+}
192
+
193
+/**
194
+ * igbvf_process_tx_packets - process transmitted packets
195
+ *
196
+ * @v netdev    network interface device structure
197
+ **/
198
+static void igbvf_process_tx_packets ( struct net_device *netdev )
199
+{
200
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
201
+	uint32_t i;
202
+	uint32_t tx_status;
203
+	union e1000_adv_tx_desc *tx_curr_desc;
204
+
205
+	/* Check status of transmitted packets
206
+	 */
207
+	DBGP ( "process_tx_packets: tx_head = %d, tx_tail = %d\n", adapter->tx_head,
208
+	      adapter->tx_tail );
209
+
210
+	while ( ( i = adapter->tx_head ) != adapter->tx_tail ) {
211
+
212
+		tx_curr_desc = ( void * )  ( adapter->tx_base ) +
213
+					   ( i * sizeof ( *adapter->tx_base ) );
214
+
215
+		tx_status = tx_curr_desc->wb.status;
216
+		DBG ( "  tx_curr_desc = %#08lx\n", virt_to_bus ( tx_curr_desc ) );
217
+		DBG ( "  tx_status = %#08x\n", tx_status );
218
+
219
+		/* if the packet at tx_head is not owned by hardware it is for us */
220
+		if ( ! ( tx_status & E1000_TXD_STAT_DD ) )
221
+			break;
222
+
223
+		DBG ( "Sent packet. tx_head: %d tx_tail: %d tx_status: %#08x\n",
224
+		      adapter->tx_head, adapter->tx_tail, tx_status );
225
+
226
+		netdev_tx_complete ( netdev, adapter->tx_iobuf[i] );
227
+		DBG ( "Success transmitting packet, tx_status: %#08x\n",
228
+		      tx_status );
229
+
230
+		/* Decrement count of used descriptors, clear this descriptor
231
+		 */
232
+		adapter->tx_fill_ctr--;
233
+		memset ( tx_curr_desc, 0, sizeof ( *tx_curr_desc ) );
234
+
235
+		adapter->tx_head = ( adapter->tx_head + 1 ) % NUM_TX_DESC;
236
+	}
237
+}
238
+
239
+/**
240
+ * igbvf_process_rx_packets - process received packets
241
+ *
242
+ * @v netdev    network interface device structure
243
+ **/
244
+static void igbvf_process_rx_packets ( struct net_device *netdev )
245
+{
246
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
247
+	struct e1000_hw *hw = &adapter->hw;
248
+	uint32_t i;
249
+	uint32_t rx_status;
250
+	uint32_t rx_len;
251
+	uint32_t rx_err;
252
+	union e1000_adv_rx_desc *rx_curr_desc;
253
+
254
+	DBGP ( "igbvf_process_rx_packets\n" );
255
+
256
+	/* Process received packets
257
+	 */
258
+	while ( 1 ) {
259
+		i = adapter->rx_curr;
260
+
261
+		rx_curr_desc = ( void * )  ( adapter->rx_base ) +
262
+				  ( i * sizeof ( *adapter->rx_base ) );
263
+		rx_status = rx_curr_desc->wb.upper.status_error;
264
+
265
+		DBG2 ( "Before DD Check RX_status: %#08x, rx_curr: %d\n",
266
+		       rx_status, i );
267
+
268
+		if ( ! ( rx_status & E1000_RXD_STAT_DD ) )
269
+			break;
270
+
271
+		if ( adapter->rx_iobuf[i] == NULL )
272
+			break;
273
+
274
+		DBG ( "E1000_RCTL = %#08x\n", er32 (RCTL) );
275
+
276
+		rx_len = rx_curr_desc->wb.upper.length;
277
+
278
+		DBG ( "Received packet, rx_curr: %d  rx_status: %#08x  rx_len: %d\n",
279
+		      i, rx_status, rx_len );
280
+
281
+		rx_err = rx_status;
282
+
283
+		iob_put ( adapter->rx_iobuf[i], rx_len );
284
+
285
+		if ( rx_err & E1000_RXDEXT_ERR_FRAME_ERR_MASK ) {
286
+
287
+			netdev_rx_err ( netdev, adapter->rx_iobuf[i], -EINVAL );
288
+			DBG ( "igbvf_process_rx_packets: Corrupted packet received!"
289
+			      " rx_err: %#08x\n", rx_err );
290
+		} else  {
291
+			/* Add this packet to the receive queue. */
292
+			netdev_rx ( netdev, adapter->rx_iobuf[i] );
293
+		}
294
+		adapter->rx_iobuf[i] = NULL;
295
+
296
+		memset ( rx_curr_desc, 0, sizeof ( *rx_curr_desc ) );
297
+
298
+		adapter->rx_curr = ( adapter->rx_curr + 1 ) % NUM_RX_DESC;
299
+	}
300
+}
301
+
302
+/**
303
+ * igbvf_poll - Poll for received packets
304
+ *
305
+ * @v netdev    Network device
306
+ */
307
+static void igbvf_poll ( struct net_device *netdev )
308
+{
309
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
310
+	uint32_t rx_status;
311
+	union e1000_adv_rx_desc *rx_curr_desc;
312
+
313
+	DBGP ( "igbvf_poll\n" );
314
+
315
+	rx_curr_desc = ( void * )  ( adapter->rx_base ) +
316
+			( adapter->rx_curr * sizeof ( *adapter->rx_base ) );
317
+	rx_status = rx_curr_desc->wb.upper.status_error;
318
+
319
+	if ( ! ( rx_status & E1000_RXD_STAT_DD ) )
320
+		return;
321
+
322
+	igbvf_process_tx_packets ( netdev );
323
+
324
+	igbvf_process_rx_packets ( netdev );
325
+
326
+	igbvf_refill_rx_ring ( adapter );
327
+}
328
+
329
+/**
330
+ *  igbvf_config_collision_dist_generic - Configure collision distance
331
+ *  @hw: pointer to the HW structure
332
+ *
333
+ *  Configures the collision distance to the default value and is used
334
+ *  during link setup. Currently no func pointer exists and all
335
+ *  implementations are handled in the generic version of this function.
336
+ **/
337
+void igbvf_config_collision_dist ( struct e1000_hw *hw )
338
+{
339
+	u32 tctl;
340
+
341
+	DBG ("igbvf_config_collision_dist");
342
+
343
+	tctl = er32 (TCTL);
344
+
345
+	tctl &= ~E1000_TCTL_COLD;
346
+	tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
347
+
348
+	ew32 (TCTL, tctl);
349
+	e1e_flush();
350
+}
351
+
352
+/**
353
+ * igbvf_configure_tx - Configure Transmit Unit after Reset
354
+ * @adapter: board private structure
355
+ *
356
+ * Configure the Tx unit of the MAC after a reset.
357
+ **/
358
+static void igbvf_configure_tx ( struct igbvf_adapter *adapter )
359
+{
360
+	struct e1000_hw *hw = &adapter->hw;
361
+	u32 tctl, txdctl;
362
+
363
+	DBG ( "igbvf_configure_tx\n" );
364
+
365
+	/* disable transmits while setting up the descriptors */
366
+	tctl = er32 ( TCTL );
367
+	ew32 ( TCTL, tctl & ~E1000_TCTL_EN );
368
+	e1e_flush();
369
+	mdelay (10);
370
+
371
+	ew32 ( TDBAH(0), 0 );
372
+	ew32 ( TDBAL(0), virt_to_bus ( adapter->tx_base ) );
373
+	ew32 ( TDLEN(0), adapter->tx_ring_size );
374
+
375
+	DBG ( "E1000_TDBAL(0): %#08x\n",  er32 ( TDBAL(0) ) );
376
+	DBG ( "E1000_TDLEN(0): %d\n",     er32 ( TDLEN(0) ) );
377
+
378
+	/* Setup the HW Tx Head and Tail descriptor pointers */
379
+	ew32 ( TDH(0), 0 );
380
+	ew32 ( TDT(0), 0 );
381
+
382
+	adapter->tx_head = 0;
383
+	adapter->tx_tail = 0;
384
+	adapter->tx_fill_ctr = 0;
385
+
386
+	txdctl = er32(TXDCTL(0));
387
+	txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
388
+	ew32 ( TXDCTL(0), txdctl );
389
+
390
+	txdctl = er32 ( TXDCTL(0) );
391
+	txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
392
+	ew32 ( TXDCTL(0), txdctl );
393
+
394
+	/* Setup Transmit Descriptor Settings for eop descriptor */
395
+	adapter->txd_cmd  = E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_IFCS;
396
+
397
+	/* Advanced descriptor */
398
+	adapter->txd_cmd |= E1000_ADVTXD_DCMD_DEXT;
399
+
400
+	/* (not part of cmd, but in same 32 bit word...) */
401
+	adapter->txd_cmd |= E1000_ADVTXD_DTYP_DATA;
402
+
403
+	/* enable Report Status bit */
404
+	adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS;
405
+
406
+	/* Program the Transmit Control Register */
407
+	tctl &= ~E1000_TCTL_CT;
408
+	tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
409
+		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
410
+
411
+	igbvf_config_collision_dist ( hw );
412
+
413
+	/* Enable transmits */
414
+	tctl |= E1000_TCTL_EN;
415
+	ew32(TCTL, tctl);
416
+	e1e_flush();
417
+}
418
+
419
+/* igbvf_reset - bring the hardware into a known good state
420
+ *
421
+ * This function boots the hardware and enables some settings that
422
+ * require a configuration cycle of the hardware - those cannot be
423
+ * set/changed during runtime. After reset the device needs to be
424
+ * properly configured for Rx, Tx etc.
425
+ */
426
+void igbvf_reset ( struct igbvf_adapter *adapter )
427
+{
428
+	struct e1000_mac_info *mac = &adapter->hw.mac;
429
+	struct net_device *netdev = adapter->netdev;
430
+	struct e1000_hw *hw = &adapter->hw;
431
+
432
+	/* Allow time for pending master requests to run */
433
+	if ( mac->ops.reset_hw(hw) )
434
+		DBG ("PF still resetting\n");
435
+
436
+	mac->ops.init_hw ( hw );
437
+
438
+	if ( is_valid_ether_addr(adapter->hw.mac.addr) ) {
439
+		memcpy ( netdev->hw_addr, adapter->hw.mac.addr, ETH_ALEN );
440
+	}
441
+}
442
+
443
+extern void igbvf_init_function_pointers_vf(struct e1000_hw *hw);
444
+
445
+/**
446
+ * igbvf_sw_init - Initialize general software structures (struct igbvf_adapter)
447
+ * @adapter: board private structure to initialize
448
+ *
449
+ * igbvf_sw_init initializes the Adapter private data structure.
450
+ * Fields are initialized based on PCI device information and
451
+ * OS network device settings (MTU size).
452
+ **/
453
+static int __devinit igbvf_sw_init ( struct igbvf_adapter *adapter )
454
+{
455
+        struct e1000_hw *hw = &adapter->hw;
456
+        struct pci_device *pdev = adapter->pdev;
457
+        int rc;
458
+
459
+        /* PCI config space info */
460
+
461
+        hw->vendor_id = pdev->vendor;
462
+        hw->device_id = pdev->device;
463
+
464
+        pci_read_config_byte ( pdev, PCI_REVISION_ID, &hw->revision_id );
465
+
466
+        pci_read_config_word ( pdev, PCI_COMMAND, &hw->bus.pci_cmd_word );
467
+
468
+        adapter->max_frame_size = MAXIMUM_ETHERNET_VLAN_SIZE + ETH_HLEN + ETH_FCS_LEN;
469
+        adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
470
+
471
+	/* Set various function pointers */
472
+        igbvf_init_function_pointers_vf ( &adapter->hw );
473
+
474
+	rc = adapter->hw.mac.ops.init_params ( &adapter->hw );
475
+	if (rc) {
476
+                DBG ("hw.mac.ops.init_params(&adapter->hw) Failure\n");
477
+		return rc;
478
+        }
479
+
480
+	rc = adapter->hw.mbx.ops.init_params ( &adapter->hw );
481
+	if (rc) {
482
+                DBG ("hw.mbx.ops.init_params(&adapter->hw) Failure\n");
483
+		return rc;
484
+        }
485
+
486
+	/* Explicitly disable IRQ since the NIC can be in any state. */
487
+	igbvf_irq_disable ( adapter );
488
+
489
+	return 0;
490
+}
491
+
492
+/**
493
+ * igbvf_setup_srrctl - configure the receive control registers
494
+ * @adapter: Board private structure
495
+ **/
496
+static void igbvf_setup_srrctl ( struct igbvf_adapter *adapter )
497
+{
498
+	struct e1000_hw *hw = &adapter->hw;
499
+	u32 srrctl = 0;
500
+
501
+	DBG ( "igbvf_setup_srrctl\n" );
502
+
503
+	srrctl &= ~(E1000_SRRCTL_DESCTYPE_MASK |
504
+		    E1000_SRRCTL_BSIZEHDR_MASK |
505
+		    E1000_SRRCTL_BSIZEPKT_MASK);
506
+
507
+	/* Enable queue drop to avoid head of line blocking */
508
+	srrctl |= E1000_SRRCTL_DROP_EN;
509
+
510
+	/* Setup buffer sizes */
511
+        srrctl |= 2048 >> E1000_SRRCTL_BSIZEPKT_SHIFT;
512
+	srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;
513
+
514
+	ew32 ( SRRCTL(0), srrctl );
515
+}
516
+
517
+/**
518
+ * igbvf_configure_rx - Configure 8254x Receive Unit after Reset
519
+ * @adapter: board private structure
520
+ *
521
+ * Configure the Rx unit of the MAC after a reset.
522
+ **/
523
+static void igbvf_configure_rx ( struct igbvf_adapter *adapter )
524
+{
525
+        struct e1000_hw *hw = &adapter->hw;
526
+        u32 rxdctl;
527
+
528
+	DBG ( "igbvf_configure_rx\n" );
529
+
530
+        /* disable receives */
531
+        rxdctl = er32 ( RXDCTL(0) );
532
+        ew32 ( RXDCTL(0), rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE );
533
+        msleep ( 10 );
534
+
535
+        /*
536
+         * Setup the HW Rx Head and Tail Descriptor Pointers and
537
+         * the Base and Length of the Rx Descriptor Ring
538
+         */
539
+        ew32 ( RDBAL(0), virt_to_bus (adapter->rx_base) );
540
+        ew32 ( RDBAH(0), 0 );
541
+        ew32 ( RDLEN(0), adapter->rx_ring_size );
542
+	adapter->rx_curr = 0;
543
+        ew32 ( RDH(0), 0 );
544
+        ew32 ( RDT(0), 0 );
545
+
546
+        rxdctl |= E1000_RXDCTL_QUEUE_ENABLE;
547
+        rxdctl &= 0xFFF00000;
548
+        rxdctl |= IGBVF_RX_PTHRESH;
549
+        rxdctl |= IGBVF_RX_HTHRESH << 8;
550
+        rxdctl |= IGBVF_RX_WTHRESH << 16;
551
+
552
+        igbvf_rlpml_set_vf ( hw, adapter->max_frame_size );
553
+
554
+        /* enable receives */
555
+        ew32 ( RXDCTL(0), rxdctl );
556
+        ew32 ( RDT(0), NUM_RX_DESC );
557
+}
558
+
559
+/**
560
+ * igbvf_setup_rx_resources - allocate Rx resources (Descriptors)
561
+ *
562
+ * @v adapter   e1000 private structure
563
+ **/
564
+int igbvf_setup_rx_resources ( struct igbvf_adapter *adapter )
565
+{
566
+	int i;
567
+	union e1000_adv_rx_desc *rx_curr_desc;
568
+        struct io_buffer *iob;
569
+
570
+	DBG ( "igbvf_setup_rx_resources\n" );
571
+
572
+	/* Allocate receive descriptor ring memory.
573
+	   It must not cross a 64K boundary because of hardware errata
574
+	 */
575
+
576
+	adapter->rx_base =
577
+		malloc_dma ( adapter->rx_ring_size, adapter->rx_ring_size );
578
+
579
+	if ( ! adapter->rx_base ) {
580
+		return -ENOMEM;
581
+	}
582
+	memset ( adapter->rx_base, 0, adapter->rx_ring_size );
583
+
584
+	for ( i = 0; i < NUM_RX_DESC; i++ ) {
585
+                rx_curr_desc = adapter->rx_base + i;
586
+                iob = alloc_iob ( MAXIMUM_ETHERNET_VLAN_SIZE );
587
+                adapter->rx_iobuf[i] = iob;
588
+                rx_curr_desc->wb.upper.status_error = 0;
589
+                if ( ! iob ) {
590
+                        DBG ( "alloc_iob failed\n" );
591
+                        return -ENOMEM;
592
+                } else {
593
+                        rx_curr_desc->read.pkt_addr = virt_to_bus ( iob->data );
594
+                        rx_curr_desc->read.hdr_addr = 0;
595
+                }
596
+	}
597
+
598
+	return 0;
599
+}
600
+
601
+/**
602
+ * igbvf_open - Called when a network interface is made active
603
+ * @netdev: network interface device structure
604
+ *
605
+ * Returns 0 on success, negative value on failure
606
+ *
607
+ * The open entry point is called when a network interface is made
608
+ * active by the system (IFF_UP).  At this point all resources needed
609
+ * for transmit and receive operations are allocated, the interrupt
610
+ * handler is registered with the OS, the watchdog timer is started,
611
+ * and the stack is notified that the interface is ready.
612
+ **/
613
+static int igbvf_open ( struct net_device *netdev )
614
+{
615
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
616
+	int err;
617
+
618
+	DBG ("igbvf_open\n");
619
+
620
+	/* allocate transmit descriptors */
621
+	err = igbvf_setup_tx_resources ( adapter );
622
+	if (err) {
623
+		DBG ( "Error setting up TX resources!\n" );
624
+		goto err_setup_tx;
625
+	}
626
+
627
+	igbvf_configure_tx ( adapter );
628
+
629
+	igbvf_setup_srrctl( adapter );
630
+
631
+	err = igbvf_setup_rx_resources( adapter );
632
+	if (err) {
633
+		DBG ( "Error setting up RX resources!\n" );
634
+		goto err_setup_rx;
635
+	}
636
+
637
+	igbvf_configure_rx ( adapter );
638
+
639
+	return 0;
640
+
641
+err_setup_rx:
642
+	DBG ( "err_setup_rx\n" );
643
+	igbvf_free_tx_resources ( adapter );
644
+	return err;
645
+
646
+err_setup_tx:
647
+	DBG ( "err_setup_tx\n" );
648
+	igbvf_reset ( adapter );
649
+
650
+	return err;
651
+}
652
+
653
+/**
654
+ * igbvf_close - Disables a network interface
655
+ * @netdev: network interface device structure
656
+ *
657
+ * Returns 0, this is not allowed to fail
658
+ *
659
+ * The close entry point is called when an interface is de-activated
660
+ * by the OS.  The hardware is still under the drivers control, but
661
+ * needs to be disabled.  A global MAC reset is issued to stop the
662
+ * hardware, and all transmit and receive resources are freed.
663
+ **/
664
+static void igbvf_close ( struct net_device *netdev )
665
+{
666
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
667
+        struct e1000_hw *hw = &adapter->hw;
668
+        uint32_t rxdctl;
669
+        uint32_t icr;
670
+
671
+        DBG ( "igbvf_close\n" );
672
+        icr = er32(EICR);
673
+
674
+        igbvf_irq_disable ( adapter );
675
+
676
+        /* disable receives */
677
+        rxdctl = er32 ( RXDCTL(0) );
678
+        ew32 ( RXDCTL(0), rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE );
679
+        mdelay ( 10 );
680
+
681
+        igbvf_reset ( adapter );
682
+
683
+	igbvf_free_tx_resources( adapter );
684
+	igbvf_free_rx_resources( adapter );
685
+}
686
+
687
+/**
688
+ * igbvf_transmit - Transmit a packet
689
+ *
690
+ * @v netdev    Network device
691
+ * @v iobuf     I/O buffer
692
+ *
693
+ * @ret rc       Returns 0 on success, negative on failure
694
+ */
695
+static int igbvf_transmit ( struct net_device *netdev, struct io_buffer *iobuf )
696
+{
697
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
698
+	struct e1000_hw *hw = &adapter->hw;
699
+	uint32_t tx_curr = adapter->tx_tail;
700
+	union e1000_adv_tx_desc *tx_curr_desc;
701
+
702
+	DBGP ("igbvf_transmit\n");
703
+
704
+	if ( adapter->tx_fill_ctr == NUM_TX_DESC ) {
705
+		DBG ("TX overflow\n");
706
+		return -ENOBUFS;
707
+	}
708
+
709
+	/* Save pointer to iobuf we have been given to transmit,
710
+	   netdev_tx_complete() will need it later
711
+	 */
712
+	adapter->tx_iobuf[tx_curr] = iobuf;
713
+
714
+	tx_curr_desc = ( void * ) ( adapter->tx_base ) +
715
+		       ( tx_curr * sizeof ( *adapter->tx_base ) );
716
+
717
+	DBG ( "tx_curr_desc = %#08lx\n", virt_to_bus ( tx_curr_desc ) );
718
+	DBG ( "tx_curr_desc + 16 = %#08lx\n", virt_to_bus ( tx_curr_desc ) + 16 );
719
+	DBG ( "iobuf->data = %#08lx\n", virt_to_bus ( iobuf->data ) );
720
+
721
+	/* Add the packet to TX ring
722
+	 */
723
+	tx_curr_desc->read.buffer_addr = virt_to_bus ( iobuf->data );
724
+	tx_curr_desc->read.cmd_type_len = adapter->txd_cmd |(iob_len ( iobuf )) ;
725
+	// minus hdr_len ????
726
+	tx_curr_desc->read.olinfo_status = ((iob_len ( iobuf )) << E1000_ADVTXD_PAYLEN_SHIFT);
727
+
728
+	DBG ( "TX fill: %d tx_curr: %d addr: %#08lx len: %zd\n", adapter->tx_fill_ctr,
729
+	      tx_curr, virt_to_bus ( iobuf->data ), iob_len ( iobuf ) );
730
+
731
+	/* Point to next free descriptor */
732
+	adapter->tx_tail = ( adapter->tx_tail + 1 ) % NUM_TX_DESC;
733
+	adapter->tx_fill_ctr++;
734
+
735
+	/* Write new tail to NIC, making packet available for transmit
736
+	 */
737
+	ew32 ( TDT(0), adapter->tx_tail );
738
+	e1e_flush ();
739
+
740
+	return 0;
741
+}
742
+
743
+/** igbvf net device operations */
744
+static struct net_device_operations igbvf_operations = {
745
+	.open		= igbvf_open,
746
+	.close		= igbvf_close,
747
+	.transmit	= igbvf_transmit,
748
+	.poll		= igbvf_poll,
749
+	.irq		= igbvf_irq,
750
+};
751
+
752
+/**
753
+ * igbvf_get_hw_control - get control of the h/w from f/w
754
+ * @adapter: address of board private structure
755
+ *
756
+ * igb_get_hw_control sets CTRL_EXT:DRV_LOAD bit.
757
+ * For ASF and Pass Through versions of f/w this means that
758
+ * the driver is loaded.
759
+ *
760
+ **/
761
+void igbvf_get_hw_control ( struct igbvf_adapter *adapter )
762
+{
763
+	struct e1000_hw *hw = &adapter->hw;
764
+	u32 ctrl_ext;
765
+
766
+	/* Let firmware know the driver has taken over */
767
+	ctrl_ext = er32 ( CTRL_EXT );
768
+	ew32 ( CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD );
769
+}
770
+
771
+/**
772
+ * igbvf_probe - Device Initialization Routine
773
+ * @pdev: PCI device information struct
774
+ * @ent: entry in igbvf_pci_tbl
775
+ *
776
+ * Returns 0 on success, negative on failure
777
+ *
778
+ * igbvf_probe initializes an adapter identified by a pci_dev structure.
779
+ * The OS initialization, configuring of the adapter private structure,
780
+ * and a hardware reset occur.
781
+ **/
782
+int igbvf_probe ( struct pci_device *pdev,
783
+		  const struct pci_device_id *ent __unused )
784
+{
785
+	int err;
786
+	struct net_device *netdev;
787
+	struct igbvf_adapter *adapter;
788
+	unsigned long mmio_start, mmio_len;
789
+	struct e1000_hw *hw;
790
+
791
+        DBG ( "igbvf_probe\n" );
792
+
793
+	err = -ENOMEM;
794
+
795
+	/* Allocate net device ( also allocates memory for netdev->priv
796
+	  and makes netdev-priv point to it ) */
797
+	netdev = alloc_etherdev ( sizeof ( struct igbvf_adapter ) );
798
+	if ( ! netdev )
799
+		goto err_alloc_etherdev;
800
+
801
+	/* Associate igbvf-specific network operations operations with
802
+	 * generic network device layer */
803
+	netdev_init ( netdev, &igbvf_operations );
804
+
805
+	/* Associate this network device with given PCI device */
806
+	pci_set_drvdata ( pdev, netdev );
807
+	netdev->dev = &pdev->dev;
808
+
809
+	/* Initialize driver private storage */
810
+	adapter = netdev_priv ( netdev );
811
+	memset ( adapter, 0, ( sizeof ( *adapter ) ) );
812
+
813
+	adapter->pdev = pdev;
814
+
815
+	adapter->ioaddr = pdev->ioaddr;
816
+	adapter->hw.io_base = pdev->ioaddr;
817
+
818
+	hw = &adapter->hw;
819
+	hw->vendor_id = pdev->vendor;
820
+	hw->device_id = pdev->device;
821
+
822
+	adapter->irqno = pdev->irq;
823
+	adapter->netdev = netdev;
824
+	adapter->hw.back = adapter;
825
+
826
+	adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
827
+	adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
828
+
829
+	adapter->tx_ring_size = sizeof ( *adapter->tx_base ) * NUM_TX_DESC;
830
+	adapter->rx_ring_size = sizeof ( *adapter->rx_base ) * NUM_RX_DESC;
831
+
832
+	/* Fix up PCI device */
833
+	adjust_pci_device ( pdev );
834
+
835
+	err = -EIO;
836
+
837
+	mmio_start = pci_bar_start ( pdev, PCI_BASE_ADDRESS_0 );
838
+	mmio_len   = pci_bar_size  ( pdev, PCI_BASE_ADDRESS_0 );
839
+
840
+	DBG ( "mmio_start: %#08lx\n", mmio_start );
841
+	DBG ( "mmio_len: %#08lx\n", mmio_len );
842
+
843
+	adapter->hw.hw_addr = ioremap ( mmio_start, mmio_len );
844
+	DBG ( "adapter->hw.hw_addr: %p\n", adapter->hw.hw_addr );
845
+
846
+	if ( ! adapter->hw.hw_addr ) {
847
+		DBG ( "err_ioremap\n" );
848
+		goto err_ioremap;
849
+	}
850
+
851
+	/* setup adapter struct */
852
+	err = igbvf_sw_init ( adapter );
853
+	if (err) {
854
+		DBG ( "err_sw_init\n" );
855
+		goto err_sw_init;
856
+	}
857
+
858
+	/* reset the controller to put the device in a known good state */
859
+	err = hw->mac.ops.reset_hw ( hw );
860
+	if ( err ) {
861
+		DBG ("PF still in reset state, assigning new address\n");
862
+		netdev->hw_addr[0] = 0x21;
863
+		netdev->hw_addr[1] = 0x21;
864
+		netdev->hw_addr[2] = 0x21;
865
+		netdev->hw_addr[3] = 0x21;
866
+		netdev->hw_addr[4] = 0x21;
867
+		netdev->hw_addr[5] = 0x21;
868
+		netdev->hw_addr[6] = 0x21;
869
+	} else {
870
+		err = hw->mac.ops.read_mac_addr(hw);
871
+		if (err) {
872
+			DBG ("Error reading MAC address\n");
873
+			goto err_hw_init;
874
+		}
875
+	}
876
+
877
+	memcpy ( netdev->hw_addr, adapter->hw.mac.addr, ETH_ALEN );
878
+
879
+	if ( ! is_valid_ether_addr( netdev->hw_addr ) ) {
880
+		DBG ("Invalid MAC Address: "
881
+		        "%02x:%02x:%02x:%02x:%02x:%02x\n",
882
+		        netdev->hw_addr[0], netdev->hw_addr[1],
883
+		        netdev->hw_addr[2], netdev->hw_addr[3],
884
+		        netdev->hw_addr[4], netdev->hw_addr[5]);
885
+		err = -EIO;
886
+		goto err_hw_init;
887
+	}
888
+
889
+	/* reset the hardware with the new settings */
890
+	igbvf_reset ( adapter );
891
+
892
+	/* let the f/w know that the h/w is now under the control of the
893
+	 * driver. */
894
+	igbvf_get_hw_control ( adapter );
895
+
896
+	/* Mark as link up; we don't yet handle link state */
897
+	netdev_link_up ( netdev );
898
+
899
+	if ( ( err = register_netdev ( netdev ) ) != 0) {
900
+		DBG ( "err_register\n" );
901
+		goto err_register;
902
+	}
903
+
904
+	DBG ("igbvf_probe_succeeded\n");
905
+
906
+	return 0;
907
+
908
+err_register:
909
+err_hw_init:
910
+err_sw_init:
911
+	iounmap ( adapter->hw.hw_addr );
912
+err_ioremap:
913
+	netdev_put ( netdev );
914
+err_alloc_etherdev:
915
+	return err;
916
+}
917
+
918
+/**
919
+ * igbvf_remove - Device Removal Routine
920
+ * @pdev: PCI device information struct
921
+ *
922
+ * igbvf_remove is called by the PCI subsystem to alert the driver
923
+ * that it should release a PCI device.  The could be caused by a
924
+ * Hot-Plug event, or because the driver is going to be removed from
925
+ * memory.
926
+ **/
927
+void igbvf_remove ( struct pci_device *pdev )
928
+{
929
+	struct net_device *netdev = pci_get_drvdata ( pdev );
930
+	struct igbvf_adapter *adapter = netdev_priv ( netdev );
931
+
932
+	DBG ( "igbvf_remove\n" );
933
+
934
+	if ( adapter->hw.flash_address )
935
+		iounmap ( adapter->hw.flash_address );
936
+	if  ( adapter->hw.hw_addr )
937
+		iounmap ( adapter->hw.hw_addr );
938
+
939
+	unregister_netdev ( netdev );
940
+	igbvf_reset  ( adapter );
941
+	netdev_nullify ( netdev );
942
+	netdev_put ( netdev );
943
+}
944
+
945
+static struct pci_device_id igbvf_pci_tbl[] = {
946
+	PCI_ROM(0x8086, 0x10CA, "igbvf", "E1000_DEV_ID_82576_VF", 0)
947
+};
948
+
949
+
950
+struct pci_driver igbvf_driver __pci_driver = {
951
+	.ids = igbvf_pci_tbl,
952
+	.id_count = (sizeof(igbvf_pci_tbl) / sizeof(igbvf_pci_tbl[0])),
953
+	.probe = igbvf_probe,
954
+	.remove = igbvf_remove,
955
+};

+ 404
- 0
src/drivers/net/igbvf/igbvf_mbx.c View File

@@ -0,0 +1,404 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 1999 - 2008 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
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+FILE_LICENCE ( GPL2_ONLY );
30
+
31
+#include "igbvf_mbx.h"
32
+
33
+/**
34
+ *  igbvf_poll_for_msg - Wait for message notification
35
+ *  @hw: pointer to the HW structure
36
+ *  @mbx_id: id of mailbox to write
37
+ *
38
+ *  returns SUCCESS if it successfully received a message notification
39
+ **/
40
+static s32 igbvf_poll_for_msg(struct e1000_hw *hw, u16 mbx_id)
41
+{
42
+	struct e1000_mbx_info *mbx = &hw->mbx;
43
+	int countdown = mbx->timeout;
44
+
45
+	DEBUGFUNC("igbvf_poll_for_msg");
46
+
47
+	if (!countdown || !mbx->ops.check_for_msg)
48
+		goto out;
49
+
50
+	while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) {
51
+		countdown--;
52
+		if (!countdown)
53
+			break;
54
+		usec_delay(mbx->usec_delay);
55
+	}
56
+
57
+	/* if we failed, all future posted messages fail until reset */
58
+	if (!countdown)
59
+		mbx->timeout = 0;
60
+out:
61
+	return countdown ? E1000_SUCCESS : -E1000_ERR_MBX;
62
+}
63
+
64
+/**
65
+ *  igbvf_poll_for_ack - Wait for message acknowledgement
66
+ *  @hw: pointer to the HW structure
67
+ *  @mbx_id: id of mailbox to write
68
+ *
69
+ *  returns SUCCESS if it successfully received a message acknowledgement
70
+ **/
71
+static s32 igbvf_poll_for_ack(struct e1000_hw *hw, u16 mbx_id)
72
+{
73
+	struct e1000_mbx_info *mbx = &hw->mbx;
74
+	int countdown = mbx->timeout;
75
+
76
+	DEBUGFUNC("igbvf_poll_for_ack");
77
+
78
+	if (!countdown || !mbx->ops.check_for_ack)
79
+		goto out;
80
+
81
+	while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) {
82
+		countdown--;
83
+		if (!countdown)
84
+			break;
85
+		usec_delay(mbx->usec_delay);
86
+	}
87
+
88
+	/* if we failed, all future posted messages fail until reset */
89
+	if (!countdown)
90
+		mbx->timeout = 0;
91
+out:
92
+	return countdown ? E1000_SUCCESS : -E1000_ERR_MBX;
93
+}
94
+
95
+/**
96
+ *  igbvf_read_posted_mbx - Wait for message notification and receive message
97
+ *  @hw: pointer to the HW structure
98
+ *  @msg: The message buffer
99
+ *  @size: Length of buffer
100
+ *  @mbx_id: id of mailbox to write
101
+ *
102
+ *  returns SUCCESS if it successfully received a message notification and
103
+ *  copied it into the receive buffer.
104
+ **/
105
+static s32 igbvf_read_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size,
106
+                                 u16 mbx_id)
107
+{
108
+	struct e1000_mbx_info *mbx = &hw->mbx;
109
+	s32 ret_val = -E1000_ERR_MBX;
110
+
111
+	DEBUGFUNC("igbvf_read_posted_mbx");
112
+
113
+	if (!mbx->ops.read)
114
+		goto out;
115
+
116
+	ret_val = igbvf_poll_for_msg(hw, mbx_id);
117
+
118
+	/* if ack received read message, otherwise we timed out */
119
+	if (!ret_val)
120
+		ret_val = mbx->ops.read(hw, msg, size, mbx_id);
121
+out:
122
+	return ret_val;
123
+}
124
+
125
+/**
126
+ *  igbvf_write_posted_mbx - Write a message to the mailbox, wait for ack
127
+ *  @hw: pointer to the HW structure
128
+ *  @msg: The message buffer
129
+ *  @size: Length of buffer
130
+ *  @mbx_id: id of mailbox to write
131
+ *
132
+ *  returns SUCCESS if it successfully copied message into the buffer and
133
+ *  received an ack to that message within delay * timeout period
134
+ **/
135
+static s32 igbvf_write_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size,
136
+                                  u16 mbx_id)
137
+{
138
+	struct e1000_mbx_info *mbx = &hw->mbx;
139
+	s32 ret_val = -E1000_ERR_MBX;
140
+
141
+	DEBUGFUNC("igbvf_write_posted_mbx");
142
+
143
+	/* exit if either we can't write or there isn't a defined timeout */
144
+	if (!mbx->ops.write || !mbx->timeout)
145
+		goto out;
146
+
147
+	/* send msg */
148
+	ret_val = mbx->ops.write(hw, msg, size, mbx_id);
149
+
150
+	/* if msg sent wait until we receive an ack */
151
+	if (!ret_val)
152
+		ret_val = igbvf_poll_for_ack(hw, mbx_id);
153
+out:
154
+	return ret_val;
155
+}
156
+
157
+/**
158
+ *  igbvf_init_mbx_ops_generic - Initialize NVM function pointers
159
+ *  @hw: pointer to the HW structure
160
+ *
161
+ *  Setups up the function pointers to no-op functions
162
+ **/
163
+void igbvf_init_mbx_ops_generic(struct e1000_hw *hw)
164
+{
165
+	struct e1000_mbx_info *mbx = &hw->mbx;
166
+	mbx->ops.read_posted = igbvf_read_posted_mbx;
167
+	mbx->ops.write_posted = igbvf_write_posted_mbx;
168
+}
169
+
170
+/**
171
+ *  igbvf_read_v2p_mailbox - read v2p mailbox
172
+ *  @hw: pointer to the HW structure
173
+ *
174
+ *  This function is used to read the v2p mailbox without losing the read to
175
+ *  clear status bits.
176
+ **/
177
+static u32 igbvf_read_v2p_mailbox(struct e1000_hw *hw)
178
+{
179
+	u32 v2p_mailbox = E1000_READ_REG(hw, E1000_V2PMAILBOX(0));
180
+
181
+	v2p_mailbox |= hw->dev_spec.vf.v2p_mailbox;
182
+	hw->dev_spec.vf.v2p_mailbox |= v2p_mailbox & E1000_V2PMAILBOX_R2C_BITS;
183
+
184
+	return v2p_mailbox;
185
+}
186
+
187
+/**
188
+ *  igbvf_check_for_bit_vf - Determine if a status bit was set
189
+ *  @hw: pointer to the HW structure
190
+ *  @mask: bitmask for bits to be tested and cleared
191
+ *
192
+ *  This function is used to check for the read to clear bits within
193
+ *  the V2P mailbox.
194
+ **/
195
+static s32 igbvf_check_for_bit_vf(struct e1000_hw *hw, u32 mask)
196
+{
197
+	u32 v2p_mailbox = igbvf_read_v2p_mailbox(hw);
198
+	s32 ret_val = -E1000_ERR_MBX;
199
+
200
+	if (v2p_mailbox & mask)
201
+		ret_val = E1000_SUCCESS;
202
+
203
+	hw->dev_spec.vf.v2p_mailbox &= ~mask;
204
+
205
+	return ret_val;
206
+}
207
+
208
+/**
209
+ *  igbvf_check_for_msg_vf - checks to see if the PF has sent mail
210
+ *  @hw: pointer to the HW structure
211
+ *  @mbx_id: id of mailbox to check
212
+ *
213
+ *  returns SUCCESS if the PF has set the Status bit or else ERR_MBX
214
+ **/
215
+static s32 igbvf_check_for_msg_vf(struct e1000_hw *hw, u16 mbx_id __unused)
216
+{
217
+	s32 ret_val = -E1000_ERR_MBX;
218
+
219
+	DEBUGFUNC("igbvf_check_for_msg_vf");
220
+
221
+	if (!igbvf_check_for_bit_vf(hw, E1000_V2PMAILBOX_PFSTS)) {
222
+		ret_val = E1000_SUCCESS;
223
+		hw->mbx.stats.reqs++;
224
+	}
225
+
226
+	return ret_val;
227
+}
228
+
229
+/**
230
+ *  igbvf_check_for_ack_vf - checks to see if the PF has ACK'd
231
+ *  @hw: pointer to the HW structure
232
+ *  @mbx_id: id of mailbox to check
233
+ *
234
+ *  returns SUCCESS if the PF has set the ACK bit or else ERR_MBX
235
+ **/
236
+static s32 igbvf_check_for_ack_vf(struct e1000_hw *hw, u16 mbx_id __unused)
237
+{
238
+	s32 ret_val = -E1000_ERR_MBX;
239
+
240
+	DEBUGFUNC("igbvf_check_for_ack_vf");
241
+
242
+	if (!igbvf_check_for_bit_vf(hw, E1000_V2PMAILBOX_PFACK)) {
243
+		ret_val = E1000_SUCCESS;
244
+		hw->mbx.stats.acks++;
245
+	}
246
+
247
+	return ret_val;
248
+}
249
+
250
+/**
251
+ *  igbvf_check_for_rst_vf - checks to see if the PF has reset
252
+ *  @hw: pointer to the HW structure
253
+ *  @mbx_id: id of mailbox to check
254
+ *
255
+ *  returns true if the PF has set the reset done bit or else false
256
+ **/
257
+static s32 igbvf_check_for_rst_vf(struct e1000_hw *hw, u16 mbx_id __unused)
258
+{
259
+	s32 ret_val = -E1000_ERR_MBX;
260
+
261
+	DEBUGFUNC("igbvf_check_for_rst_vf");
262
+
263
+	if (!igbvf_check_for_bit_vf(hw, (E1000_V2PMAILBOX_RSTD |
264
+	                                 E1000_V2PMAILBOX_RSTI))) {
265
+		ret_val = E1000_SUCCESS;
266
+		hw->mbx.stats.rsts++;
267
+	}
268
+
269
+	return ret_val;
270
+}
271
+
272
+/**
273
+ *  igbvf_obtain_mbx_lock_vf - obtain mailbox lock
274
+ *  @hw: pointer to the HW structure
275
+ *
276
+ *  return SUCCESS if we obtained the mailbox lock
277
+ **/
278
+static s32 igbvf_obtain_mbx_lock_vf(struct e1000_hw *hw)
279
+{
280
+	s32 ret_val = -E1000_ERR_MBX;
281
+
282
+	DEBUGFUNC("igbvf_obtain_mbx_lock_vf");
283
+
284
+	/* Take ownership of the buffer */
285
+	E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_VFU);
286
+
287
+	/* reserve mailbox for vf use */
288
+	if (igbvf_read_v2p_mailbox(hw) & E1000_V2PMAILBOX_VFU)
289
+		ret_val = E1000_SUCCESS;
290
+
291
+	return ret_val;
292
+}
293
+
294
+/**
295
+ *  igbvf_write_mbx_vf - Write a message to the mailbox
296
+ *  @hw: pointer to the HW structure
297
+ *  @msg: The message buffer
298
+ *  @size: Length of buffer
299
+ *  @mbx_id: id of mailbox to write
300
+ *
301
+ *  returns SUCCESS if it successfully copied message into the buffer
302
+ **/
303
+static s32 igbvf_write_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size,
304
+                              u16 mbx_id __unused)
305
+{
306
+	s32 ret_val;
307
+	u16 i;
308
+
309
+
310
+	DEBUGFUNC("igbvf_write_mbx_vf");
311
+
312
+	/* lock the mailbox to prevent pf/vf race condition */
313
+	ret_val = igbvf_obtain_mbx_lock_vf(hw);
314
+	if (ret_val)
315
+		goto out_no_write;
316
+
317
+	/* flush msg and acks as we are overwriting the message buffer */
318
+	igbvf_check_for_msg_vf(hw, 0);
319
+	igbvf_check_for_ack_vf(hw, 0);
320
+
321
+	/* copy the caller specified message to the mailbox memory buffer */
322
+	for (i = 0; i < size; i++)
323
+		E1000_WRITE_REG_ARRAY(hw, E1000_VMBMEM(0), i, msg[i]);
324
+
325
+	/* update stats */
326
+	hw->mbx.stats.msgs_tx++;
327
+
328
+	/* Drop VFU and interrupt the PF to tell it a message has been sent */
329
+	E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_REQ);
330
+
331
+out_no_write:
332
+	return ret_val;
333
+}
334
+
335
+/**
336
+ *  igbvf_read_mbx_vf - Reads a message from the inbox intended for vf
337
+ *  @hw: pointer to the HW structure
338
+ *  @msg: The message buffer
339
+ *  @size: Length of buffer
340
+ *  @mbx_id: id of mailbox to read
341
+ *
342
+ *  returns SUCCESS if it successfuly read message from buffer
343
+ **/
344
+static s32 igbvf_read_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size,
345
+                             u16 mbx_id __unused)
346
+{
347
+	s32 ret_val = E1000_SUCCESS;
348
+	u16 i;
349
+
350
+	DEBUGFUNC("igbvf_read_mbx_vf");
351
+
352
+	/* lock the mailbox to prevent pf/vf race condition */
353
+	ret_val = igbvf_obtain_mbx_lock_vf(hw);
354
+	if (ret_val)
355
+		goto out_no_read;
356
+
357
+	/* copy the message from the mailbox memory buffer */
358
+	for (i = 0; i < size; i++)
359
+		msg[i] = E1000_READ_REG_ARRAY(hw, E1000_VMBMEM(0), i);
360
+
361
+	/* Acknowledge receipt and release mailbox, then we're done */
362
+	E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_ACK);
363
+
364
+	/* update stats */
365
+	hw->mbx.stats.msgs_rx++;
366
+
367
+out_no_read:
368
+	return ret_val;
369
+}
370
+
371
+/**
372
+ *  igbvf_init_mbx_params_vf - set initial values for vf mailbox
373
+ *  @hw: pointer to the HW structure
374
+ *
375
+ *  Initializes the hw->mbx struct to correct values for vf mailbox
376
+ */
377
+s32 igbvf_init_mbx_params_vf(struct e1000_hw *hw)
378
+{
379
+	struct e1000_mbx_info *mbx = &hw->mbx;
380
+
381
+	/* start mailbox as timed out and let the reset_hw call set the timeout
382
+	 * value to begin communications */
383
+	mbx->timeout = 0;
384
+	mbx->usec_delay = E1000_VF_MBX_INIT_DELAY;
385
+
386
+	mbx->size = E1000_VFMAILBOX_SIZE;
387
+
388
+	mbx->ops.read = igbvf_read_mbx_vf;
389
+	mbx->ops.write = igbvf_write_mbx_vf;
390
+	mbx->ops.read_posted = igbvf_read_posted_mbx;
391
+	mbx->ops.write_posted = igbvf_write_posted_mbx;
392
+	mbx->ops.check_for_msg = igbvf_check_for_msg_vf;
393
+	mbx->ops.check_for_ack = igbvf_check_for_ack_vf;
394
+	mbx->ops.check_for_rst = igbvf_check_for_rst_vf;
395
+
396
+	mbx->stats.msgs_tx = 0;
397
+	mbx->stats.msgs_rx = 0;
398
+	mbx->stats.reqs = 0;
399
+	mbx->stats.acks = 0;
400
+	mbx->stats.rsts = 0;
401
+
402
+	return E1000_SUCCESS;
403
+}
404
+

+ 87
- 0
src/drivers/net/igbvf/igbvf_mbx.h View File

@@ -0,0 +1,87 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 1999 - 2008 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
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+FILE_LICENCE ( GPL2_ONLY );
30
+
31
+#ifndef _IGBVF_MBX_H_
32
+#define _IGBVF_MBX_H_
33
+
34
+#include "igbvf_vf.h"
35
+
36
+/* Define mailbox specific registers */
37
+#define E1000_V2PMAILBOX(_n)   (0x00C40 + (4 * (_n)))
38
+#define E1000_VMBMEM(_n)       (0x00800 + (64 * (_n)))
39
+
40
+/* Define mailbox register bits */
41
+#define E1000_V2PMAILBOX_REQ   0x00000001 /* Request for PF Ready bit */
42
+#define E1000_V2PMAILBOX_ACK   0x00000002 /* Ack PF message received */
43
+#define E1000_V2PMAILBOX_VFU   0x00000004 /* VF owns the mailbox buffer */
44
+#define E1000_V2PMAILBOX_PFU   0x00000008 /* PF owns the mailbox buffer */
45
+#define E1000_V2PMAILBOX_PFSTS 0x00000010 /* PF wrote a message in the MB */
46
+#define E1000_V2PMAILBOX_PFACK 0x00000020 /* PF ack the previous VF msg */
47
+#define E1000_V2PMAILBOX_RSTI  0x00000040 /* PF has reset indication */
48
+#define E1000_V2PMAILBOX_RSTD  0x00000080 /* PF has indicated reset done */
49
+#define E1000_V2PMAILBOX_R2C_BITS 0x000000B0 /* All read to clear bits */
50
+
51
+#define E1000_VFMAILBOX_SIZE   16 /* 16 32 bit words - 64 bytes */
52
+
53
+/* If it's a E1000_VF_* msg then it originates in the VF and is sent to the
54
+ * PF.  The reverse is true if it is E1000_PF_*.
55
+ * Message ACK's are the value or'd with 0xF0000000
56
+ */
57
+#define E1000_VT_MSGTYPE_ACK      0x80000000  /* Messages below or'd with
58
+                                               * this are the ACK */
59
+#define E1000_VT_MSGTYPE_NACK     0x40000000  /* Messages below or'd with
60
+                                               * this are the NACK */
61
+#define E1000_VT_MSGTYPE_CTS      0x20000000  /* Indicates that VF is still
62
+                                                 clear to send requests */
63
+#define E1000_VT_MSGINFO_SHIFT    16
64
+/* bits 23:16 are used for exra info for certain messages */
65
+#define E1000_VT_MSGINFO_MASK     (0xFF << E1000_VT_MSGINFO_SHIFT)
66
+
67
+#define E1000_VF_RESET            0x01 /* VF requests reset */
68
+#define E1000_VF_SET_MAC_ADDR     0x02 /* VF requests to set MAC addr */
69
+#define E1000_VF_SET_MULTICAST    0x03 /* VF requests to set MC addr */
70
+#define E1000_VF_SET_MULTICAST_COUNT_MASK (0x1F << E1000_VT_MSGINFO_SHIFT)
71
+#define E1000_VF_SET_MULTICAST_OVERFLOW   (0x80 << E1000_VT_MSGINFO_SHIFT)
72
+#define E1000_VF_SET_VLAN         0x04 /* VF requests to set VLAN */
73
+#define E1000_VF_SET_VLAN_ADD             (0x01 << E1000_VT_MSGINFO_SHIFT)
74
+#define E1000_VF_SET_LPE          0x05 /* VF requests to set VMOLR.LPE */
75
+#define E1000_VF_SET_PROMISC      0x06 /*VF requests to clear VMOLR.ROPE/MPME*/
76
+#define E1000_VF_SET_PROMISC_UNICAST      (0x01 << E1000_VT_MSGINFO_SHIFT)
77
+#define E1000_VF_SET_PROMISC_MULTICAST    (0x02 << E1000_VT_MSGINFO_SHIFT)
78
+
79
+#define E1000_PF_CONTROL_MSG      0x0100 /* PF control message */
80
+
81
+#define E1000_VF_MBX_INIT_TIMEOUT 2000 /* number of retries on mailbox */
82
+#define E1000_VF_MBX_INIT_DELAY   500  /* microseconds between retries */
83
+
84
+void igbvf_init_mbx_ops_generic(struct e1000_hw *hw);
85
+s32 igbvf_init_mbx_params_vf(struct e1000_hw *);
86
+
87
+#endif /* _IGBVF_MBX_H_ */

+ 121
- 0
src/drivers/net/igbvf/igbvf_osdep.h View File

@@ -0,0 +1,121 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 1999 - 2008 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
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+FILE_LICENCE ( GPL2_ONLY );
30
+
31
+/* glue for the OS-dependent part of igbvf
32
+ * includes register access macros
33
+ */
34
+
35
+#ifndef _IGBVF_OSDEP_H_
36
+#define _IGBVF_OSDEP_H_
37
+
38
+#define u8         unsigned char
39
+#define bool       boolean_t
40
+#define dma_addr_t unsigned long
41
+#define __le16     uint16_t
42
+#define __le32     uint32_t
43
+#define __le64     uint64_t
44
+
45
+#define __iomem
46
+#define __devinit
47
+#define ____cacheline_aligned_in_smp
48
+
49
+#define msleep(x) mdelay(x)
50
+
51
+#define ETH_FCS_LEN 4
52
+
53
+typedef int spinlock_t;
54
+typedef enum {
55
+    false = 0,
56
+    true = 1
57
+} boolean_t;
58
+
59
+#define TRUE  1
60
+#define FALSE 0
61
+
62
+#define usec_delay(x) udelay(x)
63
+#define msec_delay(x) mdelay(x)
64
+#define msec_delay_irq(x) mdelay(x)
65
+
66
+#define PCI_COMMAND_REGISTER   PCI_COMMAND
67
+#define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
68
+#define ETH_ADDR_LEN           ETH_ALEN
69
+
70
+
71
+#define DEBUGOUT(S) if (0) { printf(S); }
72
+#define DEBUGOUT1(S, A...) if (0) { printf(S, A); }
73
+
74
+#define DEBUGFUNC(F) DEBUGOUT(F "\n")
75
+#define DEBUGOUT2 DEBUGOUT1
76
+#define DEBUGOUT3 DEBUGOUT2
77
+#define DEBUGOUT7 DEBUGOUT3
78
+
79
+#define E1000_WRITE_REG(a, reg, value) do { \
80
+    writel((value), ((a)->hw_addr + reg)); } while (0)
81
+
82
+#define E1000_READ_REG(a, reg) (readl((a)->hw_addr + reg))
83
+
84
+#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) do { \
85
+    writel((value), ((a)->hw_addr + reg + ((offset) << 2))); } while (0)
86
+
87
+#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
88
+    readl((a)->hw_addr + reg + ((offset) << 2)))
89
+
90
+#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
91
+#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
92
+
93
+#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
94
+    writew((value), ((a)->hw_addr + reg + ((offset) << 1))))
95
+
96
+#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
97
+    readw((a)->hw_addr + reg + ((offset) << 1)))
98
+
99
+#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
100
+    writeb((value), ((a)->hw_addr + reg + (offset))))
101
+
102
+#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
103
+    readb((a)->hw_addr + reg + (offset)))
104
+
105
+#define E1000_WRITE_REG_IO(a, reg, offset) do { \
106
+    outl(reg, ((a)->io_base));                  \
107
+    outl(offset, ((a)->io_base + 4));      } while(0)
108
+
109
+#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, E1000_STATUS)
110
+
111
+#define E1000_WRITE_FLASH_REG(a, reg, value) ( \
112
+    writel((value), ((a)->flash_address + reg)))
113
+
114
+#define E1000_WRITE_FLASH_REG16(a, reg, value) ( \
115
+    writew((value), ((a)->flash_address + reg)))
116
+
117
+#define E1000_READ_FLASH_REG(a, reg) (readl((a)->flash_address + reg))
118
+
119
+#define E1000_READ_FLASH_REG16(a, reg) (readw((a)->flash_address + reg))
120
+
121
+#endif /* _IGBVF_OSDEP_H_ */

+ 338
- 0
src/drivers/net/igbvf/igbvf_regs.h View File

@@ -0,0 +1,338 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 1999 - 2008 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
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+FILE_LICENCE ( GPL2_ONLY );
30
+
31
+#ifndef _IGBVF_REGS_H_
32
+#define _IGBVF_REGS_H_
33
+
34
+#define E1000_CTRL     0x00000  /* Device Control - RW */
35
+#define E1000_CTRL_DUP 0x00004  /* Device Control Duplicate (Shadow) - RW */
36
+#define E1000_STATUS   0x00008  /* Device Status - RO */
37
+#define E1000_EECD     0x00010  /* EEPROM/Flash Control - RW */
38
+#define E1000_EERD     0x00014  /* EEPROM Read - RW */
39
+#define E1000_CTRL_EXT 0x00018  /* Extended Device Control - RW */
40
+#define E1000_FLA      0x0001C  /* Flash Access - RW */
41
+#define E1000_MDIC     0x00020  /* MDI Control - RW */
42
+#define E1000_SCTL     0x00024  /* SerDes Control - RW */
43
+#define E1000_FCAL     0x00028  /* Flow Control Address Low - RW */
44
+#define E1000_FCAH     0x0002C  /* Flow Control Address High -RW */
45
+#define E1000_FEXT     0x0002C  /* Future Extended - RW */
46
+#define E1000_FEXTNVM  0x00028  /* Future Extended NVM - RW */
47
+#define E1000_FCT      0x00030  /* Flow Control Type - RW */
48
+#define E1000_CONNSW   0x00034  /* Copper/Fiber switch control - RW */
49
+#define E1000_VET      0x00038  /* VLAN Ether Type - RW */
50
+#define E1000_ICR      0x000C0  /* Interrupt Cause Read - R/clr */
51
+#define E1000_ITR      0x000C4  /* Interrupt Throttling Rate - RW */
52
+#define E1000_ICS      0x000C8  /* Interrupt Cause Set - WO */
53
+#define E1000_IMS      0x000D0  /* Interrupt Mask Set - RW */
54
+#define E1000_IMC      0x000D8  /* Interrupt Mask Clear - WO */
55
+#define E1000_IAM      0x000E0  /* Interrupt Acknowledge Auto Mask */
56
+#define E1000_RCTL     0x00100  /* Rx Control - RW */
57
+#define E1000_FCTTV    0x00170  /* Flow Control Transmit Timer Value - RW */
58
+#define E1000_TXCW     0x00178  /* Tx Configuration Word - RW */
59
+#define E1000_RXCW     0x00180  /* Rx Configuration Word - RO */
60
+#define E1000_TCTL     0x00400  /* Tx Control - RW */
61
+#define E1000_TCTL_EXT 0x00404  /* Extended Tx Control - RW */
62
+#define E1000_TIPG     0x00410  /* Tx Inter-packet gap -RW */
63
+#define E1000_TBT      0x00448  /* Tx Burst Timer - RW */
64
+#define E1000_AIT      0x00458  /* Adaptive Interframe Spacing Throttle - RW */
65
+#define E1000_LEDCTL   0x00E00  /* LED Control - RW */
66
+#define E1000_EXTCNF_CTRL  0x00F00  /* Extended Configuration Control */
67
+#define E1000_EXTCNF_SIZE  0x00F08  /* Extended Configuration Size */
68
+#define E1000_PHY_CTRL     0x00F10  /* PHY Control Register in CSR */
69
+#define E1000_PBA      0x01000  /* Packet Buffer Allocation - RW */
70
+#define E1000_PBS      0x01008  /* Packet Buffer Size */
71
+#define E1000_EEMNGCTL 0x01010  /* MNG EEprom Control */
72
+#define E1000_EEARBC   0x01024  /* EEPROM Auto Read Bus Control */
73
+#define E1000_FLASHT   0x01028  /* FLASH Timer Register */
74
+#define E1000_EEWR     0x0102C  /* EEPROM Write Register - RW */
75
+#define E1000_FLSWCTL  0x01030  /* FLASH control register */
76
+#define E1000_FLSWDATA 0x01034  /* FLASH data register */
77
+#define E1000_FLSWCNT  0x01038  /* FLASH Access Counter */
78
+#define E1000_FLOP     0x0103C  /* FLASH Opcode Register */
79
+#define E1000_I2CCMD   0x01028  /* SFPI2C Command Register - RW */
80
+#define E1000_I2CPARAMS 0x0102C /* SFPI2C Parameters Register - RW */
81
+#define E1000_WDSTP    0x01040  /* Watchdog Setup - RW */
82
+#define E1000_SWDSTS   0x01044  /* SW Device Status - RW */
83
+#define E1000_FRTIMER  0x01048  /* Free Running Timer - RW */
84
+#define E1000_ERT      0x02008  /* Early Rx Threshold - RW */
85
+#define E1000_FCRTL    0x02160  /* Flow Control Receive Threshold Low - RW */
86
+#define E1000_FCRTH    0x02168  /* Flow Control Receive Threshold High - RW */
87
+#define E1000_PSRCTL   0x02170  /* Packet Split Receive Control - RW */
88
+#define E1000_RDFPCQ(_n)  (0x02430 + (0x4 * (_n)))
89
+#define E1000_PBRTH    0x02458  /* PB Rx Arbitration Threshold - RW */
90
+#define E1000_FCRTV    0x02460  /* Flow Control Refresh Timer Value - RW */
91
+/* Split and Replication Rx Control - RW */
92
+#define E1000_RDPUMB   0x025CC  /* DMA Rx Descriptor uC Mailbox - RW */
93
+#define E1000_RDPUAD   0x025D0  /* DMA Rx Descriptor uC Addr Command - RW */
94
+#define E1000_RDPUWD   0x025D4  /* DMA Rx Descriptor uC Data Write - RW */
95
+#define E1000_RDPURD   0x025D8  /* DMA Rx Descriptor uC Data Read - RW */
96
+#define E1000_RDPUCTL  0x025DC  /* DMA Rx Descriptor uC Control - RW */
97
+#define E1000_RXCTL(_n)   (0x0C014 + (0x40 * (_n)))
98
+#define E1000_RQDPC(_n)   (0x0C030 + (0x40 * (_n)))
99
+#define E1000_RDTR     0x02820  /* Rx Delay Timer - RW */
100
+#define E1000_RADV     0x0282C  /* Rx Interrupt Absolute Delay Timer - RW */
101
+/*
102
+ * Convenience macros
103
+ *
104
+ * Note: "_n" is the queue number of the register to be written to.
105
+ *
106
+ * Example usage:
107
+ * E1000_RDBAL_REG(current_rx_queue)
108
+ */
109
+#define E1000_RDBAL(_n)      ((_n) < 4 ? (0x02800 + ((_n) * 0x100)) : \
110
+                                         (0x0C000 + ((_n) * 0x40)))
111
+#define E1000_RDBAH(_n)      ((_n) < 4 ? (0x02804 + ((_n) * 0x100)) : \
112
+                                         (0x0C004 + ((_n) * 0x40)))
113
+#define E1000_RDLEN(_n)      ((_n) < 4 ? (0x02808 + ((_n) * 0x100)) : \
114
+                                         (0x0C008 + ((_n) * 0x40)))
115
+#define E1000_SRRCTL(_n)     ((_n) < 4 ? (0x0280C + ((_n) * 0x100)) : \
116
+                                         (0x0C00C + ((_n) * 0x40)))
117
+#define E1000_RDH(_n)        ((_n) < 4 ? (0x02810 + ((_n) * 0x100)) : \
118
+                                         (0x0C010 + ((_n) * 0x40)))
119
+#define E1000_RDT(_n)        ((_n) < 4 ? (0x02818 + ((_n) * 0x100)) : \
120
+                                         (0x0C018 + ((_n) * 0x40)))
121
+#define E1000_RXDCTL(_n)     ((_n) < 4 ? (0x02828 + ((_n) * 0x100)) : \
122
+                                         (0x0C028 + ((_n) * 0x40)))
123
+#define E1000_TDBAL(_n)      ((_n) < 4 ? (0x03800 + ((_n) * 0x100)) : \
124
+                                         (0x0E000 + ((_n) * 0x40)))
125
+#define E1000_TDBAH(_n)      ((_n) < 4 ? (0x03804 + ((_n) * 0x100)) : \
126
+                                         (0x0E004 + ((_n) * 0x40)))
127
+#define E1000_TDLEN(_n)      ((_n) < 4 ? (0x03808 + ((_n) * 0x100)) : \
128
+                                         (0x0E008 + ((_n) * 0x40)))
129
+#define E1000_TDH(_n)        ((_n) < 4 ? (0x03810 + ((_n) * 0x100)) : \
130
+                                         (0x0E010 + ((_n) * 0x40)))
131
+#define E1000_TDT(_n)        ((_n) < 4 ? (0x03818 + ((_n) * 0x100)) : \
132
+                                         (0x0E018 + ((_n) * 0x40)))
133
+#define E1000_TXDCTL(_n)     ((_n) < 4 ? (0x03828 + ((_n) * 0x100)) : \
134
+                                         (0x0E028 + ((_n) * 0x40)))
135
+#define E1000_TARC(_n)       (0x03840 + (_n << 8))
136
+#define E1000_DCA_TXCTRL(_n) (0x03814 + (_n << 8))
137
+#define E1000_DCA_RXCTRL(_n) (0x02814 + (_n << 8))
138
+#define E1000_TDWBAL(_n)     ((_n) < 4 ? (0x03838 + ((_n) * 0x100)) : \
139
+                                         (0x0E038 + ((_n) * 0x40)))
140
+#define E1000_TDWBAH(_n)     ((_n) < 4 ? (0x0383C + ((_n) * 0x100)) : \
141
+                                         (0x0E03C + ((_n) * 0x40)))
142
+#define E1000_RSRPD    0x02C00  /* Rx Small Packet Detect - RW */
143
+#define E1000_RAID     0x02C08  /* Receive Ack Interrupt Delay - RW */
144
+#define E1000_TXDMAC   0x03000  /* Tx DMA Control - RW */
145
+#define E1000_KABGTXD  0x03004  /* AFE Band Gap Transmit Ref Data */
146
+#define E1000_PSRTYPE(_i)       (0x05480 + ((_i) * 4))
147
+#define E1000_RAL(_i)  (((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \
148
+                                       (0x054E0 + ((_i - 16) * 8)))
149
+#define E1000_RAH(_i)  (((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \
150
+                                       (0x054E4 + ((_i - 16) * 8)))
151
+#define E1000_IP4AT_REG(_i)     (0x05840 + ((_i) * 8))
152
+#define E1000_IP6AT_REG(_i)     (0x05880 + ((_i) * 4))
153
+#define E1000_WUPM_REG(_i)      (0x05A00 + ((_i) * 4))
154
+#define E1000_FFMT_REG(_i)      (0x09000 + ((_i) * 8))
155
+#define E1000_FFVT_REG(_i)      (0x09800 + ((_i) * 8))
156
+#define E1000_FFLT_REG(_i)      (0x05F00 + ((_i) * 8))
157
+#define E1000_TDFH     0x03410  /* Tx Data FIFO Head - RW */
158
+#define E1000_TDFT     0x03418  /* Tx Data FIFO Tail - RW */
159
+#define E1000_TDFHS    0x03420  /* Tx Data FIFO Head Saved - RW */
160
+#define E1000_TDFTS    0x03428  /* Tx Data FIFO Tail Saved - RW */
161
+#define E1000_TDFPC    0x03430  /* Tx Data FIFO Packet Count - RW */
162
+#define E1000_TDPUMB   0x0357C  /* DMA Tx Descriptor uC Mail Box - RW */
163
+#define E1000_TDPUAD   0x03580  /* DMA Tx Descriptor uC Addr Command - RW */
164
+#define E1000_TDPUWD   0x03584  /* DMA Tx Descriptor uC Data Write - RW */
165
+#define E1000_TDPURD   0x03588  /* DMA Tx Descriptor uC Data  Read  - RW */
166
+#define E1000_TDPUCTL  0x0358C  /* DMA Tx Descriptor uC Control - RW */
167
+#define E1000_DTXCTL   0x03590  /* DMA Tx Control - RW */
168
+#define E1000_TIDV     0x03820  /* Tx Interrupt Delay Value - RW */
169
+#define E1000_TADV     0x0382C  /* Tx Interrupt Absolute Delay Val - RW */
170
+#define E1000_TSPMT    0x03830  /* TCP Segmentation PAD & Min Threshold - RW */
171
+#define E1000_CRCERRS  0x04000  /* CRC Error Count - R/clr */
172
+#define E1000_ALGNERRC 0x04004  /* Alignment Error Count - R/clr */
173
+#define E1000_SYMERRS  0x04008  /* Symbol Error Count - R/clr */
174
+#define E1000_RXERRC   0x0400C  /* Receive Error Count - R/clr */
175
+#define E1000_MPC      0x04010  /* Missed Packet Count - R/clr */
176
+#define E1000_SCC      0x04014  /* Single Collision Count - R/clr */
177
+#define E1000_ECOL     0x04018  /* Excessive Collision Count - R/clr */
178
+#define E1000_MCC      0x0401C  /* Multiple Collision Count - R/clr */
179
+#define E1000_LATECOL  0x04020  /* Late Collision Count - R/clr */
180
+#define E1000_COLC     0x04028  /* Collision Count - R/clr */
181
+#define E1000_DC       0x04030  /* Defer Count - R/clr */
182
+#define E1000_TNCRS    0x04034  /* Tx-No CRS - R/clr */
183
+#define E1000_SEC      0x04038  /* Sequence Error Count - R/clr */
184
+#define E1000_CEXTERR  0x0403C  /* Carrier Extension Error Count - R/clr */
185
+#define E1000_RLEC     0x04040  /* Receive Length Error Count - R/clr */
186
+#define E1000_XONRXC   0x04048  /* XON Rx Count - R/clr */
187
+#define E1000_XONTXC   0x0404C  /* XON Tx Count - R/clr */
188
+#define E1000_XOFFRXC  0x04050  /* XOFF Rx Count - R/clr */
189
+#define E1000_XOFFTXC  0x04054  /* XOFF Tx Count - R/clr */
190
+#define E1000_FCRUC    0x04058  /* Flow Control Rx Unsupported Count- R/clr */
191
+#define E1000_PRC64    0x0405C  /* Packets Rx (64 bytes) - R/clr */
192
+#define E1000_PRC127   0x04060  /* Packets Rx (65-127 bytes) - R/clr */
193
+#define E1000_PRC255   0x04064  /* Packets Rx (128-255 bytes) - R/clr */
194
+#define E1000_PRC511   0x04068  /* Packets Rx (255-511 bytes) - R/clr */
195
+#define E1000_PRC1023  0x0406C  /* Packets Rx (512-1023 bytes) - R/clr */
196
+#define E1000_PRC1522  0x04070  /* Packets Rx (1024-1522 bytes) - R/clr */
197
+#define E1000_GPRC     0x04074  /* Good Packets Rx Count - R/clr */
198
+#define E1000_BPRC     0x04078  /* Broadcast Packets Rx Count - R/clr */
199
+#define E1000_MPRC     0x0407C  /* Multicast Packets Rx Count - R/clr */
200
+#define E1000_GPTC     0x04080  /* Good Packets Tx Count - R/clr */
201
+#define E1000_GORCL    0x04088  /* Good Octets Rx Count Low - R/clr */
202
+#define E1000_GORCH    0x0408C  /* Good Octets Rx Count High - R/clr */
203
+#define E1000_GOTCL    0x04090  /* Good Octets Tx Count Low - R/clr */
204
+#define E1000_GOTCH    0x04094  /* Good Octets Tx Count High - R/clr */
205
+#define E1000_RNBC     0x040A0  /* Rx No Buffers Count - R/clr */
206
+#define E1000_RUC      0x040A4  /* Rx Undersize Count - R/clr */
207
+#define E1000_RFC      0x040A8  /* Rx Fragment Count - R/clr */
208
+#define E1000_ROC      0x040AC  /* Rx Oversize Count - R/clr */
209
+#define E1000_RJC      0x040B0  /* Rx Jabber Count - R/clr */
210
+#define E1000_MGTPRC   0x040B4  /* Management Packets Rx Count - R/clr */
211
+#define E1000_MGTPDC   0x040B8  /* Management Packets Dropped Count - R/clr */
212
+#define E1000_MGTPTC   0x040BC  /* Management Packets Tx Count - R/clr */
213
+#define E1000_TORL     0x040C0  /* Total Octets Rx Low - R/clr */
214
+#define E1000_TORH     0x040C4  /* Total Octets Rx High - R/clr */
215
+#define E1000_TOTL     0x040C8  /* Total Octets Tx Low - R/clr */
216
+#define E1000_TOTH     0x040CC  /* Total Octets Tx High - R/clr */
217
+#define E1000_TPR      0x040D0  /* Total Packets Rx - R/clr */
218
+#define E1000_TPT      0x040D4  /* Total Packets Tx - R/clr */
219
+#define E1000_PTC64    0x040D8  /* Packets Tx (64 bytes) - R/clr */
220
+#define E1000_PTC127   0x040DC  /* Packets Tx (65-127 bytes) - R/clr */
221
+#define E1000_PTC255   0x040E0  /* Packets Tx (128-255 bytes) - R/clr */
222
+#define E1000_PTC511   0x040E4  /* Packets Tx (256-511 bytes) - R/clr */
223
+#define E1000_PTC1023  0x040E8  /* Packets Tx (512-1023 bytes) - R/clr */
224
+#define E1000_PTC1522  0x040EC  /* Packets Tx (1024-1522 Bytes) - R/clr */
225
+#define E1000_MPTC     0x040F0  /* Multicast Packets Tx Count - R/clr */
226
+#define E1000_BPTC     0x040F4  /* Broadcast Packets Tx Count - R/clr */
227
+#define E1000_TSCTC    0x040F8  /* TCP Segmentation Context Tx - R/clr */
228
+#define E1000_TSCTFC   0x040FC  /* TCP Segmentation Context Tx Fail - R/clr */
229
+#define E1000_IAC      0x04100  /* Interrupt Assertion Count */
230
+#define E1000_ICRXPTC  0x04104  /* Interrupt Cause Rx Pkt Timer Expire Count */
231
+#define E1000_ICRXATC  0x04108  /* Interrupt Cause Rx Abs Timer Expire Count */
232
+#define E1000_ICTXPTC  0x0410C  /* Interrupt Cause Tx Pkt Timer Expire Count */
233
+#define E1000_ICTXATC  0x04110  /* Interrupt Cause Tx Abs Timer Expire Count */
234
+#define E1000_ICTXQEC  0x04118  /* Interrupt Cause Tx Queue Empty Count */
235
+#define E1000_ICTXQMTC 0x0411C  /* Interrupt Cause Tx Queue Min Thresh Count */
236
+#define E1000_ICRXDMTC 0x04120  /* Interrupt Cause Rx Desc Min Thresh Count */
237
+#define E1000_ICRXOC   0x04124  /* Interrupt Cause Receiver Overrun Count */
238
+
239
+#define E1000_VFGPRC   0x00F10
240
+#define E1000_VFGORC   0x00F18
241
+#define E1000_VFMPRC   0x00F3C
242
+#define E1000_VFGPTC   0x00F14
243
+#define E1000_VFGOTC   0x00F34
244
+#define E1000_VFGOTLBC 0x00F50
245
+#define E1000_VFGPTLBC 0x00F44
246
+#define E1000_VFGORLBC 0x00F48
247
+#define E1000_VFGPRLBC 0x00F40
248
+#define E1000_PCS_CFG0    0x04200  /* PCS Configuration 0 - RW */
249
+#define E1000_PCS_LCTL    0x04208  /* PCS Link Control - RW */
250
+#define E1000_PCS_LSTAT   0x0420C  /* PCS Link Status - RO */
251
+#define E1000_CBTMPC      0x0402C  /* Circuit Breaker Tx Packet Count */
252
+#define E1000_HTDPMC      0x0403C  /* Host Transmit Discarded Packets */
253
+#define E1000_CBRDPC      0x04044  /* Circuit Breaker Rx Dropped Count */
254
+#define E1000_CBRMPC      0x040FC  /* Circuit Breaker Rx Packet Count */
255
+#define E1000_RPTHC       0x04104  /* Rx Packets To Host */
256
+#define E1000_HGPTC       0x04118  /* Host Good Packets Tx Count */
257
+#define E1000_HTCBDPC     0x04124  /* Host Tx Circuit Breaker Dropped Count */
258
+#define E1000_HGORCL      0x04128  /* Host Good Octets Received Count Low */
259
+#define E1000_HGORCH      0x0412C  /* Host Good Octets Received Count High */
260
+#define E1000_HGOTCL      0x04130  /* Host Good Octets Transmit Count Low */
261
+#define E1000_HGOTCH      0x04134  /* Host Good Octets Transmit Count High */
262
+#define E1000_LENERRS     0x04138  /* Length Errors Count */
263
+#define E1000_SCVPC       0x04228  /* SerDes/SGMII Code Violation Pkt Count */
264
+#define E1000_HRMPC       0x0A018  /* Header Redirection Missed Packet Count */
265
+#define E1000_PCS_ANADV   0x04218  /* AN advertisement - RW */
266
+#define E1000_PCS_LPAB    0x0421C  /* Link Partner Ability - RW */
267
+#define E1000_PCS_NPTX    0x04220  /* AN Next Page Transmit - RW */
268
+#define E1000_PCS_LPABNP  0x04224  /* Link Partner Ability Next Page - RW */
269
+#define E1000_1GSTAT_RCV  0x04228  /* 1GSTAT Code Violation Packet Count - RW */
270
+#define E1000_RXCSUM   0x05000  /* Rx Checksum Control - RW */
271
+#define E1000_RLPML    0x05004  /* Rx Long Packet Max Length */
272
+#define E1000_RFCTL    0x05008  /* Receive Filter Control*/
273
+#define E1000_MTA      0x05200  /* Multicast Table Array - RW Array */
274
+#define E1000_RA       0x05400  /* Receive Address - RW Array */
275
+#define E1000_VFTA     0x05600  /* VLAN Filter Table Array - RW Array */
276
+#define E1000_VT_CTL   0x0581C  /* VMDq Control - RW */
277
+#define E1000_VFQA0    0x0B000  /* VLAN Filter Queue Array 0 - RW Array */
278
+#define E1000_VFQA1    0x0B200  /* VLAN Filter Queue Array 1 - RW Array */
279
+#define E1000_WUC      0x05800  /* Wakeup Control - RW */
280
+#define E1000_WUFC     0x05808  /* Wakeup Filter Control - RW */
281
+#define E1000_WUS      0x05810  /* Wakeup Status - RO */
282
+#define E1000_MANC     0x05820  /* Management Control - RW */
283
+#define E1000_IPAV     0x05838  /* IP Address Valid - RW */
284
+#define E1000_IP4AT    0x05840  /* IPv4 Address Table - RW Array */
285
+#define E1000_IP6AT    0x05880  /* IPv6 Address Table - RW Array */
286
+#define E1000_WUPL     0x05900  /* Wakeup Packet Length - RW */
287
+#define E1000_WUPM     0x05A00  /* Wakeup Packet Memory - RO A */
288
+#define E1000_PBACL    0x05B68  /* MSIx PBA Clear - Read/Write 1's to clear */
289
+#define E1000_FFLT     0x05F00  /* Flexible Filter Length Table - RW Array */
290
+#define E1000_HOST_IF  0x08800  /* Host Interface */
291
+#define E1000_FFMT     0x09000  /* Flexible Filter Mask Table - RW Array */
292
+#define E1000_FFVT     0x09800  /* Flexible Filter Value Table - RW Array */
293
+
294
+#define E1000_KMRNCTRLSTA 0x00034 /* MAC-PHY interface - RW */
295
+#define E1000_MDPHYA      0x0003C /* PHY address - RW */
296
+#define E1000_MANC2H      0x05860 /* Management Control To Host - RW */
297
+#define E1000_SW_FW_SYNC  0x05B5C /* Software-Firmware Synchronization - RW */
298
+#define E1000_CCMCTL      0x05B48 /* CCM Control Register */
299
+#define E1000_GIOCTL      0x05B44 /* GIO Analog Control Register */
300
+#define E1000_SCCTL       0x05B4C /* PCIc PLL Configuration Register */
301
+#define E1000_GCR         0x05B00 /* PCI-Ex Control */
302
+#define E1000_GCR2        0x05B64 /* PCI-Ex Control #2 */
303
+#define E1000_GSCL_1    0x05B10 /* PCI-Ex Statistic Control #1 */
304
+#define E1000_GSCL_2    0x05B14 /* PCI-Ex Statistic Control #2 */
305
+#define E1000_GSCL_3    0x05B18 /* PCI-Ex Statistic Control #3 */
306
+#define E1000_GSCL_4    0x05B1C /* PCI-Ex Statistic Control #4 */
307
+#define E1000_FACTPS    0x05B30 /* Function Active and Power State to MNG */
308
+#define E1000_SWSM      0x05B50 /* SW Semaphore */
309
+#define E1000_FWSM      0x05B54 /* FW Semaphore */
310
+#define E1000_SWSM2     0x05B58 /* Driver-only SW semaphore (not used by BOOT agents) */
311
+#define E1000_DCA_ID    0x05B70 /* DCA Requester ID Information - RO */
312
+#define E1000_DCA_CTRL  0x05B74 /* DCA Control - RW */
313
+#define E1000_FFLT_DBG  0x05F04 /* Debug Register */
314
+#define E1000_HICR      0x08F00 /* Host Interface Control */
315
+
316
+/* RSS registers */
317
+#define E1000_CPUVEC    0x02C10 /* CPU Vector Register - RW */
318
+#define E1000_MRQC      0x05818 /* Multiple Receive Control - RW */
319
+#define E1000_IMIR(_i)      (0x05A80 + ((_i) * 4))  /* Immediate Interrupt */
320
+#define E1000_IMIREXT(_i)   (0x05AA0 + ((_i) * 4))  /* Immediate Interrupt Ext*/
321
+#define E1000_IMIRVP    0x05AC0 /* Immediate Interrupt Rx VLAN Priority - RW */
322
+#define E1000_MSIXBM(_i)    (0x01600 + ((_i) * 4)) /* MSI-X Allocation Register
323
+                                                    * (_i) - RW */
324
+#define E1000_MSIXTADD(_i)  (0x0C000 + ((_i) * 0x10)) /* MSI-X Table entry addr
325
+                                                       * low reg - RW */
326
+#define E1000_MSIXTUADD(_i) (0x0C004 + ((_i) * 0x10)) /* MSI-X Table entry addr
327
+                                                       * upper reg - RW */
328
+#define E1000_MSIXTMSG(_i)  (0x0C008 + ((_i) * 0x10)) /* MSI-X Table entry
329
+                                                       * message reg - RW */
330
+#define E1000_MSIXVCTRL(_i) (0x0C00C + ((_i) * 0x10)) /* MSI-X Table entry
331
+                                                       * vector ctrl reg - RW */
332
+#define E1000_MSIXPBA    0x0E000 /* MSI-X Pending bit array */
333
+#define E1000_RETA(_i)  (0x05C00 + ((_i) * 4)) /* Redirection Table - RW */
334
+#define E1000_RSSRK(_i) (0x05C80 + ((_i) * 4)) /* RSS Random Key - RW */
335
+#define E1000_RSSIM     0x05864 /* RSS Interrupt Mask */
336
+#define E1000_RSSIR     0x05868 /* RSS Interrupt Request */
337
+
338
+#endif /* _IGBVF_REGS_H_ */

+ 455
- 0
src/drivers/net/igbvf/igbvf_vf.c View File

@@ -0,0 +1,455 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 1999 - 2008 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
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+FILE_LICENCE ( GPL2_ONLY );
30
+
31
+#include "igbvf_vf.h"
32
+
33
+
34
+static s32       igbvf_init_mac_params_vf(struct e1000_hw *hw);
35
+static s32       igbvf_check_for_link_vf(struct e1000_hw *hw);
36
+static s32       igbvf_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
37
+                                              u16 *duplex);
38
+static s32       igbvf_init_hw_vf(struct e1000_hw *hw);
39
+static s32       igbvf_reset_hw_vf(struct e1000_hw *hw);
40
+static void      igbvf_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *, u32);
41
+static void      igbvf_rar_set_vf(struct e1000_hw *, u8 *, u32);
42
+static s32       igbvf_read_mac_addr_vf(struct e1000_hw *);
43
+
44
+/**
45
+ *  igbvf_init_mac_params_vf - Inits MAC params
46
+ *  @hw: pointer to the HW structure
47
+ **/
48
+static s32 igbvf_init_mac_params_vf(struct e1000_hw *hw)
49
+{
50
+	struct e1000_mac_info *mac = &hw->mac;
51
+
52
+	DEBUGFUNC("igbvf_init_mac_params_vf");
53
+
54
+	/* VF's have no MTA Registers - PF feature only */
55
+	mac->mta_reg_count = 128;
56
+	/* VF's have no access to RAR entries  */
57
+	mac->rar_entry_count = 1;
58
+
59
+	/* Function pointers */
60
+	/* reset */
61
+	mac->ops.reset_hw = igbvf_reset_hw_vf;
62
+	/* hw initialization */
63
+	mac->ops.init_hw = igbvf_init_hw_vf;
64
+	/* check for link */
65
+	mac->ops.check_for_link = igbvf_check_for_link_vf;
66
+	/* link info */
67
+	mac->ops.get_link_up_info = igbvf_get_link_up_info_vf;
68
+	/* multicast address update */
69
+	mac->ops.update_mc_addr_list = igbvf_update_mc_addr_list_vf;
70
+	/* set mac address */
71
+	mac->ops.rar_set = igbvf_rar_set_vf;
72
+	/* read mac address */
73
+	mac->ops.read_mac_addr = igbvf_read_mac_addr_vf;
74
+
75
+
76
+	return E1000_SUCCESS;
77
+}
78
+
79
+/**
80
+ *  igbvf_init_function_pointers_vf - Inits function pointers
81
+ *  @hw: pointer to the HW structure
82
+ **/
83
+void igbvf_init_function_pointers_vf(struct e1000_hw *hw)
84
+{
85
+	DEBUGFUNC("igbvf_init_function_pointers_vf");
86
+
87
+	hw->mac.ops.init_params = igbvf_init_mac_params_vf;
88
+	hw->mbx.ops.init_params = igbvf_init_mbx_params_vf;
89
+}
90
+
91
+/**
92
+ *  igbvf_get_link_up_info_vf - Gets link info.
93
+ *  @hw: pointer to the HW structure
94
+ *  @speed: pointer to 16 bit value to store link speed.
95
+ *  @duplex: pointer to 16 bit value to store duplex.
96
+ *
97
+ *  Since we cannot read the PHY and get accurate link info, we must rely upon
98
+ *  the status register's data which is often stale and inaccurate.
99
+ **/
100
+static s32 igbvf_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
101
+                                     u16 *duplex)
102
+{
103
+	s32 status;
104
+
105
+	DEBUGFUNC("igbvf_get_link_up_info_vf");
106
+
107
+	status = E1000_READ_REG(hw, E1000_STATUS);
108
+	if (status & E1000_STATUS_SPEED_1000) {
109
+		*speed = SPEED_1000;
110
+		DEBUGOUT("1000 Mbs, ");
111
+	} else if (status & E1000_STATUS_SPEED_100) {
112
+		*speed = SPEED_100;
113
+		DEBUGOUT("100 Mbs, ");
114
+	} else {
115
+		*speed = SPEED_10;
116
+		DEBUGOUT("10 Mbs, ");
117
+	}
118
+
119
+	if (status & E1000_STATUS_FD) {
120
+		*duplex = FULL_DUPLEX;
121
+		DEBUGOUT("Full Duplex\n");
122
+	} else {
123
+		*duplex = HALF_DUPLEX;
124
+		DEBUGOUT("Half Duplex\n");
125
+	}
126
+
127
+	return E1000_SUCCESS;
128
+}
129
+
130
+/**
131
+ *  igbvf_reset_hw_vf - Resets the HW
132
+ *  @hw: pointer to the HW structure
133
+ *
134
+ *  VF's provide a function level reset. This is done using bit 26 of ctrl_reg.
135
+ *  This is all the reset we can perform on a VF.
136
+ **/
137
+static s32 igbvf_reset_hw_vf(struct e1000_hw *hw)
138
+{
139
+	struct e1000_mbx_info *mbx = &hw->mbx;
140
+	u32 timeout = E1000_VF_INIT_TIMEOUT;
141
+	s32 ret_val = -E1000_ERR_MAC_INIT;
142
+	u32 ctrl, msgbuf[3];
143
+	u8 *addr = (u8 *)(&msgbuf[1]);
144
+
145
+	DEBUGFUNC("igbvf_reset_hw_vf");
146
+
147
+	DEBUGOUT("Issuing a function level reset to MAC\n");
148
+	ctrl = E1000_READ_REG(hw, E1000_CTRL);
149
+	E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
150
+
151
+	/* we cannot reset while the RSTI / RSTD bits are asserted */
152
+	while (!mbx->ops.check_for_rst(hw, 0) && timeout) {
153
+		timeout--;
154
+		usec_delay(5);
155
+	}
156
+
157
+	if (timeout) {
158
+		/* mailbox timeout can now become active */
159
+		mbx->timeout = E1000_VF_MBX_INIT_TIMEOUT;
160
+
161
+		msgbuf[0] = E1000_VF_RESET;
162
+		mbx->ops.write_posted(hw, msgbuf, 1, 0);
163
+
164
+		msec_delay(10);
165
+
166
+		/* set our "perm_addr" based on info provided by PF */
167
+		ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
168
+		if (!ret_val) {
169
+			if (msgbuf[0] == (E1000_VF_RESET |
170
+						E1000_VT_MSGTYPE_ACK))
171
+				memcpy(hw->mac.perm_addr, addr, 6);
172
+			else
173
+				ret_val = -E1000_ERR_MAC_INIT;
174
+		}
175
+	}
176
+
177
+	return ret_val;
178
+}
179
+
180
+/**
181
+ *  igbvf_init_hw_vf - Inits the HW
182
+ *  @hw: pointer to the HW structure
183
+ *
184
+ *  Not much to do here except clear the PF Reset indication if there is one.
185
+ **/
186
+static s32 igbvf_init_hw_vf(struct e1000_hw *hw)
187
+{
188
+	DEBUGFUNC("igbvf_init_hw_vf");
189
+
190
+	/* attempt to set and restore our mac address */
191
+	igbvf_rar_set_vf(hw, hw->mac.addr, 0);
192
+
193
+	return E1000_SUCCESS;
194
+}
195
+
196
+/**
197
+ *  igbvf_rar_set_vf - set device MAC address
198
+ *  @hw: pointer to the HW structure
199
+ *  @addr: pointer to the receive address
200
+ *  @index receive address array register
201
+ **/
202
+static void igbvf_rar_set_vf(struct e1000_hw *hw, u8 * addr, u32 index __unused)
203
+{
204
+	struct e1000_mbx_info *mbx = &hw->mbx;
205
+	u32 msgbuf[3];
206
+	u8 *msg_addr = (u8 *)(&msgbuf[1]);
207
+	s32 ret_val;
208
+
209
+	memset(msgbuf, 0, 12);
210
+	msgbuf[0] = E1000_VF_SET_MAC_ADDR;
211
+	memcpy(msg_addr, addr, 6);
212
+	ret_val = mbx->ops.write_posted(hw, msgbuf, 3, 0);
213
+
214
+	if (!ret_val)
215
+		ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
216
+
217
+	msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
218
+
219
+	/* if nacked the address was rejected, use "perm_addr" */
220
+	if (!ret_val &&
221
+	    (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK)))
222
+		igbvf_read_mac_addr_vf(hw);
223
+}
224
+
225
+/**
226
+ *  igbvf_hash_mc_addr_vf - Generate a multicast hash value
227
+ *  @hw: pointer to the HW structure
228
+ *  @mc_addr: pointer to a multicast address
229
+ *
230
+ *  Generates a multicast address hash value which is used to determine
231
+ *  the multicast filter table array address and new table value.  See
232
+ *  igbvf_mta_set_generic()
233
+ **/
234
+static u32 igbvf_hash_mc_addr_vf(struct e1000_hw *hw, u8 *mc_addr)
235
+{
236
+	u32 hash_value, hash_mask;
237
+	u8 bit_shift = 0;
238
+
239
+	DEBUGFUNC("igbvf_hash_mc_addr_generic");
240
+
241
+	/* Register count multiplied by bits per register */
242
+	hash_mask = (hw->mac.mta_reg_count * 32) - 1;
243
+
244
+	/*
245
+	 * The bit_shift is the number of left-shifts
246
+	 * where 0xFF would still fall within the hash mask.
247
+	 */
248
+	while (hash_mask >> bit_shift != 0xFF)
249
+		bit_shift++;
250
+
251
+	hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
252
+	                          (((u16) mc_addr[5]) << bit_shift)));
253
+
254
+	return hash_value;
255
+}
256
+
257
+/**
258
+ *  igbvf_update_mc_addr_list_vf - Update Multicast addresses
259
+ *  @hw: pointer to the HW structure
260
+ *  @mc_addr_list: array of multicast addresses to program
261
+ *  @mc_addr_count: number of multicast addresses to program
262
+ *
263
+ *  Updates the Multicast Table Array.
264
+ *  The caller must have a packed mc_addr_list of multicast addresses.
265
+ **/
266
+void igbvf_update_mc_addr_list_vf(struct e1000_hw *hw,
267
+                                  u8 *mc_addr_list, u32 mc_addr_count)
268
+{
269
+	struct e1000_mbx_info *mbx = &hw->mbx;
270
+	u32 msgbuf[E1000_VFMAILBOX_SIZE];
271
+	u16 *hash_list = (u16 *)&msgbuf[1];
272
+	u32 hash_value;
273
+	u32 i;
274
+
275
+	DEBUGFUNC("igbvf_update_mc_addr_list_vf");
276
+
277
+	/* Each entry in the list uses 1 16 bit word.  We have 30
278
+	 * 16 bit words available in our HW msg buffer (minus 1 for the
279
+	 * msg type).  That's 30 hash values if we pack 'em right.  If
280
+	 * there are more than 30 MC addresses to add then punt the
281
+	 * extras for now and then add code to handle more than 30 later.
282
+	 * It would be unusual for a server to request that many multi-cast
283
+	 * addresses except for in large enterprise network environments.
284
+	 */
285
+
286
+	DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
287
+
288
+	msgbuf[0] = E1000_VF_SET_MULTICAST;
289
+
290
+	if (mc_addr_count > 30) {
291
+		msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW;
292
+		mc_addr_count = 30;
293
+	}
294
+
295
+	msgbuf[0] |= mc_addr_count << E1000_VT_MSGINFO_SHIFT;
296
+
297
+	for (i = 0; i < mc_addr_count; i++) {
298
+		hash_value = igbvf_hash_mc_addr_vf(hw, mc_addr_list);
299
+		DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
300
+		hash_list[i] = hash_value & 0x0FFF;
301
+		mc_addr_list += ETH_ADDR_LEN;
302
+	}
303
+
304
+	mbx->ops.write_posted(hw, msgbuf, E1000_VFMAILBOX_SIZE, 0);
305
+}
306
+
307
+/**
308
+ *  igbvf_vfta_set_vf - Set/Unset vlan filter table address
309
+ *  @hw: pointer to the HW structure
310
+ *  @vid: determines the vfta register and bit to set/unset
311
+ *  @set: if true then set bit, else clear bit
312
+ **/
313
+void igbvf_vfta_set_vf(struct e1000_hw *hw, u16 vid, bool set)
314
+{
315
+	struct e1000_mbx_info *mbx = &hw->mbx;
316
+	u32 msgbuf[2];
317
+
318
+	msgbuf[0] = E1000_VF_SET_VLAN;
319
+	msgbuf[1] = vid;
320
+	/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
321
+	if (set)
322
+		msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
323
+
324
+	mbx->ops.write_posted(hw, msgbuf, 2, 0);
325
+}
326
+
327
+/** igbvf_rlpml_set_vf - Set the maximum receive packet length
328
+ *  @hw: pointer to the HW structure
329
+ *  @max_size: value to assign to max frame size
330
+ **/
331
+void igbvf_rlpml_set_vf(struct e1000_hw *hw, u16 max_size)
332
+{
333
+	struct e1000_mbx_info *mbx = &hw->mbx;
334
+	u32 msgbuf[2];
335
+
336
+	msgbuf[0] = E1000_VF_SET_LPE;
337
+	msgbuf[1] = max_size;
338
+
339
+	mbx->ops.write_posted(hw, msgbuf, 2, 0);
340
+}
341
+
342
+/**
343
+ *  igbvf_promisc_set_vf - Set flags for Unicast or Multicast promisc
344
+ *  @hw: pointer to the HW structure
345
+ *  @uni: boolean indicating unicast promisc status
346
+ *  @multi: boolean indicating multicast promisc status
347
+ **/
348
+s32 igbvf_promisc_set_vf(struct e1000_hw *hw, enum e1000_promisc_type type)
349
+{
350
+	struct e1000_mbx_info *mbx = &hw->mbx;
351
+	u32 msgbuf = E1000_VF_SET_PROMISC;
352
+	s32 ret_val;
353
+
354
+	switch (type) {
355
+	case e1000_promisc_multicast:
356
+		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
357
+		break;
358
+	case e1000_promisc_enabled:
359
+		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
360
+	case e1000_promisc_unicast:
361
+		msgbuf |= E1000_VF_SET_PROMISC_UNICAST;
362
+	case e1000_promisc_disabled:
363
+		break;
364
+	default:
365
+		return -E1000_ERR_MAC_INIT;
366
+	}
367
+
368
+	 ret_val = mbx->ops.write_posted(hw, &msgbuf, 1, 0);
369
+
370
+	if (!ret_val)
371
+		ret_val = mbx->ops.read_posted(hw, &msgbuf, 1, 0);
372
+
373
+	if (!ret_val && !(msgbuf & E1000_VT_MSGTYPE_ACK))
374
+		ret_val = -E1000_ERR_MAC_INIT;
375
+
376
+	return ret_val;
377
+}
378
+
379
+/**
380
+ *  igbvf_read_mac_addr_vf - Read device MAC address
381
+ *  @hw: pointer to the HW structure
382
+ **/
383
+static s32 igbvf_read_mac_addr_vf(struct e1000_hw *hw)
384
+{
385
+	int i;
386
+
387
+	for (i = 0; i < ETH_ADDR_LEN; i++)
388
+		hw->mac.addr[i] = hw->mac.perm_addr[i];
389
+
390
+	return E1000_SUCCESS;
391
+}
392
+
393
+/**
394
+ *  igbvf_check_for_link_vf - Check for link for a virtual interface
395
+ *  @hw: pointer to the HW structure
396
+ *
397
+ *  Checks to see if the underlying PF is still talking to the VF and
398
+ *  if it is then it reports the link state to the hardware, otherwise
399
+ *  it reports link down and returns an error.
400
+ **/
401
+static s32 igbvf_check_for_link_vf(struct e1000_hw *hw)
402
+{
403
+	struct e1000_mbx_info *mbx = &hw->mbx;
404
+	struct e1000_mac_info *mac = &hw->mac;
405
+	s32 ret_val = E1000_SUCCESS;
406
+	u32 in_msg = 0;
407
+
408
+	DEBUGFUNC("igbvf_check_for_link_vf");
409
+
410
+	/*
411
+	 * We only want to run this if there has been a rst asserted.
412
+	 * in this case that could mean a link change, device reset,
413
+	 * or a virtual function reset
414
+	 */
415
+
416
+	/* If we were hit with a reset drop the link */
417
+	if (!mbx->ops.check_for_rst(hw, 0))
418
+		mac->get_link_status = true;
419
+
420
+	if (!mac->get_link_status)
421
+		goto out;
422
+
423
+	/* if link status is down no point in checking to see if pf is up */
424
+	if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU))
425
+		goto out;
426
+
427
+	/* if the read failed it could just be a mailbox collision, best wait
428
+	 * until we are called again and don't report an error */
429
+	if (mbx->ops.read(hw, &in_msg, 1, 0))
430
+		goto out;
431
+
432
+	/* if incoming message isn't clear to send we are waiting on response */
433
+	if (!(in_msg & E1000_VT_MSGTYPE_CTS)) {
434
+		/* message is not CTS and is NACK we have lost CTS status */
435
+		if (in_msg & E1000_VT_MSGTYPE_NACK)
436
+			ret_val = -E1000_ERR_MAC_INIT;
437
+		goto out;
438
+	}
439
+
440
+	/* at this point we know the PF is talking to us, check and see if
441
+	 * we are still accepting timeout or if we had a timeout failure.
442
+	 * if we failed then we will need to reinit */
443
+	if (!mbx->timeout) {
444
+		ret_val = -E1000_ERR_MAC_INIT;
445
+		goto out;
446
+	}
447
+
448
+	/* if we passed all the tests above then the link is up and we no
449
+	 * longer need to check for link */
450
+	mac->get_link_status = false;
451
+
452
+out:
453
+	return ret_val;
454
+}
455
+

+ 345
- 0
src/drivers/net/igbvf/igbvf_vf.h View File

@@ -0,0 +1,345 @@
1
+/*******************************************************************************
2
+
3
+  Intel(R) 82576 Virtual Function Linux driver
4
+  Copyright(c) 1999 - 2008 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
+  Linux NICS <linux.nics@intel.com>
24
+  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25
+  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
+
27
+*******************************************************************************/
28
+
29
+FILE_LICENCE ( GPL2_ONLY );
30
+
31
+#ifndef _IGBVF_VF_H_
32
+#define _IGBVF_VF_H_
33
+
34
+#include <stddef.h>
35
+#include <stdint.h>
36
+#include <stdlib.h>
37
+#include <stdio.h>
38
+#include <string.h>
39
+#include <unistd.h>
40
+#include <byteswap.h>
41
+#include <errno.h>
42
+#include <ipxe/pci.h>
43
+#include <ipxe/malloc.h>
44
+#include <ipxe/if_ether.h>
45
+#include <ipxe/io.h>
46
+#include <ipxe/ethernet.h>
47
+#include <ipxe/iobuf.h>
48
+#include <ipxe/netdevice.h>
49
+
50
+#include "igbvf_osdep.h"
51
+#include "igbvf_regs.h"
52
+#include "igbvf_defines.h"
53
+
54
+struct e1000_hw;
55
+
56
+#define E1000_DEV_ID_82576_VF                 0x10CA
57
+
58
+#define E1000_VF_INIT_TIMEOUT 200 /* Number of retries to clear RSTI */
59
+
60
+/* Additional Descriptor Control definitions */
61
+#define E1000_TXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Tx Queue */
62
+#define E1000_RXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Rx Queue */
63
+
64
+/* SRRCTL bit definitions */
65
+#define E1000_SRRCTL_BSIZEPKT_SHIFT                     10 /* Shift _right_ */
66
+#define E1000_SRRCTL_BSIZEHDRSIZE_MASK                  0x00000F00
67
+#define E1000_SRRCTL_BSIZEHDRSIZE_SHIFT                 2  /* Shift _left_ */
68
+#define E1000_SRRCTL_DESCTYPE_LEGACY                    0x00000000
69
+#define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF                0x02000000
70
+#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT                 0x04000000
71
+#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS          0x0A000000
72
+#define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION           0x06000000
73
+#define E1000_SRRCTL_DESCTYPE_HDR_REPLICATION_LARGE_PKT 0x08000000
74
+#define E1000_SRRCTL_DESCTYPE_MASK                      0x0E000000
75
+#define E1000_SRRCTL_DROP_EN                            0x80000000
76
+
77
+#define E1000_SRRCTL_BSIZEPKT_MASK      0x0000007F
78
+#define E1000_SRRCTL_BSIZEHDR_MASK      0x00003F00
79
+
80
+/* Interrupt Defines */
81
+#define E1000_EICR     0x01580  /* Ext. Interrupt Cause Read - R/clr */
82
+#define E1000_EITR(_n) (0x01680 + ((_n) << 2))
83
+#define E1000_EICS     0x01520  /* Ext. Interrupt Cause Set - W0 */
84
+#define E1000_EIMS     0x01524  /* Ext. Interrupt Mask Set/Read - RW */
85
+#define E1000_EIMC     0x01528  /* Ext. Interrupt Mask Clear - WO */
86
+#define E1000_EIAC     0x0152C  /* Ext. Interrupt Auto Clear - RW */
87
+#define E1000_EIAM     0x01530  /* Ext. Interrupt Ack Auto Clear Mask - RW */
88
+#define E1000_IVAR0    0x01700  /* Interrupt Vector Allocation (array) - RW */
89
+#define E1000_IVAR_MISC 0x01740 /* IVAR for "other" causes - RW */
90
+#define E1000_IVAR_VALID        0x80
91
+
92
+/* Receive Descriptor - Advanced */
93
+union e1000_adv_rx_desc {
94
+	struct {
95
+		u64 pkt_addr;             /* Packet buffer address */
96
+		u64 hdr_addr;             /* Header buffer address */
97
+	} read;
98
+	struct {
99
+		struct {
100
+			union {
101
+				u32 data;
102
+				struct {
103
+					u16 pkt_info; /* RSS type, Packet type */
104
+					u16 hdr_info; /* Split Header,
105
+						       * header buffer length */
106
+				} hs_rss;
107
+			} lo_dword;
108
+			union {
109
+				u32 rss;          /* RSS Hash */
110
+				struct {
111
+					u16 ip_id;    /* IP id */
112
+					u16 csum;     /* Packet Checksum */
113
+				} csum_ip;
114
+			} hi_dword;
115
+		} lower;
116
+		struct {
117
+			u32 status_error;     /* ext status/error */
118
+			u16 length;           /* Packet length */
119
+			u16 vlan;             /* VLAN tag */
120
+		} upper;
121
+	} wb;  /* writeback */
122
+};
123
+
124
+#define E1000_RXDADV_HDRBUFLEN_MASK      0x7FE0
125
+#define E1000_RXDADV_HDRBUFLEN_SHIFT     5
126
+
127
+/* Transmit Descriptor - Advanced */
128
+union e1000_adv_tx_desc {
129
+	struct {
130
+		u64 buffer_addr;    /* Address of descriptor's data buf */
131
+		u32 cmd_type_len;
132
+		u32 olinfo_status;
133
+	} read;
134
+	struct {
135
+		u64 rsvd;       /* Reserved */
136
+		u32 nxtseq_seed;
137
+		u32 status;
138
+	} wb;
139
+};
140
+
141
+/* Adv Transmit Descriptor Config Masks */
142
+#define E1000_ADVTXD_DTYP_CTXT    0x00200000 /* Advanced Context Descriptor */
143
+#define E1000_ADVTXD_DTYP_DATA    0x00300000 /* Advanced Data Descriptor */
144
+#define E1000_ADVTXD_DCMD_EOP     0x01000000 /* End of Packet */
145
+#define E1000_ADVTXD_DCMD_IFCS    0x02000000 /* Insert FCS (Ethernet CRC) */
146
+#define E1000_ADVTXD_DCMD_RS      0x08000000 /* Report Status */
147
+#define E1000_ADVTXD_DCMD_DEXT    0x20000000 /* Descriptor extension (1=Adv) */
148
+#define E1000_ADVTXD_DCMD_VLE     0x40000000 /* VLAN pkt enable */
149
+#define E1000_ADVTXD_DCMD_TSE     0x80000000 /* TCP Seg enable */
150
+#define E1000_ADVTXD_PAYLEN_SHIFT    14 /* Adv desc PAYLEN shift */
151
+
152
+/* Context descriptors */
153
+struct e1000_adv_tx_context_desc {
154
+	u32 vlan_macip_lens;
155
+	u32 seqnum_seed;
156
+	u32 type_tucmd_mlhl;
157
+	u32 mss_l4len_idx;
158
+};
159
+
160
+#define E1000_ADVTXD_MACLEN_SHIFT    9  /* Adv ctxt desc mac len shift */
161
+#define E1000_ADVTXD_TUCMD_IPV4    0x00000400  /* IP Packet Type: 1=IPv4 */
162
+#define E1000_ADVTXD_TUCMD_L4T_TCP 0x00000800  /* L4 Packet TYPE of TCP */
163
+#define E1000_ADVTXD_L4LEN_SHIFT     8  /* Adv ctxt L4LEN shift */
164
+#define E1000_ADVTXD_MSS_SHIFT      16  /* Adv ctxt MSS shift */
165
+
166
+enum e1000_mac_type {
167
+	e1000_undefined = 0,
168
+	e1000_vfadapt,
169
+	e1000_num_macs  /* List is 1-based, so subtract 1 for true count. */
170
+};
171
+
172
+struct e1000_vf_stats {
173
+	u64 base_gprc;
174
+	u64 base_gptc;
175
+	u64 base_gorc;
176
+	u64 base_gotc;
177
+	u64 base_mprc;
178
+	u64 base_gotlbc;
179
+	u64 base_gptlbc;
180
+	u64 base_gorlbc;
181
+	u64 base_gprlbc;
182
+
183
+	u32 last_gprc;
184
+	u32 last_gptc;
185
+	u32 last_gorc;
186
+	u32 last_gotc;
187
+	u32 last_mprc;
188
+	u32 last_gotlbc;
189
+	u32 last_gptlbc;
190
+	u32 last_gorlbc;
191
+	u32 last_gprlbc;
192
+
193
+	u64 gprc;
194
+	u64 gptc;
195
+	u64 gorc;
196
+	u64 gotc;
197
+	u64 mprc;
198
+	u64 gotlbc;
199
+	u64 gptlbc;
200
+	u64 gorlbc;
201
+	u64 gprlbc;
202
+};
203
+
204
+#include "igbvf_mbx.h"
205
+
206
+struct e1000_mac_operations {
207
+	/* Function pointers for the MAC. */
208
+	s32  (*init_params)(struct e1000_hw *);
209
+	s32  (*check_for_link)(struct e1000_hw *);
210
+	void (*clear_vfta)(struct e1000_hw *);
211
+	s32  (*get_bus_info)(struct e1000_hw *);
212
+	s32  (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
213
+	void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
214
+	s32  (*reset_hw)(struct e1000_hw *);
215
+	s32  (*init_hw)(struct e1000_hw *);
216
+	s32  (*setup_link)(struct e1000_hw *);
217
+	void (*write_vfta)(struct e1000_hw *, u32, u32);
218
+	void (*mta_set)(struct e1000_hw *, u32);
219
+	void (*rar_set)(struct e1000_hw *, u8*, u32);
220
+	s32  (*read_mac_addr)(struct e1000_hw *);
221
+};
222
+
223
+struct e1000_mac_info {
224
+	struct e1000_mac_operations ops;
225
+	u8 addr[6];
226
+	u8 perm_addr[6];
227
+
228
+	enum e1000_mac_type type;
229
+
230
+	u16 mta_reg_count;
231
+	u16 rar_entry_count;
232
+
233
+	bool get_link_status;
234
+};
235
+
236
+enum e1000_bus_type {
237
+	e1000_bus_type_unknown = 0,
238
+	e1000_bus_type_pci,
239
+	e1000_bus_type_pcix,
240
+	e1000_bus_type_pci_express,
241
+	e1000_bus_type_reserved
242
+};
243
+
244
+enum e1000_bus_speed {
245
+	e1000_bus_speed_unknown = 0,
246
+	e1000_bus_speed_33,
247
+	e1000_bus_speed_66,
248
+	e1000_bus_speed_100,
249
+	e1000_bus_speed_120,
250
+	e1000_bus_speed_133,
251
+	e1000_bus_speed_2500,
252
+	e1000_bus_speed_5000,
253
+	e1000_bus_speed_reserved
254
+};
255
+
256
+enum e1000_bus_width {
257
+	e1000_bus_width_unknown = 0,
258
+	e1000_bus_width_pcie_x1,
259
+	e1000_bus_width_pcie_x2,
260
+	e1000_bus_width_pcie_x4 = 4,
261
+	e1000_bus_width_pcie_x8 = 8,
262
+	e1000_bus_width_32,
263
+	e1000_bus_width_64,
264
+	e1000_bus_width_reserved
265
+};
266
+
267
+struct e1000_bus_info {
268
+	enum e1000_bus_type type;
269
+	enum e1000_bus_speed speed;
270
+	enum e1000_bus_width width;
271
+
272
+	u16 func;
273
+	u16 pci_cmd_word;
274
+};
275
+
276
+struct e1000_mbx_operations {
277
+	s32 (*init_params)(struct e1000_hw *hw);
278
+	s32 (*read)(struct e1000_hw *, u32 *, u16,  u16);
279
+	s32 (*write)(struct e1000_hw *, u32 *, u16, u16);
280
+	s32 (*read_posted)(struct e1000_hw *, u32 *, u16,  u16);
281
+	s32 (*write_posted)(struct e1000_hw *, u32 *, u16, u16);
282
+	s32 (*check_for_msg)(struct e1000_hw *, u16);
283
+	s32 (*check_for_ack)(struct e1000_hw *, u16);
284
+	s32 (*check_for_rst)(struct e1000_hw *, u16);
285
+};
286
+
287
+struct e1000_mbx_stats {
288
+	u32 msgs_tx;
289
+	u32 msgs_rx;
290
+
291
+	u32 acks;
292
+	u32 reqs;
293
+	u32 rsts;
294
+};
295
+
296
+struct e1000_mbx_info {
297
+	struct e1000_mbx_operations ops;
298
+	struct e1000_mbx_stats stats;
299
+	u32 timeout;
300
+	u32 usec_delay;
301
+	u16 size;
302
+};
303
+
304
+struct e1000_dev_spec_vf {
305
+	u32	vf_number;
306
+	u32	v2p_mailbox;
307
+};
308
+
309
+struct e1000_hw {
310
+	void *back;
311
+
312
+	u8 __iomem *hw_addr;
313
+	u8 __iomem *flash_address;
314
+	unsigned long io_base;
315
+
316
+	struct e1000_mac_info  mac;
317
+	struct e1000_bus_info  bus;
318
+	struct e1000_mbx_info mbx;
319
+
320
+	union {
321
+		struct e1000_dev_spec_vf	vf;
322
+	} dev_spec;
323
+
324
+	u16 device_id;
325
+	u16 subsystem_vendor_id;
326
+	u16 subsystem_device_id;
327
+	u16 vendor_id;
328
+
329
+	u8  revision_id;
330
+};
331
+
332
+enum e1000_promisc_type {
333
+	e1000_promisc_disabled = 0,   /* all promisc modes disabled */
334
+	e1000_promisc_unicast = 1,    /* unicast promiscuous enabled */
335
+	e1000_promisc_multicast = 2,  /* multicast promiscuous enabled */
336
+	e1000_promisc_enabled = 3,    /* both uni and multicast promisc */
337
+	e1000_num_promisc_types
338
+};
339
+
340
+/* These functions must be implemented by drivers */
341
+s32  igbvf_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
342
+void igbvf_vfta_set_vf(struct e1000_hw *, u16, bool);
343
+void igbvf_rlpml_set_vf(struct e1000_hw *, u16);
344
+s32 igbvf_promisc_set_vf(struct e1000_hw *, enum e1000_promisc_type);
345
+#endif /* _IGBVF_VF_H_ */

+ 1
- 0
src/include/ipxe/errfile.h View File

@@ -135,6 +135,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
135 135
 #define ERRFILE_jme		     ( ERRFILE_DRIVER | 0x005b0000 )
136 136
 #define ERRFILE_virtio_net	     ( ERRFILE_DRIVER | 0x005c0000 )
137 137
 #define ERRFILE_tap		     ( ERRFILE_DRIVER | 0x005d0000 )
138
+#define ERRFILE_igbvf_main	     ( ERRFILE_DRIVER | 0x005e0000 )
138 139
 
139 140
 #define ERRFILE_scsi		     ( ERRFILE_DRIVER | 0x00700000 )
140 141
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )

Loading…
Cancel
Save