iPXE
Data Structures | Macros | Functions | Variables
intelvf.h File Reference

Intel 10/100/1000 virtual function network card driver. More...

#include "intel.h"

Go to the source code of this file.

Data Structures

struct  intelvf_msg_mac
 MAC address mailbox message. More...
 
struct  intelvf_msg_version
 Version number mailbox message. More...
 
struct  intelvf_msg_mtu
 MTU mailbox message. More...
 
struct  intelvf_msg_queues
 Queue configuration mailbox message (API v1.1+ only) More...
 
union  intelvf_msg
 Mailbox message. More...
 

Macros

#define INTELVF_BAR_SIZE   ( 16 * 1024 )
 Intel VF BAR size. More...
 
#define INTELVF_MBCTRL   0x0c40UL
 Mailbox Control Register. More...
 
#define INTELVF_MBCTRL_REQ   0x00000001UL
 Request for PF ready. More...
 
#define INTELVF_MBCTRL_ACK   0x00000002UL
 PF message received. More...
 
#define INTELVF_MBCTRL_VFU   0x00000004UL
 Buffer taken by VF. More...
 
#define INTELVF_MBCTRL_PFU   0x00000008UL
 Buffer taken to PF. More...
 
#define INTELVF_MBCTRL_PFSTS   0x00000010UL
 PF wrote a message. More...
 
#define INTELVF_MBCTRL_PFACK   0x00000020UL
 PF acknowledged message. More...
 
#define INTELVF_MBCTRL_RSTI   0x00000040UL
 PF reset in progress. More...
 
#define INTELVF_MBCTRL_RSTD   0x00000080UL
 PF reset complete. More...
 
#define INTELVF_MBMEM   0x0800UL
 Mailbox Memory Register Base. More...
 
#define INTELVF_MSG_TYPE_RESET   0x00000001UL
 Reset mailbox message. More...
 
#define INTELVF_MSG_TYPE_SET_MAC   0x00000002UL
 Set MAC address mailbox message. More...
 
#define INTELVF_MSG_TYPE_SET_MTU   0x00000005UL
 Set MTU mailbox message. More...
 
#define INTELVF_MSG_TYPE_GET_QUEUES   0x00000009UL
 Get queue configuration message. More...
 
#define INTELVF_MSG_TYPE_CONTROL   0x00000100UL
 Control ("ping") mailbox message. More...
 
#define INTELVF_MSG_TYPE_MASK   0x0000ffffUL
 Message type mask. More...
 
#define INTELVF_MSG_NACK   0x40000000UL
 Message NACK flag. More...
 
#define INTELVF_MSG_ACK   0x80000000UL
 Message ACK flag. More...
 
#define INTELVF_MSG_RESPONSE   ( INTELVF_MSG_ACK | INTELVF_MSG_NACK )
 Message is a response. More...
 
#define INTELVF_MBOX_MAX_WAIT_MS   500
 Maximum time to wait for mailbox message. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
struct intelvf_msg_mac __attribute__ ((packed))
 
int intelvf_mbox_msg (struct intel_nic *intel, union intelvf_msg *msg)
 Send/receive mailbox message. More...
 
int intelvf_mbox_poll (struct intel_nic *intel)
 Poll mailbox. More...
 
int intelvf_mbox_wait (struct intel_nic *intel)
 Wait for PF reset to complete. More...
 
int intelvf_mbox_reset (struct intel_nic *intel, uint8_t *hw_addr)
 Send reset message and get initial MAC address. More...
 
int intelvf_mbox_set_mac (struct intel_nic *intel, const uint8_t *ll_addr)
 Send set MAC address message. More...
 
int intelvf_mbox_set_mtu (struct intel_nic *intel, size_t mtu)
 Send set MTU message. More...
 

Variables

uint32_t hdr
 Message header. More...
 
uint8_t mac [ETH_ALEN]
 MAC address. More...
 
uint8_t reserved [(-ETH_ALEN) &0x3]
 Alignment padding. More...
 
uint32_t version
 API version. More...
 
uint32_t mtu
 Maximum packet size. More...
 
uint32_t tx
 Maximum number of transmit queues. More...
 
uint32_t rx
 Maximum number of receive queues. More...
 
uint32_t vlan_thing
 VLAN hand-waving thing. More...
 
uint32_t dflt
 Default queue. More...
 
union intelvf_msg __attribute__
 

Detailed Description

