RDMA/vmw_pvrdma: Return the correct opcode when creating WR
Subsystems (3)
PATCH 1/1 RDMA/vmw_pvrdma: Return the correct opcode when creating WR
From: Adit Ranadive <[email protected]>
Since the IB_WR_REG_MR opcode value changed, set some of the PVRDMA device opcodes explicitly.
--- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +20 -1
@@ -427,7 +427,26 @@ 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_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 (enum pvrdma_wr_opcode )op; + } } static inline enum ib_wc_status pvrdma_wc_status_to_ib(
Signature · 1 line
1.8.3.1
Quoted 12 lines · Adit Ranadive
From: Adit Ranadive <[email protected]>
Since the
IB_WR_REG_MRopcode value changed, set some of the PVRDMA device opcodes explicitly.Reported-by Ruishuang Wang <[email protected]>Fixes 9a59739bd01f ("IB/rxe: Revise the ib_wr_opcode enum")Reviewed-by Bryan Tan <[email protected]>Reviewed-by Ruishuang Wang <[email protected]>Reviewed-by Vishnu Dasa <[email protected]>Signed-off-by Adit Ranadive <[email protected]>
Quoted 3 lines
--- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
So naughty!! How many other places in this driver are assuming the intenal IB constants are stable?
Did you audit for other cases?
Quoted 18 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +9
-1@@ -427,7 +427,26 @@ 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_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 ;
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h static inline enum ib_qp_state pvrdma_qp_state_to_ib(enum pvrdma_qp_state state) · line 448
Quoted 10 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +10
-0+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 (enum pvrdma_wr_opcode )op;
No default, lets write them all out please.
Jason
Quoted 17 lines · Jason Gunthorpe
Quoted 12 lines · Adit Ranadive
From: Adit Ranadive <[email protected]>
Since the
IB_WR_REG_MRopcode value changed, set some of the PVRDMA device opcodes explicitly.Reported-by Ruishuang Wang <[email protected]>Fixes 9a59739bd01f ("IB/rxe: Revise the ib_wr_opcode enum")Reviewed-by Bryan Tan <[email protected]>Reviewed-by Ruishuang Wang <[email protected]>Reviewed-by Vishnu Dasa <[email protected]>Signed-off-by Adit Ranadive <[email protected]>Quoted 3 lines
--- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Quoted 4 lines
So naughty!! How many other places in this driver are assuming the intenal IB constants are stable?
Did you audit for other cases?
Lots of places. Though its the values shared with userspace, like QP types, IB MTUs, etc. Unless you foresee changes to those ..
Quoted 23 lines
Quoted 23 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +13
-1@@ -427,7 +427,26 @@ 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_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 ;
Quoted 8 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h static inline enum ib_qp_state pvrdma_qp_state_to_ib(enum pvrdma_qp_state state) · line 448
Quoted 6 lines
drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +6
-0+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 (enum pvrdma_wr_opcode )op;No default, lets write them all out please.
Fair enough.
Quoted 3 lines
Jason
Quoted 17 lines · Adit Ranadive
Quoted 16 lines · Jason Gunthorpe
Quoted 14 lines · Adit Ranadive
From: Adit Ranadive <[email protected]>
Since the
IB_WR_REG_MRopcode value changed, set some of the PVRDMA device opcodes explicitly.Reported-by Ruishuang Wang <[email protected]>Fixes 9a59739bd01f ("IB/rxe: Revise the ib_wr_opcode enum")Reviewed-by Bryan Tan <[email protected]>Reviewed-by Ruishuang Wang <[email protected]>Reviewed-by Vishnu Dasa <[email protected]>Signed-off-by Adit Ranadive <[email protected]>drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Quoted 7 lines
Quoted 4 lines
So naughty!! How many other places in this driver are assuming the intenal IB constants are stable?
Did you audit for other cases?
Lots of places. Though its the values shared with userspace, like QP types, IB MTUs, etc. Unless you foresee changes to those ..
Constants declared in the include/uapi header should be OK, but you still need to check that the constants you are using are actually in that header and either recode them or move them into uapi, as appropriate.
When constants get moved we may find more mistakes like this that cause the kernel view to change.
Jason
Quoted 31 lines · Jason Gunthorpe
Quoted 17 lines · Adit Ranadive
Quoted 16 lines · Jason Gunthorpe
Quoted 14 lines · Adit Ranadive
From: Adit Ranadive <[email protected]>
Since the
IB_WR_REG_MRopcode value changed, set some of the PVRDMA device opcodes explicitly.Reported-by Ruishuang Wang <[email protected]>Fixes 9a59739bd01f ("IB/rxe: Revise the ib_wr_opcode enum")Reviewed-by Bryan Tan <[email protected]>Reviewed-by Ruishuang Wang <[email protected]>Reviewed-by Vishnu Dasa <[email protected]>Signed-off-by Adit Ranadive <[email protected]>drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)Quoted 7 lines
Quoted 4 lines
So naughty!! How many other places in this driver are assuming the intenal IB constants are stable?
Did you audit for other cases?
Lots of places. Though its the values shared with userspace, like QP types, IB MTUs, etc. Unless you foresee changes to those ..
Constants declared in the
include/uapiheader should be OK, but you still need to check that the constants you are using are actually in that header and either recode them or move them into uapi, as appropriate.
Quoted 5 lines
When constants get moved we may find more mistakes like this that cause the kernel view to change.
Jason
Thanks. Yeah, I was afraid we might have to do something like that. Okay, I'll send a v1 for this patch and more updates later for 5.1 inclusion if possible.
Thanks,
Adit