fio: implement 64 bit network/big endian byte swapping macros
authorSitsofe Wheeler <sitsofe@yahoo.com>
Thu, 17 Aug 2017 06:37:01 +0000 (07:37 +0100)
committerSitsofe Wheeler <sitsofe@yahoo.com>
Fri, 18 Aug 2017 18:50:48 +0000 (19:50 +0100)
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 <logang@deltatee.com>
Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
engines/rdma.c
os/os.h

index 8d31ff307b6cfd21260bbd5b82013ed35a2e0bd7..da00cba8b66b3f6db0bcd3a9cba8b45b9362ffa7 100644 (file)
@@ -44,7 +44,6 @@
 #include "../optgroup.h"
 
 #include <rdma/rdma_cma.h>
-#include <infiniband/arch.h>
 
 #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 2e1552914cd2fa9593230e14e6e68edeeafcc02c..f62b4270f8383851dede8402dc925066770623f5 100644 (file)
--- 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);                     \