iPXE
Defines | Functions | Variables
atl1e.c File Reference
#include "atl1e.h"

Go to the source code of this file.

Defines

#define TX_DESC_COUNT   32 /* TX descriptors, minimum 32 */
#define RX_MEM_SIZE   8192 /* RX area size, minimum 8kb */
#define MAX_FRAME_SIZE   1500 /* Maximum MTU supported, minimum 1500 */
#define PREAMBLE_LEN   7
#define RX_JUMBO_THRESH
#define IMT_VAL   100 /* interrupt moderator timer, us */
#define ICT_VAL   50000 /* interrupt clear timer, us */
#define SMB_TIMER   200000
#define RRD_THRESH   1 /* packets to queue before interrupt */
#define TPD_BURST   5
#define TPD_THRESH   (TX_DESC_COUNT / 2)
#define RX_COUNT_DOWN   4
#define TX_COUNT_DOWN   (IMT_VAL * 4 / 3)
#define DMAR_DLY_CNT   15
#define DMAW_DLY_CNT   4
#define PCI_DEVICE_ID_ATTANSIC_L1E   0x1026

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static void atl1e_setup_mac_ctrl (struct atl1e_adapter *adapter)
static void atl1e_irq_enable (struct atl1e_adapter *adapter)
static void atl1e_irq_disable (struct atl1e_adapter *adapter)
static void atl1e_irq_reset (struct atl1e_adapter *adapter)
static void atl1e_reset (struct atl1e_adapter *adapter)
static int atl1e_check_link (struct atl1e_adapter *adapter)
static int atl1e_mdio_read (struct net_device *netdev, int phy_id __unused, int reg_num)
static void atl1e_mdio_write (struct net_device *netdev, int phy_id __unused, int reg_num, int val)
static void atl1e_setup_pcicmd (struct pci_device *pdev)
static int atl1e_sw_init (struct atl1e_adapter *adapter)
static void atl1e_clean_tx_ring (struct atl1e_adapter *adapter)
static void atl1e_clean_rx_ring (struct atl1e_adapter *adapter)
static void atl1e_cal_ring_size (struct atl1e_adapter *adapter, u32 *ring_size)
static void atl1e_init_ring_resources (struct atl1e_adapter *adapter)
static void atl1e_init_ring_ptrs (struct atl1e_adapter *adapter)
static void atl1e_free_ring_resources (struct atl1e_adapter *adapter)
static int atl1e_setup_ring_resources (struct atl1e_adapter *adapter)
static void atl1e_configure_des_ring (const struct atl1e_adapter *adapter)
static void atl1e_configure_tx (struct atl1e_adapter *adapter)
static void atl1e_configure_rx (struct atl1e_adapter *adapter)
static void atl1e_configure_dma (struct atl1e_adapter *adapter)
static int atl1e_configure (struct atl1e_adapter *adapter)
static void atl1e_clear_phy_int (struct atl1e_adapter *adapter)
static int atl1e_clean_tx_irq (struct atl1e_adapter *adapter)
static struct atl1e_rx_page * atl1e_get_rx_page (struct atl1e_adapter *adapter)
static void atl1e_clean_rx_irq (struct atl1e_adapter *adapter)
static void atl1e_poll (struct net_device *netdev)
static u16 atl1e_tpd_avail (struct atl1e_adapter *adapter)
static struct atl1e_tpd_desc * atl1e_get_tpd (struct atl1e_adapter *adapter)
static struct atl1e_tx_buffer * atl1e_get_tx_buffer (struct atl1e_adapter *adapter, struct atl1e_tpd_desc *tpd)
static void atl1e_tx_map (struct atl1e_adapter *adapter, struct io_buffer *iob, struct atl1e_tpd_desc *tpd)
static void atl1e_tx_queue (struct atl1e_adapter *adapter, u16 count __unused, struct atl1e_tpd_desc *tpd __unused)
static int atl1e_xmit_frame (struct net_device *netdev, struct io_buffer *iob)
int atl1e_up (struct atl1e_adapter *adapter)
void atl1e_irq (struct net_device *netdev, int enable)
void atl1e_down (struct atl1e_adapter *adapter)
static int atl1e_open (struct net_device *netdev)
static void atl1e_close (struct net_device *netdev)
static void atl1e_init_netdev (struct net_device *netdev, struct pci_device *pdev)
static int atl1e_probe (struct pci_device *pdev)
static void atl1e_remove (struct pci_device *pdev)
int atl1e_check_eeprom_exist (struct atl1e_hw *hw)
void atl1e_hw_set_mac_addr (struct atl1e_hw *hw)
static int atl1e_get_permanent_address (struct atl1e_hw *hw)
void atl1e_force_ps (struct atl1e_hw *hw)
int atl1e_read_mac_addr (struct atl1e_hw *hw)
int atl1e_read_phy_reg (struct atl1e_hw *hw, u16 reg_addr, u16 *phy_data)
int atl1e_write_phy_reg (struct atl1e_hw *hw, u32 reg_addr, u16 phy_data)
static void atl1e_init_pcie (struct atl1e_hw *hw)
static int atl1e_phy_setup_autoneg_adv (struct atl1e_hw *hw)
int atl1e_phy_commit (struct atl1e_hw *hw)
int atl1e_phy_init (struct atl1e_hw *hw)
int atl1e_reset_hw (struct atl1e_hw *hw)
int atl1e_init_hw (struct atl1e_hw *hw)
int atl1e_get_speed_and_duplex (struct atl1e_hw *hw, u16 *speed, u16 *duplex)
int atl1e_restart_autoneg (struct atl1e_hw *hw)

Variables

static struct pci_device_id atl1e_pci_tbl []
static const u16 atl1e_rx_page_vld_regs [AT_PAGE_NUM_PER_QUEUE]
static const u16 atl1e_rx_page_lo_addr_regs [AT_PAGE_NUM_PER_QUEUE]
static const u16 atl1e_rx_page_write_offset_regs [AT_PAGE_NUM_PER_QUEUE]
static const u16 atl1e_pay_load_size []
static struct net_device_operations atl1e_netdev_ops
struct pci_driver atl1e_driver __pci_driver

Define Documentation

#define TX_DESC_COUNT   32 /* TX descriptors, minimum 32 */

Definition at line 29 of file atl1e.c.

Referenced by atl1e_probe().

#define RX_MEM_SIZE   8192 /* RX area size, minimum 8kb */

Definition at line 30 of file atl1e.c.

Referenced by atl1e_probe().

#define MAX_FRAME_SIZE   1500 /* Maximum MTU supported, minimum 1500 */

Definition at line 31 of file atl1e.c.

Referenced by atl1e_configure(), atl1e_configure_tx(), and atl1e_init_ring_resources().

#define PREAMBLE_LEN   7

Definition at line 34 of file atl1e.c.

Referenced by atl1e_setup_mac_ctrl().

#define RX_JUMBO_THRESH
Value:
((MAX_FRAME_SIZE + ETH_HLEN + \
                          VLAN_HLEN + ETH_FCS_LEN + 7) >> 3)

Definition at line 35 of file atl1e.c.

Referenced by atl1e_configure_rx().

#define IMT_VAL   100 /* interrupt moderator timer, us */

Definition at line 37 of file atl1e.c.

Referenced by atl1e_configure().

#define ICT_VAL   50000 /* interrupt clear timer, us */

Definition at line 38 of file atl1e.c.

Referenced by atl1e_configure().

#define SMB_TIMER   200000

Definition at line 39 of file atl1e.c.

Referenced by atl1e_configure().

#define RRD_THRESH   1 /* packets to queue before interrupt */

Definition at line 40 of file atl1e.c.

Referenced by atl1e_configure().

#define TPD_BURST   5

Definition at line 41 of file atl1e.c.

Referenced by atl1e_configure_tx().

#define TPD_THRESH   (TX_DESC_COUNT / 2)

Definition at line 42 of file atl1e.c.

Referenced by atl1e_configure().

#define RX_COUNT_DOWN   4

Definition at line 43 of file atl1e.c.

Referenced by atl1e_configure().

#define TX_COUNT_DOWN   (IMT_VAL * 4 / 3)

Definition at line 44 of file atl1e.c.

Referenced by atl1e_configure().

#define DMAR_DLY_CNT   15

Definition at line 45 of file atl1e.c.

Referenced by atl1e_configure_dma().

#define DMAW_DLY_CNT   4

Definition at line 46 of file atl1e.c.

Referenced by atl1e_configure_dma().

#define PCI_DEVICE_ID_ATTANSIC_L1E   0x1026

Definition at line 48 of file atl1e.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )
static void atl1e_setup_mac_ctrl ( struct atl1e_adapter *  adapter) [static]

Definition at line 611 of file atl1e.c.

References PREAMBLE_LEN, SPEED_1000, and value.

Referenced by atl1e_check_link().

{
        u32 value;
        struct atl1e_hw *hw = &adapter->hw;

        /* Config MAC CTRL Register */
        value = MAC_CTRL_TX_EN |
                MAC_CTRL_RX_EN ;

        if (FULL_DUPLEX == adapter->link_duplex)
                value |= MAC_CTRL_DUPLX;

        value |= ((u32)((SPEED_1000 == adapter->link_speed) ?
                          MAC_CTRL_SPEED_1000 : MAC_CTRL_SPEED_10_100) <<
                          MAC_CTRL_SPEED_SHIFT);
        value |= (MAC_CTRL_TX_FLOW | MAC_CTRL_RX_FLOW);

        value |= (MAC_CTRL_ADD_CRC | MAC_CTRL_PAD);
        value |= ((PREAMBLE_LEN & MAC_CTRL_PRMLEN_MASK) << MAC_CTRL_PRMLEN_SHIFT);

        value |= MAC_CTRL_BC_EN;
        value |= MAC_CTRL_MC_ALL_EN;

        AT_WRITE_REG(hw, REG_MAC_CTRL, value);
}
static void atl1e_irq_enable ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 92 of file atl1e.c.

