iPXE
Functions | Variables
intelx.c File Reference

Intel 10 Gigabit Ethernet 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/malloc.h>
#include <ipxe/pci.h>
#include "intelx.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int intelx_try_fetch_mac (struct intel_nic *intel, unsigned int ral0, uint8_t *hw_addr)
 Try to fetch initial MAC address. More...
 
static int intelx_fetch_mac (struct intel_nic *intel, uint8_t *hw_addr)
 Fetch initial MAC address. More...
 
static int intelx_reset (struct intel_nic *intel)
 Reset hardware. More...
 
static void intelx_check_link (struct net_device *netdev)
 Check link state. More...
 
static int intelx_open (struct net_device *netdev)
 Open network device. More...
 
static void intelx_close (struct net_device *netdev)
 Close network device. More...
 
static void intelx_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static void intelx_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts. More...
 
static int intelx_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void intelx_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

static struct net_device_operations intelx_operations
 Network device operations. More...
 
static struct pci_device_id intelx_nics []
 PCI device IDs. More...
 
struct pci_driver intelx_driver __pci_driver
 PCI driver. More...
 

Detailed Description

Intel 10 Gigabit Ethernet network card driver.

Definition in file intelx.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ intelx_try_fetch_mac()

static int intelx_try_fetch_mac ( struct intel_nic intel,
unsigned int  ral0,
uint8_t hw_addr 
)
static

Try to fetch initial MAC address.

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

Definition at line 60 of file intelx.c.

61  {
63 
64  /* Read current address from RAL0/RAH0 */
65  mac.reg.low = cpu_to_le32 ( readl ( intel->regs + ral0 ) );
66  mac.reg.high = cpu_to_le32 ( readl ( intel->regs + ral0 +
67  ( INTELX_RAH0 - INTELX_RAL0 ) ) );
68 
69  /* Use current address if valid */
70  if ( is_valid_ether_addr ( mac.raw ) ) {
71  DBGC ( intel, "INTEL %p has autoloaded MAC address %s at "
72  "%#05x\n", intel, eth_ntoa ( mac.raw ), ral0 );
73  memcpy ( hw_addr, mac.raw, ETH_ALEN );
74  return 0;
75  }
76 
77  return -ENOENT;
78 }
void * regs
Registers.
Definition: intel.h:280
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
#define INTELX_RAH0
Receive Address High.
Definition: intelx.h:67
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
#define INTELX_RAL0
Receive Address Low.
Definition: intelx.h:63
Receive address.
Definition: intel.h:204

References cpu_to_le32, DBGC, ENOENT, ETH_ALEN, eth_ntoa(), INTELX_RAH0, INTELX_RAL0, is_valid_ether_addr(), mac, memcpy(), readl(), and intel_nic::regs.

Referenced by intelx_fetch_mac().

◆ intelx_fetch_mac()

static int intelx_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 87 of file intelx.c.

87  {
88  int rc;
89 
90  /* Try to fetch address from INTELX_RAL0 */
91  if ( ( rc = intelx_try_fetch_mac ( intel, INTELX_RAL0,
92  hw_addr ) ) == 0 ) {
93  return 0;
94  }
95 
96  /* Try to fetch address from INTELX_RAL0_ALT */
97  if ( ( rc = intelx_try_fetch_mac ( intel, INTELX_RAL0_ALT,
98  hw_addr ) ) == 0 ) {
99  return 0;
100  }
101 
102  DBGC ( intel, "INTEL %p has no MAC address to use\n", intel );
103  return -ENOENT;
104 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelx_try_fetch_mac(struct intel_nic *intel, unsigned int ral0, uint8_t *hw_addr)
Try to fetch initial MAC address.
Definition: intelx.c:60
#define INTELX_RAL0_ALT
Definition: intelx.h:64
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
#define INTELX_RAL0
Receive Address Low.
Definition: intelx.h:63

References DBGC, ENOENT, INTELX_RAL0, INTELX_RAL0_ALT, intelx_try_fetch_mac(), and rc.

Referenced by intelx_probe().

◆ intelx_reset()

static int intelx_reset ( struct intel_nic intel)
static

Reset hardware.

Parameters
intelIntel device
Return values
rcReturn status code

Definition at line 119 of file intelx.c.

119  {
120  uint32_t ctrl;
121 
122  /* Perform a global software reset */
123  ctrl = readl ( intel->regs + INTELX_CTRL );
125  intel->regs + INTELX_CTRL );
127 
128  DBGC ( intel, "INTEL %p reset (ctrl %08x)\n", intel, ctrl );
129  return 0;
130 }
void * regs
Registers.
Definition: intel.h:280
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTELX_CTRL
Device Control Register.
Definition: intelx.h:17
#define INTELX_RESET_DELAY_MS
Time to delay for device reset, in milliseconds.
Definition: intelx.h:22
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
#define INTELX_CTRL_LRST
Link reset.
Definition: intelx.h:18
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define INTELX_CTRL_RST
Device reset.
Definition: intelx.h:19
static unsigned int ctrl
Definition: intel.h:270

