iPXE
igbvf_main.c File Reference
#include "igbvf.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_ONLY)
int igbvf_setup_tx_resources (struct igbvf_adapter *adapter)
 igbvf_setup_tx_resources - allocate Tx resources (Descriptors)
void igbvf_free_tx_resources (struct igbvf_adapter *adapter)
 igbvf_free_tx_resources - Free Tx Resources per Queue @adapter: board private structure
void igbvf_free_rx_resources (struct igbvf_adapter *adapter)
 igbvf_free_rx_resources - Free Rx Resources @adapter: board private structure
static int igbvf_refill_rx_ring (struct igbvf_adapter *adapter)
 igbvf_refill_rx_ring - allocate Rx io_buffers
static void igbvf_irq_disable (struct igbvf_adapter *adapter)
 igbvf_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure
static void igbvf_irq_enable (struct igbvf_adapter *adapter)
 igbvf_irq_enable - Enable default interrupt generation settings @adapter: board private structure
static void igbvf_irq (struct net_device *netdev, int enable)
 igbvf_irq - enable or Disable interrupts
static void igbvf_process_tx_packets (struct net_device *netdev)
 igbvf_process_tx_packets - process transmitted packets
static void igbvf_process_rx_packets (struct net_device *netdev)
 igbvf_process_rx_packets - process received packets
static void igbvf_poll (struct net_device *netdev)
 igbvf_poll - Poll for received packets
void igbvf_config_collision_dist (struct e1000_hw *hw)
 igbvf_config_collision_dist_generic - Configure collision distance @hw: pointer to the HW structure
static void igbvf_configure_tx (struct igbvf_adapter *adapter)
 igbvf_configure_tx - Configure Transmit Unit after Reset @adapter: board private structure
void igbvf_reset (struct igbvf_adapter *adapter)
void igbvf_init_function_pointers_vf (struct e1000_hw *hw)
 igbvf_init_function_pointers_vf - Inits function pointers @hw: pointer to the HW structure
static int __devinit igbvf_sw_init (struct igbvf_adapter *adapter)
 igbvf_sw_init - Initialize general software structures (struct igbvf_adapter) @adapter: board private structure to initialize
static void igbvf_setup_srrctl (struct igbvf_adapter *adapter)
 igbvf_setup_srrctl - configure the receive control registers @adapter: Board private structure
static void igbvf_configure_rx (struct igbvf_adapter *adapter)
 igbvf_configure_rx - Configure 8254x Receive Unit after Reset @adapter: board private structure
int igbvf_setup_rx_resources (struct igbvf_adapter *adapter)
 igbvf_setup_rx_resources - allocate Rx resources (Descriptors)
static int igbvf_open (struct net_device *netdev)
 igbvf_open - Called when a network interface is made active @netdev: network interface device structure
static void igbvf_close (struct net_device *netdev)
 igbvf_close - Disables a network interface @netdev: network interface device structure
static int igbvf_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 igbvf_transmit - Transmit a packet
void igbvf_get_hw_control (struct igbvf_adapter *adapter)
 igbvf_get_hw_control - get control of the h/w from f/w @adapter: address of board private structure
int igbvf_probe (struct pci_device *pdev)
 igbvf_probe - Device Initialization Routine @pdev: PCI device information struct @ent: entry in igbvf_pci_tbl
void igbvf_remove (struct pci_device *pdev)
 igbvf_remove - Device Removal Routine @pdev: PCI device information struct

Variables

static struct net_device_operations igbvf_operations
 igbvf net device operations
static struct pci_device_id igbvf_pci_tbl []
struct pci_driver igbvf_driver __pci_driver

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY )

◆ igbvf_setup_tx_resources()

int igbvf_setup_tx_resources ( struct igbvf_adapter * adapter)

igbvf_setup_tx_resources - allocate Tx resources (Descriptors)

Parameters
adaptere1000 private structure
Return values
rcReturns 0 on success, negative on failure

Definition at line 43 of file igbvf_main.c.

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_phys() 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_phys ( 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}
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define ENOMEM
Not enough space.
Definition errno.h:535
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
void * memset(void *dest, int character, size_t len) __nonnull
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707
union e1000_adv_tx_desc * tx_base
Definition igbvf.h:286
uint32_t tx_ring_size
Definition igbvf.h:289

References DBG, ENOMEM, malloc_phys(), memset(), igbvf_adapter::tx_base, igbvf_adapter::tx_ring_size, and virt_to_bus().

Referenced by igbvf_open().

◆ igbvf_free_tx_resources()

void igbvf_free_tx_resources ( struct igbvf_adapter * adapter)

igbvf_free_tx_resources - Free Tx Resources per Queue @adapter: board private structure

Free all transmit software resources

Definition at line 77 of file igbvf_main.c.

78{
79 DBG ( "igbvf_free_tx_resources\n" );
80
81 free_phys ( adapter->tx_base, adapter->tx_ring_size );
82}
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723

References DBG, free_phys(), igbvf_adapter::tx_base, and igbvf_adapter::tx_ring_size.

Referenced by igbvf_close(), and igbvf_open().

◆ igbvf_free_rx_resources()

void igbvf_free_rx_resources ( struct igbvf_adapter * adapter)

igbvf_free_rx_resources - Free Rx Resources @adapter: board private structure

Free all receive software resources

Definition at line 90 of file igbvf_main.c.

