iPXE
|
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <byteswap.h>
#include <errno.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/io.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/netdevice.h>
#include <ipxe/pci.h>
#include <ipxe/timer.h>
#include <mii.h>
#include "pcnet32.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
static u16 | pcnet32_wio_read_csr (unsigned long addr, int index) |
static void | pcnet32_wio_write_csr (unsigned long addr, int index, u16 val) |
static u16 | pcnet32_wio_read_bcr (unsigned long addr, int index) |
static void | pcnet32_wio_write_bcr (unsigned long addr, int index, u16 val) |
static u16 | pcnet32_wio_read_rap (unsigned long addr) |
static void | pcnet32_wio_write_rap (unsigned long addr, u16 val) |
static void | pcnet32_wio_reset (unsigned long addr) |
static int | pcnet32_wio_check (unsigned long addr) |
static u16 | pcnet32_dwio_read_csr (unsigned long addr, int index) |
static void | pcnet32_dwio_write_csr (unsigned long addr, int index, u16 val) |
static u16 | pcnet32_dwio_read_bcr (unsigned long addr, int index) |
static void | pcnet32_dwio_write_bcr (unsigned long addr, int index, u16 val) |
static u16 | pcnet32_dwio_read_rap (unsigned long addr) |
static void | pcnet32_dwio_write_rap (unsigned long addr, u16 val) |
static void | pcnet32_dwio_reset (unsigned long addr) |
static int | pcnet32_dwio_check (unsigned long addr) |
static int | pcnet32_mdio_read (struct net_device *netdev, int phy, int reg) |
static void __unused | pcnet32_mdio_write (struct net_device *netdev, int phy, int reg, int val) |
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 use by the hardware More... | |
static int | pcnet32_setup_rx_resources (struct pcnet32_private *priv) |
pcnet32_setup_rx_resources - allocate Rx resources (Descriptors) More... | |
static void | pcnet32_free_rx_resources (struct pcnet32_private *priv) |
static int | pcnet32_setup_tx_resources (struct pcnet32_private *priv) |
pcnet32_setup_tx_resources - allocate Tx resources (Descriptors) More... | |
static void | pcnet32_free_tx_resources (struct pcnet32_private *priv) |
static int | pcnet32_chip_detect (struct pcnet32_private *priv) |
static int | pcnet32_set_ops (struct pcnet32_private *priv) |
pcnet32_set_ops - Determines the ops used to access the registers More... | |
static void | pcnet32_setup_init_block (struct pcnet32_private *priv) |
pcnet32_setup_init_block - setup the NICs initialization block More... | |
static void | pcnet32_setup_probe_phy (struct pcnet32_private *priv) |
pcnet32_setup_probe_phy - go through all PHYs and see which one is present More... | |
static int | pcnet32_setup_mac_addr (struct pcnet32_private *priv) |
pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses More... | |
static void | pcnet32_setup_if_duplex (struct pcnet32_private *priv) |
pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode More... | |
static void | pcnet32_hw_start (struct pcnet32_private *priv) |
pcnet32_hw_start - Starts up the NIC More... | |
static int | pcnet32_open (struct net_device *netdev) |
open - Called when a network interface is made active More... | |
static int | pcnet32_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
transmit - Transmit a packet More... | |
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_tx_complete() More... | |
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 netdev_rx_err() if there was an error receiving the packet More... | |
static void | pcnet32_poll (struct net_device *netdev) |
poll - Poll for received packets More... | |
static void | pcnet32_close (struct net_device *netdev) |
close - Disable network interface More... | |
static void | pcnet32_irq_enable (struct pcnet32_private *priv) |
static void | pcnet32_irq_disable (struct pcnet32_private *priv) |
static void | pcnet32_irq (struct net_device *netdev, int action) |
irq - enable or disable interrupts More... | |
static int | pcnet32_probe (struct pci_device *pdev) |
probe - Initial configuration of NIC More... | |
static void | pcnet32_remove (struct pci_device *pdev) |
remove - Device Removal Routine More... | |
Variables | |
static struct pcnet32_access | pcnet32_wio |
static struct pcnet32_access | pcnet32_dwio |
static struct net_device_operations | pcnet32_operations |
static struct pci_device_id | pcnet32_nics [] |
struct pci_driver pcnet32_driver | __pci_driver |
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
|
static |
Definition at line 42 of file pcnet32.c.
References addr, index, inw(), outw, PCNET32_WIO_RAP, and PCNET32_WIO_RDP.
Referenced by pcnet32_set_ops().
|
static |
Definition at line 48 of file pcnet32.c.
References addr, index, outw, PCNET32_WIO_RAP, PCNET32_WIO_RDP, and val.
|
static |
Definition at line 54 of file pcnet32.c.
References addr, index, inw(), outw, PCNET32_WIO_BDP, and PCNET32_WIO_RAP.
|
static |
Definition at line 60 of file pcnet32.c.
References addr, index, outw, PCNET32_WIO_BDP, PCNET32_WIO_RAP, and val.
|
static |
|
static |
|
static |
Definition at line 76 of file pcnet32.c.
References addr, inw(), and PCNET32_WIO_RESET.
Referenced by pcnet32_close(), pcnet32_probe(), and pcnet32_remove().
|
static |
Definition at line 81 of file pcnet32.c.
References addr, inw(), outw, and PCNET32_WIO_RAP.
Referenced by pcnet32_set_ops().
|
static |
Definition at line 97 of file pcnet32.c.
References addr, index, inl(), outl, PCNET32_DWIO_RAP, and PCNET32_DWIO_RDP.
Referenced by pcnet32_set_ops().
|
static |
Definition at line 103 of file pcnet32.c.
References addr, index, outl, PCNET32_DWIO_RAP, PCNET32_DWIO_RDP, and val.
|
static |
Definition at line 109 of file pcnet32.c.
References addr, index, inl(), outl, PCNET32_DWIO_BDP, and PCNET32_DWIO_RAP.
|
static |
Definition at line 115 of file pcnet32.c.
References addr, index, outl, PCNET32_DWIO_BDP, PCNET32_DWIO_RAP, and val.
|
static |
|
static |
|
static |
Definition at line 131 of file pcnet32.c.
References addr, inl(), and PCNET32_DWIO_RESET.
Referenced by pcnet32_set_ops().
|
static |
Definition at line 136 of file pcnet32.c.
References addr, inl(), outl, and PCNET32_DWIO_RAP.
Referenced by pcnet32_set_ops().
|
static |
Definition at line 154 of file pcnet32.c.
References ioaddr, netdev, priv, net_device::priv, and reg.
Referenced by pcnet32_setup_probe_phy().
|
static |
Definition at line 174 of file pcnet32.c.
References ioaddr, netdev, priv, net_device::priv, reg, and val.
|
static |
pcnet32_refill_rx_ring - Allocates iobufs for every Rx descriptor that doesn't have one and isn't in use by the hardware
priv | Driver private structure |
Definition at line 198 of file pcnet32.c.
References alloc_iob(), pcnet32_rx_desc::base, pcnet32_rx_desc::buf_length, cpu_to_le16, cpu_to_le32, DBG, DBGP, DescOwn, le16_to_cpu, pcnet32_rx_desc::msg_length, NULL, PKT_BUF_SIZE, priv, pcnet32_rx_desc::reserved, RX_RING_SIZE, status, pcnet32_rx_desc::status, virt_to_bus(), and wmb().
Referenced by pcnet32_process_rx_packets(), and pcnet32_setup_rx_resources().
|
static |
pcnet32_setup_rx_resources - allocate Rx resources (Descriptors)
priv | Driver private structure |
rc | Returns 0 on success, negative on failure |
Definition at line 245 of file pcnet32.c.
References DBG, DBGP, ENOMEM, malloc_phys(), memset(), pcnet32_refill_rx_ring(), priv, RX_RING_ALIGN, RX_RING_BYTES, and virt_to_bus().
Referenced by pcnet32_open().
|
static |
Definition at line 267 of file pcnet32.c.
References DBGP, free_iob(), free_phys(), NULL, priv, RX_RING_BYTES, and RX_RING_SIZE.
Referenced by pcnet32_close().
|
static |
pcnet32_setup_tx_resources - allocate Tx resources (Descriptors)
priv | Driver private structure |
rc | Returns 0 on success, negative on failure |
Definition at line 289 of file pcnet32.c.
References DBG, DBGP, ENOMEM, malloc_phys(), memset(), priv, TX_RING_ALIGN, TX_RING_BYTES, and virt_to_bus().
Referenced by pcnet32_open().
|
static |
Definition at line 311 of file pcnet32.c.
References DBGP, free_phys(), priv, and TX_RING_BYTES.
Referenced by pcnet32_close(), and pcnet32_open().
|
static |
Definition at line 319 of file pcnet32.c.
References DBG, ENODEV, ioaddr, media, mii, priv, rc, pcnet32_access::read_bcr, pcnet32_access::read_csr, pcnet32_access::write_bcr, and pcnet32_access::write_csr.
Referenced by pcnet32_probe().
|
static |
pcnet32_set_ops - Determines the ops used to access the registers
priv | Driver private structure |
rc | Returns 0 on success, negative on failure |
Definition at line 437 of file pcnet32.c.
References ENODEV, ioaddr, pcnet32_dwio, pcnet32_dwio_check(), pcnet32_dwio_read_csr(), pcnet32_dwio_reset(), pcnet32_wio, pcnet32_wio_check(), pcnet32_wio_read_csr(), priv, and rc.
Referenced by pcnet32_probe().
|
static |
pcnet32_setup_init_block - setup the NICs initialization block
priv | Driver private structure |
rc | Returns 0 on success, negative on failure |
Definition at line 477 of file pcnet32.c.
References cpu_to_le16, cpu_to_le32, ETH_ALEN, PCNET32_LOG_RX_BUFFERS, PCNET32_LOG_TX_BUFFERS, PCNET32_PORT_PORTSEL, priv, virt_to_bus(), and wmb().
Referenced by pcnet32_open().
|
static |
pcnet32_setup_probe_phy - go through all PHYs and see which one is present
priv | Driver private structure |
Definition at line 513 of file pcnet32.c.
References ioaddr, MII_PHYSID1, MII_PHYSID2, PCNET32_MAX_PHYS, pcnet32_mdio_read(), PCNET32_PORT_MII, and priv.
Referenced by pcnet32_probe().
|
static |
pcnet32_setup_mac_addr - check for inconsistency between CSR12-14 and PROM addresses
priv | Driver private structure |
Definition at line 549 of file pcnet32.c.
References DBG, EADDRNOTAVAIL, ETH_ALEN, inb(), ioaddr, is_valid_ether_addr(), memcmp(), memcpy(), priv, and val.
Referenced by pcnet32_probe().
|
static |
pcnet32_setup_if_duplex - Sets the NICs used interface and duplex mode
priv | Driver private structure |
Definition at line 594 of file pcnet32.c.
References ioaddr, pci_read_config_word(), PCI_SUBDEVICE_ID_AT_2700FX, PCI_SUBDEVICE_ID_AT_2701FX, PCI_SUBSYSTEM_ID, PCI_SUBSYSTEM_VENDOR_ID, PCI_VENDOR_ID_AT, PCNET32_PORT_100, PCNET32_PORT_ASEL, PCNET32_PORT_AUI, PCNET32_PORT_FD, PCNET32_PORT_GPSI, PCNET32_PORT_PORTSEL, priv, and val.
Referenced by pcnet32_open().
|
static |
pcnet32_hw_start - Starts up the NIC
priv | Driver private structure |
Definition at line 666 of file pcnet32.c.
References Init, InitDone, ioaddr, priv, and Strt.
Referenced by pcnet32_open().
|
static |
open - Called when a network interface is made active
netdev | Network device |
rc | Return status code, 0 on success, negative value on failure |
Definition at line 691 of file pcnet32.c.
References BablMask, DBG, InitDoneMask, ioaddr, MissFrameMask, netdev, pcnet32_free_tx_resources(), pcnet32_hw_start(), pcnet32_setup_if_duplex(), pcnet32_setup_init_block(), pcnet32_setup_rx_resources(), pcnet32_setup_tx_resources(), PCNET32_SWSTYLE_PCNET32, priv, net_device::priv, rc, RxIntMask, TxIntMask, val, and virt_to_bus().
|
static |
transmit - Transmit a packet
netdev | Network device |
iobuf | I/O buffer |
rc | Returns 0 on success, negative on failure |
Definition at line 755 of file pcnet32.c.
References pcnet32_tx_desc::base, cpu_to_le16, cpu_to_le32, io_buffer::data, DBG, DBGP, DescOwn, EndOfPacket, ENOTSUP, IntEnable, ioaddr, iob_len(), pcnet32_tx_desc::length, pcnet32_tx_desc::misc, netdev, priv, net_device::priv, StartOfPacket, pcnet32_tx_desc::status, TX_RING_SIZE, TxDemand, virt_to_bus(), and wmb().
|
static |
pcnet32_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_complete()
netdev | Network device |
Definition at line 803 of file pcnet32.c.
References DBG, DBGP, DescOwn, le16_to_cpu, memset(), netdev, netdev_tx_complete(), priv, net_device::priv, status, pcnet32_tx_desc::status, TX_RING_SIZE, and virt_to_bus().
Referenced by pcnet32_poll().
|
static |
pcnet32_process_rx_packets - Checks for received packets, reports them to iPXE with netdev_rx() or netdev_rx_err() if there was an error receiving the packet
netdev | Network device |
Definition at line 849 of file pcnet32.c.
References DBG, DBGP, DescOwn, EINVAL, iob_put, le16_to_cpu, le32_to_cpu, len, memset(), pcnet32_rx_desc::msg_length, netdev, netdev_rx(), netdev_rx_err(), NULL, pcnet32_refill_rx_ring(), priv, net_device::priv, rmb, RX_RING_SIZE, status, pcnet32_rx_desc::status, and virt_to_bus().
Referenced by pcnet32_poll().
|
static |
poll - Poll for received packets
netdev | Network device |
Definition at line 914 of file pcnet32.c.
References DBG, DBGP, ioaddr, netdev, pcnet32_process_rx_packets(), pcnet32_process_tx_packets(), priv, net_device::priv, and status.
|
static |
close - Disable network interface
netdev | network interface device structure |
Definition at line 947 of file pcnet32.c.
References DBGP, ioaddr, netdev, pcnet32_free_rx_resources(), pcnet32_free_tx_resources(), PCNET32_SWSTYLE_LANCE, pcnet32_wio_reset(), priv, net_device::priv, and Stop.
|
static |
Definition at line 968 of file pcnet32.c.
References DBGP, IntEnable, ioaddr, priv, RxIntMask, TxIntMask, and val.
Referenced by pcnet32_irq().
|
static |
|
static |
irq - enable or disable interrupts
netdev | network adapter |
action | requested interrupt action |
Definition at line 1004 of file pcnet32.c.
References DBGP, netdev, pcnet32_irq_disable(), pcnet32_irq_enable(), priv, and net_device::priv.
|
static |
probe - Initial configuration of NIC
pdev | PCI device |
ent | PCI IDs |
rc | Return status code |
Definition at line 1037 of file pcnet32.c.
References adjust_pci_device(), alloc_etherdev(), DBG, DBGP, pci_device::dev, net_device::dev, pci_device_id::device, ENOMEM, eth_ntoa(), net_device::hw_addr, pci_device::id, ioaddr, pci_device::ioaddr, pci_device_id::name, netdev, netdev_init(), netdev_link_up(), netdev_put(), pci_set_drvdata(), pcnet32_chip_detect(), pcnet32_operations, PCNET32_PORT_ASEL, PCNET32_PORT_FD, PCNET32_PORT_GPSI, pcnet32_set_ops(), pcnet32_setup_mac_addr(), pcnet32_setup_probe_phy(), pcnet32_wio_reset(), priv, net_device::priv, rc, register_netdev(), and pci_device_id::vendor.
|
static |
remove - Device Removal Routine
pdev | PCI device information struct |
Definition at line 1135 of file pcnet32.c.
References DBGP, ioaddr, pci_device::ioaddr, netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), pcnet32_wio_reset(), and unregister_netdev().
|
static |
Definition at line 87 of file pcnet32.c.
Referenced by pcnet32_set_ops().
|
static |
Definition at line 143 of file pcnet32.c.
Referenced by pcnet32_set_ops().
|
static |
Definition at line 1020 of file pcnet32.c.
Referenced by pcnet32_probe().
|
static |
struct pci_driver pcnet32_driver __pci_driver |