References ctrl, DBGC, INTELX_CTRL, INTELX_CTRL_LRST, INTELX_CTRL_RST, INTELX_RESET_DELAY_MS, mdelay(), readl(), intel_nic::regs, and writel().

Referenced by intelx_close(), intelx_probe(), and intelx_remove().

◆ intelx_check_link()

static void intelx_check_link ( struct net_device netdev)
static

Check link state.

Parameters
netdevNetwork device

Definition at line 144 of file intelx.c.

144  {
145  struct intel_nic *intel = netdev->priv;
146  uint32_t links;
147 
148  /* Read link status */
149  links = readl ( intel->regs + INTELX_LINKS );
150  DBGC ( intel, "INTEL %p link status is %08x\n", intel, links );
151 
152  /* Update network device */
153  if ( links & INTELX_LINKS_UP ) {
155  } else {
157  }
158 }
void * regs
Registers.
Definition: intel.h:280
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
void * priv
Driver private data.
Definition: netdevice.h:425
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:768
static struct net_device * netdev
Definition: gdbudp.c:52
unsigned int uint32_t
Definition: stdint.h:12
An Intel network card.
Definition: intel.h:278
#define INTELX_LINKS
Link Status Register.
Definition: intelx.h:114
#define INTELX_LINKS_UP
Link up.
Definition: intelx.h:115

References DBGC, INTELX_LINKS, INTELX_LINKS_UP, netdev, netdev_link_down(), netdev_link_up(), net_device::priv, readl(), and intel_nic::regs.

Referenced by intelx_open(), intelx_poll(), and intelx_probe().

◆ intelx_open()

static int intelx_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 173 of file intelx.c.

