RDMA/rxe: Set partial attributes when completion status != IBV_WC_SUCCESS
authorXiao Yang <yangx.jy@fujitsu.com>
Thu, 30 Sep 2021 09:48:12 +0000 (17:48 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 6 Oct 2021 22:45:30 +0000 (19:45 -0300)
As ibv_poll_cq()'s manual said, only partial attributes are valid when
completion status != IBV_WC_SUCCESS.

Link: https://lore.kernel.org/r/20210930094813.226888-4-yangx.jy@fujitsu.com
Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/sw/rxe/rxe_comp.c

index 48a3864ada29a37b74617572681b61cc9641f20d..d771ba8449a1b86625371b22fa981a7061eb92b0 100644 (file)
@@ -380,30 +380,35 @@ static inline enum comp_state do_atomic(struct rxe_qp *qp,
 static void make_send_cqe(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
                          struct rxe_cqe *cqe)
 {
+       struct ib_wc *wc = &cqe->ibwc;
+       struct ib_uverbs_wc *uwc = &cqe->uibwc;
+
        memset(cqe, 0, sizeof(*cqe));
 
        if (!qp->is_user) {
-               struct ib_wc            *wc     = &cqe->ibwc;
-
-               wc->wr_id               = wqe->wr.wr_id;
-               wc->status              = wqe->status;
-               wc->opcode              = wr_to_wc_opcode(wqe->wr.opcode);
-               if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
-                   wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
-                       wc->wc_flags = IB_WC_WITH_IMM;
-               wc->byte_len            = wqe->dma.length;
-               wc->qp                  = &qp->ibqp;
+               wc->wr_id = wqe->wr.wr_id;
+               wc->status = wqe->status;
+               wc->qp = &qp->ibqp;
        } else {
-               struct ib_uverbs_wc     *uwc    = &cqe->uibwc;
-
-               uwc->wr_id              = wqe->wr.wr_id;
-               uwc->status             = wqe->status;
-               uwc->opcode             = wr_to_wc_opcode(wqe->wr.opcode);
-               if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
-                   wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
-                       uwc->wc_flags = IB_WC_WITH_IMM;
-               uwc->byte_len           = wqe->dma.length;
-               uwc->qp_num             = qp->ibqp.qp_num;
+               uwc->wr_id = wqe->wr.wr_id;
+               uwc->status = wqe->status;
+               uwc->qp_num = qp->ibqp.qp_num;
+       }
+
+       if (wqe->status == IB_WC_SUCCESS) {
+               if (!qp->is_user) {
+                       wc->opcode = wr_to_wc_opcode(wqe->wr.opcode);
+                       if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
+                           wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
+                               wc->wc_flags = IB_WC_WITH_IMM;
+                       wc->byte_len = wqe->dma.length;
+               } else {
+                       uwc->opcode = wr_to_wc_opcode(wqe->wr.opcode);
+                       if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
+                           wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
+                               uwc->wc_flags = IB_WC_WITH_IMM;
+                       uwc->byte_len = wqe->dma.length;
+               }
        }
 }