iPXE
|
VIA Velocity network driver. More...
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/mii.h>
#include "velocity.h"
Go to the source code of this file.
Macros | |
#define | velocity_setbit(_reg, _mask) writeb ( readb ( _reg ) | _mask, _reg ) |
#define | virt_to_le32bus(x) ( cpu_to_le32 ( virt_to_bus ( x ) ) ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
static int | velocity_autopoll_stop (struct velocity_nic *vlc) |
Stop MII auto-polling. More... | |
static int | velocity_autopoll_start (struct velocity_nic *vlc) |
Start MII auto-polling. More... | |
static int | velocity_mii_read (struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg) |
Read from MII register. More... | |
static int | velocity_mii_write (struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg, unsigned int data) |
Write to MII register. More... | |
static void | velocity_set_link (struct velocity_nic *vlc) |
Set Link speed. More... | |
static int | velocity_reload_eeprom (struct velocity_nic *vlc) |
Reload eeprom contents. More... | |
static int | velocity_reset (struct velocity_nic *vlc) |
Reset hardware. More... | |
static void | velocity_check_link (struct net_device *netdev) |
Check link state. More... | |
static int | velocity_alloc_rings (struct velocity_nic *vlc) |
Allocate descriptor rings. More... | |
static void | velocity_refill_rx (struct velocity_nic *vlc) |
Refill receive descriptor ring. More... | |
static int | velocity_open (struct net_device *netdev) |
Open network device. More... | |
static void | velocity_close (struct net_device *netdev) |
Close network device. More... | |
static int | velocity_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | velocity_poll_rx (struct velocity_nic *vlc) |
Poll for received packets. More... | |
static void | velocity_poll_tx (struct velocity_nic *vlc) |
Poll for completed packets. More... | |
static void | velocity_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static void | velocity_irq (struct net_device *netdev, int enable) |
Enable or disable interrupts. More... | |
static int | velocity_probe (struct pci_device *pci) |
Probe PCI device. More... | |
static void | velocity_remove (struct pci_device *pci) |
Remove PCI device. More... | |
Variables | |
static struct mii_operations | velocity_mii_operations |
Velocity MII operations. More... | |
static struct net_device_operations | velocity_operations |
Velocity network device operations. More... | |
static struct pci_device_id | velocity_nics [] |
Velocity PCI device IDs. More... | |
struct pci_driver velocity_driver | __pci_driver |
Velocity PCI driver. More... | |
VIA Velocity network driver.
Definition in file velocity.c.
Definition at line 36 of file velocity.c.
#define virt_to_le32bus | ( | x | ) | ( cpu_to_le32 ( virt_to_bus ( x ) ) ) |
Definition at line 37 of file velocity.c.
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
|
static |
Stop MII auto-polling.
vlc | Velocity device |
rc | Return status code |
Definition at line 58 of file velocity.c.
References DBGC, ETIMEDOUT, readb(), velocity_nic::regs, timeout(), udelay(), VELOCITY_MIICR, VELOCITY_MIISR, VELOCITY_MIISR_IDLE, VELOCITY_TIMEOUT_US, and writeb().
Referenced by velocity_mii_read(), and velocity_mii_write().
|
static |
Start MII auto-polling.
vlc | Velocity device |
rc | Return status code |
Definition at line 82 of file velocity.c.
References DBGC, ETIMEDOUT, readb(), velocity_nic::regs, timeout(), udelay(), VELOCITY_MIICR, VELOCITY_MIICR_MAUTO, VELOCITY_MIISR, VELOCITY_MIISR_IDLE, VELOCITY_TIMEOUT_US, and writeb().
Referenced by velocity_check_link(), velocity_mii_read(), velocity_mii_write(), and velocity_open().
|
static |
Read from MII register.
mdio | MII interface |
phy | PHY address |
reg | Register address |
value | Data read, or negative error |
Definition at line 108 of file velocity.c.
References container_of, DBGC, DBGC2, ETIMEDOUT, velocity_nic::mdio, readb(), readw(), reg, velocity_nic::regs, result, timeout(), udelay(), velocity_autopoll_start(), velocity_autopoll_stop(), VELOCITY_MIIADDR, VELOCITY_MIICR, VELOCITY_MIICR_RCMD, VELOCITY_MIIDATA, velocity_setbit, VELOCITY_TIMEOUT_US, and writeb().
|
static |
Write to MII register.
mdio | MII interface |
phy | PHY address |
reg | Register address |
data | Data to write |
rc | Return status code |
Definition at line 151 of file velocity.c.
References container_of, data, DBGC, DBGC2, ETIMEDOUT, velocity_nic::mdio, readb(), reg, velocity_nic::regs, timeout(), udelay(), velocity_autopoll_start(), velocity_autopoll_stop(), VELOCITY_MIIADDR, VELOCITY_MIICR, VELOCITY_MIICR_WCMD, VELOCITY_MIIDATA, velocity_setbit, VELOCITY_TIMEOUT_US, writeb(), and writew.
|
static |
Set Link speed.
vlc | Velocity device |
Definition at line 197 of file velocity.c.
References ADVERTISE_1000FULL, ADVERTISE_1000HALF, BMCR_SPEED1000, velocity_nic::mii, MII_BMCR, MII_CTRL1000, mii_read(), mii_write(), and tmp.
Referenced by velocity_probe().
|
static |
Reload eeprom contents.
vlc | Velocity device |
Definition at line 223 of file velocity.c.
References DBGC, ETIMEDOUT, readb(), velocity_nic::regs, timeout(), udelay(), VELOCITY_EECSR, VELOCITY_EECSR_RELOAD, velocity_setbit, and VELOCITY_TIMEOUT_US.
Referenced by velocity_probe().
|
static |
Reset hardware.
vlc | Velocity device |
rc | Return status code |
Definition at line 247 of file velocity.c.
References DBGC, EINVAL, readb(), velocity_nic::regs, timeout(), tmp, udelay(), VELOCITY_CFGA, VELOCITY_CFGA_PACPI, VELOCITY_CR1_SFRST, VELOCITY_CRS1, velocity_setbit, VELOCITY_STICKY, VELOCITY_STICKY_DS0, VELOCITY_STICKY_DS1, VELOCITY_TIMEOUT_US, and writeb().
Referenced by velocity_probe(), and velocity_remove().
|
static |
Check link state.
netdev | Network device |
Definition at line 288 of file velocity.c.
References DBGC, netdev, netdev_link_down(), netdev_link_up(), net_device::priv, readb(), velocity_nic::regs, velocity_autopoll_start(), VELOCITY_PHYSTS0, and VELOCITY_PHYSTS0_LINK.
Referenced by velocity_open(), and velocity_poll().
|
static |
Allocate descriptor rings.
vlc | Velocity device |
rc | Return status code |
Definition at line 316 of file velocity.c.
References DBGC2, ENOMEM, free_phys(), malloc_phys(), memset(), rc, velocity_nic::regs, velocity_nic::rx_commit, velocity_nic::rx_cons, velocity_nic::rx_prod, velocity_nic::rx_ring, velocity_nic::tx_cons, velocity_nic::tx_prod, velocity_nic::tx_ring, VELOCITY_RING_ALIGN, VELOCITY_RXDESC_ADDR_LO, VELOCITY_RXDESC_NUM, VELOCITY_RXDESC_SIZE, VELOCITY_RXDESCNUM, VELOCITY_TXDESC_ADDR_LO0, VELOCITY_TXDESC_NUM, VELOCITY_TXDESC_SIZE, VELOCITY_TXDESCNUM, virt_to_bus(), writel(), and writew.
Referenced by velocity_open().
|
static |
Refill receive descriptor ring.
vlc | Velocity device |
Definition at line 370 of file velocity.c.
References alloc_iob(), cpu_to_le32, data, DBGC2, desc, velocity_nic::regs, velocity_nic::rx_buffs, velocity_nic::rx_commit, velocity_nic::rx_cons, velocity_nic::rx_prod, velocity_nic::rx_ring, VELOCITY_DES0_OWN, VELOCITY_DES2_IC, VELOCITY_DES2_SIZE, VELOCITY_RX_MAX_LEN, VELOCITY_RXDESC_NUM, VELOCITY_RXDESC_RESIDUECNT, virt_to_le32bus, wmb(), and writew.
Referenced by velocity_open(), and velocity_poll().
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 426 of file velocity.c.
References DBGC, DBGC2, netdev, net_device::priv, rc, readb(), velocity_nic::regs, velocity_alloc_rings(), velocity_autopoll_start(), velocity_check_link(), VELOCITY_CR0_RXON, VELOCITY_CR0_START, VELOCITY_CR0_STOP, VELOCITY_CR0_TXON, VELOCITY_CR1_DPOLL, VELOCITY_CRC0, VELOCITY_CRS0, VELOCITY_IMR0, VELOCITY_IMR1, VELOCITY_RCR, velocity_refill_rx(), VELOCITY_RXQCSR_RUN, VELOCITY_RXQCSR_WAK, VELOCITY_RXQCSRS, VELOCITY_TXQCSRS, VELOCITY_TXQCSRS_RUN0, writeb(), and writew.
|
static |
Close network device.
netdev | Network device |
Definition at line 473 of file velocity.c.
References free_iob(), free_phys(), netdev, NULL, net_device::priv, velocity_nic::regs, velocity_nic::rx_buffs, velocity_nic::rx_cons, velocity_nic::rx_prod, velocity_nic::rx_ring, velocity_nic::tx_cons, velocity_nic::tx_prod, velocity_nic::tx_ring, VELOCITY_CR0_RXON, VELOCITY_CR0_STOP, VELOCITY_CR0_TXON, VELOCITY_CRC0, VELOCITY_CRS0, VELOCITY_RXDESC_ADDR_LO, VELOCITY_RXDESC_NUM, VELOCITY_RXDESC_SIZE, VELOCITY_RXDESCNUM, VELOCITY_TXDESC_ADDR_LO0, VELOCITY_TXDESC_SIZE, VELOCITY_TXDESCNUM, writeb(), writel(), and writew.
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 517 of file velocity.c.
References cpu_to_le32, io_buffer::data, DBGC2, desc, ETH_ZLEN, iob_len(), iob_pad(), netdev, net_device::priv, velocity_nic::regs, velocity_nic::tx_prod, velocity_nic::tx_ring, VELOCITY_DES0_OWN, VELOCITY_DES1_FRAG, VELOCITY_DES1_INTR, VELOCITY_DES1_TCPLS, VELOCITY_DES2_SIZE, velocity_setbit, VELOCITY_TXDESC_NUM, VELOCITY_TXQCSRS, VELOCITY_TXQCSRS_WAK0, virt_to_le32bus, and wmb().
|
static |
Poll for received packets.
vlc | Velocity device |
Definition at line 557 of file velocity.c.
References cpu_to_le32, io_buffer::data, DBGC, DBGC2, DBGC_HD, des0, desc, EINVAL, iob_put, len, velocity_nic::netdev, netdev_rx(), netdev_rx_err(), velocity_nic::rx_buffs, velocity_nic::rx_cons, velocity_nic::rx_prod, velocity_nic::rx_ring, VELOCITY_DES0_OWN, VELOCITY_DES0_RMBC, VELOCITY_DES0_RX_ERR, VELOCITY_DES0_RXOK, and VELOCITY_RXDESC_NUM.
Referenced by velocity_poll().
|
static |
Poll for completed packets.
vlc | Velocity device |
Definition at line 614 of file velocity.c.
References DBGC2, desc, EINVAL, le32_to_cpu, velocity_nic::netdev, netdev_tx_complete_next(), netdev_tx_complete_next_err(), velocity_nic::tx_cons, velocity_nic::tx_prod, velocity_nic::tx_ring, VELOCITY_DES0_OWN, VELOCITY_DES0_TERR, and VELOCITY_TXDESC_NUM.
Referenced by velocity_poll().
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 647 of file velocity.c.
References DBGC2, netdev, net_device::priv, readb(), velocity_nic::regs, velocity_check_link(), VELOCITY_ISR0, VELOCITY_ISR1, VELOCITY_ISR1_SRCI, velocity_poll_rx(), velocity_poll_tx(), velocity_refill_rx(), VELOCITY_RXQCSR_RUN, VELOCITY_RXQCSR_WAK, VELOCITY_RXQCSRS, and writew.
|
static |
Enable or disable interrupts.
netdev | Network device |
enable | Interrupts should be enabled |
Definition at line 679 of file velocity.c.
References DBGC, netdev, net_device::priv, velocity_nic::regs, VELOCITY_CR3_GINTMSK1, VELOCITY_CRC3, VELOCITY_CRS3, and writeb().
|
static |
Probe PCI device.
pci | PCI device |
rc | Return status code |
Definition at line 716 of file velocity.c.
References adjust_pci_device(), alloc_etherdev(), DBGC, pci_device::dev, net_device::dev, ENOMEM, net_device::hw_addr, velocity_nic::mdio, mdio_init(), pci_device::membase, velocity_nic::mii, mii_init(), mii_reset(), netdev, velocity_nic::netdev, netdev_init(), netdev_nullify(), netdev_put(), pci_ioremap(), pci_set_drvdata(), net_device::priv, rc, readb(), register_netdev(), velocity_nic::regs, strerror(), VELOCITY_BAR_SIZE, VELOCITY_MAC0, VELOCITY_MAC1, VELOCITY_MAC2, VELOCITY_MAC3, VELOCITY_MAC4, VELOCITY_MAC5, velocity_mii_operations, velocity_operations, velocity_reload_eeprom(), velocity_reset(), and velocity_set_link().
|
static |
Remove PCI device.
pci | PCI device |
Definition at line 788 of file velocity.c.
References netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, unregister_netdev(), and velocity_reset().
|
static |
Velocity MII operations.
Definition at line 187 of file velocity.c.
Referenced by velocity_probe().
|
static |
Velocity network device operations.
Definition at line 695 of file velocity.c.
Referenced by velocity_probe().
|
static |
struct pci_driver velocity_driver __pci_driver |
Velocity PCI driver.
Definition at line 809 of file velocity.c.