iPXE
Functions | Variables
intelxl.c File Reference

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

#include <stdint.h>
#include <string.h>
#include <stdio.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/vlan.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/version.h>
#include "intelxl.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int intelxl_reset (struct intelxl_nic *intelxl)
 Reset hardware. More...
 
static int intelxl_fetch_mac (struct intelxl_nic *intelxl, struct net_device *netdev)
 Fetch initial MAC address and maximum frame size. More...
 
int intelxl_msix_enable (struct intelxl_nic *intelxl, struct pci_device *pci)
 Enable MSI-X dummy interrupt. More...
 
void intelxl_msix_disable (struct intelxl_nic *intelxl, struct pci_device *pci)
 Disable MSI-X dummy interrupt. More...
 
static int intelxl_alloc_admin (struct intelxl_nic *intelxl, struct intelxl_admin *admin)
 Allocate admin queue. More...
 
static void intelxl_enable_admin (struct intelxl_nic *intelxl, struct intelxl_admin *admin)
 Enable admin queue. More...
 
static void intelxl_disable_admin (struct intelxl_nic *intelxl, struct intelxl_admin *admin)
 Disable admin queue. More...
 
static void intelxl_free_admin (struct intelxl_nic *intelxl __unused, struct intelxl_admin *admin)
 Free admin queue. More...
 
struct intelxl_admin_descriptorintelxl_admin_command_descriptor (struct intelxl_nic *intelxl)
 Get next admin command queue descriptor. More...
 
union intelxl_admin_bufferintelxl_admin_command_buffer (struct intelxl_nic *intelxl)
 Get next admin command queue data buffer. More...
 
static void intelxl_admin_event_init (struct intelxl_nic *intelxl, unsigned int index)
 Initialise admin event queue descriptor. More...
 
int intelxl_admin_command (struct intelxl_nic *intelxl)
 Issue admin queue command. More...
 
static int intelxl_admin_version (struct intelxl_nic *intelxl)
 Get firmware version. More...
 
static int intelxl_admin_driver (struct intelxl_nic *intelxl)
 Report driver version. More...
 
static int intelxl_admin_shutdown (struct intelxl_nic *intelxl)
 Shutdown admin queues. More...
 
static int intelxl_admin_clear_pxe (struct intelxl_nic *intelxl)
 Clear PXE mode. More...
 
static int intelxl_admin_switch (struct intelxl_nic *intelxl)
 Get switch configuration. More...
 
static int intelxl_admin_vsi (struct intelxl_nic *intelxl)
 Get VSI parameters. More...
 
static int intelxl_admin_promisc (struct intelxl_nic *intelxl)
 Set VSI promiscuous modes. More...
 
static int intelxl_admin_autoneg (struct intelxl_nic *intelxl)
 Restart autonegotiation. More...
 
static int intelxl_admin_link (struct net_device *netdev)
 Get link status. More...
 
__weak void intelxlvf_admin_event (struct net_device *netdev __unused, struct intelxl_admin_descriptor *evt __unused, union intelxl_admin_buffer *buf __unused)
 Handle virtual function event (when VF driver is not present) More...
 
static void intelxl_refill_admin (struct intelxl_nic *intelxl)
 Refill admin event queue. More...
 
void intelxl_poll_admin (struct net_device *netdev)
 Poll admin event queue. More...
 
int intelxl_open_admin (struct intelxl_nic *intelxl)
 Open admin queues. More...
 
void intelxl_reopen_admin (struct intelxl_nic *intelxl)
 Reopen admin queues (after virtual function reset) More...
 
void intelxl_close_admin (struct intelxl_nic *intelxl)
 Close admin queues. More...
 
int intelxl_alloc_ring (struct intelxl_nic *intelxl, struct intelxl_ring *ring)
 Allocate descriptor ring. More...
 
void intelxl_free_ring (struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring)
 Free descriptor ring. More...
 
static void intelxl_context_dump (struct intelxl_nic *intelxl, uint32_t op, size_t len)
 Dump queue context (for debugging) More...
 
static int intelxl_context_line (struct intelxl_nic *intelxl, struct intelxl_context_line *line, unsigned int index, uint32_t op)
 Program queue context line. More...
 
static int intelxl_context (struct intelxl_nic *intelxl, struct intelxl_context_line *line, size_t len, uint32_t op)
 Program queue context. More...
 
static int intelxl_context_tx (struct intelxl_nic *intelxl, physaddr_t address)
 Program transmit queue context. More...
 
static int intelxl_context_rx (struct intelxl_nic *intelxl, physaddr_t address)
 Program receive queue context. More...
 
static int intelxl_enable_ring (struct intelxl_nic *intelxl, struct intelxl_ring *ring)
 Enable descriptor ring. More...
 
static int intelxl_disable_ring (struct intelxl_nic *intelxl, struct intelxl_ring *ring)
 Disable descriptor ring. More...
 
static int intelxl_create_ring (struct intelxl_nic *intelxl, struct intelxl_ring *ring)
 Create descriptor ring. More...
 
static void intelxl_destroy_ring (struct intelxl_nic *intelxl, struct intelxl_ring *ring)
 Destroy descriptor ring. More...
 
static void intelxl_refill_rx (struct intelxl_nic *intelxl)
 Refill receive descriptor ring. More...
 
void intelxl_empty_rx (struct intelxl_nic *intelxl)
 Discard unused receive I/O buffers. More...
 
static int intelxl_open (struct net_device *netdev)
 Open network device. More...
 
static void intelxl_close (struct net_device *netdev)
 Close network device. More...
 
int intelxl_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void intelxl_poll_tx (struct net_device *netdev)
 Poll for completed packets. More...
 
static void intelxl_poll_rx (struct net_device *netdev)
 Poll for received packets. More...
 
void intelxl_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static int intelxl_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void intelxl_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

static const struct intelxl_admin_offsets intelxl_admin_offsets
 Admin queue register offsets. More...
 
static struct net_device_operations intelxl_operations
 Network device operations. More...
 
static struct pci_device_id intelxl_nics []
 PCI device IDs. More...
 
struct pci_driver intelxl_driver __pci_driver
 PCI driver. More...
 

Detailed Description

Intel 40 Gigabit Ethernet network card driver.

Definition in file intelxl.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ intelxl_reset()

static int intelxl_reset ( struct intelxl_nic intelxl)
static

Reset hardware.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 61 of file intelxl.c.

61  {
62  uint32_t pfgen_ctrl;
63 
64  /* Perform a global software reset */
65  pfgen_ctrl = readl ( intelxl->regs + INTELXL_PFGEN_CTRL );
66  writel ( ( pfgen_ctrl | INTELXL_PFGEN_CTRL_PFSWR ),
67  intelxl->regs + INTELXL_PFGEN_CTRL );
69 
70  return 0;
71 }
#define INTELXL_RESET_DELAY_MS
Time to delay for device reset, in milliseconds.
Definition: intelxl.h:993
#define INTELXL_PFGEN_CTRL_PFSWR
Software Reset.
Definition: intelxl.h:990
void * regs
Registers.
Definition: intelxl.h:1030
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define INTELXL_PFGEN_CTRL
PF Control Register.
Definition: intelxl.h:989
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78

References INTELXL_PFGEN_CTRL, INTELXL_PFGEN_CTRL_PFSWR, INTELXL_RESET_DELAY_MS, mdelay(), readl(), intelxl_nic::regs, and writel().

Referenced by intelxl_probe(), and intelxl_remove().

◆ intelxl_fetch_mac()

static int intelxl_fetch_mac ( struct intelxl_nic intelxl,
struct net_device netdev 
)
static

Fetch initial MAC address and maximum frame size.

Parameters
intelxlIntel device
netdevNetwork device
Return values
rcReturn status code

Definition at line 87 of file intelxl.c.

88  {
90  uint32_t prtgl_sal;
91  uint32_t prtgl_sah;
92  size_t mfs;
93 
94  /* Read NVM-loaded address */
95  prtgl_sal = readl ( intelxl->regs + INTELXL_PRTGL_SAL );
96  prtgl_sah = readl ( intelxl->regs + INTELXL_PRTGL_SAH );
97  mac.reg.low = cpu_to_le32 ( prtgl_sal );
98  mac.reg.high = cpu_to_le32 ( prtgl_sah );
99 
100  /* Check that address is valid */
101  if ( ! is_valid_ether_addr ( mac.raw ) ) {
102  DBGC ( intelxl, "INTELXL %p has invalid MAC address (%s)\n",
103  intelxl, eth_ntoa ( mac.raw ) );
104  return -ENOENT;
105  }
106 
107  /* Copy MAC address */
108  DBGC ( intelxl, "INTELXL %p has autoloaded MAC address %s\n",
109  intelxl, eth_ntoa ( mac.raw ) );
110  memcpy ( netdev->hw_addr, mac.raw, ETH_ALEN );
111 
112  /* Get maximum frame size */
113  mfs = INTELXL_PRTGL_SAH_MFS_GET ( prtgl_sah );
114  netdev->max_pkt_len = ( mfs - 4 /* CRC */ );
115 
116  return 0;
117 }
void * regs
Registers.
Definition: intelxl.h:1030
#define INTELXL_PRTGL_SAL
Port MAC Address Low Register.
Definition: intelxl.h:1011
#define INTELXL_PRTGL_SAH
Port MAC Address High Register.
Definition: intelxl.h:1014
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
#define INTELXL_PRTGL_SAH_MFS_GET(x)
Max frame size.
Definition: intelxl.h:1015
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
#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
unsigned int uint32_t
Definition: stdint.h:12
Receive address.
Definition: intelxl.h:1019
static int is_valid_ether_addr(const void *addr)
Check if Ethernet address is valid.
Definition: ethernet.h:77
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:403
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375

References cpu_to_le32, DBGC, ENOENT, ETH_ALEN, eth_ntoa(), net_device::hw_addr, INTELXL_PRTGL_SAH, INTELXL_PRTGL_SAH_MFS_GET, INTELXL_PRTGL_SAL, is_valid_ether_addr(), mac, net_device::max_pkt_len, memcpy(), netdev, readl(), and intelxl_nic::regs.

Referenced by intelxl_probe().

◆ intelxl_msix_enable()

int intelxl_msix_enable ( struct intelxl_nic intelxl,
struct pci_device pci 
)

Enable MSI-X dummy interrupt.

Parameters
intelxlIntel device
pciPCI device
Return values
rcReturn status code

Definition at line 133 of file intelxl.c.

134  {
135  int rc;
136 
137  /* Enable MSI-X capability */
138  if ( ( rc = pci_msix_enable ( pci, &intelxl->msix ) ) != 0 ) {
139  DBGC ( intelxl, "INTELXL %p could not enable MSI-X: %s\n",
140  intelxl, strerror ( rc ) );
141  return rc;
142  }
143 
144  /* Configure interrupt zero to write to dummy location */
145  pci_msix_map ( &intelxl->msix, 0, virt_to_bus ( &intelxl->msg ), 0 );
146 
147  /* Enable dummy interrupt zero */
148  pci_msix_unmask ( &intelxl->msix, 0 );
149 
150  return 0;
151 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
uint32_t msg
MSI-X dummy interrupt target.
Definition: intelxl.h:1051
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static void pci_msix_unmask(struct pci_msix *msix, unsigned int vector)
Unmask MSI-X interrupt vector.
Definition: pcimsix.h:72
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct pci_msix msix
MSI-X capability.
Definition: intelxl.h:1049
int pci_msix_enable(struct pci_device *pci, struct pci_msix *msix)
Enable MSI-X interrupts.
Definition: pcimsix.c:104
void pci_msix_map(struct pci_msix *msix, unsigned int vector, physaddr_t address, uint32_t data)
Map MSI-X interrupt vector.
Definition: pcimsix.c:181

References DBGC, intelxl_nic::msg, intelxl_nic::msix, pci_msix_enable(), pci_msix_map(), pci_msix_unmask(), rc, strerror(), and virt_to_bus().

Referenced by intelxl_probe(), and intelxlvf_probe().

◆ intelxl_msix_disable()

void intelxl_msix_disable ( struct intelxl_nic intelxl,
struct pci_device pci 
)

Disable MSI-X dummy interrupt.

Parameters
intelxlIntel device
pciPCI device

Definition at line 159 of file intelxl.c.

160  {
161 
162  /* Disable dummy interrupt zero */
163  pci_msix_mask ( &intelxl->msix, 0 );
164 
165  /* Disable MSI-X capability */
166  pci_msix_disable ( pci, &intelxl->msix );
167 }
void pci_msix_disable(struct pci_device *pci, struct pci_msix *msix)
Disable MSI-X interrupts.
Definition: pcimsix.c:158
static void pci_msix_mask(struct pci_msix *msix, unsigned int vector)
Mask MSI-X interrupt vector.
Definition: pcimsix.h:60
struct pci_msix msix
MSI-X capability.
Definition: intelxl.h:1049

References intelxl_nic::msix, pci_msix_disable(), and pci_msix_mask().

Referenced by intelxl_probe(), intelxl_remove(), intelxlvf_probe(), and intelxlvf_remove().

◆ intelxl_alloc_admin()

static int intelxl_alloc_admin ( struct intelxl_nic intelxl,
struct intelxl_admin admin 
)
static

Allocate admin queue.

Parameters
intelxlIntel device
adminAdmin queue
Return values
rcReturn status code

Definition at line 192 of file intelxl.c.

193  {
194  size_t buf_len = ( sizeof ( admin->buf[0] ) * INTELXL_ADMIN_NUM_DESC );
195  size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
196 
197  /* Allocate admin queue */
198  admin->buf = malloc_dma ( ( buf_len + len ), INTELXL_ALIGN );
199  if ( ! admin->buf )
200  return -ENOMEM;
201  admin->desc = ( ( ( void * ) admin->buf ) + buf_len );
202 
203  DBGC ( intelxl, "INTELXL %p A%cQ is at [%08llx,%08llx) buf "
204  "[%08llx,%08llx)\n", intelxl,
205  ( ( admin == &intelxl->command ) ? 'T' : 'R' ),
206  ( ( unsigned long long ) virt_to_bus ( admin->desc ) ),
207  ( ( unsigned long long ) ( virt_to_bus ( admin->desc ) + len ) ),
208  ( ( unsigned long long ) virt_to_bus ( admin->buf ) ),
209  ( ( unsigned long long ) ( virt_to_bus ( admin->buf ) +
210  buf_len ) ) );
211  return 0;
212 }
union intelxl_admin_buffer * buf
Data buffers.
Definition: intelxl.h:564
#define DBGC(...)
Definition: compiler.h:505
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
#define INTELXL_ALIGN
Alignment.
Definition: intelxl.h:25
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
#define ENOMEM
Not enough space.
Definition: errno.h:534
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_descriptor * desc
Descriptors.
Definition: intelxl.h:562
uint32_t len
Length.
Definition: ena.h:14
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66

References intelxl_admin::buf, intelxl_nic::command, DBGC, intelxl_admin::desc, ENOMEM, INTELXL_ADMIN_NUM_DESC, INTELXL_ALIGN, len, malloc_dma(), and virt_to_bus().

Referenced by intelxl_open_admin().

◆ intelxl_enable_admin()

static void intelxl_enable_admin ( struct intelxl_nic intelxl,
struct intelxl_admin admin 
)
static

Enable admin queue.

Parameters
intelxlIntel device
adminAdmin queue

Definition at line 220 of file intelxl.c.

221  {
222  size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
223  const struct intelxl_admin_offsets *regs = admin->regs;
224  void *admin_regs = ( intelxl->regs + admin->base );
226 
227  /* Initialise admin queue */
228  memset ( admin->desc, 0, len );
229 
230  /* Reset head and tail registers */
231  writel ( 0, admin_regs + regs->head );
232  writel ( 0, admin_regs + regs->tail );
233 
234  /* Reset queue index */
235  admin->index = 0;
236 
237  /* Program queue address */
238  address = virt_to_bus ( admin->desc );
239  writel ( ( address & 0xffffffffUL ), admin_regs + regs->bal );
240  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
241  writel ( ( ( ( uint64_t ) address ) >> 32 ),
242  admin_regs + regs->bah );
243  } else {
244  writel ( 0, admin_regs + regs->bah );
245  }
246 
247  /* Program queue length and enable queue */
250  admin_regs + regs->len );
251 }
void * regs
Registers.
Definition: intelxl.h:1030
#define INTELXL_ADMIN_LEN_ENABLE
Queue enable.
Definition: intelxl.h:49
Admin queue register offsets.
Definition: intelxl.h:62
uint64_t address
Base address.
Definition: ena.h:24
unsigned long long uint64_t
Definition: stdint.h:13
unsigned int base
Register block base.
Definition: intelxl.h:569
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
unsigned int index
Queue index.
Definition: intelxl.h:566
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:562
unsigned int uint32_t
Definition: stdint.h:12
#define INTELXL_ADMIN_LEN_LEN(x)
Queue length.
Definition: intelxl.h:48
struct i386_regs regs
Definition: registers.h:15
unsigned long physaddr_t
Definition: stdint.h:20
uint32_t len
Length.
Definition: ena.h:14
const struct intelxl_admin_offsets * regs
Register offsets.
Definition: intelxl.h:571
void * memset(void *dest, int character, size_t len) __nonnull

