iPXE
|
Exablaze ExaNIC driver. More...
#include <stdint.h>
#include <string.h>
#include <strings.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/umalloc.h>
#include <ipxe/pci.h>
#include "exanic.h"
Go to the source code of this file.
Macros | |
#define | EIO_ABORTED __einfo_error ( EINFO_EIO_ABORTED ) |
#define | EINFO_EIO_ABORTED __einfo_uniqify ( EINFO_EIO, 0x01, "Frame aborted" ) |
#define | EIO_CORRUPT __einfo_error ( EINFO_EIO_CORRUPT ) |
#define | EINFO_EIO_CORRUPT __einfo_uniqify ( EINFO_EIO, 0x02, "CRC incorrect" ) |
#define | EIO_HWOVFL __einfo_error ( EINFO_EIO_HWOVFL ) |
#define | EINFO_EIO_HWOVFL __einfo_uniqify ( EINFO_EIO, 0x03, "Hardware overflow" ) |
#define | EIO_STATUS(status) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | exanic_write_base (physaddr_t addr, void *reg) |
Write DMA base address register. More... | |
static void | exanic_clear_base (void *reg) |
Clear DMA base address register. More... | |
static void | exanic_reset (struct exanic *exanic) |
Reset hardware. More... | |
static int | exanic_i2c_read_bit (struct bit_basher *basher, unsigned int bit_id) |
Read I2C line status. More... | |
static void | exanic_i2c_write_bit (struct bit_basher *basher, unsigned int bit_id, unsigned long data) |
Write I2C line status. More... | |
static int | exanic_try_init_eeprom (struct exanic *exanic, struct exanic_i2c_config *i2cfg) |
Initialise EEPROM. More... | |
static int | exanic_init_eeprom (struct exanic *exanic) |
Initialise EEPROM. More... | |
static int | exanic_fetch_mac (struct exanic *exanic) |
Fetch base MAC address. More... | |
static void | exanic_check_link (struct net_device *netdev) |
Check link state. More... | |
static void | exanic_expired (struct retry_timer *timer, int over __unused) |
Check link state periodically. More... | |
static int | exanic_open (struct net_device *netdev) |
Open network device. More... | |
static void | exanic_close (struct net_device *netdev) |
Close network device. More... | |
static int | exanic_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | exanic_poll_tx (struct net_device *netdev) |
Poll for completed packets. More... | |
static void | exanic_poll_rx (struct net_device *netdev) |
Poll for received packets. More... | |
static void | exanic_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static int | exanic_probe_port (struct exanic *exanic, struct device *dev, unsigned int index) |
Probe port. More... | |
static void | exanic_remove_port (struct exanic *exanic, unsigned int index) |
Probe port. More... | |
static int | exanic_probe (struct pci_device *pci) |
Probe PCI device. More... | |
static void | exanic_remove (struct pci_device *pci) |
Remove PCI device. More... | |
Variables | |
static struct bit_basher_operations | exanic_i2c_basher_ops |
I2C bit-bashing interface operations. More... | |
static struct exanic_i2c_config | exanic_i2cfgs [] |
Possible I2C bus configurations. More... | |
static struct net_device_operations | exanic_operations |
ExaNIC network device operations. More... | |
static struct pci_device_id | exanic_ids [] |
ExaNIC PCI device IDs. More... | |
struct pci_driver exanic_driver | __pci_driver |
ExaNIC PCI driver. More... | |
Exablaze ExaNIC driver.
Definition in file exanic.c.
#define EIO_ABORTED __einfo_error ( EINFO_EIO_ABORTED ) |
#define EINFO_EIO_ABORTED __einfo_uniqify ( EINFO_EIO, 0x01, "Frame aborted" ) |
#define EIO_CORRUPT __einfo_error ( EINFO_EIO_CORRUPT ) |
#define EINFO_EIO_CORRUPT __einfo_uniqify ( EINFO_EIO, 0x02, "CRC incorrect" ) |
#define EIO_HWOVFL __einfo_error ( EINFO_EIO_HWOVFL ) |
#define EINFO_EIO_HWOVFL __einfo_uniqify ( EINFO_EIO, 0x03, "Hardware overflow" ) |
#define EIO_STATUS | ( | status | ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Write DMA base address register.
addr | DMA base address |
reg | Register |
Definition at line 67 of file exanic.c.
References addr, EXANIC_DMA_32_BIT, reg, and writel().
Referenced by exanic_open(), and exanic_probe().
|
inlinestatic |
Clear DMA base address register.
reg | Register |
Definition at line 92 of file exanic.c.
Referenced by exanic_close(), and exanic_reset().
|
static |
Reset hardware.
exanic | ExaNIC device |
Definition at line 111 of file exanic.c.
References exanic_clear_base(), EXANIC_MAX_PORTS, EXANIC_PORT_ENABLE, EXANIC_PORT_IRQ, EXANIC_PORT_REGS, EXANIC_PORT_RX_BASE, EXANIC_TXF_BASE, exanic::regs, and writel().
Referenced by exanic_probe(), and exanic_remove().
|
static |
Read I2C line status.
basher | Bit-bashing interface |
bit_id | Bit number |
zero | Input is a logic 0 |
non-zero | Input is a logic 1 |
Definition at line 142 of file exanic.c.
References assert(), i2c_bit_basher::basher, exanic::basher, container_of, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, EXANIC_I2C, exanic_i2c_config::getsda, I2C_BIT_SDA, exanic::i2cfg, readl(), and exanic::regs.
|
static |
Write I2C line status.
basher | Bit-bashing interface |
bit_id | Bit number |
data | Value to write |
Definition at line 167 of file exanic.c.
References assert(), i2c_bit_basher::basher, exanic::basher, container_of, data, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, EXANIC_I2C, I2C_BIT_SCL, I2C_BIT_SDA, exanic::i2cfg, readl(), exanic::regs, exanic_i2c_config::setscl, exanic_i2c_config::setsda, and writel().
|
static |
Initialise EEPROM.
exanic | ExaNIC device |
i2cfg | I2C bus configuration |
rc | Return status code |
Definition at line 212 of file exanic.c.
References exanic::basher, DBGC, DBGC2, exanic::eeprom, EXANIC_EEPROM_ADDRESS, exanic_i2c_basher_ops, exanic_i2c_config::getsda, i2c_bit_basher::i2c, i2c_check_presence(), exanic::i2cfg, init_i2c_bit_basher(), init_i2c_eeprom(), memcpy(), rc, exanic_i2c_config::setscl, and exanic_i2c_config::setsda.
Referenced by exanic_init_eeprom().
|
static |
Initialise EEPROM.
exanic | ExaNIC device |
rc | Return status code |
Definition at line 250 of file exanic.c.
References DBGC, ENODEV, exanic_i2cfgs, exanic_try_init_eeprom(), and rc.
Referenced by exanic_fetch_mac().
|
static |
Fetch base MAC address.
exanic | ExaNIC device |
rc | Return status code |
Definition at line 273 of file exanic.c.
References exanic::basher, DBGC, exanic::eeprom, exanic_init_eeprom(), i2c_bit_basher::i2c, exanic::mac, rc, i2c_interface::read, and strerror().
Referenced by exanic_probe().
|
static |
Check link state.
netdev | Network device |
Definition at line 304 of file exanic.c.
References DBGC, EXANIC_PORT_SPEED, EXANIC_PORT_STATUS, EXANIC_PORT_STATUS_LINK, net_device::name, netdev, netdev_link_down(), netdev_link_up(), port, net_device::priv, readl(), exanic_port::speed, and status.
Referenced by exanic_expired(), and exanic_probe_port().
|
static |
Check link state periodically.
retry | Link state check timer |
over | Failure indicator |
Definition at line 330 of file exanic.c.
References assert(), container_of, DBGC, EXANIC_CAPS_SPEED_MASK, exanic_check_link(), EXANIC_LINK_INTERVAL, EXANIC_PORT_SPEED, ffs, index, net_device::name, netdev, netdev_link_ok(), port, start_timer_fixed(), and writel().
Referenced by exanic_probe_port().
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 383 of file exanic.c.
References EXANIC_LINK_INTERVAL, EXANIC_PORT_ENABLE, EXANIC_PORT_ENABLE_ENABLED, EXANIC_PORT_FLAGS, EXANIC_PORT_FLAGS_PROMISC, EXANIC_PORT_RX_BASE, EXANIC_PORT_SPEED, EXANIC_RX_LEN, EXANIC_TYPE_RAW, exanic_write_base(), memset_user(), netdev, phys_to_bus(), port, net_device::priv, start_timer_fixed(), tx, user_to_phys(), wmb(), writeb(), writel(), and writew.
|
static |
Close network device.
netdev | Network device |
Definition at line 437 of file exanic.c.
References ECANCELED, exanic_clear_base(), EXANIC_PORT_ENABLE, EXANIC_PORT_RX_BASE, netdev, netdev_rx_err(), NULL, port, net_device::priv, stop_timer(), wmb(), and writel().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 464 of file exanic.c.
References data, io_buffer::data, DBGC, DBGC2, ENOBUFS, ENOTSUP, EXANIC_PORT_TX_COMMAND, iob_len(), len, net_device::name, netdev, offset, offsetof, port, net_device::priv, src, tx, typeof(), wmb(), writeb(), writel(), and writew.
|
static |
Poll for completed packets.
netdev | Network device |
Definition at line 523 of file exanic.c.
References DBGC2, net_device::name, netdev, netdev_tx_complete_next(), port, and net_device::priv.
Referenced by exanic_poll().
|
static |
Poll for received packets.
netdev | Network device |
Definition at line 540 of file exanic.c.
References alloc_iob(), copy_from_user(), data, DBGC, DBGC2, desc, EIO_STATUS, ENOBUFS, ERANGE, EXANIC_MAX_RX_LEN, EXANIC_RX_LEN, EXANIC_STATUS_ERROR_MASK, iob_put, iob_tailroom(), iob_unput, len, net_device::name, netdev, netdev_rx(), netdev_rx_err(), NULL, offset, offsetof, port, net_device::priv, rmb, rx, strerror(), and typeof().
Referenced by exanic_poll().
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 633 of file exanic.c.
References exanic_poll_rx(), exanic_poll_tx(), and netdev.
|
static |
Probe port.
exanic | ExaNIC device |
dev | Parent device |
index | Port number |
rc | Return status code |
Definition at line 665 of file exanic.c.
References alloc_etherdev(), assert(), exanic::caps, DBGC, net_device::dev, ENOMEM, ETH_ALEN, EXANIC_CAPS_SPEED_MASK, exanic_check_link(), exanic_expired(), EXANIC_MAX_TX_LEN, exanic_operations, EXANIC_PORT_REGS, EXANIC_PORT_SPEED, EXANIC_PORT_STATUS, EXANIC_PORT_STATUS_ABSENT, EXANIC_PORT_TX_LEN, EXANIC_PORT_TX_OFFSET, EXANIC_RX_LEN, EXANIC_TXF_SLOT, net_device::hw_addr, index, exanic::mac, memcpy(), memset(), net_device::name, netdev, netdev_init(), netdev_nullify(), netdev_put(), port, exanic::port, net_device::priv, rc, readl(), net_device::refcnt, register_netdev(), exanic::regs, status, exanic::tx, exanic::txf, ufree(), umalloc(), unregister_netdev(), and user_to_phys().
Referenced by exanic_probe().
|
static |
Probe port.
exanic | ExaNIC device |
index | Port number |
Definition at line 757 of file exanic.c.
References index, netdev_nullify(), netdev_put(), port, exanic::port, ufree(), and unregister_netdev().
Referenced by exanic_probe(), and exanic_remove().
|
static |
Probe PCI device.
pci | PCI device |
rc | Return status code |
Definition at line 782 of file exanic.c.
References adjust_pci_device(), exanic::caps, DBGC, pci_device::dev, ENODEV, ENOMEM, eth_ntoa(), EXANIC_ALIGN, EXANIC_CAPS, exanic_fetch_mac(), EXANIC_MAX_PORTS, EXANIC_POWER, EXANIC_POWER_ON, exanic_probe_port(), EXANIC_REGS_BAR, EXANIC_REGS_LEN, exanic_remove_port(), exanic_reset(), EXANIC_TX_BAR, EXANIC_TXF_BASE, EXANIC_TXF_LEN, exanic_write_base(), free, free_phys(), iounmap(), exanic::mac, malloc_phys(), memset(), pci_bar_size(), pci_bar_start(), pci_ioremap(), pci_set_drvdata(), rc, readl(), exanic::regs, exanic::tx, exanic::txf, virt_to_bus(), writel(), and zalloc().
|
static |
Remove PCI device.
pci | PCI device |
Definition at line 873 of file exanic.c.
References EXANIC_MAX_PORTS, exanic_remove_port(), exanic_reset(), EXANIC_TXF_LEN, free, free_phys(), iounmap(), pci_get_drvdata(), exanic::regs, exanic::tx, and exanic::txf.
|
static |
I2C bit-bashing interface operations.
Definition at line 192 of file exanic.c.
Referenced by exanic_try_init_eeprom().
|
static |
Possible I2C bus configurations.
Definition at line 198 of file exanic.c.
Referenced by exanic_init_eeprom().
|
static |
ExaNIC network device operations.
Definition at line 643 of file exanic.c.
Referenced by exanic_probe_port().
|
static |
ExaNIC PCI device IDs.
struct pci_driver exanic_driver __pci_driver |
ExaNIC PCI driver.