iPXE
|
Myson Technology network card 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 "myson.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | myson_soft_reset (struct myson_nic *myson) |
Reset controller chip. More... | |
static int | myson_reload_config (struct myson_nic *myson) |
Reload configuration from EEPROM. More... | |
static int | myson_reset (struct myson_nic *myson) |
Reset hardware. More... | |
static int | myson_create_ring (struct myson_nic *myson, struct myson_ring *ring) |
Create descriptor ring. More... | |
static void | myson_destroy_ring (struct myson_nic *myson, struct myson_ring *ring) |
Destroy descriptor ring. More... | |
static void | myson_refill_rx (struct net_device *netdev) |
Refill receive descriptor ring. More... | |
static int | myson_open (struct net_device *netdev) |
Open network device. More... | |
static int | myson_wait_idle (struct myson_nic *myson) |
Wait for transmit and receive to become idle. More... | |
static void | myson_close (struct net_device *netdev) |
Close network device. More... | |
static int | myson_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | myson_poll_tx (struct net_device *netdev) |
Poll for completed packets. More... | |
static void | myson_poll_rx (struct net_device *netdev) |
Poll for received packets. More... | |
static void | myson_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static void | myson_irq (struct net_device *netdev, int enable) |
Enable or disable interrupts. More... | |
static int | myson_probe (struct pci_device *pci) |
Probe PCI device. More... | |
static void | myson_remove (struct pci_device *pci) |
Remove PCI device. More... | |
Variables | |
static struct net_device_operations | myson_operations |
Myson network device operations. More... | |
static struct pci_device_id | myson_nics [] |
Myson PCI device IDs. More... | |
struct pci_driver myson_driver | __pci_driver |
Myson PCI driver. More... | |
Myson Technology network card driver.
Definition in file myson.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Reset controller chip.
myson | Myson device |
rc | Return status code |
Definition at line 59 of file myson.c.
References DBGC, ETIMEDOUT, mdelay(), MYSON_BCR, MYSON_BCR_PBL_DEFAULT, MYSON_BCR_PBL_MASK, MYSON_BCR_RLE, MYSON_BCR_RME, MYSON_BCR_SWR, MYSON_BCR_WIE, MYSON_RESET_MAX_WAIT_MS, readl(), myson_nic::regs, and writel().
Referenced by myson_reset().
|
static |
Reload configuration from EEPROM.
myson | Myson device |
rc | Return status code |
Definition at line 98 of file myson.c.
References DBGC, ETIMEDOUT, mdelay(), MYSON_AUTOLD_MAX_WAIT_MS, MYSON_ROM_AUTOLD, MYSON_ROM_MII, readl(), myson_nic::regs, and writel().
Referenced by myson_reset().
|
static |
Reset hardware.
myson | Myson device |
rc | Return status code |
Definition at line 127 of file myson.c.
References MYSON_IMR, myson_reload_config(), myson_soft_reset(), rc, myson_nic::regs, and writel().
Referenced by myson_probe(), and myson_remove().
|
static |
Create descriptor ring.
myson | Myson device |
ring | Descriptor ring |
rc | Return status code |
Definition at line 158 of file myson.c.
References address, myson_ring::count, cpu_to_le32, DBGC, desc, myson_ring::desc, ENOMEM, ENOTSUP, free_phys(), len, malloc_phys(), memset(), MYSON_RING_ALIGN, next, NULL, rc, myson_ring::reg, myson_nic::regs, virt_to_bus(), and writel().
Referenced by myson_open().
|
static |
Destroy descriptor ring.
myson | Myson device |
ring | Descriptor ring |
Definition at line 212 of file myson.c.
References myson_ring::cons, myson_ring::count, myson_ring::desc, free_phys(), len, NULL, myson_ring::prod, myson_ring::reg, myson_nic::regs, and writel().
Referenced by myson_close(), and myson_open().
|
static |
Refill receive descriptor ring.
netdev | Network device |
Definition at line 231 of file myson.c.
References address, alloc_iob(), assert(), myson_ring::cons, cpu_to_le32, io_buffer::data, DBGC, DBGC2, myson_ring::desc, ENOTSUP, MYSON_NUM_RX_DESC, MYSON_RX_CTRL_RBS, MYSON_RX_MAX_LEN, MYSON_RX_STAT_OWN, MYSON_RXPDR, netdev, netdev_rx_err(), NULL, net_device::priv, myson_ring::prod, myson_nic::regs, myson_nic::rx, rx, myson_nic::rx_iobuf, virt_to_bus(), wmb(), and writel().
Referenced by myson_open(), and myson_poll().
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 287 of file myson.c.
References ETH_ALEN, le32_to_cpu, net_device::ll_addr, mac, memcpy(), memset(), myson_create_ring(), myson_destroy_ring(), MYSON_PAR0, MYSON_PAR4, MYSON_RCR_AB, MYSON_RCR_ALP, MYSON_RCR_AM, MYSON_RCR_ARP, MYSON_RCR_PROM, MYSON_RCR_RE, myson_refill_rx(), MYSON_TCR_RCR, MYSON_TCR_TE, netdev, net_device::priv, rc, myson_nic::regs, myson_nic::rx, myson_nic::tx, and writel().
|
static |
Wait for transmit and receive to become idle.
myson | Myson device |
rc | Return status code |
Definition at line 329 of file myson.c.
References DBGC, ETIMEDOUT, mdelay(), MYSON_IDLE_MAX_WAIT_MS, MYSON_RCR_RXS, MYSON_TCR_RCR, MYSON_TCR_TXS, readl(), and myson_nic::regs.
Referenced by myson_close().
|
static |
Close network device.
netdev | Network device |
Definition at line 356 of file myson.c.
References free_iob(), myson_destroy_ring(), MYSON_NUM_RX_DESC, MYSON_TCR_RCR, myson_wait_idle(), netdev, NULL, net_device::priv, myson_nic::regs, myson_nic::rx, myson_nic::rx_iobuf, myson_nic::tx, and writel().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 387 of file myson.c.
References address, myson_ring::cons, cpu_to_le32, io_buffer::data, DBGC, DBGC2, myson_ring::desc, ENOBUFS, ENOTSUP, iob_len(), MYSON_NUM_TX_DESC, MYSON_TX_CTRL_CRC, MYSON_TX_CTRL_FD, MYSON_TX_CTRL_IC, MYSON_TX_CTRL_LD, MYSON_TX_CTRL_PAD, MYSON_TX_CTRL_PKTS, MYSON_TX_CTRL_RTLC, MYSON_TX_CTRL_TBS, MYSON_TX_STAT_OWN, MYSON_TXPDR, netdev, net_device::priv, myson_ring::prod, myson_nic::regs, myson_nic::tx, tx, virt_to_bus(), wmb(), and writel().
|
static |
Poll for completed packets.
netdev | Network device |
Definition at line 437 of file myson.c.
References myson_ring::cons, cpu_to_le32, DBGC, DBGC2, myson_ring::desc, EIO, le32_to_cpu, MYSON_NUM_TX_DESC, MYSON_TX_STAT_ABORT, MYSON_TX_STAT_CSL, MYSON_TX_STAT_OWN, netdev, netdev_tx_complete_next(), netdev_tx_complete_next_err(), net_device::priv, myson_ring::prod, myson_nic::tx, and tx.
Referenced by myson_poll().
|
static |
Poll for received packets.
netdev | Network device |
Definition at line 474 of file myson.c.
References myson_ring::cons, cpu_to_le32, DBGC, DBGC2, myson_ring::desc, EIO, iob_put, le32_to_cpu, len, MYSON_NUM_RX_DESC, MYSON_RX_STAT_ES, MYSON_RX_STAT_FLNG, MYSON_RX_STAT_OWN, netdev, netdev_rx(), netdev_rx_err(), NULL, net_device::priv, myson_ring::prod, myson_nic::rx, rx, and myson_nic::rx_iobuf.
Referenced by myson_poll().
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 518 of file myson.c.
References iodelay(), isr, MYSON_IRQ_RI, MYSON_IRQ_TI, MYSON_ISR, MYSON_ISR_IODELAY_COUNT, myson_poll_rx(), myson_poll_tx(), myson_refill_rx(), netdev, net_device::priv, readl(), myson_nic::regs, and writel().
|
static |
Enable or disable interrupts.
netdev | Network device |
enable | Interrupts should be enabled |
Definition at line 555 of file myson.c.
References imr, MYSON_IMR, MYSON_IRQ_RI, MYSON_IRQ_TI, netdev, net_device::priv, myson_nic::regs, and writel().
|
static |
Probe PCI device.
pci | PCI device |
rc | Return status code |
Definition at line 585 of file myson.c.
References adjust_pci_device(), alloc_etherdev(), cpu_to_le32, pci_device::dev, net_device::dev, ENODEV, ENOMEM, ETH_ALEN, net_device::hw_addr, iounmap(), mac, pci_device::membase, memcpy(), memset(), MYSON_BAR_SIZE, MYSON_NUM_RX_DESC, MYSON_NUM_TX_DESC, myson_operations, MYSON_PAR0, MYSON_PAR4, myson_reset(), MYSON_RXLBA, MYSON_TXLBA, netdev, netdev_init(), netdev_link_up(), netdev_nullify(), netdev_put(), pci_ioremap(), pci_set_drvdata(), net_device::priv, rc, readl(), register_netdev(), myson_nic::regs, myson_nic::rx, myson_nic::tx, and unregister_netdev().
|
static |
Remove PCI device.
pci | PCI device |
Definition at line 650 of file myson.c.
References iounmap(), myson_reset(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, myson_nic::regs, and unregister_netdev().
|
static |
Myson network device operations.
Definition at line 564 of file myson.c.
Referenced by myson_probe().
|
static |
Myson PCI device IDs.
struct pci_driver myson_driver __pci_driver |
Myson PCI driver.