]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Seperate kernel uapi from user structures
authorKeith Busch <keith.busch@intel.com>
Thu, 2 Jun 2016 22:08:31 +0000 (16:08 -0600)
committerKeith Busch <keith.busch@intel.com>
Wed, 8 Jun 2016 17:06:38 +0000 (11:06 -0600)
This pulls in the latest kernel's exported uapi. Including it here
so that it can be used when the kernel headers are either outdated or
not installed.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Makefile
fabrics.c
linux/nvme_ioctl.h [new file with mode: 0644]
nvme-ioctl.h
nvme-print.h
nvme.h [moved from linux/nvme.h with 93% similarity]

index bf756f5b29392baf6c370d76c6a6beba46b04c11..48640f213af4037187175009e0d2d54533d9237a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,13 +33,13 @@ NVME_DPKG_VERSION=1~`lsb_release -sc`
 OBJS := argconfig.o suffix.o parser.o nvme-print.o nvme-ioctl.o \
        nvme-lightnvm.o fabrics.o
 
-nvme: nvme.c ./linux/nvme.h $(OBJS) NVME-VERSION-FILE
+nvme: nvme.c nvme.h $(OBJS) NVME-VERSION-FILE
        $(CC) $(CPPFLAGS) $(CFLAGS) nvme.c $(LDFLAGS) -o $(NVME) $(OBJS)
 
 nvme.o: nvme.c nvme.h nvme-print.h nvme-ioctl.h argconfig.h suffix.h nvme-lightnvm.h fabrics.h
        $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
 
-%.o: %.c %.h
+%.o: %.c %.h nvme.h linux/nvme_ioctl.h
        $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
 
 doc: $(NVME)
index f7bf3b552d40033499bc32d06c02605206c16baa..c8bf2a6e39b32a685b41e253b94327290487cdff 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -35,7 +35,7 @@
 #include "nvme-ioctl.h"
 #include "fabrics.h"
 
-#include "linux/nvme.h"
+#include "nvme.h"
 #include "argconfig.h"
 
 #include "common.h"
diff --git a/linux/nvme_ioctl.h b/linux/nvme_ioctl.h
new file mode 100644 (file)
index 0000000..50ff21f
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Definitions for the NVM Express ioctl interface
+ * Copyright (c) 2011-2014, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef _UAPI_LINUX_NVME_IOCTL_H
+#define _UAPI_LINUX_NVME_IOCTL_H
+
+#include <linux/types.h>
+
+struct nvme_user_io {
+       __u8    opcode;
+       __u8    flags;
+       __u16   control;
+       __u16   nblocks;
+       __u16   rsvd;
+       __u64   metadata;
+       __u64   addr;
+       __u64   slba;
+       __u32   dsmgmt;
+       __u32   reftag;
+       __u16   apptag;
+       __u16   appmask;
+};
+
+struct nvme_passthru_cmd {
+       __u8    opcode;
+       __u8    flags;
+       __u16   rsvd1;
+       __u32   nsid;
+       __u32   cdw2;
+       __u32   cdw3;
+       __u64   metadata;
+       __u64   addr;
+       __u32   metadata_len;
+       __u32   data_len;
+       __u32   cdw10;
+       __u32   cdw11;
+       __u32   cdw12;
+       __u32   cdw13;
+       __u32   cdw14;
+       __u32   cdw15;
+       __u32   timeout_ms;
+       __u32   result;
+};
+
+#define nvme_admin_cmd nvme_passthru_cmd
+
+#define NVME_IOCTL_ID          _IO('N', 0x40)
+#define NVME_IOCTL_ADMIN_CMD   _IOWR('N', 0x41, struct nvme_admin_cmd)
+#define NVME_IOCTL_SUBMIT_IO   _IOW('N', 0x42, struct nvme_user_io)
+#define NVME_IOCTL_IO_CMD      _IOWR('N', 0x43, struct nvme_passthru_cmd)
+#define NVME_IOCTL_RESET       _IO('N', 0x44)
+#define NVME_IOCTL_SUBSYS_RESET        _IO('N', 0x45)
+#define NVME_IOCTL_RESCAN      _IO('N', 0x46)
+
+#endif /* _UAPI_LINUX_NVME_IOCTL_H */
index 5485b6409c801420466aac3228896a362d79d3f6..434b29e54cacbc195669b15f02b8ec20da96d149 100644 (file)
@@ -1,8 +1,10 @@
 #ifndef _NVME_LIB_H
 #define _NVME_LIB_H
 