Intel 10/100/1000 virtual function network card driver.

Definition in file intelvf.h.

Macro Definition Documentation

◆ INTELVF_BAR_SIZE

#define INTELVF_BAR_SIZE   ( 16 * 1024 )

Intel VF BAR size.

Definition at line 15 of file intelvf.h.

◆ INTELVF_MBCTRL

#define INTELVF_MBCTRL   0x0c40UL

Mailbox Control Register.

Definition at line 18 of file intelvf.h.

◆ INTELVF_MBCTRL_REQ

#define INTELVF_MBCTRL_REQ   0x00000001UL

Request for PF ready.

Definition at line 19 of file intelvf.h.

◆ INTELVF_MBCTRL_ACK

#define INTELVF_MBCTRL_ACK   0x00000002UL

PF message received.

Definition at line 20 of file intelvf.h.

◆ INTELVF_MBCTRL_VFU

#define INTELVF_MBCTRL_VFU   0x00000004UL

Buffer taken by VF.

Definition at line 21 of file intelvf.h.

◆ INTELVF_MBCTRL_PFU

#define INTELVF_MBCTRL_PFU   0x00000008UL

Buffer taken to PF.

Definition at line 22 of file intelvf.h.

◆ INTELVF_MBCTRL_PFSTS

#define INTELVF_MBCTRL_PFSTS   0x00000010UL

PF wrote a message.

Definition at line 23 of file intelvf.h.

◆ INTELVF_MBCTRL_PFACK

#define INTELVF_MBCTRL_PFACK   0x00000020UL

PF acknowledged message.

Definition at line 24 of file intelvf.h.

◆ INTELVF_MBCTRL_RSTI

#define INTELVF_MBCTRL_RSTI   0x00000040UL

PF reset in progress.

Definition at line 25 of file intelvf.h.

◆ INTELVF_MBCTRL_RSTD

#define INTELVF_MBCTRL_RSTD   0x00000080UL

PF reset complete.

Definition at line 26 of file intelvf.h.

◆ INTELVF_MBMEM

#define INTELVF_MBMEM   0x0800UL

Mailbox Memory Register Base.

Definition at line 29 of file intelvf.h.

◆ INTELVF_MSG_TYPE_RESET

#define INTELVF_MSG_TYPE_RESET   0x00000001UL

Reset mailbox message.

Definition at line 32 of file intelvf.h.

◆ INTELVF_MSG_TYPE_SET_MAC

#define INTELVF_MSG_TYPE_SET_MAC   0x00000002UL

Set MAC address mailbox message.

Definition at line 35 of file intelvf.h.

◆ INTELVF_MSG_TYPE_SET_MTU

#define INTELVF_MSG_TYPE_SET_MTU   0x00000005UL

Set MTU mailbox message.

Definition at line 38 of file intelvf.h.

◆ INTELVF_MSG_TYPE_GET_QUEUES

#define INTELVF_MSG_TYPE_GET_QUEUES   0x00000009UL

Get queue configuration message.

Definition at line 41 of file intelvf.h.

◆ INTELVF_MSG_TYPE_CONTROL

#define INTELVF_MSG_TYPE_CONTROL   0x00000100UL

Control ("ping") mailbox message.

Definition at line 44 of file intelvf.h.

◆ INTELVF_MSG_TYPE_MASK

#define INTELVF_MSG_TYPE_MASK   0x0000ffffUL

Message type mask.

Definition at line 47 of file intelvf.h.

◆ INTELVF_MSG_NACK

#define INTELVF_MSG_NACK   0x40000000UL

Message NACK flag.

Definition at line 50 of file intelvf.h.

◆ INTELVF_MSG_ACK

#define INTELVF_MSG_ACK   0x80000000UL

Message ACK flag.

Definition at line 53 of file intelvf.h.

◆ INTELVF_MSG_RESPONSE

#define INTELVF_MSG_RESPONSE   ( INTELVF_MSG_ACK | INTELVF_MSG_NACK )

Message is a response.

Definition at line 56 of file intelvf.h.

◆ INTELVF_MBOX_MAX_WAIT_MS

#define INTELVF_MBOX_MAX_WAIT_MS   500

Maximum time to wait for mailbox message.

This is a policy decision.

Definition at line 142 of file intelvf.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ __attribute__()

struct intelvf_msg_mac __attribute__ ( (packed)  )

◆ intelvf_mbox_msg()