91{
92 int i;
93
94 DBG ( "igbvf_free_rx_resources\n" );
95
96 free_phys ( 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}
#define NUM_RX_DESC
Definition igbvf.h:281
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
union e1000_adv_rx_desc * rx_base
Definition igbvf.h:287
uint32_t rx_ring_size
Definition igbvf.h:290
struct io_buffer * rx_iobuf[NUM_RX_DESC]
Definition igbvf.h:284

References DBG, free_iob(), free_phys(), NUM_RX_DESC, igbvf_adapter::rx_base, igbvf_adapter::rx_iobuf, and igbvf_adapter::rx_ring_size.

Referenced by igbvf_close().

◆ igbvf_refill_rx_ring()

int igbvf_refill_rx_ring ( struct igbvf_adapter * adapter)
static

igbvf_refill_rx_ring - allocate Rx io_buffers

Parameters
adaptere1000 private structure
Return values
rcReturns 0 on success, negative on failure

Definition at line 110 of file igbvf_main.c.

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
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}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBGP(...)
Definition compiler.h:532
#define DBG2(...)
Definition compiler.h:515
#define ew32(reg, val)
Definition igbvf.h:374
#define MAXIMUM_ETHERNET_VLAN_SIZE
Definition igbvf.h:77
#define E1000_RXD_STAT_DD
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition iobuf.c:131
Definition hw.c:16
uint32_t rx_curr
Definition igbvf.h:296
struct e1000_hw hw
Definition igbvf.h:273
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53
struct e1000_adv_rx_desc::@302144110352222217365215063167103107375312305323 read
struct e1000_adv_rx_desc::@324104077243240211364137173065054016027147265141::@071135136066236263262155133326122220255171234376 upper
struct e1000_adv_rx_desc::@324104077243240211364137173065054016027147265141 wb

References alloc_iob(), io_buffer::data, DBG, DBG2, DBGP, E1000_RXD_STAT_DD, ENOMEM, ew32, e1000_adv_rx_desc::hdr_addr, igbvf_adapter::hw, MAXIMUM_ETHERNET_VLAN_SIZE, NULL, NUM_RX_DESC, e1000_adv_rx_desc::pkt_addr, rc, e1000_adv_rx_desc::read, igbvf_adapter::rx_base, igbvf_adapter::rx_curr, igbvf_adapter::rx_iobuf, e1000_adv_rx_desc::status_error, e1000_adv_rx_desc::upper, virt_to_bus(), and e1000_adv_rx_desc::wb.

Referenced by igbvf_poll().

◆ igbvf_irq_disable()

void igbvf_irq_disable ( struct igbvf_adapter * adapter)
static

igbvf_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure

Definition at line 154 of file igbvf_main.c.

155{
156 struct e1000_hw *hw = &adapter->hw;
157
158 ew32 ( EIMC, ~0 );
159}

References ew32, and igbvf_adapter::hw.

Referenced by igbvf_close(), igbvf_irq(), and igbvf_sw_init().

◆ igbvf_irq_enable()

void igbvf_irq_enable ( struct igbvf_adapter * adapter)
static

igbvf_irq_enable - Enable default interrupt generation settings @adapter: board private structure

Definition at line 165 of file igbvf_main.c.

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}
#define IMS_ENABLE_MASK

References ew32, igbvf_adapter::hw, and IMS_ENABLE_MASK.

Referenced by igbvf_irq().

◆ igbvf_irq()

void igbvf_irq ( struct net_device * netdev,
int enable )
static

igbvf_irq - enable or Disable interrupts

Parameters
adaptere1000 adapter
actionrequested interrupt action

Definition at line 180 of file igbvf_main.c.

181{
182 struct igbvf_adapter *adapter = netdev->priv;
183
184 DBG ( "igbvf_irq\n" );
185
186 if ( enable ) {
187 igbvf_irq_enable ( adapter );
188 } else {
189 igbvf_irq_disable ( adapter );
190 }
191}
static struct net_device * netdev
Definition gdbudp.c:53
static void igbvf_irq_disable(struct igbvf_adapter *adapter)
igbvf_irq_disable - Mask off interrupt generation on the NIC @adapter: board private structure
Definition igbvf_main.c:154
static void igbvf_irq_enable(struct igbvf_adapter *adapter)
igbvf_irq_enable - Enable default interrupt generation settings @adapter: board private structure
Definition igbvf_main.c:165

References DBG, igbvf_irq_disable(), igbvf_irq_enable(), and netdev.

◆ igbvf_process_tx_packets()

void igbvf_process_tx_packets ( struct net_device * netdev)
static

igbvf_process_tx_packets - process transmitted packets

Parameters
netdevnetwork interface device structure

Definition at line 198 of file igbvf_main.c.

199{
200 struct igbvf_adapter *adapter = netdev->priv;
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}
unsigned int uint32_t
Definition stdint.h:12
#define NUM_TX_DESC
Definition igbvf.h:280
#define E1000_TXD_STAT_DD
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767
uint32_t tx_tail
Definition igbvf.h:293
struct io_buffer * tx_iobuf[NUM_TX_DESC]
Definition igbvf.h:283
uint32_t tx_head
Definition igbvf.h:292
uint32_t tx_fill_ctr
Definition igbvf.h:294
struct e1000_adv_tx_desc::@341340065042306374070130041365162125260313270241 wb

References DBG, DBGP, E1000_TXD_STAT_DD, memset(), netdev, netdev_tx_complete(), NUM_TX_DESC, e1000_adv_tx_desc::status, igbvf_adapter::tx_base, igbvf_adapter::tx_fill_ctr, igbvf_adapter::tx_head, igbvf_adapter::tx_iobuf, igbvf_adapter::tx_tail, virt_to_bus(), and e1000_adv_tx_desc::wb.

Referenced by igbvf_poll().

◆ igbvf_process_rx_packets()

void igbvf_process_rx_packets ( struct net_device * netdev)
static

igbvf_process_rx_packets - process received packets

Parameters
netdevnetwork interface device structure

Definition at line 244 of file igbvf_main.c.

245{
246 struct igbvf_adapter *adapter = netdev->priv;
247 struct e1000_hw *hw = &adapter->hw;
248 uint32_t i;
249 uint32_t rx_status;
250 uint32_t rx_len;
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
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}
struct ath5k_hw_rx_error rx_err
Definition desc.h:3
#define EINVAL
Invalid argument.
Definition errno.h:429
#define er32(reg)
Definition igbvf.h:373
#define E1000_RXDEXT_ERR_FRAME_ERR_MASK
#define iob_put(iobuf, len)
Definition iobuf.h:125
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition netdevice.c:587