Referenced by atl1e_irq().

{
        AT_WRITE_REG(&adapter->hw, REG_ISR, 0);
        AT_WRITE_REG(&adapter->hw, REG_IMR, IMR_NORMAL_MASK);
        AT_WRITE_FLUSH(&adapter->hw);
}
static void atl1e_irq_disable ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 103 of file atl1e.c.

Referenced by atl1e_irq(), and atl1e_up().

{
        AT_WRITE_REG(&adapter->hw, REG_IMR, 0);
        AT_WRITE_FLUSH(&adapter->hw);
}
static void atl1e_irq_reset ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 113 of file atl1e.c.

Referenced by atl1e_poll().

{
        AT_WRITE_REG(&adapter->hw, REG_ISR, 0);
        AT_WRITE_REG(&adapter->hw, REG_IMR, 0);
        AT_WRITE_FLUSH(&adapter->hw);
}
static void atl1e_reset ( struct atl1e_adapter *  adapter) [static]

Definition at line 120 of file atl1e.c.

References atl1e_down(), and atl1e_up().

Referenced by atl1e_clean_rx_irq(), and atl1e_poll().

{
        atl1e_down(adapter);
        atl1e_up(adapter);
}
static int atl1e_check_link ( struct atl1e_adapter *  adapter) [static]

Definition at line 126 of file atl1e.c.

References atl1e_get_speed_and_duplex(), atl1e_read_phy_reg(), atl1e_setup_mac_ctrl(), BMSR_LSTATUS, DBG, MII_BMSR, net_device::name, netdev, netdev_link_down(), netdev_link_ok(), netdev_link_up(), speed, and value.

Referenced by atl1e_poll().

{
        struct atl1e_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
        int err = 0;
        u16 speed, duplex, phy_data;

        /* MII_BMSR must read twise */
        atl1e_read_phy_reg(hw, MII_BMSR, &phy_data);
        atl1e_read_phy_reg(hw, MII_BMSR, &phy_data);

        if ((phy_data & BMSR_LSTATUS) == 0) {
                /* link down */
                if (netdev_link_ok(netdev)) { /* old link state: Up */
                        u32 value;
                        /* disable rx */
                        value = AT_READ_REG(hw, REG_MAC_CTRL);
                        value &= ~MAC_CTRL_RX_EN;
                        AT_WRITE_REG(hw, REG_MAC_CTRL, value);
                        adapter->link_speed = SPEED_0;

                        DBG("atl1e: %s link is down\n", netdev->name);
                        netdev_link_down(netdev);
                }
        } else {
                /* Link Up */
                err = atl1e_get_speed_and_duplex(hw, &speed, &duplex);
                if (err)
                        return err;

                /* link result is our setting */
                if (adapter->link_speed != speed ||
                    adapter->link_duplex != duplex) {
                        adapter->link_speed  = speed;
                        adapter->link_duplex = duplex;
                        atl1e_setup_mac_ctrl(adapter);

                        DBG("atl1e: %s link is up, %d Mbps, %s duplex\n",
                            netdev->name, adapter->link_speed,
                            adapter->link_duplex == FULL_DUPLEX ?
                            "full" : "half");
                        netdev_link_up(netdev);
                }
        }
        return 0;
}
static int atl1e_mdio_read ( struct net_device netdev,
int phy_id  __unused,
int  reg_num 
) [static]

Definition at line 173 of file atl1e.c.

References atl1e_read_phy_reg(), and netdev_priv().

Referenced by atl1e_probe().

{
        struct atl1e_adapter *adapter = netdev_priv(netdev);
        u16 result;

        atl1e_read_phy_reg(&adapter->hw, reg_num & MDIO_REG_ADDR_MASK, &result);
        return result;
}
static void atl1e_mdio_write ( struct net_device netdev,
int phy_id  __unused,
int  reg_num,
int  val 
) [static]

Definition at line 183 of file atl1e.c.

References atl1e_write_phy_reg(), and netdev_priv().

Referenced by atl1e_probe().

{
        struct atl1e_adapter *adapter = netdev_priv(netdev);

        atl1e_write_phy_reg(&adapter->hw, reg_num & MDIO_REG_ADDR_MASK, val);
}
static void atl1e_setup_pcicmd ( struct pci_device pdev) [static]

Definition at line 191 of file atl1e.c.

References cmd, mdelay(), PCI_COMMAND, PCI_COMMAND_MASTER, PCI_COMMAND_MEM, pci_read_config_word(), pci_write_config_dword(), and pci_write_config_word().

Referenced by atl1e_probe().

{
        u16 cmd;

        pci_read_config_word(pdev, PCI_COMMAND, &cmd);
        cmd |=  (PCI_COMMAND_MEM | PCI_COMMAND_MASTER);
        pci_write_config_word(pdev, PCI_COMMAND, cmd);

        /*
         * some motherboards BIOS(PXE/EFI) driver may set PME
         * while they transfer control to OS (Windows/Linux)
         * so we should clear this bit before NIC work normally
         */
        pci_write_config_dword(pdev, REG_PM_CTRLSTAT, 0);
        mdelay(1);
}
static int atl1e_sw_init ( struct atl1e_adapter *  adapter) [static]

Definition at line 216 of file atl1e.c.

References pci_read_config_byte(), and PCI_REVISION.

Referenced by atl1e_probe().

{
        struct atl1e_hw *hw = &adapter->hw;
        struct pci_device *pdev = adapter->pdev;
        u32 phy_status_data = 0;
        u8 rev_id = 0;

        adapter->link_speed = SPEED_0;   /* hardware init */
        adapter->link_duplex = FULL_DUPLEX;

        /* PCI config space info */
        pci_read_config_byte(pdev, PCI_REVISION, &rev_id);

        phy_status_data = AT_READ_REG(hw, REG_PHY_STATUS);
        /* nic type */
        if (rev_id >= 0xF0) {
                hw->nic_type = athr_l2e_revB;
        } else {
                if (phy_status_data & PHY_STATUS_100M)
                        hw->nic_type = athr_l1e;
                else
                        hw->nic_type = athr_l2e_revA;
        }

        phy_status_data = AT_READ_REG(hw, REG_PHY_STATUS);

        hw->emi_ca = !!(phy_status_data & PHY_STATUS_EMI_CA);

        hw->phy_configured = 0;

        /* need confirm */

        hw->dmar_block = atl1e_dma_req_1024;
        hw->dmaw_block = atl1e_dma_req_1024;

        return 0;
}
static void atl1e_clean_tx_ring ( struct atl1e_adapter *  adapter) [static]

Definition at line 258 of file atl1e.c.

References index, memset(), netdev_tx_complete(), NULL, and tx_ring.

Referenced by atl1e_down(), and atl1e_free_ring_resources().

{
        struct atl1e_tx_ring *tx_ring = (struct atl1e_tx_ring *)
                                &adapter->tx_ring;
        struct atl1e_tx_buffer *tx_buffer = NULL;
        u16 index, ring_count = tx_ring->count;

        if (tx_ring->desc == NULL || tx_ring->tx_buffer == NULL)
                return;

        for (index = 0; index < ring_count; index++) {
                tx_buffer = &tx_ring->tx_buffer[index];
                if (tx_buffer->iob) {
                        netdev_tx_complete(adapter->netdev, tx_buffer->iob);
                        tx_buffer->dma = 0;
                        tx_buffer->iob = NULL;
                }
        }

        /* Zero out Tx-buffers */
        memset(tx_ring->desc, 0, sizeof(struct atl1e_tpd_desc) *
               ring_count);
        memset(tx_ring->tx_buffer, 0, sizeof(struct atl1e_tx_buffer) *
               ring_count);
}
static void atl1e_clean_rx_ring ( struct atl1e_adapter *  adapter) [static]

Definition at line 288 of file atl1e.c.

References memset(), NULL, and rx_ring.

Referenced by atl1e_down(), and atl1e_free_ring_resources().

{
        struct atl1e_rx_ring *rx_ring =
                (struct atl1e_rx_ring *)&adapter->rx_ring;
        struct atl1e_rx_page_desc *rx_page_desc = &rx_ring->rx_page_desc;
        u16 j;

        if (adapter->ring_vir_addr == NULL)
                return;

        /* Zero out the descriptor ring */
        for (j = 0; j < AT_PAGE_NUM_PER_QUEUE; j++) {
                if (rx_page_desc->rx_page[j].addr != NULL) {
                        memset(rx_page_desc->rx_page[j].addr, 0,
                               rx_ring->real_page_size);
                }
        }
}
static void atl1e_cal_ring_size ( struct atl1e_adapter *  adapter,
u32 ring_size 
) [static]

Definition at line 307 of file atl1e.c.

Referenced by atl1e_init_ring_resources().

{
        *ring_size = ((u32)(adapter->tx_ring.count *
                     sizeof(struct atl1e_tpd_desc) + 7
                        /* tx ring, qword align */
                     + adapter->rx_ring.real_page_size * AT_PAGE_NUM_PER_QUEUE
                     + 31
                        /* rx ring,  32 bytes align */
                     + (1 + AT_PAGE_NUM_PER_QUEUE) *
                        sizeof(u32) + 3));
                        /* tx, rx cmd, dword align   */
}
static void atl1e_init_ring_resources ( struct atl1e_adapter *  adapter) [static]

Definition at line 320 of file atl1e.c.

References atl1e_cal_ring_size(), ETH_FCS_LEN, ETH_HLEN, MAX_FRAME_SIZE, NULL, and rx_ring.