+#include <linux/types.h>
 #include <stdbool.h>
-#include "linux/nvme.h"
+#include "linux/nvme_ioctl.h"
+#include "nvme.h"
 
 int nvme_get_nsid(int fd);
 
index e5d77a858414bbef453738f9efebe7856f3f7702..1b51613d315e6783d69e031e0fb766a2d76fedd8 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef COMMON_H
 #define COMMON_H
 
-#include "linux/nvme.h"
+#include "nvme.h"
 
 enum {
        TERSE = 0x1u,   // only show a few useful fields
similarity index 93%
rename from linux/nvme.h
rename to nvme.h
index d05304bd3896c1612b6bc5917bda36007e56e890..1759a612a105fafa3b1e71153fde1e2ca74be4b2 100644 (file)
+++ b/nvme.h
@@ -12,8 +12,8 @@
  * more details.
  */
 
-#ifndef _UAPI_LINUX_NVME_H
-#define _UAPI_LINUX_NVME_H
+#ifndef _NVME_H
+#define _NVME_H
 
 #include <linux/types.h>
 
@@ -534,42 +534,6 @@ enum {
        NVME_SC_DNR                     = 0x4000,
 };
 
-struct nvme_user_io {
-       __u8    opcode;
-       __u8    flags;
-       __u16   control;
-       __u16   nblocks;
-       __u16   rsvd;
-       __u64   metadata;
-       __u64   addr;
-       __u64   slba;
-       __u32   dsmgmt;
-       __u32   reftag;
-       __u16   apptag;
-       __u16   appmask;
-};
-
-struct nvme_passthru_cmd {
-       __u8    opcode;
-       __u8    flags;
-       __u16   rsvd1;
-       __u32   nsid;
-       __u32   cdw2;
-       __u32   cdw3;
-       __u64   metadata;
-       __u64   addr;
-       __u32   metadata_len;
-       __u32   data_len;
-       __u32   cdw10;
-       __u32   cdw11;
-       __u32   cdw12;
-       __u32   cdw13;
-       __u32   cdw14;
-       __u32   cdw15;
-       __u32   timeout_ms;
-       __u32   result;
-};
-
 struct nvme_bar {
        __u64                   cap;    /* Controller Capabilities */
        __u32                   vs;     /* Version */
@@ -623,16 +587,6 @@ struct nvmf_disc_rsp_page_hdr {
        struct nvmf_disc_rsp_page_entry entries[0];
 };
 
-#define nvme_admin_cmd nvme_passthru_cmd
-
 #define NVME_VS(major, minor) (((major) << 16) | ((minor) << 8))
 
-#define NVME_IOCTL_ID          _IO('N', 0x40)
-#define NVME_IOCTL_ADMIN_CMD   _IOWR('N', 0x41, struct nvme_admin_cmd)
-#define NVME_IOCTL_SUBMIT_IO   _IOW('N', 0x42, struct nvme_user_io)
-#define NVME_IOCTL_IO_CMD      _IOWR('N', 0x43, struct nvme_passthru_cmd)
-#define NVME_IOCTL_RESET       _IO('N', 0x44)
-#define NVME_IOCTL_SUBSYS_RESET        _IO('N', 0x45)
-
-
-#endif /* _UAPI_LINUX_NVME_H */
+#endif /* _NVME_H */