References DBG, DBG2, DBGP, E1000_RXD_STAT_DD, E1000_RXDEXT_ERR_FRAME_ERR_MASK, EINVAL, er32, igbvf_adapter::hw, iob_put, e1000_adv_rx_desc::length, memset(), netdev, netdev_rx(), netdev_rx_err(), NULL, NUM_RX_DESC, igbvf_adapter::rx_base, igbvf_adapter::rx_curr, rx_err, igbvf_adapter::rx_iobuf, e1000_adv_rx_desc::status_error, e1000_adv_rx_desc::upper, and e1000_adv_rx_desc::wb.

Referenced by igbvf_poll().

◆ igbvf_poll()

void igbvf_poll ( struct net_device * netdev)
static

igbvf_poll - Poll for received packets

Parameters
netdevNetwork device

Definition at line 307 of file igbvf_main.c.

308{
309 struct igbvf_adapter *adapter = netdev->priv;
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
323
325
326 igbvf_refill_rx_ring ( adapter );
327}
static void igbvf_process_rx_packets(struct net_device *netdev)
igbvf_process_rx_packets - process received packets
Definition igbvf_main.c:244
static int igbvf_refill_rx_ring(struct igbvf_adapter *adapter)
igbvf_refill_rx_ring - allocate Rx io_buffers
Definition igbvf_main.c:110
static void igbvf_process_tx_packets(struct net_device *netdev)
igbvf_process_tx_packets - process transmitted packets
Definition igbvf_main.c:198

References DBGP, E1000_RXD_STAT_DD, igbvf_process_rx_packets(), igbvf_process_tx_packets(), igbvf_refill_rx_ring(), netdev, igbvf_adapter::rx_base, igbvf_adapter::rx_curr, e1000_adv_rx_desc::status_error, e1000_adv_rx_desc::upper, and e1000_adv_rx_desc::wb.

◆ igbvf_config_collision_dist()

void igbvf_config_collision_dist ( struct e1000_hw * hw)

igbvf_config_collision_dist_generic - Configure collision distance @hw: pointer to the HW structure

Configures the collision distance to the default value and is used during link setup. Currently no func pointer exists and all implementations are handled in the generic version of this function.

Definition at line 337 of file igbvf_main.c.

338{
339 u32 tctl;
340
341 DBG ("igbvf_config_collision_dist");
342
343 tctl = er32 (TCTL);
344
345 tctl &= ~E1000_TCTL_COLD;
347
348 ew32 (TCTL, tctl);
349 e1e_flush();
350}
#define e1e_flush()
Definition igbvf.h:375
#define E1000_TCTL_COLD
#define E1000_COLD_SHIFT
#define E1000_COLLISION_DISTANCE
#define u32
Definition vga.h:21

References DBG, E1000_COLD_SHIFT, E1000_COLLISION_DISTANCE, E1000_TCTL_COLD, e1e_flush, er32, ew32, and u32.

Referenced by igbvf_configure_tx().

◆ igbvf_configure_tx()

void igbvf_configure_tx ( struct igbvf_adapter * adapter)
static

igbvf_configure_tx - Configure Transmit Unit after Reset @adapter: board private structure

Configure the Tx unit of the MAC after a reset.

Definition at line 358 of file igbvf_main.c.

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));
388 ew32 ( TXDCTL(0), txdctl );
389
390 txdctl = er32 ( TXDCTL(0) );
392 ew32 ( TXDCTL(0), txdctl );
393
394 /* Setup Transmit Descriptor Settings for eop descriptor */
396
397 /* Advanced descriptor */
399
400 /* (not part of cmd, but in same 32 bit word...) */
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;
410
412
413 /* Enable transmits */
414 tctl |= E1000_TCTL_EN;
415 ew32(TCTL, tctl);
416 e1e_flush();
417}
#define E1000_COLLISION_THRESHOLD
#define E1000_TCTL_RTLC
#define E1000_TCTL_PSP
#define E1000_TCTL_CT
#define E1000_CT_SHIFT
#define E1000_TCTL_EN
void igbvf_config_collision_dist(struct e1000_hw *hw)
igbvf_config_collision_dist_generic - Configure collision distance @hw: pointer to the HW structure
Definition igbvf_main.c:337
#define E1000_ADVTXD_DCMD_EOP
Definition igbvf_vf.h:145
#define E1000_ADVTXD_DCMD_DEXT
Definition igbvf_vf.h:148
#define E1000_TXDCTL_QUEUE_ENABLE
Definition igbvf_vf.h:62
#define E1000_ADVTXD_DCMD_IFCS
Definition igbvf_vf.h:146
#define E1000_ADVTXD_DCMD_RS
Definition igbvf_vf.h:147
#define E1000_ADVTXD_DTYP_DATA
Definition igbvf_vf.h:144
uint32_t txd_cmd
Definition igbvf.h:303
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79

References DBG, E1000_ADVTXD_DCMD_DEXT, E1000_ADVTXD_DCMD_EOP, E1000_ADVTXD_DCMD_IFCS, E1000_ADVTXD_DCMD_RS, E1000_ADVTXD_DTYP_DATA, E1000_COLLISION_THRESHOLD, E1000_CT_SHIFT, E1000_TCTL_CT, E1000_TCTL_EN, E1000_TCTL_PSP, E1000_TCTL_RTLC, E1000_TXDCTL_QUEUE_ENABLE, e1e_flush, er32, ew32, igbvf_adapter::hw, igbvf_config_collision_dist(), mdelay(), igbvf_adapter::tx_base, igbvf_adapter::tx_fill_ctr, igbvf_adapter::tx_head, igbvf_adapter::tx_ring_size, igbvf_adapter::tx_tail, igbvf_adapter::txd_cmd, u32, and virt_to_bus().

