1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2016 Nexenta Systems, Inc. 14 * Copyright 2019 Western Digital Corporation 15 * Copyright 2020 Oxide Computer Company 16 */ 17 18 #ifndef _NVMEADM_H 19 #define _NVMEADM_H 20 21 #include <stdio.h> 22 #include <libdevinfo.h> 23 #include <sys/nvme.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 extern int verbose; 30 extern int debug; 31 32 /* printing functions */ 33 extern void nvme_print(int, const char *, int, const char *, ...); 34 extern void nvme_print_ctrl_summary(nvme_identify_ctrl_t *, nvme_version_t *); 35 extern void nvme_print_nsid_summary(nvme_identify_nsid_t *); 36 extern void nvme_print_identify_ctrl(nvme_identify_ctrl_t *, 37 nvme_capabilities_t *, nvme_version_t *); 38 extern void nvme_print_identify_nsid(nvme_identify_nsid_t *, nvme_version_t *); 39 extern void nvme_print_error_log(int, nvme_error_log_entry_t *); 40 extern void nvme_print_health_log(nvme_health_log_t *, nvme_identify_ctrl_t *, 41 nvme_version_t *); 42 extern void nvme_print_fwslot_log(nvme_fwslot_log_t *); 43 44 extern void nvme_print_feat_arbitration(uint64_t, void *, size_t, 45 nvme_identify_ctrl_t *); 46 extern void nvme_print_feat_power_mgmt(uint64_t, void *, size_t, 47 nvme_identify_ctrl_t *); 48 extern void nvme_print_feat_lba_range(uint64_t, void *, size_t, 49 nvme_identify_ctrl_t *); 50 extern void nvme_print_feat_temperature(uint64_t, void *, size_t, 51 nvme_identify_ctrl_t *); 52 extern void nvme_print_feat_error(uint64_t, void *, size_t, 53 nvme_identify_ctrl_t *); 54 extern void nvme_print_feat_write_cache(uint64_t, void *, size_t, 55 nvme_identify_ctrl_t *); 56 extern void nvme_print_feat_nqueues(uint64_t, void *, size_t, 57 nvme_identify_ctrl_t *); 58 extern void nvme_print_feat_intr_coal(uint64_t, void *, size_t, 59 nvme_identify_ctrl_t *); 60 extern void nvme_print_feat_intr_vect(uint64_t, void *, size_t, 61 nvme_identify_ctrl_t *); 62 extern void nvme_print_feat_write_atom(uint64_t, void *, size_t, 63 nvme_identify_ctrl_t *); 64 extern void nvme_print_feat_async_event(uint64_t, void *, size_t, 65 nvme_identify_ctrl_t *); 66 extern void nvme_print_feat_auto_pst(uint64_t, void *, size_t, 67 nvme_identify_ctrl_t *); 68 extern void nvme_print_feat_progress(uint64_t, void *, size_t, 69 nvme_identify_ctrl_t *); 70 extern const char *nvme_str_error(int, int); 71 72 /* device node functions */ 73 extern int nvme_open(di_minor_t); 74 extern void nvme_close(int); 75 extern nvme_version_t *nvme_version(int); 76 extern nvme_capabilities_t *nvme_capabilities(int); 77 extern nvme_identify_ctrl_t *nvme_identify_ctrl(int); 78 extern nvme_identify_nsid_t *nvme_identify_nsid(int); 79 extern void *nvme_get_logpage(int, uint8_t, size_t *); 80 extern boolean_t nvme_get_feature(int, uint8_t, uint32_t, uint64_t *, size_t *, 81 void **); 82 extern int nvme_intr_cnt(int); 83 extern boolean_t nvme_format_nvm(int, uint8_t, uint8_t); 84 extern boolean_t nvme_detach(int); 85 extern boolean_t nvme_attach(int); 86 extern boolean_t nvme_firmware_load(int, void *, size_t, offset_t); 87 extern boolean_t nvme_firmware_commit(int fd, int, int, uint16_t *, uint16_t *); 88 89 #ifdef __cplusplus 90 } 91 #endif 92 93 #endif /* _NVMEADM_H */ 94