int intelvf_mbox_msg ( struct intel_nic intel,
union intelvf_msg msg 
)

Send/receive mailbox message.

Parameters
intelIntel device
msgMessage buffer
Return values
rcReturn status code

Definition at line 149 of file intelvf.c.

149  {
150  struct intel_mailbox *mbox = &intel->mbox;
151  uint32_t ctrl;
152  uint32_t seen = 0;
153  unsigned int i;
154 
155  /* Sanity check */
156  assert ( ! ( msg->hdr & INTELVF_MSG_RESPONSE ) );
157 
158  /* Handle mailbox */
159  for ( i = 0 ; i < INTELVF_MBOX_MAX_WAIT_MS ; i++ ) {
160 
161  /* Attempt to claim mailbox, if we have not yet sent
162  * our message.
163  */
164  if ( ! ( seen & INTELVF_MBCTRL_VFU ) )
165  writel ( INTELVF_MBCTRL_VFU, intel->regs + mbox->ctrl );
166 
167  /* Get mailbox status and record observed flags */
168  ctrl = readl ( intel->regs + mbox->ctrl );
169  seen |= ctrl;
170 
171  /* If a reset is in progress, clear VFU and abort */
172  if ( ctrl & INTELVF_MBCTRL_RSTI ) {
173  writel ( 0, intel->regs + mbox->ctrl );
174  return -EPIPE;
175  }
176 
177  /* Write message to mailbox, if applicable. This
178  * potentially overwrites a message sent by the PF (if
179  * the PF has simultaneously released PFU (thus
180  * allowing our VFU) and asserted PFSTS), but that
181  * doesn't really matter since there are no
182  * unsolicited PF->VF messages that require the actual
183  * message content to be observed.
184  */
185  if ( ctrl & INTELVF_MBCTRL_VFU )
186  intelvf_mbox_write ( intel, msg );
187 
188  /* Read message from mailbox, if applicable. */
189  if ( ( seen & INTELVF_MBCTRL_VFU ) &&
190  ( seen & INTELVF_MBCTRL_PFACK ) &&
191  ( ctrl & INTELVF_MBCTRL_PFSTS ) )
192  intelvf_mbox_read ( intel, msg );
193 
194  /* Acknowledge received message (if applicable),
195  * release VFU lock, and send message (if applicable).
196  */
197  ctrl = ( ( ( ctrl & INTELVF_MBCTRL_PFSTS ) ?
198  INTELVF_MBCTRL_ACK : 0 ) |
199  ( ( ctrl & INTELVF_MBCTRL_VFU ) ?
200  INTELVF_MBCTRL_REQ : 0 ) );
201  writel ( ctrl, intel->regs + mbox->ctrl );
202 
203  /* Exit successfully if we have received a response */
204  if ( msg->hdr & INTELVF_MSG_RESPONSE ) {
205 
206  /* Sanity check */
207  assert ( seen & INTELVF_MBCTRL_VFU );
208  assert ( seen & INTELVF_MBCTRL_PFACK );
209  assert ( seen & INTELVF_MBCTRL_PFSTS );
210 
211  return 0;
212  }
213 
214  /* Delay */
215  mdelay ( 1 );
216  }
217 
218  DBGC ( intel, "INTEL %p timed out waiting for mailbox (seen %08x)\n",
219  intel, seen );
220  return -ETIMEDOUT;
221 }
void * regs
Registers.
Definition: intel.h:280
static void intelvf_mbox_write(struct intel_nic *intel, const union intelvf_msg *msg)
Write message to mailbox.
Definition: intelvf.c:53
struct intel_mailbox mbox
Mailbox.
Definition: intel.h:296
#define EPIPE
Broken pipe.
Definition: errno.h:619
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define INTELVF_MBCTRL_PFACK
PF acknowledged message.
Definition: intelvf.h:24
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.
Definition: golan.c:120
#define INTELVF_MBCTRL_REQ
Request for PF ready.
Definition: intelvf.h:19
#define INTELVF_MBCTRL_PFSTS
PF wrote a message.
Definition: intelvf.h:23
An Intel virtual function mailbox.
Definition: intel.h:255
#define INTELVF_MBCTRL_ACK
PF message received.
Definition: intelvf.h:20
#define INTELVF_MSG_RESPONSE
Message is a response.
Definition: intelvf.h:56
unsigned int uint32_t
Definition: stdint.h:12
#define INTELVF_MBCTRL_RSTI
PF reset in progress.
Definition: intelvf.h:25
#define INTELVF_MBCTRL_VFU
Buffer taken by VF.
Definition: intelvf.h:21
#define INTELVF_MBOX_MAX_WAIT_MS
Maximum time to wait for mailbox message.
Definition: intelvf.h:142
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static unsigned int ctrl
Definition: intel.h:270
static void intelvf_mbox_read(struct intel_nic *intel, union intelvf_msg *msg)
Read message from mailbox.
Definition: intelvf.c:73
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References assert(), ctrl, DBGC, EPIPE, ETIMEDOUT, INTELVF_MBCTRL_ACK, INTELVF_MBCTRL_PFACK, INTELVF_MBCTRL_PFSTS, INTELVF_MBCTRL_REQ, INTELVF_MBCTRL_RSTI, INTELVF_MBCTRL_VFU, INTELVF_MBOX_MAX_WAIT_MS, intelvf_mbox_read(), intelvf_mbox_write(), INTELVF_MSG_RESPONSE, intel_nic::mbox, mdelay(), msg(), readl(), intel_nic::regs, and writel().

