iPXE
|
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.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 <ipxe/nvs.h>
#include "3c90x.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (BSD2) | |
static void | a3c90x_internal_IssueCommand (int ioaddr, int cmd, int param) |
a3c90x_internal_IssueCommand: sends a command to the 3c90x card and waits for it's completion More... | |
static void | a3c90x_internal_SetWindow (struct INF_3C90X *inf_3c90x, int window) |
a3c90x_internal_SetWindow: selects a register window set. More... | |
static void | a3c90x_internal_WaitForEeprom (struct INF_3C90X *inf_3c90x) |
static int | a3c90x_internal_ReadEeprom (struct nvs_device *nvs, unsigned int address, void *data, size_t len) |
a3c90x_internal_ReadEeprom - nvs routine to read eeprom data We only support reading one word(2 byte). More... | |
static int | a3c90x_internal_WriteEeprom (struct nvs_device *nvs __unused, unsigned int address __unused, const void *data __unused, size_t len __unused) |
a3c90x_internal_WriteEeprom - nvs routine to write eeprom data currently not implemented More... | |
static void | a3c90x_internal_ReadEepromContents (struct INF_3C90X *inf_3c90x) |
static void | a3c90x_reset (struct INF_3C90X *inf_3c90x) |
a3c90x_reset: exported function that resets the card to its default state. More... | |
static int | a3c90x_setup_tx_ring (struct INF_3C90X *p) |
a3c90x_setup_tx_ring - Allocates TX ring, initialize tx_desc values More... | |
static void | a3c90x_process_tx_packets (struct net_device *netdev) |
a3c90x_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_complete(); More... | |
static void | a3c90x_free_tx_ring (struct INF_3C90X *p) |
static int | a3c90x_transmit (struct net_device *netdev, struct io_buffer *iob) |
a3c90x_transmit - Transmits a packet. More... | |
static void | a3c90x_prepare_rx_desc (struct INF_3C90X *p, unsigned int index) |
a3c90x_prepare_rx_desc - fills the rx desc with initial data More... | |
static void | a3c90x_refill_rx_ring (struct INF_3C90X *p) |
a3c90x_refill_rx_ring -checks every entry in the rx ring and reallocates them as necessary. More... | |
static int | a3c90x_setup_rx_ring (struct INF_3C90X *p) |
a3c90x_setup_rx_ring - Allocates RX ring, initialize rx_desc values More... | |
static void | a3c90x_free_rx_ring (struct INF_3C90X *p) |
static void | a3c90x_free_rx_iobuf (struct INF_3C90X *p) |
static void | a3c90x_process_rx_packets (struct net_device *netdev) |
a3c90x_process_rx_packets - Checks for received packets, reports them to iPXE with netdev_rx() or netdev_rx_err() if there was an error while receiving the packet More... | |
static void | a3c90x_poll (struct net_device *netdev) |
a3c90x_poll - Routine that gets called periodically. More... | |
static void | a3c90x_free_resources (struct INF_3C90X *p) |
static void | a3c90x_remove (struct pci_device *pci) |
a3c90x_remove - Routine to remove the card. More... | |
static void | a3c90x_irq (struct net_device *netdev, int enable) |
static void | a3c90x_hw_start (struct net_device *netdev) |
a3c90x_hw_start - Initialize hardware, copy MAC address to NIC registers, set default receiver More... | |
static int | a3c90x_open (struct net_device *netdev) |
a3c90x_open - Routine to initialize the card. More... | |
static void | a3c90x_close (struct net_device *netdev) |
a3c90x_close - free()s TX and RX ring, disablex RX/TX, resets NIC More... | |
static int | a3c90x_probe (struct pci_device *pci) |
a3c90x_probe: exported routine to probe for the 3c905 card. More... | |
Variables | |
static struct net_device_operations | a3c90x_operations |
static struct pci_device_id | a3c90x_nics [] |
struct pci_driver a3c90x_driver | __pci_driver |
FILE_LICENCE | ( | BSD2 | ) |
|
static |
a3c90x_internal_IssueCommand: sends a command to the 3c90x card and waits for it's completion
ioaddr | IOAddress of the NIC |
cmd | Command to be issued |
param | Command parameter |
Definition at line 70 of file 3c90x.c.
References cmd, DBG, DBG2, DBGP, INT_CMDINPROGRESS, inw(), ioaddr, outw, param, regCommandIntStatus_w, and val.
Referenced by a3c90x_hw_start(), a3c90x_internal_SetWindow(), a3c90x_irq(), a3c90x_open(), a3c90x_poll(), a3c90x_prepare_rx_desc(), a3c90x_reset(), and a3c90x_transmit().
|
static |
a3c90x_internal_SetWindow: selects a register window set.
inf_3c90x | private NIC data |
window | window to be selected |
Definition at line 99 of file 3c90x.c.
References a3c90x_internal_IssueCommand(), cmdSelectRegisterWindow, INF_3C90X::CurrentWindow, DBGP, and INF_3C90X::IOAddr.
Referenced by a3c90x_hw_start(), a3c90x_internal_ReadEeprom(), a3c90x_open(), and a3c90x_reset().
|
static |
Definition at line 114 of file 3c90x.c.
References DBG, DBGP, EEPROM_TIMEOUT, eepromBusy, inw(), INF_3C90X::IOAddr, regEepromCommand_0_w, and udelay().
Referenced by a3c90x_internal_ReadEeprom().
|
static |
a3c90x_internal_ReadEeprom - nvs routine to read eeprom data We only support reading one word(2 byte).
The nvs subsystem will make sure that the routine will never be called with len != 2.
nvs | nvs data. |
address | eeprom address to read data from. |
data | data is put here. |
len | number of bytes to read. |
Definition at line 141 of file 3c90x.c.
References a3c90x_internal_SetWindow(), a3c90x_internal_WaitForEeprom(), address, assert(), container_of, data, DBGP, dest, eepromRead, eepromRead_556, inw(), INF_3C90X::IOAddr, INF_3C90X::is3c556, len, INF_3C90X::nvs, outw, regEepromCommand_0_w, regEepromData_0_w, and winEepromBios0.
Referenced by a3c90x_probe().
|
static |
a3c90x_internal_WriteEeprom - nvs routine to write eeprom data currently not implemented
nvs | nvs data. |
address | eeprom address to read data from. |
data | data is put here. |
len | number of bytes to read. |
Definition at line 179 of file 3c90x.c.
References ENOTSUP.
Referenced by a3c90x_probe().
|
static |
Definition at line 186 of file 3c90x.c.
References DBGP, INF_3C90X::eeprom, INF_3C90X::isBrev, INF_3C90X::nvs, and nvs_read().
Referenced by a3c90x_probe().
|
static |
a3c90x_reset: exported function that resets the card to its default state.
This is so the Linux driver can re-set the card up the way it wants to. If CFG_3C90X_PRESERVE_XCVR is defined, then the reset will not alter the selected transceiver that we used to download the boot image.
inf_3c90x | Private NIC data |
Definition at line 204 of file 3c90x.c.
References a3c90x_internal_IssueCommand(), a3c90x_internal_SetWindow(), cmdAcknowledgeInterrupt, cmdGlobalReset, cmdRxEnable, cmdSetIndicationEnable, cmdTxEnable, DBG2, DBGP, globalResetMaskNetwork, INT_TXCOMPLETE, INT_UPCOMPLETE, INF_3C90X::IOAddr, outw, regStationMask_2_3w, and winAddressing2.
Referenced by a3c90x_close(), a3c90x_open(), a3c90x_probe(), and a3c90x_remove().
|
static |
a3c90x_setup_tx_ring - Allocates TX ring, initialize tx_desc values
p | Private NIC data |
Returns | 0 on success, negative on failure |
Definition at line 248 of file 3c90x.c.
References DBG, DBGP, ENOMEM, malloc_phys(), memset(), INF_3C90X::tx_cnt, INF_3C90X::tx_cur, INF_3C90X::tx_ring, TX_RING_ALIGN, TX_RING_SIZE, and INF_3C90X::tx_tail.
Referenced by a3c90x_open().
|
static |
a3c90x_process_tx_packets - Checks for successfully sent packets, reports them to iPXE with netdev_tx_complete();
netdev | Network device info |
Definition at line 273 of file 3c90x.c.
References DBG2, DBGP, inl(), INF_3C90X::IOAddr, iob_len(), netdev, netdev_tx_complete(), net_device::priv, regDnListPtr_l, INF_3C90X::tx_cnt, INF_3C90X::tx_cur, INF_3C90X::tx_iobuf, INF_3C90X::tx_ring, TX_RING_SIZE, INF_3C90X::tx_tail, and virt_to_bus().
Referenced by a3c90x_poll().
|
static |
Definition at line 303 of file 3c90x.c.
References DBGP, free_phys(), NULL, INF_3C90X::tx_ring, and TX_RING_SIZE.
Referenced by a3c90x_free_resources().
|
static |
a3c90x_transmit - Transmits a packet.
netdev | Network device info |
iob | io_buffer containing the data to be send |
Returns | 0 on success, negative on failure |
Definition at line 320 of file 3c90x.c.
References a3c90x_internal_IssueCommand(), cmdStallCtl, io_buffer::data, TXD::DataAddr, TXD::DataLength, DBG, DBGP, TXD::DnNextPtr, dnStall, dnUnStall, downLastFrag, ENOBUFS, TXD::FrameStartHeader, fshRndupDefeat, fshTxIndicate, inl(), INF_3C90X::IOAddr, iob_len(), INF_3C90X::isBrev, len, netdev, outl, net_device::priv, regDnListPtr_l, INF_3C90X::tx_cnt, INF_3C90X::tx_cur, INF_3C90X::tx_iobuf, INF_3C90X::tx_ring, TX_RING_SIZE, and virt_to_bus().
|
static |
a3c90x_prepare_rx_desc - fills the rx desc with initial data
p | NIC private data |
index | Index for rx_iobuf and rx_ring array |
Definition at line 393 of file 3c90x.c.
References a3c90x_internal_IssueCommand(), cmdStallCtl, io_buffer::data, RXD::DataAddr, RXD::DataLength, DBG2, DBGP, index, INF_3C90X::IOAddr, RX_BUF_SIZE, INF_3C90X::rx_iobuf, INF_3C90X::rx_ring, upLastFrag, RXD::UpPktStatus, upStall, upUnStall, and virt_to_bus().
Referenced by a3c90x_refill_rx_ring().
|
static |
a3c90x_refill_rx_ring -checks every entry in the rx ring and reallocates them as necessary.
Then it calls a3c90x_prepare_rx_desc to fill the rx desc with initial data.
p | NIC private data |
Definition at line 420 of file 3c90x.c.
References a3c90x_prepare_rx_desc(), alloc_iob(), DBG, DBGP, NULL, RX_BUF_SIZE, INF_3C90X::rx_iobuf, INF_3C90X::rx_ring, RX_RING_SIZE, status, upComplete, and RXD::UpPktStatus.
Referenced by a3c90x_process_rx_packets(), and a3c90x_setup_rx_ring().
|
static |
a3c90x_setup_rx_ring - Allocates RX ring, initialize rx_desc values
p | Private NIC data |
Returns | 0 on success, negative on failure |
Definition at line 457 of file 3c90x.c.
References a3c90x_refill_rx_ring(), DBG, DBGP, ENOMEM, malloc_phys(), NULL, INF_3C90X::rx_cur, INF_3C90X::rx_iobuf, INF_3C90X::rx_ring, RX_RING_ALIGN, RX_RING_SIZE, upComplete, RXD::UpNextPtr, RXD::UpPktStatus, and virt_to_bus().
Referenced by a3c90x_open().
|
static |
Definition at line 490 of file 3c90x.c.
References DBGP, free_phys(), NULL, INF_3C90X::rx_ring, and RX_RING_SIZE.
Referenced by a3c90x_free_resources().
|
static |
Definition at line 498 of file 3c90x.c.
References DBGP, free_iob(), NULL, INF_3C90X::rx_iobuf, and RX_RING_SIZE.
Referenced by a3c90x_free_resources().
|
static |
a3c90x_process_rx_packets - Checks for received packets, reports them to iPXE with netdev_rx() or netdev_rx_err() if there was an error while receiving the packet
netdev | Network device info |
Definition at line 517 of file 3c90x.c.
References a3c90x_refill_rx_ring(), DBG, DBG2, DBGP, EINVAL, iob_put, netdev, netdev_rx(), netdev_rx_err(), NULL, net_device::priv, INF_3C90X::rx_cur, INF_3C90X::rx_iobuf, INF_3C90X::rx_ring, RX_RING_SIZE, upComplete, upError, and RXD::UpPktStatus.
Referenced by a3c90x_poll().
|
static |
a3c90x_poll - Routine that gets called periodically.
Here we hanle transmitted and received packets. We could also check the link status from time to time, which we currently don't do.
netdev | Network device info |
Definition at line 568 of file 3c90x.c.
References a3c90x_internal_IssueCommand(), a3c90x_process_rx_packets(), a3c90x_process_tx_packets(), cmdAcknowledgeInterrupt, DBG2, DBGP, INT_TXCOMPLETE, inw(), INF_3C90X::IOAddr, netdev, outb, net_device::priv, regCommandIntStatus_w, and regTxStatus_b.
|
static |
Definition at line 596 of file 3c90x.c.
References a3c90x_free_rx_iobuf(), a3c90x_free_rx_ring(), a3c90x_free_tx_ring(), and DBGP.
Referenced by a3c90x_close(), and a3c90x_open().
|
static |
a3c90x_remove - Routine to remove the card.
Unregisters the NIC from iPXE, disables RX/TX and resets the card.
pci | PCI device info |
Definition at line 611 of file 3c90x.c.
References a3c90x_reset(), cmdRxDisable, cmdTxDisable, DBGP, INF_3C90X::IOAddr, netdev, netdev_nullify(), netdev_put(), outw, pci_get_drvdata(), net_device::priv, regCommandIntStatus_w, and unregister_netdev().
|
static |
Definition at line 629 of file 3c90x.c.
References a3c90x_internal_IssueCommand(), cmdAcknowledgeInterrupt, cmdSetInterruptEnable, DBGP, INT_TXCOMPLETE, INT_UPCOMPLETE, INF_3C90X::IOAddr, netdev, and net_device::priv.
|
static |
a3c90x_hw_start - Initialize hardware, copy MAC address to NIC registers, set default receiver
Definition at line 654 of file 3c90x.c.
References a3c90x_internal_IssueCommand(), a3c90x_internal_SetWindow(), c, cfg, cmdAcknowledgeInterrupt, cmdEnableDcConverter, cmdSetIndicationEnable, cmdSetInterruptEnable, cmdSetRxFilter, cmdTxReset, DBG, DBG2, DBGP, INF_3C90X::eeprom, ETH_ALEN, inl(), INT_TXCOMPLETE, INT_UPCOMPLETE, inw(), INF_3C90X::IOAddr, INF_3C90X::is3c556, INF_3C90X::isBrev, link100BaseFX, link10Base2, linkAUI, linkAutoneg, linkExternalMII, linkMII, net_device::ll_addr, netdev, outb, outl, outw, net_device::priv, regInternalConfig_3_l, regResetMediaOptions_3_w, regResetOptions_2_w, regStationAddress_2_3w, regStationMask_2_3w, regTxFreeThresh_b, tmp, winAddressing2, winTxRxOptions3, and XCVR_MAGIC.
Referenced by a3c90x_open().
|
static |
a3c90x_open - Routine to initialize the card.
Initialize hardware, allocate TX and RX ring, send RX ring address to the NIC.
netdev | Network device info |
Returns | 0 on success, negative on failure |
Definition at line 796 of file 3c90x.c.
References a3c90x_free_resources(), a3c90x_hw_start(), a3c90x_internal_IssueCommand(), a3c90x_internal_SetWindow(), a3c90x_reset(), a3c90x_setup_rx_ring(), a3c90x_setup_tx_ring(), cmdRxEnable, cmdStallCtl, cmdTxEnable, DBG, DBGP, error, INF_3C90X::IOAddr, netdev, outl, net_device::priv, rc, regMaxPktSize_3_w, regUpListPtr_l, RX_BUF_SIZE, INF_3C90X::rx_ring, upStall, upUnStall, virt_to_bus(), and winTxRxOptions3.
|
static |
a3c90x_close - free()s TX and RX ring, disablex RX/TX, resets NIC
netdev | Network device info |
Definition at line 846 of file 3c90x.c.
References a3c90x_free_resources(), a3c90x_reset(), cmdRxDisable, cmdTxDisable, DBGP, INF_3C90X::IOAddr, netdev, outw, net_device::priv, and regCommandIntStatus_w.
|
static |
a3c90x_probe: exported routine to probe for the 3c905 card.
If this routine is called, the pci functions did find the card. We read the eeprom here and get the MAC address. Initialization is done in a3c90x_open().
pci | PCI device info @ pci_id PCI device IDs |
rc | Returns 0 on success, negative on failure |
Definition at line 877 of file 3c90x.c.
References a3c90x_internal_ReadEeprom(), a3c90x_internal_ReadEepromContents(), a3c90x_internal_WriteEeprom(), a3c90x_operations, a3c90x_reset(), adjust_pci_device(), alloc_etherdev(), nvs_device::block_size, INF_3C90X::CurrentWindow, DBG, DBG2, DBGP, pci_device::dev, net_device::dev, pci_device::device, INF_3C90X::eeprom, eepromHwAddrOffset, EINVAL, ENOMEM, net_device::hw_addr, pci_device::ioaddr, INF_3C90X::IOAddr, INF_3C90X::is3c556, INF_3C90X::isBrev, memset(), netdev, netdev_init(), netdev_link_up(), netdev_put(), INF_3C90X::nvs, pci_set_drvdata(), net_device::priv, rc, nvs_device::read, register_netdev(), nvs_device::size, pci_device::vendor, winNone, nvs_device::word_len_log2, and nvs_device::write.
|
static |
Definition at line 858 of file 3c90x.c.
Referenced by a3c90x_probe().
|
static |
struct pci_driver a3c90x_driver __pci_driver |