iPXE
intelxlvf.c File Reference

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

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

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int intelxlvf_reset_wait_teardown (struct intelxl_nic *intelxl)
 Wait for admin event queue to be torn down.
static int intelxlvf_reset_wait_active (struct intelxl_nic *intelxl)
 Wait for virtual function to be marked as active.
static int intelxlvf_reset_wait (struct intelxl_nic *intelxl)
 Wait for reset to complete.
static int intelxlvf_reset_admin (struct intelxl_nic *intelxl)
 Reset hardware via admin queue.
static int intelxlvf_admin_command (struct net_device *netdev)
 Issue admin queue virtual function command.
static void intelxlvf_admin_link (struct net_device *netdev, struct intelxlvf_admin_status_link *link)
 Handle link status event.
static void intelxlvf_admin_status (struct net_device *netdev, struct intelxlvf_admin_status_buffer *stat)
 Handle status change event.
static void intelxlvf_admin_event (struct net_device *netdev, struct intelxl_admin_descriptor *xlevt, union intelxl_admin_buffer *xlbuf)
 Handle admin event.
static int intelxlvf_admin_version (struct net_device *netdev)
 Negotiate API version.
static int intelxlvf_admin_get_resources (struct net_device *netdev)
 Get resources.
static int intelxlvf_admin_stats (struct net_device *netdev)
 Get statistics (for debugging)
static int intelxlvf_admin_request_qps (struct net_device *netdev)
 Configure number of queue pairs.
static int intelxlvf_admin_configure (struct net_device *netdev)
 Configure queues.
static int intelxlvf_admin_irq_map (struct net_device *netdev)
 Configure IRQ mapping.
static int intelxlvf_admin_queues (struct net_device *netdev, int enable)
 Enable/disable queues.
static int intelxlvf_admin_promisc (struct net_device *netdev)
 Configure promiscuous mode.
static int intelxlvf_open (struct net_device *netdev)
 Open network device.
static void intelxlvf_close (struct net_device *netdev)
 Close network device.
static int intelxlvf_probe (struct pci_device *pci)
 Probe PCI device.
static void intelxlvf_remove (struct pci_device *pci)
 Remove PCI device.

Variables

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

Detailed Description

Intel 40 Gigabit Ethernet virtual function network card driver.

Definition in file intelxlvf.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ intelxlvf_reset_wait_teardown()

int intelxlvf_reset_wait_teardown ( struct intelxl_nic * intelxl)
static

Wait for admin event queue to be torn down.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 55 of file intelxlvf.c.