Referenced by intelvf_mbox_reset(), intelvf_mbox_set_mac(), intelvf_mbox_set_mtu(), intelxvf_mbox_queues(), and intelxvf_mbox_version().

◆ intelvf_mbox_poll()

int intelvf_mbox_poll ( struct intel_nic intel)

Poll mailbox.

Parameters
intelIntel device
Return values
rcReturn status code

Note that polling the mailbox may fail if the underlying PF is reset.

Definition at line 96 of file intelvf.c.

96  {
97  struct intel_mailbox *mbox = &intel->mbox;
98  union intelvf_msg msg;
99  uint32_t ctrl;
100 
101  /* Get mailbox status */
102  ctrl = readl ( intel->regs + mbox->ctrl );
103 
104  /* Fail if a reset is in progress */
105  if ( ctrl & INTELVF_MBCTRL_RSTI )
106  return -EPIPE;
107 
108  /* Acknowledge (and ignore) any received messages */
109  if ( ctrl & INTELVF_MBCTRL_PFSTS ) {
110  intelvf_mbox_read ( intel, &msg );
111  writel ( INTELVF_MBCTRL_ACK, intel->regs + mbox->ctrl );
112  }
113 
114  return 0;
115 }
void * regs
Registers.
Definition: intel.h:280
struct intel_mailbox mbox
Mailbox.
Definition: intel.h:296
#define EPIPE
Broken pipe.
Definition: errno.h:619
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
Mailbox message.
Definition: intelvf.h:123
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
Definition: golan.c:120
#define INTELVF_MBCTRL_PFSTS
PF wrote a message.
Definition: intelvf.h:23
An Intel virtual function mailbox.
Definition: intel.h:255
#define INTELVF_MBCTRL_ACK
PF message received.
Definition: intelvf.h:20
unsigned int uint32_t
Definition: stdint.h:12
#define INTELVF_MBCTRL_RSTI
PF reset in progress.
Definition: intelvf.h:25
static unsigned int ctrl
Definition: intel.h:270
static void intelvf_mbox_read(struct intel_nic *intel, union intelvf_msg *msg)
Read message from mailbox.
Definition: intelvf.c:73
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References ctrl, EPIPE, INTELVF_MBCTRL_ACK, INTELVF_MBCTRL_PFSTS, INTELVF_MBCTRL_RSTI, intelvf_mbox_read(), intel_nic::mbox, msg(), readl(), intel_nic::regs, and writel().

Referenced by intelvf_mbox_wait(), and intelxvf_poll().

◆ intelvf_mbox_wait()

int intelvf_mbox_wait ( struct intel_nic intel)

Wait for PF reset to complete.

Parameters
intelIntel device
Return values
rcReturn status code

Definition at line 123 of file intelvf.c.