Referenced by igbvf_open().

◆ igbvf_reset()

void igbvf_reset ( struct igbvf_adapter * adapter)

Definition at line 426 of file igbvf_main.c.

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}
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition ethernet.h:78
#define ETH_ALEN
Definition if_ether.h:9
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct e1000_mac_info mac
Definition igbvf_vf.h:317
struct net_device * netdev
Definition igbvf.h:268
A network device.
Definition netdevice.h:353

References e1000_mac_info::addr, DBG, ETH_ALEN, igbvf_adapter::hw, is_valid_ether_addr(), e1000_hw::mac, mac, memcpy(), igbvf_adapter::netdev, and netdev.

Referenced by igbvf_close(), igbvf_open(), igbvf_probe(), and igbvf_remove().

◆ igbvf_init_function_pointers_vf()

void igbvf_init_function_pointers_vf ( struct e1000_hw * hw)
extern

igbvf_init_function_pointers_vf - Inits function pointers @hw: pointer to the HW structure

Definition at line 83 of file igbvf_vf.c.

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}
s32 igbvf_init_mbx_params_vf(struct e1000_hw *hw)
igbvf_init_mbx_params_vf - set initial values for vf mailbox @hw: pointer to the HW structure
Definition igbvf_mbx.c:377
#define DEBUGFUNC(F)
Definition igbvf_osdep.h:68
static s32 igbvf_init_mac_params_vf(struct e1000_hw *hw)
igbvf_init_mac_params_vf - Inits MAC params @hw: pointer to the HW structure
Definition igbvf_vf.c:48

References DEBUGFUNC, igbvf_init_mac_params_vf(), and igbvf_init_mbx_params_vf().

Referenced by igbvf_sw_init().

◆ igbvf_sw_init()

int __devinit igbvf_sw_init ( struct igbvf_adapter * adapter)
static

igbvf_sw_init - Initialize general software structures (struct igbvf_adapter) @adapter: board private structure to initialize

igbvf_sw_init initializes the Adapter private data structure. Fields are initialized based on PCI device information and OS network device settings (MTU size).

Definition at line 453 of file igbvf_main.c.

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, &hw->revision_id );
465
466 pci_read_config_word ( pdev, PCI_COMMAND, &hw->bus.pci_cmd_word );
467
470
471 /* Set various function pointers */
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}
#define ETH_FCS_LEN
Definition atl1e.h:45
#define ETH_ZLEN
Definition if_ether.h:11
#define ETH_HLEN
Definition if_ether.h:10
void igbvf_init_function_pointers_vf(struct e1000_hw *hw)
igbvf_init_function_pointers_vf - Inits function pointers @hw: pointer to the HW structure
Definition igbvf_vf.c:83
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
#define PCI_REVISION
PCI revision.
Definition pci.h:45
#define PCI_COMMAND
PCI command.
Definition pci.h:26
struct e1000_mbx_info mbx
Definition igbvf_vf.h:319
struct e1000_mac_operations ops
Definition igbvf_vf.h:225
s32(* init_params)(struct e1000_hw *)
Definition igbvf_vf.h:209
struct e1000_mbx_operations ops
Definition igbvf_vf.h:298
s32(* init_params)(struct e1000_hw *hw)
Definition igbvf_vf.h:278
u32 max_frame_size
Definition igbvf.h:276
u32 min_frame_size
Definition igbvf.h:275
struct pci_device * pdev
Definition igbvf.h:269
A PCI device.
Definition pci.h:211
uint16_t vendor
Vendor ID.
Definition pci.h:228
uint16_t device
Device ID.
Definition pci.h:230

References __devinit, DBG, pci_device::device, ETH_FCS_LEN, ETH_HLEN, ETH_ZLEN, igbvf_adapter::hw, igbvf_init_function_pointers_vf(), igbvf_irq_disable(), e1000_mac_operations::init_params, e1000_mbx_operations::init_params, e1000_hw::mac, igbvf_adapter::max_frame_size, MAXIMUM_ETHERNET_VLAN_SIZE, e1000_hw::mbx, igbvf_adapter::min_frame_size, e1000_mac_info::ops, e1000_mbx_info::ops, PCI_COMMAND, pci_read_config_byte(), pci_read_config_word(), PCI_REVISION, igbvf_adapter::pdev, rc, and pci_device::vendor.

Referenced by igbvf_probe().

◆ igbvf_setup_srrctl()

void igbvf_setup_srrctl ( struct igbvf_adapter * adapter)
static

igbvf_setup_srrctl - configure the receive control registers @adapter: Board private structure

Definition at line 496 of file igbvf_main.c.

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 |
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;
513
514 ew32 ( SRRCTL(0), srrctl );
515}
#define E1000_SRRCTL_DROP_EN
Definition igbvf_vf.h:76
#define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF
Definition igbvf_vf.h:70
#define E1000_SRRCTL_BSIZEPKT_MASK
Definition igbvf_vf.h:78
#define E1000_SRRCTL_BSIZEPKT_SHIFT
Definition igbvf_vf.h:66
#define E1000_SRRCTL_BSIZEHDR_MASK
Definition igbvf_vf.h:79
#define E1000_SRRCTL_DESCTYPE_MASK
Definition igbvf_vf.h:75

References DBG, E1000_SRRCTL_BSIZEHDR_MASK, E1000_SRRCTL_BSIZEPKT_MASK, E1000_SRRCTL_BSIZEPKT_SHIFT, E1000_SRRCTL_DESCTYPE_ADV_ONEBUF, E1000_SRRCTL_DESCTYPE_MASK, E1000_SRRCTL_DROP_EN, ew32, igbvf_adapter::hw, and u32.

Referenced by igbvf_open().

◆ igbvf_configure_rx()

void igbvf_configure_rx ( struct igbvf_adapter * adapter)
static