55 {
56 uint32_t admin_evt_len;
57 unsigned int i;
58
59 /* Wait for admin event queue to be torn down */
60 for ( i = 0 ; i < INTELXLVF_RESET_MAX_WAIT_MS ; i++ ) {
61
62 /* Check admin event queue length register */
63 admin_evt_len = readl ( intelxl->regs + INTELXLVF_ADMIN +
65 if ( ! ( admin_evt_len & INTELXL_ADMIN_LEN_ENABLE ) )
66 return 0;
67
68 /* Delay */
69 mdelay ( 1 );
70 }
71
72 DBGC ( intelxl, "INTELXL %p timed out waiting for teardown (%#08x)\n",
73 intelxl, admin_evt_len );
74 return -ETIMEDOUT;
75}
unsigned int uint32_t
Definition stdint.h:12
#define DBGC(...)
Definition compiler.h:505
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define INTELXL_ADMIN_LEN_ENABLE
Queue enable.
Definition intelxl.h:51
#define INTELXLVF_ADMIN_EVT_LEN
Admin Event Queue Length Register (offset)
Definition intelxlvf.h:63
#define INTELXLVF_RESET_MAX_WAIT_MS
Maximum time to wait for reset to complete.
Definition intelxlvf.h:404
#define INTELXLVF_ADMIN
VF Admin Queue register block.
Definition intelxlvf.h:39
void * regs
Registers.
Definition intelxl.h:901
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79
#define readl
Definition w89c840.c:157

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

Referenced by intelxlvf_reset_wait().

◆ intelxlvf_reset_wait_active()

int intelxlvf_reset_wait_active ( struct intelxl_nic * intelxl)
static

Wait for virtual function to be marked as active.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 83 of file intelxlvf.c.

83 {
84 uint32_t vfgen_rstat;
85 unsigned int vfr_state;
86 unsigned int i;
87
88 /* Wait for virtual function to be marked as active */
89 for ( i = 0 ; i < INTELXLVF_RESET_MAX_WAIT_MS ; i++ ) {
90
91 /* Check status as written by physical function driver */
92 vfgen_rstat = readl ( intelxl->regs + INTELXLVF_VFGEN_RSTAT );
93 vfr_state = INTELXLVF_VFGEN_RSTAT_VFR_STATE ( vfgen_rstat );
95 return 0;
96
97 /* Delay */
98 mdelay ( 1 );
99 }
100
101 DBGC ( intelxl, "INTELXL %p timed out waiting for activation "
102 "(%#08x)\n", intelxl, vfgen_rstat );
103 return -ETIMEDOUT;
104}
#define INTELXLVF_VFGEN_RSTAT
VF Reset Status Register.
Definition intelxlvf.h:396
#define INTELXLVF_VFGEN_RSTAT_VFR_STATE(x)
Definition intelxlvf.h:397
#define INTELXLVF_VFGEN_RSTAT_VFR_STATE_ACTIVE
Definition intelxlvf.h:398

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

Referenced by intelxlvf_reset_wait().

◆ intelxlvf_reset_wait()

int intelxlvf_reset_wait ( struct intelxl_nic * intelxl)
static

Wait for reset to complete.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 112 of file intelxlvf.c.

112 {
113 int rc;
114
115 /* Wait for minimum reset time */
117
118 /* Wait for reset to take effect */
119 if ( ( rc = intelxlvf_reset_wait_teardown ( intelxl ) ) != 0 )
120 goto err_teardown;
121
122 /* Wait for virtual function to become active */
123 if ( ( rc = intelxlvf_reset_wait_active ( intelxl ) ) != 0 )
124 goto err_active;
125
126 err_active:
127 err_teardown:
128 intelxl_reopen_admin ( intelxl );
129 return rc;
130}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
void intelxl_reopen_admin(struct intelxl_nic *intelxl)
Reopen admin queues (after virtual function reset)
Definition intelxl.c:907
static int intelxlvf_reset_wait_teardown(struct intelxl_nic *intelxl)
Wait for admin event queue to be torn down.
Definition intelxlvf.c:55
static int intelxlvf_reset_wait_active(struct intelxl_nic *intelxl)
Wait for virtual function to be marked as active.
Definition intelxlvf.c:83
#define INTELXLVF_RESET_DELAY_MS
Minimum time to wait for reset to complete.
Definition intelxlvf.h:401

References intelxl_reopen_admin(), INTELXLVF_RESET_DELAY_MS, intelxlvf_reset_wait_active(), intelxlvf_reset_wait_teardown(), mdelay(), and rc.

Referenced by intelxlvf_admin_request_qps(), and intelxlvf_reset_admin().

◆ intelxlvf_reset_admin()

int intelxlvf_reset_admin ( struct intelxl_nic * intelxl)
static

Reset hardware via admin queue.

Parameters
intelxlIntel device
Return values
rcReturn status code

Definition at line 138 of file intelxlvf.c.

138 {
140 int rc;
141
142 /* Populate descriptor */
146
147 /* Issue command */
148 if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
149 return rc;
150
151 /* Wait for reset to complete */
152 if ( ( rc = intelxlvf_reset_wait ( intelxl ) ) != 0 )
153 return rc;
154
155 return 0;
156}
struct golan_eqe_cmd cmd
Definition CIB_PRM.h:1
#define cpu_to_le32(value)
Definition byteswap.h:108
#define cpu_to_le16(value)
Definition byteswap.h:107
int intelxl_admin_command(struct intelxl_nic *intelxl)
Issue admin queue command.
Definition intelxl.c:278
static int intelxlvf_reset_wait(struct intelxl_nic *intelxl)
Wait for reset to complete.
Definition intelxlvf.c:112
#define INTELXLVF_ADMIN_SEND_TO_PF
Admin queue Send Message to PF command.
Definition intelxlvf.h:75
struct intelxlvf_admin_descriptor * intelxlvf_admin_command_descriptor(struct intelxl_nic *intelxl)
Get next admin command queue descriptor.
Definition intelxlvf.h:374
#define INTELXLVF_ADMIN_RESET
Admin Queue VF Reset opcode.
Definition intelxlvf.h:98
Admin queue descriptor.
Definition intelxlvf.h:342

References cmd, cpu_to_le16, cpu_to_le32, intelxl_admin_command(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_RESET, INTELXLVF_ADMIN_SEND_TO_PF, intelxlvf_reset_wait(), and rc.

Referenced by intelxlvf_probe(), and intelxlvf_remove().

◆ intelxlvf_admin_command()

int intelxlvf_admin_command ( struct net_device * netdev)
static

Issue admin queue virtual function command.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 189 of file intelxlvf.c.

189 {
190 struct intelxl_nic *intelxl = netdev->priv;
191 struct intelxl_admin *admin = &intelxl->command;
192 struct intelxl_admin_descriptor *xlcmd;
194 unsigned int i;
195 int rc;
196
197 /* Populate descriptor */
198 xlcmd = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
199 cmd = container_of ( xlcmd, struct intelxlvf_admin_descriptor, xl );
201
202 /* Record opcode */
203 intelxl->vopcode = le32_to_cpu ( cmd->vopcode );
204
205 /* Issue command */
206 if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
207 goto err_command;
208
209 /* Wait for response */
210 for ( i = 0 ; i < INTELXLVF_ADMIN_MAX_WAIT_MS ; i++ ) {
211
212 /* Poll admin event queue */
214
215 /* If response has not arrived, delay 1ms and retry */
216 if ( intelxl->vopcode ) {
217 mdelay ( 1 );
218 continue;
219 }
220
221 /* Check for errors */
222 if ( cmd->vret != 0 )
223 return -EIO;
224
225 return 0;
226 }
227
228 rc = -ETIMEDOUT;
229 DBGC ( intelxl, "INTELXL %p timed out waiting for admin VF command "
230 "%#x\n", intelxl, intelxl->vopcode );
231 err_command:
232 intelxl->vopcode = 0;
233 return rc;
234}
static struct net_device * netdev
Definition gdbudp.c:53
#define EIO
Input/output error.
Definition errno.h:434
#define le32_to_cpu(value)
Definition byteswap.h:114
void intelxl_poll_admin(struct net_device *netdev)
Poll admin event queue.
Definition intelxl.c:836
#define INTELXL_ADMIN_NUM_DESC
Number of admin queue descriptors.
Definition intelxl.h:484
#define INTELXLVF_ADMIN_MAX_WAIT_MS
Maximum time to wait for a VF admin request to complete.
Definition intelxlvf.h:72
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
Admin queue descriptor.
Definition intelxl.h:416
Admin queue.
Definition intelxl.h:452
struct intelxl_admin_descriptor * desc
Descriptors.
Definition intelxl.h:454
unsigned int index
Queue index.
Definition intelxl.h:460
An Intel 40 Gigabit network card.
Definition intelxl.h:899
unsigned int vopcode
Current VF opcode.
Definition intelxl.h:936
struct intelxl_admin command
Admin command queue.
Definition intelxl.h:931
struct intelxl_admin_descriptor xl
Original 40 Gigabit Ethernet descriptor.
Definition intelxlvf.h:346

References cmd, intelxl_nic::command, container_of, cpu_to_le16, DBGC, intelxl_admin::desc, EIO, ETIMEDOUT, intelxl_admin::index, intelxl_admin_command(), INTELXL_ADMIN_NUM_DESC, intelxl_poll_admin(), INTELXLVF_ADMIN_MAX_WAIT_MS, INTELXLVF_ADMIN_SEND_TO_PF, le32_to_cpu, mdelay(), netdev, rc, intelxl_nic::vopcode, and intelxlvf_admin_descriptor::xl.

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

◆ intelxlvf_admin_link()

void intelxlvf_admin_link ( struct net_device * netdev,
struct intelxlvf_admin_status_link * link )
static

Handle link status event.

Parameters
netdevNetwork device
linkLink status

Definition at line 242 of file intelxlvf.c.

243 {
244 struct intelxl_nic *intelxl = netdev->priv;
245
246 DBGC ( intelxl, "INTELXL %p link %#02x speed %#02x\n", intelxl,
247 link->status, link->speed );
248
249 /* Update network device */
250 if ( link->status ) {
252 } else {
254 }
255}
u32 link
Link to next descriptor.
Definition ar9003_mac.h:1
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition netdevice.c:231
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:789

References DBGC, link, netdev, netdev_link_down(), and netdev_link_up().

Referenced by intelxlvf_admin_status().

◆ intelxlvf_admin_status()

void intelxlvf_admin_status ( struct net_device * netdev,
struct intelxlvf_admin_status_buffer * stat )
static

Handle status change event.

Parameters
netdevNetwork device
statStatus change event

Definition at line 264 of file intelxlvf.c.

265 {
266 struct intelxl_nic *intelxl = netdev->priv;
267
268 /* Handle event */
269 switch ( stat->event ) {
272 break;
273 default:
274 DBGC ( intelxl, "INTELXL %p unrecognised status change "
275 "event %#x:\n", intelxl, le32_to_cpu ( stat->event ) );
276 DBGC_HDA ( intelxl, 0, stat, sizeof ( *stat ) );
277 break;
278 }
279}
uint32_t stat
Completion status.
Definition dwmac.h:1
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define DBGC_HDA(...)
Definition compiler.h:506
static void intelxlvf_admin_link(struct net_device *netdev, struct intelxlvf_admin_status_link *link)
Handle link status event.
Definition intelxlvf.c:242
#define INTELXLVF_ADMIN_STATUS_LINK
Link status change event type.
Definition intelxlvf.h:141

References cpu_to_le32, DBGC, DBGC_HDA, intelxlvf_admin_link(), INTELXLVF_ADMIN_STATUS_LINK, le32_to_cpu, netdev, and stat.

Referenced by intelxlvf_admin_event().

◆ intelxlvf_admin_event()

void intelxlvf_admin_event ( struct net_device * netdev,
struct intelxl_admin_descriptor * xlevt,
union intelxl_admin_buffer * xlbuf )
static

Handle admin event.

Parameters
netdevNetwork device
xlevtAdmin queue event descriptor
xlbufAdmin queue event data buffer

Definition at line 288 of file intelxlvf.c.

290 {
291 struct intelxl_nic *intelxl = netdev->priv;
292 struct intelxl_admin *admin = &intelxl->command;
293 struct intelxlvf_admin_descriptor *evt =
294 container_of ( xlevt, struct intelxlvf_admin_descriptor, xl );
295 union intelxlvf_admin_buffer *buf =
296 container_of ( xlbuf, union intelxlvf_admin_buffer, xl );
297 unsigned int vopcode;
298 unsigned int index;
299
300 /* Ignore unrecognised events */
302 DBGC ( intelxl, "INTELXL %p unrecognised event opcode "
303 "%#04x\n", intelxl, le16_to_cpu ( evt->opcode ) );
304 return;
305 }
306
307 /* Record command response if applicable */
308 vopcode = le32_to_cpu ( evt->vopcode );
309 if ( vopcode == intelxl->vopcode ) {
310 index = ( ( admin->index - 1 ) % INTELXL_ADMIN_NUM_DESC );
311 memcpy ( &admin->desc[index], evt, sizeof ( *evt ) );
312 memcpy ( &admin->buf[index], buf, sizeof ( *buf ) );
313 intelxl->vopcode = 0;
314 if ( evt->vret != 0 ) {
315 DBGC ( intelxl, "INTELXL %p admin VF command %#x "
316 "error %d\n", intelxl, vopcode,
317 le32_to_cpu ( evt->vret ) );
318 DBGC_HDA ( intelxl, virt_to_phys ( evt ), evt,
319 sizeof ( *evt ) );
320 DBGC_HDA ( intelxl, virt_to_phys ( buf ), buf,
321 le16_to_cpu ( evt->len ) );
322 }
323 return;
324 }
325
326 /* Handle unsolicited events */
327 switch ( vopcode ) {
330 break;
331 default:
332 DBGC ( intelxl, "INTELXL %p unrecognised VF event %#x:\n",
333 intelxl, vopcode );
334 DBGC_HDA ( intelxl, virt_to_phys ( evt ), evt,
335 sizeof ( *evt ) );
336 DBGC_HDA ( intelxl, virt_to_phys ( buf ), buf,
337 le16_to_cpu ( evt->len ) );
338 break;
339 }
340}
long index
Definition bigint.h:65
#define le16_to_cpu(value)
Definition byteswap.h:113
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void intelxlvf_admin_status(struct net_device *netdev, struct intelxlvf_admin_status_buffer *stat)
Handle status change event.
Definition intelxlvf.c:264
#define INTELXLVF_ADMIN_STATUS
Admin Queue VF Status Change Event opcode.
Definition intelxlvf.h:138
#define INTELXLVF_ADMIN_SEND_TO_VF
Admin queue Send Message to VF command.
Definition intelxlvf.h:78
union intelxl_admin_buffer * buf
Data buffers.
Definition intelxl.h:456
uint16_t opcode
Opcode.
Definition intelxlvf.h:352
uint16_t len
Data length.
Definition intelxlvf.h:354
uint32_t vopcode
VF opcode.
Definition intelxlvf.h:358
int32_t vret
VF return value.
Definition intelxlvf.h:360
Admin queue data buffer.
Definition intelxlvf.h:316
struct intelxlvf_admin_status_buffer stat
VF Status Change Event data buffer.
Definition intelxlvf.h:326
union intelxl_admin_buffer xl
Original 40 Gigabit Ethernet data buffer.
Definition intelxlvf.h:318

References intelxl_admin::buf, intelxl_nic::command, container_of, cpu_to_le16, DBGC, DBGC_HDA, intelxl_admin::desc, index, intelxl_admin::index, INTELXL_ADMIN_NUM_DESC, INTELXLVF_ADMIN_SEND_TO_VF, INTELXLVF_ADMIN_STATUS, intelxlvf_admin_status(), le16_to_cpu, le32_to_cpu, intelxlvf_admin_descriptor::len, memcpy(), netdev, intelxlvf_admin_descriptor::opcode, intelxlvf_admin_buffer::stat, intelxl_nic::vopcode, intelxlvf_admin_descriptor::vopcode, intelxlvf_admin_descriptor::vret, intelxlvf_admin_buffer::xl, and intelxlvf_admin_descriptor::xl.

Referenced by intelxlvf_probe().

◆ intelxlvf_admin_version()

int intelxlvf_admin_version ( struct net_device * netdev)
static

Negotiate API version.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 348 of file intelxlvf.c.

348 {
349 struct intelxl_nic *intelxl = netdev->priv;
351 union intelxlvf_admin_buffer *buf;
352 unsigned int api;
353 int rc;
354
355 /* Populate descriptor */
359 cmd->len = cpu_to_le16 ( sizeof ( buf->ver ) );
360 buf = intelxlvf_admin_command_buffer ( intelxl );
363
364 /* Issue command */
365 if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
366 return rc;
367 api = le32_to_cpu ( buf->ver.major );
368 DBGC ( intelxl, "INTELXL %p API v%d.%d\n",
369 intelxl, api, le32_to_cpu ( buf->ver.minor ) );
370
371 /* Check for API compatibility */
373 DBGC ( intelxl, "INTELXL %p unsupported API v%d\n",
374 intelxl, api );
375 return -ENOTSUP;
376 }
377
378 return 0;
379}
#define ENOTSUP
Operation not supported.
Definition errno.h:590
#define INTELXL_ADMIN_FL_BUF
Admin descriptor uses data buffer.
Definition intelxl.h:446
#define INTELXL_ADMIN_FL_RD
Admin descriptor uses data buffer for command parameters.
Definition intelxl.h:443
static int intelxlvf_admin_command(struct net_device *netdev)
Issue admin queue virtual function command.
Definition intelxlvf.c:189
#define INTELXLVF_ADMIN_API_MAJOR
Admin queue VF API major version.
Definition intelxlvf.h:92
#define INTELXLVF_ADMIN_VERSION
Admin Queue VF Version opcode.
Definition intelxlvf.h:81
#define INTELXLVF_ADMIN_API_MINOR
Admin queue VF API minor version.
Definition intelxlvf.h:95
static union intelxlvf_admin_buffer * intelxlvf_admin_command_buffer(struct intelxl_nic *intelxl)
Get next admin command queue data buffer.
Definition intelxlvf.h:388
struct pci_api * api
API for this bus:dev.fn address.
Definition pcicloud.c:42
uint32_t major
Major version.
Definition intelxlvf.h:86
uint32_t minor
Minor version.
Definition intelxlvf.h:88
struct intelxlvf_admin_version_buffer ver
VF Version data buffer.
Definition intelxlvf.h:320

