forked from linux-nvme/nvme-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvme.h
158 lines (132 loc) · 2.97 KB
/
nvme.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* Definitions for the NVM Express 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 _NVME_H
#define _NVME_H
#include <stdbool.h>
#include <endian.h>
#include <stdint.h>
#include "plugin.h"
#include "json.h"
#define unlikely(x) x
#ifdef LIBUUID
#include <uuid/uuid.h>
#else
typedef struct {
uint8_t b[16];
} uuid_t;
#endif
#include "linux/nvme.h"
struct nvme_effects_log_page {
__le32 acs[256];
__le32 iocs[256];
__u8 resv[2048];
};
struct nvme_error_log_page {
__u64 error_count;
__u16 sqid;
__u16 cmdid;
__u16 status_field;
__u16 parm_error_location;
__u64 lba;
__u32 nsid;
__u8 vs;
__u8 resv[3];
__u64 cs;
__u8 resv2[24];
};
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_bar_cap {
__u16 mqes;
__u8 ams_cqr;
__u8 to;
__u16 bps_css_nssrs_dstrd;
__u8 mpsmax_mpsmin;
__u8 reserved;
};
#ifdef __CHECKER__
#define __force __attribute__((force))
#else
#define __force
#endif
#define cpu_to_le16(x) \
((__force __le16)htole16(x))
#define cpu_to_le32(x) \
((__force __le32)htole32(x))
#define cpu_to_le64(x) \
((__force __le64)htole64(x))
#define le16_to_cpu(x) \
le16toh((__force __u16)(x))
#define le32_to_cpu(x) \
le32toh((__force __u32)(x))
#define le64_to_cpu(x) \
le64toh((__force __u64)(x))
#define MAX_LIST_ITEMS 256
struct list_item {
char node[1024];
struct nvme_id_ctrl ctrl;
int nsid;
struct nvme_id_ns ns;
unsigned block;
};
struct ctrl_list_item {
char *name;
char *address;
char *transport;
};
struct subsys_list_item {
char *name;
char *subsysnqn;
int nctrls;
struct ctrl_list_item *ctrls;
};
enum {
NORMAL,
JSON,
BINARY,
};
void register_extension(struct plugin *plugin);
#include "argconfig.h"
int parse_and_open(int argc, char **argv, const char *desc,
const struct argconfig_commandline_options *clo, void *cfg, size_t size);
extern const char *devicename;
int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, void (*vs)(__u8 *vs, struct json_object *root));
int validate_output_format(char *format);
#endif /* _NVME_H */