igbvf_configure_rx - Configure 8254x Receive Unit after Reset @adapter: board private structure

Configure the Rx unit of the MAC after a reset.

Definition at line 523 of file igbvf_main.c.

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
547 rxdctl &= 0xFFF00000;
548 rxdctl |= IGBVF_RX_PTHRESH;
549 rxdctl |= IGBVF_RX_HTHRESH << 8;
550 rxdctl |= IGBVF_RX_WTHRESH << 16;
551
553
554 /* enable receives */
555 ew32 ( RXDCTL(0), rxdctl );
556 ew32 ( RDT(0), NUM_RX_DESC );
557}
#define IGBVF_RX_HTHRESH
Definition igbvf.h:69
#define IGBVF_RX_WTHRESH
Definition igbvf.h:70
#define IGBVF_RX_PTHRESH
Definition igbvf.h:68
#define msleep(x)
Definition igbvf_osdep.h:50
void igbvf_rlpml_set_vf(struct e1000_hw *hw, u16 max_size)
igbvf_rlpml_set_vf - Set the maximum receive packet length @hw: pointer to the HW structure @max_size...
Definition igbvf_vf.c:331
#define E1000_RXDCTL_QUEUE_ENABLE
Definition igbvf_vf.h:63

References DBG, E1000_RXDCTL_QUEUE_ENABLE, er32, ew32, igbvf_adapter::hw, igbvf_rlpml_set_vf(), IGBVF_RX_HTHRESH, IGBVF_RX_PTHRESH, IGBVF_RX_WTHRESH, igbvf_adapter::max_frame_size, msleep, NUM_RX_DESC, igbvf_adapter::rx_base, igbvf_adapter::rx_curr, igbvf_adapter::rx_ring_size, u32, and virt_to_bus().

Referenced by igbvf_open().

◆ igbvf_setup_rx_resources()

int igbvf_setup_rx_resources ( struct igbvf_adapter * adapter)

igbvf_setup_rx_resources - allocate Rx resources (Descriptors)

Parameters
adaptere1000 private structure

Definition at line 564 of file igbvf_main.c.

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_phys ( 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;
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}

References alloc_iob(), io_buffer::data, DBG, ENOMEM, e1000_adv_rx_desc::hdr_addr, malloc_phys(), MAXIMUM_ETHERNET_VLAN_SIZE, memset(), NUM_RX_DESC, e1000_adv_rx_desc::pkt_addr, e1000_adv_rx_desc::read, igbvf_adapter::rx_base, igbvf_adapter::rx_iobuf, igbvf_adapter::rx_ring_size, e1000_adv_rx_desc::status_error, e1000_adv_rx_desc::upper, virt_to_bus(), and e1000_adv_rx_desc::wb.

Referenced by igbvf_open().

◆ igbvf_open()

int igbvf_open ( struct net_device * netdev)
static

igbvf_open - Called when a network interface is made active @netdev: network interface device structure

Returns 0 on success, negative value on failure

The open entry point is called when a network interface is made active by the system (IFF_UP). At this point all resources needed for transmit and receive operations are allocated, the interrupt handler is registered with the OS, the watchdog timer is started, and the stack is notified that the interface is ready.

Definition at line 613 of file igbvf_main.c.

614{
615 struct igbvf_adapter *adapter = netdev->priv;
616 int err;
617
618 DBG ("igbvf_open\n");
619
620 /* Update MAC address */
621 memcpy ( adapter->hw.mac.addr, netdev->ll_addr, ETH_ALEN );
622 igbvf_reset( adapter );
623
624 /* allocate transmit descriptors */
625 err = igbvf_setup_tx_resources ( adapter );
626 if (err) {
627 DBG ( "Error setting up TX resources!\n" );
628 goto err_setup_tx;
629 }
630
631 igbvf_configure_tx ( adapter );
632
633 igbvf_setup_srrctl( adapter );
634
635 err = igbvf_setup_rx_resources( adapter );
636 if (err) {
637 DBG ( "Error setting up RX resources!\n" );
638 goto err_setup_rx;
639 }
640
641 igbvf_configure_rx ( adapter );
642
643 return 0;
644
645err_setup_rx:
646 DBG ( "err_setup_rx\n" );
647 igbvf_free_tx_resources ( adapter );
648 return err;
649
650err_setup_tx:
651 DBG ( "err_setup_tx\n" );
652 igbvf_reset ( adapter );
653
654 return err;
655}
int igbvf_setup_rx_resources(struct igbvf_adapter *adapter)
igbvf_setup_rx_resources - allocate Rx resources (Descriptors)
Definition igbvf_main.c:564
static void igbvf_configure_tx(struct igbvf_adapter *adapter)
igbvf_configure_tx - Configure Transmit Unit after Reset @adapter: board private structure
Definition igbvf_main.c:358
static void igbvf_configure_rx(struct igbvf_adapter *adapter)
igbvf_configure_rx - Configure 8254x Receive Unit after Reset @adapter: board private structure
Definition igbvf_main.c:523
void igbvf_free_tx_resources(struct igbvf_adapter *adapter)
igbvf_free_tx_resources - Free Tx Resources per Queue @adapter: board private structure
Definition igbvf_main.c:77
int igbvf_setup_tx_resources(struct igbvf_adapter *adapter)
igbvf_setup_tx_resources - allocate Tx resources (Descriptors)
Definition igbvf_main.c:43
void igbvf_reset(struct igbvf_adapter *adapter)
Definition igbvf_main.c:426
static void igbvf_setup_srrctl(struct igbvf_adapter *adapter)
igbvf_setup_srrctl - configure the receive control registers @adapter: Board private structure
Definition igbvf_main.c:496

References e1000_mac_info::addr, DBG, ETH_ALEN, igbvf_adapter::hw, igbvf_configure_rx(), igbvf_configure_tx(), igbvf_free_tx_resources(), igbvf_reset(), igbvf_setup_rx_resources(), igbvf_setup_srrctl(), igbvf_setup_tx_resources(), e1000_hw::mac, memcpy(), and netdev.

