From: Adit Ranadive <aditr@vmware.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "dledford@redhat.com" <dledford@redhat.com>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Pv-drivers <Pv-drivers@vmware.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v1 for-rc] RDMA/vmw_pvrdma: Return the correct opcode when creating WR
Date: Tue, 8 Jan 2019 18:39:02 +0000 [thread overview]
Message-ID: <01aef10a-8b54-5ff5-0f90-d74d8c4c70cc@vmware.com> (raw)
In-Reply-To: <20190108031051.GC5336@ziepe.ca>
On 1/7/19 7:10 PM, Jason Gunthorpe wrote:
> On Tue, Jan 08, 2019 at 12:02:42AM +0000, Adit Ranadive wrote:
>> On 1/7/19 3:28 PM, Jason Gunthorpe wrote:
>>> On Mon, Jan 07, 2019 at 11:23:05PM +0000, Adit Ranadive wrote:
>>>> From: Adit Ranadive <aditr@vmware.com>
>>>>
>>>> Since the IB_WR_REG_MR opcode value changed, let's set the PVRDMA
>>>> device opcodes explicitly.
>>>>
>>>> Reported-by: Ruishuang Wang <ruishuangw@vmware.com>
>>>> Fixes: 9a59739bd01f ("IB/rxe: Revise the ib_wr_opcode enum")
>>>> Cc: stable@vger.kernel.org
>>>> Reviewed-by: Bryan Tan <bryantan@vmware.com>
>>>> Reviewed-by: Ruishuang Wang <ruishuangw@vmware.com>
>>>> Reviewed-by: Vishnu Dasa <vdasa@vmware.com>
>>>> Signed-off-by: Adit Ranadive <aditr@vmware.com>
>>>> drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 43 +++++++++++++++++++++++++++++++
>>>> 1 file changed, 43 insertions(+)
>>>>
>>>> diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
>>>> index 42b8685c997e..a85d7ba96d55 100644
>>>> +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
>>>> @@ -427,6 +427,49 @@ static inline enum ib_qp_state pvrdma_qp_state_to_ib(enum pvrdma_qp_state state)
>>>>
>>>> static inline enum pvrdma_wr_opcode ib_wr_opcode_to_pvrdma(enum ib_wr_opcode op)
>>>> {
>>>> + switch (op) {
>>>> + case IB_WR_RDMA_WRITE:
>>>> + return PVRDMA_WR_RDMA_WRITE;
>>>> + case IB_WR_RDMA_WRITE_WITH_IMM:
>>>> + return PVRDMA_WR_RDMA_WRITE_WITH_IMM;
>>>> + case IB_WR_SEND:
>>>> + return PVRDMA_WR_SEND;
>>>> + case IB_WR_SEND_WITH_IMM:
>>>> + return PVRDMA_WR_SEND_WITH_IMM;
>>>> + case IB_WR_RDMA_READ:
>>>> + return PVRDMA_WR_RDMA_READ;
>>>> + case IB_WR_ATOMIC_CMP_AND_SWP:
>>>> + return PVRDMA_WR_ATOMIC_CMP_AND_SWP;
>>>> + case IB_WR_ATOMIC_FETCH_AND_ADD:
>>>> + return PVRDMA_WR_ATOMIC_FETCH_AND_ADD;
>>>> + case IB_WR_LSO:
>>>> + return PVRDMA_WR_LSO;
>>>> + case IB_WR_SEND_WITH_INV:
>>>> + return PVRDMA_WR_SEND_WITH_INV;
>>>> + case IB_WR_RDMA_READ_WITH_INV:
>>>> + return PVRDMA_WR_RDMA_READ_WITH_INV;
>>>> + case IB_WR_LOCAL_INV:
>>>> + return PVRDMA_WR_LOCAL_INV;
>>>> + case IB_WR_REG_MR:
>>>> + return PVRDMA_WR_FAST_REG_MR;
>>>> + case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
>>>> + return PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP;
>>>> + case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
>>>> + return PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD;
>>>> + case IB_WR_REG_SIG_MR:
>>>> + return PVRDMA_WR_REG_SIG_MR;
>>>> + case IB_WR_RESERVED1:
>>>> + case IB_WR_RESERVED2:
>>>> + case IB_WR_RESERVED3:
>>>> + case IB_WR_RESERVED4:
>>>> + case IB_WR_RESERVED5:
>>>> + case IB_WR_RESERVED6:
>>>> + case IB_WR_RESERVED7:
>>>> + case IB_WR_RESERVED8:
>>>> + case IB_WR_RESERVED9:
>>>> + case IB_WR_RESERVED10:
>>>> + return (enum pvrdma_wr_opcode)op;
>>>> + }
>>>> return (enum pvrdma_wr_opcode)op;
>>>
>>> I ment it should always translate, not cast like this - if no
>>> translation is available then it should be a posting failure.
>>>
>>> Jason
>>>
>>
>> Not sure if I follow you. We can post a failure but that would be
>> in pvrdma_qp.c when it looks at the opcode returned from here. We
>> would have to handle all the IB enums here though if you don't want
>> a default case (you would get compiler warnings otherwise).
>
> You'd do something like
>
> default:
> return PVRDMA_WR_ERROR;
>
> And something, somewhere, should fail the posting.
>
> Jason
>
Okay. So maybe something like this, would work:
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
index 42b8685c997e..3c633ab58052 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h
@@ -427,7 +427,40 @@ static inline enum ib_qp_state pvrdma_qp_state_to_ib(enum pvrdma_qp_state state)
static inline enum pvrdma_wr_opcode ib_wr_opcode_to_pvrdma(enum ib_wr_opcode op)
{
- return (enum pvrdma_wr_opcode)op;
+ switch (op) {
+ case IB_WR_RDMA_WRITE:
+ return PVRDMA_WR_RDMA_WRITE;
+ case IB_WR_RDMA_WRITE_WITH_IMM:
+ return PVRDMA_WR_RDMA_WRITE_WITH_IMM;
+ case IB_WR_SEND:
+ return PVRDMA_WR_SEND;
+ case IB_WR_SEND_WITH_IMM:
+ return PVRDMA_WR_SEND_WITH_IMM;
+ case IB_WR_RDMA_READ:
+ return PVRDMA_WR_RDMA_READ;
+ case IB_WR_ATOMIC_CMP_AND_SWP:
+ return PVRDMA_WR_ATOMIC_CMP_AND_SWP;
+ case IB_WR_ATOMIC_FETCH_AND_ADD:
+ return PVRDMA_WR_ATOMIC_FETCH_AND_ADD;
+ case IB_WR_LSO:
+ return PVRDMA_WR_LSO;
+ case IB_WR_SEND_WITH_INV:
+ return PVRDMA_WR_SEND_WITH_INV;
+ case IB_WR_RDMA_READ_WITH_INV:
+ return PVRDMA_WR_RDMA_READ_WITH_INV;
+ case IB_WR_LOCAL_INV:
+ return PVRDMA_WR_LOCAL_INV;
+ case IB_WR_REG_MR:
+ return PVRDMA_WR_FAST_REG_MR;
+ case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
+ return PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP;
+ case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
+ return PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD;
+ case IB_WR_REG_SIG_MR:
+ return PVRDMA_WR_REG_SIG_MR;
+ default:
+ return PVRDMA_WR_ERROR;
+ }
}
static inline enum ib_wc_status pvrdma_wc_status_to_ib(
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
index 3acf74cbe266..1ec3646087ba 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
@@ -721,6 +721,12 @@ int pvrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM)
wqe_hdr->ex.imm_data = wr->ex.imm_data;
+ if (unlikely(wqe_hdr->opcode == PVRDMA_WR_ERROR)) {
+ *bad_wr = wr;
+ ret = -EINVAL;
+ goto out;
+ }
+
switch (qp->ibqp.qp_type) {
case IB_QPT_GSI:
case IB_QPT_UD:
diff --git a/include/uapi/rdma/vmw_pvrdma-abi.h b/include/uapi/rdma/vmw_pvrdma-abi.h
index d13fd490b66d..6e73f0274e41 100644
--- a/include/uapi/rdma/vmw_pvrdma-abi.h
+++ b/include/uapi/rdma/vmw_pvrdma-abi.h
@@ -78,6 +78,7 @@ enum pvrdma_wr_opcode {
PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD,
PVRDMA_WR_BIND_MW,
PVRDMA_WR_REG_SIG_MR,
+ PVRDMA_WR_ERROR,
};
enum pvrdma_wc_status {
next prev parent reply other threads:[~2019-01-08 18:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-07 23:23 [PATCH v1 for-rc] RDMA/vmw_pvrdma: Return the correct opcode when creating WR Adit Ranadive
2019-01-07 23:28 ` Jason Gunthorpe
2019-01-08 0:02 ` Adit Ranadive
2019-01-08 3:10 ` Jason Gunthorpe
2019-01-08 18:39 ` Adit Ranadive [this message]
2019-01-08 23:48 ` Jason Gunthorpe
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=01aef10a-8b54-5ff5-0f90-d74d8c4c70cc@vmware.com \
--to=aditr@vmware.com \
--cc=Pv-drivers@vmware.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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