References address, intelxl_admin::base, intelxl_admin::desc, intelxl_admin::index, INTELXL_ADMIN_LEN_ENABLE, INTELXL_ADMIN_LEN_LEN, INTELXL_ADMIN_NUM_DESC, len, memset(), regs, intelxl_admin::regs, intelxl_nic::regs, virt_to_bus(), and writel().

Referenced by intelxl_reopen_admin().

◆ intelxl_disable_admin()

static void intelxl_disable_admin ( struct intelxl_nic intelxl,
struct intelxl_admin admin 
)
static

Disable admin queue.

Parameters
intelxlIntel device
adminAdmin queue

Definition at line 259 of file intelxl.c.

260  {
261  const struct intelxl_admin_offsets *regs = admin->regs;
262  void *admin_regs = ( intelxl->regs + admin->base );
263 
264  /* Disable queue */
265  writel ( 0, admin_regs + regs->len );
266 }
void * regs
Registers.
Definition: intelxl.h:1030
Admin queue register offsets.
Definition: intelxl.h:62
unsigned int base
Register block base.
Definition: intelxl.h:569
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct i386_regs regs
Definition: registers.h:15
const struct intelxl_admin_offsets * regs
Register offsets.
Definition: intelxl.h:571

References intelxl_admin::base, regs, intelxl_admin::regs, intelxl_nic::regs, and writel().

Referenced by intelxl_close_admin(), and intelxl_open_admin().

◆ intelxl_free_admin()

static void intelxl_free_admin ( struct intelxl_nic *intelxl  __unused,
struct intelxl_admin admin 
)
static

Free admin queue.

Parameters
intelxlIntel device
adminAdmin queue

Definition at line 274 of file intelxl.c.

275  {
276  size_t buf_len = ( sizeof ( admin->buf[0] ) * INTELXL_ADMIN_NUM_DESC );
277  size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC );
278 
279  /* Free queue */
280  free_dma ( admin->buf, ( buf_len + len ) );
281 }
union intelxl_admin_buffer * buf
Data buffers.
Definition: intelxl.h:564
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:562
uint32_t len
Length.
Definition: ena.h:14
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81

References intelxl_admin::buf, intelxl_admin::desc, free_dma(), INTELXL_ADMIN_NUM_DESC, and len.

Referenced by intelxl_close_admin(), and intelxl_open_admin().

◆ intelxl_admin_command_descriptor()

struct intelxl_admin_descriptor* intelxl_admin_command_descriptor ( struct intelxl_nic intelxl)

Get next admin command queue descriptor.

Parameters
intelxlIntel device
Return values
cmdCommand descriptor

Definition at line 290 of file intelxl.c.

290  {
291  struct intelxl_admin *admin = &intelxl->command;
293 
294  /* Get and initialise next descriptor */
295  cmd = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
296  memset ( cmd, 0, sizeof ( *cmd ) );
297  return cmd;
298 }
Admin queue.
Definition: intelxl.h:560
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
unsigned int index
Queue index.
Definition: intelxl.h:566
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:562
Admin queue descriptor.
Definition: intelxl.h:522
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
void * memset(void *dest, int character, size_t len) __nonnull

References cmd, intelxl_nic::command, intelxl_admin::desc, intelxl_admin::index, INTELXL_ADMIN_NUM_DESC, and memset().

Referenced by intelxl_admin_autoneg(), intelxl_admin_clear_pxe(), intelxl_admin_driver(), intelxl_admin_link(), intelxl_admin_promisc(), intelxl_admin_shutdown(), intelxl_admin_switch(), intelxl_admin_version(), intelxl_admin_vsi(), intelxlvf_admin_configure(), intelxlvf_admin_get_resources(), intelxlvf_admin_irq_map(), intelxlvf_admin_promisc(), intelxlvf_admin_queues(), and intelxlvf_reset_admin().

◆ intelxl_admin_command_buffer()

union intelxl_admin_buffer* intelxl_admin_command_buffer ( struct intelxl_nic intelxl)

Get next admin command queue data buffer.

Parameters
intelxlIntel device
Return values
bufData buffer

Definition at line 307 of file intelxl.c.

307  {
308  struct intelxl_admin *admin = &intelxl->command;
309  union intelxl_admin_buffer *buf;
310 
311  /* Get next data buffer */
312  buf = &admin->buf[ admin->index % INTELXL_ADMIN_NUM_DESC ];
313  memset ( buf, 0, sizeof ( *buf ) );
314  return buf;
315 }
union intelxl_admin_buffer * buf
Data buffers.
Definition: intelxl.h:564
Admin queue.
Definition: intelxl.h:560
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
unsigned int index
Queue index.
Definition: intelxl.h:566
Admin queue data buffer.
Definition: intelxl.h:498
void * memset(void *dest, int character, size_t len) __nonnull

References intelxl_admin::buf, intelxl_nic::command, intelxl_admin::index, INTELXL_ADMIN_NUM_DESC, and memset().

Referenced by intelxl_admin_driver(), intelxl_admin_switch(), intelxl_admin_vsi(), intelxlvf_admin_configure(), intelxlvf_admin_irq_map(), intelxlvf_admin_promisc(), and intelxlvf_admin_queues().

◆ intelxl_admin_event_init()

static void intelxl_admin_event_init ( struct intelxl_nic intelxl,
unsigned int  index 
)
static

Initialise admin event queue descriptor.

Parameters
intelxlIntel device
indexEvent queue index

Definition at line 323 of file intelxl.c.

324  {
325  struct intelxl_admin *admin = &intelxl->event;
326  struct intelxl_admin_descriptor *evt;
327  union intelxl_admin_buffer *buf;
329 
330  /* Initialise descriptor */
331  evt = &admin->desc[ index % INTELXL_ADMIN_NUM_DESC ];
332  buf = &admin->buf[ index % INTELXL_ADMIN_NUM_DESC ];
333  address = virt_to_bus ( buf );
335  evt->len = cpu_to_le16 ( sizeof ( *buf ) );
336  evt->params.buffer.high = cpu_to_le32 ( address >> 32 );
337  evt->params.buffer.low = cpu_to_le32 ( address & 0xffffffffUL );
338 }
union intelxl_admin_buffer * buf
Data buffers.
Definition: intelxl.h:564
uint64_t address
Base address.
Definition: ena.h:24
Admin queue.
Definition: intelxl.h:560
uint16_t flags
Flags.
Definition: intelxl.h:524
unsigned long long uint64_t
Definition: stdint.h:13
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
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
#define cpu_to_le32(value)
Definition: byteswap.h:107
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:562
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
union intelxl_admin_params params
Parameters.
Definition: intelxl.h:541
uint32_t high
Buffer address high.
Definition: intelxl.h:80
Admin queue descriptor.
Definition: intelxl.h:522
uint32_t low
Buffer address low.
Definition: intelxl.h:82
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct intelxl_admin_buffer_params buffer
Additional data buffer command parameters.
Definition: intelxl.h:476
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058
Admin queue data buffer.
Definition: intelxl.h:498

References address, intelxl_admin::buf, intelxl_admin_params::buffer, cpu_to_le16, cpu_to_le32, intelxl_admin::desc, intelxl_nic::event, intelxl_admin_descriptor::flags, intelxl_admin_buffer_params::high, index, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_NUM_DESC, intelxl_admin_descriptor::len, intelxl_admin_buffer_params::low, intelxl_admin_descriptor::params, and virt_to_bus().

Referenced by intelxl_poll_admin(), and intelxl_reopen_admin().

◆ intelxl_admin_command()

int intelxl_admin_command ( struct intelxl_nic intelxl)

Issue admin queue command.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 346 of file intelxl.c.

346  {
347  struct intelxl_admin *admin = &intelxl->command;
348  const struct intelxl_admin_offsets *regs = admin->regs;
349  void *admin_regs = ( intelxl->regs + admin->base );
351  union intelxl_admin_buffer *buf;
353  uint32_t cookie;
354  unsigned int index;
355  unsigned int tail;
356  unsigned int i;
357  int rc;
358 
359  /* Get next queue entry */
360  index = admin->index++;
361  tail = ( admin->index % INTELXL_ADMIN_NUM_DESC );
362  cmd = &admin->desc[ index % INTELXL_ADMIN_NUM_DESC ];
363  buf = &admin->buf[ index % INTELXL_ADMIN_NUM_DESC ];
364  DBGC2 ( intelxl, "INTELXL %p admin command %#x opcode %#04x",
365  intelxl, index, le16_to_cpu ( cmd->opcode ) );
366  if ( cmd->vopcode )
367  DBGC2 ( intelxl, "/%#08x", le32_to_cpu ( cmd->vopcode ) );
368  DBGC2 ( intelxl, ":\n" );
369 
370  /* Sanity checks */
371  assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_DD ) ) );
372  assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_CMP ) ) );
373  assert ( ! ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_ERR ) ) );
374  assert ( cmd->ret == 0 );
375 
376  /* Populate data buffer address if applicable */
377  if ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
378  address = virt_to_bus ( buf );
379  cmd->params.buffer.high = cpu_to_le32 ( address >> 32 );
380  cmd->params.buffer.low = cpu_to_le32 ( address & 0xffffffffUL );
381  }
382 
383  /* Populate cookie, if not being (ab)used for VF opcode */
384  if ( ! cmd->vopcode )
385  cmd->cookie = cpu_to_le32 ( index );
386 
387  /* Record cookie */
388  cookie = cmd->cookie;
389 
390  /* Post command descriptor */
391  DBGC2_HDA ( intelxl, virt_to_phys ( cmd ), cmd, sizeof ( *cmd ) );
392  if ( cmd->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
393  DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
394  le16_to_cpu ( cmd->len ) );
395  }
396  wmb();
397  writel ( tail, admin_regs + regs->tail );
398 
399  /* Wait for completion */
400  for ( i = 0 ; i < INTELXL_ADMIN_MAX_WAIT_MS ; i++ ) {
401 
402  /* If response is not complete, delay 1ms and retry */
403  if ( ! ( cmd->flags & INTELXL_ADMIN_FL_DD ) ) {
404  mdelay ( 1 );
405  continue;
406  }
407  DBGC2 ( intelxl, "INTELXL %p admin command %#x response:\n",
408  intelxl, index );
409  DBGC2_HDA ( intelxl, virt_to_phys ( cmd ), cmd,
410  sizeof ( *cmd ) );
411 
412  /* Check for cookie mismatch */
413  if ( cmd->cookie != cookie ) {
414  DBGC ( intelxl, "INTELXL %p admin command %#x bad "
415  "cookie %#x\n", intelxl, index,
416  le32_to_cpu ( cmd->cookie ) );
417  rc = -EPROTO;
418  goto err;
419  }
420 
421  /* Check for errors */
422  if ( cmd->ret != 0 ) {
423  DBGC ( intelxl, "INTELXL %p admin command %#x error "
424  "%d\n", intelxl, index,
425  le16_to_cpu ( cmd->ret ) );
426  rc = -EIO;
427  goto err;
428  }
429 
430  /* Success */
431  return 0;
432  }
433 
434  rc = -ETIMEDOUT;
435  DBGC ( intelxl, "INTELXL %p timed out waiting for admin command %#x:\n",
436  intelxl, index );
437  err:
438  DBGC_HDA ( intelxl, virt_to_phys ( cmd ), cmd, sizeof ( *cmd ) );
439  return rc;
440 }
void * regs
Registers.
Definition: intelxl.h:1030
#define INTELXL_ADMIN_FL_ERR
Admin descriptor completed in error.
Definition: intelxl.h:551
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
wmb()
#define le32_to_cpu(value)
Definition: byteswap.h:113
union intelxl_admin_buffer * buf
Data buffers.
Definition: intelxl.h:564
Admin queue register offsets.
Definition: intelxl.h:62
uint64_t address
Base address.
Definition: ena.h:24
Admin queue.
Definition: intelxl.h:560
#define DBGC(...)
Definition: compiler.h:505
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
unsigned long long uint64_t
Definition: stdint.h:13
unsigned int base
Register block base.
Definition: intelxl.h:569
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
#define INTELXL_ADMIN_FL_CMP
Admin descriptor contains a completion.
Definition: intelxl.h:548
unsigned int index
Queue index.
Definition: intelxl.h:566
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define DBGC_HDA(...)
Definition: compiler.h:506
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define cpu_to_le32(value)
Definition: byteswap.h:107
#define EPROTO
Protocol error.
Definition: errno.h:624
#define DBGC2_HDA(...)
Definition: compiler.h:523
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:562
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
#define le16_to_cpu(value)
Definition: byteswap.h:112
unsigned int uint32_t
Definition: stdint.h:12
struct i386_regs regs
Definition: registers.h:15
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
Admin queue descriptor.
Definition: intelxl.h:522
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
#define cpu_to_le16(value)
Definition: byteswap.h:106
const struct intelxl_admin_offsets * regs
Register offsets.
Definition: intelxl.h:571
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define INTELXL_ADMIN_MAX_WAIT_MS
Maximum time to wait for an admin request to complete.
Definition: intelxl.h:593
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
#define INTELXL_ADMIN_FL_DD
Admin descriptor done.
Definition: intelxl.h:545
Admin queue data buffer.
Definition: intelxl.h:498

References address, assert(), intelxl_admin::base, intelxl_admin::buf, cmd, intelxl_nic::command, cpu_to_le16, cpu_to_le32, DBGC, DBGC2, DBGC2_HDA, DBGC_HDA, intelxl_admin::desc, EIO, EPROTO, ETIMEDOUT, index, intelxl_admin::index, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_CMP, INTELXL_ADMIN_FL_DD, INTELXL_ADMIN_FL_ERR, INTELXL_ADMIN_MAX_WAIT_MS, INTELXL_ADMIN_NUM_DESC, le16_to_cpu, le32_to_cpu, mdelay(), rc, regs, intelxl_admin::regs, intelxl_nic::regs, virt_to_bus(), virt_to_phys(), wmb(), and writel().

Referenced by intelxl_admin_autoneg(), intelxl_admin_clear_pxe(), intelxl_admin_driver(), intelxl_admin_link(), intelxl_admin_promisc(), intelxl_admin_shutdown(), intelxl_admin_switch(), intelxl_admin_version(), intelxl_admin_vsi(), intelxlvf_admin_command(), and intelxlvf_reset_admin().

◆ intelxl_admin_version()

static int intelxl_admin_version ( struct intelxl_nic intelxl)
static

Get firmware version.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 448 of file intelxl.c.

