74 unsigned int bit_id ) {
83 return (
reg & mask );
94 unsigned int bit_id,
unsigned long data ) {
130 init_at93c06 ( &natsemi->
eeprom, 16 );
146 for ( i = ( (
ETH_ALEN / 2 ) - 1 ) ; i >= 0 ; i-- )
149 DBGC ( natsemi,
"NATSEMI %p has sane EEPROM layout\n", natsemi );
167 for ( i = 0 ; i < (
ETH_ALEN / 2 ) ; i++ ) {
174 DBGC ( natsemi,
"NATSEMI %p has insane EEPROM layout\n", natsemi );
192 sizeof ( buf ) ) ) != 0 ) {
193 DBGC ( natsemi,
"NATSEMI %p could not read EEPROM: %s\n",
197 DBGC2 ( natsemi,
"NATSEMI %p EEPROM contents:\n", natsemi );
198 DBGC2_HDA ( natsemi, 0, buf,
sizeof ( buf ) );
203 extract ( natsemi, buf, hw_addr );
239 DBGC ( natsemi,
"NATSEMI %p timed out waiting for reset\n", natsemi );
268 DBGC ( natsemi,
"NATSEMI %p timed out waiting for configuration " 269 "reload\n", natsemi );
303 DBGC ( natsemi,
"NATSEMI %p using configuration %08x\n",
328 if (
cfg == natsemi->
cfg )
341 DBGC ( natsemi,
"NATSEMI %p link status is %08x\n", natsemi,
cfg );
370 for ( i = 0 ; i <
ETH_ALEN ; i +=
sizeof ( *pmatch ) ) {
394 size_t len = ( ring->
count *
sizeof ( ring->
desc[0] ) );
412 if ( ! ring->
desc ) {
419 if ( ! natsemi_address_ok ( natsemi,
address ) ) {
420 DBGC ( natsemi,
"NATSEMI %p cannot support 64-bit ring " 421 "address\n", natsemi );
428 for ( i = 0 ; i < ring->
count ; i++ ) {
429 linked_desc = &ring->
desc [ ( i + 1 ) % ring->
count ];
443 natsemi->
regs + ring->
reg + 4 );
449 DBGC ( natsemi,
"NATSEMI %p ring %02x is at [%08llx,%08llx)\n",
471 size_t len = ( ring->
count *
sizeof ( ring->
desc[0] ) );
508 if ( ! natsemi_address_ok ( natsemi,
address ) ) {
509 DBGC ( natsemi,
"NATSEMI %p cannot support 64-bit RX " 510 "buffer address\n", natsemi );
537 DBGC2 ( natsemi,
"NATSEMI %p RX %d is [%llx,%llx)\n", natsemi,
538 rx_idx, ( (
unsigned long long )
address ),
648 if ( ! natsemi_address_ok ( natsemi,
address ) ) {
649 DBGC ( natsemi,
"NATSEMI %p cannot support 64-bit TX buffer " 650 "address\n", natsemi );
656 DBGC ( natsemi,
"NATSEMI %p out of transmit descriptors\n",
677 DBGC2 ( natsemi,
"NATSEMI %p TX %d is [%llx,%llx)\n", natsemi, tx_idx,
678 ( (
unsigned long long )
address ),
707 DBGC2 ( natsemi,
"NATSEMI %p TX %d complete\n",
711 DBGC ( natsemi,
"NATSEMI %p TX %d completion error " 712 "(%08x)\n", natsemi, tx_idx,
752 DBGC2 ( natsemi,
"NATSEMI %p RX %d complete (length " 753 "%zd)\n", natsemi, rx_idx,
len );
756 DBGC ( natsemi,
"NATSEMI %p RX %d error (length %zd, " 757 "status %08x)\n", natsemi, rx_idx,
len,
847 memset ( natsemi, 0,
sizeof ( *natsemi ) );
857 if ( ! natsemi->
regs ) {
875 goto err_register_netdev;
917 #define DP83815_FLAGS ( NATSEMI_EEPROM_LITTLE_ENDIAN | NATSEMI_EEPROM_INSANE ) 920 #define DP83820_FLAGS ( NATSEMI_64BIT | NATSEMI_1000 ) struct natsemi_descriptor_32 d32
Descriptor.
#define NATSEMI_ISR
Interrupt Status Register.
unsigned int prod
Producer index.
#define NATSEMI_CR_TXE
Transmit enable.
#define NATSEMI_MEAR_EECLK
EEPROM serial clock.
struct bit_basher basher
Bit-bashing interface.
unsigned long membase
Memory base.
#define NATSEMI_CFG
Configuration and Media Status Register.
#define NATSEMI_RXDP
Receive Descriptor Pointer.
struct natsemi_ring rx
Receive descriptor ring.
struct arbelprm_rc_send_wqe rc
#define iob_put(iobuf, len)
#define NATSEMI_CFG_MODE_1000
1000 Mb/s mode control
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
static struct bit_basher_operations natsemi_basher_ops
SPI bit-bashing interface.
Card supports 64-bit operation.
struct natsemi_ring tx
Transmit descriptor ring.
#define NATSEMI_TXCFG_MXDMA_DEFAULT
Max DMA burst size (encoded value)
static unsigned int unsigned int reg
#define DP83820_FLAGS
Flags for DP83820.
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
#define NATSEMI_MEAR
EEPROM Access Register.
#define NATSEMI_IMR
Interrupt Mask Register.
unsigned int cons
Consumer index.
SPI bit-bashing interface.
static struct pci_device_id natsemi_nics[]
National Semiconductor PCI device IDs.
#define DP83815_FLAGS
Flags for DP83815.
unsigned long driver_data
Arbitrary driver data.
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
#define DBG_ENABLE(level)
struct pci_device_id * ids
PCI ID table.
uint64_t address
Base address.
FILE_LICENCE(GPL2_OR_LATER)
#define NATSEMI_RXCFG_ARP
Accept runt packets.
#define NATSEMI_TXCFG_ATP
Automatic padding.
static int natsemi_create_ring(struct natsemi_nic *natsemi, struct natsemi_ring *ring)
Create descriptor ring.
National Semiconductor "MacPhyter" network card driver.
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
uint64_t desc
Microcode descriptor list physical address.
#define NATSEMI_EEPROM_SIZE
Size of EEPROM (in bytes)
static void natsemi_hwaddr_sane(struct natsemi_nic *natsemi, const uint16_t *eeprom, uint16_t *hw_addr)
Get hardware address from sane EEPROM data.
static int natsemi_reload_config(struct natsemi_nic *natsemi)
Reload configuration from EEPROM.
#define NATSEMI_RFCR
Receive Filter/Match Control Register.
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 NATSEMI_CFG_SPDSTS1
Speed status bit 1.
#define NATSEMI_EELOAD_MAX_WAIT_MS
Maximum time to wait for a configuration reload, in milliseconds.
#define NATSEMI_NUM_TX_DESC
Number of transmit descriptors.
#define NATSEMI_RFDR_BMASK
Byte mask.
#define cpu_to_le64(value)
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.
uint32_t cfg
Link status (cache)
#define NATSEMI_TXCFG_FLTH_DEFAULT
Fill threshold (in units of 32 bytes)
#define NATSEMI_RXCFG_DRTH_DEFAULT
Drain threshold (in units of 8 bytes)
#define offsetof(type, field)
Get offset of a field within a structure.
uint8_t mac[ETH_ALEN]
MAC address.
#define NATSEMI_CR_RXR
Receiver reset.
static struct net_device_operations natsemi_operations
National Semiconductor network device operations.
#define NATSEMI_TXCFG_DRTH_DEFAULT
Drain threshold (in units of 32 bytes)
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct bit_basher_operations * op
Bit-bashing operations.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
struct device dev
Generic device.
struct spi_device eeprom
EEPROM.
static void natsemi_hwaddr_insane(struct natsemi_nic *natsemi, const uint16_t *eeprom, uint16_t *hw_addr)
Get hardware address from insane EEPROM data.
unsigned int mode
SPI interface mode.
#define ENOTSUP
Operation not supported.
Dynamic memory allocation.
#define NATSEMI_IRQ_TXDESC
TX descriptor.
#define NATSEMI_IER_IE
Interrupt enable.
#define NATSEMI_TXCFG_64
Transmit configuration register (64-bit)
#define NATSEMI_PTSCR_EELOAD_EN
Enable EEPROM load.
#define NATSEMI_TXCFG_CSI
Carrier sense ignore.
#define NATSEMI_RFCR_RFEN
RX filter enable.
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 NATSEMI_TXDP
Transmit Descriptor Pointer.
#define ENOMEM
Not enough space.
#define NATSEMI_IER
Interrupt Enable Register.
static void natsemi_poll_rx(struct net_device *netdev)
Poll for received packets.
union natsemi_descriptor * desc
Descriptors.
Three-wire serial interface.
#define NATSEMI_MEAR_EEDO
EEPROM data out.
static void natsemi_poll(struct net_device *netdev)
Poll for completed and received packets.
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
#define NATSEMI_MEAR_EESEL
EEPROM chip select.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define container_of(ptr, type, field)
Get containing structure.
static void natsemi_remove(struct pci_device *pci)
Remove PCI device.
#define NATSEMI_RFDR
Receive Filter/Match Data Register.
void * priv
Driver private data.
#define NATSEMI_RXCFG_32
Receive configuration register (32-bit)
static void natsemi_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
void init_spi_bit_basher(struct spi_bit_basher *spibit)
Initialise SPI bit-bashing interface.
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.
unsigned int count
Number of descriptors.
static struct net_device * netdev
uint64_t link
Link to next descriptor.
u32 link
Link to next descriptor.
#define NATSEMI_RFCR_RFADDR_MASK
static int natsemi_hwaddr(struct natsemi_nic *natsemi, void *hw_addr)
Get hardware address from EEPROM.
unsigned int reg
Descriptor start address register.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
uint32_t link
Link to next descriptor.
static int natsemi_spi_read_bit(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
#define cpu_to_le32(value)
static void natsemi_refill_rx(struct net_device *netdev)
Refill receive descriptor ring.
#define NATSEMI_EEPROM_MAC_INSANE
Word offset of MAC address within insane EEPROM layout.
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
#define NATSEMI_CR_TXR
Transmit reset.
char * strerror(int errno)
Retrieve string representation of error number.
struct spi_bit_basher spibit
SPI bit-bashing interface.
#define NATSEMI_RFCR_AAU
Accept all unicast.
#define NATSEMI_RXCFG_ATX
Accept transmit packets.
#define NATSEMI_CR
Command Register.
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.
#define NATSEMI_PTSCR
PCI Test Control Register.
static int natsemi_probe(struct pci_device *pci)
Probe PCI device.
static void natsemi_check_link(struct net_device *netdev)
Check link state.
#define ENODEV
No such device.
#define SPI_BIT_SS(slave)
Determine bit index for a particular slave.
#define NATSEMI_TXCFG_ECRETRY
Excess collision retry.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
A National Semiconductor descriptor ring.
static void natsemi_destroy_ring(struct natsemi_nic *natsemi, struct natsemi_ring *ring)
Destroy descriptor ring.
#define NATSEMI_RXCFG_ALP
Accept long packets.
struct natsemi_descriptor_64 d64
64-bit descriptor
#define NATSEMI_MEAR_EEDI
EEPROM data in.
struct natsemi_descriptor_32 d32
Descriptor.
A PCI device ID list entry.
#define le16_to_cpu(value)
static void natsemi_poll_tx(struct net_device *netdev)
Poll for completed packets.
static const uint8_t natsemi_eeprom_bits[]
Pin mapping for SPI bit-bashing interface.
Card supports 1000Mbps link.
struct spi_bus bus
SPI bus.
static struct xen_remove_from_physmap * remove
static int natsemi_open(struct net_device *netdev)
Open network device.
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 int natsemi_reset(struct natsemi_nic *natsemi)
Reset hardware.
#define NATSEMI_RFCR_AAB
Accept all broadcast.
Network device management.
#define SPI_BIT_BIG_ENDIAN
SPI bit basher treats data as big-endian.
struct nvs_device nvs
NVS device.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define NATSEMI_BAR_SIZE
BAR size.
struct pci_driver natsemi_driver __pci_driver
National Semiconductor PCI driver.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Descriptor is owned by NIC.
#define NATSEMI_TXCFG_HBI
Heartbeat ignore.
#define NATSEMI_CR_RST
Reset.
#define NATSEMI_RX_MAX_LEN
Receive buffer length.
static void natsemi_pmatch(struct natsemi_nic *natsemi, const void *mac)
Set perfect match filter address.
#define ENOBUFS
No buffer space available.
#define NATSEMI_TXCFG_32
Transmit configuration register (32-bit)
int(* probe)(struct pci_device *pci)
Probe device.
static int natsemi_soft_reset(struct natsemi_nic *natsemi)
Reset controller chip.
static void natsemi_init_eeprom(struct natsemi_nic *natsemi)
Initialise EEPROM.
void * data
Start of data.
#define EIO
Input/output error.
struct spi_bus * bus
SPI bus to which device is attached.
static void natsemi_spi_write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
#define SPI_BIT_LITTLE_ENDIAN
SPI bit basher treats data as little-endian.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
struct pci_device_id * id
Driver device ID.
#define NATSEMI_CFG_EXTSTS_EN
Extended status enable.
#define cpu_to_le16(value)
#define NATSEMI_CR_RXE
Receiver enable.
void iounmap(volatile const void *io_addr)
Unmap I/O address.
uint8_t data[48]
Additional event data.
#define NATSEMI_RXCFG_64
Receive configuration register (64-bit)
static int natsemi_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
#define NATSEMI_CFG_PCI64_DET
PCI 64-bit bus detected.
#define NATSEMI_CFG_M64ADDR
64-bit address enable
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
#define NATSEMI_RFADDR_PMATCH_BASE
Perfect match filter address base.
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
static void natsemi_close(struct net_device *netdev)
Close network device.
uint16_t offset
Offset to command line.
#define NATSEMI_IRQ_RXDESC
RX descriptor.
#define NATSEMI_RXCFG_MXDMA_DEFAULT
Max DMA burst size (encoded value)
typeof(acpi_finder=acpi_find)
ACPI table finder.
#define SPI_MODE_THREEWIRE
Threewire-compatible mode.
#define NATSEMI_RESET_MAX_WAIT_MS
Maximum time to wait for a reset, in milliseconds.
#define NATSEMI_EEPROM_MAC_SANE
Word offset of MAC address within sane EEPROM layout.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
Request descriptor interrupt.
#define NATSEMI_RFCR_AAM
Accept all multicast.
#define NATSEMI_DESC_SIZE_MASK
Descriptor buffer size mask.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
struct io_buffer * rx_iobuf[NATSEMI_NUM_RX_DESC]
Receive I/O buffers.
#define NULL
NULL pointer (VOID *)
#define ETIMEDOUT
Connection timed out.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
#define NATSEMI_CFG_LNKSTS
Link status.
#define NATSEMI_RFCR_RFADDR(addr)
Extended address.
A National Semiconductor network card.
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
#define NATSEMI_CFG_DATA64_EN
64-bit data enable
#define NATSEMI_NUM_RX_DESC
Number of receive descriptors.
void * memset(void *dest, int character, size_t len) __nonnull
int endianness
Endianness of data.