iPXE
Functions | Variables
intel.c File Reference

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...
 

Detailed Description

Intel 10/100/1000 network card driver.

Definition in file intel.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ intel_read_eeprom()

static int intel_read_eeprom ( struct nvs_device nvs,
unsigned int  address,
void *  data,
size_t  len 
)
static

Read data from EEPROM.

Parameters
nvsNVS device
addressAddress from which to read
dataData buffer
lenLength of data buffer
Return values
rcReturn status code

Definition at line 74 of file intel.c.

75  {
76  struct intel_nic *intel =
77  container_of ( nvs, struct intel_nic, eeprom );
78  unsigned int i;
80  uint16_t *data_word = data;
81 
82  /* Sanity check. We advertise a blocksize of one word, so
83  * should only ever receive single-word requests.
84  */
85  assert ( len == sizeof ( *data_word ) );
86 
87  /* Initiate read */
88  writel ( ( INTEL_EERD_START | ( address << intel->eerd_addr_shift ) ),
89  intel->regs + INTEL_EERD );
90 
91  /* Wait for read to complete */
92  for ( i = 0 ; i < INTEL_EEPROM_MAX_WAIT_MS ; i++ ) {
93 
94  /* If read is not complete, delay 1ms and retry */
95  value = readl ( intel->regs + INTEL_EERD );
96  if ( ! ( value & intel->eerd_done ) ) {
97  mdelay ( 1 );
98  continue;
99  }
100 
101  /* Extract data */
102  *data_word = cpu_to_le16 ( INTEL_EERD_DATA ( value ) );
103  return 0;
104  }
105 
106  DBGC ( intel, "INTEL %p timed out waiting for EEPROM read\n", intel );
107  return -ETIMEDOUT;
108 }
void * regs
Registers.
Definition: intel.h:283
unsigned short uint16_t
Definition: stdint.h:11
#define INTEL_EERD
EEPROM Read Register.
Definition: intel.h:77
uint64_t address
Base address.
Definition: ena.h:24
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
eeprom
Definition: 3c90x.h:232
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define INTEL_EERD_DATA(value)
Read data.
Definition: intel.h:83
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
uint32_t eerd_done
EEPROM done flag.
Definition: intel.h:296
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define INTEL_EEPROM_MAX_WAIT_MS
Maximum time to wait for EEPROM read, in milliseconds.
Definition: intel.h:86
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
uint32_t len
Length.
Definition: ena.h:14
#define cpu_to_le16(value)
Definition: byteswap.h:106
An Intel network card.
Definition: intel.h:281
#define INTEL_EERD_START
Start read.
Definition: intel.h:78
unsigned int eerd_addr_shift
EEPROM address shift.
Definition: intel.h:298
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

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().

◆ intel_write_eeprom()

static int intel_write_eeprom ( struct nvs_device nvs,
unsigned int address  __unused,
const void *data  __unused,
size_t len  __unused 
)
static

Write data to EEPROM.

Parameters
nvsNVS device
addressAddress to which to write
dataData buffer
lenLength of data buffer
Return values
rcReturn status code

Definition at line 119 of file intel.c.

122  {
123  struct intel_nic *intel =
124  container_of ( nvs, struct intel_nic, eeprom );
125 
126  DBGC ( intel, "INTEL %p EEPROM write not supported\n", intel );
127  return -ENOTSUP;
128 }
#define DBGC(...)
Definition: compiler.h:505
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
eeprom
Definition: 3c90x.h:232
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An Intel network card.
Definition: intel.h:281

References container_of, DBGC, and ENOTSUP.

Referenced by intel_init_eeprom().

◆ intel_init_eeprom()

static int intel_init_eeprom ( struct intel_nic intel)
static

Initialise EEPROM.

Parameters
intelIntel device
Return values
rcReturn status code

Definition at line 136 of file intel.c.

