RDMA/rxe: Add RDMA Atomic Write operation
Subsystems (2)
v5 cover RDMA/rxe: Add RDMA Atomic Write operation
The IB SPEC v1.5[1] defined new RDMA Atomic Write operation. This patchset makes SoftRoCE support new RDMA Atomic Write on RC service.
On my rdma-core repository[2], I have introduced RDMA Atomic Write API for libibverbs and Pyverbs. I also have provided a rdma_atomic_write example and test_qp_ex_rc_rdma_atomic_write python test to verify the patchset.
The steps to run the rdma_atomic_write example:
server:
$ ./rdma_atomic_write_server -s [server_address] -p [port_number] client: $ ./rdma_atomic_write_client -s [server_address] -p [port_number]
The steps to run test_qp_ex_rc_rdma_atomic_write test:run_tests.py --dev rxe_enp0s3 --gid 1 -v test_qpex.QpExTestCase.test_qp_ex_rc_rdma_atomic_write test_qp_ex_rc_rdma_atomic_write (tests.test_qpex.QpExTestCase) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.008s
OK
[1]: https://www.infinibandta.org/wp-content/uploads/2021/08/IBTA-Overview-of-IBTA-Volume-1-Release-1.5-and-MPE-2021-08-17-Secure.pptx
[2]: https://github.com/yangx-jy/rdma-core/tree/new_api_with_point
Note:
This patch set depends on the following patch set:
https://lore.kernel.org/linux-rdma/[email protected]/T/#t
v4->v5:
1) Rebase on current wip/jgg-for-next
2) Rewrite the implementation on responder
v3->v4:
1) Rebase on current wip/jgg-for-next
2) Fix a compiler error on 32-bit arch (e.g. parisc) by disabling RDMA Atomic Write
3) Replace 64-bit value with 8-byte array for RDMA Atomic Write
V2->V3:
1) Rebase
2) Add RDMA Atomic Write attribute for rxe device
V1->V2:
1) Set IB_OPCODE_RDMA_ATOMIC_WRITE to 0x1D
2) Add rdma.atomic_wr in struct rxe_send_wr and use it to pass the atomic write value
3) Use smp_store_release() to ensure that all prior operations have completed
Xiao Yang (2):
RDMA/rxe: Support RDMA Atomic Write operation RDMA/rxe: Add RDMA Atomic Write attribute for rxe device
drivers/infiniband/sw/rxe/rxe_comp.c | 4 ++ drivers/infiniband/sw/rxe/rxe_opcode.c | 18 +++++ drivers/infiniband/sw/rxe/rxe_opcode.h | 3 + drivers/infiniband/sw/rxe/rxe_param.h | 5 ++ drivers/infiniband/sw/rxe/rxe_req.c | 15 +++- drivers/infiniband/sw/rxe/rxe_resp.c | 94 ++++++++++++++++++++++++-- include/rdma/ib_pack.h | 2 + include/rdma/ib_verbs.h | 3 + include/uapi/rdma/ib_user_verbs.h | 4 ++ include/uapi/rdma/rdma_user_rxe.h | 1 + 10 files changed, 142 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
PATCH RESEND v5 1/2 RDMA/rxe: Support RDMA Atomic Write operation
This patch implements RDMA Atomic Write operation for RC service.
--- drivers/infiniband/sw/rxe/rxe_comp.c | 4 ++ drivers/infiniband/sw/rxe/rxe_opcode.c | 18 +++++ drivers/infiniband/sw/rxe/rxe_opcode.h | 3 + drivers/infiniband/sw/rxe/rxe_req.c | 15 +++- drivers/infiniband/sw/rxe/rxe_resp.c | 94 ++++++++++++++++++++++++-- include/rdma/ib_pack.h | 2 + include/rdma/ib_verbs.h | 2 + include/uapi/rdma/ib_user_verbs.h | 2 + include/uapi/rdma/rdma_user_rxe.h | 1 + 9 files changed, 134 insertions(+), 7 deletions(-)
drivers/infiniband/sw/rxe/rxe_comp.c +4 -0
@@ -104,6 +104,7 @@ static enum ib_wc_opcode wr_to_wc_opcode(enum ib_wr_opcode opcode)case IB_WR_LOCAL_INV :return IB_WC_LOCAL_INV ;case IB_WR_REG_MR :return IB_WC_REG_MR ;case IB_WR_BIND_MW :return IB_WC_BIND_MW ; +case IB_WR_RDMA_ATOMIC_WRITE :return IB_WC_RDMA_ATOMIC_WRITE ;default :return 0xff ;
@@ -256,6 +257,9 @@ static inline enum comp_state check_ack(struct rxe_qp *qp,if ((syn &AETH_TYPE_MASK ) !=AETH_ACK )return COMPST_ERROR ; +if (wqe->wr.opcode ==IB_WR_RDMA_ATOMIC_WRITE ) +return COMPST_WRITE_SEND ; + fallthrough;/* (IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE doesn't have an AETH) */
drivers/infiniband/sw/rxe/rxe_opcode.c +18 -0
@@ -101,6 +101,12 @@ struct rxe_wr_opcode_info rxe_wr_opcode_info[] = { [IB_QPT_UC] = WR_LOCAL_OP_MASK, }, }, + [IB_WR_RDMA_ATOMIC_WRITE] = { + .name = "IB_WR_RDMA_ATOMIC_WRITE", + .mask = { + [IB_QPT_RC] = WR_ATOMIC_WRITE_MASK, + }, + }, };struct rxe_opcode_info rxe_opcode[RXE_NUM_OPCODE ] = {
@@ -378,6 +384,18 @@ struct rxe_opcode_info rxe_opcode[RXE_NUM_OPCODE] = { RXE_IETH_BYTES, } }, + [IB_OPCODE_RC_RDMA_ATOMIC_WRITE] = { + .name = "IB_OPCODE_RC_RDMA_ATOMIC_WRITE", + .mask =RXE_RETH_MASK |RXE_PAYLOAD_MASK |RXE_REQ_MASK | +RXE_ATOMIC_WRITE_MASK |RXE_START_MASK | + RXE_END_MASK, + .length = RXE_BTH_BYTES + RXE_RETH_BYTES, + .offset = { + [RXE_BTH] = 0, + [RXE_RETH] = RXE_BTH_BYTES, + [RXE_PAYLOAD] = RXE_BTH_BYTES + RXE_RETH_BYTES, + } + },/* UC */ [IB_OPCODE_UC_SEND_FIRST] = {
drivers/infiniband/sw/rxe/rxe_opcode.h +3 -0
@@ -20,6 +20,7 @@ enum rxe_wr_mask {WR_READ_MASK =BIT (3 ),WR_WRITE_MASK =BIT (4 ),WR_LOCAL_OP_MASK =BIT (5 ), +WR_ATOMIC_WRITE_MASK =BIT (7 ),WR_READ_OR_WRITE_MASK =WR_READ_MASK |WR_WRITE_MASK , WR_WRITE_OR_SEND_MASK = WR_WRITE_MASK | WR_SEND_MASK,
@@ -81,6 +82,8 @@ enum rxe_hdr_mask {RXE_LOOPBACK_MASK =BIT (NUM_HDR_TYPES +12 ), +RXE_ATOMIC_WRITE_MASK =BIT (NUM_HDR_TYPES +14 ), +RXE_READ_OR_ATOMIC_MASK = (RXE_READ_MASK |RXE_ATOMIC_MASK ),RXE_WRITE_OR_SEND_MASK = (RXE_WRITE_MASK |RXE_SEND_MASK ), RXE_READ_OR_WRITE_MASK = (RXE_READ_MASK | RXE_WRITE_MASK),
drivers/infiniband/sw/rxe/rxe_req.c +13 -2
@@ -235,6 +235,10 @@ static int next_opcode_rc(struct rxe_qp *qp, u32 opcode, int fits)else return fits ?IB_OPCODE_RC_SEND_ONLY_WITH_INVALIDATE :IB_OPCODE_RC_SEND_FIRST ; + +case IB_WR_RDMA_ATOMIC_WRITE : +return IB_OPCODE_RC_RDMA_ATOMIC_WRITE ; +case IB_WR_REG_MR :case IB_WR_LOCAL_INV :return opcode;
@@ -463,6 +467,11 @@ static int finish_packet(struct rxe_qp *qp, struct rxe_av *av, } } +if (pkt->mask &RXE_ATOMIC_WRITE_MASK ) { +memcpy (payload_addr (pkt), wqe->wr.wr.rdma.atomic_wr, payload); + wqe->dma.resid -= payload; + } +return 0 ; }
@@ -663,13 +672,15 @@ int rxe_requester(void *arg) } mask = rxe_opcode[opcode].mask; -if (unlikely (mask &RXE_READ_OR_ATOMIC_MASK )) { +if (unlikely (mask & (RXE_READ_OR_ATOMIC_MASK | +RXE_ATOMIC_WRITE_MASK ))) {if (check_init_depth (qp, wqe)) goto exit; } mtu =get_mtu (qp); - payload = (mask &RXE_WRITE_OR_SEND_MASK ) ? wqe->dma.resid :0 ; + payload = (mask & (RXE_WRITE_OR_SEND_MASK |RXE_ATOMIC_WRITE_MASK )) ? + wqe->dma.resid :0 ;if (payload > mtu) {if (qp_type (qp) ==IB_QPT_UD ) {/* C10-93.1.1: If the total sum of all the buffer lengths specified for a
drivers/infiniband/sw/rxe/rxe_resp.c +89 -5
172 lines not on this page · raw message
include/rdma/ib_pack.h +2 -0
@@ -84,6 +84,7 @@ enum {/* opcode 0x15 is reserved */ IB_OPCODE_SEND_LAST_WITH_INVALIDATE =0x16 ,IB_OPCODE_SEND_ONLY_WITH_INVALIDATE =0x17 , + IB_OPCODE_RDMA_ATOMIC_WRITE = 0x1D,/* real constants follow -- see comment about above IB_OPCODE() macro for more details */
@@ -112,6 +113,7 @@ enum {IB_OPCODE (RC ,FETCH_ADD ),IB_OPCODE (RC ,SEND_LAST_WITH_INVALIDATE ),IB_OPCODE (RC ,SEND_ONLY_WITH_INVALIDATE ), +IB_OPCODE (RC ,RDMA_ATOMIC_WRITE ),/* UC */ IB_OPCODE(UC, SEND_FIRST),
include/rdma/ib_verbs.h +2 -0
@@ -985,6 +985,7 @@ enum ib_wc_opcode {IB_WC_REG_MR ,IB_WC_MASKED_COMP_SWAP ,IB_WC_MASKED_FETCH_ADD , +IB_WC_RDMA_ATOMIC_WRITE =IB_UVERBS_WC_RDMA_ATOMIC_WRITE ,/* * Set value of IB_WC_RECV so consumers can test if a completion is a * receive by testing (opcode & IB_WC_RECV).
@@ -1325,6 +1326,7 @@ enum ib_wr_opcode {IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP ,IB_WR_MASKED_ATOMIC_FETCH_AND_ADD =IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD , +IB_WR_RDMA_ATOMIC_WRITE =IB_UVERBS_WR_RDMA_ATOMIC_WRITE ,/* These are kernel only and can not be issued by userspace */ IB_WR_REG_MR = 0x20,
include/uapi/rdma/ib_user_verbs.h +2 -0
@@ -466,6 +466,7 @@ enum ib_uverbs_wc_opcode {IB_UVERBS_WC_BIND_MW =5 ,IB_UVERBS_WC_LOCAL_INV =6 ,IB_UVERBS_WC_TSO =7 , + IB_UVERBS_WC_RDMA_ATOMIC_WRITE = 9, }; struct ib_uverbs_wc {
@@ -784,6 +785,7 @@ enum ib_uverbs_wr_opcode {IB_UVERBS_WR_RDMA_READ_WITH_INV =11 ,IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP =12 ,IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD =13 , + IB_UVERBS_WR_RDMA_ATOMIC_WRITE = 15, /* Review enum ib_wr_opcode before modifying this */ };
include/uapi/rdma/rdma_user_rxe.h +1 -0
@@ -86,6 +86,7 @@ struct rxe_send_wr {__aligned_u64 remote_addr;__u32 rkey;__u32 reserved; +__u8 atomic_wr[8 ]; } rdma;struct {__aligned_u64 remote_addr;
Signature · 1 line
2.34.1
Jason Gunthorpe
maintainerRe: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 14 lines · On Fri, Jul 08, 2022 at 04:02:36AM +0000, [email protected] wrote:
drivers/infiniband/sw/rxe/rxe_resp.c +14
-0+static enum resp_states atomic_write_reply (struct rxe_qp *qp, +struct rxe_pkt_info *pkt) +{ +u64 src, *dst; +struct resp_res *res = qp->resp.res; +struct rxe_mr *mr = qp->resp.mr; +int payload =payload_size (pkt); + +if (!res) { + res =rxe_prepare_res (qp, pkt,RXE_ATOMIC_WRITE_MASK ); + qp->resp.res = res; + } + +if (!res->replay) {
drivers/infiniband/sw/rxe/rxe_resp.c static enum resp_states atomic_reply(struct rxe_qp *qp, · line 681
Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_resp.c +10
-0+#ifdef CONFIG_64BIT +memcpy (&src,payload_addr (pkt), payload); + + dst =iova_to_vaddr (mr, qp->resp.va + qp->resp.offset, payload); +/* check vaddr is 8 bytes aligned. */ +if (!dst || (uintptr_t )dst &7 ) +return RESPST_ERR_MISALIGNED_ATOMIC ; + +/* Do atomic write after all prior operations have completed */ +smp_store_release (dst, src);
Someone needs to fix iova_to_vaddr to do the missing kmap, we can't just assume you can cast a u64 pfn to a vaddr like this.
Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_resp.c +6
-0+/* decrease resp.resid to zero */ + qp->resp.resid -=sizeof (payload); + + qp->resp.msn++; + +/* next expected psn, read handles this separately */
drivers/infiniband/sw/rxe/rxe_resp.c static enum resp_states atomic_reply(struct rxe_qp *qp, · line 698
Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_resp.c +10
-0+ qp->resp.psn = (pkt->psn +1 ) &BTH_PSN_MASK ; + qp->resp.ack_psn = qp->resp.psn; + + qp->resp.opcode = pkt->opcode; + qp->resp.status =IB_WC_SUCCESS ; + +return RESPST_ACKNOWLEDGE ; +#else +pr_err ("32-bit arch doesn't support 8-byte atomic write\n" ); +return RESPST_ERR_UNSUPPORTED_OPCODE ;
No print on receiving a remote packet
Jason
Re: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 20 lines · Jason Gunthorpe
Quoted 19 lines · On Fri, Jul 08, 2022 at 04:02:36AM +0000, [email protected] wrote:
drivers/infiniband/sw/rxe/rxe_resp.c +19
-0+static enum resp_states atomic_write_reply (struct rxe_qp *qp, +struct rxe_pkt_info *pkt) +{ +u64 src, *dst; +struct resp_res *res = qp->resp.res; +struct rxe_mr *mr = qp->resp.mr; +int payload =payload_size (pkt); + +if (!res) { + res =rxe_prepare_res (qp, pkt,RXE_ATOMIC_WRITE_MASK ); + qp->resp.res = res; + } + +if (!res->replay) { +#ifdef CONFIG_64BIT +memcpy (&src,payload_addr (pkt), payload); + + dst =iova_to_vaddr (mr, qp->resp.va + qp->resp.offset, payload); +/* check vaddr is 8 bytes aligned. */
Quoted 8 lines
drivers/infiniband/sw/rxe/rxe_resp.c static enum resp_states atomic_reply(struct rxe_qp *qp, · line 681
Quoted 5 lines
drivers/infiniband/sw/rxe/rxe_resp.c +5
-0+if (!dst || (uintptr_t )dst &7 ) +return RESPST_ERR_MISALIGNED_ATOMIC ; + +/* Do atomic write after all prior operations have completed */ +smp_store_release (dst, src);Someone needs to fix
iova_to_vaddrto do the missing kmap, we can't just assume you can cast a u64 pfn to a vaddr like this.
Hi Jason,
Cc Ira,
When using PMEM with DAX mode(devdax or fsdax), we cannot ensure that iova_to_vaddr() can cast a u64 pfn to a vaddr, right? so we have to replace page_address() with kmap_local_page().
Without Ira's PKS patch set, I didn't see any failure when accessing remote PMEM with devdax mode by RDMA based on RXE. I don't know why I cannot trigger any failure in the condition.
Quoted 11 lines
Quoted 11 lines
drivers/infiniband/sw/rxe/rxe_resp.c +10
-0+/* decrease resp.resid to zero */ + qp->resp.resid -=sizeof (payload); + + qp->resp.msn++; + +/* next expected psn, read handles this separately */ + qp->resp.psn = (pkt->psn +1 ) &BTH_PSN_MASK ; + qp->resp.ack_psn = qp->resp.psn; + + qp->resp.opcode = pkt->opcode;
Quoted 8 lines
drivers/infiniband/sw/rxe/rxe_resp.c static enum resp_states atomic_reply(struct rxe_qp *qp, · line 698
Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_resp.c +6
-0+ qp->resp.status =IB_WC_SUCCESS ; + +return RESPST_ACKNOWLEDGE ; +#else +pr_err ("32-bit arch doesn't support 8-byte atomic write\n" ); +return RESPST_ERR_UNSUPPORTED_OPCODE ;No print on receiving a remote packet
OK
Best Regards,
Xiao Yang
Quoted 2 lines
Jason
Re: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
In reply to Jason GunthorpeQuoted 20 lines · Jason Gunthorpe
Quoted 19 lines · On Fri, Jul 08, 2022 at 04:02:36AM +0000, [email protected] wrote:
drivers/infiniband/sw/rxe/rxe_resp.c +19
-0+static enum resp_states atomic_write_reply (struct rxe_qp *qp, +struct rxe_pkt_info *pkt) +{ +u64 src, *dst; +struct resp_res *res = qp->resp.res; +struct rxe_mr *mr = qp->resp.mr; +int payload =payload_size (pkt); + +if (!res) { + res =rxe_prepare_res (qp, pkt,RXE_ATOMIC_WRITE_MASK ); + qp->resp.res = res; + } + +if (!res->replay) { +#ifdef CONFIG_64BIT +memcpy (&src,payload_addr (pkt), payload); + + dst =iova_to_vaddr (mr, qp->resp.va + qp->resp.offset, payload); +/* check vaddr is 8 bytes aligned. */
Quoted 8 lines
drivers/infiniband/sw/rxe/rxe_resp.c static enum resp_states atomic_reply(struct rxe_qp *qp, · line 681
Quoted 5 lines
drivers/infiniband/sw/rxe/rxe_resp.c +5
-0+if (!dst || (uintptr_t )dst &7 ) +return RESPST_ERR_MISALIGNED_ATOMIC ; + +/* Do atomic write after all prior operations have completed */ +smp_store_release (dst, src);Someone needs to fix
iova_to_vaddrto do the missing kmap, we can't just assume you can cast a u64 pfn to a vaddr like this.
Hi Jason,
Sorry, it is still not clear to me after looking into the related code again.
IMO, SoftRoCE depends on INFINIBAND_VIRT_DMA Kconfig which only allows !HIGHMEM so that SoftRoCE can call page_address() to gain a kernel virtual address for a page allocated on low memory zone. If a page is allocated on high memory zone, we need to gain a kernel virtual address by kmap()/kmap_atomic(). Did I miss something? I wonder why it is necessary to call kmap()?
Best Regards,
Xiao Yang
Quoted 21 lines
Quoted 7 lines
drivers/infiniband/sw/rxe/rxe_resp.c +6
-0+/* decrease resp.resid to zero */ + qp->resp.resid -=sizeof (payload); + + qp->resp.msn++; + +/* next expected psn, read handles this separately */ drivers/infiniband/sw/rxe/rxe_resp.c static enum resp_states atomic_reply(struct rxe_qp *qp, · line 698
Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_resp.c +10
-0+ qp->resp.psn = (pkt->psn +1 ) &BTH_PSN_MASK ; + qp->resp.ack_psn = qp->resp.psn; + + qp->resp.opcode = pkt->opcode; + qp->resp.status =IB_WC_SUCCESS ; + +return RESPST_ACKNOWLEDGE ; +#else +pr_err ("32-bit arch doesn't support 8-byte atomic write\n" ); +return RESPST_ERR_UNSUPPORTED_OPCODE ;No print on receiving a remote packet
Jason
Jason Gunthorpe
maintainerRe: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 35 lines · Xiao/杨 晓
Quoted 20 lines · Jason Gunthorpe
Quoted 19 lines · On Fri, Jul 08, 2022 at 04:02:36AM +0000, [email protected] wrote:
drivers/infiniband/sw/rxe/rxe_resp.c +19
-0+static enum resp_states atomic_write_reply (struct rxe_qp *qp, +struct rxe_pkt_info *pkt) +{ +u64 src, *dst; +struct resp_res *res = qp->resp.res; +struct rxe_mr *mr = qp->resp.mr; +int payload =payload_size (pkt); + +if (!res) { + res =rxe_prepare_res (qp, pkt,RXE_ATOMIC_WRITE_MASK ); + qp->resp.res = res; + } + +if (!res->replay) { +#ifdef CONFIG_64BIT +memcpy (&src,payload_addr (pkt), payload); + + dst =iova_to_vaddr (mr, qp->resp.va + qp->resp.offset, payload); +/* check vaddr is 8 bytes aligned. */ Quoted 8 lines
drivers/infiniband/sw/rxe/rxe_resp.c static enum resp_states atomic_reply(struct rxe_qp *qp, · line 681
Quoted 5 lines
drivers/infiniband/sw/rxe/rxe_resp.c +5
-0+if (!dst || (uintptr_t )dst &7 ) +return RESPST_ERR_MISALIGNED_ATOMIC ; + +/* Do atomic write after all prior operations have completed */ +smp_store_release (dst, src);Someone needs to fix
iova_to_vaddrto do the missing kmap, we can't just assume you can cast a u64 pfn to a vaddr like this.Hi Jason,
Sorry, it is still not clear to me after looking into the related code again.
Quoted 6 lines
IMO, SoftRoCE depends on
INFINIBAND_VIRT_DMAKconfigwhich only allows !HIGHMEM so that SoftRoCE can callpage_address()to gain a kernel virtual address for a page allocated on low memory zone. If a page is allocated on high memory zone, we need to gain a kernel virtual address by kmap()/kmap_atomic(). Did I miss something? I wonder why it is necessary to callkmap()?
People have been thinking of new uses for kmap, rxe still should be calling it.
The above just explains why it doesn't fail today, it doesn't excuse the wrong usage.
Jason
Re: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 2 lines · Jason Gunthorpe
People have been thinking of new uses for kmap, rxe still should be calling it.
Hi Jason,
Thanks a lot for your reply.
Could you tell me what is the new usage about kmap()?
Quoted 3 lines
The above just explains why it doesn't fail today, it doesn't excuse the wrong usage.
I wonder why we need to use kmap() in this case?
I'm sorry to ask the stupid question.
Best Regards,
Xiao Yang
Quoted 2 lines
Jason
Jason Gunthorpe
maintainerRe: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 8 lines · Xiao/杨 晓
Quoted 2 lines · Jason Gunthorpe
People have been thinking of new uses for kmap, rxe still should be calling it.
Hi Jason,
Thanks a lot for your reply.
Could you tell me what is the new usage aboutkmap()?
New in-kernel memory protection schemes
Quoted 5 lines
Quoted 2 lines
The above just explains why it doesn't fail today, it doesn't excuse the wrong usage.
I wonder why we need to use
kmap()in this case?
I'm sorry to ask the stupid question.
It is the defined API to convert a struct page into an address the CPU can access.
Jason
Re: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
In reply to [email protected]Hi Yang
I wonder if you need to do something if a user register MR with ATOMIC_WRITE to non-rxe device, something like in my flush:
Thanks
Zhijian
static inline int ib_check_mr_access(struct ib_device *ib_dev,
unsigned int flags)
{
+ u64 device_cap = ib_dev->attrs.device_cap_flags;
+
/*
* Local write permission is required if remote write or
* remote atomic permission is also requested.
@@ -4335,6 +4346,13 @@ static inline int ib_check_mr_access(struct ib_device *ib_dev,
if (flags & IB_ACCESS_ON_DEMAND &&
!(ib_dev->attrs.kernel_cap_flags & IBK_ON_DEMAND_PAGING))
return -EINVAL;
+
+ if ((flags & IB_ACCESS_FLUSH_GLOBAL &&
+ !(device_cap & IB_DEVICE_FLUSH_GLOBAL)) || + (flags & IB_ACCESS_FLUSH_PERSISTENT && + !(device_cap & IB_DEVICE_FLUSH_PERSISTENT)))
+ return -EINVAL;
+
return 0;
}
Quoted 4 lines · Xiao/杨 晓
include/rdma/ib_verbs.h +0
-0
Re: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 4 lines · Li Zhijian
Hi Yang
I wonder if you need to do something if a user register MR with
ATOMIC_WRITEto non-rxe device, something like in my flush:
This makes sense..
Jason
Re: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 7 lines · Jason Gunthorpe
Quoted 4 lines · Li Zhijian
Hi Yang
I wonder if you need to do something if a user register MR with
ATOMIC_WRITEto non-rxe device, something like in my flush:This makes sense..
Hi Zhijian, Jason
Agreed. I will add the check in ib_check_mr_access().
Best Regards,
Xiao Yang
Quoted 2 lines
Jason
Re: [RESEND PATCH v5 1/2] RDMA/rxe: Support RDMA Atomic Write operation
Quoted 4 lines · Xiao/杨 晓
Quoted 3 lines · Jason Gunthorpe
Quoted 2 lines · Li Zhijian
Hi Yang
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I wonder if you need to do something if a user register MR with
ATOMIC_WRITEto non-rxe device, something like in my flush:This makes sense..
Hi Zhijian, Jason
Agreed. I will add the check in
ib_check_mr_access().
Hi Zhijian, Jason,
Sorry for the rough reply.
After reading the IBTA Spec A19.4.5.3 again, it seems not suitable for Atomic Write to do the similar check in ib_check_mr_access().
Atomic Write uses the original IB_ACCESS_REMOTE_WRITE flag during memory registration. (In other words, it doesn't introduce a new IB_ACCESS_REMOTE_ATOMIC_WRITE flag)
In this case, we should not return -EINVAL when IB_ACCESS_REMOTE_WRITE is specified and ib_dev->attrs.device_cap_flags doesn't support IB_DEVICE_ATOMIC_WRITE.
Best Regards,
Xiao Yang
Quoted 5 lines
Best Regards,
Xiao YangQuoted 2 lines
Jason
PATCH RESEND v5 2/2 RDMA/rxe: Add RDMA Atomic Write attribute for rxe device
In reply to [email protected]The attribute shows that rxe device supports RDMA Atomic Write operation.
--- drivers/infiniband/sw/rxe/rxe_param.h | 5 +++++ include/rdma/ib_verbs.h | 1 + include/uapi/rdma/ib_user_verbs.h | 2 ++ 3 files changed, 8 insertions(+)
drivers/infiniband/sw/rxe/rxe_param.h +5 -0
@@ -51,7 +51,12 @@ enum rxe_device_param { | IB_DEVICE_SRQ_RESIZE |IB_DEVICE_MEM_MGT_EXTENSIONS | IB_DEVICE_MEM_WINDOW +#ifdef CONFIG_64BIT + |IB_DEVICE_MEM_WINDOW_TYPE_2B + | IB_DEVICE_ATOMIC_WRITE, +#else |IB_DEVICE_MEM_WINDOW_TYPE_2B , +#endif /* CONFIG_64BIT */RXE_MAX_SGE =32 ,RXE_MAX_WQE_SIZE =sizeof (struct rxe_send_wqe ) + sizeof(struct ib_sge) * RXE_MAX_SGE,
include/rdma/ib_verbs.h +1 -0
@@ -270,6 +270,7 @@ enum ib_device_cap_flags {/* The device supports padding incoming writes to cacheline. */ IB_DEVICE_PCI_WRITE_END_PADDING =IB_UVERBS_DEVICE_PCI_WRITE_END_PADDING , + IB_DEVICE_ATOMIC_WRITE = IB_UVERBS_DEVICE_ATOMIC_WRITE, }; enum ib_kernel_cap_flags {
include/uapi/rdma/ib_user_verbs.h +2 -0
@@ -1333,6 +1333,8 @@ enum ib_uverbs_device_cap_flags {/* Deprecated. Please use IB_UVERBS_RAW_PACKET_CAP_SCATTER_FCS. */ IB_UVERBS_DEVICE_RAW_SCATTER_FCS =1ULL <<34 ,IB_UVERBS_DEVICE_PCI_WRITE_END_PADDING =1ULL <<36 , +/* Atomic write attributes */ + IB_UVERBS_DEVICE_ATOMIC_WRITE = 1ULL << 40, }; enum ib_uverbs_raw_packet_caps {
Signature · 1 line
2.34.1
Hi all,
Ping. Is it time to review the patch set?
Best Regards,
Xiao Yang
Quoted 64 lines · Xiao/杨 晓
The IB SPEC v1.5[1] defined new RDMA Atomic Write operation. This patchset makes SoftRoCE support new RDMA Atomic Write on RC service.
On my rdma-core repository[2], I have introduced RDMA Atomic Write API for libibverbs and Pyverbs. I also have provided a
rdma_atomic_writeexample andtest_qp_ex_rc_rdma_atomic_writepython test to verify the patchset.The steps to run the
rdma_atomic_writeexample:
server:$ ./rdma_atomic_write_server -s [server_address] -p [port_number] client: $ ./rdma_atomic_write_client -s [server_address] -p [port_number]The steps to run
test_qp_ex_rc_rdma_atomic_writetest:run_tests.py--devrxe_enp0s3--gid 1 -v test_qpex.QpExTestCase.test_qp_ex_rc_rdma_atomic_writetest_qp_ex_rc_rdma_atomic_write(tests.test_qpex.QpExTestCase) ... ok----------------------------------------------------------------------
Ran 1 test in 0.008sOK
[1]: https://www.infinibandta.org/wp-content/uploads/2021/08/IBTA-Overview-of-IBTA-Volume-1-Release-1.5-and-MPE-2021-08-17-Secure.pptx
[2]: https://github.com/yangx-jy/rdma-core/tree/new_api_with_pointNote:
This patch set depends on the following patch set:
https://lore.kernel.org/linux-rdma/[email protected]/T/#t
v4->v5:
1) Rebase on current wip/jgg-for-next
2) Rewrite the implementation on responder
v3->v4:
1) Rebase on current wip/jgg-for-next
2) Fix a compiler error on 32-bit arch (e.g. parisc) by disabling RDMA Atomic Write
3) Replace 64-bit value with 8-byte array for RDMA Atomic Write
V2->V3:
1) Rebase
2) Add RDMA Atomic Write attribute for rxe device
V1->V2:
1) SetIB_OPCODE_RDMA_ATOMIC_WRITEto0x1D
2) Add rdma.atomic_wr in structrxe_send_wrand use it to pass the atomic write value
3) Usesmp_store_release()to ensure that all prior operations have completedXiao Yang (2):
RDMA/rxe: Support RDMA Atomic Write operation RDMA/rxe: Add RDMA Atomic Write attribute for rxe devicedrivers/infiniband/sw/rxe/rxe_comp.c | 4 ++ drivers/infiniband/sw/rxe/rxe_opcode.c | 18 +++++ drivers/infiniband/sw/rxe/rxe_opcode.h | 3 + drivers/infiniband/sw/rxe/rxe_param.h | 5 ++ drivers/infiniband/sw/rxe/rxe_req.c | 15 +++- drivers/infiniband/sw/rxe/rxe_resp.c | 94 ++++++++++++++++++++++++-- include/rdma/ib_pack.h | 2 + include/rdma/ib_verbs.h | 3 + include/uapi/rdma/ib_user_verbs.h | 4 ++ include/uapi/rdma/rdma_user_rxe.h | 1 + 10 files changed, 142 insertions(+), 7 deletions(-)