448  {
451  unsigned int api;
452  int rc;
453 
454  /* Populate descriptor */
456  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_VERSION );
457  version = &cmd->params.version;
458 
459  /* Issue command */
460  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
461  return rc;
462  api = le16_to_cpu ( version->api.major );
463  DBGC ( intelxl, "INTELXL %p firmware v%d.%d API v%d.%d\n",
464  intelxl, le16_to_cpu ( version->firmware.major ),
465  le16_to_cpu ( version->firmware.minor ),
466  api, le16_to_cpu ( version->api.minor ) );
467 
468  /* Check for API compatibility */
469  if ( api > INTELXL_ADMIN_API_MAJOR ) {
470  DBGC ( intelxl, "INTELXL %p unsupported API v%d\n",
471  intelxl, api );
472  return -ENOTSUP;
473  }
474 
475  return 0;
476 }
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
#define DBGC(...)
Definition: compiler.h:505
struct intelxl_admin_version api
API version.
Definition: intelxl.h:105
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
u32 version
Version number.
Definition: ath9k_hw.c:1983
#define INTELXL_ADMIN_VERSION
Admin queue Get Version command.
Definition: intelxl.h:86
#define INTELXL_ADMIN_API_MAJOR
Admin queue API major version.
Definition: intelxl.h:596
Admin queue Get Version command parameters.
Definition: intelxl.h:97
#define le16_to_cpu(value)
Definition: byteswap.h:112
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References intelxl_admin_version_params::api, cmd, cpu_to_le16, DBGC, ENOTSUP, INTELXL_ADMIN_API_MAJOR, intelxl_admin_command(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_VERSION, le16_to_cpu, rc, and version.

◆ intelxl_admin_driver()

static int intelxl_admin_driver ( struct intelxl_nic intelxl)
static

Report driver version.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 484 of file intelxl.c.

484  {
486  struct intelxl_admin_driver_params *driver;
487  union intelxl_admin_buffer *buf;
488  int rc;
489 
490  /* Populate descriptor */
492  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_DRIVER );
494  cmd->len = cpu_to_le16 ( sizeof ( buf->driver ) );
495  driver = &cmd->params.driver;
496  driver->major = product_major_version;
497  driver->minor = product_minor_version;
498  buf = intelxl_admin_command_buffer ( intelxl );
499  snprintf ( buf->driver.name, sizeof ( buf->driver.name ), "%s",
501 
502  /* Issue command */
503  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
504  return rc;
505 
506  return 0;
507 }
const char product_short_name[]
Product short name string.
Definition: version.c:75
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
char name[32]
Driver name.
Definition: intelxl.h:130
union intelxl_admin_buffer * intelxl_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition: intelxl.c:307
struct intelxl_admin_driver_buffer driver
Driver Version data buffer.
Definition: intelxl.h:500
Admin queue Driver Version command parameters.
Definition: intelxl.h:112
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
const int product_major_version
Product major version.
Definition: version.c:63
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
const char product_name[]
Product name string.
Definition: version.c:72
#define INTELXL_ADMIN_DRIVER
Admin queue Driver Version command.
Definition: intelxl.h:109
#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
const int product_minor_version
Product minor version.
Definition: version.c:66
Admin queue data buffer.
Definition: intelxl.h:498

References cmd, cpu_to_le16, intelxl_admin_buffer::driver, intelxl_admin_command(), intelxl_admin_command_buffer(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_DRIVER, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, intelxl_admin_driver_buffer::name, product_major_version, product_minor_version, product_name, product_short_name, rc, and snprintf().

Referenced by intelxl_open_admin().

◆ intelxl_admin_shutdown()

static int intelxl_admin_shutdown ( struct intelxl_nic intelxl)
static

Shutdown admin queues.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 515 of file intelxl.c.

515  {
518  int rc;
519 
520  /* Populate descriptor */
522  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SHUTDOWN );
523  shutdown = &cmd->params.shutdown;
525 
526  /* Issue command */
527  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
528  return rc;
529 
530  return 0;
531 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
#define INTELXL_ADMIN_SHUTDOWN
Admin queue Shutdown command.
Definition: intelxl.h:134
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Admin queue Shutdown command parameters.
Definition: intelxl.h:137
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_SHUTDOWN_UNLOADING
Driver is unloading.
Definition: intelxl.h:145
void shutdown(int flags)
Shut down iPXE.
Definition: init.c:98
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_le16, intelxl_admin_command(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_SHUTDOWN, INTELXL_ADMIN_SHUTDOWN_UNLOADING, rc, and shutdown().

Referenced by intelxl_close_admin().

◆ intelxl_admin_clear_pxe()

static int intelxl_admin_clear_pxe ( struct intelxl_nic intelxl)
static

Clear PXE mode.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 539 of file intelxl.c.

539  {
541  struct intelxl_admin_clear_pxe_params *pxe;
542  uint32_t gllan_rctl_0;
543  int rc;
544 
545  /* Do nothing if device is already out of PXE mode */
546  gllan_rctl_0 = readl ( intelxl->regs + INTELXL_GLLAN_RCTL_0 );
547  if ( ! ( gllan_rctl_0 & INTELXL_GLLAN_RCTL_0_PXE_MODE ) ) {
548  DBGC2 ( intelxl, "INTELXL %p already in non-PXE mode\n",
549  intelxl );
550  return 0;
551  }
552 
553  /* Populate descriptor */
556  pxe = &cmd->params.pxe;
558 
559  /* Issue command */
560  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
561  return rc;
562 
563  return 0;
564 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
void * regs
Registers.
Definition: intelxl.h:1030
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTELXL_GLLAN_RCTL_0
Global RLAN Control 0 register.
Definition: intelxl.h:761
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
Admin queue Clear PXE Mode command parameters.
Definition: intelxl.h:151
#define INTELXL_ADMIN_CLEAR_PXE_MAGIC
Clear PXE Mode magic value.
Definition: intelxl.h:159
uint8_t magic
Magic value.
Definition: intelxl.h:153
unsigned int uint32_t
Definition: stdint.h:12
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
#define INTELXL_GLLAN_RCTL_0_PXE_MODE
PXE mode.
Definition: intelxl.h:762
Admin queue descriptor.
Definition: intelxl.h:522
#define DBGC2(...)
Definition: compiler.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_CLEAR_PXE
Admin queue Clear PXE Mode command.
Definition: intelxl.h:148
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_le16, DBGC2, INTELXL_ADMIN_CLEAR_PXE, INTELXL_ADMIN_CLEAR_PXE_MAGIC, intelxl_admin_command(), intelxl_admin_command_descriptor(), INTELXL_GLLAN_RCTL_0, INTELXL_GLLAN_RCTL_0_PXE_MODE, intelxl_admin_clear_pxe_params::magic, rc, readl(), and intelxl_nic::regs.

Referenced by intelxl_probe().

◆ intelxl_admin_switch()

static int intelxl_admin_switch ( struct intelxl_nic intelxl)
static

Get switch configuration.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 572 of file intelxl.c.

572  {
574  struct intelxl_admin_switch_params *sw;
575  union intelxl_admin_buffer *buf;
576  int rc;
577 
578  /* Populate descriptor */
580  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SWITCH );
581  cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
582  cmd->len = cpu_to_le16 ( sizeof ( buf->sw ) );
583  sw = &cmd->params.sw;
584  buf = intelxl_admin_command_buffer ( intelxl );
585 
586  /* Get each configuration in turn */
587  do {
588  /* Issue command */
589  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
590  return rc;
591 
592  /* Dump raw configuration */
593  DBGC2 ( intelxl, "INTELXL %p SEID %#04x:\n",
594  intelxl, le16_to_cpu ( buf->sw.cfg.seid ) );
595  DBGC2_HDA ( intelxl, 0, &buf->sw.cfg, sizeof ( buf->sw.cfg ) );
596 
597  /* Parse response */
598  if ( buf->sw.cfg.type == INTELXL_ADMIN_SWITCH_TYPE_VSI ) {
599  intelxl->vsi = le16_to_cpu ( buf->sw.cfg.seid );
600  DBGC ( intelxl, "INTELXL %p VSI %#04x uplink %#04x "
601  "downlink %#04x conn %#02x\n", intelxl,
602  intelxl->vsi, le16_to_cpu ( buf->sw.cfg.uplink ),
603  le16_to_cpu ( buf->sw.cfg.downlink ),
604  buf->sw.cfg.connection );
605  }
606 
607  } while ( sw->next );
608 
609  /* Check that we found a VSI */
610  if ( ! intelxl->vsi ) {
611  DBGC ( intelxl, "INTELXL %p has no VSI\n", intelxl );
612  return -ENOENT;
613  }
614 
615  return 0;
616 }
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
#define INTELXL_ADMIN_SWITCH
Admin queue Get Switch Configuration command.
Definition: intelxl.h:162
uint8_t type
Switching element type.
Definition: intelxl.h:167
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
union intelxl_admin_buffer * intelxl_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition: intelxl.c:307
struct intelxl_admin_switch_buffer sw
Get Switch Configuration data buffer.
Definition: intelxl.h:502
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
uint16_t downlink
Downlink switching element ID.
Definition: intelxl.h:175
#define DBGC2_HDA(...)
Definition: compiler.h:523
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
uint8_t connection
Connection type.
Definition: intelxl.h:179
#define le16_to_cpu(value)
Definition: byteswap.h:112
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
Admin queue descriptor.
Definition: intelxl.h:522
uint16_t uplink
Uplink switching element ID.
Definition: intelxl.h:173
#define DBGC2(...)
Definition: compiler.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct intelxl_admin_switch_config cfg
Switch configuration.
Definition: intelxl.h:208
Admin queue Get Switch Configuration command parameters.
Definition: intelxl.h:190
#define INTELXL_ADMIN_SWITCH_TYPE_VSI
Virtual Station Inferface element type.
Definition: intelxl.h:187
uint16_t seid
Switching element ID.
Definition: intelxl.h:171
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
Admin queue data buffer.
Definition: intelxl.h:498

References intelxl_admin_switch_buffer::cfg, cmd, intelxl_admin_switch_config::connection, cpu_to_le16, DBGC, DBGC2, DBGC2_HDA, intelxl_admin_switch_config::downlink, ENOENT, intelxl_admin_command(), intelxl_admin_command_buffer(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_SWITCH, INTELXL_ADMIN_SWITCH_TYPE_VSI, le16_to_cpu, rc, intelxl_admin_switch_config::seid, intelxl_admin_buffer::sw, intelxl_admin_switch_config::type, intelxl_admin_switch_config::uplink, and intelxl_nic::vsi.

Referenced by intelxl_probe().

◆ intelxl_admin_vsi()

static int intelxl_admin_vsi ( struct intelxl_nic intelxl)
static

Get VSI parameters.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 624 of file intelxl.c.

624  {
627  union intelxl_admin_buffer *buf;
628  int rc;
629 
630  /* Populate descriptor */
632  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_VSI );
633  cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_BUF );
634  cmd->len = cpu_to_le16 ( sizeof ( buf->vsi ) );
635  vsi = &cmd->params.vsi;
636  vsi->vsi = cpu_to_le16 ( intelxl->vsi );
637  buf = intelxl_admin_command_buffer ( intelxl );
638 
639  /* Issue command */
640  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
641  return rc;
642 
643  /* Parse response */
644  intelxl->queue = le16_to_cpu ( buf->vsi.queue[0] );
645  intelxl->qset = le16_to_cpu ( buf->vsi.qset[0] );
646  DBGC ( intelxl, "INTELXL %p VSI %#04x queue %#04x qset %#04x\n",
647  intelxl, intelxl->vsi, intelxl->queue, intelxl->qset );
648 
649  return 0;
650 }
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
uint16_t queue[16]
Queue numbers.
Definition: intelxl.h:229
uint16_t qset[8]
Queue set handles for each traffic class.
Definition: intelxl.h:233
struct intelxl_admin_vsi_buffer vsi
Get VSI Parameters data buffer.
Definition: intelxl.h:504
Admin queue Get VSI Parameters command parameters.
Definition: intelxl.h:215
unsigned int qset
Queue set handle.
Definition: intelxl.h:1045
#define DBGC(...)
Definition: compiler.h:505
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_VSI
Admin queue Get VSI Parameters command.
Definition: intelxl.h:212
unsigned int queue
Queue number.
Definition: intelxl.h:1041
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:217
#define le16_to_cpu(value)
Definition: byteswap.h:112
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
Admin queue data buffer.
Definition: intelxl.h:498

References cmd, cpu_to_le16, DBGC, intelxl_admin_command(), intelxl_admin_command_buffer(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_VSI, le16_to_cpu, intelxl_admin_vsi_buffer::qset, intelxl_nic::qset, intelxl_admin_vsi_buffer::queue, intelxl_nic::queue, rc, intelxl_admin_vsi_params::vsi, intelxl_admin_buffer::vsi, and intelxl_nic::vsi.

Referenced by intelxl_probe().

◆ intelxl_admin_promisc()

static int intelxl_admin_promisc ( struct intelxl_nic intelxl)
static

Set VSI promiscuous modes.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 658 of file intelxl.c.

658  {
660  struct intelxl_admin_promisc_params *promisc;
661  uint16_t flags;
662  int rc;
663 
664  /* Populate descriptor */
666  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_PROMISC );
671  promisc = &cmd->params.promisc;
672  promisc->flags = cpu_to_le16 ( flags );
673  promisc->valid = cpu_to_le16 ( flags );
674  promisc->vsi = cpu_to_le16 ( intelxl->vsi );
675 
676  /* Issue command */
677  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
678  return rc;
679 
680  return 0;
681 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
#define INTELXL_ADMIN_PROMISC_FL_VLAN
Promiscuous VLAN mode.
Definition: intelxl.h:263
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
#define INTELXL_ADMIN_PROMISC
Admin queue Set VSI Promiscuous Modes command.
Definition: intelxl.h:239
unsigned int vsi
Virtual Station Interface switching element ID.
Definition: intelxl.h:1043
uint16_t flags
Flags.
Definition: intelxl.h:244
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
uint16_t vsi
VSI switching element ID.
Definition: intelxl.h:248
Admin queue Set VSI Promiscuous Modes command parameters.
Definition: intelxl.h:242
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_PROMISC_FL_BROADCAST
Promiscuous broadcast mode.
Definition: intelxl.h:260
uint16_t valid
Valid flags.
Definition: intelxl.h:246
#define INTELXL_ADMIN_PROMISC_FL_UNICAST
Promiscuous unicast mode.
Definition: intelxl.h:254
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define INTELXL_ADMIN_PROMISC_FL_MULTICAST
Promiscuous multicast mode.
Definition: intelxl.h:257
uint8_t flags
Flags.
Definition: ena.h:18

References cmd, cpu_to_le16, flags, intelxl_admin_promisc_params::flags, intelxl_admin_command(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_PROMISC, INTELXL_ADMIN_PROMISC_FL_BROADCAST, INTELXL_ADMIN_PROMISC_FL_MULTICAST, INTELXL_ADMIN_PROMISC_FL_UNICAST, INTELXL_ADMIN_PROMISC_FL_VLAN, rc, intelxl_admin_promisc_params::valid, intelxl_admin_promisc_params::vsi, and intelxl_nic::vsi.

Referenced by intelxl_probe().

◆ intelxl_admin_autoneg()

static int intelxl_admin_autoneg ( struct intelxl_nic intelxl)
static

Restart autonegotiation.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 689 of file intelxl.c.

689  {
691  struct intelxl_admin_autoneg_params *autoneg;
692  int rc;
693 
694  /* Populate descriptor */
696  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_AUTONEG );
697  autoneg = &cmd->params.autoneg;
700 
701  /* Issue command */
702  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
703  return rc;
704 
705  return 0;
706 }
struct intelxl_admin_descriptor * intelxl_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition: intelxl.c:290
#define INTELXL_ADMIN_AUTONEG_FL_RESTART
Restart autonegotiation.
Definition: intelxl.h:277
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTELXL_ADMIN_AUTONEG
Admin queue Restart Autonegotiation command.
Definition: intelxl.h:266
Admin queue Restart Autonegotiation command parameters.
Definition: intelxl.h:269
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
Admin queue descriptor.
Definition: intelxl.h:522
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_ADMIN_AUTONEG_FL_ENABLE
Enable link.
Definition: intelxl.h:280
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_le16, intelxl_admin_autoneg_params::flags, INTELXL_ADMIN_AUTONEG, INTELXL_ADMIN_AUTONEG_FL_ENABLE, INTELXL_ADMIN_AUTONEG_FL_RESTART, intelxl_admin_command(), intelxl_admin_command_descriptor(), and rc.

Referenced by intelxl_open().

◆ intelxl_admin_link()

static int intelxl_admin_link ( struct net_device netdev)
static

Get link status.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 714 of file intelxl.c.

714  {
715  struct intelxl_nic *intelxl = netdev->priv;
718  int rc;
719 
720  /* Populate descriptor */
722  cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_LINK );
723  link = &cmd->params.link;
725 
726  /* Issue command */
727  if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
728  return rc;
729  DBGC ( intelxl, "INTELXL %p PHY %#02x speed %#02x status %#02x\n",
730  intelxl, link->phy, link->speed, link->status );
731 
732  /* Update network device */
733  if ( link->status & INTELXL_ADMIN_LINK_UP ) {
735  } else {
737  }
738 
739  return 0;
740 }
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
#define INTELXL_ADMIN_LINK
Admin queue Get Link Status command.
Definition: intelxl.h:283
#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
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition: intelxl.c:346
Admin queue descriptor.
Definition: intelxl.h:522
#define INTELXL_ADMIN_LINK_UP
Link is up.
Definition: intelxl.h:305
#define INTELXL_ADMIN_LINK_NOTIFY
Notify driver of link status changes.
Definition: intelxl.h:302
#define cpu_to_le16(value)
Definition: byteswap.h:106
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_le16, DBGC, intelxl_admin_command(), intelxl_admin_command_descriptor(), INTELXL_ADMIN_LINK, INTELXL_ADMIN_LINK_NOTIFY, INTELXL_ADMIN_LINK_UP, link, netdev, netdev_link_down(), netdev_link_up(), net_device::priv, and rc.

Referenced by intelxl_open(), intelxl_poll_admin(), and intelxl_probe().

◆ intelxlvf_admin_event()

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

Handle virtual function event (when VF driver is not present)

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

Definition at line 750 of file intelxl.c.

752  {
753 
754  /* Nothing to do */
755 }

Referenced by intelxl_poll_admin().

◆ intelxl_refill_admin()

static void intelxl_refill_admin ( struct intelxl_nic intelxl)
static

Refill admin event queue.

Parameters
intelxlIntel device

Definition at line 762 of file intelxl.c.

762  {
763  struct intelxl_admin *admin = &intelxl->event;
764  const struct intelxl_admin_offsets *regs = admin->regs;
765  void *admin_regs = ( intelxl->regs + admin->base );
766  unsigned int tail;
767 
768  /* Update tail pointer */
769  tail = ( ( admin->index + INTELXL_ADMIN_NUM_DESC - 1 ) %
771  wmb();
772  writel ( tail, admin_regs + regs->tail );
773 }
void * regs
Registers.
Definition: intelxl.h:1030
wmb()
Admin queue register offsets.
Definition: intelxl.h:62
Admin queue.
Definition: intelxl.h:560
unsigned int base
Register block base.
Definition: intelxl.h:569
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
unsigned int index
Queue index.
Definition: intelxl.h:566
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct i386_regs regs
Definition: registers.h:15
unsigned int tail
Tail Register offset.
Definition: intelxl.h:72
const struct intelxl_admin_offsets * regs
Register offsets.
Definition: intelxl.h:571
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058

References intelxl_admin::base, intelxl_nic::event, intelxl_admin::index, INTELXL_ADMIN_NUM_DESC, regs, intelxl_admin::regs, intelxl_nic::regs, intelxl_admin_offsets::tail, wmb(), and writel().

Referenced by intelxl_poll_admin(), and intelxl_reopen_admin().

◆ intelxl_poll_admin()

void intelxl_poll_admin ( struct net_device netdev)

Poll admin event queue.

Parameters
netdevNetwork device

Definition at line 780 of file intelxl.c.

780  {
781  struct intelxl_nic *intelxl = netdev->priv;
782  struct intelxl_admin *admin = &intelxl->event;
783  struct intelxl_admin_descriptor *evt;
784  union intelxl_admin_buffer *buf;
785 
786  /* Check for events */
787  while ( 1 ) {
788 
789  /* Get next event descriptor and data buffer */
790  evt = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
791  buf = &admin->buf[ admin->index % INTELXL_ADMIN_NUM_DESC ];
792 
793  /* Stop if descriptor is not yet completed */
794  if ( ! ( evt->flags & INTELXL_ADMIN_FL_DD ) )
795  return;
796  DBGC2 ( intelxl, "INTELXL %p admin event %#x:\n",
797  intelxl, admin->index );
798  DBGC2_HDA ( intelxl, virt_to_phys ( evt ), evt,
799  sizeof ( *evt ) );
800  if ( evt->flags & cpu_to_le16 ( INTELXL_ADMIN_FL_BUF ) ) {
801  DBGC2_HDA ( intelxl, virt_to_phys ( buf ), buf,
802  le16_to_cpu ( evt->len ) );
803  }
804 
805  /* Handle event */
806  switch ( evt->opcode ) {
809  break;
811  intelxlvf_admin_event ( netdev, evt, buf );
812  break;
813  default:
814  DBGC ( intelxl, "INTELXL %p admin event %#x "
815  "unrecognised opcode %#04x\n", intelxl,
816  admin->index, le16_to_cpu ( evt->opcode ) );
817  break;
818  }
819 
820  /* Reset descriptor and refill queue */
821  intelxl_admin_event_init ( intelxl, admin->index );
822  admin->index++;
823  intelxl_refill_admin ( intelxl );
824  }
825 }
#define INTELXL_ADMIN_LINK
Admin queue Get Link Status command.
Definition: intelxl.h:283
union intelxl_admin_buffer * buf
Data buffers.
Definition: intelxl.h:564
uint16_t opcode
Opcode.
Definition: intelxl.h:526
Admin queue.
Definition: intelxl.h:560
#define DBGC(...)
Definition: compiler.h:505
uint16_t flags
Flags.
Definition: intelxl.h:524
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
uint16_t len
Data length.
Definition: intelxl.h:528
unsigned int index
Queue index.
Definition: intelxl.h:566
static void intelxl_admin_event_init(struct intelxl_nic *intelxl, unsigned int index)
Initialise admin event queue descriptor.
Definition: intelxl.c:323
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
static void intelxl_refill_admin(struct intelxl_nic *intelxl)
Refill admin event queue.
Definition: intelxl.c:762
#define DBGC2_HDA(...)
Definition: compiler.h:523
struct intelxl_admin_descriptor * desc
Descriptors.
Definition: intelxl.h:562
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition: intelxl.h:557
#define INTELXL_ADMIN_SEND_TO_VF
Admin queue Send Message to VF command.
Definition: intelxl.h:311
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
#define le16_to_cpu(value)
Definition: byteswap.h:112
Admin queue descriptor.
Definition: intelxl.h:522
#define DBGC2(...)
Definition: compiler.h:522
__weak void intelxlvf_admin_event(struct net_device *netdev __unused, struct intelxl_admin_descriptor *evt __unused, union intelxl_admin_buffer *buf __unused)
Handle virtual function event (when VF driver is not present)
Definition: intelxl.c:750
#define cpu_to_le16(value)
Definition: byteswap.h:106
static int intelxl_admin_link(struct net_device *netdev)
Get link status.
Definition: intelxl.c:714
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058
#define INTELXL_ADMIN_FL_DD
Admin descriptor done.
Definition: intelxl.h:545
Admin queue data buffer.
Definition: intelxl.h:498

References intelxl_admin::buf, cpu_to_le16, DBGC, DBGC2, DBGC2_HDA, intelxl_admin::desc, intelxl_nic::event, intelxl_admin_descriptor::flags, intelxl_admin::index, intelxl_admin_event_init(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_DD, INTELXL_ADMIN_LINK, intelxl_admin_link(), INTELXL_ADMIN_NUM_DESC, INTELXL_ADMIN_SEND_TO_VF, intelxl_refill_admin(), intelxlvf_admin_event(), le16_to_cpu, intelxl_admin_descriptor::len, netdev, intelxl_admin_descriptor::opcode, net_device::priv, and virt_to_phys().

Referenced by intelxl_poll(), and intelxlvf_admin_command().

◆ intelxl_open_admin()

int intelxl_open_admin ( struct intelxl_nic intelxl)

Open admin queues.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 833 of file intelxl.c.

833  {
834  int rc;
835 
836  /* Allocate admin event queue */
837  if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->event ) ) != 0 )
838  goto err_alloc_event;
839 
840  /* Allocate admin command queue */
841  if ( ( rc = intelxl_alloc_admin ( intelxl, &intelxl->command ) ) != 0 )
842  goto err_alloc_command;
843 
844  /* (Re)open admin queues */
845  intelxl_reopen_admin ( intelxl );
846 
847  /* Get firmware version */
848  if ( ( rc = intelxl_admin_version ( intelxl ) ) != 0 )
849  goto err_version;
850 
851  /* Report driver version */
852  if ( ( rc = intelxl_admin_driver ( intelxl ) ) != 0 )
853  goto err_driver;
854 
855  return 0;
856 
857  err_driver:
858  err_version:
859  intelxl_disable_admin ( intelxl, &intelxl->command );
860  intelxl_disable_admin ( intelxl, &intelxl->event );
861  intelxl_free_admin ( intelxl, &intelxl->command );
862  err_alloc_command:
863  intelxl_free_admin ( intelxl, &intelxl->event );
864  err_alloc_event:
865  return rc;
866 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
Admin queue version number.
Definition: intelxl.h:89
static int intelxl_alloc_admin(struct intelxl_nic *intelxl, struct intelxl_admin *admin)
Allocate admin queue.
Definition: intelxl.c:192
static void intelxl_free_admin(struct intelxl_nic *intelxl __unused, struct intelxl_admin *admin)
Free admin queue.
Definition: intelxl.c:274
static void intelxl_disable_admin(struct intelxl_nic *intelxl, struct intelxl_admin *admin)
Disable admin queue.
Definition: intelxl.c:259
void intelxl_reopen_admin(struct intelxl_nic *intelxl)
Reopen admin queues (after virtual function reset)
Definition: intelxl.c:873
static int intelxl_admin_driver(struct intelxl_nic *intelxl)
Report driver version.
Definition: intelxl.c:484
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058

References intelxl_nic::command, intelxl_nic::event, intelxl_admin_driver(), intelxl_alloc_admin(), intelxl_disable_admin(), intelxl_free_admin(), intelxl_reopen_admin(), and rc.

Referenced by intelxl_probe(), and intelxlvf_probe().

◆ intelxl_reopen_admin()

void intelxl_reopen_admin ( struct intelxl_nic intelxl)

Reopen admin queues (after virtual function reset)

Parameters
intelxlIntel device

Definition at line 873 of file intelxl.c.

873  {
874  unsigned int i;
875 
876  /* Enable admin event queue */
877  intelxl_enable_admin ( intelxl, &intelxl->event );
878 
879  /* Enable admin command queue */
880  intelxl_enable_admin ( intelxl, &intelxl->command );
881 
882  /* Initialise all admin event queue descriptors */
883  for ( i = 0 ; i < INTELXL_ADMIN_NUM_DESC ; i++ )
884  intelxl_admin_event_init ( intelxl, i );
885 
886  /* Post all descriptors to event queue */
887  intelxl_refill_admin ( intelxl );
888 }
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
static void intelxl_enable_admin(struct intelxl_nic *intelxl, struct intelxl_admin *admin)
Enable admin queue.
Definition: intelxl.c:220
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition: intelxl.h:590
static void intelxl_admin_event_init(struct intelxl_nic *intelxl, unsigned int index)
Initialise admin event queue descriptor.
Definition: intelxl.c:323
static void intelxl_refill_admin(struct intelxl_nic *intelxl)
Refill admin event queue.
Definition: intelxl.c:762
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058

References intelxl_nic::command, intelxl_nic::event, intelxl_admin_event_init(), INTELXL_ADMIN_NUM_DESC, intelxl_enable_admin(), and intelxl_refill_admin().

Referenced by intelxl_open_admin(), and intelxlvf_reset_admin().

◆ intelxl_close_admin()

void intelxl_close_admin ( struct intelxl_nic intelxl)

Close admin queues.

Parameters
intelxlIntel device

Definition at line 895 of file intelxl.c.

895  {
896 
897  /* Shut down admin queues */
898  intelxl_admin_shutdown ( intelxl );
899 
900  /* Disable admin queues */
901  intelxl_disable_admin ( intelxl, &intelxl->command );
902  intelxl_disable_admin ( intelxl, &intelxl->event );
903 
904  /* Free admin queues */
905  intelxl_free_admin ( intelxl, &intelxl->command );
906  intelxl_free_admin ( intelxl, &intelxl->event );
907 }
static int intelxl_admin_shutdown(struct intelxl_nic *intelxl)
Shutdown admin queues.
Definition: intelxl.c:515
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
static void intelxl_free_admin(struct intelxl_nic *intelxl __unused, struct intelxl_admin *admin)
Free admin queue.
Definition: intelxl.c:274
static void intelxl_disable_admin(struct intelxl_nic *intelxl, struct intelxl_admin *admin)
Disable admin queue.
Definition: intelxl.c:259
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058

References intelxl_nic::command, intelxl_nic::event, intelxl_admin_shutdown(), intelxl_disable_admin(), and intelxl_free_admin().

Referenced by intelxl_probe(), intelxl_remove(), intelxlvf_probe(), and intelxlvf_remove().

◆ intelxl_alloc_ring()

int intelxl_alloc_ring ( struct intelxl_nic intelxl,
struct intelxl_ring ring 
)

Allocate descriptor ring.

Parameters
intelxlIntel device
ringDescriptor ring
Return values
rcReturn status code

Definition at line 923 of file intelxl.c.

924  {
926  int rc;
927 
928  /* Allocate descriptor ring */
929  ring->desc.raw = malloc_dma ( ring->len, INTELXL_ALIGN );
930  if ( ! ring->desc.raw ) {
931  rc = -ENOMEM;
932  goto err_alloc;
933  }
934  address = virt_to_bus ( ring->desc.raw );
935 
936  /* Initialise descriptor ring */
937  memset ( ring->desc.raw, 0, ring->len );
938 
939  /* Reset tail pointer */
940  writel ( 0, ( intelxl->regs + ring->tail ) );
941 
942  /* Reset counters */
943  ring->prod = 0;
944  ring->cons = 0;
945 
946  DBGC ( intelxl, "INTELXL %p ring %06x is at [%08llx,%08llx)\n",
947  intelxl, ( ring->reg + ring->tail ),
948  ( ( unsigned long long ) address ),
949  ( ( unsigned long long ) address + ring->len ) );
950 
951  return 0;
952 
953  free_dma ( ring->desc.raw, ring->len );
954  err_alloc:
955  return rc;
956 }
void * regs
Registers.
Definition: intelxl.h:1030
size_t len
Length (in bytes)
Definition: intelxl.h:884
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint64_t address
Base address.
Definition: ena.h:24
#define DBGC(...)
Definition: compiler.h:505
unsigned int prod
Producer index.
Definition: intelxl.h:875
#define INTELXL_ALIGN
Alignment.
Definition: intelxl.h:25
#define ENOMEM
Not enough space.
Definition: errno.h:534
unsigned int cons
Consumer index.
Definition: intelxl.h:877
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void * raw
Raw data.
Definition: intelxl.h:872
unsigned int reg
Register block.
Definition: intelxl.h:880
union intelxl_ring::@64 desc
Descriptors.
unsigned long physaddr_t
Definition: stdint.h:20
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
unsigned int tail
Tail register.
Definition: intelxl.h:882
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
void * memset(void *dest, int character, size_t len) __nonnull

References address, intelxl_ring::cons, DBGC, intelxl_ring::desc, ENOMEM, free_dma(), INTELXL_ALIGN, intelxl_ring::len, malloc_dma(), memset(), intelxl_ring::prod, intelxl_ring::raw, rc, intelxl_ring::reg, intelxl_nic::regs, intelxl_ring::tail, virt_to_bus(), and writel().

Referenced by intelxl_create_ring(), and intelxlvf_open().

◆ intelxl_free_ring()

void intelxl_free_ring ( struct intelxl_nic *intelxl  __unused,
struct intelxl_ring ring 
)

Free descriptor ring.

Parameters
intelxlIntel device
ringDescriptor ring

Definition at line 964 of file intelxl.c.

965  {
966 
967  /* Free descriptor ring */
968  free_dma ( ring->desc.raw, ring->len );
969  ring->desc.raw = NULL;
970 }
size_t len
Length (in bytes)
Definition: intelxl.h:884
void * raw
Raw data.
Definition: intelxl.h:872
union intelxl_ring::@64 desc
Descriptors.
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References intelxl_ring::desc, free_dma(), intelxl_ring::len, NULL, and intelxl_ring::raw.

Referenced by intelxl_create_ring(), intelxl_destroy_ring(), intelxlvf_close(), and intelxlvf_open().

◆ intelxl_context_dump()

static void intelxl_context_dump ( struct intelxl_nic intelxl,
uint32_t  op,
size_t  len 
)
static

Dump queue context (for debugging)

Parameters
intelxlIntel device
opContext operation
lenSize of context

Definition at line 980 of file intelxl.c.

980  {
981  struct intelxl_context_line line;
982  uint32_t pfcm_lanctxctl;
983  uint32_t pfcm_lanctxstat;
984  unsigned int queue;
985  unsigned int index;
986  unsigned int i;
987 
988  /* Do nothing unless debug output is enabled */
989  if ( ! DBG_EXTRA )
990  return;
991 
992  /* Dump context */
993  DBGC2 ( intelxl, "INTELXL %p context %#08x:\n", intelxl, op );
994  for ( index = 0 ; ( sizeof ( line ) * index ) < len ; index++ ) {
995 
996  /* Start context operation */
997  queue = ( intelxl->base + intelxl->queue );
998  pfcm_lanctxctl =
1002  writel ( pfcm_lanctxctl,
1003  intelxl->regs + INTELXL_PFCM_LANCTXCTL );
1004 
1005  /* Wait for operation to complete */
1006  for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
1007 
1008  /* Check if operation is complete */
1009  pfcm_lanctxstat = readl ( intelxl->regs +
1011  if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
1012  break;
1013 
1014  /* Delay */
1015  mdelay ( 1 );
1016  }
1017 
1018  /* Read context data */
1019  for ( i = 0 ; i < ( sizeof ( line ) /
1020  sizeof ( line.raw[0] ) ) ; i++ ) {
1021  line.raw[i] = readl ( intelxl->regs +
1022  INTELXL_PFCM_LANCTXDATA ( i ) );
1023  }
1024  DBGC2_HDA ( intelxl, ( sizeof ( line ) * index ),
1025  &line, sizeof ( line ) );
1026  }
1027 }
void * regs
Registers.
Definition: intelxl.h:1030
Queue context line.
Definition: intelxl.h:636
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
unsigned int queue
Queue number.
Definition: intelxl.h:1041
#define INTELXL_PFCM_LANCTXCTL_QUEUE_NUM(x)
Queue number.
Definition: intelxl.h:610
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTELXL_PFCM_LANCTXSTAT
CMLAN Context Status Register.
Definition: intelxl.h:632
#define DBGC2_HDA(...)
Definition: compiler.h:523
#define INTELXL_PFCM_LANCTXCTL_SUB_LINE(x)
Sub-line.
Definition: intelxl.h:613
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
#define INTELXL_PFCM_LANCTXSTAT_DONE
Complete.
Definition: intelxl.h:633
unsigned int base
Absolute queue number base.
Definition: intelxl.h:1037
#define DBG_EXTRA
Definition: compiler.h:319
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
uint16_t queue
Queue ID.
Definition: ena.h:22
#define INTELXL_CTX_MAX_WAIT_MS
Maximum time to wait for a context operation to complete.
Definition: intelxl.h:708
#define INTELXL_PFCM_LANCTXCTL
CMLAN Context Control Register.
Definition: intelxl.h:609
#define INTELXL_PFCM_LANCTXDATA(x)
CMLAN Context Data Register.
Definition: intelxl.h:606
#define INTELXL_PFCM_LANCTXCTL_OP_CODE_READ
Read context.
Definition: intelxl.h:626

References intelxl_nic::base, DBG_EXTRA, DBGC2, DBGC2_HDA, index, INTELXL_CTX_MAX_WAIT_MS, INTELXL_PFCM_LANCTXCTL, INTELXL_PFCM_LANCTXCTL_OP_CODE_READ, INTELXL_PFCM_LANCTXCTL_QUEUE_NUM, INTELXL_PFCM_LANCTXCTL_SUB_LINE, INTELXL_PFCM_LANCTXDATA, INTELXL_PFCM_LANCTXSTAT, INTELXL_PFCM_LANCTXSTAT_DONE, len, mdelay(), op, queue, intelxl_nic::queue, intelxl_context_line::raw, readl(), intelxl_nic::regs, and writel().

Referenced by intelxl_close().

◆ intelxl_context_line()

static int intelxl_context_line ( struct intelxl_nic intelxl,
struct intelxl_context_line line,
unsigned int  index,
uint32_t  op 
)
static

Program queue context line.

Parameters
intelxlIntel device
lineQueue context line
indexLine number
opContext operation
Return values
rcReturn status code

Definition at line 1038 of file intelxl.c.

1040  {
1041  uint32_t pfcm_lanctxctl;
1042  uint32_t pfcm_lanctxstat;
1043  unsigned int queue;
1044  unsigned int i;
1045 
1046  /* Write context data */
1047  for ( i = 0; i < ( sizeof ( *line ) / sizeof ( line->raw[0] ) ); i++ ) {
1048  writel ( le32_to_cpu ( line->raw[i] ),
1049  intelxl->regs + INTELXL_PFCM_LANCTXDATA ( i ) );
1050  }
1051 
1052  /* Start context operation */
1053  queue = ( intelxl->base + intelxl->queue );
1054  pfcm_lanctxctl = ( INTELXL_PFCM_LANCTXCTL_QUEUE_NUM ( queue ) |
1057  writel ( pfcm_lanctxctl, intelxl->regs + INTELXL_PFCM_LANCTXCTL );
1058 
1059  /* Wait for operation to complete */
1060  for ( i = 0 ; i < INTELXL_CTX_MAX_WAIT_MS ; i++ ) {
1061 
1062  /* Check if operation is complete */
1063  pfcm_lanctxstat = readl ( intelxl->regs +
1065  if ( pfcm_lanctxstat & INTELXL_PFCM_LANCTXSTAT_DONE )
1066  return 0;
1067 
1068  /* Delay */
1069  mdelay ( 1 );
1070  }
1071 
1072  DBGC ( intelxl, "INTELXL %p timed out waiting for context: %#08x\n",
1073  intelxl, pfcm_lanctxctl );
1074  return -ETIMEDOUT;
1075 }
void * regs
Registers.
Definition: intelxl.h:1030
uint32_t raw[4]
Raw data.
Definition: intelxl.h:638
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define INTELXL_PFCM_LANCTXCTL_OP_CODE_WRITE
Write context.
Definition: intelxl.h:628
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
unsigned int queue
Queue number.
Definition: intelxl.h:1041
#define INTELXL_PFCM_LANCTXCTL_QUEUE_NUM(x)
Queue number.
Definition: intelxl.h:610
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTELXL_PFCM_LANCTXSTAT
CMLAN Context Status Register.
Definition: intelxl.h:632
#define INTELXL_PFCM_LANCTXCTL_SUB_LINE(x)
Sub-line.
Definition: intelxl.h:613
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define INTELXL_PFCM_LANCTXSTAT_DONE
Complete.
Definition: intelxl.h:633
unsigned int base
Absolute queue number base.
Definition: intelxl.h:1037
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
uint16_t queue
Queue ID.
Definition: ena.h:22
#define INTELXL_CTX_MAX_WAIT_MS
Maximum time to wait for a context operation to complete.
Definition: intelxl.h:708
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
#define INTELXL_PFCM_LANCTXCTL
CMLAN Context Control Register.
Definition: intelxl.h:609
#define INTELXL_PFCM_LANCTXDATA(x)
CMLAN Context Data Register.
Definition: intelxl.h:606

References intelxl_nic::base, DBGC, ETIMEDOUT, index, INTELXL_CTX_MAX_WAIT_MS, INTELXL_PFCM_LANCTXCTL, INTELXL_PFCM_LANCTXCTL_OP_CODE_WRITE, INTELXL_PFCM_LANCTXCTL_QUEUE_NUM, INTELXL_PFCM_LANCTXCTL_SUB_LINE, INTELXL_PFCM_LANCTXDATA, INTELXL_PFCM_LANCTXSTAT, INTELXL_PFCM_LANCTXSTAT_DONE, le32_to_cpu, mdelay(), op, queue, intelxl_nic::queue, intelxl_context_line::raw, readl(), intelxl_nic::regs, and writel().

◆ intelxl_context()

static int intelxl_context ( struct intelxl_nic intelxl,
struct intelxl_context_line line,
size_t  len,
uint32_t  op 
)
static

Program queue context.

Parameters
intelxlIntel device
lineQueue context lines
lenSize of context
opContext operation
Return values
rcReturn status code

Definition at line 1086 of file intelxl.c.

1088  {
1089  unsigned int index;
1090  int rc;
1091 
1092  DBGC2 ( intelxl, "INTELXL %p context %#08x len %#zx:\n",
1093  intelxl, op, len );
1094  DBGC2_HDA ( intelxl, 0, line, len );
1095 
1096  /* Program one line at a time */
1097  for ( index = 0 ; ( sizeof ( *line ) * index ) < len ; index++ ) {
1098  if ( ( rc = intelxl_context_line ( intelxl, line++, index,
1099  op ) ) != 0 )
1100  return rc;
1101  }
1102 
1103  return 0;
1104 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Queue context line.
Definition: intelxl.h:636
#define DBGC2_HDA(...)
Definition: compiler.h:523
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21

References DBGC2, DBGC2_HDA, index, len, op, and rc.

Referenced by intelxl_context_rx(), and intelxl_context_tx().

◆ intelxl_context_tx()

static int intelxl_context_tx ( struct intelxl_nic intelxl,
physaddr_t  address 
)
static

Program transmit queue context.

Parameters
intelxlIntel device
addressDescriptor ring base address
Return values
rcReturn status code

Definition at line 1113 of file intelxl.c.

1114  {
1115  union {
1116  struct intelxl_context_tx tx;
1117  struct intelxl_context_line line;
1118  } ctx;
1119  int rc;
1120 
1121  /* Initialise context */
1122  memset ( &ctx, 0, sizeof ( ctx ) );
1123  ctx.tx.flags = cpu_to_le16 ( INTELXL_CTX_TX_FL_NEW );
1124  ctx.tx.base = cpu_to_le64 ( INTELXL_CTX_TX_BASE ( address ) );
1125  ctx.tx.count =
1127  ctx.tx.qset = INTELXL_CTX_TX_QSET ( intelxl->qset );
1128 
1129  /* Program context */
1130  if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
1132  return rc;
1133 
1134  return 0;
1135 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint64_t address
Base address.
Definition: ena.h:24
Queue context line.
Definition: intelxl.h:636
unsigned int qset
Queue set handle.
Definition: intelxl.h:1045
#define cpu_to_le64(value)
Definition: byteswap.h:108
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define INTELXL_PFCM_LANCTXCTL_TYPE_TX
TX queue type.
Definition: intelxl.h:621
static int intelxl_context(struct intelxl_nic *intelxl, struct intelxl_context_line *line, size_t len, uint32_t op)
Program queue context.
Definition: intelxl.c:1086
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition: intelxl.h:915
#define INTELXL_CTX_TX_FL_NEW
New transmit queue context.
Definition: intelxl.h:662
uint32_t tx
Maximum number of transmit queues.
Definition: intelvf.h:14
#define INTELXL_CTX_TX_QSET(qset)
Transmit queue set.
Definition: intelxl.h:671
#define INTELXL_CTX_TX_BASE(base)
Transmit queue base address.
Definition: intelxl.h:665
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_CTX_TX_COUNT(count)
Transmit queue count.
Definition: intelxl.h:668
Transmit queue context.
Definition: intelxl.h:642
void * memset(void *dest, int character, size_t len) __nonnull

References address, cpu_to_le16, cpu_to_le64, ctx, intelxl_context(), INTELXL_CTX_TX_BASE, INTELXL_CTX_TX_COUNT, INTELXL_CTX_TX_FL_NEW, INTELXL_CTX_TX_QSET, INTELXL_PFCM_LANCTXCTL_TYPE_TX, INTELXL_TX_NUM_DESC, memset(), intelxl_nic::qset, rc, and tx.

◆ intelxl_context_rx()

static int intelxl_context_rx ( struct intelxl_nic intelxl,
physaddr_t  address 
)
static

Program receive queue context.

Parameters
intelxlIntel device
addressDescriptor ring base address
Return values
rcReturn status code

Definition at line 1144 of file intelxl.c.

1145  {
1146  union {
1147  struct intelxl_context_rx rx;
1148  struct intelxl_context_line line;
1149  } ctx;
1150  uint64_t base_count;
1151  int rc;
1152 
1153  /* Initialise context */
1154  memset ( &ctx, 0, sizeof ( ctx ) );
1156  ctx.rx.base_count = cpu_to_le64 ( base_count );
1157  ctx.rx.len = cpu_to_le16 ( INTELXL_CTX_RX_LEN ( intelxl->mfs ) );
1159  ctx.rx.mfs = cpu_to_le16 ( INTELXL_CTX_RX_MFS ( intelxl->mfs ) );
1160 
1161  /* Program context */
1162  if ( ( rc = intelxl_context ( intelxl, &ctx.line, sizeof ( ctx ),
1164  return rc;
1165 
1166  return 0;
1167 }
Receive queue context.
Definition: intelxl.h:674
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTELXL_CTX_RX_LEN(len)
Receive queue data buffer length.
Definition: intelxl.h:696
uint64_t address
Base address.
Definition: ena.h:24
Queue context line.
Definition: intelxl.h:636
unsigned long long uint64_t
Definition: stdint.h:13
#define cpu_to_le64(value)
Definition: byteswap.h:108
#define INTELXL_CTX_RX_MFS(mfs)
Receive queue maximum frame size.
Definition: intelxl.h:705
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
size_t mfs
Maximum frame size.
Definition: intelxl.h:1032
#define INTELXL_CTX_RX_FL_DSIZE
Use 32-byte receive descriptors.
Definition: intelxl.h:699
#define INTELXL_PFCM_LANCTXCTL_TYPE_RX
RX queue type.
Definition: intelxl.h:619
static int intelxl_context(struct intelxl_nic *intelxl, struct intelxl_context_line *line, size_t len, uint32_t op)
Program queue context.
Definition: intelxl.c:1086
#define INTELXL_RX_NUM_DESC
Number of receive descriptors.
Definition: intelxl.h:924
uint32_t rx
Maximum number of receive queues.
Definition: intelvf.h:16
#define INTELXL_CTX_RX_FL_CRCSTRIP
Strip CRC from received packets.
Definition: intelxl.h:702
#define cpu_to_le16(value)
Definition: byteswap.h:106
#define INTELXL_CTX_RX_BASE_COUNT(base, count)
Receive queue base address and queue count.
Definition: intelxl.h:692
void * memset(void *dest, int character, size_t len) __nonnull

References address, cpu_to_le16, cpu_to_le64, ctx, intelxl_context(), INTELXL_CTX_RX_BASE_COUNT, INTELXL_CTX_RX_FL_CRCSTRIP, INTELXL_CTX_RX_FL_DSIZE, INTELXL_CTX_RX_LEN, INTELXL_CTX_RX_MFS, INTELXL_PFCM_LANCTXCTL_TYPE_RX, INTELXL_RX_NUM_DESC, memset(), intelxl_nic::mfs, rc, and rx.

◆ intelxl_enable_ring()

static int intelxl_enable_ring ( struct intelxl_nic intelxl,
struct intelxl_ring ring 
)
static

Enable descriptor ring.

Parameters
intelxlIntel device
ringDescriptor ring
Return values
rcReturn status code

Definition at line 1176 of file intelxl.c.

1177  {
1178  void *ring_regs = ( intelxl->regs + ring->reg );
1179  uint32_t qxx_ena;
1180 
1181  /* Enable ring */
1182  writel ( INTELXL_QXX_ENA_REQ, ( ring_regs + INTELXL_QXX_ENA ) );
1184  qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
1185  if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) ) {
1186  DBGC ( intelxl, "INTELXL %p ring %06x failed to enable: "
1187  "%#08x\n", intelxl, ring->reg, qxx_ena );
1188  return -EIO;
1189  }
1190 
1191  return 0;
1192 }
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 INTELXL_QXX_ENA_STAT
Enabled status.
Definition: intelxl.h:748
#define INTELXL_QXX_ENA
Queue Enable Register (offset)
Definition: intelxl.h:746
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define INTELXL_QXX_ENA_REQ
Enable request.
Definition: intelxl.h:747
unsigned int reg
Register block.
Definition: intelxl.h:880
unsigned int uint32_t
Definition: stdint.h:12
#define INTELXL_QUEUE_ENABLE_DELAY_US
Time to wait for a queue to become enabled.
Definition: intelxl.h:711
#define EIO
Input/output error.
Definition: errno.h:433

References DBGC, EIO, INTELXL_QUEUE_ENABLE_DELAY_US, INTELXL_QXX_ENA, INTELXL_QXX_ENA_REQ, INTELXL_QXX_ENA_STAT, readl(), intelxl_ring::reg, intelxl_nic::regs, udelay(), and writel().

Referenced by intelxl_create_ring().

◆ intelxl_disable_ring()

static int intelxl_disable_ring ( struct intelxl_nic intelxl,
struct intelxl_ring ring 
)
static

Disable descriptor ring.

Parameters
intelxlIntel device
ringDescriptor ring
Return values
rcReturn status code

Definition at line 1201 of file intelxl.c.

1202  {
1203  void *ring_regs = ( intelxl->regs + ring->reg );
1204  uint32_t qxx_ena;
1205  unsigned int i;
1206 
1207  /* Disable ring */
1208  writel ( 0, ( ring_regs + INTELXL_QXX_ENA ) );
1209 
1210  /* Wait for ring to be disabled */
1211  for ( i = 0 ; i < INTELXL_QUEUE_DISABLE_MAX_WAIT_MS ; i++ ) {
1212 
1213  /* Check if ring is disabled */
1214  qxx_ena = readl ( ring_regs + INTELXL_QXX_ENA );
1215  if ( ! ( qxx_ena & INTELXL_QXX_ENA_STAT ) )
1216  return 0;
1217 
1218  /* Delay */
1219  mdelay ( 1 );
1220  }
1221 
1222  DBGC ( intelxl, "INTELXL %p ring %06x timed out waiting for disable: "
1223  "%#08x\n", intelxl, ring->reg, qxx_ena );
1224  return -ETIMEDOUT;
1225 }
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 INTELXL_QXX_ENA_STAT
Enabled status.
Definition: intelxl.h:748
#define INTELXL_QXX_ENA
Queue Enable Register (offset)
Definition: intelxl.h:746
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
unsigned int reg
Register block.
Definition: intelxl.h:880
#define INTELXL_QUEUE_DISABLE_MAX_WAIT_MS
Maximum time to wait for a queue to become disabled.
Definition: intelxl.h:717
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_QUEUE_DISABLE_MAX_WAIT_MS, INTELXL_QXX_ENA, INTELXL_QXX_ENA_STAT, mdelay(), readl(), intelxl_ring::reg, intelxl_nic::regs, and writel().

Referenced by intelxl_create_ring(), and intelxl_destroy_ring().

◆ intelxl_create_ring()

static int intelxl_create_ring ( struct intelxl_nic intelxl,
struct intelxl_ring ring 
)
static

Create descriptor ring.

Parameters
intelxlIntel device
ringDescriptor ring
Return values
rcReturn status code

Definition at line 1234 of file intelxl.c.

1235  {
1237  int rc;
1238 
1239  /* Allocate descriptor ring */
1240  if ( ( rc = intelxl_alloc_ring ( intelxl, ring ) ) != 0 )
1241  goto err_alloc;
1242 
1243  /* Program queue context */
1244  address = virt_to_bus ( ring->desc.raw );
1245  if ( ( rc = ring->context ( intelxl, address ) ) != 0 )
1246  goto err_context;
1247 
1248  /* Enable ring */
1249  if ( ( rc = intelxl_enable_ring ( intelxl, ring ) ) != 0 )
1250  goto err_enable;
1251 
1252  return 0;
1253 
1254  intelxl_disable_ring ( intelxl, ring );
1255  err_enable:
1256  err_context:
1257  intelxl_free_ring ( intelxl, ring );
1258  err_alloc:
1259  return rc;
1260 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int(* context)(struct intelxl_nic *intelxl, physaddr_t address)
Program queue context.
Definition: intelxl.h:890
static int intelxl_enable_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Enable descriptor ring.
Definition: intelxl.c:1176
uint64_t address
Base address.
Definition: ena.h:24
static int intelxl_disable_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Disable descriptor ring.
Definition: intelxl.c:1201
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
void * raw
Raw data.
Definition: intelxl.h:872
void intelxl_free_ring(struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring)
Free descriptor ring.
Definition: intelxl.c:964
union intelxl_ring::@64 desc
Descriptors.
unsigned long physaddr_t
Definition: stdint.h:20
int intelxl_alloc_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Allocate descriptor ring.
Definition: intelxl.c:923

References address, intelxl_ring::context, intelxl_ring::desc, intelxl_alloc_ring(), intelxl_disable_ring(), intelxl_enable_ring(), intelxl_free_ring(), intelxl_ring::raw, rc, and virt_to_bus().

Referenced by intelxl_open().

◆ intelxl_destroy_ring()

static void intelxl_destroy_ring ( struct intelxl_nic intelxl,
struct intelxl_ring ring 
)
static

Destroy descriptor ring.

Parameters
intelxlIntel device
ringDescriptor ring

Definition at line 1268 of file intelxl.c.

1269  {
1270  int rc;
1271 
1272  /* Disable ring */
1273  if ( ( rc = intelxl_disable_ring ( intelxl, ring ) ) != 0 ) {
1274  /* Leak memory; there's nothing else we can do */
1275  return;
1276  }
1277 
1278  /* Free descriptor ring */
1279  intelxl_free_ring ( intelxl, ring );
1280 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxl_disable_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Disable descriptor ring.
Definition: intelxl.c:1201
void intelxl_free_ring(struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring)
Free descriptor ring.
Definition: intelxl.c:964

References intelxl_disable_ring(), intelxl_free_ring(), and rc.

Referenced by intelxl_close(), and intelxl_open().

◆ intelxl_refill_rx()

static void intelxl_refill_rx ( struct intelxl_nic intelxl)
static

Refill receive descriptor ring.

Parameters
intelxlIntel device

Definition at line 1287 of file intelxl.c.

1287  {
1289  struct io_buffer *iobuf;
1290  unsigned int rx_idx;
1291  unsigned int rx_tail;
1293  unsigned int refilled = 0;
1294 
1295  /* Refill ring */
1296  while ( ( intelxl->rx.prod - intelxl->rx.cons ) < INTELXL_RX_FILL ) {
1297 
1298  /* Allocate I/O buffer */
1299  iobuf = alloc_iob ( intelxl->mfs );
1300  if ( ! iobuf ) {
1301  /* Wait for next refill */
1302  break;
1303  }
1304 
1305  /* Get next receive descriptor */
1306  rx_idx = ( intelxl->rx.prod++ % INTELXL_RX_NUM_DESC );
1307  rx = &intelxl->rx.desc.rx[rx_idx].data;
1308 
1309  /* Populate receive descriptor */
1310  address = virt_to_bus ( iobuf->data );
1311  rx->address = cpu_to_le64 ( address );
1312  rx->flags = 0;
1313 
1314  /* Record I/O buffer */
1315  assert ( intelxl->rx_iobuf[rx_idx] == NULL );
1316  intelxl->rx_iobuf[rx_idx] = iobuf;
1317 
1318  DBGC2 ( intelxl, "INTELXL %p RX %d is [%llx,%llx)\n", intelxl,
1319  rx_idx, ( ( unsigned long long ) address ),
1320  ( ( unsigned long long ) address + intelxl->mfs ) );
1321  refilled++;
1322  }
1323 
1324  /* Push descriptors to card, if applicable */
1325  if ( refilled ) {
1326  wmb();
1327  rx_tail = ( intelxl->rx.prod % INTELXL_RX_NUM_DESC );
1328  writel ( rx_tail, ( intelxl->regs + intelxl->rx.tail ) );
1329  }
1330 }
void * regs
Registers.
Definition: intelxl.h:1030
wmb()
uint64_t address
Base address.
Definition: ena.h:24
unsigned int prod
Producer index.
Definition: intelxl.h:875
#define cpu_to_le64(value)
Definition: byteswap.h:108
size_t mfs
Maximum frame size.
Definition: intelxl.h:1032
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
unsigned int cons
Consumer index.
Definition: intelxl.h:877
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 io_buffer * rx_iobuf[INTELXL_RX_NUM_DESC]
Receive I/O buffers.
Definition: intelxl.h:1072
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define INTELXL_RX_NUM_DESC
Number of receive descriptors.
Definition: intelxl.h:924
uint32_t rx
Maximum number of receive queues.
Definition: intelvf.h:16
Receive data descriptor.
Definition: intelxl.h:818
union intelxl_rx_descriptor * rx
Receive descriptors.
Definition: intelxl.h:870
union intelxl_ring::@64 desc
Descriptors.
unsigned long physaddr_t
Definition: stdint.h:20
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:44
unsigned int tail
Tail register.
Definition: intelxl.h:882
#define INTELXL_RX_FILL
Receive descriptor ring fill level.
Definition: intelxl.h:930
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct intelxl_rx_data_descriptor data
Receive data descriptor.
Definition: intelxl.h:858
A persistent I/O buffer.
Definition: iobuf.h:32

References address, alloc_iob(), assert(), intelxl_ring::cons, cpu_to_le64, io_buffer::data, intelxl_rx_descriptor::data, DBGC2, intelxl_ring::desc, INTELXL_RX_FILL, INTELXL_RX_NUM_DESC, intelxl_nic::mfs, NULL, intelxl_ring::prod, intelxl_nic::regs, rx, intelxl_ring::rx, intelxl_nic::rx, intelxl_nic::rx_iobuf, intelxl_ring::tail, virt_to_bus(), wmb(), and writel().

Referenced by intelxl_open(), and intelxl_poll().

◆ intelxl_empty_rx()

void intelxl_empty_rx ( struct intelxl_nic intelxl)

Discard unused receive I/O buffers.

Parameters
intelxlIntel device

Definition at line 1337 of file intelxl.c.

1337  {
1338  unsigned int i;
1339 
1340  /* Discard any unused receive buffers */
1341  for ( i = 0 ; i < INTELXL_RX_NUM_DESC ; i++ ) {
1342  if ( intelxl->rx_iobuf[i] )
1343  free_iob ( intelxl->rx_iobuf[i] );
1344  intelxl->rx_iobuf[i] = NULL;
1345  }
1346 }
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
struct io_buffer * rx_iobuf[INTELXL_RX_NUM_DESC]
Receive I/O buffers.
Definition: intelxl.h:1072
#define INTELXL_RX_NUM_DESC
Number of receive descriptors.
Definition: intelxl.h:924
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References free_iob(), INTELXL_RX_NUM_DESC, NULL, and intelxl_nic::rx_iobuf.

Referenced by intelxl_close(), and intelxlvf_close().

◆ intelxl_open()

static int intelxl_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 1361 of file intelxl.c.

1361  {
1362  struct intelxl_nic *intelxl = netdev->priv;
1364  unsigned int queue;
1365  uint32_t prtgl_sal;
1366  uint32_t prtgl_sah;
1367  int rc;
1368 
1369  /* Calculate maximum frame size */
1370  intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
1371  INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
1372 
1373  /* Program MAC address and maximum frame size */
1374  memset ( &mac, 0, sizeof ( mac ) );
1375  memcpy ( mac.raw, netdev->ll_addr, sizeof ( mac.raw ) );
1376  prtgl_sal = le32_to_cpu ( mac.reg.low );
1377  prtgl_sah = ( le32_to_cpu ( mac.reg.high ) |
1378  INTELXL_PRTGL_SAH_MFS_SET ( intelxl->mfs ) );
1379  writel ( prtgl_sal, intelxl->regs + INTELXL_PRTGL_SAL );
1380  writel ( prtgl_sah, intelxl->regs + INTELXL_PRTGL_SAH );
1381 
1382  /* Associate transmit queue to PF */
1384  INTELXL_QXX_CTL_PFVF_PF_INDX ( intelxl->pf ) ),
1385  ( intelxl->regs + intelxl->tx.reg + INTELXL_QXX_CTL ) );
1386 
1387  /* Clear transmit pre queue disable */
1388  queue = ( intelxl->base + intelxl->queue );
1391  ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
1392 
1393  /* Reset transmit queue head */
1394  writel ( 0, ( intelxl->regs + INTELXL_QTX_HEAD ( intelxl->queue ) ) );
1395 
1396  /* Create receive descriptor ring */
1397  if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->rx ) ) != 0 )
1398  goto err_create_rx;
1399 
1400  /* Create transmit descriptor ring */
1401  if ( ( rc = intelxl_create_ring ( intelxl, &intelxl->tx ) ) != 0 )
1402  goto err_create_tx;
1403 
1404  /* Fill receive ring */
1405  intelxl_refill_rx ( intelxl );
1406 
1407  /* Restart autonegotiation */
1408  intelxl_admin_autoneg ( intelxl );
1409 
1410  /* Update link state */
1412 
1413  return 0;
1414 
1417  ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
1419  intelxl_destroy_ring ( intelxl, &intelxl->tx );
1420  err_create_tx:
1421  intelxl_destroy_ring ( intelxl, &intelxl->rx );
1422  err_create_rx:
1423  return rc;
1424 }
#define INTELXL_GLLAN_TXPRE_QDIS(x)
Global Transmit Pre Queue Disable register.
Definition: intelxl.h:730
void * regs
Registers.
Definition: intelxl.h:1030
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTELXL_QXX_CTL_PFVF_Q_PF
PF queue.
Definition: intelxl.h:753
#define INTELXL_GLLAN_TXPRE_QDIS_QINDX(x)
Queue index.
Definition: intelxl.h:731
#define le32_to_cpu(value)
Definition: byteswap.h:113
#define INTELXL_PRTGL_SAL
Port MAC Address Low Register.
Definition: intelxl.h:1011
#define INTELXL_PRTGL_SAH
Port MAC Address High Register.
Definition: intelxl.h:1014
size_t mtu
Maximum transmission unit length.
Definition: netdevice.h:409
#define INTELXL_ALIGN
Alignment.
Definition: intelxl.h:25
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
size_t mfs
Maximum frame size.
Definition: intelxl.h:1032
unsigned int queue
Queue number.
Definition: intelxl.h:1041
static void intelxl_refill_rx(struct intelxl_nic *intelxl)
Refill receive descriptor ring.
Definition: intelxl.c:1287
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:1070
static void intelxl_destroy_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Destroy descriptor ring.
Definition: intelxl.c:1268
#define ETH_HLEN
Definition: if_ether.h:9
#define INTELXL_QXX_CTL_PFVF_PF_INDX(x)
PF index.
Definition: intelxl.h:755
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.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct net_device * netdev
Definition: gdbudp.c:52
unsigned int reg
Register block.
Definition: intelxl.h:880
static int intelxl_admin_autoneg(struct intelxl_nic *intelxl)
Restart autonegotiation.
Definition: intelxl.c:689
#define INTELXL_QUEUE_PRE_DISABLE_DELAY_US
Time to wait for a transmit queue to become pre-disabled.
Definition: intelxl.h:714
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
unsigned int uint32_t
Definition: stdint.h:12
Receive address.
Definition: intelxl.h:1019
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
#define INTELXL_PRTGL_SAH_MFS_SET(x)
Max frame size.
Definition: intelxl.h:1016
unsigned int pf
Physical function number.
Definition: intelxl.h:1035
#define INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS
Set disable.
Definition: intelxl.h:734
#define INTELXL_GLLAN_TXPRE_QDIS_CLEAR_QDIS
Clear disable.
Definition: intelxl.h:736
unsigned int base
Absolute queue number base.
Definition: intelxl.h:1037
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:381
static int intelxl_admin_link(struct net_device *netdev)
Get link status.
Definition: intelxl.c:714
uint16_t queue
Queue ID.
Definition: ena.h:22
static int intelxl_create_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Create descriptor ring.
Definition: intelxl.c:1234
#define INTELXL_QXX_CTL
Queue Control Register (offset)
Definition: intelxl.h:751
#define INTELXL_QTX_HEAD(x)
Global Transmit Queue Head register.
Definition: intelxl.h:727
void * memset(void *dest, int character, size_t len) __nonnull

References intelxl_nic::base, ETH_HLEN, intelxl_admin_autoneg(), intelxl_admin_link(), INTELXL_ALIGN, intelxl_create_ring(), intelxl_destroy_ring(), INTELXL_GLLAN_TXPRE_QDIS, INTELXL_GLLAN_TXPRE_QDIS_CLEAR_QDIS, INTELXL_GLLAN_TXPRE_QDIS_QINDX, INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS, INTELXL_PRTGL_SAH, INTELXL_PRTGL_SAH_MFS_SET, INTELXL_PRTGL_SAL, INTELXL_QTX_HEAD, INTELXL_QUEUE_PRE_DISABLE_DELAY_US, INTELXL_QXX_CTL, INTELXL_QXX_CTL_PFVF_PF_INDX, INTELXL_QXX_CTL_PFVF_Q_PF, intelxl_refill_rx(), le32_to_cpu, net_device::ll_addr, mac, memcpy(), memset(), intelxl_nic::mfs, net_device::mtu, netdev, intelxl_nic::pf, net_device::priv, queue, intelxl_nic::queue, rc, intelxl_ring::reg, intelxl_nic::regs, intelxl_nic::rx, intelxl_nic::tx, udelay(), and writel().

◆ intelxl_close()

static void intelxl_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 1431 of file intelxl.c.

1431  {
1432  struct intelxl_nic *intelxl = netdev->priv;
1433  unsigned int queue;
1434 
1435  /* Dump contexts (for debugging) */
1437  sizeof ( struct intelxl_context_tx ) );
1439  sizeof ( struct intelxl_context_rx ) );
1440 
1441  /* Pre-disable transmit queue */
1442  queue = ( intelxl->base + intelxl->queue );
1445  ( intelxl->regs + INTELXL_GLLAN_TXPRE_QDIS ( queue ) ) );
1447 
1448  /* Destroy transmit descriptor ring */
1449  intelxl_destroy_ring ( intelxl, &intelxl->tx );
1450 
1451  /* Destroy receive descriptor ring */
1452  intelxl_destroy_ring ( intelxl, &intelxl->rx );
1453 
1454  /* Discard any unused receive buffers */
1455  intelxl_empty_rx ( intelxl );
1456 }
Receive queue context.
Definition: intelxl.h:674
#define INTELXL_GLLAN_TXPRE_QDIS(x)
Global Transmit Pre Queue Disable register.
Definition: intelxl.h:730
void * regs
Registers.
Definition: intelxl.h:1030
static void intelxl_context_dump(struct intelxl_nic *intelxl, uint32_t op, size_t len)
Dump queue context (for debugging)
Definition: intelxl.c:980
#define INTELXL_GLLAN_TXPRE_QDIS_QINDX(x)
Queue index.
Definition: intelxl.h:731
unsigned int queue
Queue number.
Definition: intelxl.h:1041
#define INTELXL_PFCM_LANCTXCTL_TYPE_RX
RX queue type.
Definition: intelxl.h:619
#define INTELXL_PFCM_LANCTXCTL_TYPE_TX
TX queue type.
Definition: intelxl.h:621
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:1070
static void intelxl_destroy_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Destroy descriptor ring.
Definition: intelxl.c:1268
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.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct net_device * netdev
Definition: gdbudp.c:52
#define INTELXL_QUEUE_PRE_DISABLE_DELAY_US
Time to wait for a transmit queue to become pre-disabled.
Definition: intelxl.h:714
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
#define INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS
Set disable.
Definition: intelxl.h:734
unsigned int base
Absolute queue number base.
Definition: intelxl.h:1037
uint16_t queue
Queue ID.
Definition: ena.h:22
Transmit queue context.
Definition: intelxl.h:642
void intelxl_empty_rx(struct intelxl_nic *intelxl)
Discard unused receive I/O buffers.
Definition: intelxl.c:1337

References intelxl_nic::base, intelxl_context_dump(), intelxl_destroy_ring(), intelxl_empty_rx(), INTELXL_GLLAN_TXPRE_QDIS, INTELXL_GLLAN_TXPRE_QDIS_QINDX, INTELXL_GLLAN_TXPRE_QDIS_SET_QDIS, INTELXL_PFCM_LANCTXCTL_TYPE_RX, INTELXL_PFCM_LANCTXCTL_TYPE_TX, INTELXL_QUEUE_PRE_DISABLE_DELAY_US, netdev, net_device::priv, queue, intelxl_nic::queue, intelxl_nic::regs, intelxl_nic::rx, intelxl_nic::tx, udelay(), and writel().

◆ intelxl_transmit()

int intelxl_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)