123  {
124  unsigned int i;
125  int rc;
126 
127  /* Wait until a poll completes successfully */
128  for ( i = 0 ; i < INTELVF_MBOX_MAX_WAIT_MS ; i++ ) {
129 
130  /* Check for successful poll */
131  if ( ( rc = intelvf_mbox_poll ( intel ) ) == 0 )
132  return 0;
133 
134  /* Delay */
135  mdelay ( 1 );
136  }
137 
138  DBGC ( intel, "INTEL %p timed out waiting for reset\n", intel );
139  return -ETIMEDOUT;
140 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define INTELVF_MBOX_MAX_WAIT_MS
Maximum time to wait for mailbox message.
Definition: intelvf.h:142
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
int intelvf_mbox_poll(struct intel_nic *intel)
Poll mailbox.
Definition: intelvf.c:96
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References DBGC, ETIMEDOUT, INTELVF_MBOX_MAX_WAIT_MS, intelvf_mbox_poll(), mdelay(), and rc.

◆ intelvf_mbox_reset()

int intelvf_mbox_reset ( struct intel_nic intel,
uint8_t hw_addr 
)

Send reset message and get initial MAC address.

Parameters
intelIntel device
hw_addrHardware address to fill in, or NULL
Return values
rcReturn status code

Definition at line 230 of file intelvf.c.

230  {
231  union intelvf_msg msg;
232  int rc;
233 
234  /* Send reset message */
235  memset ( &msg, 0, sizeof ( msg ) );
237  if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
238  DBGC ( intel, "INTEL %p reset failed: %s\n",
239  intel, strerror ( rc ) );
240  return rc;
241  }
242 
243  /* Check response */
244  if ( ( msg.hdr & INTELVF_MSG_TYPE_MASK ) != INTELVF_MSG_TYPE_RESET ) {
245  DBGC ( intel, "INTEL %p reset unexpected response:\n", intel );
246  DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
247  return -EPROTO;
248  }
249 
250  /* Fill in MAC address, if applicable */
251  if ( hw_addr ) {
252  if ( msg.hdr & INTELVF_MSG_ACK ) {
253  memcpy ( hw_addr, msg.mac.mac, sizeof ( msg.mac.mac ) );
254  DBGC ( intel, "INTEL %p reset assigned MAC address "
255  "%s\n", intel, eth_ntoa ( hw_addr ) );
256  } else {
257  eth_random_addr ( hw_addr );
258  DBGC ( intel, "INTEL %p reset generated MAC address "
259  "%s\n", intel, eth_ntoa ( hw_addr ) );
260  }
261  }
262 
263  return 0;
264 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
Mailbox message.
Definition: intelvf.h:123
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPROTO
Protocol error.
Definition: errno.h:624
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define INTELVF_MSG_ACK
Message ACK flag.
Definition: intelvf.h:53
int intelvf_mbox_msg(struct intel_nic *intel, union intelvf_msg *msg)
Send/receive mailbox message.
Definition: intelvf.c:149
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
#define INTELVF_MSG_TYPE_MASK
Message type mask.
Definition: intelvf.h:47
#define INTELVF_MSG_TYPE_RESET
Reset mailbox message.
Definition: intelvf.h:32
void eth_random_addr(void *hw_addr)
Generate random Ethernet address.
Definition: ethernet.c:159
void * memset(void *dest, int character, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, DBGC_HDA, EPROTO, eth_ntoa(), eth_random_addr(), intelvf_mbox_msg(), INTELVF_MSG_ACK, INTELVF_MSG_TYPE_MASK, INTELVF_MSG_TYPE_RESET, memcpy(), memset(), msg(), rc, and strerror().

Referenced by intelxvf_open(), and intelxvf_probe().

◆ intelvf_mbox_set_mac()

int intelvf_mbox_set_mac ( struct intel_nic intel,
const uint8_t ll_addr 
)

Send set MAC address message.

Parameters
intelIntel device
ll_addrLink-layer address
Return values
rcReturn status code

Definition at line 273 of file intelvf.c.

273  {
274  union intelvf_msg msg;
275  int rc;
276 
277  /* Send set MAC address message */
278  memset ( &msg, 0, sizeof ( msg ) );
280  memcpy ( msg.mac.mac, ll_addr, sizeof ( msg.mac.mac ) );
281  if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
282  DBGC ( intel, "INTEL %p set MAC address failed: %s\n",
283  intel, strerror ( rc ) );
284  return rc;
285  }
286 
287  /* Check response */
289  DBGC ( intel, "INTEL %p set MAC address unexpected response:\n",
290  intel );
291  DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
292  return -EPROTO;
293  }
294 
295  /* Check that we were allowed to set the MAC address */
296  if ( ! ( msg.hdr & INTELVF_MSG_ACK ) ) {
297  DBGC ( intel, "INTEL %p set MAC address refused\n", intel );
298  return -EPERM;
299  }
300 
301  return 0;
302 }
#define INTELVF_MSG_TYPE_SET_MAC
Set MAC address mailbox message.
Definition: intelvf.h:35
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
Mailbox message.
Definition: intelvf.h:123
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPROTO
Protocol error.
Definition: errno.h:624
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define INTELVF_MSG_ACK
Message ACK flag.
Definition: intelvf.h:53
int intelvf_mbox_msg(struct intel_nic *intel, union intelvf_msg *msg)
Send/receive mailbox message.
Definition: intelvf.c:149
#define EPERM
Operation not permitted.
Definition: errno.h:614
#define INTELVF_MSG_TYPE_MASK
Message type mask.
Definition: intelvf.h:47
void * memset(void *dest, int character, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

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

Referenced by intelxvf_open().

◆ intelvf_mbox_set_mtu()

int intelvf_mbox_set_mtu ( struct intel_nic intel,
size_t  mtu 
)

Send set MTU message.

Parameters
intelIntel device
mtuMaximum packet size
Return values
rcReturn status code

Definition at line 311 of file intelvf.c.

311  {
312  union intelvf_msg msg;
313  int rc;
314 
315  /* Send set MTU message */
316  memset ( &msg, 0, sizeof ( msg ) );
318  msg.mtu.mtu = mtu;
319  if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
320  DBGC ( intel, "INTEL %p set MTU failed: %s\n",
321  intel, strerror ( rc ) );
322  return rc;
323  }
324 
325  /* Check response */
327  DBGC ( intel, "INTEL %p set MTU unexpected response:\n",
328  intel );
329  DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
330  return -EPROTO;
331  }
332 
333  /* Check that we were allowed to set the MTU */
334  if ( ! ( msg.hdr & INTELVF_MSG_ACK ) ) {
335  DBGC ( intel, "INTEL %p set MTU refused\n", intel );
336  return -EPERM;
337  }
338 
339  return 0;
340 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
Mailbox message.
Definition: intelvf.h:123
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPROTO
Protocol error.
Definition: errno.h:624
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define INTELVF_MSG_ACK
Message ACK flag.
Definition: intelvf.h:53
int intelvf_mbox_msg(struct intel_nic *intel, union intelvf_msg *msg)
Send/receive mailbox message.
Definition: intelvf.c:149
#define INTELVF_MSG_TYPE_SET_MTU
Set MTU mailbox message.
Definition: intelvf.h:38
#define EPERM
Operation not permitted.
Definition: errno.h:614
#define INTELVF_MSG_TYPE_MASK
Message type mask.
Definition: intelvf.h:47
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
void * memset(void *dest, int character, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

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

Referenced by intelxvf_open().

Variable Documentation

◆ hdr

struct peerdist_msg_header hdr

◆ mac

MAC address.

Definition at line 14 of file intelvf.h.

◆ reserved

uint8_t reserved[(-ETH_ALEN) &0x3]

Alignment padding.

Definition at line 16 of file intelvf.h.

◆ version

uint32_t version

API version.

Definition at line 14 of file intelvf.h.

◆ mtu

uint32_t mtu

Maximum packet size.

Definition at line 14 of file intelvf.h.

◆ tx

u8 tx

◆ rx

u8 rx

◆ vlan_thing

uint32_t vlan_thing

VLAN hand-waving thing.

This is labelled IXGBE_VF_TRANS_VLAN in the Linux driver.

A comment in the Linux PF driver describes it as "notify VF of need for VLAN tag stripping, and correct queue". It will be filled with a non-zero value if the PF is enforcing the use of a single VLAN tag. It will also be filled with a non-zero value if the PF is using multiple traffic classes.

The Linux VF driver seems to treat this field as being simply the number of traffic classes, and gives it no VLAN-related interpretation.

If the PF is enforcing the use of a single VLAN tag for the VF, then the VLAN tag will be transparently inserted in transmitted packets (via the PFVMVIR register) but will still be visible in received packets. The Linux VF driver handles this unexpected VLAN tag by simply ignoring any unrecognised VLAN tags.

We choose to strip and ignore the VLAN tag if this field has a non-zero value.

Definition at line 42 of file intelvf.h.

Referenced by intelxvf_mbox_queues(), and intelxvf_open().

◆ dflt

uint32_t dflt

Default queue.

Definition at line 44 of file intelvf.h.

◆ __attribute__