public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: "Pearson, Robert B" <rpearsonhpe@gmail.com>
To: Zhu Yanjun <zyjzyj2000@gmail.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Bob Pearson <rpearson@hpe.com>
Subject: Re: [PATCH for-next v5 06/10] RDMA/rxe: Move local ops to subroutine
Date: Wed, 28 Apr 2021 11:16:44 -0500	[thread overview]
Message-ID: <c36b5faf-ffc3-c5c7-4577-867c662857b7@gmail.com> (raw)
In-Reply-To: <CAD=hENch84JXK3h_+g_Np_uwR0qmqR6659QYNq9ZAALV+wUj+g@mail.gmail.com>


On 4/24/2021 11:34 PM, Zhu Yanjun wrote:
> On Fri, Apr 23, 2021 at 12:13 AM Bob Pearson <rpearsonhpe@gmail.com> wrote:
>> Simplify rxe_requester() by moving the local operations
>> to a subroutine. Add an error return for illegal send WR opcode.
>> Moved next_index ahead of rxe_run_task which fixed a small bug where
>> work completions were delayed until after the next wqe which was not
>> the intended behavior.
>>
>> Signed-off-by: Bob Pearson <rpearson@hpe.com>
>> ---
>>   drivers/infiniband/sw/rxe/rxe_req.c | 89 +++++++++++++++++------------
>>   1 file changed, 54 insertions(+), 35 deletions(-)
>>
>> diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
>> index 0d4dcd514c55..0cf97e3db29f 100644
>> --- a/drivers/infiniband/sw/rxe/rxe_req.c
>> +++ b/drivers/infiniband/sw/rxe/rxe_req.c
>> @@ -555,6 +555,56 @@ static void update_state(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
>>                            jiffies + qp->qp_timeout_jiffies);
>>   }
>>
>> +static int do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
> rxe_do_local_ops if not used out of softroce.


Same issue. I am trying to be consistent with the original style (which 
mostly I wrote). Static names

don't need to be elaborate.

