iPXE
Functions | Variables
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 : board private structure
void igbvf_free_rx_resources (struct igbvf_adapter *adapter)
 igbvf_free_rx_resources - Free Rx Resources : 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 : board private structure
static void igbvf_irq_enable (struct igbvf_adapter *adapter)
 igbvf_irq_enable - Enable default interrupt generation settings : 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 : pointer to the HW structure
static void igbvf_configure_tx (struct igbvf_adapter *adapter)
 igbvf_configure_tx - Configure Transmit Unit after Reset : 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 : 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) : board private structure to initialize
static void igbvf_setup_srrctl (struct igbvf_adapter *adapter)
 igbvf_setup_srrctl - configure the receive control registers : Board private structure
static void igbvf_configure_rx (struct igbvf_adapter *adapter)
 igbvf_configure_rx - Configure 8254x Receive Unit after Reset : 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 : network interface device structure
static void igbvf_close (struct net_device *netdev)
 igbvf_close - Disables a network interface : 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 : address of board private structure
int igbvf_probe (struct pci_device *pdev)
 igbvf_probe - Device Initialization Routine : PCI device information struct : entry in igbvf_pci_tbl
void igbvf_remove (struct pci_device *pdev)
 igbvf_remove - Device Removal Routine : 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 ( GPL2_ONLY  )
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.

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

Referenced by igbvf_open().

{
        DBG ( "igbvf_setup_tx_resources\n" );

        /* Allocate transmit descriptor ring memory.
           It must not cross a 64K boundary because of hardware errata #23
           so we use malloc_dma() requesting a 128 byte block that is
           128 byte aligned. This should guarantee that the memory
           allocated will not cross a 64K boundary, because 128 is an
           even multiple of 65536 ( 65536 / 128 == 512 ), so all possible
           allocations of 128 bytes on a 128 byte boundary will not
           cross 64K bytes.
         */

        adapter->tx_base =
                malloc_dma ( adapter->tx_ring_size, adapter->tx_ring_size );

        if ( ! adapter->tx_base ) {
                return -ENOMEM;
        }

        memset ( adapter->tx_base, 0, adapter->tx_ring_size );

        DBG ( "adapter->tx_base = %#08lx\n", virt_to_bus ( adapter->tx_base ) );

        return 0;
}
void igbvf_free_tx_resources ( struct igbvf_adapter adapter)

igbvf_free_tx_resources - Free Tx Resources per Queue : board private structure

Free all transmit software resources

Definition at line 77 of file igbvf_main.c.

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

Referenced by igbvf_close(), and igbvf_open().

{
        DBG ( "igbvf_free_tx_resources\n" );

        free_dma ( adapter->tx_base, adapter->tx_ring_size );
}
void igbvf_free_rx_resources ( struct igbvf_adapter adapter)

igbvf_free_rx_resources - Free Rx Resources : board private structure

Free all receive software resources

Definition at line 90 of file igbvf_main.c.

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

Referenced by igbvf_close().

{
        int i;

        DBG ( "igbvf_free_rx_resources\n" );

        free_dma ( adapter->rx_base, adapter->rx_ring_size );

        for ( i = 0; i < NUM_RX_DESC; i++ ) {
                free_iob ( adapter->rx_iobuf[i] );
        }
}
static 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.

References alloc_iob(), io_buffer::data, DBG, DBG2, DBGP, ENOMEM, ew32, igbvf_adapter::hw, MAXIMUM_ETHERNET_VLAN_SIZE, NULL, NUM_RX_DESC, rc, igbvf_adapter::rx_base, igbvf_adapter::rx_curr, igbvf_adapter::rx_iobuf, and virt_to_bus().

Referenced by igbvf_poll().

