]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Move all spec defined structs to single file
authorKeith Busch <kbusch@kernel.org>
Thu, 7 Nov 2019 23:33:12 +0000 (08:33 +0900)
committerKeith Busch <kbusch@kernel.org>
Thu, 7 Nov 2019 23:33:12 +0000 (08:33 +0900)
Signed-off-by: Keith Busch <kbusch@kernel.org>
linux/nvme.h
nvme.h

index a01722162ad7a111adca5feec073138b2f0c7704..ffb8eed7acba0dc7f23c26098fee116c6e9219a2 100644 (file)
@@ -1120,6 +1120,143 @@ struct streams_directive_params {
        __u8    rsvd2[6];
 };
 
+struct nvme_effects_log_page {
+       __le32 acs[256];
+       __le32 iocs[256];
+       __u8   resv[2048];
+};
+
+struct nvme_error_log_page {
+       __le64  error_count;
+       __le16  sqid;
+       __le16  cmdid;
+       __le16  status_field;
+       __le16  parm_error_location;
+       __le64  lba;
+       __le32  nsid;
+       __u8    vs;
+       __u8    trtype;
+       __u8    resv[2];
+       __le64  cs;
+       __le16  trtype_spec_info;
+       __u8    resv2[22];
+};
+
+struct nvme_firmware_log_page {
+       __u8    afi;
+       __u8    resv[7];
+       __u64   frs[7];
+       __u8    resv2[448];
+};
+
+/* idle and active power scales occupy the last 2 bits of the field */
+#define POWER_SCALE(s) ((s) >> 6)
+
+struct nvme_host_mem_buffer {
+       __u32                   hsize;
+       __u32                   hmdlal;
+       __u32                   hmdlau;
+       __u32                   hmdlec;
+       __u8                    rsvd16[4080];
+};
+
+struct nvme_auto_pst {
+       __u32   data;
+       __u32   rsvd32;
+};
+
+struct nvme_timestamp {
+       __u8 timestamp[6];
+       __u8 attr;
+       __u8 rsvd;
+};
+
+struct nvme_controller_list {
+       __le16 num;
+       __le16 identifier[];
+};
+
+struct nvme_secondary_controller_entry {
+       __le16 scid;    /* Secondary Controller Identifier */
+       __le16 pcid;    /* Primary Controller Identifier */
+       __u8   scs;     /* Secondary Controller State */
+       __u8   rsvd5[3];
+       __le16 vfn;     /* Virtual Function Number */
+       __le16 nvq;     /* Number of VQ Flexible Resources Assigned */
+       __le16 nvi;     /* Number of VI Flexible Resources Assigned */
+       __u8   rsvd14[18];
+};
+
+struct nvme_secondary_controllers_list {
+       __u8   num;
+       __u8   rsvd[31];
+       struct nvme_secondary_controller_entry sc_entry[127];
+};
+
+struct nvme_bar_cap {
+       __u16   mqes;
+       __u8    ams_cqr;
+       __u8    to;
+       __u16   bps_css_nssrs_dstrd;
+       __u8    mpsmax_mpsmin;
+       __u8    rsvd_cmbs_pmrs;
+};
+
+/*
+ * is_64bit_reg - It checks whether given offset of the controller register is
+ *                64bit or not.
+ * @offset: offset of controller register field in bytes
+ *
+ * It gives true if given offset is 64bit register, otherwise it returns false.
+ *
+ * Notes:  This function does not care about transport so that the offset is
+ * not going to be checked inside of this function for the unsupported fields
+ * in a specific transport.  For example, BPMBL(Boot Partition Memory Buffer
+ * Location) register is not supported by fabrics, but it can be chcked here.
+ */
+static inline bool is_64bit_reg(__u32 offset)
+{
+       if (offset == NVME_REG_CAP ||
+                       offset == NVME_REG_ASQ ||
+                       offset == NVME_REG_ACQ ||
+                       offset == NVME_REG_BPMBL)
+               return true;
+
+       return false;
+}
+
+#ifdef __CHECKER__
+#define __force       __attribute__((force))
+#else
+#define __force
+#endif
+
+static inline __le16 cpu_to_le16(uint16_t x)
+{
+       return (__force __le16)htole16(x);
+}
+static inline __le32 cpu_to_le32(uint32_t x)
+{
+       return (__force __le32)htole32(x);
+}
+static inline __le64 cpu_to_le64(uint64_t x)
+{
+       return (__force __le64)htole64(x);
+}
+
+static inline uint16_t le16_to_cpu(__le16 x)
+{
+       return le16toh((__force __u16)x);
+}
+static inline uint32_t le32_to_cpu(__le32 x)
+{
+       return le32toh((__force __u32)x);
+}
+static inline uint64_t le64_to_cpu(__le64 x)
+{
+       return le64toh((__force __u64)x);
+}
+
 enum {
        NVME_SCT_GENERIC                = 0x0,
        NVME_SCT_CMD_SPECIFIC           = 0x1,
@@ -1240,21 +1377,6 @@ enum {
        NVME_SC_DNR                     = 0x4000,
 };
 
-struct nvme_completion {
-       /*
-        * Used by Admin and Fabrics commands to return data:
-        */
-       union nvme_result {
-               __le16  u16;
-               __le32  u32;
-               __le64  u64;
-       } result;
-       __le16  sq_head;        /* how much of this queue may be reclaimed */
-       __le16  sq_id;          /* submission queue that generated this entry */
-       __u16   command_id;     /* of the command which completed */
-       __le16  status;         /* did the command fail, and if so, why? */
-};
-
 #define NVME_VS(major, minor, tertiary) \
        (((major) << 16) | ((minor) << 8) | (tertiary))
 
diff --git a/nvme.h b/nvme.h
index 5b51de520c9839622350596fa5dc158b98aee878..b0b23c7558f006077f86e4a6e3b0ef871101ccd5 100644 (file)
--- a/nvme.h
+++ b/nvme.h
@@ -33,119 +33,6 @@ enum nvme_print_flags {
        BINARY  = 1 << 3,       /* binary dump raw bytes */
 };
 
-struct nvme_effects_log_page {
-       __le32 acs[256];
-       __le32 iocs[256];
-       __u8   resv[2048];
-};
-
-struct nvme_error_log_page {
-       __le64  error_count;
-       __le16  sqid;
-       __le16  cmdid;
-       __le16  status_field;
-       __le16  parm_error_location;
-       __le64  lba;
-       __le32  nsid;
-       __u8    vs;
-       __u8    trtype;
-       __u8    resv[2];
-       __le64  cs;
-       __le16  trtype_spec_info;
-       __u8    resv2[22];
-};
-
-struct nvme_firmware_log_page {
-       __u8    afi;
-       __u8    resv[7];
-       __u64   frs[7];
-       __u8    resv2[448];
-};
-
-/* idle and active power scales occupy the last 2 bits of the field */
-#define POWER_SCALE(s) ((s) >> 6)
-
-struct nvme_host_mem_buffer {
-       __u32                   hsize;
-       __u32                   hmdlal;
-       __u32                   hmdlau;
-       __u32                   hmdlec;
-       __u8                    rsvd16[4080];
-};
-
-struct nvme_auto_pst {
-       __u32   data;
-       __u32   rsvd32;
-};
-
-struct nvme_timestamp {
-       __u8 timestamp[6];
-       __u8 attr;
-       __u8 rsvd;
-};
-
-struct nvme_controller_list {
-       __le16 num;
-       __le16 identifier[];
-};
-
-struct nvme_secondary_controller_entry {
-       __le16 scid;    /* Secondary Controller Identifier */
-       __le16 pcid;    /* Primary Controller Identifier */
-       __u8   scs;     /* Secondary Controller State */
-       __u8   rsvd5[3];
-       __le16 vfn;     /* Virtual Function Number */
-       __le16 nvq;     /* Number of VQ Flexible Resources Assigned */
-       __le16 nvi;     /* Number of VI Flexible Resources Assigned */
-       __u8   rsvd14[18];
-};
-
-struct nvme_secondary_controllers_list {
-       __u8   num;
-       __u8   rsvd[31];
-       struct nvme_secondary_controller_entry sc_entry[127];
-};
-
-struct nvme_bar_cap {
-       __u16   mqes;
-       __u8    ams_cqr;
-       __u8    to;
-       __u16   bps_css_nssrs_dstrd;
-       __u8    mpsmax_mpsmin;
-       __u8    rsvd_cmbs_pmrs;
-};
-
-#ifdef __CHECKER__
-#define __force       __attribute__((force))
-#else
-#define __force
-#endif
-
-static inline __le16 cpu_to_le16(uint16_t x)
-{
-       return (__force __le16)htole16(x);
-}
-static inline __le32 cpu_to_le32(uint32_t x)
-{
-       return (__force __le32)htole32(x);
-}
-static inline __le64 cpu_to_le64(uint64_t x)
-{
-       return (__force __le64)htole64(x);
-}
-
-static inline uint16_t le16_to_cpu(__le16 x)
-{
-       return le16toh((__force __u16)x);
-}
-static inline uint32_t le32_to_cpu(__le32 x)
-{
-       return le32toh((__force __u32)x);
-}
-static inline uint64_t le64_to_cpu(__le64 x)
-{
-       return le64toh((__force __u64)x);
-}
 
 struct nvme_subsystem;
 struct nvme_ctrl;
@@ -259,27 +146,4 @@ int scan_subsystems(struct nvme_topology *t);
 void free_topology(struct nvme_topology *t);
 char *get_nvme_subsnqn(char *path);
 
-/*
- * is_64bit_reg - It checks whether given offset of the controller register is
- *                64bit or not.
- * @offset: offset of controller register field in bytes
- *
- * It gives true if given offset is 64bit register, otherwise it returns false.
- *
- * Notes:  This function does not care about transport so that the offset is
- * not going to be checked inside of this function for the unsupported fields
- * in a specific transport.  For example, BPMBL(Boot Partition Memory Buffer
- * Location) register is not supported by fabrics, but it can be chcked here.
- */
-static inline bool is_64bit_reg(__u32 offset)
-{
-       if (offset == NVME_REG_CAP ||
-                       offset == NVME_REG_ASQ ||
-                       offset == NVME_REG_ACQ ||
-                       offset == NVME_REG_BPMBL)
-               return true;
-
-       return false;
-}
-
 #endif /* _NVME_H */