◆ igbvf_close()

void igbvf_close ( struct net_device * netdev)
static

igbvf_close - Disables a network interface @netdev: network interface device structure

Returns 0, this is not allowed to fail

The close entry point is called when an interface is de-activated by the OS. The hardware is still under the drivers control, but needs to be disabled. A global MAC reset is issued to stop the hardware, and all transmit and receive resources are freed.

Definition at line 668 of file igbvf_main.c.

669{
670 struct igbvf_adapter *adapter = netdev->priv;
671 struct e1000_hw *hw = &adapter->hw;
672 uint32_t rxdctl;
673
674 DBG ( "igbvf_close\n" );
675
676 /* Disable and acknowledge interrupts */
677 igbvf_irq_disable ( adapter );
678 er32(EICR);
679
680 /* disable receives */
681 rxdctl = er32 ( RXDCTL(0) );
682 ew32 ( RXDCTL(0), rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE );
683 mdelay ( 10 );
684
685 igbvf_reset ( adapter );
686
687 igbvf_free_tx_resources( adapter );
688 igbvf_free_rx_resources( adapter );
689}
void igbvf_free_rx_resources(struct igbvf_adapter *adapter)
igbvf_free_rx_resources - Free Rx Resources @adapter: board private structure
Definition igbvf_main.c:90

References DBG, E1000_RXDCTL_QUEUE_ENABLE, er32, ew32, igbvf_adapter::hw, igbvf_free_rx_resources(), igbvf_free_tx_resources(), igbvf_irq_disable(), igbvf_reset(), mdelay(), and netdev.

◆ igbvf_transmit()

int igbvf_transmit ( struct net_device * netdev,
struct io_buffer * iobuf )
static

igbvf_transmit - Transmit a packet

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturns 0 on success, negative on failure

Definition at line 699 of file igbvf_main.c.

700{
701 struct igbvf_adapter *adapter = netdev->priv;
702 struct e1000_hw *hw = &adapter->hw;
703 uint32_t tx_curr = adapter->tx_tail;
704 union e1000_adv_tx_desc *tx_curr_desc;
705
706 DBGP ("igbvf_transmit\n");
707
708 if ( adapter->tx_fill_ctr == NUM_TX_DESC ) {
709 DBG ("TX overflow\n");
710 return -ENOBUFS;
711 }
712
713 /* Save pointer to iobuf we have been given to transmit,
714 netdev_tx_complete() will need it later
715 */
716 adapter->tx_iobuf[tx_curr] = iobuf;
717
718 tx_curr_desc = ( void * ) ( adapter->tx_base ) +
719 ( tx_curr * sizeof ( *adapter->tx_base ) );
720
721 DBG ( "tx_curr_desc = %#08lx\n", virt_to_bus ( tx_curr_desc ) );
722 DBG ( "tx_curr_desc + 16 = %#08lx\n", virt_to_bus ( tx_curr_desc ) + 16 );
723 DBG ( "iobuf->data = %#08lx\n", virt_to_bus ( iobuf->data ) );
724
725 /* Add the packet to TX ring
726 */
727 tx_curr_desc->read.buffer_addr = virt_to_bus ( iobuf->data );
728 tx_curr_desc->read.cmd_type_len = adapter->txd_cmd |(iob_len ( iobuf )) ;
729 // minus hdr_len ????
730 tx_curr_desc->read.olinfo_status = ((iob_len ( iobuf )) << E1000_ADVTXD_PAYLEN_SHIFT);
731
732 DBG ( "TX fill: %d tx_curr: %d addr: %#08lx len: %zd\n", adapter->tx_fill_ctr,
733 tx_curr, virt_to_bus ( iobuf->data ), iob_len ( iobuf ) );
734
735 /* Point to next free descriptor */
736 adapter->tx_tail = ( adapter->tx_tail + 1 ) % NUM_TX_DESC;
737 adapter->tx_fill_ctr++;
738
739 /* Write new tail to NIC, making packet available for transmit
740 */
741 ew32 ( TDT(0), adapter->tx_tail );
742 e1e_flush ();
743
744 return 0;
745}
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define E1000_ADVTXD_PAYLEN_SHIFT
Definition igbvf_vf.h:151
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
struct e1000_adv_tx_desc::@306366227022350030362102361364010267201304327377 read

References e1000_adv_tx_desc::buffer_addr, e1000_adv_tx_desc::cmd_type_len, io_buffer::data, DBG, DBGP, E1000_ADVTXD_PAYLEN_SHIFT, e1e_flush, ENOBUFS, ew32, igbvf_adapter::hw, iob_len(), netdev, NUM_TX_DESC, e1000_adv_tx_desc::olinfo_status, e1000_adv_tx_desc::read, igbvf_adapter::tx_base, igbvf_adapter::tx_fill_ctr, igbvf_adapter::tx_iobuf, igbvf_adapter::tx_tail, igbvf_adapter::txd_cmd, and virt_to_bus().

◆ igbvf_get_hw_control()

void igbvf_get_hw_control ( struct igbvf_adapter * adapter)

igbvf_get_hw_control - get control of the h/w from f/w @adapter: address of board private structure

igb_get_hw_control sets CTRL_EXT:DRV_LOAD bit. For ASF and Pass Through versions of f/w this means that the driver is loaded.

Definition at line 765 of file igbvf_main.c.

766{
767 struct e1000_hw *hw = &adapter->hw;
768 u32 ctrl_ext;
769
770 /* Let firmware know the driver has taken over */
771 ctrl_ext = er32 ( CTRL_EXT );
772 ew32 ( CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD );
773}
#define E1000_CTRL_EXT_DRV_LOAD

References E1000_CTRL_EXT_DRV_LOAD, er32, ew32, igbvf_adapter::hw, and u32.

Referenced by igbvf_probe().

