iPXE
|
Intel 10/100/1000 network card driver. More...
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/dma.h>
#include <ipxe/pci.h>
#include <ipxe/profile.h>
#include "intel.h"
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | intel_read_eeprom (struct nvs_device *nvs, unsigned int address, void *data, size_t len) |
Read data from EEPROM. More... | |
static int | intel_write_eeprom (struct nvs_device *nvs, unsigned int address __unused, const void *data __unused, size_t len __unused) |
Write data to EEPROM. More... | |
static int | intel_init_eeprom (struct intel_nic *intel) |
Initialise EEPROM. More... | |
static int | intel_fetch_mac_eeprom (struct intel_nic *intel, uint8_t *hw_addr) |
Fetch initial MAC address from EEPROM. More... | |
static int | intel_fetch_mac (struct intel_nic *intel, uint8_t *hw_addr) |
Fetch initial MAC address. More... | |
static int | intel_reset (struct intel_nic *intel) |
Reset hardware. More... | |
static void | intel_check_link (struct net_device *netdev) |
Check link state. More... | |
void | intel_describe_tx (struct intel_descriptor *tx, physaddr_t addr, size_t len) |
Populate transmit descriptor. More... | |
void | intel_describe_tx_adv (struct intel_descriptor *tx, physaddr_t addr, size_t len) |
Populate advanced transmit descriptor. More... | |
void | intel_describe_rx (struct intel_descriptor *rx, physaddr_t addr, size_t len __unused) |
Populate receive descriptor. More... | |
static int | intel_disable_ring (struct intel_nic *intel, unsigned int reg) |
Disable descriptor ring. More... | |
void | intel_reset_ring (struct intel_nic *intel, unsigned int reg) |
Reset descriptor ring. More... | |
int | intel_create_ring (struct intel_nic *intel, struct intel_ring *ring) |
Create descriptor ring. More... | |
void | intel_destroy_ring (struct intel_nic *intel, struct intel_ring *ring) |
Destroy descriptor ring. More... | |
void | intel_refill_rx (struct intel_nic *intel) |
Refill receive descriptor ring. More... | |
void | intel_empty_rx (struct intel_nic *intel) |
Discard unused receive I/O buffers. More... | |
static int | intel_open (struct net_device *netdev) |
Open network device. More... | |
static void | intel_close (struct net_device *netdev) |
Close network device. More... | |
int | intel_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
void | intel_poll_tx (struct net_device *netdev) |
Poll for completed packets. More... | |
void | intel_poll_rx (struct net_device *netdev) |
Poll for received packets. More... | |
static void | intel_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static void | intel_irq (struct net_device *netdev, int enable) |
Enable or disable interrupts. More... | |
static int | intel_probe (struct pci_device *pci) |
Probe PCI device. More... | |
static void | intel_remove (struct pci_device *pci) |
Remove PCI device. More... | |
Variables | |
static struct profiler intel_vm_tx_profiler | __profiler |
VM transmit profiler. More... | |
static struct net_device_operations | intel_operations |
Intel network device operations. More... | |
static struct pci_device_id | intel_nics [] |
Intel PCI device IDs. More... | |
struct pci_driver intel_driver | __pci_driver |
Intel PCI driver. More... | |
Intel 10/100/1000 network card driver.
Definition in file intel.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Read data from EEPROM.
nvs | NVS device |
address | Address from which to read |
data | Data buffer |
len | Length of data buffer |
rc | Return status code |
Definition at line 74 of file intel.c.
References address, assert(), container_of, cpu_to_le16, data, DBGC, intel_nic::eerd_addr_shift, intel_nic::eerd_done, ETIMEDOUT, INTEL_EEPROM_MAX_WAIT_MS, INTEL_EERD, INTEL_EERD_DATA, INTEL_EERD_START, len, mdelay(), readl(), intel_nic::regs, value, and writel().
Referenced by intel_init_eeprom().
|
static |
Write data to EEPROM.
nvs | NVS device |
address | Address to which to write |
data | Data buffer |
len | Length of data buffer |
rc | Return status code |
Definition at line 119 of file intel.c.
References container_of, DBGC, and ENOTSUP.
Referenced by intel_init_eeprom().
|
static |
Initialise EEPROM.
intel | Intel device |
rc | Return status code |
Definition at line 136 of file intel.c.
References nvs_device::block_size, DBGC, intel_nic::eeprom, intel_nic::eerd_addr_shift, intel_nic::eerd_done, ETIMEDOUT, INTEL_EEPROM_MAX_WAIT_MS, INTEL_EEPROM_MIN_SIZE_WORDS, INTEL_EEPROM_WORD_LEN_LOG2, INTEL_EERD, INTEL_EERD_ADDR_SHIFT_LARGE, INTEL_EERD_ADDR_SHIFT_SMALL, INTEL_EERD_DONE_LARGE, INTEL_EERD_DONE_SMALL, INTEL_EERD_START, intel_read_eeprom(), intel_write_eeprom(), mdelay(), nvs_device::read, readl(), intel_nic::regs, nvs_device::size, value, nvs_device::word_len_log2, nvs_device::write, and writel().
Referenced by intel_fetch_mac_eeprom().
Fetch initial MAC address from EEPROM.
intel | Intel device |
hw_addr | Hardware address to fill in |
rc | Return status code |
Definition at line 198 of file intel.c.
References DBGC, intel_nic::eeprom, ETH_ALEN, eth_ntoa(), INTEL_EEPROM_MAC, intel_init_eeprom(), nvs_read(), intel_nic::port, rc, and strerror().
Referenced by intel_fetch_mac().
Fetch initial MAC address.
intel | Intel device |
hw_addr | Hardware address to fill in |
rc | Return status code |
Definition at line 229 of file intel.c.
References cpu_to_le32, DBGC, ENOENT, ETH_ALEN, eth_ntoa(), intel_fetch_mac_eeprom(), INTEL_RAH0, INTEL_RAL0, is_valid_ether_addr(), mac, memcpy(), rc, readl(), and intel_nic::regs.
Referenced by intel_probe().
|
static |
Reset hardware.
intel | Intel device |
rc | Return status code |
Definition at line 266 of file intel.c.
References ctrl, DBGC, intel_nic::flags, INTEL_CTRL, INTEL_CTRL_ASDE, INTEL_CTRL_FRCDPLX, INTEL_CTRL_FRCSPD, INTEL_CTRL_LRST, INTEL_CTRL_PHY_RST, INTEL_CTRL_RST, INTEL_CTRL_SLU, INTEL_NO_ASDE, INTEL_NO_PHY_RST, INTEL_PBA, INTEL_PBS, INTEL_PBS_ERRATA, INTEL_PBSIZE_RST, INTEL_RESET_DELAY_MS, INTEL_RXPBS, INTEL_RXPBS_I210, INTEL_STATUS, INTEL_STATUS_LU, INTEL_TXPBS, INTEL_TXPBS_I210, mdelay(), readl(), intel_nic::regs, status, and writel().
Referenced by intel_close(), intel_probe(), and intel_remove().
|
static |
Check link state.
netdev | Network device |
Definition at line 365 of file intel.c.
References DBGC, INTEL_STATUS, INTEL_STATUS_LU, netdev, netdev_link_down(), netdev_link_up(), net_device::priv, readl(), intel_nic::regs, and status.
Referenced by intel_open(), intel_poll(), and intel_probe().
void intel_describe_tx | ( | struct intel_descriptor * | tx, |
physaddr_t | addr, | ||
size_t | len | ||
) |
Populate transmit descriptor.
tx | Transmit descriptor |
addr | Data buffer address |
len | Length of data |
Definition at line 395 of file intel.c.
References addr, cpu_to_le16, cpu_to_le64, INTEL_DESC_CMD_EOP, INTEL_DESC_CMD_IFCS, INTEL_DESC_CMD_RS, len, and tx.
Referenced by intel_probe(), and intelx_probe().
void intel_describe_tx_adv | ( | struct intel_descriptor * | tx, |
physaddr_t | addr, | ||
size_t | len | ||
) |
Populate advanced transmit descriptor.
tx | Transmit descriptor |
addr | Data buffer address |
len | Length of data |
Definition at line 414 of file intel.c.
References addr, cpu_to_le16, cpu_to_le32, cpu_to_le64, INTEL_DESC_CMD_DEXT, INTEL_DESC_CMD_EOP, INTEL_DESC_CMD_IFCS, INTEL_DESC_CMD_RS, INTEL_DESC_FL_DTYP_DATA, INTEL_DESC_STATUS_PAYLEN, len, and tx.
Referenced by intelxvf_probe().
void intel_describe_rx | ( | struct intel_descriptor * | rx, |
physaddr_t | addr, | ||
size_t len | __unused | ||
) |
Populate receive descriptor.
rx | Receive descriptor |
addr | Data buffer address |
len | Length of data |
Definition at line 433 of file intel.c.
References addr, cpu_to_le64, and rx.
Referenced by intel_probe(), intelx_probe(), and intelxvf_probe().
|
static |
Disable descriptor ring.
intel | Intel device |
reg | Register block |
rc | Return status code |
Definition at line 456 of file intel.c.
References DBGC, ETIMEDOUT, INTEL_DISABLE_MAX_WAIT_MS, INTEL_xDCTL, INTEL_xDCTL_ENABLE, mdelay(), readl(), reg, intel_nic::regs, and writel().
Referenced by intel_reset_ring().
void intel_reset_ring | ( | struct intel_nic * | intel, |
unsigned int | reg | ||
) |
Reset descriptor ring.
intel | Intel device |
reg | Register block |
rc | Return status code |
Definition at line 487 of file intel.c.
References intel_disable_ring(), INTEL_xDBAH, INTEL_xDBAL, INTEL_xDH, INTEL_xDLEN, INTEL_xDT, reg, intel_nic::regs, and writel().
Referenced by intel_destroy_ring(), and intelxvf_open().
int intel_create_ring | ( | struct intel_nic * | intel, |
struct intel_ring * | ring | ||
) |
Create descriptor ring.
intel | Intel device |
ring | Descriptor ring |
rc | Return status code |
Definition at line 511 of file intel.c.
References address, DBGC, intel_ring::desc, intel_nic::dma, dma(), dma_alloc(), ENOMEM, INTEL_xDBAH, INTEL_xDBAL, INTEL_xDCTL, INTEL_xDCTL_ENABLE, INTEL_xDH, INTEL_xDLEN, INTEL_xDT, intel_ring::len, intel_ring::map, memset(), readl(), intel_ring::reg, intel_nic::regs, virt_to_phys(), and writel().
Referenced by intel_open(), intelx_open(), and intelxvf_open().
void intel_destroy_ring | ( | struct intel_nic * | intel, |
struct intel_ring * | ring | ||
) |
Destroy descriptor ring.
intel | Intel device |
ring | Descriptor ring |
Definition at line 563 of file intel.c.
References intel_ring::cons, intel_ring::desc, dma_free(), intel_reset_ring(), intel_ring::len, intel_ring::map, NULL, intel_ring::prod, and intel_ring::reg.
Referenced by intel_close(), intel_open(), intelx_close(), intelx_open(), intelxvf_close(), and intelxvf_open().
void intel_refill_rx | ( | struct intel_nic * | intel | ) |
Refill receive descriptor ring.
intel | Intel device |
Definition at line 580 of file intel.c.
References alloc_rx_iob(), assert(), intel_ring::cons, io_buffer::data, DBGC2, intel_ring::desc, intel_ring::describe, intel_nic::dma, INTEL_NUM_RX_DESC, INTEL_RX_FILL, INTEL_RX_MAX_LEN, INTEL_xDT, iob_dma(), NULL, intel_ring::prod, profile_exclude(), profile_start(), profile_stop(), intel_ring::reg, intel_nic::regs, rx, intel_nic::rx, intel_nic::rx_iobuf, virt_to_phys(), wmb(), and writel().
Referenced by intel_open(), intel_poll(), intelx_open(), intelx_poll(), intelxvf_open(), and intelxvf_poll().
void intel_empty_rx | ( | struct intel_nic * | intel | ) |
Discard unused receive I/O buffers.
intel | Intel device |
Definition at line 630 of file intel.c.
References free_rx_iob(), INTEL_NUM_RX_DESC, NULL, and intel_nic::rx_iobuf.
Referenced by intel_close(), intelx_close(), and intelxvf_close().
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 647 of file intel.c.
References DBGC, intel_nic::flags, intel_nic::force_icr, intel_check_link(), intel_create_ring(), intel_destroy_ring(), INTEL_FEXTNVM11, INTEL_FEXTNVM11_WTF, INTEL_IRQ_RXT0, INTEL_RAH0, INTEL_RAH0_AV, INTEL_RAL0, INTEL_RCTL, INTEL_RCTL_BAM, INTEL_RCTL_BSIZE_2048, INTEL_RCTL_BSIZE_BSEX_MASK, INTEL_RCTL_EN, INTEL_RCTL_MPE, INTEL_RCTL_SECRC, INTEL_RCTL_UPE, intel_refill_rx(), INTEL_RST_HANG, INTEL_TCTL, INTEL_TCTL_COLD_DEFAULT, INTEL_TCTL_COLD_MASK, INTEL_TCTL_CT_DEFAULT, INTEL_TCTL_CT_MASK, INTEL_TCTL_EN, INTEL_TCTL_PSP, INTEL_VMWARE, le32_to_cpu, net_device::ll_addr, mac, memcpy(), memset(), netdev, net_device::priv, rc, readl(), intel_nic::regs, intel_nic::rx, intel_nic::tx, and writel().
|
static |
Close network device.
netdev | Network device |
Definition at line 723 of file intel.c.
References intel_destroy_ring(), intel_empty_rx(), INTEL_RCTL, intel_reset(), INTEL_TCTL, netdev, net_device::priv, intel_nic::regs, intel_nic::rx, intel_nic::tx, and writel().
int intel_transmit | ( | struct net_device * | netdev, |
struct io_buffer * | iobuf | ||
) |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 752 of file intel.c.
References intel_ring::cons, io_buffer::data, DBGC, DBGC2, intel_ring::desc, intel_ring::describe, ENOBUFS, INTEL_NUM_TX_DESC, INTEL_TX_FILL, INTEL_xDT, iob_dma(), iob_len(), len, netdev, net_device::priv, intel_ring::prod, profile_exclude(), profile_start(), profile_stop(), intel_ring::reg, intel_nic::regs, tx, intel_nic::tx, virt_to_phys(), wmb(), and writel().
void intel_poll_tx | ( | struct net_device * | netdev | ) |
Poll for completed packets.
netdev | Network device |
Definition at line 791 of file intel.c.
References intel_ring::cons, cpu_to_le32, DBGC2, intel_ring::desc, INTEL_DESC_STATUS_DD, INTEL_NUM_TX_DESC, netdev, netdev_tx_complete_next(), net_device::priv, intel_ring::prod, tx, and intel_nic::tx.
Referenced by intel_poll(), intelx_poll(), and intelxvf_poll().
void intel_poll_rx | ( | struct net_device * | netdev | ) |
Poll for received packets.
netdev | Network device |
Definition at line 820 of file intel.c.
References intel_ring::cons, cpu_to_le32, DBGC, DBGC2, intel_ring::desc, EIO, INTEL_DESC_STATUS_DD, INTEL_DESC_STATUS_RXE, INTEL_NUM_RX_DESC, iob_put, le16_to_cpu, le32_to_cpu, len, netdev, netdev_rx(), netdev_rx_err(), NULL, net_device::priv, intel_ring::prod, rx, intel_nic::rx, and intel_nic::rx_iobuf.
Referenced by intel_poll(), intelx_poll(), and intelxvf_poll().
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 864 of file intel.c.
References DBGC, ENOBUFS, ENOTSUP, intel_nic::force_icr, intel_check_link(), INTEL_ICR, INTEL_IRQ_LSC, INTEL_IRQ_RXDMT0, INTEL_IRQ_RXO, INTEL_IRQ_RXT0, INTEL_IRQ_TXDW, INTEL_IRQ_TXQE, intel_poll_rx(), intel_poll_tx(), intel_refill_rx(), netdev, netdev_rx_err(), netdev_tx_err(), NULL, net_device::priv, profile_exclude(), profile_start(), profile_stop(), readl(), and intel_nic::regs.
|
static |
Enable or disable interrupts.
netdev | Network device |
enable | Interrupts should be enabled |
Definition at line 911 of file intel.c.
References INTEL_IMC, INTEL_IMS, INTEL_IRQ_LSC, INTEL_IRQ_RXT0, INTEL_IRQ_TXDW, netdev, net_device::priv, intel_nic::regs, and writel().
|
static |
Probe PCI device.
pci | PCI device |
rc | Return status code |
Definition at line 945 of file intel.c.
References adjust_pci_device(), alloc_etherdev(), pci_device::busdevfn, pci_device::dev, net_device::dev, pci_device::dma, intel_nic::dma, net_device::dma, dma_set_mask_64bit(), pci_device_id::driver_data, ENODEV, ENOMEM, intel_nic::flags, net_device::hw_addr, pci_device::id, INTEL_BAR_SIZE, intel_check_link(), intel_describe_rx(), intel_describe_tx(), intel_fetch_mac(), intel_init_ring(), INTEL_NUM_RX_DESC, INTEL_NUM_TX_DESC, intel_operations, INTEL_RD, intel_reset(), INTEL_TD, iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), PCI_FUNC, pci_ioremap(), pci_set_drvdata(), intel_nic::port, net_device::priv, rc, register_netdev(), intel_nic::regs, intel_nic::rx, intel_nic::tx, and unregister_netdev().
|
static |
Remove PCI device.
pci | PCI device |
Definition at line 1018 of file intel.c.
References intel_reset(), iounmap(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, intel_nic::regs, and unregister_netdev().
|
static |
|
static |
Intel network device operations.
Definition at line 924 of file intel.c.
Referenced by intel_probe().
|
static |
struct pci_driver intel_driver __pci_driver |
Intel PCI driver.