173  {
174  struct intel_nic *intel = netdev->priv;
176  uint32_t ral0;
177  uint32_t rah0;
178  uint32_t dmatxctl;
179  uint32_t fctrl;
180  uint32_t srrctl;
181  uint32_t hlreg0;
182  uint32_t maxfrs;
183  uint32_t rdrxctl;
184  uint32_t rxctrl;
185  uint32_t dca_rxctrl;
186  int rc;
187 
188  /* Create transmit descriptor ring */
189  if ( ( rc = intel_create_ring ( intel, &intel->tx ) ) != 0 )
190  goto err_create_tx;
191 
192  /* Create receive descriptor ring */
193  if ( ( rc = intel_create_ring ( intel, &intel->rx ) ) != 0 )
194  goto err_create_rx;
195 
196  /* Program MAC address */
197  memset ( &mac, 0, sizeof ( mac ) );
198  memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
199  ral0 = le32_to_cpu ( mac.reg.low );
200  rah0 = ( le32_to_cpu ( mac.reg.high ) | INTELX_RAH0_AV );
201  writel ( ral0, intel->regs + INTELX_RAL0 );
202  writel ( rah0, intel->regs + INTELX_RAH0 );
203  writel ( ral0, intel->regs + INTELX_RAL0_ALT );
204  writel ( rah0, intel->regs + INTELX_RAH0_ALT );
205 
206  /* Allocate interrupt vectors */
209  intel->regs + INTELX_IVAR );
210 
211  /* Enable transmitter */
212  dmatxctl = readl ( intel->regs + INTELX_DMATXCTL );
213  dmatxctl |= INTELX_DMATXCTL_TE;
214  writel ( dmatxctl, intel->regs + INTELX_DMATXCTL );
215 
216  /* Configure receive filter */
217  fctrl = readl ( intel->regs + INTELX_FCTRL );
219  writel ( fctrl, intel->regs + INTELX_FCTRL );
220 
221  /* Configure receive buffer sizes */
222  srrctl = readl ( intel->regs + INTELX_SRRCTL );
223  srrctl &= ~INTELX_SRRCTL_BSIZE_MASK;
224  srrctl |= INTELX_SRRCTL_BSIZE_DEFAULT;
225  writel ( srrctl, intel->regs + INTELX_SRRCTL );
226 
227  /* Configure jumbo frames. Required to allow the extra 4-byte
228  * headroom for VLANs, since we don't use the hardware's
229  * native VLAN offload.
230  */
231  hlreg0 = readl ( intel->regs + INTELX_HLREG0 );
232  hlreg0 |= INTELX_HLREG0_JUMBOEN;
233  writel ( hlreg0, intel->regs + INTELX_HLREG0 );
234 
235  /* Configure frame size */
236  maxfrs = readl ( intel->regs + INTELX_MAXFRS );
237  maxfrs &= ~INTELX_MAXFRS_MFS_MASK;
238  maxfrs |= INTELX_MAXFRS_MFS_DEFAULT;
239  writel ( maxfrs, intel->regs + INTELX_MAXFRS );
240 
241  /* Configure receive DMA */
242  rdrxctl = readl ( intel->regs + INTELX_RDRXCTL );
243  rdrxctl |= INTELX_RDRXCTL_SECRC;
244  writel ( rdrxctl, intel->regs + INTELX_RDRXCTL );
245 
246  /* Clear "must-be-zero" bit for direct cache access (DCA). We
247  * leave DCA disabled anyway, but if we do not clear this bit
248  * then the received packets contain garbage data.
249  */
250  dca_rxctrl = readl ( intel->regs + INTELX_DCA_RXCTRL );
251  dca_rxctrl &= ~INTELX_DCA_RXCTRL_MUST_BE_ZERO;
252  writel ( dca_rxctrl, intel->regs + INTELX_DCA_RXCTRL );
253 
254  /* Enable receiver */
255  rxctrl = readl ( intel->regs + INTELX_RXCTRL );
256  rxctrl |= INTELX_RXCTRL_RXEN;
257  writel ( rxctrl, intel->regs + INTELX_RXCTRL );
258 
259  /* Fill receive ring */
260  intel_refill_rx ( intel );
261 
262  /* Update link state */
264 
265  return 0;
266 
267  intel_destroy_ring ( intel, &intel->rx );
268  err_create_rx:
269  intel_destroy_ring ( intel, &intel->tx );
270  err_create_tx:
271  return rc;
272 }
void * regs
Registers.
Definition: intel.h:280
#define INTELX_RDRXCTL
Receive DMA Control Register.
Definition: intelx.h:84
#define INTELX_IVAR_TX0_VALID
TX queue 0 valid.
Definition: intelx.h:46
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTELX_RAL0_ALT
Definition: intelx.h:64
#define INTELX_IVAR
Interrupt Vector Allocation Register.
Definition: intelx.h:38
#define INTELX_FCTRL_BAM
Broadcast accept mode.
Definition: intelx.h:52
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define INTELX_SRRCTL_BSIZE_MASK
Definition: intelx.h:81
#define INTELX_SRRCTL_BSIZE_DEFAULT
Definition: intelx.h:80
#define INTELX_IVAR_TX0_DEFAULT
Definition: intelx.h:44
#define INTELX_MAXFRS
Maximum Frame Size Register.
Definition: intelx.h:107
#define INTELX_RAH0_AV
Address valid.
Definition: intelx.h:69
#define INTELX_RXCTRL
Receive Control Register.
Definition: intelx.h:88
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:301
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 INTELX_HLREG0
MAC Core Control 0 Register.
Definition: intelx.h:103
static void intelx_check_link(struct net_device *netdev)
Check link state.
Definition: intelx.c:144
void intel_refill_rx(struct intel_nic *intel)
Refill receive descriptor ring.
Definition: intel.c:567
#define INTELX_RXCTRL_RXEN
Receive enable.
Definition: intelx.h:89
#define INTELX_RAH0
Receive Address High.
Definition: intelx.h:67
#define INTELX_DMATXCTL
Transmit DMA Control Register.
Definition: intelx.h:92
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define INTELX_FCTRL_MPE
Multicast promiscuous.
Definition: intelx.h:50
#define INTELX_IVAR_RX0_VALID
RX queue 0 valid.
Definition: intelx.h:42
void * priv
Driver private data.
Definition: netdevice.h:425
#define INTELX_FCTRL
Receive Filter Control Register.
Definition: intelx.h:49
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTELX_IVAR_RX0_DEFAULT
Definition: intelx.h:40
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTELX_HLREG0_JUMBOEN
Jumbo frame enable.
Definition: intelx.h:104
#define INTELX_DCA_RXCTRL_MUST_BE_ZERO
Must be zero.
Definition: intelx.h:100
#define INTELX_RAH0_ALT
Definition: intelx.h:68
#define INTELX_FCTRL_UPE
Unicast promiscuous mode.
Definition: intelx.h:51
#define INTELX_DCA_RXCTRL
RX DCA Control Register.
Definition: intelx.h:99
unsigned int uint32_t
Definition: stdint.h:12
#define INTELX_MAXFRS_MFS_MASK
Definition: intelx.h:111
#define INTELX_SRRCTL
Split Receive Control Register.
Definition: intelx.h:78
void intel_destroy_ring(struct intel_nic *intel, struct intel_ring *ring)
Destroy descriptor ring.
Definition: intel.c:550
An Intel network card.
Definition: intel.h:278
#define INTELX_RDRXCTL_SECRC
Strip CRC.
Definition: intelx.h:85
#define INTELX_DMATXCTL_TE
Transmit enable.
Definition: intelx.h:93
#define INTELX_RAL0
Receive Address Low.
Definition: intelx.h:63
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:299
Receive address.
Definition: intel.h:204
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
#define INTELX_MAXFRS_MFS_DEFAULT
Definition: intelx.h:109
void * memset(void *dest, int character, size_t len) __nonnull

