iPXE
Functions | Variables
intelxvf.c File Reference

Intel 10 Gigabit Ethernet virtual function network card driver. More...

#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/io.h>
#include <ipxe/pci.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include "intelx.h"
#include "intelxvf.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void intelxvf_stats (struct intel_nic *intel)
 Dump statistics. More...
 
static void intelxvf_reset (struct intel_nic *intel)
 Reset hardware. More...
 
static void intelxvf_check_link (struct net_device *netdev)
 Check link state. More...
 
static int intelxvf_mbox_version (struct intel_nic *intel, unsigned int version)
 Send negotiate API version message. More...
 
static int intelxvf_mbox_queues (struct intel_nic *intel, int *vlan_thing)
 Get queue configuration. More...
 
static int intelxvf_open (struct net_device *netdev)
 Open network device. More...
 
static void intelxvf_close (struct net_device *netdev)
 Close network device. More...
 
static void intelxvf_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static void intelxvf_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts. More...
 
static int intelxvf_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void intelxvf_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

static struct net_device_operations intelxvf_operations
 Network device operations. More...
 
static struct pci_device_id intelxvf_nics []
 PCI device IDs. More...
 
struct pci_driver intelxvf_driver __pci_driver
 PCI driver. More...
 

Detailed Description

Intel 10 Gigabit Ethernet virtual function network card driver.

Definition in file intelxvf.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ intelxvf_stats()

static void intelxvf_stats ( struct intel_nic intel)
static

Dump statistics.

Parameters
intelIntel device

Definition at line 55 of file intelxvf.c.

55  {
56 
57  DBGC ( intel, "INTEL %p TX %d (%#x%08x) RX %d (%#x%08x) multi %d\n",
58  intel, readl ( intel->regs + INTELXVF_GPTC ),
59  readl ( intel->regs + INTELXVF_GOTCH ),
60  readl ( intel->regs + INTELXVF_GOTCL ),
61  readl ( intel->regs + INTELXVF_GPRC ),
62  readl ( intel->regs + INTELXVF_GORCH ),
63  readl ( intel->regs + INTELXVF_GORCL ),
64  readl ( intel->regs + INTELXVF_MPRC ) );
65 }
void * regs
Registers.
Definition: intel.h:291
#define INTELXVF_MPRC
Definition: intelxvf.h:91
#define INTELXVF_GORCL
Good Packets Received Count Low.
Definition: intelxvf.h:85
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTELXVF_GORCH
Good Packets Received Count High.
Definition: intelxvf.h:88
#define INTELXVF_GOTCL
Good Packets Transmitted Count Low.
Definition: intelxvf.h:100
#define INTELXVF_GPTC
Good Packets Transmitted Count.
Definition: intelxvf.h:97
#define INTELXVF_GOTCH
Good Packets Transmitted Count High.
Definition: intelxvf.h:103
#define INTELXVF_GPRC
Good Packets Received Count.
Definition: intelxvf.h:82

References DBGC, INTELXVF_GORCH, INTELXVF_GORCL, INTELXVF_GOTCH, INTELXVF_GOTCL, INTELXVF_GPRC, INTELXVF_GPTC, INTELXVF_MPRC, readl(), and intel_nic::regs.

◆ intelxvf_reset()

static void intelxvf_reset ( struct intel_nic intel)
static

Reset hardware.

Parameters
intelIntel device

Definition at line 79 of file intelxvf.c.

79  {
80 
81  /* Perform a function-level reset */
83 }
void * regs
Registers.
Definition: intel.h:291
#define INTELXVF_CTRL
Control Register.
Definition: intelxvf.h:15
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTELXVF_CTRL_RST
Function-level reset.
Definition: intelxvf.h:16

References INTELXVF_CTRL, INTELXVF_CTRL_RST, intel_nic::regs, and writel().

Referenced by intelxvf_close(), intelxvf_open(), intelxvf_probe(), and intelxvf_remove().

◆ intelxvf_check_link()

static void intelxvf_check_link ( struct net_device netdev)
static

Check link state.

Parameters
netdevNetwork device

Definition at line 97 of file intelxvf.c.