136  {
137  unsigned int i;
138  uint32_t value;
139 
140  /* The NIC automatically detects the type of attached EEPROM.
141  * The EERD register provides access to only a single word at
142  * a time, so we pretend to have a single-word block size.
143  *
144  * The EEPROM size may be larger than the minimum size, but
145  * this doesn't matter to us since we access only the first
146  * few words.
147  */
150  intel->eeprom.block_size = 1;
151  intel->eeprom.read = intel_read_eeprom;
153 
154  /* The layout of the EERD register was changed at some point
155  * to accommodate larger EEPROMs. Read from address zero (for
156  * which the request layouts are compatible) to determine
157  * which type of register we have.
158  */
159  writel ( INTEL_EERD_START, intel->regs + INTEL_EERD );
160  for ( i = 0 ; i < INTEL_EEPROM_MAX_WAIT_MS ; i++ ) {
161  value = readl ( intel->regs + INTEL_EERD );
162  if ( value & INTEL_EERD_DONE_LARGE ) {
163  DBGC ( intel, "INTEL %p has large-format EERD\n",
164  intel );
167  return 0;
168  }
169  if ( value & INTEL_EERD_DONE_SMALL ) {
170  DBGC ( intel, "INTEL %p has small-format EERD\n",
171  intel );
174  return 0;
175  }
176  mdelay ( 1 );
177  }
178 
179  DBGC ( intel, "INTEL %p timed out waiting for initial EEPROM read "
180  "(value %08x)\n", intel, value );
181  return -ETIMEDOUT;
182 }
void * regs
Registers.
Definition: intel.h:283
int(* write)(struct nvs_device *nvs, unsigned int address, const void *data, size_t len)
Write data to device.
Definition: nvs.h:59
unsigned int word_len_log2
Word length.
Definition: nvs.h:22
#define INTEL_EERD
EEPROM Read Register.
Definition: intel.h:77
#define INTEL_EERD_DONE_SMALL
Read done (small EERD)
Definition: intel.h:79
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
unsigned int block_size
Data block size (in words)
Definition: nvs.h:36
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
uint32_t eerd_done
EEPROM done flag.
Definition: intel.h:296
#define INTEL_EEPROM_WORD_LEN_LOG2
EEPROM word length.
Definition: intel.h:89
#define INTEL_EERD_ADDR_SHIFT_SMALL
Address shift (small)
Definition: intel.h:81
int(* read)(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read data from device.
Definition: nvs.h:47
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
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.
Definition: intel.c:119
#define INTEL_EEPROM_MAX_WAIT_MS
Maximum time to wait for EEPROM read, in milliseconds.
Definition: intel.h:86
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define INTEL_EERD_DONE_LARGE
Read done (large EERD)
Definition: intel.h:80
#define INTEL_EERD_ADDR_SHIFT_LARGE
Address shift (large)
Definition: intel.h:82
static int intel_read_eeprom(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read data from EEPROM.
Definition: intel.c:74
#define INTEL_EERD_START
Start read.
Definition: intel.h:78
unsigned int eerd_addr_shift
EEPROM address shift.
Definition: intel.h:298
#define INTEL_EEPROM_MIN_SIZE_WORDS
Minimum EEPROM size, in words.
Definition: intel.h:92
struct nvs_device eeprom
EEPROM.
Definition: intel.h:294
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
unsigned int size
Device size (in words)
Definition: nvs.h:24

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().

◆ intel_fetch_mac_eeprom()

static int intel_fetch_mac_eeprom ( struct intel_nic intel,
uint8_t hw_addr 
)
static

Fetch initial MAC address from EEPROM.

Parameters
intelIntel device
hw_addrHardware address to fill in
Return values
rcReturn status code

Definition at line 198 of file intel.c.

199  {
200  int rc;
201 
202  /* Initialise EEPROM */
203  if ( ( rc = intel_init_eeprom ( intel ) ) != 0 )
204  return rc;
205 
206  /* Read base MAC address from EEPROM */
207  if ( ( rc = nvs_read ( &intel->eeprom, INTEL_EEPROM_MAC,
208  hw_addr, ETH_ALEN ) ) != 0 ) {
209  DBGC ( intel, "INTEL %p could not read EEPROM base MAC "
210  "address: %s\n", intel, strerror ( rc ) );
211  return rc;
212  }
213 
214  /* Adjust MAC address for multi-port devices */
215  hw_addr[ETH_ALEN-1] ^= intel->port;
216 
217  DBGC ( intel, "INTEL %p has EEPROM MAC address %s (port %d)\n",
218  intel, eth_ntoa ( hw_addr ), intel->port );
219  return 0;
220 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
unsigned int port
Port number (for multi-port devices)
Definition: intel.h:287
#define INTEL_EEPROM_MAC
Offset of MAC address within EEPROM.
Definition: intel.h:95
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
#define ETH_ALEN
Definition: if_ether.h:8
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
Definition: nvs.c:75
static int intel_init_eeprom(struct intel_nic *intel)
Initialise EEPROM.
Definition: intel.c:136
struct nvs_device eeprom
EEPROM.
Definition: intel.h:294

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().

◆ intel_fetch_mac()

static int intel_fetch_mac ( struct intel_nic intel,
uint8_t hw_addr 
)
static

Fetch initial MAC address.

Parameters
intelIntel device
hw_addrHardware address to fill in
Return values
rcReturn status code

Definition at line 229 of file intel.c.

229  {
231  int rc;
232 
233  /* Read current address from RAL0/RAH0 */
234  mac.reg.low = cpu_to_le32 ( readl ( intel->regs + INTEL_RAL0 ) );
235  mac.reg.high = cpu_to_le32 ( readl ( intel->regs + INTEL_RAH0 ) );
236  DBGC ( intel, "INTEL %p has autoloaded MAC address %s\n",
237  intel, eth_ntoa ( mac.raw ) );
238 
239  /* Use current address if valid */
240  if ( is_valid_ether_addr ( mac.raw ) ) {
241  memcpy ( hw_addr, mac.raw, ETH_ALEN );
242  return 0;
243  }
244 
245  /* Otherwise, try to read address from EEPROM */
246  if ( ( rc = intel_fetch_mac_eeprom ( intel, hw_addr ) ) == 0 )
247  return 0;
248 
249  DBGC ( intel, "INTEL %p has no MAC address to use\n", intel );
250  return -ENOENT;
251 }
void * regs
Registers.
Definition: intel.h:283
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intel_fetch_mac_eeprom(struct intel_nic *intel, uint8_t *hw_addr)
Fetch initial MAC address from EEPROM.
Definition: intel.c:198
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define cpu_to_le32(value)
Definition: byteswap.h:107
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
#define ETH_ALEN
Definition: if_ether.h:8
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
Receive address.
Definition: intel.h:205
#define INTEL_RAL0
Receive Address Low.
Definition: intel.h:194
#define INTEL_RAH0
Receive Address High.
Definition: intel.h:197

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().

◆ intel_reset()

static int intel_reset ( struct intel_nic intel)
static

Reset hardware.

Parameters
intelIntel device
Return values
rcReturn status code

Definition at line 266 of file intel.c.

266  {
267  uint32_t pbs;
268  uint32_t pba;
269  uint32_t ctrl;
271  uint32_t orig_ctrl;
272  uint32_t orig_status;
273 
274  /* Record initial control and status register values */
275  orig_ctrl = ctrl = readl ( intel->regs + INTEL_CTRL );
276  orig_status = readl ( intel->regs + INTEL_STATUS );
277 
278  /* Force RX and TX packet buffer allocation, to work around an
279  * errata in ICH devices.
280  */
281  if ( intel->flags & INTEL_PBS_ERRATA ) {
282  DBGC ( intel, "INTEL %p WARNING: applying ICH PBS/PBA errata\n",
283  intel );
284  pbs = readl ( intel->regs + INTEL_PBS );
285  pba = readl ( intel->regs + INTEL_PBA );
286  writel ( 0x08, intel->regs + INTEL_PBA );
287  writel ( 0x10, intel->regs + INTEL_PBS );
288  DBGC ( intel, "INTEL %p PBS %#08x->%#08x PBA %#08x->%#08x\n",
289  intel, pbs, readl ( intel->regs + INTEL_PBS ),
290  pba, readl ( intel->regs + INTEL_PBA ) );
291  }
292 
293  /* Always reset MAC. Required to reset the TX and RX rings. */
294  writel ( ( ctrl | INTEL_CTRL_RST ), intel->regs + INTEL_CTRL );
296 
297  /* Set a sensible default configuration */
298  if ( ! ( intel->flags & INTEL_NO_ASDE ) )
300  ctrl |= INTEL_CTRL_SLU;
302  writel ( ctrl, intel->regs + INTEL_CTRL );
304 
305  /* On some models (notably ICH), the PHY reset mechanism
306  * appears to be broken. In particular, the PHY_CTRL register
307  * will be correctly loaded from NVM but the values will not
308  * be propagated to the "OEM bits" PHY register. This
309  * typically has the effect of dropping the link speed to
310  * 10Mbps.
311  *
312  * Work around this problem by skipping the PHY reset if
313  * either (a) the link is already up, or (b) this particular
314  * NIC is known to be broken.
315  */
316  status = readl ( intel->regs + INTEL_STATUS );
317  if ( ( intel->flags & INTEL_NO_PHY_RST ) ||
318  ( status & INTEL_STATUS_LU ) ) {
319  DBGC ( intel, "INTEL %p %sMAC reset (%08x/%08x was "
320  "%08x/%08x)\n", intel,
321  ( ( intel->flags & INTEL_NO_PHY_RST ) ? "forced " : "" ),
322  ctrl, status, orig_ctrl, orig_status );
323  return 0;
324  }
325 
326  /* Reset PHY and MAC simultaneously */
328  intel->regs + INTEL_CTRL );
330 
331  /* PHY reset is not self-clearing on all models */
332  writel ( ctrl, intel->regs + INTEL_CTRL );
334  status = readl ( intel->regs + INTEL_STATUS );
335 
336  DBGC ( intel, "INTEL %p MAC+PHY reset (%08x/%08x was %08x/%08x)\n",
337  intel, ctrl, status, orig_ctrl, orig_status );
338  return 0;
339 }
void * regs
Registers.
Definition: intel.h:283
PHY reset is broken.
Definition: intel.h:318
#define INTEL_PBA
Packet Buffer Allocation.
Definition: intel.h:137
ASDE is broken.
Definition: intel.h:320
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTEL_PBS
Packet Buffer Size.
Definition: intel.h:140
PBS/PBA errata workaround required.
Definition: intel.h:314
uint8_t status
Status.
Definition: ena.h:16
#define INTEL_CTRL_FRCDPLX
Force duplex.
Definition: intel.h:65
#define INTEL_CTRL_ASDE
Auto-speed detection.
Definition: intel.h:62
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTEL_CTRL_LRST
Link reset.
Definition: intel.h:61
#define INTEL_CTRL_RST
Device reset.
Definition: intel.h:66
#define INTEL_STATUS_LU
Link up.
Definition: intel.h:74
unsigned int uint32_t
Definition: stdint.h:12
#define INTEL_CTRL
Device Control Register.
Definition: intel.h:60
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define INTEL_CTRL_PHY_RST
PHY reset.
Definition: intel.h:67
#define INTEL_RESET_DELAY_MS
Time to delay for device reset, in milliseconds.
Definition: intel.h:70
#define INTEL_CTRL_SLU
Set link up.
Definition: intel.h:63
u8 ctrl
Definition: sky2.h:10
#define INTEL_STATUS
Device Status Register.
Definition: intel.h:73
unsigned int flags
Flags.
Definition: intel.h:289
#define INTEL_CTRL_FRCSPD
Force speed.
Definition: intel.h:64

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_RESET_DELAY_MS, INTEL_STATUS, INTEL_STATUS_LU, mdelay(), readl(), intel_nic::regs, status, and writel().

Referenced by intel_close(), intel_probe(), and intel_remove().

◆ intel_check_link()

static void intel_check_link ( struct net_device netdev)
static

Check link state.

Parameters
netdevNetwork device

Definition at line 353 of file intel.c.

353  {
354  struct intel_nic *intel = netdev->priv;
356 
357  /* Read link status */
358  status = readl ( intel->regs + INTEL_STATUS );
359  DBGC ( intel, "INTEL %p link status is %08x\n", intel, status );
360 
361  /* Update network device */
362  if ( status & INTEL_STATUS_LU ) {
364  } else {
366  }
367 }
void * regs
Registers.
Definition: intel.h:283
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:186
uint8_t status
Status.
Definition: ena.h:16
void * priv
Driver private data.
Definition: netdevice.h:431
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:774
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTEL_STATUS_LU
Link up.
Definition: intel.h:74
unsigned int uint32_t
Definition: stdint.h:12
An Intel network card.
Definition: intel.h:281
#define INTEL_STATUS
Device Status Register.
Definition: intel.h:73

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().

◆ intel_describe_tx()

void intel_describe_tx ( struct intel_descriptor tx,
physaddr_t  addr,
size_t  len 
)

Populate transmit descriptor.

Parameters
txTransmit descriptor
addrData buffer address
lenLength of data

Definition at line 383 of file intel.c.

384  {
385 
386  /* Populate transmit descriptor */
387  tx->address = cpu_to_le64 ( addr );
388  tx->length = cpu_to_le16 ( len );
389  tx->flags = 0;
390  tx->command = ( INTEL_DESC_CMD_RS | INTEL_DESC_CMD_IFCS |
392  tx->status = 0;
393 }
#define cpu_to_le64(value)
Definition: byteswap.h:108
#define INTEL_DESC_CMD_IFCS
Insert frame checksum (CRC)
Definition: intel.h:45
u32 addr
Definition: sky2.h:8
uint32_t len
Length.
Definition: ena.h:14
#define INTEL_DESC_CMD_EOP
End of packet.
Definition: intel.h:48
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTEL_DESC_CMD_RS
Report status.
Definition: intel.h:42
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237

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().

◆ intel_describe_tx_adv()

void intel_describe_tx_adv ( struct intel_descriptor tx,
physaddr_t  addr,
size_t  len 
)

Populate advanced transmit descriptor.

Parameters
txTransmit descriptor
addrData buffer address
lenLength of data

Definition at line 402 of file intel.c.

403  {
404 
405  /* Populate advanced transmit descriptor */
406  tx->address = cpu_to_le64 ( addr );
407  tx->length = cpu_to_le16 ( len );
408  tx->flags = INTEL_DESC_FL_DTYP_DATA;
409  tx->command = ( INTEL_DESC_CMD_DEXT | INTEL_DESC_CMD_RS |
411  tx->status = cpu_to_le32 ( INTEL_DESC_STATUS_PAYLEN ( len ) );
412 }
#define INTEL_DESC_STATUS_PAYLEN(len)
Payload length.
Definition: intel.h:57
#define cpu_to_le64(value)
Definition: byteswap.h:108
#define INTEL_DESC_FL_DTYP_DATA
Definition: intel.h:36
#define INTEL_DESC_CMD_IFCS
Insert frame checksum (CRC)
Definition: intel.h:45
#define cpu_to_le32(value)
Definition: byteswap.h:107
u32 addr
Definition: sky2.h:8
uint32_t len
Length.
Definition: ena.h:14
#define INTEL_DESC_CMD_DEXT
Descriptor extension.
Definition: intel.h:39
#define INTEL_DESC_CMD_EOP
End of packet.
Definition: intel.h:48
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTEL_DESC_CMD_RS
Report status.
Definition: intel.h:42
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237

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().

◆ intel_describe_rx()

void intel_describe_rx ( struct intel_descriptor rx,
physaddr_t  addr,
size_t len  __unused 
)

Populate receive descriptor.

Parameters
rxReceive descriptor
addrData buffer address
lenLength of data

Definition at line 421 of file intel.c.

422  {
423 
424  /* Populate transmit descriptor */
425  rx->address = cpu_to_le64 ( addr );
426  rx->length = 0;
427  rx->status = 0;
428 }
#define cpu_to_le64(value)
Definition: byteswap.h:108
u32 addr
Definition: sky2.h:8
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234

References addr, cpu_to_le64, and rx.

Referenced by intel_probe(), intelx_probe(), and intelxvf_probe().

◆ intel_disable_ring()

static int intel_disable_ring ( struct intel_nic intel,
unsigned int  reg 
)
static

Disable descriptor ring.

Parameters
intelIntel device
regRegister block
Return values
rcReturn status code

Definition at line 444 of file intel.c.

444  {
445  uint32_t dctl;
446  unsigned int i;
447 
448  /* Disable ring */
449  writel ( 0, ( intel->regs + reg + INTEL_xDCTL ) );
450 
451  /* Wait for disable to complete */
452  for ( i = 0 ; i < INTEL_DISABLE_MAX_WAIT_MS ; i++ ) {
453 
454  /* Check if ring is disabled */
455  dctl = readl ( intel->regs + reg + INTEL_xDCTL );
456  if ( ! ( dctl & INTEL_xDCTL_ENABLE ) )
457  return 0;
458 
459  /* Delay */
460  mdelay ( 1 );
461  }
462 
463  DBGC ( intel, "INTEL %p ring %05x timed out waiting for disable "
464  "(dctl %08x)\n", intel, reg, dctl );
465  return -ETIMEDOUT;
466 }
void * regs
Registers.
Definition: intel.h:283
static unsigned int unsigned int reg
Definition: myson.h:162
#define INTEL_xDCTL
Receive/Transmit Descriptor Control (offset)
Definition: intel.h:187
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTEL_DISABLE_MAX_WAIT_MS
Maximum time to wait for queue disable, in milliseconds.
Definition: intel.h:191
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define INTEL_xDCTL_ENABLE
Queue enable.
Definition: intel.h:188
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

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().

◆ intel_reset_ring()

void intel_reset_ring ( struct intel_nic intel,
unsigned int  reg 
)

Reset descriptor ring.

Parameters
intelIntel device
regRegister block
Return values
rcReturn status code

Definition at line 475 of file intel.c.

475  {
476 
477  /* Disable ring. Ignore errors and continue to reset the ring anyway */
478  intel_disable_ring ( intel, reg );
479 
480  /* Clear ring length */
481  writel ( 0, ( intel->regs + reg + INTEL_xDLEN ) );
482 
483  /* Clear ring address */
484  writel ( 0, ( intel->regs + reg + INTEL_xDBAH ) );
485  writel ( 0, ( intel->regs + reg + INTEL_xDBAL ) );
486 
487  /* Reset head and tail pointers */
488  writel ( 0, ( intel->regs + reg + INTEL_xDH ) );
489  writel ( 0, ( intel->regs + reg + INTEL_xDT ) );
490 }
void * regs
Registers.
Definition: intel.h:283
static unsigned int unsigned int reg
Definition: myson.h:162
#define INTEL_xDT
Receive/Transmit Descriptor Tail (offset)
Definition: intel.h:184
#define INTEL_xDLEN
Receive/Transmit Descriptor Length (offset)
Definition: intel.h:178
#define INTEL_xDH
Receive/Transmit Descriptor Head (offset)
Definition: intel.h:181
#define INTEL_xDBAL
Receive/Transmit Descriptor Base Address Low (offset)
Definition: intel.h:172
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static int intel_disable_ring(struct intel_nic *intel, unsigned int reg)
Disable descriptor ring.
Definition: intel.c:444
#define INTEL_xDBAH
Receive/Transmit Descriptor Base Address High (offset)
Definition: intel.h:175

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().

◆ intel_create_ring()

int intel_create_ring ( struct intel_nic intel,
struct intel_ring ring 
)

Create descriptor ring.

Parameters
intelIntel device
ringDescriptor ring
Return values
rcReturn status code

Definition at line 499 of file intel.c.

499  {
501  uint32_t dctl;
502 
503  /* Allocate descriptor ring. Align ring on its own size to
504  * prevent any possible page-crossing errors due to hardware
505  * errata.
506  */
507  ring->desc = dma_alloc ( intel->dma, &ring->map, ring->len,
508  ring->len );
509  if ( ! ring->desc )
510  return -ENOMEM;
511 
512  /* Initialise descriptor ring */
513  memset ( ring->desc, 0, ring->len );
514 
515  /* Program ring address */
516  address = dma ( &ring->map, ring->desc );
517  writel ( ( address & 0xffffffffUL ),
518  ( intel->regs + ring->reg + INTEL_xDBAL ) );
519  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
520  writel ( ( ( ( uint64_t ) address ) >> 32 ),
521  ( intel->regs + ring->reg + INTEL_xDBAH ) );
522  } else {
523  writel ( 0, intel->regs + ring->reg + INTEL_xDBAH );
524  }
525 
526  /* Program ring length */
527  writel ( ring->len, ( intel->regs + ring->reg + INTEL_xDLEN ) );
528 
529  /* Reset head and tail pointers */
530  writel ( 0, ( intel->regs + ring->reg + INTEL_xDH ) );
531  writel ( 0, ( intel->regs + ring->reg + INTEL_xDT ) );
532 
533  /* Enable ring */
534  dctl = readl ( intel->regs + ring->reg + INTEL_xDCTL );
535  dctl |= INTEL_xDCTL_ENABLE;
536  writel ( dctl, intel->regs + ring->reg + INTEL_xDCTL );
537 
538  DBGC ( intel, "INTEL %p ring %05x is at [%08lx,%08lx)\n",
539  intel, ring->reg, virt_to_phys ( ring->desc ),
540  ( virt_to_phys ( ring->desc ) + ring->len ) );
541 
542  return 0;
543 }
void * regs
Registers.
Definition: intel.h:283
struct dma_mapping map
Descriptor ring DMA mapping.
Definition: intel.h:218
#define INTEL_xDCTL
Receive/Transmit Descriptor Control (offset)
Definition: intel.h:187
uint64_t address
Base address.
Definition: ena.h:24
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTEL_xDT
Receive/Transmit Descriptor Tail (offset)
Definition: intel.h:184
size_t len
Length (in bytes)
Definition: intel.h:227
unsigned long long uint64_t
Definition: stdint.h:13
#define INTEL_xDLEN
Receive/Transmit Descriptor Length (offset)
Definition: intel.h:178
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
unsigned int reg
Register block.
Definition: intel.h:225
#define INTEL_xDH
Receive/Transmit Descriptor Head (offset)
Definition: intel.h:181
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define INTEL_xDBAL
Receive/Transmit Descriptor Base Address Low (offset)
Definition: intel.h:172
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
unsigned int uint32_t
Definition: stdint.h:12
void * dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer.
unsigned long physaddr_t
Definition: stdint.h:20
struct dma_device * dma
DMA device.
Definition: intel.h:285
#define INTEL_xDCTL_ENABLE
Queue enable.
Definition: intel.h:188
struct intel_descriptor * desc
Descriptors.
Definition: intel.h:216
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
#define INTEL_xDBAH
Receive/Transmit Descriptor Base Address High (offset)
Definition: intel.h:175
void * memset(void *dest, int character, size_t len) __nonnull

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().

◆ intel_destroy_ring()

void intel_destroy_ring ( struct intel_nic intel,
struct intel_ring ring 
)

Destroy descriptor ring.

Parameters
intelIntel device
ringDescriptor ring

Definition at line 551 of file intel.c.

551  {
552 
553  /* Reset ring */
554  intel_reset_ring ( intel, ring->reg );
555 
556  /* Free descriptor ring */
557  dma_free ( &ring->map, ring->desc, ring->len );
558  ring->desc = NULL;
559  ring->prod = 0;
560  ring->cons = 0;
561 }
void intel_reset_ring(struct intel_nic *intel, unsigned int reg)
Reset descriptor ring.
Definition: intel.c:475
struct dma_mapping map
Descriptor ring DMA mapping.
Definition: intel.h:218
size_t len
Length (in bytes)
Definition: intel.h:227
unsigned int cons
Consumer index.
Definition: intel.h:222
unsigned int reg
Register block.
Definition: intel.h:225
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
unsigned int prod
Producer index.
Definition: intel.h:220
struct intel_descriptor * desc
Descriptors.
Definition: intel.h:216
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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().

◆ intel_refill_rx()

void intel_refill_rx ( struct intel_nic intel)

Refill receive descriptor ring.

Parameters
intelIntel device

Definition at line 568 of file intel.c.

568  {
569  struct intel_descriptor *rx;
570  struct io_buffer *iobuf;
571  unsigned int rx_idx;
572  unsigned int rx_tail;
573  unsigned int refilled = 0;
574 
575  /* Refill ring */
576  while ( ( intel->rx.prod - intel->rx.cons ) < INTEL_RX_FILL ) {
577 
578  /* Allocate I/O buffer */
579  iobuf = alloc_rx_iob ( INTEL_RX_MAX_LEN, intel->dma );
580  if ( ! iobuf ) {
581  /* Wait for next refill */
582  break;
583  }
584 
585  /* Get next receive descriptor */
586  rx_idx = ( intel->rx.prod++ % INTEL_NUM_RX_DESC );
587  rx = &intel->rx.desc[rx_idx];
588 
589  /* Populate receive descriptor */
590  intel->rx.describe ( rx, iob_dma ( iobuf ), 0 );
591 
592  /* Record I/O buffer */
593  assert ( intel->rx_iobuf[rx_idx] == NULL );
594  intel->rx_iobuf[rx_idx] = iobuf;
595 
596  DBGC2 ( intel, "INTEL %p RX %d is [%lx,%lx)\n",
597  intel, rx_idx, virt_to_phys ( iobuf->data ),
598  ( virt_to_phys ( iobuf->data ) + INTEL_RX_MAX_LEN ) );
599  refilled++;
600  }
601 
602  /* Push descriptors to card, if applicable */
603  if ( refilled ) {
604  wmb();
605  rx_tail = ( intel->rx.prod % INTEL_NUM_RX_DESC );
606  profile_start ( &intel_vm_refill_profiler );
607  writel ( rx_tail, intel->regs + intel->rx.reg + INTEL_xDT );
608  profile_stop ( &intel_vm_refill_profiler );
609  profile_exclude ( &intel_vm_refill_profiler );
610  }
611 }
void * regs
Registers.
Definition: intel.h:283
wmb()
#define INTEL_NUM_RX_DESC
Number of receive descriptors.
Definition: intel.h:150
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:306
#define INTEL_xDT
Receive/Transmit Descriptor Tail (offset)
Definition: intel.h:184
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
unsigned int cons
Consumer index.
Definition: intel.h:222
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
unsigned int reg
Register block.
Definition: intel.h:225
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition: iobuf.h:264
struct io_buffer * rx_iobuf[INTEL_NUM_RX_DESC]
Receive I/O buffers.
Definition: intel.h:308
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
struct io_buffer * alloc_rx_iob(size_t len, struct dma_device *dma)
Allocate and map I/O buffer for receive DMA.
Definition: iobuf.c:181
#define INTEL_RX_MAX_LEN
Receive buffer length.
Definition: intel.h:156
void(* describe)(struct intel_descriptor *desc, physaddr_t addr, size_t len)
Populate descriptor.
Definition: intel.h:235
struct dma_device * dma
DMA device.
Definition: intel.h:285
A packet descriptor.
Definition: intel.h:21
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:48
unsigned int prod
Producer index.
Definition: intel.h:220
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
#define INTEL_RX_FILL
Receive descriptor ring fill level.
Definition: intel.h:153
struct intel_descriptor * desc
Descriptors.
Definition: intel.h:216
static void profile_exclude(struct profiler *profiler)
Exclude time from other ongoing profiling results.
Definition: profile.h:184
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A persistent I/O buffer.
Definition: iobuf.h:33

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().

◆ intel_empty_rx()

void intel_empty_rx ( struct intel_nic intel)

Discard unused receive I/O buffers.

Parameters
intelIntel device

Definition at line 618 of file intel.c.

618  {
619  unsigned int i;
620 
621  /* Discard unused receive buffers */
622  for ( i = 0 ; i < INTEL_NUM_RX_DESC ; i++ ) {
623  if ( intel->rx_iobuf[i] )
624  free_rx_iob ( intel->rx_iobuf[i] );
625  intel->rx_iobuf[i] = NULL;
626  }
627 }
#define INTEL_NUM_RX_DESC
Number of receive descriptors.
Definition: intel.h:150
struct io_buffer * rx_iobuf[INTEL_NUM_RX_DESC]
Receive I/O buffers.
Definition: intel.h:308
void free_rx_iob(struct io_buffer *iobuf)
Unmap and free I/O buffer for receive DMA.
Definition: iobuf.c:208
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References free_rx_iob(), INTEL_NUM_RX_DESC, NULL, and intel_nic::rx_iobuf.

Referenced by intel_close(), intelx_close(), and intelxvf_close().

◆ intel_open()

static int intel_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 635 of file intel.c.

635  {
636  struct intel_nic *intel = netdev->priv;
638  uint32_t fextnvm11;
639  uint32_t tctl;
640  uint32_t rctl;
641  int rc;
642 
643  /* Set undocumented bit in FEXTNVM11 to work around an errata
644  * in i219 devices that will otherwise cause a complete
645  * datapath hang at the next device reset.
646  */
647  if ( intel->flags & INTEL_RST_HANG ) {
648  DBGC ( intel, "INTEL %p WARNING: applying reset hang "
649  "workaround\n", intel );
650  fextnvm11 = readl ( intel->regs + INTEL_FEXTNVM11 );
651  fextnvm11 |= INTEL_FEXTNVM11_WTF;
652  writel ( fextnvm11, intel->regs + INTEL_FEXTNVM11 );
653  }
654 
655  /* Create transmit descriptor ring */
656  if ( ( rc = intel_create_ring ( intel, &intel->tx ) ) != 0 )
657  goto err_create_tx;
658 
659  /* Create receive descriptor ring */
660  if ( ( rc = intel_create_ring ( intel, &intel->rx ) ) != 0 )
661  goto err_create_rx;
662 
663  /* Program MAC address */
664  memset ( &mac, 0, sizeof ( mac ) );
665  memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
666  writel ( le32_to_cpu ( mac.reg.low ), intel->regs + INTEL_RAL0 );
667  writel ( ( le32_to_cpu ( mac.reg.high ) | INTEL_RAH0_AV ),
668  intel->regs + INTEL_RAH0 );
669 
670  /* Enable transmitter */
671  tctl = readl ( intel->regs + INTEL_TCTL );
675  writel ( tctl, intel->regs + INTEL_TCTL );
676 
677  /* Enable receiver */
678  rctl = readl ( intel->regs + INTEL_RCTL );
679  rctl &= ~( INTEL_RCTL_BSIZE_BSEX_MASK );
682  writel ( rctl, intel->regs + INTEL_RCTL );
683 
684  /* Fill receive ring */
685  intel_refill_rx ( intel );
686 
687  /* Update link state */
689 
690  /* Apply required errata */
691  if ( intel->flags & INTEL_VMWARE ) {
692  DBGC ( intel, "INTEL %p applying VMware errata workaround\n",
693  intel );
694  intel->force_icr = INTEL_IRQ_RXT0;
695  }
696 
697  return 0;
698 
699  intel_destroy_ring ( intel, &intel->rx );
700  err_create_rx:
701  intel_destroy_ring ( intel, &intel->tx );
702  err_create_tx:
703  return rc;
704 }
unsigned int force_icr
Forced interrupts.
Definition: intel.h:291
void * regs
Registers.
Definition: intel.h:283
#define INTEL_RCTL_BSIZE_2048
Definition: intel.h:121
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTEL_IRQ_RXT0
Receive timer.
Definition: intel.h:104
#define le32_to_cpu(value)
Definition: byteswap.h:113
VMware missing interrupt workaround required.
Definition: intel.h:316
#define INTEL_RCTL_BSIZE_BSEX_MASK
Definition: intel.h:122
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:306
#define INTEL_TCTL_EN
Transmit enable.
Definition: intel.h:127
#define DBGC(...)
Definition: compiler.h:505
int intel_create_ring(struct intel_nic *intel, struct intel_ring *ring)
Create descriptor ring.
Definition: intel.c:499
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
#define INTEL_RCTL_SECRC
Strip CRC.
Definition: intel.h:123
void intel_refill_rx(struct intel_nic *intel)
Refill receive descriptor ring.
Definition: intel.c:568
static void intel_check_link(struct net_device *netdev)
Check link state.
Definition: intel.c:353
#define INTEL_TCTL_CT_MASK
Definition: intel.h:131
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define INTEL_FEXTNVM11
Future Extended NVM register 11.
Definition: intel.h:201
void * priv
Driver private data.
Definition: netdevice.h:431
#define INTEL_FEXTNVM11_WTF
Don't ask.
Definition: intel.h:202
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTEL_TCTL_CT_DEFAULT
Definition: intel.h:130
#define INTEL_RCTL_BAM
Broadcast accept mode.
Definition: intel.h:117
unsigned int uint32_t
Definition: stdint.h:12
#define INTEL_RCTL_UPE
Unicast promiscuous mode.
Definition: intel.h:115
#define INTEL_RCTL
Receive Control Register.
Definition: intel.h:113
#define INTEL_TCTL
Transmit Control Register.
Definition: intel.h:126
void intel_destroy_ring(struct intel_nic *intel, struct intel_ring *ring)
Destroy descriptor ring.
Definition: intel.c:551
An Intel network card.
Definition: intel.h:281
#define INTEL_TCTL_PSP
Pad short packets.
Definition: intel.h:128
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:304
Receive address.
Definition: intel.h:205
Reset may cause a complete device hang.
Definition: intel.h:322
#define INTEL_RCTL_EN
Receive enable.
Definition: intel.h:114
#define INTEL_RAH0_AV
Address valid.
Definition: intel.h:198
#define INTEL_RAL0
Receive Address Low.
Definition: intel.h:194
#define INTEL_RAH0
Receive Address High.
Definition: intel.h:197
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
#define INTEL_TCTL_COLD_MASK
Definition: intel.h:134
#define INTEL_TCTL_COLD_DEFAULT
Definition: intel.h:133
unsigned int flags
Flags.
Definition: intel.h:289
#define INTEL_RCTL_MPE
Multicast promiscuous.
Definition: intel.h:116
void * memset(void *dest, int character, size_t len) __nonnull

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().

◆ intel_close()

static void intel_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 711 of file intel.c.

711  {
712  struct intel_nic *intel = netdev->priv;
713 
714  /* Disable receiver */
715  writel ( 0, intel->regs + INTEL_RCTL );
716 
717  /* Disable transmitter */
718  writel ( 0, intel->regs + INTEL_TCTL );
719 
720  /* Destroy receive descriptor ring */
721  intel_destroy_ring ( intel, &intel->rx );
722 
723  /* Discard any unused receive buffers */
724  intel_empty_rx ( intel );
725 
726  /* Destroy transmit descriptor ring */
727  intel_destroy_ring ( intel, &intel->tx );
728 
729  /* Reset the NIC, to flush the transmit and receive FIFOs */
730  intel_reset ( intel );
731 }
void * regs
Registers.
Definition: intel.h:283
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:306
void intel_empty_rx(struct intel_nic *intel)
Discard unused receive I/O buffers.
Definition: intel.c:618
static int intel_reset(struct intel_nic *intel)
Reset hardware.
Definition: intel.c:266
void * priv
Driver private data.
Definition: netdevice.h:431
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTEL_RCTL
Receive Control Register.
Definition: intel.h:113
#define INTEL_TCTL
Transmit Control Register.
Definition: intel.h:126
void intel_destroy_ring(struct intel_nic *intel, struct intel_ring *ring)
Destroy descriptor ring.
Definition: intel.c:551
An Intel network card.
Definition: intel.h:281
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:304

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().

◆ intel_transmit()

int intel_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)

Transmit packet.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 740 of file intel.c.

740  {
741  struct intel_nic *intel = netdev->priv;
742  struct intel_descriptor *tx;
743  unsigned int tx_idx;
744  unsigned int tx_tail;
745  size_t len;
746 
747  /* Get next transmit descriptor */
748  if ( ( intel->tx.prod - intel->tx.cons ) >= INTEL_TX_FILL ) {
749  DBGC ( intel, "INTEL %p out of transmit descriptors\n", intel );
750  return -ENOBUFS;
751  }
752  tx_idx = ( intel->tx.prod++ % INTEL_NUM_TX_DESC );
753  tx_tail = ( intel->tx.prod % INTEL_NUM_TX_DESC );
754  tx = &intel->tx.desc[tx_idx];
755 
756  /* Populate transmit descriptor */
757  len = iob_len ( iobuf );
758  intel->tx.describe ( tx, iob_dma ( iobuf ), len );
759  wmb();
760 
761  /* Notify card that there are packets ready to transmit */
762  profile_start ( &intel_vm_tx_profiler );
763  writel ( tx_tail, intel->regs + intel->tx.reg + INTEL_xDT );
764  profile_stop ( &intel_vm_tx_profiler );
765  profile_exclude ( &intel_vm_tx_profiler );
766 
767  DBGC2 ( intel, "INTEL %p TX %d is [%lx,%lx)\n",
768  intel, tx_idx, virt_to_phys ( iobuf->data ),
769  ( virt_to_phys ( iobuf->data ) + len ) );
770 
771  return 0;
772 }
void * regs
Registers.
Definition: intel.h:283
wmb()
#define INTEL_NUM_TX_DESC
Number of transmit descriptors.
Definition: intel.h:166
#define DBGC(...)
Definition: compiler.h:505
#define INTEL_xDT
Receive/Transmit Descriptor Tail (offset)
Definition: intel.h:184
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
unsigned int cons
Consumer index.
Definition: intel.h:222
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
unsigned int reg
Register block.
Definition: intel.h:225
#define INTEL_TX_FILL
Transmit descriptor ring maximum fill level.
Definition: intel.h:169
void * priv
Driver private data.
Definition: netdevice.h:431
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition: iobuf.h:264
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
void(* describe)(struct intel_descriptor *desc, physaddr_t addr, size_t len)
Populate descriptor.
Definition: intel.h:235
A packet descriptor.
Definition: intel.h:21
uint32_t len
Length.
Definition: ena.h:14
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:48
unsigned int prod
Producer index.
Definition: intel.h:220
An Intel network card.
Definition: intel.h:281
struct intel_descriptor * desc
Descriptors.
Definition: intel.h:216
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:304
static void profile_exclude(struct profiler *profiler)
Exclude time from other ongoing profiling results.
Definition: profile.h:184
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237

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().

◆ intel_poll_tx()

void intel_poll_tx ( struct net_device netdev)

Poll for completed packets.

Parameters
netdevNetwork device

Definition at line 779 of file intel.c.

779  {
780  struct intel_nic *intel = netdev->priv;
781  struct intel_descriptor *tx;
782  unsigned int tx_idx;
783 
784  /* Check for completed packets */
785  while ( intel->tx.cons != intel->tx.prod ) {
786 
787  /* Get next transmit descriptor */
788  tx_idx = ( intel->tx.cons % INTEL_NUM_TX_DESC );
789  tx = &intel->tx.desc[tx_idx];
790 
791  /* Stop if descriptor is still in use */
792  if ( ! ( tx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
793  return;
794 
795  DBGC2 ( intel, "INTEL %p TX %d complete\n", intel, tx_idx );
796 
797  /* Complete TX descriptor */
799  intel->tx.cons++;
800  }
801 }
#define INTEL_DESC_STATUS_DD
Descriptor done.
Definition: intel.h:51
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition: netdevice.h:764
#define INTEL_NUM_TX_DESC
Number of transmit descriptors.
Definition: intel.h:166
unsigned int cons
Consumer index.
Definition: intel.h:222
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define cpu_to_le32(value)
Definition: byteswap.h:107
A packet descriptor.
Definition: intel.h:21
#define DBGC2(...)
Definition: compiler.h:522
unsigned int prod
Producer index.
Definition: intel.h:220
An Intel network card.
Definition: intel.h:281
struct intel_descriptor * desc
Descriptors.
Definition: intel.h:216
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:304
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237

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().

◆ intel_poll_rx()

void intel_poll_rx ( struct net_device netdev)

Poll for received packets.

Parameters
netdevNetwork device

Definition at line 808 of file intel.c.

808  {
809  struct intel_nic *intel = netdev->priv;
810  struct intel_descriptor *rx;
811  struct io_buffer *iobuf;
812  unsigned int rx_idx;
813  size_t len;
814 
815  /* Check for received packets */
816  while ( intel->rx.cons != intel->rx.prod ) {
817 
818  /* Get next receive descriptor */
819  rx_idx = ( intel->rx.cons % INTEL_NUM_RX_DESC );
820  rx = &intel->rx.desc[rx_idx];
821 
822  /* Stop if descriptor is still in use */
823  if ( ! ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
824  return;
825 
826  /* Populate I/O buffer */
827  iobuf = intel->rx_iobuf[rx_idx];
828  intel->rx_iobuf[rx_idx] = NULL;
829  len = le16_to_cpu ( rx->length );
830  iob_put ( iobuf, len );
831 
832  /* Hand off to network stack */
833  if ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_RXE ) ) {
834  DBGC ( intel, "INTEL %p RX %d error (length %zd, "
835  "status %08x)\n", intel, rx_idx, len,
836  le32_to_cpu ( rx->status ) );
837  netdev_rx_err ( netdev, iobuf, -EIO );
838  } else {
839  DBGC2 ( intel, "INTEL %p RX %d complete (length %zd)\n",
840  intel, rx_idx, len );
841  netdev_rx ( netdev, iobuf );
842  }
843  intel->rx.cons++;
844  }
845 }
#define INTEL_DESC_STATUS_DD
Descriptor done.
Definition: intel.h:51
#define iob_put(iobuf, len)
Definition: iobuf.h:120
#define INTEL_NUM_RX_DESC
Number of receive descriptors.
Definition: intel.h:150
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:527
#define le32_to_cpu(value)
Definition: byteswap.h:113
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:306
#define DBGC(...)
Definition: compiler.h:505
unsigned int cons
Consumer index.
Definition: intel.h:222
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
struct io_buffer * rx_iobuf[INTEL_NUM_RX_DESC]
Receive I/O buffers.
Definition: intel.h:308
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define le16_to_cpu(value)
Definition: byteswap.h:112
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:489
A packet descriptor.
Definition: intel.h:21
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
unsigned int prod
Producer index.
Definition: intel.h:220
#define EIO
Input/output error.
Definition: errno.h:433
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
An Intel network card.
Definition: intel.h:281
struct intel_descriptor * desc
Descriptors.
Definition: intel.h:216
#define INTEL_DESC_STATUS_RXE
Receive error.
Definition: intel.h:54
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A persistent I/O buffer.
Definition: iobuf.h:33

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().

◆ intel_poll()

static void intel_poll ( struct net_device netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 852 of file intel.c.

852  {
853  struct intel_nic *intel = netdev->priv;
854  uint32_t icr;
855 
856  /* Check for and acknowledge interrupts */
857  profile_start ( &intel_vm_poll_profiler );
858  icr = readl ( intel->regs + INTEL_ICR );
859  profile_stop ( &intel_vm_poll_profiler );
860  profile_exclude ( &intel_vm_poll_profiler );
861  icr |= intel->force_icr;
862  if ( ! icr )
863  return;
864 
865  /* Poll for TX completions, if applicable */
866  if ( icr & INTEL_IRQ_TXDW )
867  intel_poll_tx ( netdev );
868 
869  /* Poll for RX completions, if applicable */
870  if ( icr & ( INTEL_IRQ_RXT0 | INTEL_IRQ_RXO ) )
871  intel_poll_rx ( netdev );
872 
873  /* Report receive overruns */
874  if ( icr & INTEL_IRQ_RXO )
876 
877  /* Check link state, if applicable */
878  if ( icr & INTEL_IRQ_LSC )
880 
881  /* Check for unexpected interrupts */
882  if ( icr & ~( INTEL_IRQ_TXDW | INTEL_IRQ_TXQE | INTEL_IRQ_LSC |
884  DBGC ( intel, "INTEL %p unexpected ICR %08x\n", intel, icr );
885  /* Report as a TX error */
887  }
888 
889  /* Refill RX ring */
890  intel_refill_rx ( intel );
891 }
unsigned int force_icr
Forced interrupts.
Definition: intel.h:291
void * regs
Registers.
Definition: intel.h:283
#define INTEL_ICR
Interrupt Cause Read Register.
Definition: intel.h:98
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:527
#define INTEL_IRQ_RXDMT0
Receive queue low.
Definition: intel.h:102
void intel_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: intel.c:808
#define INTEL_IRQ_RXT0
Receive timer.
Definition: intel.h:104
void netdev_tx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard transmitted packet.
Definition: netdevice.c:381
void intel_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: intel.c:779
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTEL_IRQ_TXDW
Transmit descriptor done.
Definition: intel.h:99
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
void intel_refill_rx(struct intel_nic *intel)
Refill receive descriptor ring.
Definition: intel.c:568
static void intel_check_link(struct net_device *netdev)
Check link state.
Definition: intel.c:353
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
unsigned int uint32_t
Definition: stdint.h:12
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
An Intel network card.
Definition: intel.h:281
#define INTEL_IRQ_TXQE
Transmit queue empty.
Definition: intel.h:100
#define INTEL_IRQ_LSC
Link status change.
Definition: intel.h:101
static void profile_exclude(struct profiler *profiler)
Exclude time from other ongoing profiling results.
Definition: profile.h:184
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define INTEL_IRQ_RXO
Receive overrun.
Definition: intel.h:103

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.

◆ intel_irq()

static void intel_irq ( struct net_device netdev,
int  enable 
)
static

Enable or disable interrupts.

Parameters
netdevNetwork device
enableInterrupts should be enabled

Definition at line 899 of file intel.c.

899  {
900  struct intel_nic *intel = netdev->priv;
901  uint32_t mask;
902 
904  if ( enable ) {
905  writel ( mask, intel->regs + INTEL_IMS );
906  } else {
907  writel ( mask, intel->regs + INTEL_IMC );
908  }
909 }
void * regs
Registers.
Definition: intel.h:283
#define INTEL_IRQ_RXT0
Receive timer.
Definition: intel.h:104
#define INTEL_IRQ_TXDW
Transmit descriptor done.
Definition: intel.h:99
void * priv
Driver private data.
Definition: netdevice.h:431
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTEL_IMS
Interrupt Mask Set/Read Register.
Definition: intel.h:107
unsigned int uint32_t
Definition: stdint.h:12
An Intel network card.
Definition: intel.h:281
#define INTEL_IRQ_LSC
Link status change.
Definition: intel.h:101
#define INTEL_IMC
Interrupt Mask Clear Register.
Definition: intel.h:110

References INTEL_IMC, INTEL_IMS, INTEL_IRQ_LSC, INTEL_IRQ_RXT0, INTEL_IRQ_TXDW, netdev, net_device::priv, intel_nic::regs, and writel().

◆ intel_probe()

static int intel_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 933 of file intel.c.

933  {
934  struct net_device *netdev;
935  struct intel_nic *intel;
936  int rc;
937 
938  /* Allocate and initialise net device */
939  netdev = alloc_etherdev ( sizeof ( *intel ) );
940  if ( ! netdev ) {
941  rc = -ENOMEM;
942  goto err_alloc;
943  }
945  intel = netdev->priv;
946  pci_set_drvdata ( pci, netdev );
947  netdev->dev = &pci->dev;
948  memset ( intel, 0, sizeof ( *intel ) );
949  intel->port = PCI_FUNC ( pci->busdevfn );
950  intel->flags = pci->id->driver_data;
955 
956  /* Fix up PCI device */
957  adjust_pci_device ( pci );
958 
959  /* Map registers */
960  intel->regs = pci_ioremap ( pci, pci->membase, INTEL_BAR_SIZE );
961  if ( ! intel->regs ) {
962  rc = -ENODEV;
963  goto err_ioremap;
964  }
965 
966  /* Configure DMA */
967  intel->dma = &pci->dma;
968  dma_set_mask_64bit ( intel->dma );
969  netdev->dma = intel->dma;
970 
971  /* Reset the NIC */
972  if ( ( rc = intel_reset ( intel ) ) != 0 )
973  goto err_reset;
974 
975  /* Fetch MAC address */
976  if ( ( rc = intel_fetch_mac ( intel, netdev->hw_addr ) ) != 0 )
977  goto err_fetch_mac;
978 
979  /* Register network device */
980  if ( ( rc = register_netdev ( netdev ) ) != 0 )
981  goto err_register_netdev;
982 
983  /* Set initial link state */
985 
986  return 0;
987 
989  err_register_netdev:
990  err_fetch_mac:
991  intel_reset ( intel );
992  err_reset:
993  iounmap ( intel->regs );
994  err_ioremap:
996  netdev_put ( netdev );
997  err_alloc:
998  return rc;
999 }
void * regs
Registers.
Definition: intel.h:283
#define PCI_FUNC(busdevfn)
Definition: pci.h:261
unsigned long membase
Memory base.
Definition: pci.h:197
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct dma_device dma
DMA device.
Definition: pci.h:192
#define INTEL_NUM_RX_DESC
Number of receive descriptors.
Definition: intel.h:150
static int intel_fetch_mac(struct intel_nic *intel, uint8_t *hw_addr)
Fetch initial MAC address.
Definition: intel.c:229
#define INTEL_RD
Receive Descriptor register block.
Definition: intel.h:143
unsigned long driver_data
Arbitrary driver data.
Definition: pci.h:160
#define INTEL_NUM_TX_DESC
Number of transmit descriptors.
Definition: intel.h:166
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:306
static __always_inline void dma_set_mask_64bit(struct dma_device *dma)
Set 64-bit addressable space mask.
Definition: dma.h:474
void intel_describe_tx(struct intel_descriptor *tx, physaddr_t addr, size_t len)
Populate transmit descriptor.
Definition: intel.c:383
struct dma_device * dma
DMA device.
Definition: netdevice.h:366
#define INTEL_BAR_SIZE
Intel BAR size.
Definition: intel.h:18
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
static void intel_init_ring(struct intel_ring *ring, unsigned int count, unsigned int reg, void(*describe)(struct intel_descriptor *desc, physaddr_t addr, size_t len))
Initialise descriptor ring.
Definition: intel.h:248
struct device dev
Generic device.
Definition: pci.h:190
static void intel_check_link(struct net_device *netdev)
Check link state.
Definition: intel.c:353
unsigned int port
Port number (for multi-port devices)
Definition: intel.h:287
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:504
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:341
#define ENOMEM
Not enough space.
Definition: errno.h:534
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:561
static int intel_reset(struct intel_nic *intel)
Reset hardware.
Definition: intel.c:266
void * priv
Driver private data.
Definition: netdevice.h:431
void intel_describe_rx(struct intel_descriptor *rx, physaddr_t addr, size_t len __unused)
Populate receive descriptor.
Definition: intel.c:421
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:874
static struct net_device_operations intel_operations
Intel network device operations.
Definition: intel.c:912
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:697
A network device.
Definition: netdevice.h:352
#define ENODEV
No such device.
Definition: errno.h:509
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:517
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
struct dma_device * dma
DMA device.
Definition: intel.h:285
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:213
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
struct pci_device_id * id
Driver device ID.
Definition: pci.h:223
An Intel network card.
Definition: intel.h:281
void iounmap(volatile const void *io_addr)
Unmap I/O address.
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:304
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
unsigned int flags
Flags.
Definition: intel.h:289
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
#define INTEL_TD
Transmit Descriptor register block.
Definition: intel.h:159
void * memset(void *dest, int character, size_t len) __nonnull

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().

◆ intel_remove()

static void intel_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 1006 of file intel.c.

1006  {
1007  struct net_device *netdev = pci_get_drvdata ( pci );
1008  struct intel_nic *intel = netdev->priv;
1009 
1010  /* Unregister network device */
1012 
1013  /* Reset the NIC */
1014  intel_reset ( intel );
1015 
1016  /* Free network device */
1017  iounmap ( intel->regs );
1018  netdev_nullify ( netdev );
1019  netdev_put ( netdev );
1020 }
void * regs
Registers.
Definition: intel.h:283
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:561
static int intel_reset(struct intel_nic *intel)
Reset hardware.
Definition: intel.c:266
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:874
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:517
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:351
An Intel network card.
Definition: intel.h:281
void iounmap(volatile const void *io_addr)
Unmap I/O address.

References intel_reset(), iounmap(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, intel_nic::regs, and unregister_netdev().

Variable Documentation

◆ __profiler

struct profiler intel_vm_poll_profiler __profiler
static
Initial value:
=
{ .name = "intel.vm_tx" }

VM transmit profiler.

VM poll profiler.

VM receive refill profiler.

Definition at line 47 of file intel.c.

◆ intel_operations

struct net_device_operations intel_operations
static
Initial value:
= {
.open = intel_open,
.close = intel_close,
.transmit = intel_transmit,
.poll = intel_poll,
.irq = intel_irq,
}
static int intel_open(struct net_device *netdev)
Open network device.
Definition: intel.c:635
static void intel_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition: intel.c:899
static void intel_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: intel.c:852
int intel_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: intel.c:740
static void intel_close(struct net_device *netdev)
Close network device.
Definition: intel.c:711

Intel network device operations.

Definition at line 912 of file intel.c.

Referenced by intel_probe().

◆ intel_nics

struct pci_device_id intel_nics[]
static

Intel PCI device IDs.

Definition at line 1023 of file intel.c.

◆ __pci_driver

struct pci_driver intel_driver __pci_driver
Initial value:
= {
.ids = intel_nics,
.id_count = ( sizeof ( intel_nics ) / sizeof ( intel_nics[0] ) ),
.probe = intel_probe,
}
static int intel_probe(struct pci_device *pci)
Probe PCI device.
Definition: intel.c:933
static struct pci_device_id intel_nics[]
Intel PCI device IDs.
Definition: intel.c:1023
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static void intel_remove(struct pci_device *pci)
Remove PCI device.
Definition: intel.c:1006

Intel PCI driver.

Definition at line 1170 of file intel.c.