iPXE
Data Structures | Defines | 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...

Defines

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

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.
int intelvf_mbox_poll (struct intel_nic *intel)
 Poll mailbox.
int intelvf_mbox_wait (struct intel_nic *intel)
 Wait for PF reset to complete.
int intelvf_mbox_reset (struct intel_nic *intel, uint8_t *hw_addr)
 Send reset message and get initial MAC address.
int intelvf_mbox_set_mac (struct intel_nic *intel, const uint8_t *ll_addr)
 Send set MAC address message.
int intelvf_mbox_set_mtu (struct intel_nic *intel, size_t mtu)
 Send set MTU message.

Variables

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

Detailed Description

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

Definition in file intelvf.h.


Define Documentation

#define INTELVF_BAR_SIZE   ( 16 * 1024 )

Intel VF BAR size.

Definition at line 15 of file intelvf.h.

Referenced by intelxvf_probe().

#define INTELVF_MBCTRL   0x0c40UL

Mailbox Control Register.

Definition at line 18 of file intelvf.h.

#define INTELVF_MBCTRL_REQ   0x00000001UL

Request for PF ready.

Definition at line 19 of file intelvf.h.

Referenced by intelvf_mbox_msg().

#define INTELVF_MBCTRL_ACK   0x00000002UL

PF message received.

Definition at line 20 of file intelvf.h.

Referenced by intelvf_mbox_msg(), and intelvf_mbox_poll().

#define INTELVF_MBCTRL_VFU   0x00000004UL

Buffer taken by VF.

Definition at line 21 of file intelvf.h.

Referenced by intelvf_mbox_msg().

#define INTELVF_MBCTRL_PFU   0x00000008UL

Buffer taken to PF.

Definition at line 22 of file intelvf.h.

#define INTELVF_MBCTRL_PFSTS   0x00000010UL

PF wrote a message.

Definition at line 23 of file intelvf.h.

Referenced by intelvf_mbox_msg(), and intelvf_mbox_poll().

#define INTELVF_MBCTRL_PFACK   0x00000020UL

PF acknowledged message.

Definition at line 24 of file intelvf.h.

Referenced by intelvf_mbox_msg().

#define INTELVF_MBCTRL_RSTI   0x00000040UL

PF reset in progress.

Definition at line 25 of file intelvf.h.

Referenced by intelvf_mbox_msg(), and intelvf_mbox_poll().

#define INTELVF_MBCTRL_RSTD   0x00000080UL

PF reset complete.

Definition at line 26 of file intelvf.h.

#define INTELVF_MBMEM   0x0800UL

Mailbox Memory Register Base.

Definition at line 29 of file intelvf.h.

#define INTELVF_MSG_TYPE_RESET   0x00000001UL

Reset mailbox message.

Definition at line 32 of file intelvf.h.

Referenced by intelvf_mbox_reset().

#define INTELVF_MSG_TYPE_SET_MAC   0x00000002UL

Set MAC address mailbox message.

Definition at line 35 of file intelvf.h.

Referenced by intelvf_mbox_set_mac().

#define INTELVF_MSG_TYPE_SET_MTU   0x00000005UL

Set MTU mailbox message.

Definition at line 38 of file intelvf.h.

Referenced by intelvf_mbox_set_mtu().

#define INTELVF_MSG_TYPE_GET_QUEUES   0x00000009UL

Get queue configuration message.

Definition at line 41 of file intelvf.h.

Referenced by intelxvf_mbox_queues().

#define INTELVF_MSG_TYPE_CONTROL   0x00000100UL

Control ("ping") mailbox message.

Definition at line 44 of file intelvf.h.

#define INTELVF_MSG_TYPE_MASK   0x0000ffffUL
#define INTELVF_MSG_NACK   0x40000000UL

Message NACK flag.

Definition at line 50 of file intelvf.h.

#define INTELVF_MSG_ACK   0x80000000UL

Message is a response.

Definition at line 56 of file intelvf.h.

Referenced by intelvf_mbox_msg().

#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.

Referenced by intelvf_mbox_msg(), and intelvf_mbox_wait().


Function Documentation

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.

Parameters:
intelIntel device
msgMessage buffer
Return values:
rcReturn status code

Definition at line 149 of file intelvf.c.