References intel_create_ring(), intel_destroy_ring(), intel_refill_rx(), intelx_check_link(), INTELX_DCA_RXCTRL, INTELX_DCA_RXCTRL_MUST_BE_ZERO, INTELX_DMATXCTL, INTELX_DMATXCTL_TE, INTELX_FCTRL, INTELX_FCTRL_BAM, INTELX_FCTRL_MPE, INTELX_FCTRL_UPE, INTELX_HLREG0, INTELX_HLREG0_JUMBOEN, INTELX_IVAR, INTELX_IVAR_RX0_DEFAULT, INTELX_IVAR_RX0_VALID, INTELX_IVAR_TX0_DEFAULT, INTELX_IVAR_TX0_VALID, INTELX_MAXFRS, INTELX_MAXFRS_MFS_DEFAULT, INTELX_MAXFRS_MFS_MASK, INTELX_RAH0, INTELX_RAH0_ALT, INTELX_RAH0_AV, INTELX_RAL0, INTELX_RAL0_ALT, INTELX_RDRXCTL, INTELX_RDRXCTL_SECRC, INTELX_RXCTRL, INTELX_RXCTRL_RXEN, INTELX_SRRCTL, INTELX_SRRCTL_BSIZE_DEFAULT, INTELX_SRRCTL_BSIZE_MASK, 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().

◆ intelx_close()

static void intelx_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 279 of file intelx.c.

279  {
280  struct intel_nic *intel = netdev->priv;
281  uint32_t rxctrl;
282  uint32_t dmatxctl;
283 
284  /* Disable receiver */
285  rxctrl = readl ( intel->regs + INTELX_RXCTRL );
286  rxctrl &= ~INTELX_RXCTRL_RXEN;
287  writel ( rxctrl, intel->regs + INTELX_RXCTRL );
288 
289  /* Disable transmitter */
290  dmatxctl = readl ( intel->regs + INTELX_DMATXCTL );
291  dmatxctl &= ~INTELX_DMATXCTL_TE;
292  writel ( dmatxctl, intel->regs + INTELX_DMATXCTL );
293 
294  /* Destroy receive descriptor ring */
295  intel_destroy_ring ( intel, &intel->rx );
296 
297  /* Discard any unused receive buffers */
298  intel_empty_rx ( intel );
299 
300  /* Destroy transmit descriptor ring */
301  intel_destroy_ring ( intel, &intel->tx );
302 
303  /* Reset the NIC, to flush the transmit and receive FIFOs */
304  intelx_reset ( intel );
305 }
void * regs
Registers.
Definition: intel.h:280
static int intelx_reset(struct intel_nic *intel)
Reset hardware.
Definition: intelx.c:119
#define INTELX_RXCTRL
Receive Control Register.
Definition: intelx.h:88
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:301
void intel_empty_rx(struct intel_nic *intel)
Discard unused receive I/O buffers.
Definition: intel.c:619
#define INTELX_RXCTRL_RXEN
Receive enable.
Definition: intelx.h:89
#define INTELX_DMATXCTL
Transmit DMA Control Register.
Definition: intelx.h:92
void * priv
Driver private data.
Definition: netdevice.h:425
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
unsigned int uint32_t
Definition: stdint.h:12
void intel_destroy_ring(struct intel_nic *intel, struct intel_ring *ring)
Destroy descriptor ring.
Definition: intel.c:550
An Intel network card.
Definition: intel.h:278
#define INTELX_DMATXCTL_TE
Transmit enable.
Definition: intelx.h:93
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:299