Referenced by atl1e_open().

{
        struct atl1e_rx_ring *rx_ring = &adapter->rx_ring;

        rx_ring->real_page_size = adapter->rx_ring.page_size
                                 + MAX_FRAME_SIZE
                                 + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN;
        rx_ring->real_page_size = (rx_ring->real_page_size + 31) & ~31;
        atl1e_cal_ring_size(adapter, &adapter->ring_size);

        adapter->ring_vir_addr = NULL;
        adapter->rx_ring.desc = NULL;

        return;
}
static void atl1e_init_ring_ptrs ( struct atl1e_adapter *  adapter) [static]

Definition at line 339 of file atl1e.c.

References NULL, rx_ring, and tx_ring.

Referenced by atl1e_up().

{
        struct atl1e_tx_ring *tx_ring = NULL;
        struct atl1e_rx_ring *rx_ring = NULL;
        struct atl1e_rx_page_desc *rx_page_desc = NULL;
        int j;

        tx_ring = &adapter->tx_ring;
        rx_ring = &adapter->rx_ring;
        rx_page_desc = &rx_ring->rx_page_desc;

        tx_ring->next_to_use = 0;
        tx_ring->next_to_clean = 0;

        rx_page_desc->rx_using  = 0;
        rx_page_desc->rx_nxseq = 0;
        for (j = 0; j < AT_PAGE_NUM_PER_QUEUE; j++) {
                *rx_page_desc->rx_page[j].write_offset_addr = 0;
                rx_page_desc->rx_page[j].read_offset = 0;
        }
}
static void atl1e_free_ring_resources ( struct atl1e_adapter *  adapter) [static]

Definition at line 367 of file atl1e.c.

References atl1e_clean_rx_ring(), atl1e_clean_tx_ring(), free, free_dma(), and NULL.

Referenced by atl1e_close(), atl1e_open(), atl1e_remove(), and atl1e_setup_ring_resources().

{
        atl1e_clean_tx_ring(adapter);
        atl1e_clean_rx_ring(adapter);

        if (adapter->ring_vir_addr) {
                free_dma(adapter->ring_vir_addr, adapter->ring_size);
                adapter->ring_vir_addr = NULL;
                adapter->ring_dma = 0;
        }

        if (adapter->tx_ring.tx_buffer) {
                free(adapter->tx_ring.tx_buffer);
                adapter->tx_ring.tx_buffer = NULL;
        }
}
static int atl1e_setup_ring_resources ( struct atl1e_adapter *  adapter) [static]

Definition at line 390 of file atl1e.c.

References atl1e_free_ring_resources(), DBG, EINVAL, ENOMEM, malloc_dma(), memset(), NULL, offset, rx_ring, size, tx_ring, virt_to_bus(), and zalloc().

Referenced by atl1e_open().

{
        struct atl1e_tx_ring *tx_ring;
        struct atl1e_rx_ring *rx_ring;
        struct atl1e_rx_page_desc  *rx_page_desc;
        int size, j;
        u32 offset = 0;
        int err = 0;

        if (adapter->ring_vir_addr != NULL)
                return 0; /* alloced already */

        tx_ring = &adapter->tx_ring;
        rx_ring = &adapter->rx_ring;

        /* real ring DMA buffer */

        size = adapter->ring_size;
        adapter->ring_vir_addr = malloc_dma(adapter->ring_size, 32);

        if (adapter->ring_vir_addr == NULL) {
                DBG("atl1e: out of memory allocating %d bytes for %s ring\n",
                    adapter->ring_size, adapter->netdev->name);
                return -ENOMEM;
        }

        adapter->ring_dma = virt_to_bus(adapter->ring_vir_addr);
        memset(adapter->ring_vir_addr, 0, adapter->ring_size);

        rx_page_desc = &rx_ring->rx_page_desc;

        /* Init TPD Ring */
        tx_ring->dma = (adapter->ring_dma + 7) & ~7;
        offset = tx_ring->dma - adapter->ring_dma;
        tx_ring->desc = (struct atl1e_tpd_desc *)
                        (adapter->ring_vir_addr + offset);
        size = sizeof(struct atl1e_tx_buffer) * (tx_ring->count);
        tx_ring->tx_buffer = zalloc(size);
        if (tx_ring->tx_buffer == NULL) {
                DBG("atl1e: out of memory allocating %d bytes for %s txbuf\n",
                    size, adapter->netdev->name);
                err = -ENOMEM;
                goto failed;
        }

        /* Init RXF-Pages */
        offset += (sizeof(struct atl1e_tpd_desc) * tx_ring->count);
        offset = (offset + 31) & ~31;

        for (j = 0; j < AT_PAGE_NUM_PER_QUEUE; j++) {
                rx_page_desc->rx_page[j].dma =
                        adapter->ring_dma + offset;
                rx_page_desc->rx_page[j].addr =
                        adapter->ring_vir_addr + offset;
                offset += rx_ring->real_page_size;
        }

        /* Init CMB dma address */
        tx_ring->cmb_dma = adapter->ring_dma + offset;
        tx_ring->cmb     = (u32 *)(adapter->ring_vir_addr + offset);
        offset += sizeof(u32);

        for (j = 0; j < AT_PAGE_NUM_PER_QUEUE; j++) {
                rx_page_desc->rx_page[j].write_offset_dma =
                        adapter->ring_dma + offset;
                rx_page_desc->rx_page[j].write_offset_addr =
                        adapter->ring_vir_addr + offset;
                offset += sizeof(u32);
        }

        if (offset > adapter->ring_size) {
                DBG("atl1e: ring miscalculation! need %d > %d bytes\n",
                    offset, adapter->ring_size);
                err = -EINVAL;
                goto failed;
        }

        return 0;
failed:
        atl1e_free_ring_resources(adapter);
        return err;
}
static void atl1e_configure_des_ring ( const struct atl1e_adapter *  adapter) [inline, static]

Definition at line 473 of file atl1e.c.

References atl1e_rx_page_lo_addr_regs, atl1e_rx_page_vld_regs, atl1e_rx_page_write_offset_regs, NULL, rx_ring, and tx_ring.

Referenced by atl1e_configure().

{

        struct atl1e_hw *hw = (struct atl1e_hw *)&adapter->hw;
        struct atl1e_rx_ring *rx_ring =
                        (struct atl1e_rx_ring *)&adapter->rx_ring;
        struct atl1e_tx_ring *tx_ring =
                        (struct atl1e_tx_ring *)&adapter->tx_ring;
        struct atl1e_rx_page_desc *rx_page_desc = NULL;
        int j;

        AT_WRITE_REG(hw, REG_DESC_BASE_ADDR_HI, 0);
        AT_WRITE_REG(hw, REG_TPD_BASE_ADDR_LO, tx_ring->dma);
        AT_WRITE_REG(hw, REG_TPD_RING_SIZE, (u16)(tx_ring->count));
        AT_WRITE_REG(hw, REG_HOST_TX_CMB_LO, tx_ring->cmb_dma);

        rx_page_desc = &rx_ring->rx_page_desc;

        /* RXF Page Physical address / Page Length */
        AT_WRITE_REG(hw, REG_RXF0_BASE_ADDR_HI, 0);

        for (j = 0; j < AT_PAGE_NUM_PER_QUEUE; j++) {
                u32 page_phy_addr;
                u32 offset_phy_addr;

                page_phy_addr = rx_page_desc->rx_page[j].dma;
                offset_phy_addr = rx_page_desc->rx_page[j].write_offset_dma;

                AT_WRITE_REG(hw, atl1e_rx_page_lo_addr_regs[j], page_phy_addr);
                AT_WRITE_REG(hw, atl1e_rx_page_write_offset_regs[j],
                             offset_phy_addr);
                AT_WRITE_REGB(hw, atl1e_rx_page_vld_regs[j], 1);
        }

        /* Page Length */
        AT_WRITE_REG(hw, REG_HOST_RXFPAGE_SIZE, rx_ring->page_size);
        /* Load all of base address above */
        AT_WRITE_REG(hw, REG_LOAD_PTR, 1);

        return;
}
static void atl1e_configure_tx ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 515 of file atl1e.c.

References atl1e_pay_load_size, ETH_FCS_LEN, ETH_HLEN, MAX_FRAME_SIZE, and TPD_BURST.

Referenced by atl1e_configure().

{
        struct atl1e_hw *hw = (struct atl1e_hw *)&adapter->hw;
        u32 dev_ctrl_data = 0;
        u32 max_pay_load = 0;
        u32 jumbo_thresh = 0;
        u32 extra_size = 0;     /* Jumbo frame threshold in QWORD unit */

        /* configure TXQ param */
        if (hw->nic_type != athr_l2e_revB) {
                extra_size = ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN;
                jumbo_thresh = MAX_FRAME_SIZE + extra_size;
                AT_WRITE_REG(hw, REG_TX_EARLY_TH, (jumbo_thresh + 7) >> 3);
        }

        dev_ctrl_data = AT_READ_REG(hw, REG_DEVICE_CTRL);

        max_pay_load  = ((dev_ctrl_data >> DEVICE_CTRL_MAX_PAYLOAD_SHIFT)) &
                        DEVICE_CTRL_MAX_PAYLOAD_MASK;
        if (max_pay_load < hw->dmaw_block)
                hw->dmaw_block = max_pay_load;

        max_pay_load  = ((dev_ctrl_data >> DEVICE_CTRL_MAX_RREQ_SZ_SHIFT)) &
                        DEVICE_CTRL_MAX_RREQ_SZ_MASK;
        if (max_pay_load < hw->dmar_block)
                hw->dmar_block = max_pay_load;

        if (hw->nic_type != athr_l2e_revB)
                AT_WRITE_REGW(hw, REG_TXQ_CTRL + 2,
                              atl1e_pay_load_size[hw->dmar_block]);
        /* enable TXQ */
        AT_WRITE_REGW(hw, REG_TXQ_CTRL,
                        ((TPD_BURST & TXQ_CTRL_NUM_TPD_BURST_MASK)
                         << TXQ_CTRL_NUM_TPD_BURST_SHIFT)
                        | TXQ_CTRL_ENH_MODE | TXQ_CTRL_EN);
        return;
}
static void atl1e_configure_rx ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 553 of file atl1e.c.