{
        int i, rx_curr;
        int rc = 0;
        union e1000_adv_rx_desc *rx_curr_desc;
        struct e1000_hw *hw = &adapter->hw;
        struct io_buffer *iob;

        DBGP ("igbvf_refill_rx_ring\n");

        for ( i = 0; i < NUM_RX_DESC; i++ ) {
                rx_curr = ( ( adapter->rx_curr + i ) % NUM_RX_DESC );
                rx_curr_desc = adapter->rx_base + rx_curr;

                if ( rx_curr_desc->wb.upper.status_error & E1000_RXD_STAT_DD )
                        continue;

                if ( adapter->rx_iobuf[rx_curr] != NULL )
                        continue;

                DBG2 ( "Refilling rx desc %d\n", rx_curr );

                iob = alloc_iob ( MAXIMUM_ETHERNET_VLAN_SIZE );
                adapter->rx_iobuf[rx_curr] = iob;

                rx_curr_desc->wb.upper.status_error = 0;

                if ( ! iob ) {
                        DBG ( "alloc_iob failed\n" );
                        rc = -ENOMEM;
                        break;
                } else {
                        rx_curr_desc->read.pkt_addr = virt_to_bus ( iob->data );
                        rx_curr_desc->read.hdr_addr = 0;
                        ew32 ( RDT(0), rx_curr );
                }
        }
        return rc;
}
static void igbvf_irq_disable ( struct igbvf_adapter adapter) [static]

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

Definition at line 154 of file igbvf_main.c.

References ew32, and igbvf_adapter::hw.

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

{
        struct e1000_hw *hw = &adapter->hw;

        ew32 ( EIMC, ~0 );
}
static void igbvf_irq_enable ( struct igbvf_adapter adapter) [static]

igbvf_irq_enable - Enable default interrupt generation settings : board private structure

Definition at line 165 of file igbvf_main.c.

References ew32, and igbvf_adapter::hw.

Referenced by igbvf_irq().

{
        struct e1000_hw *hw = &adapter->hw;

        ew32 ( EIAC, IMS_ENABLE_MASK );
        ew32 ( EIAM, IMS_ENABLE_MASK );
        ew32 ( EIMS, IMS_ENABLE_MASK );
}
static 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.

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

{
        struct igbvf_adapter *adapter = netdev_priv ( netdev );

        DBG ( "igbvf_irq\n" );

        if ( enable ) {
                igbvf_irq_enable ( adapter );
        } else {
                igbvf_irq_disable ( adapter );
        }
}
static 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.

References DBG, DBGP, memset(), netdev_priv(), netdev_tx_complete(), NUM_TX_DESC, igbvf_adapter::tx_base, igbvf_adapter::tx_fill_ctr, igbvf_adapter::tx_head, igbvf_adapter::tx_iobuf, igbvf_adapter::tx_tail, and virt_to_bus().

Referenced by igbvf_poll().

{
        struct igbvf_adapter *adapter = netdev_priv ( netdev );
        uint32_t i;
        uint32_t tx_status;
        union e1000_adv_tx_desc *tx_curr_desc;

        /* Check status of transmitted packets
         */
        DBGP ( "process_tx_packets: tx_head = %d, tx_tail = %d\n", adapter->tx_head,
              adapter->tx_tail );

        while ( ( i = adapter->tx_head ) != adapter->tx_tail ) {

                tx_curr_desc = ( void * )  ( adapter->tx_base ) +
                                           ( i * sizeof ( *adapter->tx_base ) );

                tx_status = tx_curr_desc->wb.status;
                DBG ( "  tx_curr_desc = %#08lx\n", virt_to_bus ( tx_curr_desc ) );
                DBG ( "  tx_status = %#08x\n", tx_status );

                /* if the packet at tx_head is not owned by hardware it is for us */
                if ( ! ( tx_status & E1000_TXD_STAT_DD ) )
                        break;

                DBG ( "Sent packet. tx_head: %d tx_tail: %d tx_status: %#08x\n",
                      adapter->tx_head, adapter->tx_tail, tx_status );

                netdev_tx_complete ( netdev, adapter->tx_iobuf[i] );
                DBG ( "Success transmitting packet, tx_status: %#08x\n",
                      tx_status );

                /* Decrement count of used descriptors, clear this descriptor
                 */
                adapter->tx_fill_ctr--;
                memset ( tx_curr_desc, 0, sizeof ( *tx_curr_desc ) );

                adapter->tx_head = ( adapter->tx_head + 1 ) % NUM_TX_DESC;
        }
}
static 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.