Transmit packet.

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

Definition at line 1465 of file intelxl.c.

1465  {
1466  struct intelxl_nic *intelxl = netdev->priv;
1468  unsigned int tx_idx;
1469  unsigned int tx_tail;
1471  size_t len;
1472 
1473  /* Get next transmit descriptor */
1474  if ( ( intelxl->tx.prod - intelxl->tx.cons ) >= INTELXL_TX_FILL ) {
1475  DBGC ( intelxl, "INTELXL %p out of transmit descriptors\n",
1476  intelxl );
1477  return -ENOBUFS;
1478  }
1479  tx_idx = ( intelxl->tx.prod++ % INTELXL_TX_NUM_DESC );
1480  tx_tail = ( intelxl->tx.prod % INTELXL_TX_NUM_DESC );
1481  tx = &intelxl->tx.desc.tx[tx_idx].data;
1482 
1483  /* Populate transmit descriptor */
1484  address = virt_to_bus ( iobuf->data );
1485  len = iob_len ( iobuf );
1486  tx->address = cpu_to_le64 ( address );
1487  tx->len = cpu_to_le32 ( INTELXL_TX_DATA_LEN ( len ) );
1490  wmb();
1491 
1492  /* Notify card that there are packets ready to transmit */
1493  writel ( tx_tail, ( intelxl->regs + intelxl->tx.tail ) );
1494 
1495  DBGC2 ( intelxl, "INTELXL %p TX %d is [%llx,%llx)\n", intelxl, tx_idx,
1496  ( ( unsigned long long ) address ),
1497  ( ( unsigned long long ) address + len ) );
1498  return 0;
1499 }
void * regs
Registers.
Definition: intelxl.h:1030
wmb()
uint64_t address
Base address.
Definition: ena.h:24
#define INTELXL_TX_DATA_EOP
Transmit data descriptor end of packet.
Definition: intelxl.h:778
#define INTELXL_TX_DATA_DTYP
Transmit data descriptor type.
Definition: intelxl.h:775
#define DBGC(...)
Definition: compiler.h:505
unsigned int prod
Producer index.
Definition: intelxl.h:875
#define cpu_to_le64(value)
Definition: byteswap.h:108
union intelxl_tx_descriptor * tx
Transmit descriptors.
Definition: intelxl.h:868
#define INTELXL_TX_DATA_LEN(len)
Transmit data descriptor length.
Definition: intelxl.h:794
unsigned int cons
Consumer index.
Definition: intelxl.h:877
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_tx_data_descriptor data
Transmit data descriptor.
Definition: intelxl.h:812
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition: intelxl.h:915
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 cpu_to_le32(value)
Definition: byteswap.h:107
#define INTELXL_TX_DATA_RS
Transmit data descriptor report status.
Definition: intelxl.h:781
uint32_t tx
Maximum number of transmit queues.
Definition: intelvf.h:14
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
union intelxl_ring::@64 desc
Descriptors.
Transmit data descriptor.
Definition: intelxl.h:765
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
#define INTELXL_TX_DATA_JFDI
Transmit data descriptor pretty please.
Definition: intelxl.h:791
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
unsigned long physaddr_t
Definition: stdint.h:20
uint32_t len
Length.
Definition: ena.h:14
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:44
unsigned int tail
Tail register.
Definition: intelxl.h:882
#define INTELXL_TX_FILL
Transmit descriptor ring maximum fill level.
Definition: intelxl.h:918

