]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[intelxl] Reuse admin command descriptor and buffer for VF responses
authorMichael Brown <mcb30@ipxe.org>
Mon, 8 Aug 2022 13:48:25 +0000 (14:48 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 11 Aug 2022 13:53:57 +0000 (14:53 +0100)
Remove the large static admin data buffer structure embedded within
struct intelxl_nic, and instead copy the response received via the
"send to VF" admin queue event to the (already consumed and completed)
admin command descriptor and data buffer.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/intelxl.h
src/drivers/net/intelxlvf.c

index cd0d2ee81c91fe3d4facfcfb6dcafacd27bc1d06..771932c0bdc0472d1aca8f031650d3f9b3b2ef39 100644 (file)
@@ -1092,10 +1092,6 @@ struct intelxl_nic {
 
        /** Current VF opcode */
        unsigned int vopcode;
-       /** Current VF return value */
-       int vret;
-       /** Current VF event data buffer */
-       union intelxl_admin_buffer vbuf;
 
        /** Transmit descriptor ring */
        struct intelxl_ring tx;
index 6f52f139353afa84466d3dd9ad1532e2dc4c74c6..8774b110a66c95412b2b63e09f9a89c7a3f30a79 100644 (file)
@@ -201,7 +201,7 @@ static int intelxlvf_admin_command ( struct net_device *netdev ) {
                }
 
                /* Check for errors */
-               if ( intelxl->vret != 0 )
+               if ( cmd->vret != 0 )
                        return -EIO;
 
                return 0;
@@ -271,7 +271,9 @@ static void intelxlvf_admin_event ( struct net_device *netdev,
                                    struct intelxl_admin_descriptor *evt,
                                    union intelxl_admin_buffer *buf ) {
        struct intelxl_nic *intelxl = netdev->priv;
+       struct intelxl_admin *admin = &intelxl->command;
        unsigned int vopcode;
+       unsigned int index;
 
        /* Ignore unrecognised events */
        if ( evt->opcode != cpu_to_le16 ( INTELXL_ADMIN_SEND_TO_VF ) ) {
@@ -283,12 +285,14 @@ static void intelxlvf_admin_event ( struct net_device *netdev,
        /* Record command response if applicable */
        vopcode = le32_to_cpu ( evt->vopcode );
        if ( vopcode == intelxl->vopcode ) {
-               memcpy ( &intelxl->vbuf, buf, sizeof ( intelxl->vbuf ) );
+               index = ( ( admin->index - 1 ) % INTELXL_ADMIN_NUM_DESC );
+               memcpy ( &admin->desc[index], evt, sizeof ( *evt ) );
+               memcpy ( &admin->buf[index], buf, sizeof ( *buf ) );
                intelxl->vopcode = 0;
-               intelxl->vret = le32_to_cpu ( evt->vret );
-               if ( intelxl->vret != 0 ) {
+               if ( evt->vret != 0 ) {
                        DBGC ( intelxl, "INTELXL %p admin VF command %#x "
-                              "error %d\n", intelxl, vopcode, intelxl->vret );
+                              "error %d\n", intelxl, vopcode,
+                              le32_to_cpu ( evt->vret ) );
                        DBGC_HDA ( intelxl, virt_to_phys ( evt ), evt,
                                   sizeof ( *evt ) );
                        DBGC_HDA ( intelxl, virt_to_phys ( buf ), buf,
@@ -322,7 +326,6 @@ 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;
-       struct intelxl_admin_vf_version_buffer *ver;
        union intelxl_admin_buffer *buf;
        unsigned int api;
        int rc;
@@ -339,10 +342,9 @@ static int intelxlvf_admin_version ( struct net_device *netdev ) {
        /* Issue command */
        if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
                return rc;
-       ver = &intelxl->vbuf.ver;
-       api = le32_to_cpu ( ver->major );
+       api = le32_to_cpu ( buf->ver.major );
        DBGC ( intelxl, "INTELXL %p API v%d.%d\n",
-              intelxl, api, le32_to_cpu ( ver->minor ) );
+              intelxl, api, le32_to_cpu ( buf->ver.minor ) );
 
        /* Check for API compatibility */
        if ( api > INTELXL_ADMIN_VF_API_MAJOR ) {
@@ -363,21 +365,21 @@ 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;
-       struct intelxl_admin_vf_get_resources_buffer *res;
+       union intelxl_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 );
 
        /* Issue command */
        if ( ( rc = intelxlvf_admin_command ( netdev ) ) != 0 )
                return rc;
 
        /* Parse response */
-       res = &intelxl->vbuf.res;
-       intelxl->vsi = le16_to_cpu ( res->vsi );
-       memcpy ( netdev->hw_addr, res->mac, ETH_ALEN );
+       intelxl->vsi = le16_to_cpu ( buf->res.vsi );
+       memcpy ( netdev->hw_addr, buf->res.mac, ETH_ALEN );
        DBGC ( intelxl, "INTELXL %p VSI %#04x\n", intelxl, intelxl->vsi );
 
        return 0;