48 #define EIO_ABORTED __einfo_error ( EINFO_EIO_ABORTED ) 49 #define EINFO_EIO_ABORTED \ 50 __einfo_uniqify ( EINFO_EIO, 0x01, "Frame aborted" ) 51 #define EIO_CORRUPT __einfo_error ( EINFO_EIO_CORRUPT ) 52 #define EINFO_EIO_CORRUPT \ 53 __einfo_uniqify ( EINFO_EIO, 0x02, "CRC incorrect" ) 54 #define EIO_HWOVFL __einfo_error ( EINFO_EIO_HWOVFL ) 55 #define EINFO_EIO_HWOVFL \ 56 __einfo_uniqify ( EINFO_EIO, 0x03, "Hardware overflow" ) 57 #define EIO_STATUS( status ) \ 58 EUNIQ ( EINFO_EIO, ( (status) & EXANIC_STATUS_ERROR_MASK ), \ 59 EIO_ABORTED, EIO_CORRUPT, EIO_HWOVFL ) 143 unsigned int bit_id ) {
157 return ( ( i2c >> shift ) & 1 );
168 unsigned int bit_id,
unsigned long data ) {
179 mask = ( 1UL << shift );
200 { .
setscl = 7, .setsda = 4, .getsda = 12 },
202 { .setscl = 7, .setsda = 5, .getsda = 13 },
222 DBGC2 (
exanic,
"EXANIC %p found no I2C bus via %d/%d/%d\n",
232 DBGC2 (
exanic,
"EXANIC %p found no EEPROM via %d/%d/%d\n",
238 DBGC (
exanic,
"EXANIC %p found EEPROM via %d/%d/%d\n",
284 DBGC (
exanic,
"EXANIC %p could not read MAC address: %s\n",
313 DBGC (
port,
"EXANIC %s port status %#08x speed %dMbps\n",
335 100, 1000, 10000, 40000, 100000,
350 if ( !
port->speeds )
358 port->speed = ( 8 *
sizeof (
port->speeds ) );
360 }
while ( ! ( ( 1UL <<
port->speed ) &
port->speeds ) );
362 assert (
index < (
sizeof ( speeds ) /
sizeof ( speeds[0] ) ) );
365 DBGC (
netdev,
"EXANIC %s attempting %dMbps\n",
389 for ( i = 0 ; i <
port->tx_count ; i++ ) {
390 tx = (
port->tx + ( i *
sizeof ( *tx ) ) );
451 if (
port->rx_iobuf ) {
468 unsigned int tx_fill;
469 unsigned int tx_index;
477 if (
len >
sizeof (
tx->data ) ) {
483 tx_fill = (
port->tx_prod -
port->tx_cons );
484 if ( tx_fill >=
port->tx_count ) {
485 DBGC (
port,
"EXANIC %s out of transmit descriptors\n",
489 tx_index = (
port->tx_prod & (
port->tx_count - 1 ) );
490 offset = ( tx_index *
sizeof ( *tx ) );
492 DBGC2 (
port,
"EXANIC %s TX %04x at [%05zx,%05zx)\n",
527 while (
port->tx_cons != *(
port->txf) ) {
528 DBGC2 (
port,
"EXANIC %s TX %04x complete\n",
549 for ( ; ;
port->rx_cons++ ) {
559 previous = ( current - 1 );
562 if (
desc.generation == previous )
566 if ( !
port->rx_iobuf ) {
568 if ( !
port->rx_iobuf ) {
585 DBGC (
port,
"EXANIC %s RX too large\n",
595 sizeof (
desc.generation ) );
596 if (
desc.generation != current ) {
609 DBGC (
port,
"EXANIC %s RX %04x error: %s\n",
666 unsigned int index ) {
687 goto err_alloc_netdev;
695 port->regs = port_regs;
702 assert ( ! ( tx_len & ( tx_len - 1 ) ) );
709 (
port->txf_slot *
sizeof ( *(
port->txf) ) ) );
728 goto err_register_netdev;
729 DBGC (
port,
"EXANIC %s port %d TX [%#05zx,%#05zx) TXF %#02x RX " 731 (
port->tx_offset + tx_len ),
port->txf_slot,
784 unsigned long regs_bar_start;
785 unsigned long tx_bar_start;
806 goto err_ioremap_regs;
821 DBGC (
exanic,
"EXANIC %p capabilities %#08x base MAC %s\n",
853 for ( i-- ; i >= 0 ; i-- )
899 PCI_ROM ( 0x10ee, 0x2b00,
"exanic-old",
"ExaNIC (old)", 0 ),
900 PCI_ROM ( 0x1ce4, 0x0001,
"exanic-x4",
"ExaNIC X4", 0 ),
901 PCI_ROM ( 0x1ce4, 0x0002,
"exanic-x2",
"ExaNIC X2", 0 ),
902 PCI_ROM ( 0x1ce4, 0x0003,
"exanic-x10",
"ExaNIC X10", 0 ),
903 PCI_ROM ( 0x1ce4, 0x0004,
"exanic-x10gm",
"ExaNIC X10 GM", 0 ),
904 PCI_ROM ( 0x1ce4, 0x0005,
"exanic-x40",
"ExaNIC X40", 0 ),
905 PCI_ROM ( 0x1ce4, 0x0006,
"exanic-x10hpt",
"ExaNIC X10 HPT", 0 ),
906 PCI_ROM ( 0x1ce4, 0x0007,
"exanic-x40g",
"ExaNIC X40", 0 ),
struct arbelprm_rc_send_wqe rc
#define EXANIC_PORT_ENABLE_ENABLED
Port is enabled.
#define iob_put(iobuf, len)
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
uint8_t getsda
GPIO bit for reading SDA.
static unsigned int unsigned int reg
struct exanic_i2c_config i2cfg
I2C bus configuration.
int(* open)(struct net_device *netdev)
Open network device.
void * tx
Transmit region.
static int exanic_i2c_read_bit(struct bit_basher *basher, unsigned int bit_id)
Read I2C line status.
static void exanic_close(struct net_device *netdev)
Close network device.
uint8_t setscl
GPIO bit for pulling SCL low.
static void exanic_poll(struct net_device *netdev)
Poll for completed and received packets.
#define EXANIC_LINK_INTERVAL
Interval between link state checks.
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
static int i2c_check_presence(struct i2c_interface *i2c, struct i2c_device *i2cdev)
Check presence of I2C device.
#define DBG_ENABLE(level)
struct pci_device_id * ids
PCI ID table.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static struct bit_basher_operations exanic_i2c_basher_ops
I2C bit-bashing interface operations.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
#define EXANIC_I2C
I2C GPIO register.
#define EXANIC_POWER
Power control register.
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
uint64_t desc
Microcode descriptor list physical address.
unsigned long long uint64_t
#define DBG_DISABLE(level)
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
#define EXANIC_PORT_FLAGS_PROMISC
Promiscuous mode.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
#define EXANIC_DMA_32_BIT
Flag for 32-bit DMA addresses.
static int exanic_probe_port(struct exanic *exanic, struct device *dev, unsigned int index)
Probe port.
#define offsetof(type, field)
Get offset of a field within a structure.
struct exanic_port * port[EXANIC_MAX_PORTS]
Ports.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define EXANIC_EEPROM_ADDRESS
EEPROM address.
#define EXANIC_TX_BAR
Transmit region BAR.
An ExaNIC transmit chunk.
struct device dev
Generic device.
#define EXANIC_TXF_BASE
Transmit feedback base address register.
void writeb(uint8_t data, volatile uint8_t *io_addr)
Write byte to memory-mapped device.
#define ECANCELED
Operation canceled.
#define ENOTSUP
Operation not supported.
Dynamic memory allocation.
#define EXANIC_REGS_BAR
Register BAR.
static int exanic_probe(struct pci_device *pci)
Probe PCI device.
static void exanic_poll_rx(struct net_device *netdev)
Poll for received packets.
static void exanic_expired(struct retry_timer *timer, int over __unused)
Check link state periodically.
#define EXANIC_TXF_LEN
Transmit feedback region length.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
#define EXANIC_PORT_REGS(index)
Port register offset.
uint8_t setsda
GPIO bit for pulling SDA low.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
static __always_inline void init_i2c_eeprom(struct i2c_device *i2cdev, unsigned int dev_addr)
Initialise generic I2C EEPROM device.
static void exanic_remove_port(struct exanic *exanic, unsigned int index)
Probe port.
#define ENOMEM
Not enough space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
void * txf
Transmit feedback region.
#define EXANIC_PORT_TX_OFFSET
Port transmit region offset register.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct i2c_device eeprom
I2C serial EEPROM.
static void exanic_remove(struct pci_device *pci)
Remove PCI device.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define container_of(ptr, type, field)
Get containing structure.
static int exanic_fetch_mac(struct exanic *exanic)
Fetch base MAC address.
struct i2c_interface i2c
I2C interface.
void * priv
Driver private data.
#define EXANIC_PORT_FLAGS
Port flags register.
#define __unused
Declare a variable or data structure as unused.
An ExaNIC receive chunk descriptor.
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.
static struct exanic_i2c_config exanic_i2cfgs[]
Possible I2C bus configurations.
#define EXANIC_STATUS_ERROR_MASK
Receive status error mask.
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
static struct net_device * netdev
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
#define EXANIC_TYPE_RAW
Raw Ethernet frame type.
static int exanic_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
struct bit_basher basher
Bit-bashing interface.
#define EXANIC_PORT_TX_LEN
Port transmit region length register.
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
uint32_t caps
Capabilities.
#define iob_unput(iobuf, len)
#define ERANGE
Result too large.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
struct refcnt refcnt
Reference counter.
void * zalloc(size_t size)
Allocate cleared memory.
static void exanic_reset(struct exanic *exanic)
Reset hardware.
int register_netdev(struct net_device *netdev)
Register network device.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
static void exanic_check_link(struct net_device *netdev)
Check link state.
#define EIO_STATUS(status)
unsigned int speed
Current attempted link speed (as a capability bit index)
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
#define ENODEV
No such device.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static void exanic_i2c_write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Write I2C line status.
A PCI device ID list entry.
int(* read)(struct i2c_interface *i2c, struct i2c_device *i2cdev, unsigned int offset, uint8_t *data, unsigned int len)
Read data from I2C device.
unsigned long phys_to_bus(unsigned long phys_addr)
Convert physical address to a bus address.
#define ffs(x)
Find first (i.e.
static struct xen_remove_from_physmap * remove
#define EXANIC_PORT_SPEED
Port speed register.
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.
#define EXANIC_MAX_PORTS
Maximum number of ports.
struct pci_driver exanic_driver __pci_driver
ExaNIC PCI driver.
Network device management.
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
void stop_timer(struct retry_timer *timer)
Stop timer.
#define EXANIC_MAX_TX_LEN
Maximum used length of transmit region.
char name[NETDEV_NAME_LEN]
Name of this network device.
static __always_inline void ufree(userptr_t userptr)
Free external memory.
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
#define ENOBUFS
No buffer space available.
#define EXANIC_PORT_STATUS
Port status register.
static int exanic_init_eeprom(struct exanic *exanic)
Initialise EEPROM.
int(* probe)(struct pci_device *pci)
Probe device.
void * data
Start of data.
#define EXANIC_PORT_TX_COMMAND
Port transmit command register.
#define EXANIC_CAPS_SPEED_MASK
Supported speeds mask.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
#define EXANIC_POWER_ON
Power on PHYs.
void iounmap(volatile const void *io_addr)
Unmap I/O address.
uint8_t data[48]
Additional event data.
static void exanic_clear_base(void *reg)
Clear DMA base address register.
static struct net_device_operations exanic_operations
ExaNIC network device operations.
static void exanic_poll_tx(struct net_device *netdev)
Poll for completed packets.
struct i2c_bit_basher basher
I2C bit-bashing interface.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
#define EXANIC_REGS_LEN
Register set length.
#define EXANIC_PORT_IRQ
Port interrupt configuration register.
uint16_t offset
Offset to command line.
typeof(acpi_finder=acpi_find)
ACPI table finder.
#define EXANIC_PORT_ENABLE
Port enable register.
#define EXANIC_PORT_STATUS_LINK
Link is up.
static int exanic_open(struct net_device *netdev)
Open network device.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
uint8_t mac[ETH_ALEN]
Base MAC address.
int init_i2c_bit_basher(struct i2c_bit_basher *i2cbit, struct bit_basher_operations *bash_op)
Initialise I2C bit-bashing interface.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
#define PCI_ROM(_vendor, _device, _name, _description, _data)
#define EXANIC_MAX_RX_LEN
Maximum length of received packet.
#define EXANIC_PORT_STATUS_ABSENT
Port is not present.
#define EXANIC_ALIGN
Alignment for DMA regions.
static int exanic_try_init_eeprom(struct exanic *exanic, struct exanic_i2c_config *i2cfg)
Initialise EEPROM.
#define EXANIC_RX_LEN
Receive region length.
static void exanic_write_base(physaddr_t addr, void *reg)
Write DMA base address register.
An ExaNIC I2C bus configuration.
#define EXANIC_TXF_SLOT(index)
Transmit feedback slot.
static struct pci_device_id exanic_ids[]
ExaNIC PCI device IDs.
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
#define EXANIC_PORT_RX_BASE
Port receive chunk base address register.
void * memset(void *dest, int character, size_t len) __nonnull
#define EXANIC_CAPS
Capabilities register.