From b747af64f3f666ee8a3c265425c2b28d7fe74c69 Mon Sep 17 00:00:00 2001 From: Sitsofe Wheeler Date: Thu, 17 Aug 2017 07:37:01 +0100 Subject: [PATCH] fio: implement 64 bit network/big endian byte swapping macros Add cpu_to_be64/be64_to_cpu and make the RDMA ioengine use them so it no longer needs to include infiniband/arch.h (which generates obsolete warnings at compile time) or ntohll (which generates deprecation warnings at compile time). Tested-by: Logan Gunthorpe Signed-off-by: Sitsofe Wheeler --- engines/rdma.c | 5 ++--- os/os.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/engines/rdma.c b/engines/rdma.c index 8d31ff30..da00cba8 100644 --- a/engines/rdma.c +++ b/engines/rdma.c @@ -44,7 +44,6 @@ #include "../optgroup.h" #include -#include #define FIO_RDMA_MAX_IO_DEPTH 512 @@ -216,7 +215,7 @@ static int client_recv(struct thread_data *td, struct ibv_wc *wc) rd->rmt_nr = ntohl(rd->recv_buf.nr); for (i = 0; i < rd->rmt_nr; i++) { - rd->rmt_us[i].buf = ntohll(rd->recv_buf.rmt_us[i].buf); + rd->rmt_us[i].buf = be64_to_cpu(rd->recv_buf.rmt_us[i].buf); rd->rmt_us[i].rkey = ntohl(rd->recv_buf.rmt_us[i].rkey); rd->rmt_us[i].size = ntohl(rd->recv_buf.rmt_us[i].size); @@ -1300,7 +1299,7 @@ static int fio_rdmaio_init(struct thread_data *td) } rd->send_buf.rmt_us[i].buf = - htonll((uint64_t) (unsigned long)io_u->buf); + cpu_to_be64((uint64_t) (unsigned long)io_u->buf); rd->send_buf.rmt_us[i].rkey = htonl(io_u->mr->rkey); rd->send_buf.rmt_us[i].size = htonl(max_bs); diff --git a/os/os.h b/os/os.h index 2e155291..f62b4270 100644 --- a/os/os.h +++ b/os/os.h @@ -204,16 +204,20 @@ static inline uint64_t fio_swap64(uint64_t val) #ifndef FIO_HAVE_BYTEORDER_FUNCS #ifdef CONFIG_LITTLE_ENDIAN +#define __be64_to_cpu(x) fio_swap64(x) #define __le16_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le64_to_cpu(x) (x) +#define __cpu_to_be64(x) fio_swap64(x) #define __cpu_to_le16(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le64(x) (x) #else +#define __be64_to_cpu(x) (x) #define __le16_to_cpu(x) fio_swap16(x) #define __le32_to_cpu(x) fio_swap32(x) #define __le64_to_cpu(x) fio_swap64(x) +#define __cpu_to_be64(x) (x) #define __cpu_to_le16(x) fio_swap16(x) #define __cpu_to_le32(x) fio_swap32(x) #define __cpu_to_le64(x) fio_swap64(x) @@ -221,6 +225,10 @@ static inline uint64_t fio_swap64(uint64_t val) #endif /* FIO_HAVE_BYTEORDER_FUNCS */ #ifdef FIO_INTERNAL +#define be64_to_cpu(val) ({ \ + typecheck(uint64_t, val); \ + __be64_to_cpu(val); \ +}) #define le16_to_cpu(val) ({ \ typecheck(uint16_t, val); \ __le16_to_cpu(val); \ @@ -235,6 +243,10 @@ static inline uint64_t fio_swap64(uint64_t val) }) #endif +#define cpu_to_be64(val) ({ \ + typecheck(uint64_t, val); \ + __cpu_to_be64(val); \ +}) #define cpu_to_le16(val) ({ \ typecheck(uint16_t, val); \ __cpu_to_le16(val); \ -- 2.25.1