References api, cmd, cpu_to_le16, cpu_to_le32, DBGC, ENOTSUP, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXLVF_ADMIN_API_MAJOR, INTELXLVF_ADMIN_API_MINOR, intelxlvf_admin_command(), intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_VERSION, le32_to_cpu, intelxlvf_admin_version_buffer::major, intelxlvf_admin_version_buffer::minor, netdev, rc, and intelxlvf_admin_buffer::ver.

Referenced by intelxlvf_probe().

◆ intelxlvf_admin_get_resources()

int intelxlvf_admin_get_resources ( struct net_device * netdev)
static

Get resources.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 387 of file intelxlvf.c.

387 {
388 struct intelxl_nic *intelxl = netdev->priv;
390 union intelxlvf_admin_buffer *buf;
391 int rc;
392
393 /* Populate descriptor */
397 cmd->len = cpu_to_le16 ( sizeof ( buf->caps ) );
398 buf = intelxlvf_admin_command_buffer ( intelxl );
401
402 /* Issue command */
403 if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
404 return rc;
405
406 /* Parse response */
407 intelxl->caps = le32_to_cpu ( buf->res.caps );
408 intelxl->vsi = le16_to_cpu ( buf->res.vsi );
409 memcpy ( netdev->hw_addr, buf->res.mac, ETH_ALEN );
410 DBGC ( intelxl, "INTELXL %p capabilities %#08x VSI %#04x\n",
411 intelxl, intelxl->caps, intelxl->vsi );
412
413 return 0;
414}
#define ETH_ALEN
Definition if_ether.h:9
#define INTELXLVF_ADMIN_CAP_L2
Layer 2 capabilities (add/remove MAC, configure promiscuous mode)
Definition intelxlvf.h:132
#define INTELXLVF_ADMIN_GET_RESOURCES
Admin Queue VF Get Resources opcode.
Definition intelxlvf.h:101
#define INTELXLVF_ADMIN_CAP_RQPS
Request Queues capabilities.
Definition intelxlvf.h:135
unsigned int vsi
Virtual Station Interface switching element ID.
Definition intelxl.h:916
uint32_t caps
Device capabilities.
Definition intelxl.h:922
uint16_t vsi
VSI switching element ID.
Definition intelxlvf.h:124
uint8_t mac[ETH_ALEN]
MAC address.
Definition intelxlvf.h:128
struct intelxlvf_admin_get_resources_buffer res
VF Get Resources data buffer.
Definition intelxlvf.h:324
struct intelxlvf_admin_capabilities_buffer caps
VF Capabilities data buffer.
Definition intelxlvf.h:322