97  {
98  struct intel_nic *intel = netdev->priv;
99  uint32_t links;
100 
101  /* Read link status */
102  links = readl ( intel->regs + INTELXVF_LINKS );
103  DBGC ( intel, "INTEL %p link status is %08x\n", intel, links );
104 
105  /* Update network device */
106  if ( links & INTELXVF_LINKS_UP ) {
108  } else {
110  }
111 }
void * regs
Registers.
Definition: intel.h:291
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:230
#define INTELXVF_LINKS
Link Status Register.
Definition: intelxvf.h:19
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 INTELXVF_LINKS_UP
Link up.
Definition: intelxvf.h:20
unsigned int uint32_t
Definition: stdint.h:12
An Intel network card.
Definition: intel.h:289

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

Referenced by intelxvf_open(), intelxvf_poll(), and intelxvf_probe().

◆ intelxvf_mbox_version()

static int intelxvf_mbox_version ( struct intel_nic intel,
unsigned int  version 
)
static

Send negotiate API version message.

Parameters
intelIntel device
versionRequested version
Return values
rcReturn status code

Definition at line 127 of file intelxvf.c.

128  {
129  union intelvf_msg msg;
130  int rc;
131 
132  /* Send set MTU message */
133  memset ( &msg, 0, sizeof ( msg ) );
135  msg.version.version = version;
136  if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
137  DBGC ( intel, "INTEL %p negotiate API version failed: %s\n",
138  intel, strerror ( rc ) );
139  return rc;
140  }
141 
142  /* Check response */
144  DBGC ( intel, "INTEL %p negotiate API version unexpected "
145  "response:\n", intel );
146  DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
147  return -EPROTO;
148  }
149 
150  /* Check that this version is supported */
151  if ( ! ( msg.hdr & INTELVF_MSG_ACK ) ) {
152  DBGC ( intel, "INTEL %p negotiate API version failed\n",
153  intel );
154  return -EPERM;
155  }
156 
157  return 0;
158 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: message.c:61
#define DBGC(...)
Definition: compiler.h:505
Mailbox message.
Definition: intelvf.h:129
u32 version
Driver version.
Definition: ath9k_hw.c:1983
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPROTO
Protocol error.
Definition: errno.h:624
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define INTELVF_MSG_ACK
Message ACK flag.
Definition: intelvf.h:53
int intelvf_mbox_msg(struct intel_nic *intel, union intelvf_msg *msg)
Send/receive mailbox message.
Definition: intelvf.c:151
#define EPERM
Operation not permitted.
Definition: errno.h:614
#define INTELVF_MSG_TYPE_MASK
Message type mask.
Definition: intelvf.h:47
#define INTELXVF_MSG_TYPE_VERSION
Negotiate API version mailbox message.
Definition: intelxvf.h:106
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, DBGC_HDA, EPERM, EPROTO, intelvf_mbox_msg(), INTELVF_MSG_ACK, INTELVF_MSG_TYPE_MASK, INTELXVF_MSG_TYPE_VERSION, memset(), msg(), rc, strerror(), and version.

Referenced by intelxvf_open().

◆ intelxvf_mbox_queues()

static int intelxvf_mbox_queues ( struct intel_nic intel,
int *  vlan_thing 
)
static

Get queue configuration.

Parameters
intelIntel device
vlan_thingVLAN hand-waving thing to fill in
Return values
rcReturn status code

Definition at line 167 of file intelxvf.c.

167  {
168  union intelvf_msg msg;
169  int rc;
170 
171  /* Send queue configuration message */
172  memset ( &msg, 0, sizeof ( msg ) );
174  if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
175  DBGC ( intel, "INTEL %p get queue configuration failed: %s\n",
176  intel, strerror ( rc ) );
177  return rc;
178  }
179 
180  /* Check response */
182  DBGC ( intel, "INTEL %p get queue configuration unexpected "
183  "response:\n", intel );
184  DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
185  return -EPROTO;
186  }
187 
188  /* Check that we were allowed to get the queue configuration */
189  if ( ! ( msg.hdr & INTELVF_MSG_ACK ) ) {
190  DBGC ( intel, "INTEL %p get queue configuration refused\n",
191  intel );
192  return -EPERM;
193  }
194 
195  /* Extract VLAN hand-waving thing */
196  *vlan_thing = msg.queues.vlan_thing;
197 
198  return 0;
199 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: message.c:61
#define DBGC(...)
Definition: compiler.h:505
Mailbox message.
Definition: intelvf.h:129
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPROTO
Protocol error.
Definition: errno.h:624
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define INTELVF_MSG_ACK
Message ACK flag.
Definition: intelvf.h:53
int intelvf_mbox_msg(struct intel_nic *intel, union intelvf_msg *msg)
Send/receive mailbox message.
Definition: intelvf.c:151
#define EPERM
Operation not permitted.
Definition: errno.h:614
#define INTELVF_MSG_TYPE_MASK
Message type mask.
Definition: intelvf.h:47
#define INTELVF_MSG_TYPE_GET_QUEUES
Get queue configuration message.
Definition: intelvf.h:41
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, DBGC_HDA, EPERM, EPROTO, intelvf_mbox_msg(), INTELVF_MSG_ACK, INTELVF_MSG_TYPE_GET_QUEUES, INTELVF_MSG_TYPE_MASK, memset(), msg(), rc, and strerror().

