iPXE
intelvf.h
Go to the documentation of this file.
00001 #ifndef _INTELVF_H
00002 #define _INTELVF_H
00003 
00004 /** @file
00005  *
00006  * Intel 10/100/1000 virtual function network card driver
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include "intel.h"
00013 
00014 /** Intel VF BAR size */
00015 #define INTELVF_BAR_SIZE ( 16 * 1024 )
00016 
00017 /** Mailbox Control Register */
00018 #define INTELVF_MBCTRL 0x0c40UL
00019 #define INTELVF_MBCTRL_REQ      0x00000001UL    /**< Request for PF ready */
00020 #define INTELVF_MBCTRL_ACK      0x00000002UL    /**< PF message received */
00021 #define INTELVF_MBCTRL_VFU      0x00000004UL    /**< Buffer taken by VF */
00022 #define INTELVF_MBCTRL_PFU      0x00000008UL    /**< Buffer taken to PF */
00023 #define INTELVF_MBCTRL_PFSTS    0x00000010UL    /**< PF wrote a message */
00024 #define INTELVF_MBCTRL_PFACK    0x00000020UL    /**< PF acknowledged message */
00025 #define INTELVF_MBCTRL_RSTI     0x00000040UL    /**< PF reset in progress */
00026 #define INTELVF_MBCTRL_RSTD     0x00000080UL    /**< PF reset complete */
00027 
00028 /** Mailbox Memory Register Base */
00029 #define INTELVF_MBMEM 0x0800UL
00030 
00031 /** Reset mailbox message */
00032 #define INTELVF_MSG_TYPE_RESET 0x00000001UL
00033 
00034 /** Set MAC address mailbox message */
00035 #define INTELVF_MSG_TYPE_SET_MAC 0x00000002UL
00036 
00037 /** Set MTU mailbox message */
00038 #define INTELVF_MSG_TYPE_SET_MTU 0x00000005UL
00039 
00040 /** Get queue configuration message */
00041 #define INTELVF_MSG_TYPE_GET_QUEUES 0x00000009UL
00042 
00043 /** Control ("ping") mailbox message */
00044 #define INTELVF_MSG_TYPE_CONTROL 0x00000100UL
00045 
00046 /** Message type mask */
00047 #define INTELVF_MSG_TYPE_MASK 0x0000ffffUL
00048 
00049 /** Message NACK flag */
00050 #define INTELVF_MSG_NACK 0x40000000UL
00051 
00052 /** Message ACK flag */
00053 #define INTELVF_MSG_ACK 0x80000000UL
00054 
00055 /** Message is a response */
00056 #define INTELVF_MSG_RESPONSE ( INTELVF_MSG_ACK | INTELVF_MSG_NACK )
00057 
00058 /** MAC address mailbox message */
00059 struct intelvf_msg_mac {
00060         /** Message header */
00061         uint32_t hdr;
00062         /** MAC address */
00063         uint8_t mac[ETH_ALEN];
00064         /** Alignment padding */
00065         uint8_t reserved[ (-ETH_ALEN) & 0x3 ];
00066 } __attribute__ (( packed ));
00067 
00068 /** Version number mailbox message */
00069 struct intelvf_msg_version {
00070         /** Message header */
00071         uint32_t hdr;
00072         /** API version */
00073         uint32_t version;
00074 } __attribute__ (( packed ));
00075 
00076 /** MTU mailbox message */
00077 struct intelvf_msg_mtu {
00078         /** Message header */
00079         uint32_t hdr;
00080         /** Maximum packet size */
00081         uint32_t mtu;
00082 } __attribute__ (( packed ));
00083 
00084 /** Queue configuration mailbox message (API v1.1+ only) */
00085 struct intelvf_msg_queues {
00086         /** Message header */
00087         uint32_t hdr;
00088         /** Maximum number of transmit queues */
00089         uint32_t tx;
00090         /** Maximum number of receive queues */
00091         uint32_t rx;
00092         /** VLAN hand-waving thing
00093          *
00094          * This is labelled IXGBE_VF_TRANS_VLAN in the Linux driver.
00095          *
00096          * A comment in the Linux PF driver describes it as "notify VF
00097          * of need for VLAN tag stripping, and correct queue".  It
00098          * will be filled with a non-zero value if the PF is enforcing
00099          * the use of a single VLAN tag.  It will also be filled with
00100          * a non-zero value if the PF is using multiple traffic
00101          * classes.
00102          *
00103          * The Linux VF driver seems to treat this field as being
00104          * simply the number of traffic classes, and gives it no
00105          * VLAN-related interpretation.
00106          *
00107          * If the PF is enforcing the use of a single VLAN tag for the
00108          * VF, then the VLAN tag will be transparently inserted in
00109          * transmitted packets (via the PFVMVIR register) but will
00110          * still be visible in received packets.  The Linux VF driver
00111          * handles this unexpected VLAN tag by simply ignoring any
00112          * unrecognised VLAN tags.
00113          *
00114          * We choose to strip and ignore the VLAN tag if this field
00115          * has a non-zero value.
00116          */
00117         uint32_t vlan_thing;
00118         /** Default queue */
00119         uint32_t dflt;
00120 } __attribute__ (( packed ));
00121 
00122 /** Mailbox message */
00123 union intelvf_msg {
00124         /** Message header */
00125         uint32_t hdr;
00126         /** MAC address message */
00127         struct intelvf_msg_mac mac;
00128         /** Version number message */
00129         struct intelvf_msg_version version;
00130         /** MTU message */
00131         struct intelvf_msg_mtu mtu;
00132         /** Queue configuration message */
00133         struct intelvf_msg_queues queues;
00134         /** Raw dwords */
00135         uint32_t dword[0];
00136 };
00137 
00138 /** Maximum time to wait for mailbox message
00139  *
00140  * This is a policy decision.
00141  */
00142 #define INTELVF_MBOX_MAX_WAIT_MS 500
00143 
00144 extern int intelvf_mbox_msg ( struct intel_nic *intel, union intelvf_msg *msg );
00145 extern int intelvf_mbox_poll ( struct intel_nic *intel );
00146 extern int intelvf_mbox_wait ( struct intel_nic *intel );
00147 extern int intelvf_mbox_reset ( struct intel_nic *intel, uint8_t *hw_addr );
00148 extern int intelvf_mbox_set_mac ( struct intel_nic *intel,
00149                                   const uint8_t *ll_addr );
00150 extern int intelvf_mbox_set_mtu ( struct intel_nic *intel, size_t mtu );
00151 
00152 #endif /* _INTELVF_H */