References DBG, DBG2, DBGP, EINVAL, er32, igbvf_adapter::hw, iob_put, memset(), netdev_priv(), netdev_rx(), netdev_rx_err(), NULL, NUM_RX_DESC, igbvf_adapter::rx_base, igbvf_adapter::rx_curr, rx_err, and igbvf_adapter::rx_iobuf.

Referenced by igbvf_poll().

{
        struct igbvf_adapter *adapter = netdev_priv ( netdev );
        struct e1000_hw *hw = &adapter->hw;
        uint32_t i;
        uint32_t rx_status;
        uint32_t rx_len;
        uint32_t rx_err;
        union e1000_adv_rx_desc *rx_curr_desc;

        DBGP ( "igbvf_process_rx_packets\n" );

        /* Process received packets
         */
        while ( 1 ) {
                i = adapter->rx_curr;

                rx_curr_desc = ( void * )  ( adapter->rx_base ) +
                                  ( i * sizeof ( *adapter->rx_base ) );
                rx_status = rx_curr_desc->wb.upper.status_error;

                DBG2 ( "Before DD Check RX_status: %#08x, rx_curr: %d\n",
                       rx_status, i );

                if ( ! ( rx_status & E1000_RXD_STAT_DD ) )
                        break;

                if ( adapter->rx_iobuf[i] == NULL )
                        break;

                DBG ( "E1000_RCTL = %#08x\n", er32 (RCTL) );

                rx_len = rx_curr_desc->wb.upper.length;

                DBG ( "Received packet, rx_curr: %d  rx_status: %#08x  rx_len: %d\n",
                      i, rx_status, rx_len );

                rx_err = rx_status;

                iob_put ( adapter->rx_iobuf[i], rx_len );

                if ( rx_err & E1000_RXDEXT_ERR_FRAME_ERR_MASK ) {

                        netdev_rx_err ( netdev, adapter->rx_iobuf[i], -EINVAL );
                        DBG ( "igbvf_process_rx_packets: Corrupted packet received!"
                              " rx_err: %#08x\n", rx_err );
                } else  {
                        /* Add this packet to the receive queue. */
                        netdev_rx ( netdev, adapter->rx_iobuf[i] );
                }
                adapter->rx_iobuf[i] = NULL;

                memset ( rx_curr_desc, 0, sizeof ( *rx_curr_desc ) );

                adapter->rx_curr = ( adapter->rx_curr + 1 ) % NUM_RX_DESC;
        }
}
static 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.

References DBGP, igbvf_process_rx_packets(), igbvf_process_tx_packets(), igbvf_refill_rx_ring(), netdev_priv(), igbvf_adapter::rx_base, and igbvf_adapter::rx_curr.

{
        struct igbvf_adapter *adapter = netdev_priv ( netdev );
        uint32_t rx_status;
        union e1000_adv_rx_desc *rx_curr_desc;

        DBGP ( "igbvf_poll\n" );

        rx_curr_desc = ( void * )  ( adapter->rx_base ) +
                        ( adapter->rx_curr * sizeof ( *adapter->rx_base ) );
        rx_status = rx_curr_desc->wb.upper.status_error;

        if ( ! ( rx_status & E1000_RXD_STAT_DD ) )
                return;

        igbvf_process_tx_packets ( netdev );

        igbvf_process_rx_packets ( netdev );

        igbvf_refill_rx_ring ( adapter );
}
void igbvf_config_collision_dist ( struct e1000_hw *  hw)

igbvf_config_collision_dist_generic - Configure collision distance : 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.

References DBG, e1e_flush, er32, and ew32.

Referenced by igbvf_configure_tx().

{
        u32 tctl;

        DBG ("igbvf_config_collision_dist");

        tctl = er32 (TCTL);

        tctl &= ~E1000_TCTL_COLD;
        tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;

        ew32 (TCTL, tctl);
        e1e_flush();
}
static void igbvf_configure_tx ( struct igbvf_adapter adapter) [static]

igbvf_configure_tx - Configure Transmit Unit after Reset : board private structure

Configure the Tx unit of the MAC after a reset.

Definition at line 358 of file igbvf_main.c.

References DBG, 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, and virt_to_bus().

Referenced by igbvf_open().

