From cdfcc6b59c9c862d0a41358d2be31eaf7449551e Mon Sep 17 00:00:00 2001 From: Changcheng Liu Date: Wed, 5 Jun 2019 11:13:07 +0800 Subject: [PATCH] msg/async/rdma: define package sequence numbers macro Refer to Doc: InfiniBandTM Architecture Specification Volume 1 Ver1.2.1 Section: 9.2 BASE TRANSPORT HEADER bits |31---------24 | 23-----------16 | 15----------8 | 7---------0 | bytes |______________________________________________________________| 0 - 3 |____OpCode____|__|SE|M|Pad|Tver_|_________ Partition Key______| 4 - 7 |___Reserved___|______________Destination QP___________________| 8 -11 |A|Reserved 7__|________ PSN - Packet Sequence Number _________| Signed-off-by: Changcheng Liu --- src/msg/async/rdma/Infiniband.cc | 2 +- src/msg/async/rdma/Infiniband.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/msg/async/rdma/Infiniband.cc b/src/msg/async/rdma/Infiniband.cc index 17286949c02..ecca8d7a896 100644 --- a/src/msg/async/rdma/Infiniband.cc +++ b/src/msg/async/rdma/Infiniband.cc @@ -174,7 +174,7 @@ Infiniband::QueuePair::QueuePair( q_key(q_key), dead(false) { - initial_psn = lrand48() & 0xffffff; + initial_psn = lrand48() & PSN_MSK; if (type != IBV_QPT_RC && type != IBV_QPT_UD && type != IBV_QPT_RAW_PACKET) { lderr(cct) << __func__ << " invalid queue pair type" << cpp_strerror(errno) << dendl; ceph_abort(); diff --git a/src/msg/async/rdma/Infiniband.h b/src/msg/async/rdma/Infiniband.h index b1aec88400d..a2d1f4e7c0a 100644 --- a/src/msg/async/rdma/Infiniband.h +++ b/src/msg/async/rdma/Infiniband.h @@ -41,6 +41,9 @@ #define ALIGN_TO_PAGE_SIZE(x) \ (((x) + HUGE_PAGE_SIZE -1) / HUGE_PAGE_SIZE * HUGE_PAGE_SIZE) +#define PSN_LEN 24 +#define PSN_MSK ((1 << PSN_LEN) - 1) + struct IBSYNMsg { uint16_t lid; uint32_t qpn; -- 2.39.5