References assert, intel_mailbox::ctrl, ctrl, DBGC, EPIPE, ETIMEDOUT, intelvf_msg::hdr, 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, mdelay(), readl(), and writel().

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

                                                                         {
        struct intel_mailbox *mbox = &intel->mbox;
        uint32_t ctrl;
        uint32_t seen = 0;
        unsigned int i;

        /* Sanity check */
        assert ( ! ( msg->hdr & INTELVF_MSG_RESPONSE ) );

        /* Handle mailbox */
        for ( i = 0 ; i < INTELVF_MBOX_MAX_WAIT_MS ; i++ ) {

                /* Attempt to claim mailbox, if we have not yet sent
                 * our message.
                 */
                if ( ! ( seen & INTELVF_MBCTRL_VFU ) )
                        writel ( INTELVF_MBCTRL_VFU, intel->regs + mbox->ctrl );

                /* Get mailbox status and record observed flags */
                ctrl = readl ( intel->regs + mbox->ctrl );
                seen |= ctrl;

                /* If a reset is in progress, clear VFU and abort */
                if ( ctrl & INTELVF_MBCTRL_RSTI ) {
                        writel ( 0, intel->regs + mbox->ctrl );
                        return -EPIPE;
                }

                /* Write message to mailbox, if applicable.  This
                 * potentially overwrites a message sent by the PF (if
                 * the PF has simultaneously released PFU (thus
                 * allowing our VFU) and asserted PFSTS), but that
                 * doesn't really matter since there are no
                 * unsolicited PF->VF messages that require the actual
                 * message content to be observed.
                 */
                if ( ctrl & INTELVF_MBCTRL_VFU )
                        intelvf_mbox_write ( intel, msg );

                /* Read message from mailbox, if applicable. */
                if ( ( seen & INTELVF_MBCTRL_VFU ) &&
                     ( seen & INTELVF_MBCTRL_PFACK ) &&
                     ( ctrl & INTELVF_MBCTRL_PFSTS ) )
                        intelvf_mbox_read ( intel, msg );

                /* Acknowledge received message (if applicable),
                 * release VFU lock, and send message (if applicable).
                 */
                ctrl = ( ( ( ctrl & INTELVF_MBCTRL_PFSTS ) ?
                           INTELVF_MBCTRL_ACK : 0 ) |
                         ( ( ctrl & INTELVF_MBCTRL_VFU ) ?
                           INTELVF_MBCTRL_REQ : 0 ) );
                writel ( ctrl, intel->regs + mbox->ctrl );

                /* Exit successfully if we have received a response */
                if ( msg->hdr & INTELVF_MSG_RESPONSE ) {

                        /* Sanity check */
                        assert ( seen & INTELVF_MBCTRL_VFU );
                        assert ( seen & INTELVF_MBCTRL_PFACK );
                        assert ( seen & INTELVF_MBCTRL_PFSTS );

                        return 0;
                }

                /* Delay */
                mdelay ( 1 );
        }

        DBGC ( intel, "INTEL %p timed out waiting for mailbox (seen %08x)\n",
               intel, seen );
        return -ETIMEDOUT;
}
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.

References intel_mailbox::ctrl, ctrl, EPIPE, INTELVF_MBCTRL_ACK, INTELVF_MBCTRL_PFSTS, INTELVF_MBCTRL_RSTI, intelvf_mbox_read(), readl(), and writel().

Referenced by intelvf_mbox_wait(), and intelxvf_poll().

                                                  {
        struct intel_mailbox *mbox = &intel->mbox;
        union intelvf_msg msg;
        uint32_t ctrl;

        /* Get mailbox status */
        ctrl = readl ( intel->regs + mbox->ctrl );

        /* Fail if a reset is in progress */
        if ( ctrl & INTELVF_MBCTRL_RSTI )
                return -EPIPE;

        /* Acknowledge (and ignore) any received messages */
        if ( ctrl & INTELVF_MBCTRL_PFSTS ) {
                intelvf_mbox_read ( intel, &msg );
                writel ( INTELVF_MBCTRL_ACK, intel->regs + mbox->ctrl );
        }

        return 0;
}
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.

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

                                                  {
        unsigned int i;
        int rc;

        /* Wait until a poll completes successfully */
        for ( i = 0 ; i < INTELVF_MBOX_MAX_WAIT_MS ; i++ ) {

                /* Check for successful poll */
                if ( ( rc = intelvf_mbox_poll ( intel ) ) == 0 )
                        return 0;

                /* Delay */
                mdelay ( 1 );
        }

        DBGC ( intel, "INTEL %p timed out waiting for reset\n", intel );
        return -ETIMEDOUT;
}
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.

References DBGC, DBGC_HDA, EPROTO, eth_ntoa(), eth_random_addr(), intelvf_msg::hdr, intelvf_mbox_msg(), INTELVF_MSG_ACK, INTELVF_MSG_TYPE_MASK, INTELVF_MSG_TYPE_RESET, intelvf_msg_mac::mac, intelvf_msg::mac, memcpy(), memset(), rc, and strerror().