{
        struct e1000_hw *hw = &adapter->hw;
        u32 tctl, txdctl;

        DBG ( "igbvf_configure_tx\n" );

        /* disable transmits while setting up the descriptors */
        tctl = er32 ( TCTL );
        ew32 ( TCTL, tctl & ~E1000_TCTL_EN );
        e1e_flush();
        mdelay (10);

        ew32 ( TDBAH(0), 0 );
        ew32 ( TDBAL(0), virt_to_bus ( adapter->tx_base ) );
        ew32 ( TDLEN(0), adapter->tx_ring_size );

        DBG ( "E1000_TDBAL(0): %#08x\n",  er32 ( TDBAL(0) ) );
        DBG ( "E1000_TDLEN(0): %d\n",     er32 ( TDLEN(0) ) );

        /* Setup the HW Tx Head and Tail descriptor pointers */
        ew32 ( TDH(0), 0 );
        ew32 ( TDT(0), 0 );

        adapter->tx_head = 0;
        adapter->tx_tail = 0;
        adapter->tx_fill_ctr = 0;

        txdctl = er32(TXDCTL(0));
        txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
        ew32 ( TXDCTL(0), txdctl );

        txdctl = er32 ( TXDCTL(0) );
        txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
        ew32 ( TXDCTL(0), txdctl );

        /* Setup Transmit Descriptor Settings for eop descriptor */
        adapter->txd_cmd  = E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_IFCS;

        /* Advanced descriptor */
        adapter->txd_cmd |= E1000_ADVTXD_DCMD_DEXT;

        /* (not part of cmd, but in same 32 bit word...) */
        adapter->txd_cmd |= E1000_ADVTXD_DTYP_DATA;

        /* enable Report Status bit */
        adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS;

        /* Program the Transmit Control Register */
        tctl &= ~E1000_TCTL_CT;
        tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
                (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);

        igbvf_config_collision_dist ( hw );

        /* Enable transmits */
        tctl |= E1000_TCTL_EN;
        ew32(TCTL, tctl);
        e1e_flush();
}
void igbvf_reset ( struct igbvf_adapter adapter)

Definition at line 426 of file igbvf_main.c.

References DBG, ETH_ALEN, igbvf_adapter::hw, net_device::hw_addr, is_valid_ether_addr(), mac, memcpy(), netdev, and igbvf_adapter::netdev.

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

{
        struct e1000_mac_info *mac = &adapter->hw.mac;
        struct net_device *netdev = adapter->netdev;
        struct e1000_hw *hw = &adapter->hw;

        /* Allow time for pending master requests to run */
        if ( mac->ops.reset_hw(hw) )
                DBG ("PF still resetting\n");

        mac->ops.init_hw ( hw );

        if ( is_valid_ether_addr(adapter->hw.mac.addr) ) {
                memcpy ( netdev->hw_addr, adapter->hw.mac.addr, ETH_ALEN );
        }
}
void igbvf_init_function_pointers_vf ( struct e1000_hw *  hw)

igbvf_init_function_pointers_vf - Inits function pointers : pointer to the HW structure

Definition at line 83 of file igbvf_vf.c.

References igbvf_init_mac_params_vf(), and igbvf_init_mbx_params_vf().

Referenced by igbvf_sw_init().

{
        DEBUGFUNC("igbvf_init_function_pointers_vf");

        hw->mac.ops.init_params = igbvf_init_mac_params_vf;
        hw->mbx.ops.init_params = igbvf_init_mbx_params_vf;
}
static int __devinit igbvf_sw_init ( struct igbvf_adapter adapter) [static]