References RX_JUMBO_THRESH.

Referenced by atl1e_configure().

{
        struct atl1e_hw *hw = (struct atl1e_hw *)&adapter->hw;
        u32 rxf_len  = 0;
        u32 rxf_low  = 0;
        u32 rxf_high = 0;
        u32 rxf_thresh_data = 0;
        u32 rxq_ctrl_data = 0;

        if (hw->nic_type != athr_l2e_revB) {
                AT_WRITE_REGW(hw, REG_RXQ_JMBOSZ_RRDTIM,
                              (u16)((RX_JUMBO_THRESH & RXQ_JMBOSZ_TH_MASK) <<
                              RXQ_JMBOSZ_TH_SHIFT |
                              (1 & RXQ_JMBO_LKAH_MASK) <<
                              RXQ_JMBO_LKAH_SHIFT));

                rxf_len  = AT_READ_REG(hw, REG_SRAM_RXF_LEN);
                rxf_high = rxf_len * 4 / 5;
                rxf_low  = rxf_len / 5;
                rxf_thresh_data = ((rxf_high  & RXQ_RXF_PAUSE_TH_HI_MASK)
                                  << RXQ_RXF_PAUSE_TH_HI_SHIFT) |
                                  ((rxf_low & RXQ_RXF_PAUSE_TH_LO_MASK)
                                  << RXQ_RXF_PAUSE_TH_LO_SHIFT);

                AT_WRITE_REG(hw, REG_RXQ_RXF_PAUSE_THRESH, rxf_thresh_data);
        }

        /* RRS */
        AT_WRITE_REG(hw, REG_IDT_TABLE, 0);
        AT_WRITE_REG(hw, REG_BASE_CPU_NUMBER, 0);

        rxq_ctrl_data |= RXQ_CTRL_PBA_ALIGN_32 |
                         RXQ_CTRL_CUT_THRU_EN | RXQ_CTRL_EN;

        AT_WRITE_REG(hw, REG_RXQ_CTRL, rxq_ctrl_data);
        return;
}
static void atl1e_configure_dma ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 591 of file atl1e.c.

References DMAR_DLY_CNT, and DMAW_DLY_CNT.

Referenced by atl1e_configure().

{
        struct atl1e_hw *hw = &adapter->hw;
        u32 dma_ctrl_data = 0;

        dma_ctrl_data = DMA_CTRL_RXCMB_EN;
        dma_ctrl_data |= (((u32)hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK)
                << DMA_CTRL_DMAR_BURST_LEN_SHIFT;
        dma_ctrl_data |= (((u32)hw->dmaw_block) & DMA_CTRL_DMAW_BURST_LEN_MASK)
                << DMA_CTRL_DMAW_BURST_LEN_SHIFT;
        dma_ctrl_data |= DMA_CTRL_DMAR_REQ_PRI | DMA_CTRL_DMAR_OUT_ORDER;
        dma_ctrl_data |= (DMAR_DLY_CNT & DMA_CTRL_DMAR_DLY_CNT_MASK)
                << DMA_CTRL_DMAR_DLY_CNT_SHIFT;
        dma_ctrl_data |= (DMAW_DLY_CNT & DMA_CTRL_DMAW_DLY_CNT_MASK)
                << DMA_CTRL_DMAW_DLY_CNT_SHIFT;

        AT_WRITE_REG(hw, REG_DMA_CTRL, dma_ctrl_data);
        return;
}
static int atl1e_configure ( struct atl1e_adapter *  adapter) [static]

Definition at line 643 of file atl1e.c.

References atl1e_configure_des_ring(), atl1e_configure_dma(), atl1e_configure_rx(), atl1e_configure_tx(), atl1e_hw_set_mac_addr(), DBG, ETH_FCS_LEN, ETH_HLEN, ICT_VAL, IMT_VAL, MAX_FRAME_SIZE, RRD_THRESH, RX_COUNT_DOWN, SMB_TIMER, TPD_THRESH, and TX_COUNT_DOWN.

Referenced by atl1e_up().

{
        struct atl1e_hw *hw = &adapter->hw;
        u32 intr_status_data = 0;

        /* clear interrupt status */
        AT_WRITE_REG(hw, REG_ISR, ~0);

        /* 1. set MAC Address */
        atl1e_hw_set_mac_addr(hw);

        /* 2. Init the Multicast HASH table (clear) */
        AT_WRITE_REG(hw, REG_RX_HASH_TABLE, 0);
        AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);

        /* 3. Clear any WOL status */
        AT_WRITE_REG(hw, REG_WOL_CTRL, 0);

        /* 4. Descripter Ring BaseMem/Length/Read ptr/Write ptr
         *    TPD Ring/SMB/RXF0 Page CMBs, they use the same
         *    High 32bits memory */
        atl1e_configure_des_ring(adapter);

        /* 5. set Interrupt Moderator Timer */
        AT_WRITE_REGW(hw, REG_IRQ_MODU_TIMER_INIT, IMT_VAL);
        AT_WRITE_REGW(hw, REG_IRQ_MODU_TIMER2_INIT, IMT_VAL);
        AT_WRITE_REG(hw, REG_MASTER_CTRL, MASTER_CTRL_LED_MODE |
                        MASTER_CTRL_ITIMER_EN | MASTER_CTRL_ITIMER2_EN);

        /* 6. rx/tx threshold to trig interrupt */
        AT_WRITE_REGW(hw, REG_TRIG_RRD_THRESH, RRD_THRESH);
        AT_WRITE_REGW(hw, REG_TRIG_TPD_THRESH, TPD_THRESH);
        AT_WRITE_REGW(hw, REG_TRIG_RXTIMER, RX_COUNT_DOWN);
        AT_WRITE_REGW(hw, REG_TRIG_TXTIMER, TX_COUNT_DOWN);

        /* 7. set Interrupt Clear Timer */
        AT_WRITE_REGW(hw, REG_CMBDISDMA_TIMER, ICT_VAL);

        /* 8. set MTU */
        AT_WRITE_REG(hw, REG_MTU, MAX_FRAME_SIZE + ETH_HLEN +
                        VLAN_HLEN + ETH_FCS_LEN);

        /* 9. config TXQ early tx threshold */
        atl1e_configure_tx(adapter);

        /* 10. config RXQ */
        atl1e_configure_rx(adapter);

        /* 11. config  DMA Engine */
        atl1e_configure_dma(adapter);

        /* 12. smb timer to trig interrupt */
        AT_WRITE_REG(hw, REG_SMB_STAT_TIMER, SMB_TIMER);

        intr_status_data = AT_READ_REG(hw, REG_ISR);
        if ((intr_status_data & ISR_PHY_LINKDOWN) != 0) {
                DBG("atl1e: configure failed, PCIE phy link down\n");
                return -1;
        }

        AT_WRITE_REG(hw, REG_ISR, 0x7fffffff);
        return 0;
}
static void atl1e_clear_phy_int ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 707 of file atl1e.c.

References atl1e_read_phy_reg().

Referenced by atl1e_poll().

{
        u16 phy_data;

        atl1e_read_phy_reg(&adapter->hw, MII_INT_STATUS, &phy_data);
}
static int atl1e_clean_tx_irq ( struct atl1e_adapter *  adapter) [static]

Definition at line 714 of file atl1e.c.

References netdev_tx_complete(), NULL, and tx_ring.

Referenced by atl1e_poll().

{
        struct atl1e_tx_ring *tx_ring = (struct atl1e_tx_ring *)
                                        &adapter->tx_ring;
        struct atl1e_tx_buffer *tx_buffer = NULL;
        u16 hw_next_to_clean = AT_READ_REGW(&adapter->hw, REG_TPD_CONS_IDX);
        u16 next_to_clean = tx_ring->next_to_clean;

        while (next_to_clean != hw_next_to_clean) {
                tx_buffer = &tx_ring->tx_buffer[next_to_clean];

                tx_buffer->dma = 0;
                if (tx_buffer->iob) {
                        netdev_tx_complete(adapter->netdev, tx_buffer->iob);
                        tx_buffer->iob = NULL;
                }

                if (++next_to_clean == tx_ring->count)
                        next_to_clean = 0;
        }

        tx_ring->next_to_clean = next_to_clean;

        return 1;
}
static struct atl1e_rx_page* atl1e_get_rx_page ( struct atl1e_adapter *  adapter) [static, read]

Definition at line 740 of file atl1e.c.

Referenced by atl1e_clean_rx_irq().

{
        struct atl1e_rx_page_desc *rx_page_desc =
                (struct atl1e_rx_page_desc *) &adapter->rx_ring.rx_page_desc;
        u8 rx_using = rx_page_desc->rx_using;

        return (struct atl1e_rx_page *)&(rx_page_desc->rx_page[rx_using]);
}
static void atl1e_clean_rx_irq ( struct atl1e_adapter *  adapter) [static]

Definition at line 749 of file atl1e.c.

