[intelxl] Separate virtual function driver definitions

Move knowledge of the virtual function data structures and admin
command definitions from intelxl.h to intelxlvf.h.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2022-08-11 14:53:57 +01:00
parent c220b93f31
commit fb69d14002
4 changed files with 320 additions and 259 deletions
+257
View File
@@ -70,6 +70,263 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** Maximum time to wait for a VF admin request to complete */
#define INTELXLVF_ADMIN_MAX_WAIT_MS 2000
/** Admin queue Send Message to PF command */
#define INTELXLVF_ADMIN_SEND_TO_PF 0x0801
/** Admin queue Send Message to VF command */
#define INTELXLVF_ADMIN_SEND_TO_VF 0x0802
/** Admin Queue VF Version opcode */
#define INTELXLVF_ADMIN_VERSION 0x00000001
/** Admin Queue VF Version data buffer */
struct intelxlvf_admin_version_buffer {
/** Major version */
uint32_t major;
/** Minor version */
uint32_t minor;
} __attribute__ (( packed ));
/** Admin queue VF API major version */
#define INTELXLVF_ADMIN_API_MAJOR 1
/** Admin queue VF API minor version */
#define INTELXLVF_ADMIN_API_MINOR 0
/** Admin Queue VF Reset opcode */
#define INTELXLVF_ADMIN_RESET 0x00000002
/** Admin Queue VF Get Resources opcode */
#define INTELXLVF_ADMIN_GET_RESOURCES 0x00000003
/** Admin Queue VF Get Resources data buffer */
struct intelxlvf_admin_get_resources_buffer {
/** Reserved */
uint8_t reserved_a[20];
/** VSI switching element ID */
uint16_t vsi;
/** Reserved */
uint8_t reserved_b[8];
/** MAC address */
uint8_t mac[ETH_ALEN];
} __attribute__ (( packed ));
/** Admin Queue VF Status Change Event opcode */
#define INTELXLVF_ADMIN_STATUS 0x00000011
/** Link status change event type */
#define INTELXLVF_ADMIN_STATUS_LINK 0x00000001
/** Link status change event data */
struct intelxlvf_admin_status_link {
/** Link speed */
uint32_t speed;
/** Link status */
uint8_t status;
/** Reserved */
uint8_t reserved[3];
} __attribute__ (( packed ));
/** Admin Queue VF Status Change Event data buffer */
struct intelxlvf_admin_status_buffer {
/** Event type */
uint32_t event;
/** Event data */
union {
/** Link change event data */
struct intelxlvf_admin_status_link link;
} data;
/** Reserved */
uint8_t reserved[4];
} __attribute__ (( packed ));
/** Admin Queue VF Configure Queues opcode */
#define INTELXLVF_ADMIN_CONFIGURE 0x00000006
/** Admin Queue VF Configure Queues data buffer */
struct intelxlvf_admin_configure_buffer {
/** VSI switching element ID */
uint16_t vsi;
/** Number of queue pairs */
uint16_t count;
/** Reserved */
uint8_t reserved_a[4];
/** Transmit queue */
struct {
/** VSI switching element ID */
uint16_t vsi;
/** Queue ID */
uint16_t id;
/** Queue count */
uint16_t count;
/** Reserved */
uint8_t reserved_a[2];
/** Base address */
uint64_t base;
/** Reserved */
uint8_t reserved_b[8];
} __attribute__ (( packed )) tx;
/** Receive queue */
struct {
/** VSI switching element ID */
uint16_t vsi;
/** Queue ID */
uint16_t id;
/** Queue count */
uint32_t count;
/** Reserved */
uint8_t reserved_a[4];
/** Data buffer length */
uint32_t len;
/** Maximum frame size */
uint32_t mfs;
/** Reserved */
uint8_t reserved_b[4];
/** Base address */
uint64_t base;
/** Reserved */
uint8_t reserved_c[8];
} __attribute__ (( packed )) rx;
/** Reserved
*
* This field exists only due to a bug in the PF driver's
* message validation logic, which causes it to miscalculate
* the expected message length.
*/
uint8_t reserved_b[64];
} __attribute__ (( packed ));
/** Admin Queue VF IRQ Map opcode */
#define INTELXLVF_ADMIN_IRQ_MAP 0x00000007
/** Admin Queue VF IRQ Map data buffer */
struct intelxlvf_admin_irq_map_buffer {
/** Number of interrupt vectors */
uint16_t count;
/** VSI switching element ID */
uint16_t vsi;
/** Interrupt vector ID */
uint16_t vec;
/** Receive queue bitmap */
uint16_t rxmap;
/** Transmit queue bitmap */
uint16_t txmap;
/** Receive interrupt throttling index */
uint16_t rxitr;
/** Transmit interrupt throttling index */
uint16_t txitr;
/** Reserved
*
* This field exists only due to a bug in the PF driver's
* message validation logic, which causes it to miscalculate
* the expected message length.
*/
uint8_t reserved[12];
} __attribute__ (( packed ));
/** Admin Queue VF Enable Queues opcode */
#define INTELXLVF_ADMIN_ENABLE 0x00000008
/** Admin Queue VF Disable Queues opcode */
#define INTELXLVF_ADMIN_DISABLE 0x00000009
/** Admin Queue VF Enable/Disable Queues data buffer */
struct intelxlvf_admin_queues_buffer {
/** VSI switching element ID */
uint16_t vsi;
/** Reserved */
uint8_t reserved[2];
/** Receive queue bitmask */
uint32_t rx;
/** Transmit queue bitmask */
uint32_t tx;
} __attribute__ (( packed ));
/** Admin Queue VF Configure Promiscuous Mode opcode */
#define INTELXLVF_ADMIN_PROMISC 0x0000000e
/** Admin Queue VF Configure Promiscuous Mode data buffer */
struct intelxlvf_admin_promisc_buffer {
/** VSI switching element ID */
uint16_t vsi;
/** Flags */
uint16_t flags;
} __attribute__ (( packed ));
/** Admin queue data buffer */
union intelxlvf_admin_buffer {
/** Original 40 Gigabit Ethernet data buffer */
union intelxl_admin_buffer xl;
/** VF Version data buffer */
struct intelxlvf_admin_version_buffer ver;
/** VF Get Resources data buffer */
struct intelxlvf_admin_get_resources_buffer res;
/** VF Status Change Event data buffer */
struct intelxlvf_admin_status_buffer stat;
/** VF Configure Queues data buffer */
struct intelxlvf_admin_configure_buffer cfg;
/** VF Enable/Disable Queues data buffer */
struct intelxlvf_admin_queues_buffer queues;
/** VF Configure Promiscuous Mode data buffer */
struct intelxlvf_admin_promisc_buffer promisc;
/** VF IRQ Map data buffer */
struct intelxlvf_admin_irq_map_buffer irq;
} __attribute__ (( packed ));
/** Admin queue descriptor */
struct intelxlvf_admin_descriptor {
/** Transparent union */
union {
/** Original 40 Gigabit Ethernet descriptor */
struct intelxl_admin_descriptor xl;
/** Transparent struct */
struct {
/** Flags */
uint16_t flags;
/** Opcode */
uint16_t opcode;
/** Data length */
uint16_t len;
/** Return value */
uint16_t ret;
/** VF opcode */
uint32_t vopcode;
/** VF return value */
int32_t vret;
/** Parameters */
union intelxl_admin_params params;
} __attribute__ (( packed ));
} __attribute__ (( packed ));
} __attribute__ (( packed ));
/**
* Get next admin command queue descriptor
*
* @v intelxl Intel device
* @ret cmd Command descriptor
*/
struct intelxlvf_admin_descriptor *
intelxlvf_admin_command_descriptor ( struct intelxl_nic *intelxl ) {
struct intelxl_admin_descriptor *xlcmd =
intelxl_admin_command_descriptor ( intelxl );
return container_of ( xlcmd, struct intelxlvf_admin_descriptor, xl );
}
/**
* Get next admin command queue data buffer
*
* @v intelxl Intel device
* @ret buf Data buffer
*/
static inline __attribute__ (( always_inline )) union intelxlvf_admin_buffer *
intelxlvf_admin_command_buffer ( struct intelxl_nic *intelxl ) {
union intelxl_admin_buffer *xlbuf =
intelxl_admin_command_buffer ( intelxl );
return container_of ( xlbuf, union intelxlvf_admin_buffer, xl );
}
/** VF Reset Status Register */
#define INTELXLVF_VFGEN_RSTAT 0x8800
#define INTELXLVF_VFGEN_RSTAT_VFR_STATE(x) ( (x) & 0x3 )