References address, intelxl_ring::cons, cpu_to_le32, cpu_to_le64, io_buffer::data, intelxl_tx_descriptor::data, DBGC, DBGC2, intelxl_ring::desc, ENOBUFS, INTELXL_TX_DATA_DTYP, INTELXL_TX_DATA_EOP, INTELXL_TX_DATA_JFDI, INTELXL_TX_DATA_LEN, INTELXL_TX_DATA_RS, INTELXL_TX_FILL, INTELXL_TX_NUM_DESC, iob_len(), len, netdev, net_device::priv, intelxl_ring::prod, intelxl_nic::regs, intelxl_ring::tail, tx, intelxl_ring::tx, intelxl_nic::tx, virt_to_bus(), wmb(), and writel().

◆ intelxl_poll_tx()

static void intelxl_poll_tx ( struct net_device netdev)
static

Poll for completed packets.

Parameters
netdevNetwork device

Definition at line 1506 of file intelxl.c.

1506  {
1507  struct intelxl_nic *intelxl = netdev->priv;
1508  struct intelxl_tx_writeback_descriptor *tx_wb;
1509  unsigned int tx_idx;
1510 
1511  /* Check for completed packets */
1512  while ( intelxl->tx.cons != intelxl->tx.prod ) {
1513 
1514  /* Get next transmit descriptor */
1515  tx_idx = ( intelxl->tx.cons % INTELXL_TX_NUM_DESC );
1516  tx_wb = &intelxl->tx.desc.tx[tx_idx].wb;
1517 
1518  /* Stop if descriptor is still in use */
1519  if ( ! ( tx_wb->flags & INTELXL_TX_WB_FL_DD ) )
1520  return;
1521  DBGC2 ( intelxl, "INTELXL %p TX %d complete\n",
1522  intelxl, tx_idx );
1523 
1524  /* Complete TX descriptor */
1526  intelxl->tx.cons++;
1527  }
1528 }
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition: netdevice.h:758
unsigned int prod
Producer index.
Definition: intelxl.h:875
union intelxl_tx_descriptor * tx
Transmit descriptors.
Definition: intelxl.h:868
unsigned int cons
Consumer index.
Definition: intelxl.h:877
Transmit writeback descriptor.
Definition: intelxl.h:797
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition: intelxl.h:915
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
union intelxl_ring::@64 desc
Descriptors.
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
#define INTELXL_TX_WB_FL_DD
Transmit writeback descriptor complete.
Definition: intelxl.h:807
#define DBGC2(...)
Definition: compiler.h:522
struct intelxl_tx_writeback_descriptor wb
Transmit writeback descriptor.
Definition: intelxl.h:814