References alloc_iob(), atl1e_get_rx_page(), atl1e_reset(), atl1e_rx_page_vld_regs, io_buffer::data, DBG, EIO, ETH_FCS_LEN, iob_put, iob_reserve, memcpy(), net_device::name, NET_IP_ALIGN, netdev, netdev_link_ok(), netdev_rx(), netdev_rx_err(), NULL, and rx_ring.

Referenced by atl1e_poll().

{
        struct net_device *netdev  = adapter->netdev;
        struct atl1e_rx_ring *rx_ring = (struct atl1e_rx_ring *)
                                         &adapter->rx_ring;
        struct atl1e_rx_page_desc *rx_page_desc =
                (struct atl1e_rx_page_desc *) &rx_ring->rx_page_desc;
        struct io_buffer *iob = NULL;
        struct atl1e_rx_page *rx_page = atl1e_get_rx_page(adapter);
        u32 packet_size, write_offset;
        struct atl1e_recv_ret_status *prrs;

        write_offset = *(rx_page->write_offset_addr);
        if (rx_page->read_offset >= write_offset)
                return;

        do {
                /* get new packet's  rrs */
                prrs = (struct atl1e_recv_ret_status *) (rx_page->addr +
                                                         rx_page->read_offset);
                /* check sequence number */
                if (prrs->seq_num != rx_page_desc->rx_nxseq) {
                        DBG("atl1e %s: RX sequence number error (%d != %d)\n",
                            netdev->name, prrs->seq_num,
                            rx_page_desc->rx_nxseq);
                        rx_page_desc->rx_nxseq++;
                        goto fatal_err;
                }

                rx_page_desc->rx_nxseq++;

                /* error packet */
                if (prrs->pkt_flag & RRS_IS_ERR_FRAME) {
                        if (prrs->err_flag & (RRS_ERR_BAD_CRC |
                                              RRS_ERR_DRIBBLE | RRS_ERR_CODE |
                                              RRS_ERR_TRUNC)) {
                                /* hardware error, discard this
                                   packet */
                                netdev_rx_err(netdev, NULL, EIO);
                                goto skip_pkt;
                        }
                }

                packet_size = ((prrs->word1 >> RRS_PKT_SIZE_SHIFT) &
                               RRS_PKT_SIZE_MASK) - ETH_FCS_LEN;
                iob = alloc_iob(packet_size + NET_IP_ALIGN);
                if (iob == NULL) {
                        DBG("atl1e %s: dropping packet under memory pressure\n",
                            netdev->name);
                        goto skip_pkt;
                }
                iob_reserve(iob, NET_IP_ALIGN);
                memcpy(iob->data, (u8 *)(prrs + 1), packet_size);
                iob_put(iob, packet_size);

                netdev_rx(netdev, iob);

skip_pkt:
                /* skip current packet whether it's ok or not. */
                rx_page->read_offset +=
                        (((u32)((prrs->word1 >> RRS_PKT_SIZE_SHIFT) &
                                RRS_PKT_SIZE_MASK) +
                          sizeof(struct atl1e_recv_ret_status) + 31) &
                         0xFFFFFFE0);

                if (rx_page->read_offset >= rx_ring->page_size) {
                        /* mark this page clean */
                        u16 reg_addr;
                        u8  rx_using;

                        rx_page->read_offset =
                                *(rx_page->write_offset_addr) = 0;
                        rx_using = rx_page_desc->rx_using;
                        reg_addr =
                                atl1e_rx_page_vld_regs[rx_using];
                        AT_WRITE_REGB(&adapter->hw, reg_addr, 1);
                        rx_page_desc->rx_using ^= 1;
                        rx_page = atl1e_get_rx_page(adapter);
                }
                write_offset = *(rx_page->write_offset_addr);
        } while (rx_page->read_offset < write_offset);

        return;

fatal_err:
        if (!netdev_link_ok(adapter->netdev))
                atl1e_reset(adapter);
}
static void atl1e_poll ( struct net_device netdev) [static]

Definition at line 842 of file atl1e.c.

References atl1e_check_link(), atl1e_clean_rx_irq(), atl1e_clean_tx_irq(), atl1e_clear_phy_int(), atl1e_irq_reset(), atl1e_reset(), DBG, netdev_link_ok(), netdev_priv(), and status.

{
        struct atl1e_adapter *adapter = netdev_priv(netdev);
        struct atl1e_hw *hw = &adapter->hw;
        int max_ints = 64;
        u32 status;

        do {
                status = AT_READ_REG(hw, REG_ISR);
                if ((status & IMR_NORMAL_MASK) == 0)
                        break;

                /* link event */
                if (status & ISR_GPHY)
                        atl1e_clear_phy_int(adapter);
                /* Ack ISR */
                AT_WRITE_REG(hw, REG_ISR, status | ISR_DIS_INT);

                /* check if PCIE PHY Link down */
                if (status & ISR_PHY_LINKDOWN) {
                        DBG("atl1e: PCI-E PHY link down: %x\n", status);
                        if (netdev_link_ok(adapter->netdev)) {
                                /* reset MAC */
                                atl1e_irq_reset(adapter);
                                atl1e_reset(adapter);
                                break;
                        }
                }

                /* check if DMA read/write error */
                if (status & (ISR_DMAR_TO_RST | ISR_DMAW_TO_RST)) {
                        DBG("atl1e: PCI-E DMA RW error: %x\n", status);
                        atl1e_irq_reset(adapter);
                        atl1e_reset(adapter);
                        break;
                }

                /* link event */
                if (status & (ISR_GPHY | ISR_MANUAL)) {
                        atl1e_check_link(adapter);
                        break;
                }

                /* transmit event */
                if (status & ISR_TX_EVENT)
                        atl1e_clean_tx_irq(adapter);

                if (status & ISR_RX_EVENT)
                        atl1e_clean_rx_irq(adapter);
        } while (--max_ints > 0);

        /* re-enable Interrupt*/
        AT_WRITE_REG(&adapter->hw, REG_ISR, 0);

        return;
}
static u16 atl1e_tpd_avail ( struct atl1e_adapter *  adapter) [inline, static]

Definition at line 899 of file atl1e.c.

References tx_ring.

Referenced by atl1e_xmit_frame().

{
        struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;
        u16 next_to_use = 0;
        u16 next_to_clean = 0;

        next_to_clean = tx_ring->next_to_clean;
        next_to_use   = tx_ring->next_to_use;

        return (u16)(next_to_clean > next_to_use) ?
                (next_to_clean - next_to_use - 1) :
                (tx_ring->count + next_to_clean - next_to_use - 1);
}
static struct atl1e_tpd_desc* atl1e_get_tpd ( struct atl1e_adapter *  adapter) [static, read]

Definition at line 918 of file atl1e.c.

References memset(), and tx_ring.

Referenced by atl1e_xmit_frame().

{
        struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;
        u16 next_to_use = 0;

        next_to_use = tx_ring->next_to_use;
        if (++tx_ring->next_to_use == tx_ring->count)
                tx_ring->next_to_use = 0;

        memset(&tx_ring->desc[next_to_use], 0, sizeof(struct atl1e_tpd_desc));
        return (struct atl1e_tpd_desc *)&tx_ring->desc[next_to_use];
}
static struct atl1e_tx_buffer* atl1e_get_tx_buffer ( struct atl1e_adapter *  adapter,
struct atl1e_tpd_desc *  tpd 
) [static, read]

Definition at line 932 of file atl1e.c.

References tx_ring.

Referenced by atl1e_tx_map().

{
        struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;

        return &tx_ring->tx_buffer[tpd - tx_ring->desc];
}
static void atl1e_tx_map ( struct atl1e_adapter *  adapter,
struct io_buffer iob,
struct atl1e_tpd_desc *  tpd 
) [static]

Definition at line 939 of file atl1e.c.

References atl1e_get_tx_buffer(), cpu_to_le32, cpu_to_le64, io_buffer::data, iob_len(), NULL, and virt_to_bus().

Referenced by atl1e_xmit_frame().

{
        struct atl1e_tx_buffer *tx_buffer = NULL;
        u16 buf_len = iob_len(iob);

        tx_buffer = atl1e_get_tx_buffer(adapter, tpd);
        tx_buffer->iob = iob;
        tx_buffer->length = buf_len;
        tx_buffer->dma = virt_to_bus(iob->data);
        tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
        tpd->word2 = ((tpd->word2 & ~TPD_BUFLEN_MASK) |
                      ((cpu_to_le32(buf_len) & TPD_BUFLEN_MASK) <<
                       TPD_BUFLEN_SHIFT));
        tpd->word3 |= 1 << TPD_EOP_SHIFT;
}
static void atl1e_tx_queue ( struct atl1e_adapter *  adapter,
u16 count  __unused,
struct atl1e_tpd_desc *tpd  __unused 
) [static]

Definition at line 956 of file atl1e.c.

References tx_ring, and wmb.

Referenced by atl1e_xmit_frame().

{
        struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;
        wmb();
        AT_WRITE_REG(&adapter->hw, REG_MB_TPD_PROD_IDX, tx_ring->next_to_use);
}
static int atl1e_xmit_frame ( struct net_device netdev,
struct io_buffer iob 
) [static]

Definition at line 964 of file atl1e.c.

References atl1e_get_tpd(), atl1e_tpd_avail(), atl1e_tx_map(), atl1e_tx_queue(), EBUSY, EINVAL, netdev_link_ok(), and netdev_priv().

{
        struct atl1e_adapter *adapter = netdev_priv(netdev);
        u16 tpd_req = 1;
        struct atl1e_tpd_desc *tpd;

        if (!netdev_link_ok(netdev)) {
                return -EINVAL;
        }

        if (atl1e_tpd_avail(adapter) < tpd_req) {
                return -EBUSY;
        }

        tpd = atl1e_get_tpd(adapter);

        atl1e_tx_map(adapter, iob, tpd);
        atl1e_tx_queue(adapter, tpd_req, tpd);

        return 0;
}
int atl1e_up ( struct atl1e_adapter *  adapter)