References intel_destroy_ring(), intel_empty_rx(), INTELX_DMATXCTL, INTELX_DMATXCTL_TE, intelx_reset(), INTELX_RXCTRL, INTELX_RXCTRL_RXEN, netdev, net_device::priv, readl(), intel_nic::regs, intel_nic::rx, intel_nic::tx, and writel().

◆ intelx_poll()

static void intelx_poll ( struct net_device netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 312 of file intelx.c.

312  {
313  struct intel_nic *intel = netdev->priv;
314  uint32_t eicr;
315 
316  /* Check for and acknowledge interrupts */
317  eicr = readl ( intel->regs + INTELX_EICR );
318  if ( ! eicr )
319  return;
320 
321  /* Poll for TX completions, if applicable */
322  if ( eicr & INTELX_EIRQ_TX0 )
323  intel_poll_tx ( netdev );
324 
325  /* Poll for RX completions, if applicable */
326  if ( eicr & ( INTELX_EIRQ_RX0 | INTELX_EIRQ_RXO ) )
327  intel_poll_rx ( netdev );
328 
329  /* Report receive overruns */
330  if ( eicr & INTELX_EIRQ_RXO )
332 
333  /* Check link state, if applicable */
334  if ( eicr & INTELX_EIRQ_LSC )
336 
337  /* Refill RX ring */
338  intel_refill_rx ( intel );
339 }
void * regs
Registers.
Definition: intel.h:280
#define INTELX_EIRQ_LSC
Link status change.
Definition: intelx.h:29
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:501
void intel_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: intel.c:810
void intel_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: intel.c:781
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define INTELX_EIRQ_RXO
Receive overrun.
Definition: intelx.h:28
static void intelx_check_link(struct net_device *netdev)
Check link state.
Definition: intelx.c:144
#define INTELX_EIRQ_RX0
RX0 (via IVAR)
Definition: intelx.h:26
void intel_refill_rx(struct intel_nic *intel)
Refill receive descriptor ring.
Definition: intel.c:567
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
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:278
#define INTELX_EIRQ_TX0
RX0 (via IVAR)
Definition: intelx.h:27
#define INTELX_EICR
Extended Interrupt Cause Read Register.
Definition: intelx.h:25
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References ENOBUFS, intel_poll_rx(), intel_poll_tx(), intel_refill_rx(), intelx_check_link(), INTELX_EICR, INTELX_EIRQ_LSC, INTELX_EIRQ_RX0, INTELX_EIRQ_RXO, INTELX_EIRQ_TX0, netdev, netdev_rx_err(), NULL, net_device::priv, readl(), and intel_nic::regs.

◆ intelx_irq()

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

Enable or disable interrupts.

Parameters
netdevNetwork device
enableInterrupts should be enabled

Definition at line 347 of file intelx.c.

347  {
348  struct intel_nic *intel = netdev->priv;
349  uint32_t mask;
350 
352  INTELX_EIRQ_RX0 );
353  if ( enable ) {
354  writel ( mask, intel->regs + INTELX_EIMS );
355  } else {
356  writel ( mask, intel->regs + INTELX_EIMC );
357  }
358 }
void * regs
Registers.
Definition: intel.h:280
#define INTELX_EIRQ_LSC
Link status change.
Definition: intelx.h:29
#define INTELX_EIRQ_RXO
Receive overrun.
Definition: intelx.h:28
#define INTELX_EIRQ_RX0
RX0 (via IVAR)
Definition: intelx.h:26
#define INTELX_EIMC
Interrupt Mask Clear Register.
Definition: intelx.h:35
void * priv
Driver private data.
Definition: netdevice.h:425
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 INTELX_EIMS
Interrupt Mask Set/Read Register.
Definition: intelx.h:32
unsigned int uint32_t
Definition: stdint.h:12
An Intel network card.
Definition: intel.h:278
#define INTELX_EIRQ_TX0
RX0 (via IVAR)
Definition: intelx.h:27