igbvf_sw_init - Initialize general software structures (struct igbvf_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.

References DBG, pci_device::device, ETH_FCS_LEN, ETH_HLEN, ETH_ZLEN, igbvf_adapter::hw, igbvf_init_function_pointers_vf(), igbvf_irq_disable(), igbvf_adapter::max_frame_size, MAXIMUM_ETHERNET_VLAN_SIZE, igbvf_adapter::min_frame_size, PCI_COMMAND, pci_read_config_byte(), pci_read_config_word(), PCI_REVISION, igbvf_adapter::pdev, rc, and pci_device::vendor.

Referenced by igbvf_probe().

{
        struct e1000_hw *hw = &adapter->hw;
        struct pci_device *pdev = adapter->pdev;
        int rc;

        /* PCI config space info */

        hw->vendor_id = pdev->vendor;
        hw->device_id = pdev->device;

        pci_read_config_byte ( pdev, PCI_REVISION, &hw->revision_id );

        pci_read_config_word ( pdev, PCI_COMMAND, &hw->bus.pci_cmd_word );

        adapter->max_frame_size = MAXIMUM_ETHERNET_VLAN_SIZE + ETH_HLEN + ETH_FCS_LEN;
        adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;

        /* Set various function pointers */
        igbvf_init_function_pointers_vf ( &adapter->hw );

        rc = adapter->hw.mac.ops.init_params ( &adapter->hw );
        if (rc) {
                DBG ("hw.mac.ops.init_params(&adapter->hw) Failure\n");
                return rc;
        }

        rc = adapter->hw.mbx.ops.init_params ( &adapter->hw );
        if (rc) {
                DBG ("hw.mbx.ops.init_params(&adapter->hw) Failure\n");
                return rc;
        }

        /* Explicitly disable IRQ since the NIC can be in any state. */
        igbvf_irq_disable ( adapter );

        return 0;
}
static void igbvf_setup_srrctl ( struct igbvf_adapter adapter) [static]

igbvf_setup_srrctl - configure the receive control registers : Board private structure

Definition at line 496 of file igbvf_main.c.

References DBG, ew32, and igbvf_adapter::hw.

Referenced by igbvf_open().

{
        struct e1000_hw *hw = &adapter->hw;
        u32 srrctl = 0;

        DBG ( "igbvf_setup_srrctl\n" );

        srrctl &= ~(E1000_SRRCTL_DESCTYPE_MASK |
                    E1000_SRRCTL_BSIZEHDR_MASK |
                    E1000_SRRCTL_BSIZEPKT_MASK);

        /* Enable queue drop to avoid head of line blocking */
        srrctl |= E1000_SRRCTL_DROP_EN;

        /* Setup buffer sizes */
        srrctl |= 2048 >> E1000_SRRCTL_BSIZEPKT_SHIFT;
        srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;

        ew32 ( SRRCTL(0), srrctl );
}
static void igbvf_configure_rx ( struct igbvf_adapter adapter) [static]

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

Configure the Rx unit of the MAC after a reset.

Definition at line 523 of file igbvf_main.c.

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

Referenced by igbvf_open().

{
        struct e1000_hw *hw = &adapter->hw;
        u32 rxdctl;

        DBG ( "igbvf_configure_rx\n" );

        /* disable receives */
        rxdctl = er32 ( RXDCTL(0) );
        ew32 ( RXDCTL(0), rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE );
        msleep ( 10 );

        /*
         * Setup the HW Rx Head and Tail Descriptor Pointers and
         * the Base and Length of the Rx Descriptor Ring
         */
        ew32 ( RDBAL(0), virt_to_bus (adapter->rx_base) );
        ew32 ( RDBAH(0), 0 );
        ew32 ( RDLEN(0), adapter->rx_ring_size );
        adapter->rx_curr = 0;
        ew32 ( RDH(0), 0 );
        ew32 ( RDT(0), 0 );

        rxdctl |= E1000_RXDCTL_QUEUE_ENABLE;
        rxdctl &= 0xFFF00000;
        rxdctl |= IGBVF_RX_PTHRESH;
        rxdctl |= IGBVF_RX_HTHRESH << 8;
        rxdctl |= IGBVF_RX_WTHRESH << 16;

        igbvf_rlpml_set_vf ( hw, adapter->max_frame_size );

        /* enable receives */
        ew32 ( RXDCTL(0), rxdctl );
        ew32 ( RDT(0), NUM_RX_DESC );
}
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.

References alloc_iob(), io_buffer::data, DBG, ENOMEM, malloc_dma(), MAXIMUM_ETHERNET_VLAN_SIZE, memset(), NUM_RX_DESC, igbvf_adapter::rx_base, igbvf_adapter::rx_iobuf, igbvf_adapter::rx_ring_size, and virt_to_bus().

Referenced by igbvf_open().

{
        int i;
        union e1000_adv_rx_desc *rx_curr_desc;
        struct io_buffer *iob;

        DBG ( "igbvf_setup_rx_resources\n" );

        /* Allocate receive descriptor ring memory.
           It must not cross a 64K boundary because of hardware errata
         */

        adapter->rx_base =
                malloc_dma ( adapter->rx_ring_size, adapter->rx_ring_size );

        if ( ! adapter->rx_base ) {
                return -ENOMEM;
        }
        memset ( adapter->rx_base, 0, adapter->rx_ring_size );

        for ( i = 0; i < NUM_RX_DESC; i++ ) {
                rx_curr_desc = adapter->rx_base + i;
                iob = alloc_iob ( MAXIMUM_ETHERNET_VLAN_SIZE );
                adapter->rx_iobuf[i] = iob;
                rx_curr_desc->wb.upper.status_error = 0;
                if ( ! iob ) {
                        DBG ( "alloc_iob failed\n" );
                        return -ENOMEM;
                } else {
                        rx_curr_desc->read.pkt_addr = virt_to_bus ( iob->data );
                        rx_curr_desc->read.hdr_addr = 0;
                }
        }

        return 0;
}
static int igbvf_open ( struct net_device netdev) [static]

igbvf_open - Called when a network interface is made active : 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.

References 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(), net_device::ll_addr, memcpy(), and netdev_priv().

{
        struct igbvf_adapter *adapter = netdev_priv ( netdev );
        int err;

        DBG ("igbvf_open\n");

        /* Update MAC address */
        memcpy ( adapter->hw.mac.addr, netdev->ll_addr, ETH_ALEN );
        igbvf_reset( adapter );

        /* allocate transmit descriptors */
        err = igbvf_setup_tx_resources ( adapter );
        if (err) {
                DBG ( "Error setting up TX resources!\n" );
                goto err_setup_tx;
        }

        igbvf_configure_tx ( adapter );

        igbvf_setup_srrctl( adapter );

        err = igbvf_setup_rx_resources( adapter );
        if (err) {
                DBG ( "Error setting up RX resources!\n" );
                goto err_setup_rx;
        }

        igbvf_configure_rx ( adapter );

        return 0;

err_setup_rx:
        DBG ( "err_setup_rx\n" );
        igbvf_free_tx_resources ( adapter );
        return err;

err_setup_tx:
        DBG ( "err_setup_tx\n" );
        igbvf_reset ( adapter );

        return err;
}
static void igbvf_close ( struct net_device netdev) [static]

igbvf_close - Disables a network interface : 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.

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

{
        struct igbvf_adapter *adapter = netdev_priv ( netdev );
        struct e1000_hw *hw = &adapter->hw;
        uint32_t rxdctl;

        DBG ( "igbvf_close\n" );

        /* Disable and acknowledge interrupts */
        igbvf_irq_disable ( adapter );
        er32(EICR);

        /* disable receives */
        rxdctl = er32 ( RXDCTL(0) );
        ew32 ( RXDCTL(0), rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE );
        mdelay ( 10 );

        igbvf_reset ( adapter );

        igbvf_free_tx_resources( adapter );
        igbvf_free_rx_resources( adapter );
}
static 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.

References io_buffer::data, DBG, DBGP, e1e_flush, ENOBUFS, ew32, igbvf_adapter::hw, iob_len(), netdev_priv(), NUM_TX_DESC, 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().

{
        struct igbvf_adapter *adapter = netdev_priv ( netdev );
        struct e1000_hw *hw = &adapter->hw;
        uint32_t tx_curr = adapter->tx_tail;
        union e1000_adv_tx_desc *tx_curr_desc;

        DBGP ("igbvf_transmit\n");

        if ( adapter->tx_fill_ctr == NUM_TX_DESC ) {
                DBG ("TX overflow\n");
                return -ENOBUFS;
        }

        /* Save pointer to iobuf we have been given to transmit,
           netdev_tx_complete() will need it later
         */
        adapter->tx_iobuf[tx_curr] = iobuf;

        tx_curr_desc = ( void * ) ( adapter->tx_base ) +
                       ( tx_curr * sizeof ( *adapter->tx_base ) );

        DBG ( "tx_curr_desc = %#08lx\n", virt_to_bus ( tx_curr_desc ) );
        DBG ( "tx_curr_desc + 16 = %#08lx\n", virt_to_bus ( tx_curr_desc ) + 16 );
        DBG ( "iobuf->data = %#08lx\n", virt_to_bus ( iobuf->data ) );

        /* Add the packet to TX ring
         */
        tx_curr_desc->read.buffer_addr = virt_to_bus ( iobuf->data );
        tx_curr_desc->read.cmd_type_len = adapter->txd_cmd |(iob_len ( iobuf )) ;
        // minus hdr_len ????
        tx_curr_desc->read.olinfo_status = ((iob_len ( iobuf )) << E1000_ADVTXD_PAYLEN_SHIFT);

        DBG ( "TX fill: %d tx_curr: %d addr: %#08lx len: %zd\n", adapter->tx_fill_ctr,
              tx_curr, virt_to_bus ( iobuf->data ), iob_len ( iobuf ) );

        /* Point to next free descriptor */
        adapter->tx_tail = ( adapter->tx_tail + 1 ) % NUM_TX_DESC;
        adapter->tx_fill_ctr++;

        /* Write new tail to NIC, making packet available for transmit
         */
        ew32 ( TDT(0), adapter->tx_tail );
        e1e_flush ();

        return 0;
}
void igbvf_get_hw_control ( struct igbvf_adapter adapter)

igbvf_get_hw_control - get control of the h/w from f/w : 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.

References er32, ew32, and igbvf_adapter::hw.

Referenced by igbvf_probe().

{
        struct e1000_hw *hw = &adapter->hw;
        u32 ctrl_ext;

        /* Let firmware know the driver has taken over */
        ctrl_ext = er32 ( CTRL_EXT );
        ew32 ( CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD );
}
int igbvf_probe ( struct pci_device pdev)

igbvf_probe - Device Initialization Routine : PCI device information struct : 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.

References adjust_pci_device(), alloc_etherdev(), DBG, pci_device::dev, net_device::dev, pci_device::device, EIO, ENOMEM, ETH_ALEN, ETH_FCS_LEN, ETH_FRAME_LEN, eth_random_addr(), ETH_ZLEN, igbvf_adapter::hw, net_device::hw_addr, igbvf_get_hw_control(), igbvf_reset(), igbvf_sw_init(), pci_device::ioaddr, igbvf_adapter::ioaddr, ioremap(), iounmap(), pci_device::irq, igbvf_adapter::irqno, is_valid_ether_addr(), igbvf_adapter::max_hw_frame_size, memcpy(), memset(), igbvf_adapter::min_frame_size, netdev, igbvf_adapter::netdev, netdev_init(), netdev_link_up(), netdev_priv(), netdev_put(), NUM_RX_DESC, NUM_TX_DESC, pci_bar_size(), pci_bar_start(), PCI_BASE_ADDRESS_0, 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.

{
        int err;
        struct net_device *netdev;
        struct igbvf_adapter *adapter;
        unsigned long mmio_start, mmio_len;
        struct e1000_hw *hw;

        DBG ( "igbvf_probe\n" );

        err = -ENOMEM;

        /* Allocate net device ( also allocates memory for netdev->priv
          and makes netdev-priv point to it ) */
        netdev = alloc_etherdev ( sizeof ( struct igbvf_adapter ) );
        if ( ! netdev )
                goto err_alloc_etherdev;

        /* Associate igbvf-specific network operations operations with
         * generic network device layer */
        netdev_init ( netdev, &igbvf_operations );

        /* Associate this network device with given PCI device */
        pci_set_drvdata ( pdev, netdev );
        netdev->dev = &pdev->dev;

        /* Initialize driver private storage */
        adapter = netdev_priv ( netdev );
        memset ( adapter, 0, ( sizeof ( *adapter ) ) );

        adapter->pdev = pdev;

        adapter->ioaddr = pdev->ioaddr;
        adapter->hw.io_base = pdev->ioaddr;

        hw = &adapter->hw;
        hw->vendor_id = pdev->vendor;
        hw->device_id = pdev->device;

        adapter->irqno = pdev->irq;
        adapter->netdev = netdev;
        adapter->hw.back = adapter;

        adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
        adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;

        adapter->tx_ring_size = sizeof ( *adapter->tx_base ) * NUM_TX_DESC;
        adapter->rx_ring_size = sizeof ( *adapter->rx_base ) * NUM_RX_DESC;

        /* Fix up PCI device */
        adjust_pci_device ( pdev );

        err = -EIO;

        mmio_start = pci_bar_start ( pdev, PCI_BASE_ADDRESS_0 );
        mmio_len   = pci_bar_size  ( pdev, PCI_BASE_ADDRESS_0 );

        DBG ( "mmio_start: %#08lx\n", mmio_start );
        DBG ( "mmio_len: %#08lx\n", mmio_len );

        adapter->hw.hw_addr = ioremap ( mmio_start, mmio_len );
        DBG ( "adapter->hw.hw_addr: %p\n", adapter->hw.hw_addr );

        if ( ! adapter->hw.hw_addr ) {
                DBG ( "err_ioremap\n" );
                goto err_ioremap;
        }

        /* setup adapter struct */
        err = igbvf_sw_init ( adapter );
        if (err) {
                DBG ( "err_sw_init\n" );
                goto err_sw_init;
        }

        /* reset the controller to put the device in a known good state */
        err = hw->mac.ops.reset_hw ( hw );
        if ( err ) {
                DBG ("PF still in reset state, assigning new address\n");
                netdev->hw_addr[0] = 0x21;
                netdev->hw_addr[1] = 0x21;
                netdev->hw_addr[2] = 0x21;
                netdev->hw_addr[3] = 0x21;
                netdev->hw_addr[4] = 0x21;
                netdev->hw_addr[5] = 0x21;
                netdev->hw_addr[6] = 0x21;
        } else {
                err = hw->mac.ops.read_mac_addr(hw);
                if (err) {
                        DBG ("Error reading MAC address\n");
                        goto err_hw_init;
                }
                if ( ! is_valid_ether_addr(adapter->hw.mac.addr) ) {
                        /* Assign random MAC address */
                        eth_random_addr(adapter->hw.mac.addr);
                }
        }

        memcpy ( netdev->hw_addr, adapter->hw.mac.addr, ETH_ALEN );

        /* reset the hardware with the new settings */
        igbvf_reset ( adapter );

        /* let the f/w know that the h/w is now under the control of the
         * driver. */
        igbvf_get_hw_control ( adapter );

        /* Mark as link up; we don't yet handle link state */
        netdev_link_up ( netdev );

        if ( ( err = register_netdev ( netdev ) ) != 0) {
                DBG ( "err_register\n" );
                goto err_register;
        }

        DBG ("igbvf_probe_succeeded\n");

        return 0;

err_register:
err_hw_init:
err_sw_init:
        iounmap ( adapter->hw.hw_addr );
err_ioremap:
        netdev_put ( netdev );
err_alloc_etherdev:
        return err;
}
void igbvf_remove ( struct pci_device pdev)

igbvf_remove - Device Removal Routine : 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.

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

{
        struct net_device *netdev = pci_get_drvdata ( pdev );
        struct igbvf_adapter *adapter = netdev_priv ( netdev );

        DBG ( "igbvf_remove\n" );

        if ( adapter->hw.flash_address )
                iounmap ( adapter->hw.flash_address );
        if  ( adapter->hw.hw_addr )
                iounmap ( adapter->hw.hw_addr );

        unregister_netdev ( netdev );
        igbvf_reset  ( adapter );
        netdev_nullify ( netdev );
        netdev_put ( netdev );
}

Variable Documentation

Initial value:
 {
        .open           = igbvf_open,
        .close          = igbvf_close,
        .transmit       = igbvf_transmit,
        .poll           = igbvf_poll,
        .irq            = igbvf_irq,
}

igbvf net device operations

Definition at line 748 of file igbvf_main.c.

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),
}

Definition at line 942 of file igbvf_main.c.

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,
        .remove = igbvf_remove,
}

Definition at line 948 of file igbvf_main.c.