Definition at line 986 of file atl1e.c.

References atl1e_configure(), atl1e_init_hw(), atl1e_init_ring_ptrs(), atl1e_irq_disable(), EIO, ETH_ALEN, net_device::ll_addr, memcpy(), netdev, and val.

Referenced by atl1e_open(), and atl1e_reset().

{
        struct net_device *netdev = adapter->netdev;
        int err = 0;
        u32 val;

        /* hardware has been reset, we need to reload some things */
        err = atl1e_init_hw(&adapter->hw);
        if (err) {
                return -EIO;
        }
        atl1e_init_ring_ptrs(adapter);

        memcpy(adapter->hw.mac_addr, netdev->ll_addr, ETH_ALEN);

        if (atl1e_configure(adapter) != 0) {
                return -EIO;
        }

        atl1e_irq_disable(adapter);

        val = AT_READ_REG(&adapter->hw, REG_MASTER_CTRL);
        AT_WRITE_REG(&adapter->hw, REG_MASTER_CTRL,
                      val | MASTER_CTRL_MANUAL_INT);

        return err;
}
void atl1e_irq ( struct net_device netdev,
int  enable 
)

Definition at line 1014 of file atl1e.c.

References atl1e_irq_disable(), atl1e_irq_enable(), and netdev_priv().

{
        struct atl1e_adapter *adapter = netdev_priv(netdev);

        if (enable)
                atl1e_irq_enable(adapter);
        else
                atl1e_irq_disable(adapter);
}
void atl1e_down ( struct atl1e_adapter *  adapter)

Definition at line 1024 of file atl1e.c.

References atl1e_clean_rx_ring(), atl1e_clean_tx_ring(), atl1e_reset_hw(), mdelay(), netdev, and netdev_link_down().

Referenced by atl1e_close(), and atl1e_reset().

{
        struct net_device *netdev = adapter->netdev;

        /* reset MAC to disable all RX/TX */
        atl1e_reset_hw(&adapter->hw);
        mdelay(1);

        netdev_link_down(netdev);
        adapter->link_speed = SPEED_0;
        adapter->link_duplex = -1;

        atl1e_clean_tx_ring(adapter);
        atl1e_clean_rx_ring(adapter);
}
static int atl1e_open ( struct net_device netdev) [static]

Definition at line 1052 of file atl1e.c.

References atl1e_free_ring_resources(), atl1e_init_ring_resources(), atl1e_reset_hw(), atl1e_setup_ring_resources(), atl1e_up(), and netdev_priv().

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

        /* allocate rx/tx dma buffer & descriptors */
        atl1e_init_ring_resources(adapter);
        err = atl1e_setup_ring_resources(adapter);
        if (err)
                return err;

        err = atl1e_up(adapter);
        if (err)
                goto err_up;

        return 0;

err_up:
        atl1e_free_ring_resources(adapter);
        atl1e_reset_hw(&adapter->hw);

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

Definition at line 1087 of file atl1e.c.

References atl1e_down(), atl1e_free_ring_resources(), and netdev_priv().

{
        struct atl1e_adapter *adapter = netdev_priv(netdev);

        atl1e_down(adapter);
        atl1e_free_ring_resources(adapter);
}
static void atl1e_init_netdev ( struct net_device netdev,
struct pci_device pdev 
) [static]

Definition at line 1103 of file atl1e.c.

References pci_device::dev, net_device::dev, netdev_init(), and pci_set_drvdata().

Referenced by atl1e_probe().

{
        netdev_init(netdev, &atl1e_netdev_ops);

        netdev->dev = &pdev->dev;
        pci_set_drvdata(pdev, netdev);
}
static int atl1e_probe ( struct pci_device pdev) [static]

Definition at line 1122 of file atl1e.c.

References adjust_pci_device(), alloc_etherdev(), atl1e_init_netdev(), atl1e_mdio_read(), atl1e_mdio_write(), atl1e_phy_init(), atl1e_read_mac_addr(), atl1e_reset_hw(), atl1e_restart_autoneg(), atl1e_setup_pcicmd(), atl1e_sw_init(), bus_to_virt(), DBG, EIO, ENOMEM, ETH_ALEN, net_device::hw_addr, net_device::ll_addr, pci_device::membase, memcpy(), netdev, netdev_nullify(), netdev_priv(), netdev_put(), NULL, register_netdev(), RX_MEM_SIZE, and TX_DESC_COUNT.

{
        struct net_device *netdev;
        struct atl1e_adapter *adapter = NULL;
        static int cards_found;

        int err = 0;

        adjust_pci_device(pdev);

        netdev = alloc_etherdev(sizeof(struct atl1e_adapter));
        if (netdev == NULL) {
                err = -ENOMEM;
                DBG("atl1e: out of memory allocating net_device\n");
                goto err;
        }

        atl1e_init_netdev(netdev, pdev);

        adapter = netdev_priv(netdev);
        adapter->bd_number = cards_found;
        adapter->netdev = netdev;
        adapter->pdev = pdev;
        adapter->hw.adapter = adapter;
        if (!pdev->membase) {
                err = -EIO;
                DBG("atl1e: cannot map device registers\n");
                goto err_free_netdev;
        }
        adapter->hw.hw_addr = bus_to_virt(pdev->membase);

        /* init mii data */
        adapter->mii.dev = netdev;
        adapter->mii.mdio_read  = atl1e_mdio_read;
        adapter->mii.mdio_write = atl1e_mdio_write;
        adapter->mii.phy_id_mask = 0x1f;
        adapter->mii.reg_num_mask = MDIO_REG_ADDR_MASK;

        /* get user settings */
        adapter->tx_ring.count = TX_DESC_COUNT;
        adapter->rx_ring.page_size = RX_MEM_SIZE;

        atl1e_setup_pcicmd(pdev);

        /* setup the private structure */
        err = atl1e_sw_init(adapter);
        if (err) {
                DBG("atl1e: private data init failed\n");
                goto err_free_netdev;
        }

        /* Init GPHY as early as possible due to power saving issue  */
        atl1e_phy_init(&adapter->hw);

        /* reset the controller to
         * put the device in a known good starting state */
        err = atl1e_reset_hw(&adapter->hw);
        if (err) {
                err = -EIO;
                goto err_free_netdev;
        }

        /* This may have been run by a zero-wait timer around
           now... unclear. */
        atl1e_restart_autoneg(&adapter->hw);

        if (atl1e_read_mac_addr(&adapter->hw) != 0) {
                DBG("atl1e: cannot read MAC address from EEPROM\n");
                err = -EIO;
                goto err_free_netdev;
        }

        memcpy(netdev->hw_addr, adapter->hw.perm_mac_addr, ETH_ALEN);
        memcpy(netdev->ll_addr, adapter->hw.mac_addr, ETH_ALEN);
        DBG("atl1e: Attansic L1E Ethernet controller on %s, "
            "%02x:%02x:%02x:%02x:%02x:%02x\n", adapter->netdev->name,
            adapter->hw.mac_addr[0], adapter->hw.mac_addr[1],
            adapter->hw.mac_addr[2], adapter->hw.mac_addr[3],
            adapter->hw.mac_addr[4], adapter->hw.mac_addr[5]);

        err = register_netdev(netdev);
        if (err) {
                DBG("atl1e: cannot register network device\n");
                goto err_free_netdev;
        }

        cards_found++;
        return 0;

err_free_netdev:
        netdev_nullify(netdev);
        netdev_put(netdev);
err:
        return err;
}
static void atl1e_remove ( struct pci_device pdev) [static]

Definition at line 1227 of file atl1e.c.

References atl1e_force_ps(), atl1e_free_ring_resources(), netdev, netdev_nullify(), netdev_priv(), netdev_put(), pci_get_drvdata(), and unregister_netdev().

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

        unregister_netdev(netdev);
        atl1e_free_ring_resources(adapter);
        atl1e_force_ps(&adapter->hw);
        netdev_nullify(netdev);
        netdev_put(netdev);
}
int atl1e_check_eeprom_exist ( struct atl1e_hw *  hw)

Definition at line 1252 of file atl1e.c.

References value.

Referenced by atl1e_get_permanent_address().

{
        u32 value;

        value = AT_READ_REG(hw, REG_SPI_FLASH_CTRL);
        if (value & SPI_FLASH_CTRL_EN_VPD) {
                value &= ~SPI_FLASH_CTRL_EN_VPD;
                AT_WRITE_REG(hw, REG_SPI_FLASH_CTRL, value);
        }
        value = AT_READ_REGW(hw, REG_PCIE_CAP_LIST);
        return ((value & 0xFF00) == 0x6C00) ? 0 : 1;
}
void atl1e_hw_set_mac_addr ( struct atl1e_hw *  hw)

Definition at line 1265 of file atl1e.c.

References value.

Referenced by atl1e_configure().

{
        u32 value;
        /*
         * 00-0B-6A-F6-00-DC
         * 0:  6AF600DC 1: 000B
         * low dword
         */
        value = (((u32)hw->mac_addr[2]) << 24) |
                (((u32)hw->mac_addr[3]) << 16) |
                (((u32)hw->mac_addr[4]) << 8)  |
                (((u32)hw->mac_addr[5])) ;
        AT_WRITE_REG_ARRAY(hw, REG_MAC_STA_ADDR, 0, value);
        /* hight dword */
        value = (((u32)hw->mac_addr[0]) << 8) |
                (((u32)hw->mac_addr[1])) ;
        AT_WRITE_REG_ARRAY(hw, REG_MAC_STA_ADDR, 1, value);
}
static int atl1e_get_permanent_address ( struct atl1e_hw *  hw) [static]