Referenced by intelxvf_open().

◆ intelxvf_open()

static int intelxvf_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 214 of file intelxvf.c.

214  {
215  struct intel_nic *intel = netdev->priv;
216  uint32_t rxdctl;
217  uint32_t srrctl;
218  uint32_t dca_rxctrl;
219  unsigned int i;
220  int vlan_thing;
221  int rc;
222 
223  /* Reset the function */
224  intelxvf_reset ( intel );
225 
226  /* Notify PF that reset is complete */
227  if ( ( rc = intelvf_mbox_reset ( intel, NULL ) ) != 0 ) {
228  DBGC ( intel, "INTEL %p could not reset: %s\n",
229  intel, strerror ( rc ) );
230  goto err_mbox_reset;
231  }
232 
233  /* Negotiate API version 1.1. If we do not negotiate at least
234  * this version, then the RX datapath will remain disabled if
235  * the PF has jumbo frames enabled.
236  *
237  * Ignore failures, since the host may not actually support
238  * v1.1.
239  */
241 
242  /* Set MAC address */
243  if ( ( rc = intelvf_mbox_set_mac ( intel, netdev->ll_addr ) ) != 0 ) {
244  DBGC ( intel, "INTEL %p could not set MAC address: %s\n",
245  intel, strerror ( rc ) );
246  goto err_mbox_set_mac;
247  }
248 
249  /* Set MTU */
250  if ( ( rc = intelvf_mbox_set_mtu ( intel, netdev->max_pkt_len ) ) != 0){
251  DBGC ( intel, "INTEL %p could not set MTU %zd: %s\n",
252  intel, netdev->max_pkt_len, strerror ( rc ) );
253  goto err_mbox_set_mtu;
254  }
255 
256  /* Reset all descriptor rings */
257  for ( i = 0 ; i < INTELXVF_NUM_RINGS ; i++ ) {
258  intel_reset_ring ( intel, INTELXVF_TD ( i ) );
259  intel_reset_ring ( intel, INTELXVF_RD ( i ) );
260  }
261 
262  /* Reset packet split receive type register */
263  writel ( 0, intel->regs + INTELXVF_PSRTYPE );
264 
265  /* Get queue configuration. Ignore failures, since the host
266  * may not support this message.
267  */
268  vlan_thing = 0;
269  intelxvf_mbox_queues ( intel, &vlan_thing );
270  if ( vlan_thing ) {
271  DBGC ( intel, "INTEL %p stripping VLAN tags (thing=%d)\n",
272  intel, vlan_thing );
273  rxdctl = readl ( intel->regs + INTELXVF_RD(0) + INTEL_xDCTL );
274  rxdctl |= INTELX_RXDCTL_VME;
275  writel ( rxdctl, intel->regs + INTELXVF_RD(0) + INTEL_xDCTL );
276  }
277 
278  /* Create transmit descriptor ring */
279  if ( ( rc = intel_create_ring ( intel, &intel->tx ) ) != 0 )
280  goto err_create_tx;
281 
282  /* Create receive descriptor ring */
283  if ( ( rc = intel_create_ring ( intel, &intel->rx ) ) != 0 )
284  goto err_create_rx;
285 
286  /* Allocate interrupt vectors */
289  intel->regs + INTELXVF_IVAR );
291  intel->regs + INTELXVF_IVARM );
292 
293  /* Configure receive buffer sizes and set receive descriptor type */
294  srrctl = readl ( intel->regs + INTELXVF_SRRCTL );
295  srrctl &= ~( INTELXVF_SRRCTL_BSIZE_MASK |
298  srrctl |= ( INTELXVF_SRRCTL_BSIZE_DEFAULT |
302  writel ( srrctl, intel->regs + INTELXVF_SRRCTL );
303 
304  /* Clear "must-be-zero" bit for direct cache access (DCA). We
305  * leave DCA disabled anyway, but if we do not clear this bit
306  * then the received packets contain garbage data.
307  */
308  dca_rxctrl = readl ( intel->regs + INTELXVF_DCA_RXCTRL );
309  dca_rxctrl &= ~INTELXVF_DCA_RXCTRL_MUST_BE_ZERO;
310  writel ( dca_rxctrl, intel->regs + INTELXVF_DCA_RXCTRL );
311 
312  /* Fill receive ring */
313  intel_refill_rx ( intel );
314 
315  /* Update link state */
317 
318  return 0;
319 
320  intel_destroy_ring ( intel, &intel->rx );
321  err_create_rx:
322  intel_destroy_ring ( intel, &intel->tx );
323  err_create_tx:
324  err_mbox_set_mtu:
325  err_mbox_set_mac:
326  err_mbox_reset:
327  intelxvf_reset ( intel );
328  return rc;
329 }
#define INTELXVF_SRRCTL_DROP_EN
Definition: intelxvf.h:79
void * regs
Registers.
Definition: intel.h:291
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int intelvf_mbox_set_mtu(struct intel_nic *intel, size_t mtu)
Send set MTU message.
Definition: intelvf.c:313
void intel_reset_ring(struct intel_nic *intel, unsigned int reg)
Reset descriptor ring.
Definition: intel.c:487
#define INTEL_xDCTL
Receive/Transmit Descriptor Control (offset)
Definition: intel.h:195
#define INTELXVF_TD(n)
Transmit Descriptor register block.
Definition: intelxvf.h:94
#define INTELXVF_RD(n)
Receive Descriptor register block.
Definition: intelxvf.h:62
#define INTELXVF_SRRCTL_BSIZE_DEFAULT
Definition: intelxvf.h:71
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:314
#define DBGC(...)
Definition: compiler.h:505
int intel_create_ring(struct intel_nic *intel, struct intel_ring *ring)
Create descriptor ring.
Definition: intel.c:511
static void intelxvf_check_link(struct net_device *netdev)
Check link state.
Definition: intelxvf.c:97
#define INTELXVF_DCA_RXCTRL_MUST_BE_ZERO
Must be zero.
Definition: intelxvf.h:66
void intel_refill_rx(struct intel_nic *intel)
Refill receive descriptor ring.
Definition: intel.c:580
#define INTELXVF_SRRCTL_DESCTYPE_MASK
Definition: intelxvf.h:78
int intelvf_mbox_set_mac(struct intel_nic *intel, const uint8_t *ll_addr)
Send set MAC address message.
Definition: intelvf.c:275
static int intelxvf_mbox_version(struct intel_nic *intel, unsigned int version)
Send negotiate API version message.
Definition: intelxvf.c:127
#define INTELXVF_IVAR_TX0_VALID
TX queue 0 valid.
Definition: intelxvf.h:43
#define INTELXVF_IVAR
Interrupt Vector Allocation Register.
Definition: intelxvf.h:35
#define INTELXVF_SRRCTL_DESCTYPE_DEFAULT
Definition: intelxvf.h:77
#define INTELXVF_SRRCTL_BHDRSIZE_DEFAULT
Definition: intelxvf.h:74
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.
#define INTELXVF_IVAR_RX0_VALID
RX queue 0 valid.
Definition: intelxvf.h:39
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTELXVF_DCA_RXCTRL
RX DCA Control Register.
Definition: intelxvf.h:65
#define INTELXVF_IVAR_TX0_DEFAULT
Definition: intelxvf.h:41
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int intelvf_mbox_reset(struct intel_nic *intel, uint8_t *hw_addr)
Send reset message and get initial MAC address.
Definition: intelvf.c:232
#define INTELXVF_IVARM
Interrupt Vector Allocation Miscellaneous Register.
Definition: intelxvf.h:46
#define INTELXVF_IVAR_RX0_DEFAULT
Definition: intelxvf.h:37
unsigned int uint32_t
Definition: stdint.h:12
#define INTELXVF_PSRTYPE
Packet Split Receive Type.
Definition: intelxvf.h:59
static void intelxvf_reset(struct intel_nic *intel)
Reset hardware.
Definition: intelxvf.c:79
#define INTELXVF_SRRCTL_BSIZE_MASK
Definition: intelxvf.h:72
#define INTELXVF_SRRCTL_BHDRSIZE_MASK
Definition: intelxvf.h:75
#define INTELXVF_SRRCTL
Split Receive Control Register.
Definition: intelxvf.h:69
void intel_destroy_ring(struct intel_nic *intel, struct intel_ring *ring)
Destroy descriptor ring.
Definition: intel.c:563
#define INTELXVF_MSG_VERSION_1_1
API version 1.1.
Definition: intelxvf.h:109
An Intel network card.
Definition: intel.h:289
#define INTELX_RXDCTL_VME
Receive Descriptor Control Register.
Definition: intelx.h:75
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:312
#define INTELXVF_IVARM_MBOX_VALID
Mailbox valid.
Definition: intelxvf.h:50
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
static int intelxvf_mbox_queues(struct intel_nic *intel, int *vlan_thing)
Get queue configuration.
Definition: intelxvf.c:167
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:409
#define INTELXVF_IVARM_MBOX_DEFAULT
Definition: intelxvf.h:48
#define INTELXVF_NUM_RINGS
Number of queues.
Definition: intelxvf.h:112
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References DBGC, intel_create_ring(), intel_destroy_ring(), intel_refill_rx(), intel_reset_ring(), INTEL_xDCTL, intelvf_mbox_reset(), intelvf_mbox_set_mac(), intelvf_mbox_set_mtu(), INTELX_RXDCTL_VME, intelxvf_check_link(), INTELXVF_DCA_RXCTRL, INTELXVF_DCA_RXCTRL_MUST_BE_ZERO, INTELXVF_IVAR, INTELXVF_IVAR_RX0_DEFAULT, INTELXVF_IVAR_RX0_VALID, INTELXVF_IVAR_TX0_DEFAULT, INTELXVF_IVAR_TX0_VALID, INTELXVF_IVARM, INTELXVF_IVARM_MBOX_DEFAULT, INTELXVF_IVARM_MBOX_VALID, intelxvf_mbox_queues(), intelxvf_mbox_version(), INTELXVF_MSG_VERSION_1_1, INTELXVF_NUM_RINGS, INTELXVF_PSRTYPE, INTELXVF_RD, intelxvf_reset(), INTELXVF_SRRCTL, INTELXVF_SRRCTL_BHDRSIZE_DEFAULT, INTELXVF_SRRCTL_BHDRSIZE_MASK, INTELXVF_SRRCTL_BSIZE_DEFAULT, INTELXVF_SRRCTL_BSIZE_MASK, INTELXVF_SRRCTL_DESCTYPE_DEFAULT, INTELXVF_SRRCTL_DESCTYPE_MASK, INTELXVF_SRRCTL_DROP_EN, INTELXVF_TD, net_device::ll_addr, net_device::max_pkt_len, netdev, NULL, net_device::priv, rc, readl(), intel_nic::regs, intel_nic::rx, strerror(), intel_nic::tx, and writel().

◆ intelxvf_close()

static void intelxvf_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 336 of file intelxvf.c.

336  {
337  struct intel_nic *intel = netdev->priv;
338 
339  /* Destroy receive descriptor ring */
340  intel_destroy_ring ( intel, &intel->rx );
341 
342  /* Discard any unused receive buffers */
343  intel_empty_rx ( intel );
344 
345  /* Destroy transmit descriptor ring */
346  intel_destroy_ring ( intel, &intel->tx );
347 
348  /* Reset the function */
349  intelxvf_reset ( intel );
350 }
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:314
void intel_empty_rx(struct intel_nic *intel)
Discard unused receive I/O buffers.
Definition: intel.c:630
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static void intelxvf_reset(struct intel_nic *intel)
Reset hardware.
Definition: intelxvf.c:79
void intel_destroy_ring(struct intel_nic *intel, struct intel_ring *ring)
Destroy descriptor ring.
Definition: intel.c:563
An Intel network card.
Definition: intel.h:289
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:312

References intel_destroy_ring(), intel_empty_rx(), intelxvf_reset(), netdev, net_device::priv, intel_nic::rx, and intel_nic::tx.

◆ intelxvf_poll()

static void intelxvf_poll ( struct net_device netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 357 of file intelxvf.c.

357  {
358  struct intel_nic *intel = netdev->priv;
359  uint32_t eicr;
360  int rc;
361 
362  /* Check for and acknowledge interrupts */
363  eicr = readl ( intel->regs + INTELXVF_EICR );
364  if ( ! eicr )
365  return;
366 
367  /* Poll for TX completions, if applicable */
368  if ( eicr & INTELXVF_EIRQ_TX0 )
369  intel_poll_tx ( netdev );
370 
371  /* Poll for RX completions, if applicable */
372  if ( eicr & INTELXVF_EIRQ_RX0 )
373  intel_poll_rx ( netdev );
374 
375  /* Poll for mailbox messages, if applicable */
376  if ( eicr & INTELXVF_EIRQ_MBOX ) {
377 
378  /* Poll mailbox */
379  if ( ( rc = intelvf_mbox_poll ( intel ) ) != 0 ) {
380  DBGC ( intel, "INTEL %p mailbox poll failed!\n",
381  intel );
382  netdev_rx_err ( netdev, NULL, rc );
383  }
384 
385  /* Update link state */
387  }
388 
389  /* Refill RX ring */
390  intel_refill_rx ( intel );
391 }
void * regs
Registers.
Definition: intel.h:291
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:586
void intel_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: intel.c:820
void intel_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: intel.c:791
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
static void intelxvf_check_link(struct net_device *netdev)
Check link state.
Definition: intelxvf.c:97
void intel_refill_rx(struct intel_nic *intel)
Refill receive descriptor ring.
Definition: intel.c:580
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTELXVF_EIRQ_TX0
TX queue 0 (via IVAR)
Definition: intelxvf.h:25
#define INTELXVF_EIRQ_MBOX
Mailbox (via IVARM)
Definition: intelxvf.h:26
unsigned int uint32_t
Definition: stdint.h:12
#define INTELXVF_EIRQ_RX0
RX queue 0 (via IVAR)
Definition: intelxvf.h:24
int intelvf_mbox_poll(struct intel_nic *intel)
Poll mailbox.
Definition: intelvf.c:98
An Intel network card.
Definition: intel.h:289
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define INTELXVF_EICR
Extended Interrupt Cause Read Register.
Definition: intelxvf.h:23

References DBGC, intel_poll_rx(), intel_poll_tx(), intel_refill_rx(), intelvf_mbox_poll(), intelxvf_check_link(), INTELXVF_EICR, INTELXVF_EIRQ_MBOX, INTELXVF_EIRQ_RX0, INTELXVF_EIRQ_TX0, netdev, netdev_rx_err(), NULL, net_device::priv, rc, readl(), and intel_nic::regs.

◆ intelxvf_irq()

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

Enable or disable interrupts.

Parameters
netdevNetwork device
enableInterrupts should be enabled

Definition at line 399 of file intelxvf.c.

399  {
400  struct intel_nic *intel = netdev->priv;
401  uint32_t mask;
402 
404  if ( enable ) {
405  writel ( mask, intel->regs + INTELXVF_EIMS );
406  } else {
407  writel ( mask, intel->regs + INTELXVF_EIMC );
408  }
409 }
void * regs
Registers.
Definition: intel.h:291
#define INTELXVF_EIMS
Extended Interrupt Mask Set/Read Register.
Definition: intelxvf.h:29
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 INTELXVF_EIRQ_TX0
TX queue 0 (via IVAR)
Definition: intelxvf.h:25
#define INTELXVF_EIRQ_MBOX
Mailbox (via IVARM)
Definition: intelxvf.h:26
unsigned int uint32_t
Definition: stdint.h:12
#define INTELXVF_EIRQ_RX0
RX queue 0 (via IVAR)
Definition: intelxvf.h:24
An Intel network card.
Definition: intel.h:289
#define INTELXVF_EIMC
Extended Interrupt Mask Clear Register.
Definition: intelxvf.h:32

References INTELXVF_EIMC, INTELXVF_EIMS, INTELXVF_EIRQ_MBOX, INTELXVF_EIRQ_RX0, INTELXVF_EIRQ_TX0, netdev, net_device::priv, intel_nic::regs, and writel().

◆ intelxvf_probe()

static int intelxvf_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 433 of file intelxvf.c.

433  {
434  struct net_device *netdev;
435  struct intel_nic *intel;
436  int rc;
437 
438  /* Allocate and initialise net device */
439  netdev = alloc_etherdev ( sizeof ( *intel ) );
440  if ( ! netdev ) {
441  rc = -ENOMEM;
442  goto err_alloc;
443  }
445  intel = netdev->priv;
446  pci_set_drvdata ( pci, netdev );
447  netdev->dev = &pci->dev;
448  memset ( intel, 0, sizeof ( *intel ) );
454 
455  /* Fix up PCI device */
456  adjust_pci_device ( pci );
457 
458  /* Map registers */
459  intel->regs = pci_ioremap ( pci, pci->membase, INTELVF_BAR_SIZE );
460  if ( ! intel->regs ) {
461  rc = -ENODEV;
462  goto err_ioremap;
463  }
464 
465  /* Configure DMA */
466  intel->dma = &pci->dma;
467  dma_set_mask_64bit ( intel->dma );
468  netdev->dma = intel->dma;
469 
470  /* Reset the function */
471  intelxvf_reset ( intel );
472 
473  /* Send reset message and fetch MAC address */
474  if ( ( rc = intelvf_mbox_reset ( intel, netdev->hw_addr ) ) != 0 ) {
475  DBGC ( intel, "INTEL %p could not reset and fetch MAC: %s\n",
476  intel, strerror ( rc ) );
477  goto err_mbox_reset;
478  }
479 
480  /* Reset the function (since we will not respond to Control
481  * ("ping") mailbox messages until the network device is opened.
482  */
483  intelxvf_reset ( intel );
484 
485  /* Register network device */
486  if ( ( rc = register_netdev ( netdev ) ) != 0 )
487  goto err_register_netdev;
488 
489  /* Set initial link state */
491 
492  return 0;
493 
495  err_register_netdev:
496  err_mbox_reset:
497  intelxvf_reset ( intel );
498  iounmap ( intel->regs );
499  err_ioremap:
501  netdev_put ( netdev );
502  err_alloc:
503  return rc;
504 }
void * regs
Registers.
Definition: intel.h:291
unsigned long membase
Memory base.
Definition: pci.h:215
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct dma_device dma
DMA device.
Definition: pci.h:210
#define INTEL_NUM_RX_DESC
Number of receive descriptors.
Definition: intel.h:154
#define INTELXVF_MBCTRL
Mailbox Control Register.
Definition: intelxvf.h:56
struct intel_mailbox mbox
Mailbox.
Definition: intel.h:309
#define INTELXVF_TD(n)
Transmit Descriptor register block.
Definition: intelxvf.h:94
#define INTELXVF_RD(n)
Receive Descriptor register block.
Definition: intelxvf.h:62
#define INTEL_NUM_TX_DESC
Number of transmit descriptors.
Definition: intel.h:174
struct intel_ring rx
Receive descriptor ring.
Definition: intel.h:314
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void dma_set_mask_64bit(struct dma_device *dma)
Set 64-bit addressable space mask.
Definition: dma.h:474
struct dma_device * dma
DMA device.
Definition: netdevice.h:366
#define INTELXVF_MBMEM
Mailbox Memory Register Base.
Definition: intelxvf.h:53
static void intelxvf_check_link(struct net_device *netdev)
Check link state.
Definition: intelxvf.c:97
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:154
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:256
struct device dev
Generic device.
Definition: pci.h:208
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
#define INTELVF_BAR_SIZE
Intel VF BAR size.
Definition: intelvf.h:15
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
static void intel_init_mbox(struct intel_mailbox *mbox, unsigned int ctrl, unsigned int mem)
Initialise mailbox.
Definition: intel.h:281
#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:572
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:433
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int intelvf_mbox_reset(struct intel_nic *intel, uint8_t *hw_addr)
Send reset message and get initial MAC address.
Definition: intelvf.c:232
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
static struct net_device_operations intelxvf_operations
Network device operations.
Definition: intelxvf.c:412
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:528
static void intelxvf_reset(struct intel_nic *intel)
Reset hardware.
Definition: intelxvf.c:79
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
struct dma_device * dma
DMA device.
Definition: intel.h:293
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
void intel_describe_tx_adv(struct intel_descriptor *tx, physaddr_t addr, size_t len)
Populate advanced transmit descriptor.
Definition: intel.c:414
An Intel network card.
Definition: intel.h:289
void iounmap(volatile const void *io_addr)
Unmap I/O address.
struct intel_ring tx
Transmit descriptor ring.
Definition: intel.h:312
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
void * memset(void *dest, int character, size_t len) __nonnull

References adjust_pci_device(), alloc_etherdev(), DBGC, pci_device::dev, net_device::dev, pci_device::dma, intel_nic::dma, net_device::dma, dma_set_mask_64bit(), ENODEV, ENOMEM, net_device::hw_addr, intel_describe_rx(), intel_describe_tx_adv(), intel_init_mbox(), intel_init_ring(), INTEL_NUM_RX_DESC, INTEL_NUM_TX_DESC, INTELVF_BAR_SIZE, intelvf_mbox_reset(), intelxvf_check_link(), INTELXVF_MBCTRL, INTELXVF_MBMEM, intelxvf_operations, INTELXVF_RD, intelxvf_reset(), INTELXVF_TD, iounmap(), intel_nic::mbox, pci_device::membase, memset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), pci_ioremap(), pci_set_drvdata(), net_device::priv, rc, register_netdev(), intel_nic::regs, intel_nic::rx, strerror(), intel_nic::tx, and unregister_netdev().

◆ intelxvf_remove()

static void intelxvf_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 511 of file intelxvf.c.

511  {
512  struct net_device *netdev = pci_get_drvdata ( pci );
513  struct intel_nic *intel = netdev->priv;
514 
515  /* Unregister network device */
517 
518  /* Reset the NIC */
519  intelxvf_reset ( intel );
520 
521  /* Free network device */
522  iounmap ( intel->regs );
524  netdev_put ( netdev );
525 }
void * regs
Registers.
Definition: intel.h:291
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
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:941
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
static void intelxvf_reset(struct intel_nic *intel)
Reset hardware.
Definition: intelxvf.c:79
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:369
An Intel network card.
Definition: intel.h:289
void iounmap(volatile const void *io_addr)
Unmap I/O address.

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

Variable Documentation

◆ intelxvf_operations

struct net_device_operations intelxvf_operations
static
Initial value:
= {
.open = intelxvf_open,
.close = intelxvf_close,
.transmit = intel_transmit,
.poll = intelxvf_poll,
.irq = intelxvf_irq,
}
static int intelxvf_open(struct net_device *netdev)
Open network device.
Definition: intelxvf.c:214
static void intelxvf_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: intelxvf.c:357
static void intelxvf_close(struct net_device *netdev)
Close network device.
Definition: intelxvf.c:336
int intel_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: intel.c:752
static void intelxvf_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition: intelxvf.c:399

Network device operations.

Definition at line 412 of file intelxvf.c.

Referenced by intelxvf_probe().

◆ intelxvf_nics

struct pci_device_id intelxvf_nics[]
static
Initial value:
= {
PCI_ROM ( 0x8086, 0x10ed, "82599-vf", "82599 VF", 0 ),
PCI_ROM ( 0x8086, 0x1515, "x540-vf", "X540 VF", 0 ),
PCI_ROM ( 0x8086, 0x1565, "x550-vf", "X550 VF", 0 ),
PCI_ROM ( 0x8086, 0x15a8, "x552-vf", "X552 VF", 0 ),
PCI_ROM ( 0x8086, 0x15c5, "x557-vf", "X557-AT2 VF", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:303

PCI device IDs.

Definition at line 528 of file intelxvf.c.

◆ __pci_driver

struct pci_driver intelxvf_driver __pci_driver
Initial value:
= {
.ids = intelxvf_nics,
.id_count = ( sizeof ( intelxvf_nics ) / sizeof ( intelxvf_nics[0] ) ),
.probe = intelxvf_probe,
}
static void intelxvf_remove(struct pci_device *pci)
Remove PCI device.
Definition: intelxvf.c:511
static int intelxvf_probe(struct pci_device *pci)
Probe PCI device.
Definition: intelxvf.c:433
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static struct pci_device_id intelxvf_nics[]
PCI device IDs.
Definition: intelxvf.c:528

PCI driver.

Definition at line 537 of file intelxvf.c.