◆ igbvf_probe()

int igbvf_probe ( struct pci_device * pdev)

igbvf_probe - Device Initialization Routine @pdev: PCI device information struct @ent: entry in igbvf_pci_tbl

Returns 0 on success, negative on failure

igbvf_probe initializes an adapter identified by a pci_dev structure. The OS initialization, configuring of the adapter private structure, and a hardware reset occur.

Definition at line 786 of file igbvf_main.c.

787{
788 int err;
789 struct net_device *netdev;
790 struct igbvf_adapter *adapter;
791 unsigned long mmio_start, mmio_len;
792 struct e1000_hw *hw;
793
794 DBG ( "igbvf_probe\n" );
795
796 err = -ENOMEM;
797
798 /* Allocate net device ( also allocates memory for netdev->priv
799 and makes netdev-priv point to it ) */
800 netdev = alloc_etherdev ( sizeof ( struct igbvf_adapter ) );
801 if ( ! netdev )
802 goto err_alloc_etherdev;
803
804 /* Associate igbvf-specific network operations operations with
805 * generic network device layer */
807
808 /* Associate this network device with given PCI device */
809 pci_set_drvdata ( pdev, netdev );
810 netdev->dev = &pdev->dev;
811
812 /* Initialize driver private storage */
813 adapter = netdev->priv;
814 memset ( adapter, 0, ( sizeof ( *adapter ) ) );
815
816 adapter->pdev = pdev;
817
818 adapter->ioaddr = pdev->ioaddr;
819 adapter->hw.io_base = pdev->ioaddr;
820
821 hw = &adapter->hw;
822 hw->vendor_id = pdev->vendor;
823 hw->device_id = pdev->device;
824
825 adapter->irqno = pdev->irq;
826 adapter->netdev = netdev;
827 adapter->hw.back = adapter;
828
831
832 adapter->tx_ring_size = sizeof ( *adapter->tx_base ) * NUM_TX_DESC;
833 adapter->rx_ring_size = sizeof ( *adapter->rx_base ) * NUM_RX_DESC;
834
835 /* Fix up PCI device */
836 adjust_pci_device ( pdev );
837
838 err = -EIO;
839
840 mmio_start = pci_bar_start ( pdev, PCI_BASE_ADDRESS_0 );
841 mmio_len = pci_bar_size ( pdev, PCI_BASE_ADDRESS_0 );
842
843 DBG ( "mmio_start: %#08lx\n", mmio_start );
844 DBG ( "mmio_len: %#08lx\n", mmio_len );
845
846 adapter->hw.hw_addr = pci_ioremap ( pdev, mmio_start, mmio_len );
847 DBG ( "adapter->hw.hw_addr: %p\n", adapter->hw.hw_addr );
848
849 if ( ! adapter->hw.hw_addr ) {
850 DBG ( "err_ioremap\n" );
851 goto err_ioremap;
852 }
853
854 /* setup adapter struct */
855 err = igbvf_sw_init ( adapter );
856 if (err) {
857 DBG ( "err_sw_init\n" );
858 goto err_sw_init;
859 }
860
861 /* reset the controller to put the device in a known good state */
862 err = hw->mac.ops.reset_hw ( hw );
863 if ( err ) {
864 DBG ("PF still in reset state, assigning new address\n");
865 netdev->hw_addr[0] = 0x21;
866 netdev->hw_addr[1] = 0x21;
867 netdev->hw_addr[2] = 0x21;
868 netdev->hw_addr[3] = 0x21;
869 netdev->hw_addr[4] = 0x21;
870 netdev->hw_addr[5] = 0x21;
871 netdev->hw_addr[6] = 0x21;
872 } else {
873 err = hw->mac.ops.read_mac_addr(hw);
874 if (err) {
875 DBG ("Error reading MAC address\n");
876 goto err_hw_init;
877 }
878 if ( ! is_valid_ether_addr(adapter->hw.mac.addr) ) {
879 /* Assign random MAC address */
880 eth_random_addr(adapter->hw.mac.addr);
881 }
882 }
883
884 memcpy ( netdev->hw_addr, adapter->hw.mac.addr, ETH_ALEN );
885
886 /* reset the hardware with the new settings */
887 igbvf_reset ( adapter );
888
889 /* let the f/w know that the h/w is now under the control of the
890 * driver. */
891 igbvf_get_hw_control ( adapter );
892
893 /* Mark as link up; we don't yet handle link state */
895
896 if ( ( err = register_netdev ( netdev ) ) != 0) {
897 DBG ( "err_register\n" );
898 goto err_register;
899 }
900
901 DBG ("igbvf_probe_succeeded\n");
902
903 return 0;
904
905err_register:
906err_hw_init:
907err_sw_init:
908 iounmap ( adapter->hw.hw_addr );
909err_ioremap:
910 netdev_put ( netdev );
911err_alloc_etherdev:
912 return err;
913}
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
void eth_random_addr(void *hw_addr)
Generate random Ethernet address.
Definition ethernet.c:160
#define EIO
Input/output error.
Definition errno.h:434
#define ETH_FRAME_LEN
Definition if_ether.h:12
static struct net_device_operations igbvf_operations
igbvf net device operations
Definition igbvf_main.c:748
void igbvf_get_hw_control(struct igbvf_adapter *adapter)
igbvf_get_hw_control - get control of the h/w from f/w @adapter: address of board private structure
Definition igbvf_main.c:765
static int __devinit igbvf_sw_init(struct igbvf_adapter *adapter)
igbvf_sw_init - Initialize general software structures (struct igbvf_adapter) @adapter: board private...
Definition igbvf_main.c:453
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:789
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:519
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Get the size of a PCI BAR.
Definition pci.c:164
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition pci.c:97
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
#define PCI_BASE_ADDRESS_0
Definition pci.h:63
void * back
Definition igbvf_vf.h:311
u8 __iomem * hw_addr
Definition igbvf_vf.h:313
unsigned long io_base
Definition igbvf_vf.h:315
u32 max_hw_frame_size
Definition igbvf.h:278
uint32_t irqno
Definition igbvf.h:299
uint32_t ioaddr
Definition igbvf.h:298
unsigned long ioaddr
I/O address.
Definition pci.h:226
uint8_t irq
Interrupt number.
Definition pci.h:234
struct device dev
Generic device.
Definition pci.h:213