Definition at line 1288 of file atl1e.c.

References atl1e_check_eeprom_exist(), byte, dword, ETH_ALEN, mdelay(), and memcpy().

Referenced by atl1e_read_mac_addr().

{
        union {
                u32 dword[2];
                u8 byte[8];
        } hw_addr;
        u32 i;
        u32 twsi_ctrl_data;
        u8  eth_addr[ETH_ALEN];

        if (!atl1e_check_eeprom_exist(hw)) {
                /* eeprom exist */
                twsi_ctrl_data = AT_READ_REG(hw, REG_TWSI_CTRL);
                twsi_ctrl_data |= TWSI_CTRL_SW_LDSTART;
                AT_WRITE_REG(hw, REG_TWSI_CTRL, twsi_ctrl_data);
                for (i = 0; i < AT_TWSI_EEPROM_TIMEOUT; i++) {
                        mdelay(10);
                        twsi_ctrl_data = AT_READ_REG(hw, REG_TWSI_CTRL);
                        if ((twsi_ctrl_data & TWSI_CTRL_SW_LDSTART) == 0)
                                break;
                }
                if (i >= AT_TWSI_EEPROM_TIMEOUT)
                        return AT_ERR_TIMEOUT;
        }

        /* maybe MAC-address is from BIOS */
        hw_addr.dword[0] = AT_READ_REG(hw, REG_MAC_STA_ADDR);
        hw_addr.dword[1] = AT_READ_REG(hw, REG_MAC_STA_ADDR + 4);
        for (i = 0; i < ETH_ALEN; i++) {
                eth_addr[ETH_ALEN - i - 1] = hw_addr.byte[i];
        }

        memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
        return 0;
}
void atl1e_force_ps ( struct atl1e_hw *  hw)

Definition at line 1324 of file atl1e.c.

Referenced by atl1e_remove().

{
        AT_WRITE_REGW(hw, REG_GPHY_CTRL,
                        GPHY_CTRL_PW_WOL_DIS | GPHY_CTRL_EXT_RESET);
}
int atl1e_read_mac_addr ( struct atl1e_hw *  hw)

Definition at line 1335 of file atl1e.c.

References atl1e_get_permanent_address(), and memcpy().

Referenced by atl1e_probe().

{
        int err = 0;

        err = atl1e_get_permanent_address(hw);
        if (err)
                return AT_ERR_EEPROM;
        memcpy(hw->mac_addr, hw->perm_mac_addr, sizeof(hw->perm_mac_addr));
        return 0;
}
int atl1e_read_phy_reg ( struct atl1e_hw *  hw,
u16  reg_addr,
u16 phy_data 
)

Definition at line 1351 of file atl1e.c.

References u16, udelay(), val, and wmb.

Referenced by atl1e_check_link(), atl1e_clear_phy_int(), atl1e_get_speed_and_duplex(), and atl1e_mdio_read().

{
        u32 val;
        int i;

        val = ((u32)(reg_addr & MDIO_REG_ADDR_MASK)) << MDIO_REG_ADDR_SHIFT |
                MDIO_START | MDIO_SUP_PREAMBLE | MDIO_RW |
                MDIO_CLK_25_4 << MDIO_CLK_SEL_SHIFT;

        AT_WRITE_REG(hw, REG_MDIO_CTRL, val);

        wmb();

        for (i = 0; i < MDIO_WAIT_TIMES; i++) {
                udelay(2);
                val = AT_READ_REG(hw, REG_MDIO_CTRL);
                if (!(val & (MDIO_START | MDIO_BUSY)))
                        break;
                wmb();
        }
        if (!(val & (MDIO_START | MDIO_BUSY))) {
                *phy_data = (u16)val;
                return 0;
        }

        return AT_ERR_PHY;
}
int atl1e_write_phy_reg ( struct atl1e_hw *  hw,
u32  reg_addr,
u16  phy_data 
)

Definition at line 1385 of file atl1e.c.

References udelay(), val, and wmb.

Referenced by atl1e_mdio_write(), atl1e_phy_commit(), atl1e_phy_init(), atl1e_phy_setup_autoneg_adv(), and atl1e_restart_autoneg().

{
        int i;
        u32 val;

        val = ((u32)(phy_data & MDIO_DATA_MASK)) << MDIO_DATA_SHIFT |
               (reg_addr&MDIO_REG_ADDR_MASK) << MDIO_REG_ADDR_SHIFT |
               MDIO_SUP_PREAMBLE |
               MDIO_START |
               MDIO_CLK_25_4 << MDIO_CLK_SEL_SHIFT;

        AT_WRITE_REG(hw, REG_MDIO_CTRL, val);
        wmb();

        for (i = 0; i < MDIO_WAIT_TIMES; i++) {
                udelay(2);
                val = AT_READ_REG(hw, REG_MDIO_CTRL);
                if (!(val & (MDIO_START | MDIO_BUSY)))
                        break;
                wmb();
        }

        if (!(val & (MDIO_START | MDIO_BUSY)))
                return 0;

        return AT_ERR_PHY;
}
static void atl1e_init_pcie ( struct atl1e_hw *  hw) [static]

Definition at line 1416 of file atl1e.c.

References value.

Referenced by atl1e_init_hw().

{
        u32 value;
        /* comment 2lines below to save more power when sususpend
           value = LTSSM_TEST_MODE_DEF;
           AT_WRITE_REG(hw, REG_LTSSM_TEST_MODE, value);
         */

        /* pcie flow control mode change */
        value = AT_READ_REG(hw, 0x1008);
        value |= 0x8000;
        AT_WRITE_REG(hw, 0x1008, value);
}
static int atl1e_phy_setup_autoneg_adv ( struct atl1e_hw *  hw) [static]

Definition at line 1434 of file atl1e.c.

References atl1e_write_phy_reg(), and MII_ADVERTISE.

Referenced by atl1e_phy_init().

{
        s32 ret_val;
        u16 mii_autoneg_adv_reg;
        u16 mii_1000t_ctrl_reg;

        if (0 != hw->mii_autoneg_adv_reg)
                return 0;
        /* Read the MII Auto-Neg Advertisement Register (Address 4/9). */
        mii_autoneg_adv_reg = MII_AR_DEFAULT_CAP_MASK;
        mii_1000t_ctrl_reg  = MII_AT001_CR_1000T_DEFAULT_CAP_MASK;

        /*
         * First we clear all the 10/100 mb speed bits in the Auto-Neg
         * Advertisement Register (Address 4) and the 1000 mb speed bits in
         * the  1000Base-T control Register (Address 9).
         */
        mii_autoneg_adv_reg &= ~MII_AR_SPEED_MASK;
        mii_1000t_ctrl_reg  &= ~MII_AT001_CR_1000T_SPEED_MASK;

        /* Assume auto-detect media type */
        mii_autoneg_adv_reg |= (MII_AR_10T_HD_CAPS   |
                                MII_AR_10T_FD_CAPS   |
                                MII_AR_100TX_HD_CAPS |
                                MII_AR_100TX_FD_CAPS);
        if (hw->nic_type == athr_l1e) {
                mii_1000t_ctrl_reg |= MII_AT001_CR_1000T_FD_CAPS;
        }

        /* flow control fixed to enable all */
        mii_autoneg_adv_reg |= (MII_AR_ASM_DIR | MII_AR_PAUSE);

        hw->mii_autoneg_adv_reg = mii_autoneg_adv_reg;
        hw->mii_1000t_ctrl_reg  = mii_1000t_ctrl_reg;

        ret_val = atl1e_write_phy_reg(hw, MII_ADVERTISE, mii_autoneg_adv_reg);
        if (ret_val)
                return ret_val;

        if (hw->nic_type == athr_l1e || hw->nic_type == athr_l2e_revA) {
                ret_val = atl1e_write_phy_reg(hw, MII_AT001_CR,
                                           mii_1000t_ctrl_reg);
                if (ret_val)
                        return ret_val;
        }

        return 0;
}
int atl1e_phy_commit ( struct atl1e_hw *  hw)

Definition at line 1491 of file atl1e.c.

References atl1e_write_phy_reg(), DBG, mdelay(), MII_BMCR, and val.

Referenced by atl1e_phy_init().

{
        int ret_val;
        u16 phy_data;

        phy_data = MII_CR_RESET | MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG;

        ret_val = atl1e_write_phy_reg(hw, MII_BMCR, phy_data);
        if (ret_val) {
                u32 val;
                int i;
                /**************************************
                 * pcie serdes link may be down !
                 **************************************/
                for (i = 0; i < 25; i++) {
                        mdelay(1);
                        val = AT_READ_REG(hw, REG_MDIO_CTRL);
                        if (!(val & (MDIO_START | MDIO_BUSY)))
                                break;
                }

                if (0 != (val & (MDIO_START | MDIO_BUSY))) {
                        DBG("atl1e: PCI-E link down for at least 25ms\n");
                        return ret_val;
                }

                DBG("atl1e: PCI-E link up after %d ms\n", i);
        }
        return 0;
}
int atl1e_phy_init ( struct atl1e_hw *  hw)

Definition at line 1522 of file atl1e.c.

References atl1e_phy_commit(), atl1e_phy_setup_autoneg_adv(), atl1e_restart_autoneg(), atl1e_write_phy_reg(), DBG, and mdelay().

Referenced by atl1e_init_hw(), and atl1e_probe().