Referenced by intelxvf_open(), and intelxvf_probe().

                                                                     {
        union intelvf_msg msg;
        int rc;

        /* Send reset message */
        memset ( &msg, 0, sizeof ( msg ) );
        msg.hdr = INTELVF_MSG_TYPE_RESET;
        if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
                DBGC ( intel, "INTEL %p reset failed: %s\n",
                       intel, strerror ( rc ) );
                return rc;
        }

        /* Check response */
        if ( ( msg.hdr & INTELVF_MSG_TYPE_MASK ) != INTELVF_MSG_TYPE_RESET ) {
                DBGC ( intel, "INTEL %p reset unexpected response:\n", intel );
                DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
                return -EPROTO;
        }

        /* Fill in MAC address, if applicable */
        if ( hw_addr ) {
                if ( msg.hdr & INTELVF_MSG_ACK ) {
                        memcpy ( hw_addr, msg.mac.mac, sizeof ( msg.mac.mac ) );
                        DBGC ( intel, "INTEL %p reset assigned MAC address "
                               "%s\n", intel, eth_ntoa ( hw_addr ) );
                } else {
                        eth_random_addr ( hw_addr );
                        DBGC ( intel, "INTEL %p reset generated MAC address "
                               "%s\n", intel, eth_ntoa ( hw_addr ) );
                }
        }

        return 0;
}
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.

References DBGC, DBGC_HDA, EPERM, EPROTO, intelvf_msg::hdr, intelvf_mbox_msg(), INTELVF_MSG_ACK, INTELVF_MSG_TYPE_MASK, INTELVF_MSG_TYPE_SET_MAC, intelvf_msg_mac::mac, intelvf_msg::mac, memcpy(), memset(), rc, and strerror().

Referenced by intelxvf_open().

                                                                             {
        union intelvf_msg msg;
        int rc;

        /* Send set MAC address message */
        memset ( &msg, 0, sizeof ( msg ) );
        msg.hdr = INTELVF_MSG_TYPE_SET_MAC;
        memcpy ( msg.mac.mac, ll_addr, sizeof ( msg.mac.mac ) );
        if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
                DBGC ( intel, "INTEL %p set MAC address failed: %s\n",
                       intel, strerror ( rc ) );
                return rc;
        }

        /* Check response */
        if ( ( msg.hdr & INTELVF_MSG_TYPE_MASK ) != INTELVF_MSG_TYPE_SET_MAC ) {
                DBGC ( intel, "INTEL %p set MAC address unexpected response:\n",
                       intel );
                DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
                return -EPROTO;
        }

        /* Check that we were allowed to set the MAC address */
        if ( ! ( msg.hdr & INTELVF_MSG_ACK ) ) {
                DBGC ( intel, "INTEL %p set MAC address refused\n", intel );
                return -EPERM;
        }

        return 0;
}
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.

References DBGC, DBGC_HDA, EPERM, EPROTO, intelvf_msg::hdr, intelvf_mbox_msg(), INTELVF_MSG_ACK, INTELVF_MSG_TYPE_MASK, INTELVF_MSG_TYPE_SET_MTU, memset(), intelvf_msg_mtu::mtu, intelvf_msg::mtu, mtu, rc, and strerror().

Referenced by intelxvf_open().

                                                                 {
        union intelvf_msg msg;
        int rc;

        /* Send set MTU message */
        memset ( &msg, 0, sizeof ( msg ) );
        msg.hdr = INTELVF_MSG_TYPE_SET_MTU;
        msg.mtu.mtu = mtu;
        if ( ( rc = intelvf_mbox_msg ( intel, &msg ) ) != 0 ) {
                DBGC ( intel, "INTEL %p set MTU failed: %s\n",
                       intel, strerror ( rc ) );
                return rc;
        }

        /* Check response */
        if ( ( msg.hdr & INTELVF_MSG_TYPE_MASK ) != INTELVF_MSG_TYPE_SET_MTU ) {
                DBGC ( intel, "INTEL %p set MTU unexpected response:\n",
                       intel );
                DBGC_HDA ( intel, 0, &msg, sizeof ( msg ) );
                return -EPROTO;
        }

        /* Check that we were allowed to set the MTU */
        if ( ! ( msg.hdr & INTELVF_MSG_ACK ) ) {
                DBGC ( intel, "INTEL %p set MTU refused\n", intel );
                return -EPERM;
        }

        return 0;
}

Variable Documentation

MAC address.

Definition at line 70 of file intelvf.h.

Alignment padding.

Definition at line 72 of file intelvf.h.

API version.

Definition at line 78 of file intelvf.h.

Maximum packet size.

Definition at line 86 of file intelvf.h.

u8 tx
u8 rx

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 152 of file intelvf.h.

Referenced by intelxvf_open().

Default queue.

Definition at line 154 of file intelvf.h.