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
|
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
* Copyright 2021 Oxide Computer Company
* Copyright 2022 Tintri by DDN, Inc. All rights reserved.
*/
#ifndef _NVMEADM_H
#define _NVMEADM_H
#include <stdio.h>
#include <libdevinfo.h>
#include <sys/nvme.h>
#include <nvme_reg.h>
#include <ofmt.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int verbose;
extern int debug;
/* Common structures */
typedef struct nvme_process_arg nvme_process_arg_t;
typedef struct nvme_feature nvme_feature_t;
typedef struct nvmeadm_cmd nvmeadm_cmd_t;
struct nvme_process_arg {
int npa_argc;
char **npa_argv;
char *npa_name;
char *npa_nsid;
int npa_found;
boolean_t npa_isns;
const nvmeadm_cmd_t *npa_cmd;
di_node_t npa_node;
di_minor_t npa_minor;
char *npa_path;
char *npa_dsk;
nvme_identify_ctrl_t *npa_idctl;
nvme_identify_nsid_t *npa_idns;
nvme_version_t *npa_version;
ofmt_handle_t npa_ofmt;
};
/* Version checking */
extern boolean_t nvme_version_check(nvme_version_t *, uint_t, uint_t);
/* printing functions */
extern int nvme_strlen(const char *, int);
extern void nvme_print(int, const char *, int, const char *, ...);
extern void nvme_print_ctrl_summary(nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_nsid_summary(nvme_identify_nsid_t *);
extern void nvme_print_identify_ctrl(nvme_identify_ctrl_t *,
nvme_capabilities_t *, nvme_version_t *);
extern void nvme_print_identify_nsid(nvme_identify_nsid_t *, nvme_version_t *);
extern void nvme_print_error_log(int, nvme_error_log_entry_t *,
nvme_version_t *);
extern void nvme_print_health_log(nvme_health_log_t *, nvme_identify_ctrl_t *,
nvme_version_t *);
extern void nvme_print_fwslot_log(nvme_fwslot_log_t *, nvme_identify_ctrl_t *);
extern void nvme_print_feat_arbitration(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_power_mgmt(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_lba_range(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_temperature(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_error(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_write_cache(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_nqueues(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_intr_coal(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_intr_vect(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_write_atom(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_async_event(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_auto_pst(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern void nvme_print_feat_progress(uint64_t, void *, size_t,
nvme_identify_ctrl_t *, nvme_version_t *);
extern const char *nvme_fw_error(int, int);
/* device node functions */
extern int nvme_open(di_minor_t);
extern void nvme_close(int);
extern nvme_version_t *nvme_version(int);
extern nvme_capabilities_t *nvme_capabilities(int);
extern nvme_identify_ctrl_t *nvme_identify_ctrl(int);
extern nvme_identify_nsid_t *nvme_identify_nsid(int);
extern void *nvme_get_logpage(int, uint8_t, size_t *);
extern boolean_t nvme_get_feature(int, uint8_t, uint32_t, uint64_t *, size_t *,
void **);
extern int nvme_intr_cnt(int);
extern boolean_t nvme_format_nvm(int, uint8_t, uint8_t);
extern boolean_t nvme_detach(int);
extern boolean_t nvme_attach(int);
extern boolean_t nvme_firmware_load(int, void *, size_t, offset_t, uint16_t *);
extern boolean_t nvme_firmware_commit(int, int, int, uint16_t *);
/*
* ofmt related
*/
extern const ofmt_field_t nvme_list_ofmt[];
#ifdef __cplusplus
}
#endif
#endif /* _NVMEADM_H */
|