References intelxl_ring::cons, DBGC2, intelxl_ring::desc, intelxl_tx_writeback_descriptor::flags, INTELXL_TX_NUM_DESC, INTELXL_TX_WB_FL_DD, netdev, netdev_tx_complete_next(), net_device::priv, intelxl_ring::prod, intelxl_ring::tx, intelxl_nic::tx, and intelxl_tx_descriptor::wb.

Referenced by intelxl_poll().

◆ intelxl_poll_rx()

static void intelxl_poll_rx ( struct net_device netdev)
static

Poll for received packets.

Parameters
netdevNetwork device

Definition at line 1535 of file intelxl.c.

1535  {
1536  struct intelxl_nic *intelxl = netdev->priv;
1537  struct intelxl_rx_writeback_descriptor *rx_wb;
1538  struct io_buffer *iobuf;
1539  unsigned int rx_idx;
1540  unsigned int tag;
1541  size_t len;
1542 
1543  /* Check for received packets */
1544  while ( intelxl->rx.cons != intelxl->rx.prod ) {
1545 
1546  /* Get next receive descriptor */
1547  rx_idx = ( intelxl->rx.cons % INTELXL_RX_NUM_DESC );
1548  rx_wb = &intelxl->rx.desc.rx[rx_idx].wb;
1549 
1550  /* Stop if descriptor is still in use */
1551  if ( ! ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_DD ) ) )
1552  return;
1553 
1554  /* Populate I/O buffer */
1555  iobuf = intelxl->rx_iobuf[rx_idx];
1556  intelxl->rx_iobuf[rx_idx] = NULL;
1557  len = INTELXL_RX_WB_LEN ( le32_to_cpu ( rx_wb->len ) );
1558  iob_put ( iobuf, len );
1559 
1560  /* Find VLAN device, if applicable */
1561  if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_VLAN ) ) {
1562  tag = VLAN_TAG ( le16_to_cpu ( rx_wb->vlan ) );
1563  } else {
1564  tag = 0;
1565  }
1566 
1567  /* Hand off to network stack */
1568  if ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_RXE ) ) {
1569  DBGC ( intelxl, "INTELXL %p RX %d error (length %zd, "
1570  "flags %08x)\n", intelxl, rx_idx, len,
1571  le32_to_cpu ( rx_wb->flags ) );
1572  vlan_netdev_rx_err ( netdev, tag, iobuf, -EIO );
1573  } else {
1574  DBGC2 ( intelxl, "INTELXL %p RX %d complete (length "
1575  "%zd)\n", intelxl, rx_idx, len );
1576  vlan_netdev_rx ( netdev, tag, iobuf );
1577  }
1578  intelxl->rx.cons++;
1579  }
1580 }
#define VLAN_TAG(tci)
Extract VLAN tag from tag control information.
Definition: vlan.h:29
#define iob_put(iobuf, len)
Definition: iobuf.h:116
#define le32_to_cpu(value)
Definition: byteswap.h:113
uint16_t vlan
VLAN tag.
Definition: intelxl.h:832
#define INTELXL_RX_WB_FL_DD
Receive writeback descriptor complete.
Definition: intelxl.h:844
#define DBGC(...)
Definition: compiler.h:505
unsigned int prod
Producer index.
Definition: intelxl.h:875
struct intelxl_rx_writeback_descriptor wb
Receive writeback descriptor.
Definition: intelxl.h:860
unsigned int cons
Consumer index.
Definition: intelxl.h:877
struct intelxl_ring rx
Receive descriptor ring.
Definition: intelxl.h:1070
struct io_buffer * rx_iobuf[INTELXL_RX_NUM_DESC]
Receive I/O buffers.
Definition: intelxl.h:1072
void * priv
Driver private data.
Definition: netdevice.h:425
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
union intelxl_rx_descriptor * rx
Receive descriptors.
Definition: intelxl.h:870
union intelxl_ring::@64 desc
Descriptors.
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
#define le16_to_cpu(value)
Definition: byteswap.h:112
#define INTELXL_RX_WB_LEN(len)
Receive writeback descriptor length.
Definition: intelxl.h:853
__weak void vlan_netdev_rx(struct net_device *netdev, unsigned int tag, struct io_buffer *iobuf)
Add VLAN tag-stripped packet to queue (when VLAN support is not present)
Definition: netdevice.c:1135
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
__weak void vlan_netdev_rx_err(struct net_device *netdev, unsigned int tag __unused, struct io_buffer *iobuf, int rc)
Discard received VLAN tag-stripped packet (when VLAN support is not present)
Definition: netdevice.c:1153
Receive writeback descriptor.
Definition: intelxl.h:828
uint64_t tag
Identity tag.
Definition: edd.h:30
#define INTELXL_RX_WB_FL_RXE
Receive writeback descriptor error.
Definition: intelxl.h:850
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
#define INTELXL_RX_WB_FL_VLAN
Receive writeback descriptor VLAN tag present.
Definition: intelxl.h:847
A persistent I/O buffer.
Definition: iobuf.h:32

