iPXE
|
VIA Rhine 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 "rhine.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
static int | rhine_mii_read (struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg) |
Read from MII register. More... | |
static int | rhine_mii_write (struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg, unsigned int data) |
Write to MII register. More... | |
static int | rhine_mii_autopoll (struct rhine_nic *rhn) |
Enable auto-polling. More... | |
static int | rhine_reset (struct rhine_nic *rhn) |
Reset hardware. More... | |
static void | rhine_enable_mmio (struct rhine_nic *rhn, int revision) |
Enable MMIO register access. More... | |
static int | rhine_reload_eeprom (struct rhine_nic *rhn) |
Reload EEPROM contents. More... | |
static void | rhine_check_link (struct net_device *netdev) |
Check link state. More... | |
static int | rhine_create_ring (struct rhine_nic *rhn, struct rhine_ring *ring) |
Create descriptor ring. More... | |
static void | rhine_destroy_ring (struct rhine_nic *rhn, struct rhine_ring *ring) |
Destroy descriptor ring. More... | |
static void | rhine_refill_rx (struct rhine_nic *rhn) |
Refill RX descriptor ring. More... | |
static int | rhine_open (struct net_device *netdev) |
Open network device. More... | |
static void | rhine_close (struct net_device *netdev) |
Close network device. More... | |
static int | rhine_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | rhine_poll_tx (struct net_device *netdev) |
Poll for completed packets. More... | |
static void | rhine_poll_rx (struct net_device *netdev) |
Poll for received packets. More... | |
static void | rhine_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static void | rhine_irq (struct net_device *netdev, int enable) |
Enable or disable interrupts. More... | |
static int | rhine_probe (struct pci_device *pci) |
Probe PCI device. More... | |
static void | rhine_remove (struct pci_device *pci) |
Remove PCI device. More... | |
Variables | |
static struct mii_operations | rhine_mii_operations |
Rhine MII operations. More... | |
static struct net_device_operations | rhine_operations |
Rhine network device operations. More... | |
static struct pci_device_id | rhine_nics [] |
Rhine PCI device IDs. More... | |
struct pci_driver rhine_driver | __pci_driver |
Rhine PCI driver. More... | |
VIA Rhine network driver.
Definition in file rhine.c.
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
|
static |
Read from MII register.
mdio | MII interface |
phy | PHY address |
reg | Register address |
value | Data read, or negative error |
Definition at line 57 of file rhine.c.
References container_of, cr, DBGC, DBGC2, ETIMEDOUT, rhine_nic::mdio, readb(), readw(), reg, rhine_nic::regs, RHINE_MII_ADDR, RHINE_MII_CR, RHINE_MII_CR_RDEN, RHINE_MII_RDWR, RHINE_TIMEOUT_US, timeout(), udelay(), 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 91 of file rhine.c.
References container_of, cr, data, DBGC, DBGC2, ETIMEDOUT, rhine_nic::mdio, readb(), reg, rhine_nic::regs, RHINE_MII_ADDR, RHINE_MII_CR, RHINE_MII_CR_WREN, RHINE_MII_RDWR, RHINE_TIMEOUT_US, timeout(), udelay(), writeb(), and writew.
|
static |
Enable auto-polling.
rhn | Rhine device |
rc | Return status code |
This is voodoo. There seems to be no documentation on exactly what we are waiting for, or why we have to do anything other than simply turn the feature on.
Definition at line 135 of file rhine.c.
References addr, DBGC, ETIMEDOUT, MII_BMSR, readb(), rhine_nic::regs, RHINE_MII_ADDR, RHINE_MII_ADDR_MDONE, RHINE_MII_ADDR_MSRCEN, RHINE_MII_CR, RHINE_MII_CR_AUTOPOLL, RHINE_TIMEOUT_US, timeout(), udelay(), and writeb().
Referenced by rhine_open().
|
static |
Reset hardware.
rhn | Rhine device |
rc | Return status code |
We're using PIO because this might reset the MMIO enable bit.
Definition at line 173 of file rhine.c.
References DBGC, ETIMEDOUT, inb(), rhine_nic::ioaddr, outb, RHINE_CR1, RHINE_CR1_RESET, RHINE_TIMEOUT_US, timeout(), and udelay().
Referenced by rhine_probe(), and rhine_remove().
|
static |
Enable MMIO register access.
rhn | Rhine device |
revision | Card revision |
Definition at line 200 of file rhine.c.
References inb(), rhine_nic::ioaddr, outb, revision, RHINE_CHIPCFG_A, RHINE_CHIPCFG_A_MMIO, RHINE_CHIPCFG_D, RHINE_CHIPCFG_D_MMIO, and RHINE_REVISION_OLD.
Referenced by rhine_probe().
|
static |
Reload EEPROM contents.
rhn | Rhine device |
rc | Return status code |
We're using PIO because this might reset the MMIO enable bit.
Definition at line 222 of file rhine.c.
References DBGC, ETIMEDOUT, inb(), rhine_nic::ioaddr, outb, RHINE_EEPROM_CTRL, RHINE_EEPROM_CTRL_RELOAD, RHINE_TIMEOUT_US, timeout(), and udelay().
Referenced by rhine_probe().
|
static |
Check link state.
netdev | Network device |
Definition at line 255 of file rhine.c.
References DBGC, EIO, netdev, netdev_link_down(), netdev_link_err(), netdev_link_up(), net_device::priv, readb(), rhine_nic::regs, RHINE_MII_SR, RHINE_MII_SR_LINKPOLL, and RHINE_MII_SR_PHYERR.
Referenced by rhine_open(), rhine_poll(), and rhine_probe().
|
static |
Create descriptor ring.
rhn | Rhine device |
ring | Descriptor ring |
rc | Return status code |
Definition at line 287 of file rhine.c.
References address, rhine_ring::count, cpu_to_le32, DBGC, rhine_ring::desc, ENOMEM, len, malloc_phys(), memset(), next, rhine_descriptor::next, rhine_ring::reg, rhine_nic::regs, RHINE_RING_ALIGN, virt_to_bus(), and writel().
Referenced by rhine_open().
|
static |
Destroy descriptor ring.
rhn | Rhine device |
ring | Descriptor ring |
Definition at line 323 of file rhine.c.
References rhine_ring::cons, rhine_ring::count, rhine_ring::desc, free_phys(), len, NULL, rhine_ring::prod, rhine_ring::reg, rhine_nic::regs, and writel().
Referenced by rhine_close(), and rhine_open().
|
static |
Refill RX descriptor ring.
rhn | Rhine device |
Definition at line 342 of file rhine.c.
References address, alloc_iob(), rhine_descriptor::buffer, rhine_ring::cons, cpu_to_le32, io_buffer::data, DBGC2, rhine_descriptor::des0, rhine_descriptor::des1, rhine_ring::desc, rhine_ring::prod, RHINE_DES0_OWN, RHINE_DES1_CHAIN, RHINE_DES1_IC, RHINE_DES1_SIZE, RHINE_RX_MAX_LEN, RHINE_RXDESC_NUM, rhine_nic::rx, rhine_nic::rx_iobuf, virt_to_bus(), and wmb().
Referenced by rhine_open(), and rhine_poll().
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 383 of file rhine.c.
References rhine_nic::cr1, mdelay(), netdev, net_device::priv, rc, rhine_nic::regs, rhine_check_link(), RHINE_CR0, RHINE_CR0_RXEN, RHINE_CR0_STARTNIC, RHINE_CR0_TXEN, RHINE_CR1, RHINE_CR1_FDX, rhine_create_ring(), rhine_destroy_ring(), rhine_mii_autopoll(), RHINE_RCR, RHINE_RCR_BCAST_ACCEPT, RHINE_RCR_PHYS_ACCEPT, RHINE_RCR_RUNT_ACCEPT, rhine_refill_rx(), rhine_nic::rx, rhine_nic::tx, and writeb().
|
static |
Close network device.
netdev | Network device |
Definition at line 435 of file rhine.c.
References free_iob(), netdev, NULL, net_device::priv, rhine_nic::regs, RHINE_CR0, RHINE_CR0_STOPNIC, rhine_destroy_ring(), RHINE_IMR0, RHINE_IMR1, RHINE_RXDESC_NUM, rhine_nic::rx, rhine_nic::rx_iobuf, rhine_nic::tx, and writeb().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 467 of file rhine.c.
References address, rhine_descriptor::buffer, rhine_ring::cons, cpu_to_le32, rhine_nic::cr1, io_buffer::data, DBGC2, rhine_descriptor::des0, rhine_descriptor::des1, rhine_ring::desc, ENOBUFS, ETH_ZLEN, iob_len(), iob_pad(), netdev, net_device::priv, rhine_ring::prod, rhine_nic::regs, RHINE_CR1, RHINE_CR1_TXPOLL, RHINE_DES0_OWN, RHINE_DES1_CHAIN, RHINE_DES1_IC, RHINE_DES1_SIZE, RHINE_TDES1_EDP, RHINE_TDES1_STP, RHINE_TXDESC_NUM, rhine_nic::tx, virt_to_bus(), wmb(), and writeb().
|
static |
Poll for completed packets.
netdev | Network device |
Definition at line 508 of file rhine.c.
References rhine_ring::cons, cpu_to_le32, DBGC, DBGC2, des0, rhine_descriptor::des0, rhine_ring::desc, EIO, le32_to_cpu, netdev, netdev_tx_complete_next(), netdev_tx_complete_next_err(), net_device::priv, rhine_ring::prod, RHINE_DES0_OWN, RHINE_TDES0_TERR, RHINE_TXDESC_NUM, and rhine_nic::tx.
Referenced by rhine_poll().
|
static |
Poll for received packets.
netdev | Network device |
Definition at line 544 of file rhine.c.
References rhine_ring::cons, cpu_to_le32, DBGC, DBGC2, des0, rhine_descriptor::des0, rhine_ring::desc, EIO, iob_put, le32_to_cpu, len, netdev, netdev_rx(), netdev_rx_err(), NULL, net_device::priv, rhine_ring::prod, RHINE_DES0_GETSIZE, RHINE_DES0_OWN, RHINE_RDES0_RXOK, RHINE_RXDESC_NUM, rhine_nic::rx, and rhine_nic::rx_iobuf.
Referenced by rhine_poll().
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 589 of file rhine.c.
References DBGC, EIO, ENOBUFS, netdev, netdev_rx_err(), netdev_tx_err(), NULL, net_device::priv, readb(), rhine_nic::regs, rhine_check_link(), RHINE_ISR0, RHINE_ISR0_MIBOVFL, RHINE_ISR0_PCIERR, RHINE_ISR0_RXDONE, RHINE_ISR0_RXERR, RHINE_ISR0_RXRINGERR, RHINE_ISR0_TXDONE, RHINE_ISR0_TXERR, RHINE_ISR0_TXRINGERR, RHINE_ISR1, RHINE_ISR1_GPI, RHINE_ISR1_PORTSTATE, RHINE_ISR1_RXFIFOOVFL, RHINE_ISR1_RXFIFOUNFL, RHINE_ISR1_RXNOBUF, RHINE_ISR1_TXABORT, RHINE_ISR1_TXFIFOUNFL, rhine_poll_rx(), rhine_poll_tx(), rhine_refill_rx(), and writeb().
|
static |
Enable or disable interrupts.
netdev | Network device |
enable | Interrupts should be enabled |
Definition at line 642 of file rhine.c.
References netdev, net_device::priv, RHINE_IMR0, RHINE_IMR1, and writeb().
|
static |
Probe PCI device.
pci | PCI device |
rc | Return status code |
Definition at line 678 of file rhine.c.
References adjust_pci_device(), alloc_etherdev(), DBGC, pci_device::dev, net_device::dev, ENOMEM, ETH_ALEN, net_device::hw_addr, pci_device::ioaddr, rhine_nic::ioaddr, rhine_nic::mdio, mdio_init(), pci_device::membase, memset(), rhine_nic::mii, mii_init(), mii_read(), mii_reset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), pci_ioremap(), pci_read_config_byte(), PCI_REVISION, pci_set_drvdata(), net_device::priv, rc, readb(), register_netdev(), rhine_nic::regs, revision, RHINE_BAR_SIZE, rhine_check_link(), rhine_enable_mmio(), RHINE_MAC, rhine_mii_operations, rhine_operations, rhine_reload_eeprom(), rhine_reset(), RHINE_RXDESC_NUM, RHINE_RXQUEUE_BASE, RHINE_TXDESC_NUM, RHINE_TXQUEUE_BASE, rhine_nic::rx, strerror(), and rhine_nic::tx.
|
static |
Remove PCI device.
pci | PCI device |
Definition at line 761 of file rhine.c.
References netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, rhine_reset(), and unregister_netdev().
|
static |
Rhine MII operations.
Definition at line 120 of file rhine.c.
Referenced by rhine_probe().
|
static |
Rhine network device operations.
Definition at line 657 of file rhine.c.
Referenced by rhine_probe().
|
static |
Rhine PCI device IDs.
struct pci_driver rhine_driver __pci_driver |
Rhine PCI driver.