36 #define velocity_setbit(_reg, _mask) writeb ( readb ( _reg ) | _mask, _reg ) 37 #define virt_to_le32bus(x) ( cpu_to_le32 ( virt_to_bus ( x ) ) ) 72 DBGC ( vlc,
"MII autopoll stop timeout\n" );
96 DBGC ( vlc,
"MII autopoll start timeout\n" );
115 DBGC2 ( vlc,
"VELOCITY %p MII read reg %d\n", vlc,
reg );
138 DBGC ( vlc,
"MII read timeout\n" );
158 DBGC2 ( vlc,
"VELOCITY %p MII write reg %d data 0x%04x\n",
182 DBGC ( vlc,
"MII write timeout\n" );
237 DBGC ( vlc,
"VELOCITY %p EEPROM reload timeout\n", vlc );
251 DBGC ( vlc,
"VELOCITY %p reset\n", vlc );
293 DBGC ( vlc,
"VELOCITY %p link up\n", vlc );
296 DBGC ( vlc,
"VELOCITY %p link down\n", vlc );
330 DBGC2 ( vlc,
"VELOCITY %p RX ring start address: %p(phys: %#08lx)\n",
355 DBGC2 ( vlc,
"VELOCITY %p TX ring start address: %p(phys: %#08lx)\n",
397 if ( rx_idx % 4 == 3 ) {
399 for (j = 0; j < 4; j++) {
416 DBGC2 ( vlc,
"VELOCITY %p refilled %d RX descriptors\n",
430 DBGC ( vlc,
"VELOCITY %p open\n", vlc );
431 DBGC ( vlc,
"VELOCITY %p regs at: %p\n", vlc, vlc->
regs );
462 DBGC2 ( vlc,
"VELOCITY %p CR3 %02x\n",
546 DBGC2 ( vlc,
"VELOCITY %p tx_prod=%d desc=%p iobuf=%p len=%zd\n",
581 DBGC2 ( vlc,
"VELOCITY %p got packet on idx=%d (prod=%d), len %zd\n",
587 DBGC ( vlc,
"VELOCITY %p receive error, status: %02x\n",
596 DBGC ( vlc,
"VELOCITY %p RX neither ERR nor OK: %04x\n",
598 DBGC ( vlc,
"packet len: %zd\n",
len );
635 DBGC2 ( vlc,
"VELOCITY %p poll_tx cons=%d prod=%d tsr=%04x\n",
637 (
desc->des0 & 0xffff ) );
662 DBGC2 ( vlc,
"VELOCITY %p link status interrupt\n", vlc );
682 DBGC ( vlc,
"VELOCITY %p interrupts %s\n", vlc,
683 enable ?
"enable" :
"disable" );
759 DBGC ( vlc,
"VELOCITY %p could not reset MII: %s\n",
769 goto err_register_netdev;
805 PCI_ROM ( 0x1106, 0x3119,
"vt6122",
"VIA Velocity", 0 ),
#define velocity_setbit(_reg, _mask)
#define EINVAL
Invalid argument.
struct velocity_tx_descriptor * tx_ring
Transmit descriptor ring.
#define VELOCITY_DES1_INTR
#define VELOCITY_DES0_RX_ERR
unsigned long membase
Memory base.
struct arbelprm_rc_send_wqe rc
struct velocity_rx_descriptor * rx_ring
Receive descriptor ring.
unsigned int rx_cons
Receive consumer index.
uint8_t readb(volatile uint8_t *io_addr)
Read byte from memory-mapped device.
#define iob_put(iobuf, len)
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
#define VELOCITY_DES0_RMBC(_n)
static int velocity_probe(struct pci_device *pci)
Probe PCI device.
#define ADVERTISE_1000FULL
#define VELOCITY_ISR1_SRCI
#define VELOCITY_ISR0
Interrupt status register 0.
#define VELOCITY_TXQCSRS_RUN0
static unsigned int unsigned int reg
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
#define VELOCITY_ISR1
Interrupt status register 1.
uint16_t readw(volatile uint16_t *io_addr)
Read 16-bit word from memory-mapped device.
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct pci_device_id * ids
PCI ID table.
int(* read)(struct mii_interface *mdio, unsigned int phy, unsigned int reg)
Read from MII register.
struct pci_driver velocity_driver __pci_driver
Velocity PCI driver.
#define VELOCITY_RXDESCNUM
uint64_t desc
Microcode descriptor list physical address.
#define VELOCITY_IMR1
Interrupt mask register 1.
struct io_buffer * rx_buffs[VELOCITY_RXDESC_NUM]
Receive I/O buffers.
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
void netdev_tx_complete_next_err(struct net_device *netdev, int rc)
Complete network transmission.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
#define VELOCITY_MAC0
MAC address registers.
#define VELOCITY_RXDESC_RESIDUECNT
#define VELOCITY_CR1_SFRST
#define virt_to_le32bus(x)
static int velocity_autopoll_stop(struct velocity_nic *vlc)
Stop MII auto-polling.
static int velocity_alloc_rings(struct velocity_nic *vlc)
Allocate descriptor rings.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define VELOCITY_RXQCSR_RUN
#define VELOCITY_MIICR_WCMD
struct device dev
Generic device.
void writeb(uint8_t data, volatile uint8_t *io_addr)
Write byte to memory-mapped device.
unsigned int rx_commit
Receive commit number.
static void mdio_init(struct mii_interface *mdio, struct mii_operations *op)
Initialise MII interface.
#define VELOCITY_STICKY_DS1
#define VELOCITY_PHYSTS0_LINK
Dynamic memory allocation.
#define VELOCITY_CRS1
Command register 1 (set)
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define ENOMEM
Not enough space.
#define VELOCITY_TIMEOUT_US
Default timeout.
#define VELOCITY_RING_ALIGN
Descriptor alignment.
#define VELOCITY_RXDESC_NUM
Number of receive descriptors.
FILE_LICENCE(GPL2_OR_LATER)
static void velocity_check_link(struct net_device *netdev)
Check link state.
static int velocity_mii_read(struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg)
Read from MII register.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
static int velocity_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
#define VELOCITY_CR1_DPOLL
static void velocity_remove(struct pci_device *pci)
Remove PCI device.
#define VELOCITY_RCR
Receive control register.
#define VELOCITY_DES0_RXOK
static struct mii_operations velocity_mii_operations
Velocity MII operations.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define container_of(ptr, type, field)
Get containing structure.
#define VELOCITY_TXDESC_NUM
Number of transmit descriptors.
void * priv
Driver private data.
unsigned int rx_prod
Receive producer index.
#define __unused
Declare a variable or data structure as unused.
#define VELOCITY_IMR0
Interrupt mask register 0.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
static int velocity_reload_eeprom(struct velocity_nic *vlc)
Reload eeprom contents.
static struct net_device * netdev
static struct net_device_operations velocity_operations
Velocity network device operations.
static void velocity_poll_rx(struct velocity_nic *vlc)
Poll for received packets.
static void velocity_poll_tx(struct velocity_nic *vlc)
Poll for completed packets.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
#define cpu_to_le32(value)
#define VELOCITY_CR0_TXON
#define VELOCITY_DES2_SIZE(_n)
unsigned int tx_prod
Transmit producer index.
char * strerror(int errno)
Retrieve string representation of error number.
#define VELOCITY_DES0_OWN
static void velocity_close(struct net_device *netdev)
Close network device.
#define VELOCITY_CRS0
Command register 0 (set)
static void velocity_poll(struct net_device *netdev)
Poll for completed and received packets.
#define VELOCITY_BAR_SIZE
Skeleton BAR size.
int register_netdev(struct net_device *netdev)
Register network device.
#define VELOCITY_CRC3
Command register 3 (clear.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define VELOCITY_RX_MAX_LEN
Receive buffer length.
Media Independent Interface.
#define VELOCITY_RXQCSR_WAK
#define VELOCITY_TXDESC_SIZE
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static int velocity_reset(struct velocity_nic *vlc)
Reset hardware.
Velocity descriptor format.
#define VELOCITY_TXDESC_ADDR_LO0
int mii_reset(struct mii_device *mii)
Reset MII device.
A PCI device ID list entry.
#define ADVERTISE_1000HALF
#define VELOCITY_MIISR_IDLE
#define VELOCITY_DES1_FRAG(_n)
TX descriptor fragment number.
static struct xen_remove_from_physmap * remove
static int velocity_mii_write(struct mii_interface *mdio, unsigned int phy __unused, unsigned int reg, unsigned int data)
Write to MII register.
#define VELOCITY_EECSR_RELOAD
#define VELOCITY_CRS3
Command register 3 (set)
Network device operations.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
static void mii_init(struct mii_device *mii, struct mii_interface *mdio, unsigned int address)
Initialise MII device.
Network device management.
MII interface operations.
static int velocity_open(struct net_device *netdev)
Open network device.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define VELOCITY_CR0_RXON
static void velocity_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
#define VELOCITY_STICKY
Power Management Sticky Register.
int(* probe)(struct pci_device *pci)
Probe device.
#define VELOCITY_DES0_TERR
#define VELOCITY_RXDESC_ADDR_LO
static struct pci_device_id velocity_nics[]
Velocity PCI device IDs.
void * data
Start of data.
#define VELOCITY_DES1_TCPLS
#define VELOCITY_CFGA_PACPI
#define VELOCITY_MIICR_MAUTO
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
unsigned int tx_cons
Transmit consumer index.
static void velocity_set_link(struct velocity_nic *vlc)
Set Link speed.
static void velocity_refill_rx(struct velocity_nic *vlc)
Refill receive descriptor ring.
uint8_t data[48]
Additional event data.
#define VELOCITY_CR0_STOP
struct mii_device mii
MII device.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
#define VELOCITY_TXQCSRS_WAK0
static int mii_read(int phy_id, int location)
#define VELOCITY_CFGA
Chip Configuration Register A.
#define VELOCITY_STICKY_DS0
#define VELOCITY_RXDESC_SIZE
struct mii_interface mdio
MII interface.
struct net_device * netdev
Netdev.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
static int velocity_autopoll_start(struct velocity_nic *vlc)
Start MII auto-polling.
static int mii_write(struct mii_device *mii, unsigned int reg, unsigned int data)
Write to MII register.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
VIA Velocity network driver.
#define ETIMEDOUT
Connection timed out.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
#define VELOCITY_CR3_GINTMSK1
#define VELOCITY_MIICR_RCMD
#define VELOCITY_CRC0
Command register 0 (clear)
#define VELOCITY_TXDESCNUM
void * memset(void *dest, int character, size_t len) __nonnull
#define VELOCITY_CR0_START