>
>> +{
>> +       u8 opcode = wqe->wr.opcode;
>> +       struct rxe_dev *rxe;
>> +       struct rxe_mr *mr;
>> +       u32 rkey;
>> +
>> +       switch (opcode) {
>> +       case IB_WR_LOCAL_INV:
>> +               rxe = to_rdev(qp->ibqp.device);
>> +               rkey = wqe->wr.ex.invalidate_rkey;
>> +               mr = rxe_pool_get_index(&rxe->mr_pool, rkey >> 8);
>> +               if (!mr) {
>> +                       pr_err("No MR for rkey %#x\n", rkey);
>> +                       wqe->state = wqe_state_error;
>> +                       wqe->status = IB_WC_LOC_QP_OP_ERR;
>> +                       return -EINVAL;
>> +               }
>> +               mr->state = RXE_MR_STATE_FREE;
>> +               rxe_drop_ref(mr);
>> +               break;
>> +       case IB_WR_REG_MR:
>> +               mr = to_rmr(wqe->wr.wr.reg.mr);
>> +
>> +               rxe_add_ref(mr);
>> +               mr->state = RXE_MR_STATE_VALID;
>> +               mr->access = wqe->wr.wr.reg.access;
>> +               mr->ibmr.lkey = wqe->wr.wr.reg.key;
>> +               mr->ibmr.rkey = wqe->wr.wr.reg.key;
>> +               mr->iova = wqe->wr.wr.reg.mr->iova;
>> +               rxe_drop_ref(mr);
>> +               break;
>> +       default:
>> +               pr_err("Unexpected send wqe opcode %d\n", opcode);
>> +               wqe->state = wqe_state_error;
>> +               wqe->status = IB_WC_LOC_QP_OP_ERR;
>> +               return -EINVAL;
>> +       }
>> +
>> +       wqe->state = wqe_state_done;
>> +       wqe->status = IB_WC_SUCCESS;
>> +       qp->req.wqe_index = next_index(qp->sq.queue, qp->req.wqe_index);
>> +
>> +       if ((wqe->wr.send_flags & IB_SEND_SIGNALED) ||
>> +           qp->sq_sig_type == IB_SIGNAL_ALL_WR)
>> +               rxe_run_task(&qp->comp.task, 1);
>> +
>> +       return 0;
>> +}
>> +
>>   int rxe_requester(void *arg)
>>   {
>>          struct rxe_qp *qp = (struct rxe_qp *)arg;
>> @@ -594,42 +644,11 @@ int rxe_requester(void *arg)
>>                  goto exit;
>>
>>          if (wqe->mask & WR_LOCAL_OP_MASK) {
>> -               if (wqe->wr.opcode == IB_WR_LOCAL_INV) {
>> -                       struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
>> -                       struct rxe_mr *rmr;
>> -
>> -                       rmr = rxe_pool_get_index(&rxe->mr_pool,
>> -                                                wqe->wr.ex.invalidate_rkey >> 8);
>> -                       if (!rmr) {
>> -                               pr_err("No mr for key %#x\n",
>> -                                      wqe->wr.ex.invalidate_rkey);
>> -                               wqe->state = wqe_state_error;
>> -                               wqe->status = IB_WC_MW_BIND_ERR;
>> -                               goto exit;
>> -                       }
>> -                       rmr->state = RXE_MR_STATE_FREE;
>> -                       rxe_drop_ref(rmr);
>> -                       wqe->state = wqe_state_done;
>> -                       wqe->status = IB_WC_SUCCESS;
>> -               } else if (wqe->wr.opcode == IB_WR_REG_MR) {
>> -                       struct rxe_mr *rmr = to_rmr(wqe->wr.wr.reg.mr);
>> -
>> -                       rmr->state = RXE_MR_STATE_VALID;
>> -                       rmr->access = wqe->wr.wr.reg.access;
>> -                       rmr->ibmr.lkey = wqe->wr.wr.reg.key;
>> -                       rmr->ibmr.rkey = wqe->wr.wr.reg.key;
>> -                       rmr->iova = wqe->wr.wr.reg.mr->iova;
>> -                       wqe->state = wqe_state_done;
>> -                       wqe->status = IB_WC_SUCCESS;
>> -               } else {
>> +               ret = do_local_ops(qp, wqe);
>> +               if (unlikely(ret))
>>                          goto exit;
>> -               }
>> -               if ((wqe->wr.send_flags & IB_SEND_SIGNALED) ||
>> -                   qp->sq_sig_type == IB_SIGNAL_ALL_WR)
>> -                       rxe_run_task(&qp->comp.task, 1);
>> -               qp->req.wqe_index = next_index(qp->sq.queue,
>> -                                               qp->req.wqe_index);
>> -               goto next_wqe;
>> +               else
>> +                       goto next_wqe;
>>          }
>>
>>          if (unlikely(qp_type(qp) == IB_QPT_RC &&
>> --
>> 2.27.0
>>

  reply	other threads:[~2021-04-28 16:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22 16:13 [PATCH for-next v4 00/10] RDMA/rxe: Implement memory windows Bob Pearson
2021-04-22 16:13 ` [PATCH for-next v5 01/10] RDMA/rxe: Add bind MW fields to rxe_send_wr Bob Pearson
2021-04-22 16:13 ` [PATCH for-next v5 02/10] RDMA/rxe: Return errors for add index and key Bob Pearson
2021-04-22 16:13 ` [PATCH for-next v5 03/10] RDMA/rxe: Enable MW object pool Bob Pearson
2021-04-22 16:13 ` [PATCH for-next v5 04/10] RDMA/rxe: Add ib_alloc_mw and ib_dealloc_mw verbs Bob Pearson
2021-04-22 16:13 ` [PATCH for-next v5 05/10] RDMA/rxe: Replace WR_REG_MASK by WR_LOCAL_OP_MASK Bob Pearson
2021-04-22 16:13 ` [PATCH for-next v5 06/10] RDMA/rxe: Move local ops to subroutine Bob Pearson
2021-04-25  4:34   ` Zhu Yanjun
2021-04-28 16:16     ` Pearson, Robert B [this message]
2021-04-22 16:13 ` [PATCH for-next v5 07/10] RDMA/rxe: Add support for bind MW work requests Bob Pearson
2021-04-25  4:29   ` Zhu Yanjun
2021-04-28 16:14     ` Pearson, Robert B
2021-04-22 16:13 ` [PATCH for-next v5 08/10] RDMA/rxe: Implement invalidate MW operations Bob Pearson
2021-04-25  4:27   ` Zhu Yanjun
2021-04-28 16:13     ` Pearson, Robert B
2021-04-29  0:54       ` Zhu Yanjun
2021-04-29  3:06         ` Pearson, Robert B
2021-04-29  3:20           ` Zhu Yanjun
2021-04-29  3:31             ` Pearson, Robert B
2021-04-29  6:12               ` Zhu Yanjun
2021-04-29 16:02                 ` Pearson, Robert B
2021-04-29  6:25               ` Zhu Yanjun
2021-04-22 16:13 ` [PATCH for-next v5 09/10] RDMA/rxe: Implement memory access through MWs Bob Pearson
2021-04-25  4:23   ` Zhu Yanjun
2021-04-22 16:13 ` [PATCH for-next v5 10/10] Subject: [PATCH for-next v4 10/10] RDMA/rxe: Disallow MR dereg and invalidate when bound Bob Pearson
2021-04-26  9:19   ` Zhu Yanjun

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=c36b5faf-ffc3-c5c7-4577-867c662857b7@gmail.com \
    --to=rpearsonhpe@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=rpearson@hpe.com \
    --cc=zyjzyj2000@gmail.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