iPXE
Functions | Variables
intelxlvf.c File Reference

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

#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/pci.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include "intelxlvf.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void intelxlvf_reset_flr (struct intelxl_nic *intelxl, struct pci_device *pci)
 Reset hardware via PCIe function-level reset. More...
 
static int intelxlvf_reset_wait_teardown (struct intelxl_nic *intelxl)
 Wait for admin event queue to be torn down. More...
 
static int intelxlvf_reset_wait_active (struct intelxl_nic *intelxl)
 Wait for virtual function to be marked as active. More...
 
static int intelxlvf_reset_admin (struct intelxl_nic *intelxl)
 Reset hardware via admin queue. More...
 
static int intelxlvf_admin_command (struct net_device *netdev)
 Issue admin queue virtual function command. More...
 
static void intelxlvf_admin_link (struct net_device *netdev, struct intelxl_admin_vf_status_link *link)
 Handle link status event. More...
 
static void intelxlvf_admin_status (struct net_device *netdev, struct intelxl_admin_vf_status_buffer *stat)
 Handle status change event. More...
 
void intelxlvf_admin_event (struct net_device *netdev, struct intelxl_admin_descriptor *evt, union intelxl_admin_buffer *buf)
 Handle virtual function event. More...
 
static int intelxlvf_admin_get_resources (struct net_device *netdev)
 Get resources. More...
 
static int intelxlvf_admin_configure (struct net_device *netdev)
 Configure queues. More...
 
static int intelxlvf_admin_irq_map (struct net_device *netdev)
 Configure IRQ mapping. More...
 
static int intelxlvf_admin_queues (struct net_device *netdev, int enable)
 Enable/disable queues. More...
 
static int intelxlvf_admin_promisc (struct net_device *netdev)
 Configure promiscuous mode. More...
 
static int intelxlvf_open (struct net_device *netdev)
 Open network device. More...
 
static void intelxlvf_close (struct net_device *netdev)
 Close network device. More...
 
static int intelxlvf_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void intelxlvf_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

static const struct intelxl_admin_offsets intelxlvf_admin_command_offsets
 Admin command queue register offsets. More...
 
static const struct intelxl_admin_offsets intelxlvf_admin_event_offsets
 Admin event queue register offsets. More...
 
static struct net_device_operations intelxlvf_operations
 Network device operations. More...
 
static struct pci_device_id intelxlvf_nics []
 PCI device IDs. More...
 
struct pci_driver intelxlvf_driver __pci_driver
 PCI driver. More...
 

Detailed Description

Intel 40 Gigabit Ethernet virtual function network card driver.

Definition in file intelxlvf.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ intelxlvf_reset_flr()

static void intelxlvf_reset_flr ( struct intelxl_nic intelxl,
struct pci_device pci 
)
static

Reset hardware via PCIe function-level reset.

Parameters
intelxlIntel device

Definition at line 53 of file intelxlvf.c.

