]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[intelxl] Separate virtual function driver definitions
authorMichael Brown <mcb30@ipxe.org>
Mon, 8 Aug 2022 13:57:40 +0000 (14:57 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 11 Aug 2022 13:53:57 +0000 (14:53 +0100)
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>
src/drivers/net/intelxl.c
src/drivers/net/intelxl.h
src/drivers/net/intelxlvf.c
src/drivers/net/intelxlvf.h

index e31595e1ceef7a90e1cba4c638b18370f3d70e88..51e888a60457127f5a8e06fb570fc210e6793733 100644 (file)
@@ -360,8 +360,8 @@ int intelxl_admin_command ( struct intelxl_nic *intelxl ) {
        buf = &admin->buf[ index % INTELXL_ADMIN_NUM_DESC ];
        DBGC2 ( intelxl, "INTELXL %p admin command %#x opcode %#04x",
                intelxl, index, le16_to_cpu ( cmd->opcode ) );
-       if ( cmd->vopcode )
-               DBGC2 ( intelxl, "/%#08x", le32_to_cpu ( cmd->vopcode ) );
+       if ( cmd->cookie )
+               DBGC2 ( intelxl, "/%#08x", le32_to_cpu ( cmd->cookie ) );
        DBGC2 ( intelxl, ":\n" );
 
        /* Sanity checks */
@@ -378,7 +378,7 @@ int intelxl_admin_command ( struct intelxl_nic *intelxl ) {
        }
 
        /* Populate cookie, if not being (ab)used for VF opcode */
-       if ( ! cmd->vopcode )
+       if ( ! cmd->cookie )
                cmd->cookie = cpu_to_le32 ( index );
 
        /* Record cookie */
index 771932c0bdc0472d1aca8f031650d3f9b3b2ef39..49a825bc75be7f2708e9ffde37f1f7ad906df742 100644 (file)
@@ -305,183 +305,6 @@ struct intelxl_admin_link_params {
 /** Link is up */
 #define INTELXL_ADMIN_LINK_UP 0x01
 
-/** Admin queue Send Message to PF command */
-#define INTELXL_ADMIN_SEND_TO_PF 0x0801
-
-/** Admin queue Send Message to VF command */
-#define INTELXL_ADMIN_SEND_TO_VF 0x0802
-
-/** Admin Queue VF Version opcode */
-#define INTELXL_ADMIN_VF_VERSION 0x00000001
-
-/** Admin Queue VF Version data buffer */
-struct intelxl_admin_vf_version_buffer {
-       /** Major version */
-       uint32_t major;
-       /** Minor version */
-       uint32_t minor;
-} __attribute__ (( packed ));
-
-/** Admin Queue VF Reset opcode */
-#define INTELXL_ADMIN_VF_RESET 0x00000002
-
-/** Admin Queue VF Get Resources opcode */
-#define INTELXL_ADMIN_VF_GET_RESOURCES 0x00000003
-
-/** Admin Queue VF Get Resources data buffer */
-struct intelxl_admin_vf_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 INTELXL_ADMIN_VF_STATUS 0x00000011
-
-/** Link status change event type */
-#define INTELXL_ADMIN_VF_STATUS_LINK 0x00000001
-
-/** Link status change event data */
-struct intelxl_admin_vf_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 intelxl_admin_vf_status_buffer {
-       /** Event type */
-       uint32_t event;
-       /** Event data */
-       union {
-               /** Link change event data */
-               struct intelxl_admin_vf_status_link link;
-       } data;
-       /** Reserved */
-       uint8_t reserved[4];
-} __attribute__ (( packed ));
-
-/** Admin Queue VF Configure Queues opcode */
-#define INTELXL_ADMIN_VF_CONFIGURE 0x00000006
-
-/** Admin Queue VF Configure Queues data buffer */
-struct intelxl_admin_vf_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 INTELXL_ADMIN_VF_IRQ_MAP 0x00000007
-
-/** Admin Queue VF IRQ Map data buffer */
-struct intelxl_admin_vf_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 INTELXL_ADMIN_VF_ENABLE 0x00000008
-
-/** Admin Queue VF Disable Queues opcode */
-#define INTELXL_ADMIN_VF_DISABLE 0x00000009
-
-/** Admin Queue VF Enable/Disable Queues data buffer */
-struct intelxl_admin_vf_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 INTELXL_ADMIN_VF_PROMISC 0x0000000e
-
-/** Admin Queue VF Configure Promiscuous Mode data buffer */
-struct intelxl_admin_vf_promisc_buffer {
-       /** VSI switching element ID */
-       uint16_t vsi;
-       /** Flags */
-       uint16_t flags;
-} __attribute__ (( packed ));
-
 /** Admin queue command parameters */
 union intelxl_admin_params {
        /** Additional data buffer command parameters */
@@ -514,20 +337,6 @@ union intelxl_admin_buffer {
        struct intelxl_admin_switch_buffer sw;
        /** Get VSI Parameters data buffer */
        struct intelxl_admin_vsi_buffer vsi;
-       /** VF Version data buffer */
-       struct intelxl_admin_vf_version_buffer ver;
-       /** VF Get Resources data buffer */
-       struct intelxl_admin_vf_get_resources_buffer res;
-       /** VF Status Change Event data buffer */
-       struct intelxl_admin_vf_status_buffer stat;
-       /** VF Configure Queues data buffer */
-       struct intelxl_admin_vf_configure_buffer cfg;
-       /** VF Enable/Disable Queues data buffer */
-       struct intelxl_admin_vf_queues_buffer queues;
-       /** VF Configure Promiscuous Mode data buffer */
-       struct intelxl_admin_vf_promisc_buffer promisc;
-       /*** VF IRQ Map data buffer */
-       struct intelxl_admin_vf_irq_map_buffer irq;
        /** Alignment padding */
        uint8_t pad[INTELXL_ALIGN];
 } __attribute__ (( packed ));
@@ -542,15 +351,10 @@ struct intelxl_admin_descriptor {
        uint16_t len;
        /** Return value */
        uint16_t ret;
-       /** Opaque cookie / VF opcode */
-       union {
-               /** Cookie */
-               uint32_t cookie;
-               /** VF opcode */
-               uint32_t vopcode;
-       };
-       /** VF return value */
-       int32_t vret;
+       /** Opaque cookie */
+       uint32_t cookie;
+       /** Reserved */
+       uint8_t reserved[4];
        /** Parameters */
        union intelxl_admin_params params;
 } __attribute__ (( packed ));
@@ -611,12 +415,6 @@ intelxl_init_admin ( struct intelxl_admin *admin, unsigned int base,
 /** Admin queue API major version */
 #define INTELXL_ADMIN_API_MAJOR 1
 
-/** Admin queue VF API major version */
-#define INTELXL_ADMIN_VF_API_MAJOR 1
-
-/** Admin queue VF API minor version */
-#define INTELXL_ADMIN_VF_API_MINOR 0
-
 /******************************************************************************
  *
  * Transmit and receive queue context
index 8774b110a66c95412b2b63e09f9a89c7a3f30a79..3567be456bf42f30789f2f5c20cbac08ed487d9f 100644 (file)
@@ -109,13 +109,13 @@ static int intelxlvf_reset_wait_active ( struct intelxl_nic *intelxl ) {
  * @ret rc             Return status code
  */
 static int intelxlvf_reset_admin ( struct intelxl_nic *intelxl ) {
-       struct intelxl_admin_descriptor *cmd;
+       struct intelxlvf_admin_descriptor *cmd;
        int rc;
 
        /* Populate descriptor */
-       cmd = intelxl_admin_command_descriptor ( intelxl );
-       cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SEND_TO_PF );
-       cmd->vopcode = cpu_to_le32 ( INTELXL_ADMIN_VF_RESET );
+       cmd = intelxlvf_admin_command_descriptor ( intelxl );
+       cmd->opcode = cpu_to_le16 ( INTELXLVF_ADMIN_SEND_TO_PF );
+       cmd->vopcode = cpu_to_le32 ( INTELXLVF_ADMIN_RESET );
 
        /* Issue command */
        if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 )
@@ -173,13 +173,15 @@ static const struct intelxl_admin_offsets intelxlvf_admin_event_offsets = {
 static int intelxlvf_admin_command ( struct net_device *netdev ) {
        struct intelxl_nic *intelxl = netdev->priv;
        struct intelxl_admin *admin = &intelxl->command;
-       struct intelxl_admin_descriptor *cmd;
+       struct intelxl_admin_descriptor *xlcmd;
+       struct intelxlvf_admin_descriptor *cmd;
        unsigned int i;
        int rc;
 
        /* Populate descriptor */
-       cmd = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
-       cmd->opcode = cpu_to_le16 ( INTELXL_ADMIN_SEND_TO_PF );
+       xlcmd = &admin->desc[ admin->index % INTELXL_ADMIN_NUM_DESC ];
+       cmd = container_of ( xlcmd, struct intelxlvf_admin_descriptor, xl );
+       cmd->opcode = cpu_to_le16 ( INTELXLVF_ADMIN_SEND_TO_PF );
 
        /* Record opcode */
        intelxl->vopcode = le32_to_cpu ( cmd->vopcode );
@@ -222,7 +224,7 @@ static int intelxlvf_admin_command ( struct net_device *netdev ) {
  * @v link             Link status
  */
 static void intelxlvf_admin_link ( struct net_device *netdev,
-                                  struct intelxl_admin_vf_status_link *link ) {
+                                  struct intelxlvf_admin_status_link *link ) {
        struct intelxl_nic *intelxl = netdev->priv;
 
        DBGC ( intelxl, "INTELXL %p link %#02x speed %#02x\n", intelxl,
@@ -244,12 +246,12 @@ static void intelxlvf_admin_link ( struct net_device *netdev,
  */
 static void
 intelxlvf_admin_status ( struct net_device *netdev,
-                        struct intelxl_admin_vf_status_buffer *stat ) {
+                        struct intelxlvf_admin_status_buffer *stat ) {
        struct intelxl_nic *intelxl = netdev->priv;
 
        /* Handle event */
        switch ( stat->event ) {
-       case cpu_to_le32 ( INTELXL_ADMIN_VF_STATUS_LINK ):
+       case cpu_to_le32 ( INTELXLVF_ADMIN_STATUS_LINK ):
                intelxlvf_admin_link ( netdev, &stat->data.link );
                break;
        default:
@@ -264,19 +266,23 @@ intelxlvf_admin_status ( struct net_device *netdev,
  * Handle admin event
  *
  * @v netdev           Network device
- * @v evt              Admin queue event descriptor
- * @v buf              Admin queue event data buffer
+ * @v xlevt            Admin queue event descriptor
+ * @v xlbuf            Admin queue event data buffer
  */
 static void intelxlvf_admin_event ( struct net_device *netdev,
-                                   struct intelxl_admin_descriptor *evt,
-                                   union intelxl_admin_buffer *buf ) {
+                                   struct intelxl_admin_descriptor *xlevt,
+                                   union intelxl_admin_buffer *xlbuf ) {
        struct intelxl_nic *intelxl = netdev->priv;
        struct intelxl_admin *admin = &intelxl->command;
+       struct intelxlvf_admin_descriptor *evt =
+               container_of ( xlevt, struct intelxlvf_admin_descriptor, xl );
+       union intelxlvf_admin_buffer *buf =
+               container_of ( xlbuf, union intelxlvf_admin_buffer, xl );
        unsigned int vopcode;
        unsigned int index;
 
        /* Ignore unrecognised events */
-       if ( evt->opcode != cpu_to_le16 ( INTELXL_ADMIN_SEND_TO_VF ) ) {
+       if ( evt->opcode != cpu_to_le16 ( INTELXLVF_ADMIN_SEND_TO_VF ) ) {
                DBGC ( intelxl, "INTELXL %p unrecognised event opcode "
                       "%#04x\n", intelxl, le16_to_cpu ( evt->opcode ) );
                return;
@@ -303,7 +309,7 @@ static void intelxlvf_admin_event ( struct net_device *netdev,
 
        /* Handle unsolicited events */
        switch ( vopcode ) {
-       case INTELXL_ADMIN_VF_STATUS:
+       case INTELXLVF_ADMIN_STATUS:
                intelxlvf_admin_status ( netdev, &buf->stat );
                break;
        default:
@@ -325,19 +331,19 @@ static void intelxlvf_admin_event ( struct net_device *netdev,
  */
 static int intelxlvf_admin_version ( struct net_device *netdev ) {
        struct intelxl_nic *intelxl = netdev->priv;
-       struct intelxl_admin_descriptor *cmd;
-       union intelxl_admin_buffer *buf;
+       struct intelxlvf_admin_descriptor *cmd;
+       union intelxlvf_admin_buffer *buf;
        unsigned int api;
        int rc;
 
        /* Populate descriptor */
-       cmd = intelxl_admin_command_descriptor ( intelxl );
-       cmd->vopcode = cpu_to_le32 ( INTELXL_ADMIN_VF_VERSION );
+       cmd = intelxlvf_admin_command_descriptor ( intelxl );
+       cmd->vopcode = cpu_to_le32 ( INTELXLVF_ADMIN_VERSION );
        cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_RD | INTELXL_ADMIN_FL_BUF );
        cmd->len = cpu_to_le16 ( sizeof ( buf->ver ) );
-       buf = intelxl_admin_command_buffer ( intelxl );
-       buf->ver.major = cpu_to_le32 ( INTELXL_ADMIN_VF_API_MAJOR );
-       buf->ver.minor = cpu_to_le32 ( INTELXL_ADMIN_VF_API_MINOR );
+       buf = intelxlvf_admin_command_buffer ( intelxl );
+       buf->ver.major = cpu_to_le32 ( INTELXLVF_ADMIN_API_MAJOR );
+       buf->ver.minor = cpu_to_le32 ( INTELXLVF_ADMIN_API_MINOR );
 
        /* Issue command */
        if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
@@ -347,7 +353,7 @@ static int intelxlvf_admin_version ( struct net_device *netdev ) {
               intelxl, api, le32_to_cpu ( buf->ver.minor ) );
 
        /* Check for API compatibility */
-       if ( api > INTELXL_ADMIN_VF_API_MAJOR ) {
+       if ( api > INTELXLVF_ADMIN_API_MAJOR ) {
                DBGC ( intelxl, "INTELXL %p unsupported API v%d\n",
                       intelxl, api );
                return -ENOTSUP;
@@ -364,14 +370,14 @@ static int intelxlvf_admin_version ( struct net_device *netdev ) {
  */
 static int intelxlvf_admin_get_resources ( struct net_device *netdev ) {
        struct intelxl_nic *intelxl = netdev->priv;
-       struct intelxl_admin_descriptor *cmd;
-       union intelxl_admin_buffer *buf;
+       struct intelxlvf_admin_descriptor *cmd;
+       union intelxlvf_admin_buffer *buf;
        int rc;
 
        /* Populate descriptor */
-       cmd = intelxl_admin_command_descriptor ( intelxl );
-       cmd->vopcode = cpu_to_le32 ( INTELXL_ADMIN_VF_GET_RESOURCES );
-       buf = intelxl_admin_command_buffer ( intelxl );
+       cmd = intelxlvf_admin_command_descriptor ( intelxl );
+       cmd->vopcode = cpu_to_le32 ( INTELXLVF_ADMIN_GET_RESOURCES );
+       buf = intelxlvf_admin_command_buffer ( intelxl );
 
        /* Issue command */
        if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
@@ -400,16 +406,16 @@ static int intelxlvf_admin_get_resources ( struct net_device *netdev ) {
  */
 static int intelxlvf_admin_configure ( struct net_device *netdev ) {
        struct intelxl_nic *intelxl = netdev->priv;
-       struct intelxl_admin_descriptor *cmd;
-       union intelxl_admin_buffer *buf;
+       struct intelxlvf_admin_descriptor *cmd;
+       union intelxlvf_admin_buffer *buf;
        int rc;
 
        /* Populate descriptor */
-       cmd = intelxl_admin_command_descriptor ( intelxl );
-       cmd->vopcode = cpu_to_le32 ( INTELXL_ADMIN_VF_CONFIGURE );
+       cmd = intelxlvf_admin_command_descriptor ( intelxl );
+       cmd->vopcode = cpu_to_le32 ( INTELXLVF_ADMIN_CONFIGURE );
        cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_RD | INTELXL_ADMIN_FL_BUF );
        cmd->len = cpu_to_le16 ( sizeof ( buf->cfg ) );
-       buf = intelxl_admin_command_buffer ( intelxl );
+       buf = intelxlvf_admin_command_buffer ( intelxl );
        buf->cfg.vsi = cpu_to_le16 ( intelxl->vsi );
        buf->cfg.count = cpu_to_le16 ( 1 );
        buf->cfg.tx.vsi = cpu_to_le16 ( intelxl->vsi );
@@ -438,16 +444,16 @@ static int intelxlvf_admin_configure ( struct net_device *netdev ) {
  */
 static int intelxlvf_admin_irq_map ( struct net_device *netdev ) {
        struct intelxl_nic *intelxl = netdev->priv;
-       struct intelxl_admin_descriptor *cmd;
-       union intelxl_admin_buffer *buf;
+       struct intelxlvf_admin_descriptor *cmd;
+       union intelxlvf_admin_buffer *buf;
        int rc;
 
        /* Populate descriptor */
-       cmd = intelxl_admin_command_descriptor ( intelxl );
-       cmd->vopcode = cpu_to_le32 ( INTELXL_ADMIN_VF_IRQ_MAP );
+       cmd = intelxlvf_admin_command_descriptor ( intelxl );
+       cmd->vopcode = cpu_to_le32 ( INTELXLVF_ADMIN_IRQ_MAP );
        cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_RD | INTELXL_ADMIN_FL_BUF );
        cmd->len = cpu_to_le16 ( sizeof ( buf->irq ) );
-       buf = intelxl_admin_command_buffer ( intelxl );
+       buf = intelxlvf_admin_command_buffer ( intelxl );
        buf->irq.count = cpu_to_le16 ( 1 );
        buf->irq.vsi = cpu_to_le16 ( intelxl->vsi );
        buf->irq.vec = cpu_to_le16 ( INTELXLVF_MSIX_VECTOR );
@@ -470,17 +476,17 @@ static int intelxlvf_admin_irq_map ( struct net_device *netdev ) {
  */
 static int intelxlvf_admin_queues ( struct net_device *netdev, int enable ) {
        struct intelxl_nic *intelxl = netdev->priv;
-       struct intelxl_admin_descriptor *cmd;
-       union intelxl_admin_buffer *buf;
+       struct intelxlvf_admin_descriptor *cmd;
+       union intelxlvf_admin_buffer *buf;
        int rc;
 
        /* Populate descriptor */
-       cmd = intelxl_admin_command_descriptor ( intelxl );
-       cmd->vopcode = ( enable ? cpu_to_le32 ( INTELXL_ADMIN_VF_ENABLE ) :
-                        cpu_to_le32 ( INTELXL_ADMIN_VF_DISABLE ) );
+       cmd = intelxlvf_admin_command_descriptor ( intelxl );
+       cmd->vopcode = ( enable ? cpu_to_le32 ( INTELXLVF_ADMIN_ENABLE ) :
+                        cpu_to_le32 ( INTELXLVF_ADMIN_DISABLE ) );
        cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_RD | INTELXL_ADMIN_FL_BUF );
        cmd->len = cpu_to_le16 ( sizeof ( buf->queues ) );
-       buf = intelxl_admin_command_buffer ( intelxl );
+       buf = intelxlvf_admin_command_buffer ( intelxl );
        buf->queues.vsi = cpu_to_le16 ( intelxl->vsi );
        buf->queues.rx = cpu_to_le32 ( 1 );
        buf->queues.tx = cpu_to_le32 ( 1 );
@@ -500,16 +506,16 @@ static int intelxlvf_admin_queues ( struct net_device *netdev, int enable ) {
  */
 static int intelxlvf_admin_promisc ( struct net_device *netdev ) {
        struct intelxl_nic *intelxl = netdev->priv;
-       struct intelxl_admin_descriptor *cmd;
-       union intelxl_admin_buffer *buf;
+       struct intelxlvf_admin_descriptor *cmd;
+       union intelxlvf_admin_buffer *buf;
        int rc;
 
        /* Populate descriptor */
-       cmd = intelxl_admin_command_descriptor ( intelxl );
-       cmd->vopcode = cpu_to_le32 ( INTELXL_ADMIN_VF_PROMISC );
+       cmd = intelxlvf_admin_command_descriptor ( intelxl );
+       cmd->vopcode = cpu_to_le32 ( INTELXLVF_ADMIN_PROMISC );
        cmd->flags = cpu_to_le16 ( INTELXL_ADMIN_FL_RD | INTELXL_ADMIN_FL_BUF );
        cmd->len = cpu_to_le16 ( sizeof ( buf->promisc ) );
-       buf = intelxl_admin_command_buffer ( intelxl );
+       buf = intelxlvf_admin_command_buffer ( intelxl );
        buf->promisc.vsi = cpu_to_le16 ( intelxl->vsi );
        buf->promisc.flags = cpu_to_le16 ( INTELXL_ADMIN_PROMISC_FL_UNICAST |
                                           INTELXL_ADMIN_PROMISC_FL_MULTICAST );
index 58ade11e96b552bd1efdafc687a04fa8d257684a..5c22275771a438f77bd4c80908b9dd85d05e6edf 100644 (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 )