References intelxl_nic::caps, intelxlvf_admin_buffer::caps, intelxlvf_admin_capabilities_buffer::caps, intelxlvf_admin_get_resources_buffer::caps, cmd, cpu_to_le16, cpu_to_le32, DBGC, ETH_ALEN, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXLVF_ADMIN_CAP_L2, INTELXLVF_ADMIN_CAP_RQPS, intelxlvf_admin_command(), intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_GET_RESOURCES, le16_to_cpu, le32_to_cpu, intelxlvf_admin_get_resources_buffer::mac, memcpy(), netdev, rc, intelxlvf_admin_buffer::res, intelxl_nic::vsi, and intelxlvf_admin_get_resources_buffer::vsi.

Referenced by intelxlvf_admin_request_qps(), and intelxlvf_probe().

◆ intelxlvf_admin_stats()

int intelxlvf_admin_stats ( struct net_device * netdev)
static

Get statistics (for debugging)

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 422 of file intelxlvf.c.

422 {
423 struct intelxl_nic *intelxl = netdev->priv;
425 union intelxlvf_admin_buffer *buf;
428 int rc;
429
430 /* Populate descriptor */
434 cmd->len = cpu_to_le16 ( sizeof ( buf->queues ) );
435 buf = intelxlvf_admin_command_buffer ( intelxl );
436 buf->queues.vsi = cpu_to_le16 ( intelxl->vsi );
437 tx = &buf->stats.tx;
438 rx = &buf->stats.rx;
439
440 /* Issue command */
441 if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
442 return rc;
443 DBGC ( intelxl, "INTELXL %p TX bytes %#llx discards %#llx errors "
444 "%#llx\n", intelxl,
445 ( ( unsigned long long ) le64_to_cpu ( tx->bytes ) ),
446 ( ( unsigned long long ) le64_to_cpu ( tx->discards ) ),
447 ( ( unsigned long long ) le64_to_cpu ( tx->errors ) ) );
448 DBGC ( intelxl, "INTELXL %p TX unicasts %#llx multicasts %#llx "
449 "broadcasts %#llx\n", intelxl,
450 ( ( unsigned long long ) le64_to_cpu ( tx->unicasts ) ),
451 ( ( unsigned long long ) le64_to_cpu ( tx->multicasts ) ),
452 ( ( unsigned long long ) le64_to_cpu ( tx->broadcasts ) ) );
453 DBGC ( intelxl, "INTELXL %p RX bytes %#llx discards %#llx errors "
454 "%#llx\n", intelxl,
455 ( ( unsigned long long ) le64_to_cpu ( rx->bytes ) ),
456 ( ( unsigned long long ) le64_to_cpu ( rx->discards ) ),
457 ( ( unsigned long long ) le64_to_cpu ( rx->errors ) ) );
458 DBGC ( intelxl, "INTELXL %p RX unicasts %#llx multicasts %#llx "
459 "broadcasts %#llx\n", intelxl,
460 ( ( unsigned long long ) le64_to_cpu ( rx->unicasts ) ),
461 ( ( unsigned long long ) le64_to_cpu ( rx->multicasts ) ),
462 ( ( unsigned long long ) le64_to_cpu ( rx->broadcasts ) ) );
463
464 return 0;
465}
#define le64_to_cpu(value)
Definition byteswap.h:115
#define INTELXLVF_ADMIN_GET_STATS
Admin Queue VF Get Statistics opcode.
Definition intelxlvf.h:280
uint16_t vsi
VSI switching element ID.
Definition intelxlvf.h:259
struct intelxlvf_admin_stats tx
Transmit statistics.
Definition intelxlvf.h:303
struct intelxlvf_admin_stats rx
Receive statistics.
Definition intelxlvf.h:301
VF statistics.
Definition intelxlvf.h:283
struct intelxlvf_admin_queues_buffer queues
VF Enable/Disable Queues data buffer.
Definition intelxlvf.h:330
struct intelxlvf_admin_stats_buffer stats
VF Get Statistics data buffer.
Definition intelxlvf.h:336
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition wpa.h:4
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition wpa.h:1

References cmd, cpu_to_le16, cpu_to_le32, DBGC, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, intelxlvf_admin_command(), intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_GET_STATS, le64_to_cpu, netdev, intelxlvf_admin_buffer::queues, rc, intelxlvf_admin_stats_buffer::rx, rx, intelxlvf_admin_buffer::stats, intelxlvf_admin_stats_buffer::tx, tx, intelxl_nic::vsi, and intelxlvf_admin_queues_buffer::vsi.

Referenced by intelxlvf_close(), and intelxlvf_open().

◆ intelxlvf_admin_request_qps()

int intelxlvf_admin_request_qps ( struct net_device * netdev)
static

Configure number of queue pairs.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 473 of file intelxlvf.c.