{
        s32 ret_val;
        u16 phy_val;

        if (hw->phy_configured) {
                if (hw->re_autoneg) {
                        hw->re_autoneg = 0;
                        return atl1e_restart_autoneg(hw);
                }
                return 0;
        }

        /* RESET GPHY Core */
        AT_WRITE_REGW(hw, REG_GPHY_CTRL, GPHY_CTRL_DEFAULT);
        mdelay(2);
        AT_WRITE_REGW(hw, REG_GPHY_CTRL, GPHY_CTRL_DEFAULT |
                      GPHY_CTRL_EXT_RESET);
        mdelay(2);

        /* patches */
        /* p1. eable hibernation mode */
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_ADDR, 0xB);
        if (ret_val)
                return ret_val;
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_DATA, 0xBC00);
        if (ret_val)
                return ret_val;
        /* p2. set Class A/B for all modes */
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_ADDR, 0);
        if (ret_val)
                return ret_val;
        phy_val = 0x02ef;
        /* remove Class AB */
        /* phy_val = hw->emi_ca ? 0x02ef : 0x02df; */
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_DATA, phy_val);
        if (ret_val)
                return ret_val;
        /* p3. 10B ??? */
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_ADDR, 0x12);
        if (ret_val)
                return ret_val;
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_DATA, 0x4C04);
        if (ret_val)
                return ret_val;
        /* p4. 1000T power */
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_ADDR, 0x4);
        if (ret_val)
                return ret_val;
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_DATA, 0x8BBB);
        if (ret_val)
                return ret_val;

        ret_val = atl1e_write_phy_reg(hw, MII_DBG_ADDR, 0x5);
        if (ret_val)
                return ret_val;
        ret_val = atl1e_write_phy_reg(hw, MII_DBG_DATA, 0x2C46);
        if (ret_val)
                return ret_val;

        mdelay(1);

        /*Enable PHY LinkChange Interrupt */
        ret_val = atl1e_write_phy_reg(hw, MII_INT_CTRL, 0xC00);
        if (ret_val) {
                DBG("atl1e: Error enable PHY linkChange Interrupt\n");
                return ret_val;
        }
        /* setup AutoNeg parameters */
        ret_val = atl1e_phy_setup_autoneg_adv(hw);
        if (ret_val) {
                DBG("atl1e: Error Setting up Auto-Negotiation\n");
                return ret_val;
        }
        /* SW.Reset & En-Auto-Neg to restart Auto-Neg*/
        DBG("atl1e: Restarting Auto-Neg");
        ret_val = atl1e_phy_commit(hw);
        if (ret_val) {
                DBG("atl1e: Error Resetting the phy");
                return ret_val;
        }

        hw->phy_configured = 1;

        return 0;
}
int atl1e_reset_hw ( struct atl1e_hw *  hw)

Definition at line 1614 of file atl1e.c.

References DBG, mdelay(), PCI_COMMAND, PCI_COMMAND_IO, PCI_COMMAND_MASTER, PCI_COMMAND_MEM, pci_read_config_word(), pci_write_config_word(), timeout(), and wmb.

Referenced by atl1e_down(), atl1e_open(), and atl1e_probe().

{
        struct atl1e_adapter *adapter = hw->adapter;
        struct pci_device *pdev = adapter->pdev;
        int timeout = 0;
        u32 idle_status_data = 0;
        u16 pci_cfg_cmd_word = 0;

        /* Workaround for PCI problem when BIOS sets MMRBC incorrectly. */
        pci_read_config_word(pdev, PCI_COMMAND, &pci_cfg_cmd_word);
        if ((pci_cfg_cmd_word & (PCI_COMMAND_IO | PCI_COMMAND_MEM |
                                 PCI_COMMAND_MASTER))
                        != (PCI_COMMAND_IO | PCI_COMMAND_MEM |
                            PCI_COMMAND_MASTER)) {
                pci_cfg_cmd_word |= (PCI_COMMAND_IO | PCI_COMMAND_MEM |
                                     PCI_COMMAND_MASTER);
                pci_write_config_word(pdev, PCI_COMMAND, pci_cfg_cmd_word);
        }

        /*
         * Issue Soft Reset to the MAC.  This will reset the chip's
         * transmit, receive, DMA.  It will not effect
         * the current PCI configuration.  The global reset bit is self-
         * clearing, and should clear within a microsecond.
         */
        AT_WRITE_REG(hw, REG_MASTER_CTRL,
                        MASTER_CTRL_LED_MODE | MASTER_CTRL_SOFT_RST);
        wmb();
        mdelay(1);

        /* Wait at least 10ms for All module to be Idle */
        for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) {
                idle_status_data = AT_READ_REG(hw, REG_IDLE_STATUS);
                if (idle_status_data == 0)
                        break;
                mdelay(1);
        }

        if (timeout >= AT_HW_MAX_IDLE_DELAY) {
                DBG("atl1e: MAC reset timeout\n");
                return AT_ERR_TIMEOUT;
        }

        return 0;
}
int atl1e_init_hw ( struct atl1e_hw *  hw)

Definition at line 1670 of file atl1e.c.

References atl1e_init_pcie(), and atl1e_phy_init().

Referenced by atl1e_up().

{
        s32 ret_val = 0;

        atl1e_init_pcie(hw);

        /* Zero out the Multicast HASH table */
        /* clear the old settings from the multicast hash table */
        AT_WRITE_REG(hw, REG_RX_HASH_TABLE, 0);
        AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);

        ret_val = atl1e_phy_init(hw);

        return ret_val;
}
int atl1e_get_speed_and_duplex ( struct atl1e_hw *  hw,
u16 speed,
u16 duplex 
)

Definition at line 1693 of file atl1e.c.

References atl1e_read_phy_reg(), SPEED_10, SPEED_100, and SPEED_1000.

Referenced by atl1e_check_link().

{
        int err;
        u16 phy_data;

        /* Read   PHY Specific Status Register (17) */
        err = atl1e_read_phy_reg(hw, MII_AT001_PSSR, &phy_data);
        if (err)
                return err;

        if (!(phy_data & MII_AT001_PSSR_SPD_DPLX_RESOLVED))
                return AT_ERR_PHY_RES;

        switch (phy_data & MII_AT001_PSSR_SPEED) {
        case MII_AT001_PSSR_1000MBS:
                *speed = SPEED_1000;
                break;
        case MII_AT001_PSSR_100MBS:
                *speed = SPEED_100;
                break;
        case MII_AT001_PSSR_10MBS:
                *speed = SPEED_10;
                break;
        default:
                return AT_ERR_PHY_SPEED;
                break;
        }

        if (phy_data & MII_AT001_PSSR_DPLX)
                *duplex = FULL_DUPLEX;
        else
                *duplex = HALF_DUPLEX;

        return 0;
}
int atl1e_restart_autoneg ( struct atl1e_hw *  hw)

Definition at line 1729 of file atl1e.c.

References atl1e_write_phy_reg(), MII_ADVERTISE, and MII_BMCR.

Referenced by atl1e_phy_init(), and atl1e_probe().

{
        int err = 0;

        err = atl1e_write_phy_reg(hw, MII_ADVERTISE, hw->mii_autoneg_adv_reg);
        if (err)
                return err;

        if (hw->nic_type == athr_l1e || hw->nic_type == athr_l2e_revA) {
                err = atl1e_write_phy_reg(hw, MII_AT001_CR,
                                       hw->mii_1000t_ctrl_reg);
                if (err)
                        return err;
        }

        err = atl1e_write_phy_reg(hw, MII_BMCR,
                        MII_CR_RESET | MII_CR_AUTO_NEG_EN |
                        MII_CR_RESTART_AUTO_NEG);
        return err;
}

Variable Documentation

struct pci_device_id atl1e_pci_tbl[] [static]
Initial value:
 {
        PCI_ROM(0x1969, 0x1026, "atl1e_26", "Attansic L1E 0x1026", 0),
        PCI_ROM(0x1969, 0x1066, "atl1e_66", "Attansic L1E 0x1066", 0),
}

Definition at line 59 of file atl1e.c.

const u16 atl1e_rx_page_vld_regs[AT_PAGE_NUM_PER_QUEUE] [static]
Initial value:
{
        REG_HOST_RXF0_PAGE0_VLD, REG_HOST_RXF0_PAGE1_VLD
}

Definition at line 67 of file atl1e.c.

Referenced by atl1e_clean_rx_irq(), and atl1e_configure_des_ring().

const u16 atl1e_rx_page_lo_addr_regs[AT_PAGE_NUM_PER_QUEUE] [static]
Initial value:
{
        REG_HOST_RXF0_PAGE0_LO, REG_HOST_RXF0_PAGE1_LO
}

Definition at line 73 of file atl1e.c.

Referenced by atl1e_configure_des_ring().

const u16 atl1e_rx_page_write_offset_regs[AT_PAGE_NUM_PER_QUEUE] [static]
Initial value:
{
        REG_HOST_RXF0_MB0_LO,  REG_HOST_RXF0_MB1_LO
}

Definition at line 79 of file atl1e.c.

Referenced by atl1e_configure_des_ring().

const u16 atl1e_pay_load_size[] [static]
Initial value:
 {
        128, 256, 512, 1024, 2048, 4096,
}

Definition at line 84 of file atl1e.c.

Referenced by atl1e_configure_tx().

Initial value:
 {
        .open           = atl1e_open,
        .close          = atl1e_close,
        .transmit       = atl1e_xmit_frame,
        .poll           = atl1e_poll,
        .irq            = atl1e_irq,
}

Definition at line 1095 of file atl1e.c.

struct pci_driver atl1e_driver __pci_driver
Initial value:
 {
        .ids      = atl1e_pci_tbl,
        .id_count = (sizeof(atl1e_pci_tbl) / sizeof(atl1e_pci_tbl[0])),
        .probe    = atl1e_probe,
        .remove   = atl1e_remove,
}

Definition at line 1239 of file atl1e.c.