References e1000_mac_info::addr, adjust_pci_device(), alloc_etherdev(), e1000_hw::back, DBG, pci_device::dev, pci_device::device, EIO, ENOMEM, ETH_ALEN, ETH_FCS_LEN, ETH_FRAME_LEN, eth_random_addr(), ETH_ZLEN, igbvf_adapter::hw, e1000_hw::hw_addr, igbvf_get_hw_control(), igbvf_operations, igbvf_reset(), igbvf_sw_init(), e1000_hw::io_base, igbvf_adapter::ioaddr, pci_device::ioaddr, iounmap(), pci_device::irq, igbvf_adapter::irqno, is_valid_ether_addr(), e1000_hw::mac, igbvf_adapter::max_hw_frame_size, memcpy(), memset(), igbvf_adapter::min_frame_size, igbvf_adapter::netdev, netdev, netdev_init(), netdev_link_up(), netdev_put(), NUM_RX_DESC, NUM_TX_DESC, pci_bar_size(), pci_bar_start(), PCI_BASE_ADDRESS_0, pci_ioremap(), pci_set_drvdata(), igbvf_adapter::pdev, register_netdev(), igbvf_adapter::rx_base, igbvf_adapter::rx_ring_size, igbvf_adapter::tx_base, igbvf_adapter::tx_ring_size, and pci_device::vendor.

◆ igbvf_remove()

void igbvf_remove ( struct pci_device * pdev)

igbvf_remove - Device Removal Routine @pdev: PCI device information struct

igbvf_remove is called by the PCI subsystem to alert the driver that it should release a PCI device. The could be caused by a Hot-Plug event, or because the driver is going to be removed from memory.

Definition at line 924 of file igbvf_main.c.

925{
926 struct net_device *netdev = pci_get_drvdata ( pdev );
927 struct igbvf_adapter *adapter = netdev->priv;
928
929 DBG ( "igbvf_remove\n" );
930
931 if ( adapter->hw.flash_address )
932 iounmap ( adapter->hw.flash_address );
933 if ( adapter->hw.hw_addr )
934 iounmap ( adapter->hw.hw_addr );
935
937 igbvf_reset ( adapter );
939 netdev_put ( netdev );
940}
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376
u8 __iomem * flash_address
Definition igbvf_vf.h:314

References DBG, e1000_hw::flash_address, igbvf_adapter::hw, e1000_hw::hw_addr, igbvf_reset(), iounmap(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), and unregister_netdev().

Variable Documentation

◆ igbvf_operations

struct net_device_operations igbvf_operations
static
Initial value:
= {
.open = igbvf_open,
.close = igbvf_close,
.transmit = igbvf_transmit,
.poll = igbvf_poll,
.irq = igbvf_irq,
}
static int igbvf_open(struct net_device *netdev)
igbvf_open - Called when a network interface is made active @netdev: network interface device structu...
Definition igbvf_main.c:613
static void igbvf_irq(struct net_device *netdev, int enable)
igbvf_irq - enable or Disable interrupts
Definition igbvf_main.c:180
static int igbvf_transmit(struct net_device *netdev, struct io_buffer *iobuf)
igbvf_transmit - Transmit a packet
Definition igbvf_main.c:699
static void igbvf_close(struct net_device *netdev)
igbvf_close - Disables a network interface @netdev: network interface device structure
Definition igbvf_main.c:668
static void igbvf_poll(struct net_device *netdev)
igbvf_poll - Poll for received packets
Definition igbvf_main.c:307

igbvf net device operations

Definition at line 748 of file igbvf_main.c.

748 {
749 .open = igbvf_open,
750 .close = igbvf_close,
751 .transmit = igbvf_transmit,
752 .poll = igbvf_poll,
753 .irq = igbvf_irq,
754};

Referenced by igbvf_probe().

◆ igbvf_pci_tbl

struct pci_device_id igbvf_pci_tbl[]
static
Initial value:
= {
PCI_ROM(0x8086, 0x10CA, "igbvf", "E1000_DEV_ID_82576_VF", 0),
PCI_ROM(0x8086, 0x1520, "i350vf", "E1000_DEV_ID_I350_VF", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308

Definition at line 942 of file igbvf_main.c.

942 {
943 PCI_ROM(0x8086, 0x10CA, "igbvf", "E1000_DEV_ID_82576_VF", 0),
944 PCI_ROM(0x8086, 0x1520, "i350vf", "E1000_DEV_ID_I350_VF", 0),
945};

◆ __pci_driver

struct pci_driver igbvf_driver __pci_driver
Initial value:
= {
.ids = igbvf_pci_tbl,
.id_count = (sizeof(igbvf_pci_tbl) / sizeof(igbvf_pci_tbl[0])),
.probe = igbvf_probe,
}
void igbvf_remove(struct pci_device *pdev)
igbvf_remove - Device Removal Routine @pdev: PCI device information struct
Definition igbvf_main.c:924
static struct pci_device_id igbvf_pci_tbl[]
Definition igbvf_main.c:942
int igbvf_probe(struct pci_device *pdev)
igbvf_probe - Device Initialization Routine @pdev: PCI device information struct @ent: entry in igbvf...
Definition igbvf_main.c:786
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40

Definition at line 948 of file igbvf_main.c.

948 {
949 .ids = igbvf_pci_tbl,
950 .id_count = (sizeof(igbvf_pci_tbl) / sizeof(igbvf_pci_tbl[0])),
951 .probe = igbvf_probe,
953};