473 {
474 struct intelxl_nic *intelxl = netdev->priv;
476 union intelxlvf_admin_buffer *buf;
477 int rc;
478
479 /* Populate descriptor */
484 cmd->len = cpu_to_le16 ( sizeof ( buf->rqps ) );
485 buf = intelxlvf_admin_command_buffer ( intelxl );
486 buf->rqps.count = cpu_to_le16 ( 1 );
487
488 /* Issue command (which will trigger a reset) */
489 if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
490 return rc;
491
492 /* Wait for reset to complete */
493 if ( ( rc = intelxlvf_reset_wait ( intelxl ) ) != 0 )
494 return rc;
495
496 /* Reestablish capabilities to reactivate VF after reset */
497 if ( ( rc = intelxlvf_admin_get_resources ( netdev ) ) != 0 )
498 return rc;
499
500 return 0;
501}
static int intelxlvf_admin_get_resources(struct net_device *netdev)
Get resources.
Definition intelxlvf.c:387
#define INTELXLVF_ADMIN_REQUEST_QPS
Admin Queue VF Request Queues opcode.
Definition intelxlvf.h:307
uint16_t count
Number of queue pairs.
Definition intelxlvf.h:312
struct intelxlvf_admin_request_qps_buffer rqps
VF Request Queues data buffer.
Definition intelxlvf.h:338

References cmd, intelxlvf_admin_request_qps_buffer::count, cpu_to_le16, cpu_to_le32, intelxl_admin_command(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), intelxlvf_admin_get_resources(), INTELXLVF_ADMIN_REQUEST_QPS, INTELXLVF_ADMIN_SEND_TO_PF, intelxlvf_reset_wait(), netdev, rc, and intelxlvf_admin_buffer::rqps.

Referenced by intelxlvf_probe().

◆ intelxlvf_admin_configure()

int intelxlvf_admin_configure ( struct net_device * netdev)
static

Configure queues.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 516 of file intelxlvf.c.

516 {
517 struct intelxl_nic *intelxl = netdev->priv;
519 union intelxlvf_admin_buffer *buf;
520 int rc;
521
522 /* Populate descriptor */
526 cmd->len = cpu_to_le16 ( sizeof ( buf->cfg ) );
527 buf = intelxlvf_admin_command_buffer ( intelxl );
528 buf->cfg.vsi = cpu_to_le16 ( intelxl->vsi );
529 buf->cfg.count = cpu_to_le16 ( 1 );
530 buf->cfg.tx.vsi = cpu_to_le16 ( intelxl->vsi );
532 buf->cfg.tx.base = cpu_to_le64 ( dma ( &intelxl->tx.map,
533 intelxl->tx.desc.raw ) );
534 buf->cfg.rx.vsi = cpu_to_le16 ( intelxl->vsi );
536 buf->cfg.rx.len = cpu_to_le32 ( intelxl->mfs );
537 buf->cfg.rx.mfs = cpu_to_le32 ( intelxl->mfs );
538 buf->cfg.rx.base = cpu_to_le64 ( dma ( &intelxl->rx.map,
539 intelxl->rx.desc.raw ) );
540
541 /* Issue command */
542 if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
543 return rc;
544
545 return 0;
546}
#define cpu_to_le64(value)
Definition byteswap.h:109
#define INTELXL_RX_NUM_DESC
Number of receive descriptors.
Definition intelxl.h:813
#define INTELXL_TX_NUM_DESC
Number of transmit descriptors.
Definition intelxl.h:804
#define INTELXLVF_ADMIN_CONFIGURE
Admin Queue VF Configure Queues opcode.
Definition intelxlvf.h:167
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
size_t mfs
Maximum frame size.
Definition intelxl.h:905
struct intelxl_ring tx
Transmit descriptor ring.
Definition intelxl.h:939
struct intelxl_ring rx
Receive descriptor ring.
Definition intelxl.h:941
union intelxl_ring::@075242332004324155326134235227235157077022164124 desc
Descriptors.
void * raw
Raw data.
Definition intelxl.h:759
struct dma_mapping map
Descriptor ring DMA mapping.
Definition intelxl.h:762
uint16_t count
Number of queue pairs.
Definition intelxlvf.h:174
uint32_t mfs
Maximum frame size.
Definition intelxlvf.h:205
uint64_t base
Base address.
Definition intelxlvf.h:188
struct intelxlvf_admin_configure_buffer::@166201031002050133373251075153005015352345336164 rx
Receive queue.
uint32_t len
Data buffer length.
Definition intelxlvf.h:203
struct intelxlvf_admin_configure_buffer::@134171277040120213047171043245331251250005247271 tx
Transmit queue.
uint16_t vsi
VSI switching element ID.
Definition intelxlvf.h:172
struct intelxlvf_admin_configure_buffer cfg
VF Configure Queues data buffer.
Definition intelxlvf.h:328

References intelxlvf_admin_configure_buffer::base, intelxlvf_admin_buffer::cfg, cmd, intelxlvf_admin_configure_buffer::count, cpu_to_le16, cpu_to_le32, cpu_to_le64, intelxl_ring::desc, dma(), INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXL_RX_NUM_DESC, INTELXL_TX_NUM_DESC, intelxlvf_admin_command(), intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_CONFIGURE, intelxlvf_admin_configure_buffer::len, intelxl_ring::map, intelxl_nic::mfs, intelxlvf_admin_configure_buffer::mfs, netdev, intelxl_ring::raw, rc, intelxl_nic::rx, intelxlvf_admin_configure_buffer::rx, intelxl_nic::tx, intelxlvf_admin_configure_buffer::tx, intelxl_nic::vsi, and intelxlvf_admin_configure_buffer::vsi.

Referenced by intelxlvf_open().

◆ intelxlvf_admin_irq_map()

int intelxlvf_admin_irq_map ( struct net_device * netdev)
static

Configure IRQ mapping.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 554 of file intelxlvf.c.

554 {
555 struct intelxl_nic *intelxl = netdev->priv;
557 union intelxlvf_admin_buffer *buf;
558 int rc;
559
560 /* Populate descriptor */
564 cmd->len = cpu_to_le16 ( sizeof ( buf->irq ) );
565 buf = intelxlvf_admin_command_buffer ( intelxl );
566 buf->irq.count = cpu_to_le16 ( 1 );
567 buf->irq.vsi = cpu_to_le16 ( intelxl->vsi );
569 buf->irq.rxmap = cpu_to_le16 ( 0x0001 );
570 buf->irq.txmap = cpu_to_le16 ( 0x0001 );
571
572 /* Issue command */
573 if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
574 return rc;
575
576 return 0;
577}
#define INTELXLVF_ADMIN_IRQ_MAP
Admin Queue VF IRQ Map opcode.
Definition intelxlvf.h:223
#define INTELXLVF_MSIX_VECTOR
MSI-X vector.
Definition intelxlvf.h:24
uint16_t vec
Interrupt vector ID.
Definition intelxlvf.h:232
uint16_t txmap
Transmit queue bitmap.
Definition intelxlvf.h:236
uint16_t vsi
VSI switching element ID.
Definition intelxlvf.h:230
uint16_t count
Number of interrupt vectors.
Definition intelxlvf.h:228
uint16_t rxmap
Receive queue bitmap.
Definition intelxlvf.h:234
struct intelxlvf_admin_irq_map_buffer irq
VF IRQ Map data buffer.
Definition intelxlvf.h:334