References intelxl_ring::cons, cpu_to_le32, DBGC, DBGC2, intelxl_ring::desc, EIO, intelxl_rx_writeback_descriptor::flags, INTELXL_RX_NUM_DESC, INTELXL_RX_WB_FL_DD, INTELXL_RX_WB_FL_RXE, INTELXL_RX_WB_FL_VLAN, INTELXL_RX_WB_LEN, iob_put, le16_to_cpu, le32_to_cpu, len, intelxl_rx_writeback_descriptor::len, netdev, NULL, net_device::priv, intelxl_ring::prod, intelxl_ring::rx, intelxl_nic::rx, intelxl_nic::rx_iobuf, tag, intelxl_rx_writeback_descriptor::vlan, vlan_netdev_rx(), vlan_netdev_rx_err(), VLAN_TAG, and intelxl_rx_descriptor::wb.

Referenced by intelxl_poll().

◆ intelxl_poll()

void intelxl_poll ( struct net_device netdev)

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 1587 of file intelxl.c.

1587  {
1588  struct intelxl_nic *intelxl = netdev->priv;
1589 
1590  /* Poll for completed packets */
1591  intelxl_poll_tx ( netdev );
1592 
1593  /* Poll for received packets */
1594  intelxl_poll_rx ( netdev );
1595 
1596  /* Poll for admin events */
1598 
1599  /* Refill RX ring */
1600  intelxl_refill_rx ( intelxl );
1601 
1602  /* Rearm interrupt, since otherwise receive descriptors will
1603  * be written back only after a complete cacheline (four
1604  * packets) have been received.
1605  *
1606  * There is unfortunately no efficient way to determine
1607  * whether or not rearming the interrupt is necessary. If we
1608  * are running inside a hypervisor (e.g. using a VF or PF as a
1609  * passed-through PCI device), then the MSI-X write is
1610  * redirected by the hypervisor to the real host APIC and the
1611  * host ISR then raises an interrupt within the guest. We
1612  * therefore cannot poll the nominal MSI-X target location to
1613  * watch for the value being written. We could read from the
1614  * INT_DYN_CTL register, but this is even less efficient than
1615  * just unconditionally rearming the interrupt.
1616  */
1617  writel ( INTELXL_INT_DYN_CTL_INTENA, intelxl->regs + intelxl->intr );
1618 }
void * regs
Registers.
Definition: intelxl.h:1030
#define INTELXL_INT_DYN_CTL_INTENA
Enable.
Definition: intelxl.h:941
static void intelxl_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: intelxl.c:1506
static void intelxl_refill_rx(struct intelxl_nic *intelxl)
Refill receive descriptor ring.
Definition: intelxl.c:1287
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
void intelxl_poll_admin(struct net_device *netdev)
Poll admin event queue.
Definition: intelxl.c:780
unsigned int intr
Interrupt control register.
Definition: intelxl.h:1047
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
static void intelxl_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: intelxl.c:1535

References INTELXL_INT_DYN_CTL_INTENA, intelxl_poll_admin(), intelxl_poll_rx(), intelxl_poll_tx(), intelxl_refill_rx(), intelxl_nic::intr, netdev, net_device::priv, intelxl_nic::regs, and writel().

◆ intelxl_probe()

static int intelxl_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 1641 of file intelxl.c.

