qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Yuval Shaia <yuval.shaia@oracle.com>,
	dmitry.fleytman@gmail.com, jasowang@redhat.com,
	eblake@redhat.com, armbru@redhat.com, pbonzini@redhat.com,
	qemu-devel@nongnu.org, shamir.rabinovitch@oracle.com,
	cohuck@redhat.com
Subject: Re: [Qemu-devel] [PATCH v5 17/24] hw/pvrdma: Fill error code in command's response
Date: Sun, 25 Nov 2018 09:40:33 +0200	[thread overview]
Message-ID: <335892d6-7475-8465-4b20-060bd2960c0f@gmail.com> (raw)
In-Reply-To: <20181122121402.13764-18-yuval.shaia@oracle.com>



On 11/22/18 2:13 PM, Yuval Shaia wrote:
> Driver checks error code let's set it.
>
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
>   hw/rdma/vmw/pvrdma_cmd.c | 67 ++++++++++++++++++++++++++++------------
>   1 file changed, 48 insertions(+), 19 deletions(-)
>
> diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
> index 0d3c818c20..a326c5d470 100644
> --- a/hw/rdma/vmw/pvrdma_cmd.c
> +++ b/hw/rdma/vmw/pvrdma_cmd.c
> @@ -131,7 +131,8 @@ static int query_port(PVRDMADev *dev, union pvrdma_cmd_req *req,
>   
>       if (rdma_backend_query_port(&dev->backend_dev,
>                                   (struct ibv_port_attr *)&attrs)) {
> -        return -ENOMEM;
> +        resp->hdr.err = -ENOMEM;
> +        goto out;
>       }
>   
>       memset(resp, 0, sizeof(*resp));
> @@ -150,7 +151,9 @@ static int query_port(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       resp->attrs.active_width = 1;
>       resp->attrs.active_speed = 1;
>   
> -    return 0;
> +out:
> +    pr_dbg("ret=%d\n", resp->hdr.err);
> +    return resp->hdr.err;
>   }
>   
>   static int query_pkey(PVRDMADev *dev, union pvrdma_cmd_req *req,
> @@ -170,7 +173,7 @@ static int query_pkey(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       resp->pkey = PVRDMA_PKEY;
>       pr_dbg("pkey=0x%x\n", resp->pkey);
>   
> -    return 0;
> +    return resp->hdr.err;
>   }
>   
>   static int create_pd(PVRDMADev *dev, union pvrdma_cmd_req *req,
> @@ -200,7 +203,9 @@ static int destroy_pd(PVRDMADev *dev, union pvrdma_cmd_req *req,
>   
>       rdma_rm_dealloc_pd(&dev->rdma_dev_res, cmd->pd_handle);
>   
> -    return 0;
> +    rsp->hdr.err = 0;
> +
> +    return rsp->hdr.err;
>   }
>   
>   static int create_mr(PVRDMADev *dev, union pvrdma_cmd_req *req,
> @@ -251,7 +256,9 @@ static int destroy_mr(PVRDMADev *dev, union pvrdma_cmd_req *req,
>   
>       rdma_rm_dealloc_mr(&dev->rdma_dev_res, cmd->mr_handle);
>   
> -    return 0;
> +    rsp->hdr.err = 0;
> +
> +    return rsp->hdr.err;
>   }
>   
>   static int create_cq_ring(PCIDevice *pci_dev , PvrdmaRing **ring,
> @@ -353,7 +360,8 @@ static int destroy_cq(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       cq = rdma_rm_get_cq(&dev->rdma_dev_res, cmd->cq_handle);
>       if (!cq) {
>           pr_dbg("Invalid CQ handle\n");
> -        return -EINVAL;
> +        rsp->hdr.err = -EINVAL;
> +        goto out;
>       }
>   
>       ring = (PvrdmaRing *)cq->opaque;
> @@ -364,7 +372,11 @@ static int destroy_cq(PVRDMADev *dev, union pvrdma_cmd_req *req,
>   
>       rdma_rm_dealloc_cq(&dev->rdma_dev_res, cmd->cq_handle);
>   
> -    return 0;
> +    rsp->hdr.err = 0;
> +
> +out:
> +    pr_dbg("ret=%d\n", rsp->hdr.err);
> +    return rsp->hdr.err;
>   }
>   
>   static int create_qp_rings(PCIDevice *pci_dev, uint64_t pdir_dma,
> @@ -553,7 +565,8 @@ static int destroy_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       qp = rdma_rm_get_qp(&dev->rdma_dev_res, cmd->qp_handle);
>       if (!qp) {
>           pr_dbg("Invalid QP handle\n");
> -        return -EINVAL;
> +        rsp->hdr.err = -EINVAL;
> +        goto out;
>       }
>   
>       rdma_rm_dealloc_qp(&dev->rdma_dev_res, cmd->qp_handle);
> @@ -567,7 +580,11 @@ static int destroy_qp(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       rdma_pci_dma_unmap(PCI_DEVICE(dev), ring->ring_state, TARGET_PAGE_SIZE);
>       g_free(ring);
>   
> -    return 0;
> +    rsp->hdr.err = 0;
> +
> +out:
> +    pr_dbg("ret=%d\n", rsp->hdr.err);
> +    return rsp->hdr.err;
>   }
>   
>   static int create_bind(PVRDMADev *dev, union pvrdma_cmd_req *req,
> @@ -580,7 +597,8 @@ static int create_bind(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       pr_dbg("index=%d\n", cmd->index);
>   
>       if (cmd->index >= MAX_PORT_GIDS) {
> -        return -EINVAL;
> +        rsp->hdr.err = -EINVAL;
> +        goto out;
>       }
>   
>       pr_dbg("gid[%d]=0x%llx,0x%llx\n", cmd->index,
> @@ -590,10 +608,15 @@ static int create_bind(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       rc = rdma_rm_add_gid(&dev->rdma_dev_res, &dev->backend_dev,
>                            dev->backend_eth_device_name, gid, cmd->index);
>       if (rc < 0) {
> -        return -EINVAL;
> +        rsp->hdr.err = rc;
> +        goto out;
>       }
>   
> -    return 0;
> +    rsp->hdr.err = 0;
> +
> +out:
> +    pr_dbg("ret=%d\n", rsp->hdr.err);
> +    return rsp->hdr.err;
>   }
>   
>   static int destroy_bind(PVRDMADev *dev, union pvrdma_cmd_req *req,
> @@ -606,7 +629,8 @@ static int destroy_bind(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       pr_dbg("index=%d\n", cmd->index);
>   
>       if (cmd->index >= MAX_PORT_GIDS) {
> -        return -EINVAL;
> +        rsp->hdr.err = -EINVAL;
> +        goto out;
>       }
>   
>       rc = rdma_rm_del_gid(&dev->rdma_dev_res, &dev->backend_dev,
> @@ -617,7 +641,11 @@ static int destroy_bind(PVRDMADev *dev, union pvrdma_cmd_req *req,
>           goto out;
>       }
>   
> -    return 0;
> +    rsp->hdr.err = 0;
> +
> +out:
> +    pr_dbg("ret=%d\n", rsp->hdr.err);
> +    return rsp->hdr.err;
>   }
>   
>   static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,
> @@ -634,9 +662,8 @@ static int create_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,
>       resp->hdr.err = rdma_rm_alloc_uc(&dev->rdma_dev_res, cmd->pfn,
>                                        &resp->ctx_handle);
>   
> -    pr_dbg("ret=%d\n", resp->hdr.err);
> -
> -    return 0;
> +    pr_dbg("ret=%d\n", rsp->hdr.err);
> +    return rsp->hdr.err;
>   }
>   
>   static int destroy_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,
> @@ -648,7 +675,9 @@ static int destroy_uc(PVRDMADev *dev, union pvrdma_cmd_req *req,
>   
>       rdma_rm_dealloc_uc(&dev->rdma_dev_res, cmd->ctx_handle);
>   
> -    return 0;
> +    rsp->hdr.err = 0;
> +
> +    return rsp->hdr.err;
>   }
>   struct cmd_handler {
>       uint32_t cmd;
> @@ -696,7 +725,7 @@ int execute_command(PVRDMADev *dev)
>       }
>   
>       err = cmd_handlers[dsr_info->req->hdr.cmd].exec(dev, dsr_info->req,
> -                            dsr_info->rsp);
> +                                                    dsr_info->rsp);
>   out:
>       set_reg_val(dev, PVRDMA_REG_ERR, err);
>       post_interrupt(dev, INTR_VEC_CMD_RING);


As I responded in V4 thread :) one might forget to set hdr.error to 0
resulting in errors hard to debug.

Please consider clearing the field on init.

Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>

Thanks,
Marcel

  reply	other threads:[~2018-11-25  7:41 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-22 12:13 [Qemu-devel] [PATCH v5 00/24] Add support for RDMA MAD Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 01/24] contrib/rdmacm-mux: Add implementation of RDMA User MAD multiplexer Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 02/24] hw/rdma: Add ability to force notification without re-arm Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 03/24] hw/rdma: Return qpn 1 if ibqp is NULL Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 04/24] hw/rdma: Abort send-op if fail to create addr handler Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 05/24] hw/rdma: Add support for MAD packets Yuval Shaia
2018-11-25  7:05   ` Marcel Apfelbaum
2018-11-25  7:27     ` Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 06/24] hw/pvrdma: Make function reset_device return void Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 07/24] hw/pvrdma: Make default pkey 0xFFFF Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 08/24] hw/pvrdma: Set the correct opcode for recv completion Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 09/24] hw/pvrdma: Set the correct opcode for send completion Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 10/24] qapi: Define new QMP message for pvrdma Yuval Shaia
2018-11-26 10:01   ` Markus Armbruster
2018-11-26 10:08     ` Yuval Shaia
2018-11-26 20:43     ` Eric Blake
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 11/24] hw/pvrdma: Add support to allow guest to configure GID table Yuval Shaia
2018-11-25  7:29   ` Marcel Apfelbaum
2018-11-25  9:10     ` Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 12/24] vmxnet3: Move some definitions to header file Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 13/24] hw/pvrdma: Make sure PCI function 0 is vmxnet3 Yuval Shaia
2018-11-25  7:31   ` Marcel Apfelbaum
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 14/24] hw/rdma: Initialize node_guid from vmxnet3 mac address Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 15/24] hw/pvrdma: Make device state depend on Ethernet function state Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 16/24] hw/pvrdma: Fill all CQE fields Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 17/24] hw/pvrdma: Fill error code in command's response Yuval Shaia
2018-11-25  7:40   ` Marcel Apfelbaum [this message]
2018-11-25 11:53     ` Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 18/24] hw/rdma: Remove unneeded code that handles more that one port Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 19/24] vl: Introduce shutdown_notifiers Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 20/24] hw/pvrdma: Clean device's resource when system is shutdown Yuval Shaia
2018-11-22 12:13 ` [Qemu-devel] [PATCH v5 21/24] hw/rdma: Do not use bitmap_zero_extend to free bitmap Yuval Shaia
2018-11-22 12:14 ` [Qemu-devel] [PATCH v5 22/24] hw/rdma: Do not call rdma_backend_del_gid on an empty gid Yuval Shaia
2018-11-22 12:14 ` [Qemu-devel] [PATCH v5 23/24] hw/pvrdma: Do not clean resources on shutdown Yuval Shaia
2018-11-25  7:30   ` Yuval Shaia
2018-11-25  7:41   ` Marcel Apfelbaum
2018-11-22 12:14 ` [Qemu-devel] [PATCH v5 24/24] docs: Update pvrdma device documentation Yuval Shaia
     [not found]   ` <8b89bfaf-be29-e043-32fa-9615fb4ea0f7@gmail.com>
2018-11-26 10:34     ` Marcel Apfelbaum
2018-11-26 13:05       ` Yuval Shaia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=335892d6-7475-8465-4b20-060bd2960c0f@gmail.com \
    --to=marcel.apfelbaum@gmail.com \
    --cc=armbru@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=dmitry.fleytman@gmail.com \
    --cc=eblake@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shamir.rabinovitch@oracle.com \
    --cc=yuval.shaia@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).