References cmd, intelxlvf_admin_irq_map_buffer::count, cpu_to_le16, cpu_to_le32, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, intelxlvf_admin_command(), intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_IRQ_MAP, INTELXLVF_MSIX_VECTOR, intelxlvf_admin_buffer::irq, netdev, rc, intelxlvf_admin_irq_map_buffer::rxmap, intelxlvf_admin_irq_map_buffer::txmap, intelxlvf_admin_irq_map_buffer::vec, intelxl_nic::vsi, and intelxlvf_admin_irq_map_buffer::vsi.

Referenced by intelxlvf_open().

◆ intelxlvf_admin_queues()

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

Enable/disable queues.

Parameters
netdevNetwork device
enableEnable queues
Return values
rcReturn status code

Definition at line 586 of file intelxlvf.c.

586 {
587 struct intelxl_nic *intelxl = netdev->priv;
589 union intelxlvf_admin_buffer *buf;
590 int rc;
591
592 /* Populate descriptor */
594 cmd->vopcode = ( enable ? cpu_to_le32 ( INTELXLVF_ADMIN_ENABLE ) :
597 cmd->len = cpu_to_le16 ( sizeof ( buf->queues ) );
598 buf = intelxlvf_admin_command_buffer ( intelxl );
599 buf->queues.vsi = cpu_to_le16 ( intelxl->vsi );
600 buf->queues.rx = cpu_to_le32 ( 1 );
601 buf->queues.tx = cpu_to_le32 ( 1 );
602
603 /* Issue command */
604 if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
605 return rc;
606
607 return 0;
608}
#define INTELXLVF_ADMIN_DISABLE
Admin Queue VF Disable Queues opcode.
Definition intelxlvf.h:254
#define INTELXLVF_ADMIN_ENABLE
Admin Queue VF Enable Queues opcode.
Definition intelxlvf.h:251
uint32_t tx
Transmit queue bitmask.
Definition intelxlvf.h:265
uint32_t rx
Receive queue bitmask.
Definition intelxlvf.h:263

References cmd, cpu_to_le16, cpu_to_le32, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, intelxlvf_admin_command(), intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_DISABLE, INTELXLVF_ADMIN_ENABLE, netdev, intelxlvf_admin_buffer::queues, rc, intelxlvf_admin_queues_buffer::rx, intelxlvf_admin_queues_buffer::tx, intelxl_nic::vsi, and intelxlvf_admin_queues_buffer::vsi.

Referenced by intelxlvf_close(), and intelxlvf_open().

◆ intelxlvf_admin_promisc()

int intelxlvf_admin_promisc ( struct net_device * netdev)
static

Configure promiscuous mode.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 616 of file intelxlvf.c.

616 {
617 struct intelxl_nic *intelxl = netdev->priv;
619 union intelxlvf_admin_buffer *buf;
620 int rc;
621
622 /* Populate descriptor */
626 cmd->len = cpu_to_le16 ( sizeof ( buf->promisc ) );
627 buf = intelxlvf_admin_command_buffer ( intelxl );
628 buf->promisc.vsi = cpu_to_le16 ( intelxl->vsi );
631
632 /* Issue command */
633 if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
634 return rc;
635
636 return 0;
637}
#define INTELXL_ADMIN_PROMISC_FL_MULTICAST
Promiscuous multicast mode.
Definition intelxl.h:302
#define INTELXL_ADMIN_PROMISC_FL_UNICAST
Promiscuous unicast mode.
Definition intelxl.h:299
#define INTELXLVF_ADMIN_PROMISC
Admin Queue VF Configure Promiscuous Mode opcode.
Definition intelxlvf.h:269
uint16_t vsi
VSI switching element ID.
Definition intelxlvf.h:274
struct intelxlvf_admin_promisc_buffer promisc
VF Configure Promiscuous Mode data buffer.
Definition intelxlvf.h:332

References cmd, cpu_to_le16, cpu_to_le32, intelxlvf_admin_promisc_buffer::flags, INTELXL_ADMIN_FL_BUF, INTELXL_ADMIN_FL_RD, INTELXL_ADMIN_PROMISC_FL_MULTICAST, INTELXL_ADMIN_PROMISC_FL_UNICAST, intelxlvf_admin_command(), intelxlvf_admin_command_buffer(), intelxlvf_admin_command_descriptor(), INTELXLVF_ADMIN_PROMISC, netdev, intelxlvf_admin_buffer::promisc, rc, intelxl_nic::vsi, and intelxlvf_admin_promisc_buffer::vsi.

Referenced by intelxlvf_open().

◆ intelxlvf_open()

int intelxlvf_open ( struct net_device * netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 645 of file intelxlvf.c.

645 {
646 struct intelxl_nic *intelxl = netdev->priv;
647 int rc;
648
649 /* Calculate maximum frame size */
650 intelxl->mfs = ( ( ETH_HLEN + netdev->mtu + 4 /* CRC */ +
651 INTELXL_ALIGN - 1 ) & ~( INTELXL_ALIGN - 1 ) );
652
653 /* Allocate transmit descriptor ring */
654 if ( ( rc = intelxl_alloc_ring ( intelxl, &intelxl->tx ) ) != 0 )
655 goto err_alloc_tx;
656
657 /* Allocate receive descriptor ring */
658 if ( ( rc = intelxl_alloc_ring ( intelxl, &intelxl->rx ) ) != 0 )
659 goto err_alloc_rx;
660
661 /* Configure queues */
662 if ( ( rc = intelxlvf_admin_configure ( netdev ) ) != 0 )
663 goto err_configure;
664
665 /* Configure IRQ map */
666 if ( ( rc = intelxlvf_admin_irq_map ( netdev ) ) != 0 )
667 goto err_irq_map;
668
669 /* Enable queues */
670 if ( ( rc = intelxlvf_admin_queues ( netdev, 1 ) ) != 0 )
671 goto err_enable;
672
673 /* Configure promiscuous mode */
674 if ( ( rc = intelxlvf_admin_promisc ( netdev ) ) != 0 )
675 goto err_promisc;
676
677 /* Reset statistics counters (if debugging) */
678 if ( DBG_LOG )
680
681 return 0;
682
683 err_promisc:
685 err_enable:
686 err_irq_map:
687 err_configure:
688 intelxl_free_ring ( intelxl, &intelxl->rx );
689 err_alloc_rx:
690 intelxl_free_ring ( intelxl, &intelxl->tx );
691 err_alloc_tx:
692 return rc;
693}
#define DBG_LOG
Definition compiler.h:317
#define ETH_HLEN
Definition if_ether.h:10
int intelxl_alloc_ring(struct intelxl_nic *intelxl, struct intelxl_ring *ring)
Allocate descriptor ring.
Definition intelxl.c:957
void intelxl_free_ring(struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring)
Free descriptor ring.
Definition intelxl.c:996
#define INTELXL_ALIGN
Alignment.
Definition intelxl.h:27
static int intelxlvf_admin_irq_map(struct net_device *netdev)
Configure IRQ mapping.
Definition intelxlvf.c:554
static int intelxlvf_admin_configure(struct net_device *netdev)
Configure queues.
Definition intelxlvf.c:516
static int intelxlvf_admin_stats(struct net_device *netdev)
Get statistics (for debugging)
Definition intelxlvf.c:422
static int intelxlvf_admin_queues(struct net_device *netdev, int enable)
Enable/disable queues.
Definition intelxlvf.c:586
static int intelxlvf_admin_promisc(struct net_device *netdev)
Configure promiscuous mode.
Definition intelxlvf.c:616

References DBG_LOG, ETH_HLEN, INTELXL_ALIGN, intelxl_alloc_ring(), intelxl_free_ring(), intelxlvf_admin_configure(), intelxlvf_admin_irq_map(), intelxlvf_admin_promisc(), intelxlvf_admin_queues(), intelxlvf_admin_stats(), intelxl_nic::mfs, netdev, rc, intelxl_nic::rx, and intelxl_nic::tx.

◆ intelxlvf_close()

void intelxlvf_close ( struct net_device * netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 700 of file intelxlvf.c.

700 {
701 struct intelxl_nic *intelxl = netdev->priv;
702 int rc;
703
704 /* Show statistics (if debugging) */
705 if ( DBG_LOG )
707
708 /* Disable queues */
709 if ( ( rc = intelxlvf_admin_queues ( netdev, 0 ) ) != 0 ) {
710 /* Leak memory; there's nothing else we can do */
711 return;
712 }
713
714 /* Free receive descriptor ring */
715 intelxl_free_ring ( intelxl, &intelxl->rx );
716
717 /* Free transmit descriptor ring */
718 intelxl_free_ring ( intelxl, &intelxl->tx );
719
720 /* Discard any unused receive buffers */
721 intelxl_empty_rx ( intelxl );
722}
void intelxl_empty_rx(struct intelxl_nic *intelxl)
Discard unused receive I/O buffers.
Definition intelxl.c:1367

References DBG_LOG, intelxl_empty_rx(), intelxl_free_ring(), intelxlvf_admin_queues(), intelxlvf_admin_stats(), netdev, rc, intelxl_nic::rx, and intelxl_nic::tx.

◆ intelxlvf_probe()

int intelxlvf_probe ( struct pci_device * pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 745 of file intelxlvf.c.

745 {
746 struct net_device *netdev;
747 struct intelxl_nic *intelxl;
748 int rc;
749
750 /* Allocate and initialise net device */
751 netdev = alloc_etherdev ( sizeof ( *intelxl ) );
752 if ( ! netdev ) {
753 rc = -ENOMEM;
754 goto err_alloc;
755 }
757 intelxl = netdev->priv;
758 pci_set_drvdata ( pci, netdev );
759 netdev->dev = &pci->dev;
760 memset ( intelxl, 0, sizeof ( *intelxl ) );
762 intelxl->handle = intelxlvf_admin_event;
768 sizeof ( intelxl->tx.desc.tx[0] ),
771 sizeof ( intelxl->rx.desc.rx[0] ),
773
774 /* Fix up PCI device */
775 adjust_pci_device ( pci );
776
777 /* Map registers */
778 intelxl->regs = pci_ioremap ( pci, pci->membase, INTELXLVF_BAR_SIZE );
779 if ( ! intelxl->regs ) {
780 rc = -ENODEV;
781 goto err_ioremap;
782 }
783
784 /* Configure DMA */
785 intelxl->dma = &pci->dma;
786 dma_set_mask_64bit ( intelxl->dma );
787 netdev->dma = intelxl->dma;
788
789 /* Locate PCI Express capability */
790 intelxl->exp = pci_find_capability ( pci, PCI_CAP_ID_EXP );
791 if ( ! intelxl->exp ) {
792 DBGC ( intelxl, "INTELXL %p missing PCIe capability\n",
793 intelxl );
794 rc = -ENXIO;
795 goto err_exp;
796 }
797
798 /* Reset the function via PCIe FLR */
799 pci_reset ( pci, intelxl->exp );
800
801 /* Enable MSI-X dummy interrupt */
802 if ( ( rc = intelxl_msix_enable ( intelxl, pci,
803 INTELXLVF_MSIX_VECTOR ) ) != 0 )
804 goto err_msix;
805
806 /* Open admin queues */
807 if ( ( rc = intelxl_open_admin ( intelxl ) ) != 0 )
808 goto err_open_admin;
809
810 /* Reset the function via admin queue */
811 if ( ( rc = intelxlvf_reset_admin ( intelxl ) ) != 0 )
812 goto err_reset_admin;
813
814 /* Negotiate API version */
815 if ( ( rc = intelxlvf_admin_version ( netdev ) ) != 0 )
816 goto err_version;
817
818 /* Get MAC address */
819 if ( ( rc = intelxlvf_admin_get_resources ( netdev ) ) != 0 )
820 goto err_get_resources;
821
822 /* Configure number of queue pairs, if applicable */
823 if ( ( intelxl->caps & INTELXLVF_ADMIN_CAP_RQPS ) &&
824 ( ( rc = intelxlvf_admin_request_qps ( netdev ) ) != 0 ) )
825 goto err_rqps;
826
827 /* Register network device */
828 if ( ( rc = register_netdev ( netdev ) ) != 0 )
829 goto err_register_netdev;
830
831 return 0;
832
834 err_register_netdev:
835 err_rqps:
836 err_get_resources:
837 err_version:
838 err_reset_admin:
839 intelxl_close_admin ( intelxl );
840 err_open_admin:
842 err_msix:
843 pci_reset ( pci, intelxl->exp );
844 err_exp:
845 iounmap ( intelxl->regs );
846 err_ioremap:
848 netdev_put ( netdev );
849 err_alloc:
850 return rc;
851}
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
#define ENXIO
No such device or address.
Definition errno.h:600
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ENODEV
No such device.
Definition errno.h:510
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
void * memset(void *dest, int character, size_t len) __nonnull
int intelxl_msix_enable(struct intelxl_nic *intelxl, struct pci_device *pci, unsigned int vector)
Enable MSI-X dummy interrupt.
Definition intelxl.c:63
void intelxl_close_admin(struct intelxl_nic *intelxl)
Close admin queues.
Definition intelxl.c:929
void intelxl_msix_disable(struct intelxl_nic *intelxl, struct pci_device *pci, unsigned int vector)
Disable MSI-X dummy interrupt.
Definition intelxl.c:91
int intelxl_open_admin(struct intelxl_nic *intelxl)
Open admin queues.
Definition intelxl.c:877
static void intelxl_init_admin(struct intelxl_admin *admin, unsigned int base, const struct intelxl_admin_offsets *regs)
Initialise admin queue.
Definition intelxl.h:476
static const struct intelxl_admin_offsets intelxlvf_admin_event_offsets
Admin event queue register offsets.
Definition intelxlvf.c:175
static int intelxlvf_reset_admin(struct intelxl_nic *intelxl)
Reset hardware via admin queue.
Definition intelxlvf.c:138
static int intelxlvf_admin_version(struct net_device *netdev)
Negotiate API version.
Definition intelxlvf.c:348
static const struct intelxl_admin_offsets intelxlvf_admin_command_offsets
Admin command queue register offsets.
Definition intelxlvf.c:166
static struct net_device_operations intelxlvf_operations
Network device operations.
Definition intelxlvf.c:725
static int intelxlvf_admin_request_qps(struct net_device *netdev)
Configure number of queue pairs.
Definition intelxlvf.c:473
static void intelxlvf_admin_event(struct net_device *netdev, struct intelxl_admin_descriptor *xlevt, union intelxl_admin_buffer *xlbuf)
Handle admin event.
Definition intelxlvf.c:288
#define INTELXLVF_QTX_TAIL
Transmit Queue Tail Register.
Definition intelxlvf.h:27
#define INTELXLVF_BAR_SIZE
BAR size.
Definition intelxlvf.h:16
static void intelxlvf_init_ring(struct intelxl_ring *ring, unsigned int count, size_t len, unsigned int tail)
Initialise descriptor ring.
Definition intelxlvf.h:415
#define INTELXLVF_QRX_TAIL
Receive Queue Tail Register.
Definition intelxlvf.h:30
#define INTELXLVF_VFINT_DYN_CTLN(x)
VF Interrupt N Dynamic Control Register.
Definition intelxlvf.h:33
static __always_inline void dma_set_mask_64bit(struct dma_device *dma)
Set 64-bit addressable space mask.
Definition dma.h:467
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:519
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
#define PCI_CAP_ID_EXP
PCI Express.
Definition pci.h:98
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
void pci_reset(struct pci_device *pci, unsigned int exp)
Perform PCI Express function-level reset (FLR)
Definition pciextra.c:89
int pci_find_capability(struct pci_device *pci, int cap)
Look for a PCI capability.
Definition pciextra.c:39
struct intelxl_admin event
Admin event queue.
Definition intelxl.h:933
struct dma_device * dma
DMA device.
Definition intelxl.h:903
unsigned int intr
Interrupt control register.
Definition intelxl.h:924
unsigned int exp
PCI Express capability offset.
Definition intelxl.h:926
void(* handle)(struct net_device *netdev, struct intelxl_admin_descriptor *evt, union intelxl_admin_buffer *buf)
Handle admin event.
Definition intelxl.h:952
union intelxl_rx_descriptor * rx
Receive descriptors.
Definition intelxl.h:757
union intelxl_tx_descriptor * tx
Transmit descriptors.
Definition intelxl.h:755
A network device.
Definition netdevice.h:353
unsigned long membase
Memory base.
Definition pci.h:220
struct device dev
Generic device.
Definition pci.h:213
struct dma_device dma
DMA device.
Definition pci.h:215

References adjust_pci_device(), alloc_etherdev(), intelxl_nic::caps, intelxl_nic::command, DBGC, intelxl_ring::desc, pci_device::dev, intelxl_nic::dma, pci_device::dma, dma_set_mask_64bit(), ENODEV, ENOMEM, ENXIO, intelxl_nic::event, intelxl_nic::exp, intelxl_nic::handle, intelxl_close_admin(), intelxl_init_admin(), intelxl_msix_disable(), intelxl_msix_enable(), intelxl_open_admin(), INTELXL_RX_NUM_DESC, INTELXL_TX_NUM_DESC, INTELXLVF_ADMIN, INTELXLVF_ADMIN_CAP_RQPS, intelxlvf_admin_command_offsets, intelxlvf_admin_event(), intelxlvf_admin_event_offsets, intelxlvf_admin_get_resources(), intelxlvf_admin_request_qps(), intelxlvf_admin_version(), INTELXLVF_BAR_SIZE, intelxlvf_init_ring(), INTELXLVF_MSIX_VECTOR, intelxlvf_operations, INTELXLVF_QRX_TAIL, INTELXLVF_QTX_TAIL, intelxlvf_reset_admin(), INTELXLVF_VFINT_DYN_CTLN, intelxl_nic::intr, iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_nullify(), netdev_put(), PCI_CAP_ID_EXP, pci_find_capability(), pci_ioremap(), pci_reset(), pci_set_drvdata(), rc, register_netdev(), intelxl_nic::regs, intelxl_nic::rx, intelxl_ring::rx, intelxl_nic::tx, intelxl_ring::tx, and unregister_netdev().

◆ intelxlvf_remove()

void intelxlvf_remove ( struct pci_device * pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 858 of file intelxlvf.c.

858 {
859 struct net_device *netdev = pci_get_drvdata ( pci );
860 struct intelxl_nic *intelxl = netdev->priv;
861
862 /* Unregister network device */
864
865 /* Reset the function via admin queue */
866 intelxlvf_reset_admin ( intelxl );
867
868 /* Close admin queues */
869 intelxl_close_admin ( intelxl );
870
871 /* Disable MSI-X dummy interrupt */
873
874 /* Reset the function via PCIe FLR */
875 pci_reset ( pci, intelxl->exp );
876
877 /* Free network device */
878 iounmap ( intelxl->regs );
880 netdev_put ( netdev );
881}
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376

References intelxl_nic::exp, intelxl_close_admin(), intelxl_msix_disable(), INTELXLVF_MSIX_VECTOR, intelxlvf_reset_admin(), iounmap(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), pci_reset(), intelxl_nic::regs, and unregister_netdev().

Variable Documentation

◆ intelxlvf_admin_command_offsets

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

Admin command queue register offsets.

Definition at line 166 of file intelxlvf.c.

166 {
172};

Referenced by intelxlvf_probe().

◆ intelxlvf_admin_event_offsets

const struct intelxl_admin_offsets intelxlvf_admin_event_offsets
static
Initial value:
= {
}
#define INTELXLVF_ADMIN_EVT_BAL
Admin Event Queue Base Address Low Register (offset)
Definition intelxlvf.h:57
#define INTELXLVF_ADMIN_EVT_BAH
Admin Event Queue Base Address High Register (offset)
Definition intelxlvf.h:60
#define INTELXLVF_ADMIN_EVT_HEAD
Admin Event Queue Head Register (offset)
Definition intelxlvf.h:66
#define INTELXLVF_ADMIN_EVT_TAIL
Admin Event Queue Tail Register (offset)
Definition intelxlvf.h:69

Admin event queue register offsets.

Definition at line 175 of file intelxlvf.c.

175 {
181};

Referenced by intelxlvf_probe().

◆ intelxlvf_operations

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

Network device operations.

Definition at line 725 of file intelxlvf.c.

725 {
726 .open = intelxlvf_open,
727 .close = intelxlvf_close,
728 .transmit = intelxl_transmit,
729 .poll = intelxl_poll,
730};

Referenced by intelxlvf_probe().

◆ intelxlvf_nics

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

PCI device IDs.

Definition at line 884 of file intelxlvf.c.

884 {
885 PCI_ROM ( 0x8086, 0x154c, "xl710-vf", "XL710 VF", 0 ),
886 PCI_ROM ( 0x8086, 0x1571, "xl710-vf-hv", "XL710 VF (Hyper-V)", 0 ),
887 PCI_ROM ( 0x8086, 0x1889, "iavf", "Intel adaptive VF", 0 ),
888 PCI_ROM ( 0x8086, 0x37cd, "x722-vf", "X722 VF", 0 ),
889 PCI_ROM ( 0x8086, 0x37d9, "x722-vf-hv", "X722 VF (Hyper-V)", 0 ),
890};

◆ __pci_driver

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

PCI driver.

Definition at line 893 of file intelxlvf.c.

893 {
894 .ids = intelxlvf_nics,
895 .id_count = ( sizeof ( intelxlvf_nics ) /
896 sizeof ( intelxlvf_nics[0] ) ),
897 .probe = intelxlvf_probe,
899};