54  {
56 
57  /* Perform a PCIe function-level reset */
58  pci_read_config_word ( pci, ( intelxl->exp + PCI_EXP_DEVCTL ),
59  &control );
60  pci_write_config_word ( pci, ( intelxl->exp + PCI_EXP_DEVCTL ),
63 }
#define INTELXL_RESET_DELAY_MS
Time to delay for device reset, in milliseconds.
Definition: intelxl.h:993
unsigned short uint16_t
Definition: stdint.h:11
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
#define PCI_EXP_DEVCTL_FLR
Function level reset.
Definition: pci.h:111
unsigned int exp
PCI Express capability offset.
Definition: intelxl.h:1053
uint32_t control
Control.
Definition: myson.h:14
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define PCI_EXP_DEVCTL
PCI Express.
Definition: pci.h:110

References control, intelxl_nic::exp, INTELXL_RESET_DELAY_MS, mdelay(), PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_FLR, pci_read_config_word(), and pci_write_config_word().

Referenced by intelxlvf_probe(), and intelxlvf_remove().

◆ intelxlvf_reset_wait_teardown()

static int intelxlvf_reset_wait_teardown ( struct intelxl_nic intelxl)
static

Wait for admin event queue to be torn down.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 71 of file intelxlvf.c.

71  {
72  uint32_t admin_evt_len;
73  unsigned int i;
74 
75  /* Wait for admin event queue to be torn down */
76  for ( i = 0 ; i < INTELXLVF_RESET_MAX_WAIT_MS ; i++ ) {
77 
78  /* Check admin event queue length register */
79  admin_evt_len = readl ( intelxl->regs + INTELXLVF_ADMIN +
81  if ( ! ( admin_evt_len & INTELXL_ADMIN_LEN_ENABLE ) )
82  return 0;
83 
84  /* Delay */
85  mdelay ( 1 );
86  }
87 
88  DBGC ( intelxl, "INTELXL %p timed out waiting for teardown (%#08x)\n",
89  intelxl, admin_evt_len );
90  return -ETIMEDOUT;
91 }
void * regs
Registers.
Definition: intelxl.h:1030
#define INTELXLVF_ADMIN_EVT_LEN
Admin Event Queue Length Register (offset)
Definition: intelxlvf.h:51
#define INTELXL_ADMIN_LEN_ENABLE
Queue enable.
Definition: intelxl.h:49
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTELXLVF_ADMIN
VF Admin Queue register block.
Definition: intelxlvf.h:27
#define INTELXLVF_RESET_MAX_WAIT_MS
Maximum time to wait for reset to complete.
Definition: intelxlvf.h:68
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 ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References DBGC, ETIMEDOUT, INTELXL_ADMIN_LEN_ENABLE, INTELXLVF_ADMIN, INTELXLVF_ADMIN_EVT_LEN, INTELXLVF_RESET_MAX_WAIT_MS, mdelay(), readl(), and intelxl_nic::regs.

Referenced by intelxlvf_reset_admin().

◆ intelxlvf_reset_wait_active()

static int intelxlvf_reset_wait_active ( struct intelxl_nic intelxl)
static

Wait for virtual function to be marked as active.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 99 of file intelxlvf.c.

99  {
100  uint32_t vfgen_rstat;
101  unsigned int vfr_state;
102  unsigned int i;
103 
104  /* Wait for virtual function to be marked as active */
105  for ( i = 0 ; i < INTELXLVF_RESET_MAX_WAIT_MS ; i++ ) {
106 
107  /* Check status as written by physical function driver */
108  vfgen_rstat = readl ( intelxl->regs + INTELXLVF_VFGEN_RSTAT );
109  vfr_state = INTELXLVF_VFGEN_RSTAT_VFR_STATE ( vfgen_rstat );
110  if ( vfr_state == INTELXLVF_VFGEN_RSTAT_VFR_STATE_ACTIVE )
111  return 0;
112 
113  /* Delay */
114  mdelay ( 1 );
115  }
116 
117  DBGC ( intelxl, "INTELXL %p timed out waiting for activation "
118  "(%#08x)\n", intelxl, vfgen_rstat );
119  return -ETIMEDOUT;
120 }
void * regs
Registers.
Definition: intelxl.h:1030
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTELXLVF_VFGEN_RSTAT_VFR_STATE(x)
Definition: intelxlvf.h:64
#define INTELXLVF_VFGEN_RSTAT_VFR_STATE_ACTIVE
Definition: intelxlvf.h:65
#define INTELXLVF_RESET_MAX_WAIT_MS
Maximum time to wait for reset to complete.
Definition: intelxlvf.h:68
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 INTELXLVF_VFGEN_RSTAT
VF Reset Status Register.
Definition: intelxlvf.h:63
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References DBGC, ETIMEDOUT, INTELXLVF_RESET_MAX_WAIT_MS, INTELXLVF_VFGEN_RSTAT, INTELXLVF_VFGEN_RSTAT_VFR_STATE, INTELXLVF_VFGEN_RSTAT_VFR_STATE_ACTIVE, mdelay(), readl(), and intelxl_nic::regs.

Referenced by intelxlvf_reset_admin().

◆ intelxlvf_reset_admin()

static int intelxlvf_reset_admin ( struct intelxl_nic intelxl)
static

Reset hardware via admin queue.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 128 of file intelxlvf.c.

128  {
130  int rc;
131 
132  /* Populate descriptor */
135  cmd->vopcode = cpu_to_le32 ( INTELXL_ADMIN_VF_RESET );
136 
137  /* Issue command */
138  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
139  goto err_command;
140 
141  /* Wait for minimum reset time */
143 
144  /* Wait for reset to take effect */
145  if ( ( rc = intelxlvf_reset_wait_teardown ( intelxl ) ) != 0 )
146  goto err_teardown;
147 
148  /* Wait for virtual function to become active */
149  if ( ( rc = intelxlvf_reset_wait_active ( intelxl ) ) != 0 )
150  goto err_active;
151 
152  err_active:
153  err_teardown:
154  intelxl_reopen_admin ( intelxl );
155  err_command:
156  return rc;
157 }
#define INTELXL_RESET_DELAY_MS
Time to delay for device reset, in milliseconds.
Definition: intelxl.h:993
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxlvf_reset_wait_active(struct intelxl_nic *intelxl)
Wait for virtual function to be marked as active.
Definition: intelxlvf.c:99
#define INTELXL_ADMIN_SEND_TO_PF
Admin queue Send Message to PF command.
Definition: intelxl.h:308
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define INTELXL_ADMIN_VF_RESET
Admin Queue VF Reset opcode.
Definition: intelxl.h:314
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
Admin queue descriptor.
Definition: intelxl.h:522
static int intelxlvf_reset_wait_teardown(struct intelxl_nic *intelxl)
Wait for admin event queue to be torn down.
Definition: intelxlvf.c:71
#define cpu_to_le16(value)
Definition: byteswap.h:106
void intelxl_reopen_admin(struct intelxl_nic *intelxl)
Reopen admin queues (after virtual function reset)
Definition: intelxl.c:873
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_le16, cpu_to_le32, intelxl_admin_command(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_SEND_TO_PF, INTELXL_ADMIN_VF_RESET, intelxl_reopen_admin(), INTELXL_RESET_DELAY_MS, intelxlvf_reset_wait_active(), intelxlvf_reset_wait_teardown(), mdelay(), and rc.

Referenced by intelxlvf_probe(), and intelxlvf_remove().

◆ intelxlvf_admin_command()

static int intelxlvf_admin_command ( struct net_device netdev)
static

Issue admin queue virtual function command.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 190 of file intelxlvf.c.

190  {
191  struct intelxl_nic *intelxl = netdev->priv;
192  struct intelxl_admin *admin = &intelxl->command;
194  unsigned int i;
195  int rc;
196 
197  /* Populate descriptor */
198  cmd = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
200 
201  /* Record opcode */
202  intelxl->vopcode = le32_to_cpu ( cmd->vopcode );
203 
204  /* Issue command */
205  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
206  goto err_command;
207 
208  /* Wait for response */
209  for ( i = 0 ; i < INTELXLVF_ADMIN_MAX_WAIT_MS ; i++ ) {
210 
211  /* Poll admin event queue */
213 
214  /* If response has not arrived, delay 1ms and retry */
215  if ( intelxl->vopcode ) {
216  mdelay ( 1 );
217  continue;
218  }
219 
220  /* Check for errors */
221  if ( intelxl->vret != 0 )
222  return -EIO;
223 
224  return 0;
225  }
226 
227  rc = -ETIMEDOUT;
228  DBGC ( intelxl, "INTELXL %p timed out waiting for admin VF command "
229  "%#x\n", intelxl, intelxl->vopcode );
230  err_command:
231  intelxl->vopcode = 0;
232  return rc;
233 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define le32_to_cpu(value)
Definition: byteswap.h:113
int vret
Current VF return value.
Definition: intelxl.h:1063
Admin queue.
Definition: intelxl.h:560
#define DBGC(...)
Definition: compiler.h:505
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
#define INTELXL_ADMIN_SEND_TO_PF
Admin queue Send Message to PF command.
Definition: intelxl.h:308
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
unsigned int index
Queue index.
Definition: intelxl.h:566
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
void intelxl_poll_admin(struct net_device *netdev)
Poll admin event queue.
Definition: intelxl.c:780
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:562
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
Admin queue descriptor.
Definition: intelxl.h:522
#define EIO
Input/output error.
Definition: errno.h:433
#define INTELXLVF_ADMIN_MAX_WAIT_MS
Maximum time to wait for a VF admin request to complete.
Definition: intelxlvf.h:60
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
unsigned int vopcode
Current VF opcode.
Definition: intelxl.h:1061

References cmd, intelxl_nic::command, cpu_to_le16, DBGC, intelxl_admin::desc, EIO, ETIMEDOUT, intelxl_admin::index, intelxl_admin_command(), INTELXL_ADMIN_NUM_DESC, INTELXL_ADMIN_SEND_TO_PF, intelxl_poll_admin(), INTELXLVF_ADMIN_MAX_WAIT_MS, le32_to_cpu, mdelay(), netdev, net_device::priv, rc, intelxl_nic::vopcode, and intelxl_nic::vret.

Referenced by intelxlvf_admin_configure(), intelxlvf_admin_get_resources(), intelxlvf_admin_irq_map(), intelxlvf_admin_promisc(), and intelxlvf_admin_queues().

◆ intelxlvf_admin_link()

static void intelxlvf_admin_link ( struct net_device netdev,
struct intelxl_admin_vf_status_link link 
)
static

Handle link status event.

Parameters
netdevNetwork device
linkLink status

Definition at line 241 of file intelxlvf.c.

242  {
243  struct intelxl_nic *intelxl = netdev->priv;
244 
245  DBGC ( intelxl, "INTELXL %p link %#02x speed %#02x\n", intelxl,
246  link->status, link->speed );
247 
248  /* Update network device */
249  if ( link->status ) {
251  } else {
253  }
254 }
#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
u32 link
Link to next descriptor.
Definition: ar9003_mac.h:68
An Intel 40Gigabit network card.
Definition: intelxl.h:1028

References DBGC, link, netdev, netdev_link_down(), netdev_link_up(), and net_device::priv.

Referenced by intelxlvf_admin_status().

◆ intelxlvf_admin_status()

static void intelxlvf_admin_status ( struct net_device netdev,
struct intelxl_admin_vf_status_buffer stat 
)
static

Handle status change event.

Parameters
netdevNetwork device
statStatus change event

Definition at line 263 of file intelxlvf.c.

264  {
265  struct intelxl_nic *intelxl = netdev->priv;
266 
267  /* Handle event */
268  switch ( stat->event ) {
270  intelxlvf_admin_link ( netdev, &stat->data.link );
271  break;
272  default:
273  DBGC ( intelxl, "INTELXL %p unrecognised status change "
274  "event %#x:\n", intelxl, le32_to_cpu ( stat->event ) );
275  DBGC_HDA ( intelxl, 0, stat, sizeof ( *stat ) );
276  break;
277  }
278 }
#define le32_to_cpu(value)
Definition: byteswap.h:113
static void intelxlvf_admin_link(struct net_device *netdev, struct intelxl_admin_vf_status_link *link)
Handle link status event.
Definition: intelxlvf.c:241
#define DBGC(...)
Definition: compiler.h:505
uint32_t event
Event type.
Definition: intelxl.h:350
#define INTELXL_ADMIN_VF_STATUS_LINK
Link status change event type.
Definition: intelxl.h:335
void * priv
Driver private data.
Definition: netdevice.h:425
#define DBGC_HDA(...)
Definition: compiler.h:506
static struct net_device * netdev
Definition: gdbudp.c:52
u32 link
Link to next descriptor.
Definition: ar9003_mac.h:68
#define cpu_to_le32(value)
Definition: byteswap.h:107
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References cpu_to_le32, intelxl_admin_vf_status_buffer::data, DBGC, DBGC_HDA, intelxl_admin_vf_status_buffer::event, INTELXL_ADMIN_VF_STATUS_LINK, intelxlvf_admin_link(), le32_to_cpu, intelxl_admin_vf_status_buffer::link, netdev, and net_device::priv.

Referenced by intelxlvf_admin_event().

◆ intelxlvf_admin_event()

void intelxlvf_admin_event ( struct net_device netdev,
struct intelxl_admin_descriptor evt,
union intelxl_admin_buffer buf 
)

Handle virtual function event.

Parameters
netdevNetwork device
evtAdmin queue event descriptor
bufAdmin queue event data buffer

Definition at line 287 of file intelxlvf.c.

289  {
290  struct intelxl_nic *intelxl = netdev->priv;
291  unsigned int vopcode = le32_to_cpu ( evt->vopcode );
292 
293  /* Record command response if applicable */
294  if ( vopcode == intelxl->vopcode ) {
295  memcpy ( &intelxl->vbuf, buf, sizeof ( intelxl->vbuf ) );
296  intelxl->vopcode = 0;
297  intelxl->vret = le32_to_cpu ( evt->vret );
298  if ( intelxl->vret != 0 ) {
299  DBGC ( intelxl, "INTELXL %p admin VF command %#x "
300  "error %d\n", intelxl, vopcode, intelxl->vret );
301  DBGC_HDA ( intelxl, virt_to_bus ( evt ), evt,
302  sizeof ( *evt ) );
303  DBGC_HDA ( intelxl, virt_to_bus ( buf ), buf,
304  le16_to_cpu ( evt->len ) );
305  }
306  return;
307  }
308 
309  /* Handle unsolicited events */
310  switch ( vopcode ) {
313  break;
314  default:
315  DBGC ( intelxl, "INTELXL %p unrecognised VF event %#x:\n",
316  intelxl, vopcode );
317  DBGC_HDA ( intelxl, 0, evt, sizeof ( *evt ) );
318  DBGC_HDA ( intelxl, 0, buf, le16_to_cpu ( evt->len ) );
319  break;
320  }
321 }
#define le32_to_cpu(value)
Definition: byteswap.h:113
int vret
Current VF return value.
Definition: intelxl.h:1063
#define DBGC(...)
Definition: compiler.h:505
static void intelxlvf_admin_status(struct net_device *netdev, struct intelxl_admin_vf_status_buffer *stat)
Handle status change event.
Definition: intelxlvf.c:263
struct intelxl_admin_vf_status_buffer stat
VF Status Change Event data buffer.
Definition: intelxl.h:508
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint16_t len
Data length.
Definition: intelxl.h:528
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
void * priv
Driver private data.
Definition: netdevice.h:425
#define DBGC_HDA(...)
Definition: compiler.h:506
static struct net_device * netdev
Definition: gdbudp.c:52
union intelxl_admin_buffer vbuf
Current VF event data buffer.
Definition: intelxl.h:1065
int32_t vret
VF return value.
Definition: intelxl.h:539
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
#define le16_to_cpu(value)
Definition: byteswap.h:112
unsigned int vopcode
Current VF opcode.
Definition: intelxl.h:1061
uint32_t vopcode
VF opcode.
Definition: intelxl.h:536
#define INTELXL_ADMIN_VF_STATUS
Admin Queue VF Status Change Event opcode.
Definition: intelxl.h:332

References DBGC, DBGC_HDA, INTELXL_ADMIN_VF_STATUS, intelxlvf_admin_status(), le16_to_cpu, le32_to_cpu, intelxl_admin_descriptor::len, memcpy(), netdev, net_device::priv, intelxl_admin_buffer::stat, intelxl_nic::vbuf, virt_to_bus(), intelxl_admin_descriptor::vopcode, intelxl_nic::vopcode, intelxl_admin_descriptor::vret, and intelxl_nic::vret.

◆ intelxlvf_admin_get_resources()

static int intelxlvf_admin_get_resources ( struct net_device netdev)
static

Get resources.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 329 of file intelxlvf.c.

329  {
330  struct intelxl_nic *intelxl = netdev->priv;
333  int rc;
334 
335  /* Populate descriptor */
338 
339  /* Issue command */
340  if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
341  return rc;
342 
343  /* Parse response */
344  res = &intelxl->vbuf.res;
345  intelxl->vsi = le16_to_cpu ( res->vsi );
346  memcpy ( netdev->hw_addr, res->mac, ETH_ALEN );
347  DBGC ( intelxl, "INTELXL %p VSI %#04x\n", intelxl, intelxl->vsi );
348 
349  return 0;
350 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxlvf_admin_command(struct net_device *netdev)
Issue admin queue virtual function command.
Definition: intelxlvf.c:190
#define DBGC(...)
Definition: compiler.h:505
Admin Queue VF Get Resources data buffer.
Definition: intelxl.h:320
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:324
struct intelxl_admin_vf_get_resources_buffer res
VF Get Resources data buffer.
Definition: intelxl.h:506
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define cpu_to_le32(value)
Definition: byteswap.h:107
union intelxl_admin_buffer vbuf
Current VF event data buffer.
Definition: intelxl.h:1065
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
#define ETH_ALEN
Definition: if_ether.h:8
#define le16_to_cpu(value)
Definition: byteswap.h:112
Admin queue descriptor.
Definition: intelxl.h:522
#define INTELXL_ADMIN_VF_GET_RESOURCES
Admin Queue VF Get Resources opcode.
Definition: intelxl.h:317
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
uint8_t mac[ETH_ALEN]
MAC address.
Definition: intelxl.h:328

References cmd, cpu_to_le32, DBGC, ETH_ALEN, net_device::hw_addr, intelxl_admin_command_descriptor(), INTELXL_ADMIN_VF_GET_RESOURCES, intelxlvf_admin_command(), le16_to_cpu, intelxl_admin_vf_get_resources_buffer::mac, memcpy(), netdev, net_device::priv, rc, intelxl_admin_buffer::res, intelxl_nic::vbuf, intelxl_admin_vf_get_resources_buffer::vsi, and intelxl_nic::vsi.

Referenced by intelxlvf_probe().

◆ intelxlvf_admin_configure()

static int intelxlvf_admin_configure ( struct net_device netdev)
static

Configure queues.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 365 of file intelxlvf.c.

365  {
366  struct intelxl_nic *intelxl = netdev->priv;
368  union intelxl_admin_buffer *buf;
369  int rc;
370 
371  /* Populate descriptor */
375  cmd->len = cpu_to_le16 ( sizeof ( buf->cfg ) );
376  buf = intelxl_admin_command_buffer ( intelxl );
377  buf->cfg.vsi = cpu_to_le16 ( intelxl->vsi );
378  buf->cfg.count = cpu_to_le16 ( 1 );
379  buf->cfg.tx.vsi = cpu_to_le16 ( intelxl->vsi );
381  buf->cfg.tx.base = cpu_to_le64 ( virt_to_bus ( intelxl->tx.desc.raw ) );
382  buf->cfg.rx.vsi = cpu_to_le16 ( intelxl->vsi );
384  buf->cfg.rx.len = cpu_to_le32 ( intelxl->mfs );
385  buf->cfg.rx.mfs = cpu_to_le32 ( intelxl->mfs );
386  buf->cfg.rx.base = cpu_to_le64 ( virt_to_bus ( intelxl->rx.desc.raw ) );
387 
388  /* Issue command */
389  if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
390  return rc;
391 
392  return 0;
393 }
struct intelxl_admin_vf_configure_buffer cfg
VF Configure Queues data buffer.
Definition: intelxl.h:510
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxlvf_admin_command(struct net_device *netdev)
Issue admin queue virtual function command.
Definition: intelxlvf.c:190
union intelxl_admin_buffer * intelxl_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition: intelxl.c:307
#define cpu_to_le64(value)
Definition: byteswap.h:108
size_t mfs
Maximum frame size.
Definition: intelxl.h:1032
uint32_t mfs
Maximum frame size.
Definition: intelxl.h:399
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:1070
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
struct intelxl_admin_vf_configure_buffer::@60 tx
Transmit queue.
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition: intelxl.h:915
void * priv
Driver private data.
Definition: netdevice.h:425
#define INTELXL_ADMIN_VF_CONFIGURE
Admin Queue VF Configure Queues opcode.
Definition: intelxl.h:361
void * raw
Raw data.
Definition: intelxl.h:872
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTELXL_RX_NUM_DESC
Number of receive descriptors.
Definition: intelxl.h:924
#define cpu_to_le32(value)
Definition: byteswap.h:107
uint64_t base
Base address.
Definition: intelxl.h:382
union intelxl_ring::@64 desc
Descriptors.
struct intelxl_admin_vf_configure_buffer::@61 rx
Receive queue.
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
uint16_t count
Number of queue pairs.
Definition: intelxl.h:368
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:366
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
uint32_t len
Data buffer length.
Definition: intelxl.h:397
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_FL_RD
Admin descriptor uses data buffer for command parameters.
Definition: intelxl.h:554
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
Admin queue data buffer.
Definition: intelxl.h:498

References intelxl_admin_vf_configure_buffer::base, intelxl_admin_buffer::cfg, cmd, intelxl_admin_vf_configure_buffer::count, cpu_to_le16, cpu_to_le32, cpu_to_le64, intelxl_ring::desc, intelxl_admin_command_buffer(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXL_ADMIN_VF_CONFIGURE, INTELXL_RX_NUM_DESC, INTELXL_TX_NUM_DESC, intelxlvf_admin_command(), intelxl_admin_vf_configure_buffer::len, intelxl_admin_vf_configure_buffer::mfs, intelxl_nic::mfs, netdev, net_device::priv, intelxl_ring::raw, rc, intelxl_admin_vf_configure_buffer::rx, intelxl_nic::rx, intelxl_admin_vf_configure_buffer::tx, intelxl_nic::tx, virt_to_bus(), intelxl_admin_vf_configure_buffer::vsi, and intelxl_nic::vsi.

Referenced by intelxlvf_open().

◆ intelxlvf_admin_irq_map()

static int intelxlvf_admin_irq_map ( struct net_device netdev)
static

Configure IRQ mapping.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 401 of file intelxlvf.c.

401  {
402  struct intelxl_nic *intelxl = netdev->priv;
404  union intelxl_admin_buffer *buf;
405  int rc;
406 
407  /* Populate descriptor */
411  cmd->len = cpu_to_le16 ( sizeof ( buf->irq ) );
412  buf = intelxl_admin_command_buffer ( intelxl );
413  buf->irq.count = cpu_to_le16 ( 1 );
414  buf->irq.vsi = cpu_to_le16 ( intelxl->vsi );
415  buf->irq.rxmap = cpu_to_le16 ( 0x0001 );
416  buf->irq.txmap = cpu_to_le16 ( 0x0001 );
417 
418  /* Issue command */
419  if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
420  return rc;
421 
422  return 0;
423 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxlvf_admin_command(struct net_device *netdev)
Issue admin queue virtual function command.
Definition: intelxlvf.c:190
struct intelxl_admin_vf_irq_map_buffer irq
Definition: intelxl.h:516
union intelxl_admin_buffer * intelxl_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition: intelxl.c:307
#define INTELXL_ADMIN_VF_IRQ_MAP
Admin Queue VF IRQ Map opcode.
Definition: intelxl.h:417
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
void * priv
Driver private data.
Definition: netdevice.h:425
uint16_t txmap
Transmit queue bitmap.
Definition: intelxl.h:430
static struct net_device * netdev
Definition: gdbudp.c:52
#define cpu_to_le32(value)
Definition: byteswap.h:107
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:424
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
uint16_t count
Number of interrupt vectors.
Definition: intelxl.h:422
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
Admin queue descriptor.
Definition: intelxl.h:522
uint16_t rxmap
Receive queue bitmap.
Definition: intelxl.h:428
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_FL_RD
Admin descriptor uses data buffer for command parameters.
Definition: intelxl.h:554
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
Admin queue data buffer.
Definition: intelxl.h:498

References cmd, intelxl_admin_vf_irq_map_buffer::count, cpu_to_le16, cpu_to_le32, intelxl_admin_command_buffer(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXL_ADMIN_VF_IRQ_MAP, intelxlvf_admin_command(), intelxl_admin_buffer::irq, netdev, net_device::priv, rc, intelxl_admin_vf_irq_map_buffer::rxmap, intelxl_admin_vf_irq_map_buffer::txmap, intelxl_admin_vf_irq_map_buffer::vsi, and intelxl_nic::vsi.

Referenced by intelxlvf_open().

◆ intelxlvf_admin_queues()

static int intelxlvf_admin_queues ( struct net_device netdev,
int  enable 
)
static

Enable/disable queues.

Parameters
netdevNetwork device
enableEnable queues
Return values
rcReturn status code

Definition at line 432 of file intelxlvf.c.

432  {
433  struct intelxl_nic *intelxl = netdev->priv;
435  union intelxl_admin_buffer *buf;
436  int rc;
437 
438  /* Populate descriptor */
440  cmd->vopcode = ( enable ? cpu_to_le32 ( INTELXL_ADMIN_VF_ENABLE ) :
443  cmd->len = cpu_to_le16 ( sizeof ( buf->queues ) );
444  buf = intelxl_admin_command_buffer ( intelxl );
445  buf->queues.vsi = cpu_to_le16 ( intelxl->vsi );
446  buf->queues.rx = cpu_to_le32 ( 1 );
447  buf->queues.tx = cpu_to_le32 ( 1 );
448 
449  /* Issue command */
450  if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
451  return rc;
452 
453  return 0;
454 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
uint32_t tx
Transmit queue bitmask.
Definition: intelxl.h:459
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxlvf_admin_command(struct net_device *netdev)
Issue admin queue virtual function command.
Definition: intelxlvf.c:190
union intelxl_admin_buffer * intelxl_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition: intelxl.c:307
uint32_t rx
Receive queue bitmask.
Definition: intelxl.h:457
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:453
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTELXL_ADMIN_VF_DISABLE
Admin Queue VF Disable Queues opcode.
Definition: intelxl.h:448
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
Admin queue descriptor.
Definition: intelxl.h:522
struct intelxl_admin_vf_queues_buffer queues
VF Enable/Disable Queues data buffer.
Definition: intelxl.h:512
#define INTELXL_ADMIN_VF_ENABLE
Admin Queue VF Enable Queues opcode.
Definition: intelxl.h:445
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_FL_RD
Admin descriptor uses data buffer for command parameters.
Definition: intelxl.h:554
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
Admin queue data buffer.
Definition: intelxl.h:498

References cmd, cpu_to_le16, cpu_to_le32, intelxl_admin_command_buffer(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXL_ADMIN_VF_DISABLE, INTELXL_ADMIN_VF_ENABLE, intelxlvf_admin_command(), netdev, net_device::priv, intelxl_admin_buffer::queues, rc, intelxl_admin_vf_queues_buffer::rx, intelxl_admin_vf_queues_buffer::tx, intelxl_admin_vf_queues_buffer::vsi, and intelxl_nic::vsi.

Referenced by intelxlvf_close(), and intelxlvf_open().

◆ intelxlvf_admin_promisc()

static int intelxlvf_admin_promisc ( struct net_device netdev)
static

Configure promiscuous mode.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 462 of file intelxlvf.c.

462  {
463  struct intelxl_nic *intelxl = netdev->priv;
465  union intelxl_admin_buffer *buf;
466  int rc;
467 
468  /* Populate descriptor */
472  cmd->len = cpu_to_le16 ( sizeof ( buf->promisc ) );
473  buf = intelxl_admin_command_buffer ( intelxl );
474  buf->promisc.vsi = cpu_to_le16 ( intelxl->vsi );
477 
478  /* Issue command */
479  if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
480  return rc;
481 
482  return 0;
483 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxlvf_admin_command(struct net_device *netdev)
Issue admin queue virtual function command.
Definition: intelxlvf.c:190
union intelxl_admin_buffer * intelxl_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition: intelxl.c:307
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:468
#define INTELXL_ADMIN_VF_PROMISC
Admin Queue VF Configure Promiscuous Mode opcode.
Definition: intelxl.h:463
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_PROMISC_FL_UNICAST
Promiscuous unicast mode.
Definition: intelxl.h:254
#define INTELXL_ADMIN_FL_RD
Admin descriptor uses data buffer for command parameters.
Definition: intelxl.h:554
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define INTELXL_ADMIN_PROMISC_FL_MULTICAST
Promiscuous multicast mode.
Definition: intelxl.h:257
Admin queue data buffer.
Definition: intelxl.h:498
struct intelxl_admin_vf_promisc_buffer promisc
VF Configure Promiscuous Mode data buffer.
Definition: intelxl.h:514

References cmd, cpu_to_le16, cpu_to_le32, intelxl_admin_vf_promisc_buffer::flags, intelxl_admin_command_buffer(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXL_ADMIN_PROMISC_FL_MULTICAST, INTELXL_ADMIN_PROMISC_FL_UNICAST, INTELXL_ADMIN_VF_PROMISC, intelxlvf_admin_command(), netdev, net_device::priv, intelxl_admin_buffer::promisc, rc, intelxl_admin_vf_promisc_buffer::vsi, and intelxl_nic::vsi.

Referenced by intelxlvf_open().

◆ intelxlvf_open()

static int intelxlvf_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 491 of file intelxlvf.c.

491  {
492  struct intelxl_nic *intelxl = netdev->priv;
493  int rc;
494 
495  /* Calculate maximum frame size */
496  intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
497  INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
498 
499  /* Allocate transmit descriptor ring */
500  if ( ( rc = intelxl_alloc_ring ( intelxl, &intelxl->tx ) ) != 0 )
501  goto err_alloc_tx;
502 
503  /* Allocate receive descriptor ring */
504  if ( ( rc = intelxl_alloc_ring ( intelxl, &intelxl->rx ) ) != 0 )
505  goto err_alloc_rx;
506 
507  /* Configure queues */
508  if ( ( rc = intelxlvf_admin_configure ( netdev ) ) != 0 )
509  goto err_configure;
510 
511  /* Configure IRQ map */
512  if ( ( rc = intelxlvf_admin_irq_map ( netdev ) ) != 0 )
513  goto err_irq_map;
514 
515  /* Enable queues */
516  if ( ( rc = intelxlvf_admin_queues ( netdev, 1 ) ) != 0 )
517  goto err_enable;
518 
519  /* Configure promiscuous mode */
520  if ( ( rc = intelxlvf_admin_promisc ( netdev ) ) != 0 )
521  goto err_promisc;
522 
523  return 0;
524 
525  err_promisc:
527  err_enable:
528  err_irq_map:
529  err_configure:
530  intelxl_free_ring ( intelxl, &intelxl->rx );
531  err_alloc_rx:
532  intelxl_free_ring ( intelxl, &intelxl->tx );
533  err_alloc_tx:
534  return rc;
535 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxlvf_admin_configure(struct net_device *netdev)
Configure queues.
Definition: intelxlvf.c:365
static int intelxlvf_admin_irq_map(struct net_device *netdev)
Configure IRQ mapping.
Definition: intelxlvf.c:401
static int intelxlvf_admin_promisc(struct net_device *netdev)
Configure promiscuous mode.
Definition: intelxlvf.c:462
size_t mtu
Maximum transmission unit length.
Definition: netdevice.h:409
#define INTELXL_ALIGN
Alignment.
Definition: intelxl.h:25
size_t mfs
Maximum frame size.
Definition: intelxl.h:1032
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:1070
#define ETH_HLEN
Definition: if_ether.h:9
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
static int intelxlvf_admin_queues(struct net_device *netdev, int enable)
Enable/disable queues.
Definition: intelxlvf.c:432
#define INTELXL_ADMIN_VF_DISABLE
Admin Queue VF Disable Queues opcode.
Definition: intelxl.h:448
void intelxl_free_ring(struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring)
Free descriptor ring.
Definition: intelxl.c:964
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
int intelxl_alloc_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Allocate descriptor ring.
Definition: intelxl.c:923

References ETH_HLEN, INTELXL_ADMIN_VF_DISABLE, INTELXL_ALIGN, intelxl_alloc_ring(), intelxl_free_ring(), intelxlvf_admin_configure(), intelxlvf_admin_irq_map(), intelxlvf_admin_promisc(), intelxlvf_admin_queues(), intelxl_nic::mfs, net_device::mtu, netdev, net_device::priv, rc, intelxl_nic::rx, and intelxl_nic::tx.

◆ intelxlvf_close()

static void intelxlvf_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 542 of file intelxlvf.c.

542  {
543  struct intelxl_nic *intelxl = netdev->priv;
544  int rc;
545 
546  /* Disable queues */
547  if ( ( rc = intelxlvf_admin_queues ( netdev, 0 ) ) != 0 ) {
548  /* Leak memory; there's nothing else we can do */
549  return;
550  }
551 
552  /* Free receive descriptor ring */
553  intelxl_free_ring ( intelxl, &intelxl->rx );
554 
555  /* Free transmit descriptor ring */
556  intelxl_free_ring ( intelxl, &intelxl->tx );
557 
558  /* Discard any unused receive buffers */
559  intelxl_empty_rx ( intelxl );
560 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:1070
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
static int intelxlvf_admin_queues(struct net_device *netdev, int enable)
Enable/disable queues.
Definition: intelxlvf.c:432
void intelxl_free_ring(struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring)
Free descriptor ring.
Definition: intelxl.c:964
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
void intelxl_empty_rx(struct intelxl_nic *intelxl)
Discard unused receive I/O buffers.
Definition: intelxl.c:1337

References intelxl_empty_rx(), intelxl_free_ring(), intelxlvf_admin_queues(), netdev, net_device::priv, rc, intelxl_nic::rx, and intelxl_nic::tx.

◆ intelxlvf_probe()

static int intelxlvf_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 583 of file intelxlvf.c.

583  {
584  struct net_device *netdev;
585  struct intelxl_nic *intelxl;
586  int rc;
587 
588  /* Allocate and initialise net device */
589  netdev = alloc_etherdev ( sizeof ( *intelxl ) );
590  if ( ! netdev ) {
591  rc = -ENOMEM;
592  goto err_alloc;
593  }
595  intelxl = netdev->priv;
596  pci_set_drvdata ( pci, netdev );
597  netdev->dev = &pci->dev;
598  memset ( intelxl, 0, sizeof ( *intelxl ) );
599  intelxl->intr = INTELXLVF_VFINT_DYN_CTL0;
605  sizeof ( intelxl->tx.desc.tx[0] ),
608  sizeof ( intelxl->rx.desc.rx[0] ),
610 
611  /* Fix up PCI device */
612  adjust_pci_device ( pci );
613 
614  /* Map registers */
615  intelxl->regs = ioremap ( pci->membase, INTELXLVF_BAR_SIZE );
616  if ( ! intelxl->regs ) {
617  rc = -ENODEV;
618  goto err_ioremap;
619  }
620 
621  /* Locate PCI Express capability */
622  intelxl->exp = pci_find_capability ( pci, PCI_CAP_ID_EXP );
623  if ( ! intelxl->exp ) {
624  DBGC ( intelxl, "INTELXL %p missing PCIe capability\n",
625  intelxl );
626  rc = -ENXIO;
627  goto err_exp;
628  }
629 
630  /* Reset the function via PCIe FLR */
631  intelxlvf_reset_flr ( intelxl, pci );
632 
633  /* Enable MSI-X dummy interrupt */
634  if ( ( rc = intelxl_msix_enable ( intelxl, pci ) ) != 0 )
635  goto err_msix;
636 
637  /* Open admin queues */
638  if ( ( rc = intelxl_open_admin ( intelxl ) ) != 0 )
639  goto err_open_admin;
640 
641  /* Reset the function via admin queue */
642  if ( ( rc = intelxlvf_reset_admin ( intelxl ) ) != 0 )
643  goto err_reset_admin;
644 
645  /* Get MAC address */
646  if ( ( rc = intelxlvf_admin_get_resources ( netdev ) ) != 0 )
647  goto err_get_resources;
648 
649  /* Register network device */
650  if ( ( rc = register_netdev ( netdev ) ) != 0 )
651  goto err_register_netdev;
652 
653  return 0;
654 
656  err_register_netdev:
657  err_get_resources:
658  err_reset_admin:
659  intelxl_close_admin ( intelxl );
660  err_open_admin:
661  intelxl_msix_disable ( intelxl, pci );
662  err_msix:
663  intelxlvf_reset_flr ( intelxl, pci );
664  err_exp:
665  iounmap ( intelxl->regs );
666  err_ioremap:
668  netdev_put ( netdev );
669  err_alloc:
670  return rc;
671 }
void * regs
Registers.
Definition: intelxl.h:1030
unsigned long membase
Memory base.
Definition: pci.h:194
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition: pciextra.c:36
void intelxl_msix_disable(struct intelxl_nic *intelxl, struct pci_device *pci)
Disable MSI-X dummy interrupt.
Definition: intelxl.c:159
#define DBGC(...)
Definition: compiler.h:505
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
#define INTELXLVF_BAR_SIZE
BAR size.
Definition: intelxlvf.h:15
#define INTELXLVF_VFINT_DYN_CTL0
VF Interrupt Zero Dynamic Control Register.
Definition: intelxlvf.h:24
int intelxl_open_admin(struct intelxl_nic *intelxl)
Open admin queues.
Definition: intelxl.c:833
#define INTELXLVF_ADMIN
VF Admin Queue register block.
Definition: intelxlvf.h:27
union intelxl_tx_descriptor * tx
Transmit descriptors.
Definition: intelxl.h:868
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
struct device dev
Generic device.
Definition: pci.h:189
unsigned int exp
PCI Express capability offset.
Definition: intelxl.h:1053
int intelxl_msix_enable(struct intelxl_nic *intelxl, struct pci_device *pci)
Enable MSI-X dummy interrupt.
Definition: intelxl.c:133
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
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:1070
static void intelxl_init_admin(struct intelxl_admin *admin, unsigned int base, const struct intelxl_admin_offsets *regs)
Initialise admin queue.
Definition: intelxl.h:582
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition: intelxl.h:915
void * priv
Driver private data.
Definition: netdevice.h:425
static int intelxlvf_admin_get_resources(struct net_device *netdev)
Get resources.
Definition: intelxlvf.c:329
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTELXL_RX_NUM_DESC
Number of receive descriptors.
Definition: intelxl.h:924
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
#define INTELXLVF_QTX_TAIL
Transmit Queue Tail Register.
Definition: intelxlvf.h:18
union intelxl_rx_descriptor * rx
Receive descriptors.
Definition: intelxl.h:870
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
union intelxl_ring::@64 desc
Descriptors.
unsigned int intr
Interrupt control register.
Definition: intelxl.h:1047
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
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
static const struct intelxl_admin_offsets intelxlvf_admin_event_offsets
Admin event queue register offsets.
Definition: intelxlvf.c:176
static void intelxlvf_reset_flr(struct intelxl_nic *intelxl, struct pci_device *pci)
Reset hardware via PCIe function-level reset.
Definition: intelxlvf.c:53
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
#define PCI_CAP_ID_EXP
PCI Express.
Definition: pci.h:96
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
static struct net_device_operations intelxlvf_operations
Network device operations.
Definition: intelxlvf.c:563
#define ENXIO
No such device or address.
Definition: errno.h:599
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
static const struct intelxl_admin_offsets intelxlvf_admin_command_offsets
Admin command queue register offsets.
Definition: intelxlvf.c:167
static void intelxlvf_init_ring(struct intelxl_ring *ring, unsigned int count, size_t len, unsigned int tail)
Initialise descriptor ring.
Definition: intelxlvf.h:79
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void intelxl_close_admin(struct intelxl_nic *intelxl)
Close admin queues.
Definition: intelxl.c:895
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058
static int intelxlvf_reset_admin(struct intelxl_nic *intelxl)
Reset hardware via admin queue.
Definition: intelxlvf.c:128
void * memset(void *dest, int character, size_t len) __nonnull
#define INTELXLVF_QRX_TAIL
Receive Queue Tail Register.
Definition: intelxlvf.h:21

References adjust_pci_device(), alloc_etherdev(), intelxl_nic::command, DBGC, intelxl_ring::desc, pci_device::dev, net_device::dev, ENODEV, ENOMEM, ENXIO, intelxl_nic::event, intelxl_nic::exp, intelxl_close_admin(), intelxl_init_admin(), intelxl_msix_disable(), intelxl_msix_enable(), intelxl_open_admin(), INTELXL_RX_NUM_DESC, INTELXL_TX_NUM_DESC, INTELXLVF_ADMIN, intelxlvf_admin_command_offsets, intelxlvf_admin_event_offsets, intelxlvf_admin_get_resources(), INTELXLVF_BAR_SIZE, intelxlvf_init_ring(), intelxlvf_operations, INTELXLVF_QRX_TAIL, INTELXLVF_QTX_TAIL, intelxlvf_reset_admin(), intelxlvf_reset_flr(), INTELXLVF_VFINT_DYN_CTL0, intelxl_nic::intr, ioremap(), iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), PCI_CAP_ID_EXP, pci_find_capability(), pci_set_drvdata(), net_device::priv, rc, register_netdev(), intelxl_nic::regs, intelxl_ring::rx, intelxl_nic::rx, intelxl_ring::tx, intelxl_nic::tx, and unregister_netdev().

◆ intelxlvf_remove()

static void intelxlvf_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 678 of file intelxlvf.c.

678  {
679  struct net_device *netdev = pci_get_drvdata ( pci );
680  struct intelxl_nic *intelxl = netdev->priv;
681 
682  /* Unregister network device */
684 
685  /* Reset the function via admin queue */
686  intelxlvf_reset_admin ( intelxl );
687 
688  /* Close admin queues */
689  intelxl_close_admin ( intelxl );
690 
691  /* Disable MSI-X dummy interrupt */
692  intelxl_msix_disable ( intelxl, pci );
693 
694  /* Reset the function via PCIe FLR */
695  intelxlvf_reset_flr ( intelxl, pci );
696 
697  /* Free network device */
698  iounmap ( intelxl->regs );
700  netdev_put ( netdev );
701 }
void * regs
Registers.
Definition: intelxl.h:1030
void intelxl_msix_disable(struct intelxl_nic *intelxl, struct pci_device *pci)
Disable MSI-X dummy interrupt.
Definition: intelxl.c:159
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
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
static void intelxlvf_reset_flr(struct intelxl_nic *intelxl, struct pci_device *pci)
Reset hardware via PCIe function-level reset.
Definition: intelxlvf.c:53
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:348
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void intelxl_close_admin(struct intelxl_nic *intelxl)
Close admin queues.
Definition: intelxl.c:895
static int intelxlvf_reset_admin(struct intelxl_nic *intelxl)
Reset hardware via admin queue.
Definition: intelxlvf.c:128

References intelxl_close_admin(), intelxl_msix_disable(), intelxlvf_reset_admin(), intelxlvf_reset_flr(), iounmap(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, intelxl_nic::regs, and unregister_netdev().

Variable Documentation

◆ intelxlvf_admin_command_offsets

const struct intelxl_admin_offsets intelxlvf_admin_command_offsets
static
Initial value:
= {
}
#define INTELXLVF_ADMIN_CMD_HEAD
Admin Command Queue Head Register (offset)
Definition: intelxlvf.h:39
#define INTELXLVF_ADMIN_CMD_TAIL
Admin Command Queue Tail Register (offset)
Definition: intelxlvf.h:42
#define INTELXLVF_ADMIN_CMD_LEN
Admin Command Queue Length Register (offset)
Definition: intelxlvf.h:36
#define INTELXLVF_ADMIN_CMD_BAL
Admin Command Queue Base Address Low Register (offset)
Definition: intelxlvf.h:30
#define INTELXLVF_ADMIN_CMD_BAH
Admin Command Queue Base Address High Register (offset)
Definition: intelxlvf.h:33

Admin command queue register offsets.

Definition at line 167 of file intelxlvf.c.

Referenced by intelxlvf_probe().

◆ intelxlvf_admin_event_offsets

const struct intelxl_admin_offsets intelxlvf_admin_event_offsets
static
Initial value:
= {
}
#define INTELXLVF_ADMIN_EVT_LEN
Admin Event Queue Length Register (offset)
Definition: intelxlvf.h:51
#define INTELXLVF_ADMIN_EVT_HEAD
Admin Event Queue Head Register (offset)
Definition: intelxlvf.h:54
#define INTELXLVF_ADMIN_EVT_BAH
Admin Event Queue Base Address High Register (offset)
Definition: intelxlvf.h:48
#define INTELXLVF_ADMIN_EVT_BAL
Admin Event Queue Base Address Low Register (offset)
Definition: intelxlvf.h:45
#define INTELXLVF_ADMIN_EVT_TAIL
Admin Event Queue Tail Register (offset)
Definition: intelxlvf.h:57

Admin event queue register offsets.

Definition at line 176 of file intelxlvf.c.

Referenced by intelxlvf_probe().

◆ intelxlvf_operations

struct net_device_operations intelxlvf_operations
static
Initial value:
= {
.open = intelxlvf_open,
.close = intelxlvf_close,
.transmit = intelxl_transmit,
.poll = intelxl_poll,
}
int intelxl_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: intelxl.c:1465
static void intelxlvf_close(struct net_device *netdev)
Close network device.
Definition: intelxlvf.c:542
static int intelxlvf_open(struct net_device *netdev)
Open network device.
Definition: intelxlvf.c:491
void intelxl_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: intelxl.c:1587

Network device operations.

Definition at line 563 of file intelxlvf.c.

Referenced by intelxlvf_probe().

◆ intelxlvf_nics

struct pci_device_id intelxlvf_nics[]
static
Initial value:
= {
PCI_ROM ( 0x8086, 0x154c, "xl710-vf", "XL710 VF", 0 ),
PCI_ROM ( 0x8086, 0x1571, "xl710-vf-hv", "XL710 VF (Hyper-V)", 0 ),
PCI_ROM ( 0x8086, 0x1889, "xl710-vf-ad", "XL710 VF (adaptive)", 0 ),
PCI_ROM ( 0x8086, 0x37cd, "x722-vf", "X722 VF", 0 ),
PCI_ROM ( 0x8086, 0x37d9, "x722-vf-hv", "X722 VF (Hyper-V)", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

PCI device IDs.

Definition at line 704 of file intelxlvf.c.

◆ __pci_driver

struct pci_driver intelxlvf_driver __pci_driver
Initial value:
= {
.id_count = ( sizeof ( intelxlvf_nics ) /
sizeof ( intelxlvf_nics[0] ) ),
.probe = intelxlvf_probe,
}
static int intelxlvf_probe(struct pci_device *pci)
Probe PCI device.
Definition: intelxlvf.c:583
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static struct pci_device_id intelxlvf_nics[]
PCI device IDs.
Definition: intelxlvf.c:704
static void intelxlvf_remove(struct pci_device *pci)
Remove PCI device.
Definition: intelxlvf.c:678

PCI driver.

Definition at line 713 of file intelxlvf.c.