165 ( ( phy & 0x1f ) << 5 ) | (
reg & 0x1f ) );
184 ( ( phy & 0x1f ) << 5 ) | (
reg & 0x1f ) );
204 DBGP (
"pcnet32_refill_rx_ring\n" );
207 rx_curr_desc =
priv->rx_base + i;
221 DBG (
"Refill rx ring failed\n" );
247 DBGP (
"pcnet32_setup_rx_resources\n" );
253 if ( !
priv->rx_base ) {
271 DBGP (
"pcnet32_free_rx_resources\n" );
291 DBGP (
"pcnet32_setup_tx_resources\n" );
295 if ( !
priv->tx_base ) {
304 priv->tx_fill_ctr = 0;
313 DBGP (
"pcnet32_free_tx_resources\n" );
337 DBG (
"PCnet chip version is 0x%X\n", chip_version );
338 if ( ( chip_version & 0xfff ) != 0x003 )
339 goto err_unsupported;
341 fdx =
mii = fset = 0;
342 chip_version = ( chip_version >> 12 ) & 0xffff;
344 switch (chip_version) {
346 chipname =
"PCnet/PCI 79C970";
350 chipname =
"PCnet/PCI 79C970";
353 chipname =
"PCnet/PCI II 79C970A";
357 chipname =
"PCnet/FAST 79C971";
363 chipname =
"PCnet/FAST+ 79C972";
369 chipname =
"PCnet/FAST III 79C973";
374 chipname =
"PCnet/Home 79C978";
386 DBG (
"media reset to %#x.\n",
media );
390 chipname =
"PCnet/FAST III 79C975";
395 chipname =
"PCnet/PRO 79C976";
400 chipname =
"UNKNOWN";
401 DBG (
"PCnet version %#x, no PCnet32 chip.\n", chip_version );
402 goto err_unsupported;
405 DBG (
"PCnet chipname %s\n", chipname );
420 priv->full_duplex = fdx;
459 goto err_unsupported;
482 priv->init_block.mode =
486 priv->init_block.tlen_rlen =
492 priv->init_block.phys_addr[i] =
priv->netdev->hw_addr[i];
495 priv->init_block.filter[0] = 0xffffffff;
496 priv->init_block.filter[1] = 0xffffffff;
498 priv->init_block.rx_ring =
500 priv->init_block.tx_ring =
516 unsigned int phycount = 0;
521 phy_id = ( (
priv->a->read_bcr (
ioaddr, 33 ) ) >> 5 ) & 0x1f;
523 unsigned short id1, id2;
530 if ( i == 31 && ( (
priv->chip_version + 1 ) & 0xfffe ) == 0x2624 )
536 priv->a->write_bcr (
ioaddr, 33, phy_id << 5 );
562 for ( i = 0; i < 3; i++ ) {
566 priv->netdev->hw_addr[2 * i] =
val & 0x0ff;
567 priv->netdev->hw_addr[2 * i + 1] = (
val >> 8 ) & 0x0ff;
576 DBG (
"CSR address is invalid, using PROM addr\n" );
606 if (
priv->full_duplex ) {
614 if (
priv->chip_version == 0x2627 )
627 u16 subsys_vend_id, subsys_dev_id;
650 if ( (
priv->chip_version != 0x2420 ) &&
651 (
priv->chip_version != 0x2621 ) ) {
700 DBG (
"Error setting up TX resources\n" );
705 DBG (
"Error setting up RX resources\n" );
742 priv->a->reset(
priv->pci_dev->ioaddr );
762 DBGP (
"pcnet32_transmit\n" );
765 DBG (
"Tx overflow\n" );
769 priv->tx_iobuf[
priv->tx_curr] = iobuf;
771 tx_curr_desc =
priv->tx_base +
priv->tx_curr;
775 tx_curr_desc->
misc = 0x00000000;
808 DBGP (
"pcnet32_process_tx_packets\n" );
810 while (
priv->tx_tail !=
priv->tx_curr ) {
811 tx_curr_desc =
priv->tx_base +
priv->tx_tail;
815 DBG (
"Before OWN bit check, status: %#08x\n",
status );
821 DBG (
"Transmitted packet.\n" );
822 DBG (
"priv->tx_fill_ctr= %d\n",
priv->tx_fill_ctr );
823 DBG (
"priv->tx_tail = %d\n",
priv->tx_tail );
824 DBG (
"priv->tx_curr = %d\n",
priv->tx_curr );
831 memset ( tx_curr_desc, 0,
sizeof(*tx_curr_desc) );
857 DBGP (
"pcnet32_process_rx_packets\n" );
860 rx_curr_desc =
priv->rx_base +
priv->rx_curr;
865 DBG (
"Before OWN bit check, status: %#08x\n",
status );
875 DBG (
"Received packet.\n" );
876 DBG (
"priv->rx_curr = %d\n",
priv->rx_curr );
877 DBG (
"rx_len = %d\n",
879 DBG (
"rx_curr_desc = %#08lx\n",
886 DBG (
"Corrupted packet received!\n");
898 memset ( rx_curr_desc, 0,
sizeof(*rx_curr_desc) );
920 DBGP (
"pcnet32_poll\n" );
927 DBG (
"pcnet32_poll: mask = %#04x, status = %#04x\n",
931 if ( (
status & 0x0500 ) == 0x0000 )
952 DBGP (
"pcnet32_close\n" );
973 DBGP (
"pcnet32_irq_enable\n" );
983 priv->irq_enabled = 1;
990 DBGP (
"pcnet32_irq_disable\n" );
994 priv->irq_enabled = 0;
1008 DBGP (
"pcnet32_irq\n" );
1044 DBGP (
"pcnet32_probe\n" );
1046 DBG (
"Found %s, vendor = %#04x, device = %#04x\n",
1053 goto err_alloc_etherdev;
1067 priv->pci_dev = pdev;
1073 priv->irq_enabled = 0;
1079 DBG (
"Setting driver operations failed\n");
1084 DBG (
"pcnet32_chip_detect failed\n" );
1085 goto err_chip_detect;
1093 DBG (
"Setting MAC address failed\n" );
1097 DBG (
"IO Addr 0x%lX, MAC Addr %s\n",
ioaddr,
1112 DBG (
"Error registering netdev\n" );
1140 DBGP (
"pcnet32_remove\n" );
1151 PCI_ROM(0x1022, 0x2000,
"pcnet32",
"AMD PCnet/PCI", 0),
1152 PCI_ROM(0x1022, 0x2001,
"amdhomepna",
"AMD PCnet/HomePNA", 0),
1153 PCI_ROM(0x1022, 0x2625,
"pcnetfastiii",
"AMD PCNet FAST III", 0),
static struct pcnet32_access pcnet32_dwio
static u16 pcnet32_wio_read_bcr(unsigned long addr, int index)
#define EINVAL
Invalid argument.
#define PCI_SUBDEVICE_ID_AT_2701FX
struct arbelprm_rc_send_wqe rc
#define PCNET32_DWIO_RESET
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
static struct mii_phy mii
#define iob_put(iobuf, len)
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
static void pcnet32_wio_reset(unsigned long addr)
static int pcnet32_setup_rx_resources(struct pcnet32_private *priv)
pcnet32_setup_rx_resources - allocate Rx resources (Descriptors)
static int pcnet32_setup_mac_addr(struct pcnet32_private *priv)
pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses
static unsigned int unsigned int reg
static u16 pcnet32_wio_read_rap(unsigned long addr)
struct pci_driver pcnet32_driver __pci_driver
#define le32_to_cpu(value)
int(* open)(struct net_device *netdev)
Open network device.
#define outw(data, io_addr)
unsigned long ioaddr
I/O address.
static u16 pcnet32_wio_read_csr(unsigned long addr, int index)
static int pcnet32_mdio_read(struct net_device *netdev, int phy, int reg)
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct pci_device_id * ids
PCI ID table.
static void pcnet32_close(struct net_device *netdev)
close - Disable network interface
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
static void pcnet32_remove(struct pci_device *pdev)
remove - Device Removal Routine
static void pcnet32_process_tx_packets(struct net_device *netdev)
pcnet32_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_t...
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
static int pcnet32_set_ops(struct pcnet32_private *priv)
pcnet32_set_ops - Determines the ops used to access the registers
#define PCNET32_WIO_RESET
#define PCNET32_LOG_RX_BUFFERS
static void pcnet32_process_rx_packets(struct net_device *netdev)
pcnet32_process_rx_packets - Checks for received packets, reports them to iPXE with netdev_rx() or ne...
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define PCI_SUBSYSTEM_ID
PCI subsystem ID.
struct device dev
Generic device.
static u16 pcnet32_dwio_read_csr(unsigned long addr, int index)
#define ENOTSUP
Operation not supported.
Dynamic memory allocation.
static void pcnet32_dwio_write_rap(unsigned long addr, u16 val)
static void pcnet32_poll(struct net_device *netdev)
poll - Poll for received packets
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void pcnet32_wio_write_rap(unsigned long addr, u16 val)
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define ENOMEM
Not enough space.
static unsigned long ioaddr
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void pcnet32_free_tx_resources(struct pcnet32_private *priv)
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
static int pcnet32_dwio_check(unsigned long addr)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
void * priv
Driver private data.
#define __unused
Declare a variable or data structure as unused.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
static struct net_device * netdev
static int pcnet32_chip_detect(struct pcnet32_private *priv)
static void pcnet32_irq(struct net_device *netdev, int action)
irq - enable or disable interrupts
#define PCNET32_PORT_ASEL
void unregister_netdev(struct net_device *netdev)
Unregister network device.
static struct pcnet32_access pcnet32_wio
#define cpu_to_le32(value)
static int pcnet32_setup_tx_resources(struct pcnet32_private *priv)
pcnet32_setup_tx_resources - allocate Tx resources (Descriptors)
void(* write_csr)(unsigned long, int, u16)
static int pcnet32_open(struct net_device *netdev)
open - Called when a network interface is made active
static int pcnet32_probe(struct pci_device *pdev)
probe - Initial configuration of NIC
#define outl(data, io_addr)
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 u16 pcnet32_dwio_read_rap(unsigned long addr)
static void __unused pcnet32_mdio_write(struct net_device *netdev, int phy, int reg, int val)
#define PCNET32_LOG_TX_BUFFERS
static void pcnet32_hw_start(struct pcnet32_private *priv)
pcnet32_hw_start - Starts up the NIC
#define ENODEV
No such device.
static int pcnet32_transmit(struct net_device *netdev, struct io_buffer *iobuf)
transmit - Transmit a packet
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static void pcnet32_setup_if_duplex(struct pcnet32_private *priv)
pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode
#define PCNET32_SWSTYLE_LANCE
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
A PCI device ID list entry.
#define le16_to_cpu(value)
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
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 EADDRNOTAVAIL
Address not available.
static void pcnet32_refill_rx_ring(struct pcnet32_private *priv)
pcnet32_refill_rx_ring - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in ...
Network device management.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
#define PCNET32_PORT_PORTSEL
uint16_t vendor
PCI vendor ID.
uint16_t device
PCI device ID.
static struct tlan_private * priv
Media Independent Interface constants.
#define PCI_SUBDEVICE_ID_AT_2700FX
FILE_LICENCE(GPL2_OR_LATER)
void * data
Start of data.
static void pcnet32_dwio_reset(unsigned long addr)
static void pcnet32_setup_init_block(struct pcnet32_private *priv)
pcnet32_setup_init_block - setup the NICs initialization block
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
static void pcnet32_wio_write_bcr(unsigned long addr, int index, u16 val)
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
struct pci_device_id * id
Driver device ID.
static void pcnet32_dwio_write_csr(unsigned long addr, int index, u16 val)
static void pcnet32_wio_write_csr(unsigned long addr, int index, u16 val)
#define cpu_to_le16(value)
void(* write_bcr)(unsigned long, int, u16)
static int pcnet32_wio_check(unsigned long addr)
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
u16(* read_bcr)(unsigned long, int)
#define PCI_SUBSYSTEM_VENDOR_ID
PCI subsystem vendor ID.
static u16 pcnet32_dwio_read_bcr(unsigned long addr, int index)
#define PCNET32_PORT_GPSI
#define DBG(...)
Print a debugging message.
#define PCNET32_SWSTYLE_PCNET32
static void pcnet32_dwio_write_bcr(unsigned long addr, int index, u16 val)
static void pcnet32_setup_probe_phy(struct pcnet32_private *priv)
pcnet32_setup_probe_phy - go through all PHYs and see which one is present
static struct pci_device_id pcnet32_nics[]
static void pcnet32_irq_disable(struct pcnet32_private *priv)
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
static struct net_device_operations pcnet32_operations
u16(* read_csr)(unsigned long, int)
#define PCI_ROM(_vendor, _device, _name, _description, _data)
static void pcnet32_irq_enable(struct pcnet32_private *priv)
static void pcnet32_free_rx_resources(struct pcnet32_private *priv)
void * memset(void *dest, int character, size_t len) __nonnull