engines:nvme: pull required 48 bit accessors from linux kernel
authorAnkit Kumar <ankit.kumar@samsung.com>
Mon, 14 Aug 2023 14:57:46 +0000 (20:27 +0530)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 14 Aug 2023 14:27:33 +0000 (10:27 -0400)
Pull the 48 bit helpers, required for supporting 48 bit reference tags.
Add GPL 2.0 license to nvme.c and nvme.h files.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
Link: https://lore.kernel.org/r/20230814145747.114725-10-ankit.kumar@samsung.com
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
engines/nvme.c
engines/nvme.h

index 6896dfc062023a39a4ddc0d2626aa8ee4375ff94..41e7d07b63e60df23f50dc87a25dc7a4a963aae1 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * nvme structure declarations and helper functions for the
  * io_uring_cmd engine.
index a1102dfe8c58b1030df9075948a96b9a7d8fe9f2..fb1f776097a9d0d007bf259b299f15fc4c37bf22 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * nvme structure declarations and helper functions for the
  * io_uring_cmd engine.
@@ -440,4 +441,20 @@ int fio_nvme_reset_wp(struct thread_data *td, struct fio_file *f,
 int fio_nvme_get_max_open_zones(struct thread_data *td, struct fio_file *f,
                                unsigned int *max_open_zones);
 
+static inline void put_unaligned_be48(__u64 val, __u8 *p)
+{
+       *p++ = val >> 40;
+       *p++ = val >> 32;
+       *p++ = val >> 24;
+       *p++ = val >> 16;
+       *p++ = val >> 8;
+       *p++ = val;
+}
+
+static inline __u64 get_unaligned_be48(__u8 *p)
+{
+       return (__u64)p[0] << 40 | (__u64)p[1] << 32 | (__u64)p[2] << 24 |
+               p[3] << 16 | p[4] << 8 | p[5];
+}
+
 #endif