1641  {
1642  struct net_device *netdev;
1643  struct intelxl_nic *intelxl;
1644  uint32_t pfgen_portnum;
1645  uint32_t pflan_qalloc;
1646  int rc;
1647 
1648  /* Allocate and initialise net device */
1649  netdev = alloc_etherdev ( sizeof ( *intelxl ) );
1650  if ( ! netdev ) {
1651  rc = -ENOMEM;
1652  goto err_alloc;
1653  }
1655  intelxl = netdev->priv;
1656  pci_set_drvdata ( pci, netdev );
1657  netdev->dev = &pci->dev;
1658  memset ( intelxl, 0, sizeof ( *intelxl ) );
1659  intelxl->pf = PCI_FUNC ( pci->busdevfn );
1660  intelxl->intr = INTELXL_PFINT_DYN_CTL0;
1666  sizeof ( intelxl->tx.desc.tx[0] ),
1669  sizeof ( intelxl->rx.desc.rx[0] ),
1671 
1672  /* Fix up PCI device */
1673  adjust_pci_device ( pci );
1674 
1675  /* Map registers */
1676  intelxl->regs = ioremap ( pci->membase, INTELXL_BAR_SIZE );
1677  if ( ! intelxl->regs ) {
1678  rc = -ENODEV;
1679  goto err_ioremap;
1680  }
1681 
1682  /* Reset the NIC */
1683  if ( ( rc = intelxl_reset ( intelxl ) ) != 0 )
1684  goto err_reset;
1685 
1686  /* Get port number and base queue number */
1687  pfgen_portnum = readl ( intelxl->regs + INTELXL_PFGEN_PORTNUM );
1688  intelxl->port = INTELXL_PFGEN_PORTNUM_PORT_NUM ( pfgen_portnum );
1689  pflan_qalloc = readl ( intelxl->regs + INTELXL_PFLAN_QALLOC );
1690  intelxl->base = INTELXL_PFLAN_QALLOC_FIRSTQ ( pflan_qalloc );
1691  DBGC ( intelxl, "INTELXL %p PF %d using port %d queues [%#04x-%#04x]\n",
1692  intelxl, intelxl->pf, intelxl->port, intelxl->base,
1693  INTELXL_PFLAN_QALLOC_LASTQ ( pflan_qalloc ) );
1694 
1695  /* Fetch MAC address and maximum frame size */
1696  if ( ( rc = intelxl_fetch_mac ( intelxl, netdev ) ) != 0 )
1697  goto err_fetch_mac;
1698 
1699  /* Enable MSI-X dummy interrupt */
1700  if ( ( rc = intelxl_msix_enable ( intelxl, pci ) ) != 0 )
1701  goto err_msix;
1702 
1703  /* Open admin queues */
1704  if ( ( rc = intelxl_open_admin ( intelxl ) ) != 0 )
1705  goto err_open_admin;
1706 
1707  /* Clear PXE mode */
1708  if ( ( rc = intelxl_admin_clear_pxe ( intelxl ) ) != 0 )
1709  goto err_admin_clear_pxe;
1710 
1711  /* Get switch configuration */
1712  if ( ( rc = intelxl_admin_switch ( intelxl ) ) != 0 )
1713  goto err_admin_switch;
1714 
1715  /* Get VSI configuration */
1716  if ( ( rc = intelxl_admin_vsi ( intelxl ) ) != 0 )
1717  goto err_admin_vsi;
1718 
1719  /* Configure switch for promiscuous mode */
1720  if ( ( rc = intelxl_admin_promisc ( intelxl ) ) != 0 )
1721  goto err_admin_promisc;
1722 
1723  /* Configure queue register addresses */
1724  intelxl->tx.reg = INTELXL_QTX ( intelxl->queue );
1725  intelxl->tx.tail = ( intelxl->tx.reg + INTELXL_QXX_TAIL );
1726  intelxl->rx.reg = INTELXL_QRX ( intelxl->queue );
1727  intelxl->rx.tail = ( intelxl->rx.reg + INTELXL_QXX_TAIL );
1728 
1729  /* Configure interrupt causes */
1732  intelxl->regs + INTELXL_QINT_TQCTL ( intelxl->queue ) );
1733  writel ( ( INTELXL_QINT_RQCTL_NEXTQ_INDX ( intelxl->queue ) |
1736  intelxl->regs + INTELXL_QINT_RQCTL ( intelxl->queue ) );
1739  intelxl->regs + INTELXL_PFINT_LNKLST0 );
1741  intelxl->regs + INTELXL_PFINT_ICR0_ENA );
1742 
1743  /* Register network device */
1744  if ( ( rc = register_netdev ( netdev ) ) != 0 )
1745  goto err_register_netdev;
1746 
1747  /* Set initial link state */
1749 
1750  return 0;
1751 
1753  err_register_netdev:
1754  err_admin_promisc:
1755  err_admin_vsi:
1756  err_admin_switch:
1757  err_admin_clear_pxe:
1758  intelxl_close_admin ( intelxl );
1759  err_open_admin:
1760  intelxl_msix_disable ( intelxl, pci );
1761  err_msix:
1762  err_fetch_mac:
1763  intelxl_reset ( intelxl );
1764  err_reset:
1765  iounmap ( intelxl->regs );
1766  err_ioremap:
1767  netdev_nullify ( netdev );
1768  netdev_put ( netdev );
1769  err_alloc:
1770  return rc;
1771 }
static int intelxl_admin_promisc(struct intelxl_nic *intelxl)
Set VSI promiscuous modes.
Definition: intelxl.c:658
Receive queue context.
Definition: intelxl.h:674
#define PCI_FUNC(busdevfn)
Definition: pci.h:258
#define INTELXL_PFLAN_QALLOC_FIRSTQ(x)
First queue.
Definition: intelxl.h:997
void * regs
Registers.
Definition: intelxl.h:1030
#define INTELXL_QRX(x)
Global Receive Queue register block.
Definition: intelxl.h:743
unsigned long membase
Memory base.
Definition: pci.h:194
#define INTELXL_PFLAN_QALLOC_LASTQ(x)
Last queue.
Definition: intelxl.h:1000
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int intelxl_admin_switch(struct intelxl_nic *intelxl)
Get switch configuration.
Definition: intelxl.c:572
#define INTELXL_ADMIN_EVT
PF Admin Event Queue register block.
Definition: intelxl.h:38
#define INTELXL_PFLAN_QALLOC
PF Queue Allocation Register.
Definition: intelxl.h:996
#define INTELXL_QINT_RQCTL_NEXTQ_INDX(x)
Queue index.
Definition: intelxl.h:966
#define INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE
End of list.
Definition: intelxl.h:979
#define INTELXL_ADMIN_CMD
PF Admin Command Queue register block.
Definition: intelxl.h:35
void intelxl_msix_disable(struct intelxl_nic *intelxl, struct pci_device *pci)
Disable MSI-X dummy interrupt.
Definition: intelxl.c:159
Admin queue register offsets.
Definition: intelxl.h:62
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTELXL_PFINT_ICR0_ENA
PF Interrupt Zero Cause Enablement Register.
Definition: intelxl.h:961
struct intelxl_admin command
Admin command queue.
Definition: intelxl.h:1056
#define INTELXL_PFINT_ICR0_ENA_ADMINQ
Admin event.
Definition: intelxl.h:962
#define INTELXL_PFGEN_PORTNUM_PORT_NUM(x)
Port number.
Definition: intelxl.h:1006
int intelxl_open_admin(struct intelxl_nic *intelxl)
Open admin queues.
Definition: intelxl.c:833
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 queue
Queue number.
Definition: intelxl.h:1041
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
#define INTELXL_PFGEN_PORTNUM
PF LAN Port Number Register.
Definition: intelxl.h:1005
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
#define INTELXL_QINT_TQCTL_CAUSE_ENA
Enable.
Definition: intelxl.h:986
static int intelxl_reset(struct intelxl_nic *intelxl)
Reset hardware.
Definition: intelxl.c:61
#define INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX
Receive queue.
Definition: intelxl.h:955
#define INTELXL_PFINT_DYN_CTL0
PF Interrupt Zero Dynamic Control Register.
Definition: intelxl.h:940
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
#define INTELXL_QINT_RQCTL_CAUSE_ENA
Enable.
Definition: intelxl.h:974
#define INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX
Transmit queue.
Definition: intelxl.h:972
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition: intelxl.h:915
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 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
unsigned int reg
Register block.
Definition: intelxl.h:880
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 INTELXL_QTX(x)
Global Transmit Queue register block.
Definition: intelxl.h:740
#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
unsigned int port
Port number.
Definition: intelxl.h:1039
An Intel 40Gigabit network card.
Definition: intelxl.h:1028
#define INTELXL_PFINT_LNKLST0
PF Interrupt Zero Linked List Register.
Definition: intelxl.h:946
unsigned int uint32_t
Definition: stdint.h:12
static void intelxl_init_ring(struct intelxl_ring *ring, unsigned int count, size_t len, int(*context)(struct intelxl_nic *intelxl, physaddr_t address))
Initialise descriptor ring.
Definition: intelxl.h:902
struct intelxl_ring tx
Transmit descriptor ring.
Definition: intelxl.h:1068
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
#define INTELXL_QINT_TQCTL(x)
Transmit Queue Interrupt Cause Control Register.
Definition: intelxl.h:977
unsigned int pf
Physical function number.
Definition: intelxl.h:1035
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:210
#define INTELXL_QXX_TAIL
Queue Tail Pointer Register (offset)
Definition: intelxl.h:758
static int intelxl_admin_clear_pxe(struct intelxl_nic *intelxl)
Clear PXE mode.
Definition: intelxl.c:539
#define INTELXL_PFINT_LNKLST0_FIRSTQ_INDX(x)
Queue index.
Definition: intelxl.h:947
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
unsigned int base
Absolute queue number base.
Definition: intelxl.h:1037
void iounmap(volatile const void *io_addr)
Unmap I/O address.
unsigned int tail
Tail register.
Definition: intelxl.h:882
#define INTELXL_QINT_RQCTL(x)
Receive Queue Interrupt Cause Control Register.
Definition: intelxl.h:965
#define INTELXL_BAR_SIZE
BAR size.
Definition: intelxl.h:19
static int intelxl_admin_vsi(struct intelxl_nic *intelxl)
Get VSI parameters.
Definition: intelxl.c:624
static int intelxl_fetch_mac(struct intelxl_nic *intelxl, struct net_device *netdev)
Fetch initial MAC address and maximum frame size.
Definition: intelxl.c:87
void intelxl_close_admin(struct intelxl_nic *intelxl)
Close admin queues.
Definition: intelxl.c:895
static struct net_device_operations intelxl_operations
Network device operations.
Definition: intelxl.c:1621
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
static int intelxl_admin_link(struct net_device *netdev)
Get link status.
Definition: intelxl.c:714
Transmit queue context.
Definition: intelxl.h:642
struct intelxl_admin event
Admin event queue.
Definition: intelxl.h:1058
void * memset(void *dest, int character, size_t len) __nonnull

References adjust_pci_device(), alloc_etherdev(), intelxl_nic::base, pci_device::busdevfn, intelxl_nic::command, DBGC, intelxl_ring::desc, pci_device::dev, net_device::dev, ENODEV, ENOMEM, intelxl_nic::event, intelxl_admin_clear_pxe(), INTELXL_ADMIN_CMD, INTELXL_ADMIN_EVT, intelxl_admin_link(), intelxl_admin_promisc(), intelxl_admin_switch(), intelxl_admin_vsi(), INTELXL_BAR_SIZE, intelxl_close_admin(), intelxl_fetch_mac(), intelxl_init_admin(), intelxl_init_ring(), intelxl_msix_disable(), intelxl_msix_enable(), intelxl_open_admin(), intelxl_operations, INTELXL_PFGEN_PORTNUM, INTELXL_PFGEN_PORTNUM_PORT_NUM, INTELXL_PFINT_DYN_CTL0, INTELXL_PFINT_ICR0_ENA, INTELXL_PFINT_ICR0_ENA_ADMINQ, INTELXL_PFINT_LNKLST0, INTELXL_PFINT_LNKLST0_FIRSTQ_INDX, INTELXL_PFINT_LNKLST0_FIRSTQ_TYPE_RX, INTELXL_PFLAN_QALLOC, INTELXL_PFLAN_QALLOC_FIRSTQ, INTELXL_PFLAN_QALLOC_LASTQ, INTELXL_QINT_RQCTL, INTELXL_QINT_RQCTL_CAUSE_ENA, INTELXL_QINT_RQCTL_NEXTQ_INDX, INTELXL_QINT_RQCTL_NEXTQ_TYPE_TX, INTELXL_QINT_TQCTL, INTELXL_QINT_TQCTL_CAUSE_ENA, INTELXL_QINT_TQCTL_NEXTQ_INDX_NONE, INTELXL_QRX, INTELXL_QTX, INTELXL_QXX_TAIL, intelxl_reset(), INTELXL_RX_NUM_DESC, INTELXL_TX_NUM_DESC, intelxl_nic::intr, ioremap(), iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), PCI_FUNC, pci_set_drvdata(), intelxl_nic::pf, intelxl_nic::port, net_device::priv, intelxl_nic::queue, rc, readl(), intelxl_ring::reg, register_netdev(), intelxl_nic::regs, intelxl_ring::rx, intelxl_nic::rx, intelxl_ring::tail, intelxl_ring::tx, intelxl_nic::tx, unregister_netdev(), and writel().

◆ intelxl_remove()

static void intelxl_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 1778 of file intelxl.c.

1778  {
1779  struct net_device *netdev = pci_get_drvdata ( pci );
1780  struct intelxl_nic *intelxl = netdev->priv;
1781 
1782  /* Unregister network device */
1784 
1785  /* Close admin queues */
1786  intelxl_close_admin ( intelxl );
1787 
1788  /* Disable MSI-X dummy interrupt */
1789  intelxl_msix_disable ( intelxl, pci );
1790 
1791  /* Reset the NIC */
1792  intelxl_reset ( intelxl );
1793 
1794  /* Free network device */
1795  iounmap ( intelxl->regs );
1796  netdev_nullify ( netdev );
1797  netdev_put ( netdev );
1798 }
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 int intelxl_reset(struct intelxl_nic *intelxl)
Reset hardware.
Definition: intelxl.c:61
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 * 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

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

Variable Documentation

◆ intelxl_admin_offsets

Initial value:
= {
}
#define INTELXL_ADMIN_BAH
Admin Queue Base Address High Register (offset)
Definition: intelxl.h:44
#define INTELXL_ADMIN_BAL
Admin Queue Base Address Low Register (offset)
Definition: intelxl.h:41
#define INTELXL_ADMIN_TAIL
Admin Queue Tail Register (offset)
Definition: intelxl.h:55
#define INTELXL_ADMIN_LEN
Admin Queue Length Register (offset)
Definition: intelxl.h:47
#define INTELXL_ADMIN_HEAD
Admin Queue Head Register (offset)
Definition: intelxl.h:52

Admin queue register offsets.

Definition at line 177 of file intelxl.c.

◆ intelxl_operations

struct net_device_operations intelxl_operations
static
Initial value:
= {
.open = intelxl_open,
.close = intelxl_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 int intelxl_open(struct net_device *netdev)
Open network device.
Definition: intelxl.c:1361
static void intelxl_close(struct net_device *netdev)
Close network device.
Definition: intelxl.c:1431
void intelxl_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: intelxl.c:1587

Network device operations.

Definition at line 1621 of file intelxl.c.

Referenced by intelxl_probe().

◆ intelxl_nics

struct pci_device_id intelxl_nics[]
static
Initial value:
= {
PCI_ROM ( 0x8086, 0x1572, "x710-sfp", "X710 10GbE SFP+", 0 ),
PCI_ROM ( 0x8086, 0x1574, "xl710-qemu", "Virtual XL710", 0 ),
PCI_ROM ( 0x8086, 0x1580, "xl710-kx-b", "XL710 40GbE backplane", 0 ),
PCI_ROM ( 0x8086, 0x1581, "xl710-kx-c", "XL710 10GbE backplane", 0 ),
PCI_ROM ( 0x8086, 0x1583, "xl710-qda2", "XL710 40GbE QSFP+", 0 ),
PCI_ROM ( 0x8086, 0x1584, "xl710-qda1", "XL710 40GbE QSFP+", 0 ),
PCI_ROM ( 0x8086, 0x1585, "x710-qsfp", "X710 10GbE QSFP+", 0 ),
PCI_ROM ( 0x8086, 0x1586, "x710-10gt", "X710 10GBASE-T", 0 ),
PCI_ROM ( 0x8086, 0x1587, "x710-kr2", "XL710 20GbE backplane", 0 ),
PCI_ROM ( 0x8086, 0x1588, "x710-kr2-a", "XL710 20GbE backplane", 0 ),
PCI_ROM ( 0x8086, 0x1589, "x710-10gt4", "X710 10GBASE-T4", 0 ),
PCI_ROM ( 0x8086, 0x158a, "xxv710", "XXV710 25GbE backplane", 0 ),
PCI_ROM ( 0x8086, 0x158b, "xxv710-sfp28", "XXV710 25GbE SFP28", 0 ),
PCI_ROM ( 0x8086, 0x37ce, "x722-kx", "X722 10GbE backplane", 0 ),
PCI_ROM ( 0x8086, 0x37cf, "x722-qsfp", "X722 10GbE QSFP+", 0 ),
PCI_ROM ( 0x8086, 0x37d0, "x722-sfp", "X722 10GbE SFP+", 0 ),
PCI_ROM ( 0x8086, 0x37d1, "x722-1gt", "X722 1GBASE-T", 0 ),
PCI_ROM ( 0x8086, 0x37d2, "x722-10gt", "X722 10GBASE-T", 0 ),
PCI_ROM ( 0x8086, 0x37d3, "x722-sfp-i", "X722 10GbE SFP+", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

PCI device IDs.

Definition at line 1801 of file intelxl.c.

◆ __pci_driver

struct pci_driver intelxl_driver __pci_driver
Initial value:
= {
.ids = intelxl_nics,
.id_count = ( sizeof ( intelxl_nics ) / sizeof ( intelxl_nics[0] ) ),
.probe = intelxl_probe,
}
static struct pci_device_id intelxl_nics[]
PCI device IDs.
Definition: intelxl.c:1801
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static int intelxl_probe(struct pci_device *pci)
Probe PCI device.
Definition: intelxl.c:1641
static void intelxl_remove(struct pci_device *pci)
Remove PCI device.
Definition: intelxl.c:1778

PCI driver.

Definition at line 1824 of file intelxl.c.