References INTELX_EIMC, INTELX_EIMS, INTELX_EIRQ_LSC, INTELX_EIRQ_RX0, INTELX_EIRQ_RXO, INTELX_EIRQ_TX0, netdev, net_device::priv, intel_nic::regs, and writel().

◆ intelx_probe()

static int intelx_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 382 of file intelx.c.

382  {
383  struct net_device *netdev;
384  struct intel_nic *intel;
385  int rc;
386 
387  /* Allocate and initialise net device */
388  netdev = alloc_etherdev ( sizeof ( *intel ) );
389  if ( ! netdev ) {
390  rc = -ENOMEM;
391  goto err_alloc;
392  }
394  intel = netdev->priv;
395  pci_set_drvdata ( pci, netdev );
396  netdev->dev = &pci->dev;
397  memset ( intel, 0, sizeof ( *intel ) );
398  intel->port = PCI_FUNC ( pci->busdevfn );
399  intel_init_ring ( &intel->tx, INTEL_NUM_TX_DESC, INTELX_TD,
401  intel_init_ring ( &intel->rx, INTEL_NUM_RX_DESC, INTELX_RD,
403 
404  /* Fix up PCI device */
405  adjust_pci_device ( pci );
406 
407  /* Map registers */
408  intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE );
409  if ( ! intel->regs ) {
410  rc = -ENODEV;
411  goto err_ioremap;
412  }
413 
414  /* Reset the NIC */
415  if ( ( rc = intelx_reset ( intel ) ) != 0 )
416  goto err_reset;
417 
418  /* Fetch MAC address */
419  if ( ( rc = intelx_fetch_mac ( intel, netdev->hw_addr ) ) != 0 )
420  goto err_fetch_mac;
421 
422  /* Register network device */
423  if ( ( rc = register_netdev ( netdev ) ) != 0 )
424  goto err_register_netdev;
425 
426  /* Set initial link state */
428 
429  return 0;
430 
432  err_register_netdev:
433  err_fetch_mac:
434  intelx_reset ( intel );
435  err_reset:
436  iounmap ( intel->regs );
437  err_ioremap:
439  netdev_put ( netdev );
440  err_alloc:
441  return rc;
442 }
void * regs
Registers.
Definition: intel.h:280
#define PCI_FUNC(busdevfn)
Definition: pci.h:258
unsigned long membase
Memory base.
Definition: pci.h:194
static int intelx_reset(struct intel_nic *intel)
Reset hardware.
Definition: intelx.c:119
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTELX_RD
Receive Descriptor register block.
Definition: intelx.h:72
#define INTEL_NUM_RX_DESC
Number of receive descriptors.
Definition: intel.h:149
#define INTEL_NUM_TX_DESC
Number of transmit descriptors.
Definition: intel.h:165
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:301
void intel_describe_tx(struct intel_descriptor *tx, physaddr_t addr, size_t len)
Populate transmit descriptor.
Definition: intel.c:383
#define INTEL_BAR_SIZE
Intel BAR size.
Definition: intel.h:17
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
static void intelx_check_link(struct net_device *netdev)
Check link state.
Definition: intelx.c:144
struct device dev
Generic device.
Definition: pci.h:189
unsigned int port
Port number (for multi-port devices)
Definition: intel.h:282
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:338
#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:555
void * priv
Driver private data.
Definition: netdevice.h:425
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:844
static int intelx_fetch_mac(struct intel_nic *intel, uint8_t *hw_addr)
Fetch initial MAC address.
Definition: intelx.c:87
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
A network device.
Definition: netdevice.h:348
#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:511
static struct net_device_operations intelx_operations
Network device operations.
Definition: intelx.c:361
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:210
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
An Intel network card.
Definition: intel.h:278
void iounmap(volatile const void *io_addr)
Unmap I/O address.
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:299
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
#define INTELX_TD
Transmit Descriptor register block.
Definition: intelx.h:96
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
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, ENODEV, ENOMEM, net_device::hw_addr, INTEL_BAR_SIZE, intel_describe_rx(), intel_describe_tx(), INTEL_NUM_RX_DESC, INTEL_NUM_TX_DESC, intelx_check_link(), intelx_fetch_mac(), intelx_operations, INTELX_RD, intelx_reset(), INTELX_TD, ioremap(), iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), PCI_FUNC, pci_set_drvdata(), intel_nic::port, net_device::priv, rc, register_netdev(), intel_nic::regs, intel_nic::rx, intel_nic::tx, and unregister_netdev().

◆ intelx_remove()

static void intelx_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 449 of file intelx.c.

449  {
450  struct net_device *netdev = pci_get_drvdata ( pci );
451  struct intel_nic *intel = netdev->priv;
452 
453  /* Unregister network device */
455 
456  /* Reset the NIC */
457  intelx_reset ( intel );
458 
459  /* Free network device */
460  iounmap ( intel->regs );
462  netdev_put ( netdev );
463 }
void * regs
Registers.
Definition: intel.h:280
static int intelx_reset(struct intel_nic *intel)
Reset hardware.
Definition: intelx.c:119
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348
An Intel network card.
Definition: intel.h:278
void iounmap(volatile const void *io_addr)
Unmap I/O address.

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

Variable Documentation

◆ intelx_operations

struct net_device_operations intelx_operations
static
Initial value:
= {
.open = intelx_open,
.close = intelx_close,
.transmit = intel_transmit,
.poll = intelx_poll,
.irq = intelx_irq,
}
static int intelx_open(struct net_device *netdev)
Open network device.
Definition: intelx.c:173
static void intelx_close(struct net_device *netdev)
Close network device.
Definition: intelx.c:279
static void intelx_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: intelx.c:312
int intel_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: intel.c:740
static void intelx_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition: intelx.c:347

Network device operations.

Definition at line 361 of file intelx.c.

Referenced by intelx_probe().

◆ intelx_nics

struct pci_device_id intelx_nics[]
static
Initial value:
= {
PCI_ROM ( 0x8086, 0x10f7, "82599-kx4", "82599 (KX/KX4)", 0 ),
PCI_ROM ( 0x8086, 0x10f8, "82599-combo-backplane", "82599 (combined backplane; KR/KX4/KX)", 0 ),
PCI_ROM ( 0x8086, 0x10f9, "82599-cx4", "82599 (CX4)", 0 ),
PCI_ROM ( 0x8086, 0x10fb, "82599-sfp", "82599 (SFI/SFP+)", 0 ),
PCI_ROM ( 0x8086, 0x10fc, "82599-xaui", "82599 (XAUI/BX4)", 0 ),
PCI_ROM ( 0x8086, 0x1528, "x540t", "X540-AT2/X540-BT2", 0 ),
PCI_ROM ( 0x8086, 0x154d, "82599-sfp-sf2", "82599 (SFI/SFP+)", 0 ),
PCI_ROM ( 0x8086, 0x1557, "82599en-sfp", "82599 (Single Port SFI Only)", 0 ),
PCI_ROM ( 0x8086, 0x1560, "x540t1", "X540-AT2/X540-BT2 (with single port NVM)", 0 ),
PCI_ROM ( 0x8086, 0x1563, "x550t2", "X550-T2", 0 ),
PCI_ROM ( 0x8086, 0x15ab, "x552", "X552", 0 ),
PCI_ROM ( 0x8086, 0x15e5, "x553", "X553", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

PCI device IDs.

Definition at line 466 of file intelx.c.

◆ __pci_driver

struct pci_driver intelx_driver __pci_driver
Initial value:
= {
.ids = intelx_nics,
.id_count = ( sizeof ( intelx_nics ) / sizeof ( intelx_nics[0] ) ),
.probe = intelx_probe,
}
static struct pci_device_id intelx_nics[]
PCI device IDs.
Definition: intelx.c:466
static int intelx_probe(struct pci_device *pci)
Probe PCI device.
Definition: intelx.c:382
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static void intelx_remove(struct pci_device *pci)
Remove PCI device.
Definition: intelx.c:449

PCI driver.

Definition at line 482 of file intelx.c.