1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * NVM Express device driver verbose errors
4 * Copyright (c) 2022, Oracle and/or its affiliates
5 */
6
7 #include "nvme.h"
8
9 static const char * const nvme_ops[] = {
10 [nvme_cmd_flush] = "Flush",
11 [nvme_cmd_write] = "Write",
12 [nvme_cmd_read] = "Read",
13 [nvme_cmd_write_uncor] = "Write Uncorrectable",
14 [nvme_cmd_compare] = "Compare",
15 [nvme_cmd_write_zeroes] = "Write Zeros",
16 [nvme_cmd_dsm] = "Dataset Management",
17 [nvme_cmd_verify] = "Verify",
18 [nvme_cmd_resv_register] = "Reservation Register",
19 [nvme_cmd_resv_report] = "Reservation Report",
20 [nvme_cmd_resv_acquire] = "Reservation Acquire",
21 [nvme_cmd_resv_release] = "Reservation Release",
22 [nvme_cmd_zone_mgmt_send] = "Zone Management Send",
23 [nvme_cmd_zone_mgmt_recv] = "Zone Management Receive",
24 [nvme_cmd_zone_append] = "Zone Append",
25 };
26
27 static const char * const nvme_admin_ops[] = {
28 [nvme_admin_delete_sq] = "Delete SQ",
29 [nvme_admin_create_sq] = "Create SQ",
30 [nvme_admin_get_log_page] = "Get Log Page",
31 [nvme_admin_delete_cq] = "Delete CQ",
32 [nvme_admin_create_cq] = "Create CQ",
33 [nvme_admin_identify] = "Identify",
34 [nvme_admin_abort_cmd] = "Abort Command",
35 [nvme_admin_set_features] = "Set Features",
36 [nvme_admin_get_features] = "Get Features",
37 [nvme_admin_async_event] = "Async Event",
38 [nvme_admin_ns_mgmt] = "Namespace Management",
39 [nvme_admin_activate_fw] = "Activate Firmware",
40 [nvme_admin_download_fw] = "Download Firmware",
41 [nvme_admin_dev_self_test] = "Device Self Test",
42 [nvme_admin_ns_attach] = "Namespace Attach",
43 [nvme_admin_keep_alive] = "Keep Alive",
44 [nvme_admin_directive_send] = "Directive Send",
45 [nvme_admin_directive_recv] = "Directive Receive",
46 [nvme_admin_virtual_mgmt] = "Virtual Management",
47 [nvme_admin_nvme_mi_send] = "NVMe Send MI",
48 [nvme_admin_nvme_mi_recv] = "NVMe Receive MI",
49 [nvme_admin_dbbuf] = "Doorbell Buffer Config",
50 [nvme_admin_format_nvm] = "Format NVM",
51 [nvme_admin_security_send] = "Security Send",
52 [nvme_admin_security_recv] = "Security Receive",
53 [nvme_admin_sanitize_nvm] = "Sanitize NVM",
54 [nvme_admin_get_lba_status] = "Get LBA Status",
55 };
56
57 static const char * const nvme_statuses[] = {
58 [NVME_SC_SUCCESS] = "Success",
59 [NVME_SC_INVALID_OPCODE] = "Invalid Command Opcode",
60 [NVME_SC_INVALID_FIELD] = "Invalid Field in Command",
61 [NVME_SC_CMDID_CONFLICT] = "Command ID Conflict",
62 [NVME_SC_DATA_XFER_ERROR] = "Data Transfer Error",
63 [NVME_SC_POWER_LOSS] = "Commands Aborted due to Power Loss Notification",
64 [NVME_SC_INTERNAL] = "Internal Error",
65 [NVME_SC_ABORT_REQ] = "Command Abort Requested",
66 [NVME_SC_ABORT_QUEUE] = "Command Aborted due to SQ Deletion",
67 [NVME_SC_FUSED_FAIL] = "Command Aborted due to Failed Fused Command",
68 [NVME_SC_FUSED_MISSING] = "Command Aborted due to Missing Fused Command",
69 [NVME_SC_INVALID_NS] = "Invalid Namespace or Format",
70 [NVME_SC_CMD_SEQ_ERROR] = "Command Sequence Error",
71 [NVME_SC_SGL_INVALID_LAST] = "Invalid SGL Segment Descriptor",
72 [NVME_SC_SGL_INVALID_COUNT] = "Invalid Number of SGL Descriptors",
73 [NVME_SC_SGL_INVALID_DATA] = "Data SGL Length Invalid",
74 [NVME_SC_SGL_INVALID_METADATA] = "Metadata SGL Length Invalid",
75 [NVME_SC_SGL_INVALID_TYPE] = "SGL Descriptor Type Invalid",
76 [NVME_SC_CMB_INVALID_USE] = "Invalid Use of Controller Memory Buffer",
77 [NVME_SC_PRP_INVALID_OFFSET] = "PRP Offset Invalid",
78 [NVME_SC_ATOMIC_WU_EXCEEDED] = "Atomic Write Unit Exceeded",
79 [NVME_SC_OP_DENIED] = "Operation Denied",
80 [NVME_SC_SGL_INVALID_OFFSET] = "SGL Offset Invalid",
81 [NVME_SC_RESERVED] = "Reserved",
82 [NVME_SC_HOST_ID_INCONSIST] = "Host Identifier Inconsistent Format",
83 [NVME_SC_KA_TIMEOUT_EXPIRED] = "Keep Alive Timeout Expired",
84 [NVME_SC_KA_TIMEOUT_INVALID] = "Keep Alive Timeout Invalid",
85 [NVME_SC_ABORTED_PREEMPT_ABORT] = "Command Aborted due to Preempt and Abort",
86 [NVME_SC_SANITIZE_FAILED] = "Sanitize Failed",
87 [NVME_SC_SANITIZE_IN_PROGRESS] = "Sanitize In Progress",
88 [NVME_SC_SGL_INVALID_GRANULARITY] = "SGL Data Block Granularity Invalid",
89 [NVME_SC_CMD_NOT_SUP_CMB_QUEUE] = "Command Not Supported for Queue in CMB",
90 [NVME_SC_NS_WRITE_PROTECTED] = "Namespace is Write Protected",
91 [NVME_SC_CMD_INTERRUPTED] = "Command Interrupted",
92 [NVME_SC_TRANSIENT_TR_ERR] = "Transient Transport Error",
93 [NVME_SC_ADMIN_COMMAND_MEDIA_NOT_READY] = "Admin Command Media Not Ready",
94 [NVME_SC_INVALID_IO_CMD_SET] = "Invalid IO Command Set",
95 [NVME_SC_LBA_RANGE] = "LBA Out of Range",
96 [NVME_SC_CAP_EXCEEDED] = "Capacity Exceeded",
97 [NVME_SC_NS_NOT_READY] = "Namespace Not Ready",
98 [NVME_SC_RESERVATION_CONFLICT] = "Reservation Conflict",
99 [NVME_SC_FORMAT_IN_PROGRESS] = "Format In Progress",
100 [NVME_SC_CQ_INVALID] = "Completion Queue Invalid",
101 [NVME_SC_QID_INVALID] = "Invalid Queue Identifier",
102 [NVME_SC_QUEUE_SIZE] = "Invalid Queue Size",
103 [NVME_SC_ABORT_LIMIT] = "Abort Command Limit Exceeded",
104 [NVME_SC_ABORT_MISSING] = "Reserved", /* XXX */
105 [NVME_SC_ASYNC_LIMIT] = "Asynchronous Event Request Limit Exceeded",
106 [NVME_SC_FIRMWARE_SLOT] = "Invalid Firmware Slot",
107 [NVME_SC_FIRMWARE_IMAGE] = "Invalid Firmware Image",
108 [NVME_SC_INVALID_VECTOR] = "Invalid Interrupt Vector",
109 [NVME_SC_INVALID_LOG_PAGE] = "Invalid Log Page",
110 [NVME_SC_INVALID_FORMAT] = "Invalid Format",
111 [NVME_SC_FW_NEEDS_CONV_RESET] = "Firmware Activation Requires Conventional Reset",
112 [NVME_SC_INVALID_QUEUE] = "Invalid Queue Deletion",
113 [NVME_SC_FEATURE_NOT_SAVEABLE] = "Feature Identifier Not Saveable",
114 [NVME_SC_FEATURE_NOT_CHANGEABLE] = "Feature Not Changeable",
115 [NVME_SC_FEATURE_NOT_PER_NS] = "Feature Not Namespace Specific",
116 [NVME_SC_FW_NEEDS_SUBSYS_RESET] = "Firmware Activation Requires NVM Subsystem Reset",
117 [NVME_SC_FW_NEEDS_RESET] = "Firmware Activation Requires Reset",
118 [NVME_SC_FW_NEEDS_MAX_TIME] = "Firmware Activation Requires Maximum Time Violation",
119 [NVME_SC_FW_ACTIVATE_PROHIBITED] = "Firmware Activation Prohibited",
120 [NVME_SC_OVERLAPPING_RANGE] = "Overlapping Range",
121 [NVME_SC_NS_INSUFFICIENT_CAP] = "Namespace Insufficient Capacity",
122 [NVME_SC_NS_ID_UNAVAILABLE] = "Namespace Identifier Unavailable",
123 [NVME_SC_NS_ALREADY_ATTACHED] = "Namespace Already Attached",
124 [NVME_SC_NS_IS_PRIVATE] = "Namespace Is Private",
125 [NVME_SC_NS_NOT_ATTACHED] = "Namespace Not Attached",
126 [NVME_SC_THIN_PROV_NOT_SUPP] = "Thin Provisioning Not Supported",
127 [NVME_SC_CTRL_LIST_INVALID] = "Controller List Invalid",
128 [NVME_SC_SELT_TEST_IN_PROGRESS] = "Device Self-test In Progress",
129 [NVME_SC_BP_WRITE_PROHIBITED] = "Boot Partition Write Prohibited",
130 [NVME_SC_CTRL_ID_INVALID] = "Invalid Controller Identifier",
131 [NVME_SC_SEC_CTRL_STATE_INVALID] = "Invalid Secondary Controller State",
132 [NVME_SC_CTRL_RES_NUM_INVALID] = "Invalid Number of Controller Resources",
133 [NVME_SC_RES_ID_INVALID] = "Invalid Resource Identifier",
134 [NVME_SC_PMR_SAN_PROHIBITED] = "Sanitize Prohibited",
135 [NVME_SC_ANA_GROUP_ID_INVALID] = "ANA Group Identifier Invalid",
136 [NVME_SC_ANA_ATTACH_FAILED] = "ANA Attach Failed",
137 [NVME_SC_BAD_ATTRIBUTES] = "Conflicting Attributes",
138 [NVME_SC_INVALID_PI] = "Invalid Protection Information",
139 [NVME_SC_READ_ONLY] = "Attempted Write to Read Only Range",
140 [NVME_SC_ONCS_NOT_SUPPORTED] = "ONCS Not Supported",
141 [NVME_SC_ZONE_BOUNDARY_ERROR] = "Zoned Boundary Error",
142 [NVME_SC_ZONE_FULL] = "Zone Is Full",
143 [NVME_SC_ZONE_READ_ONLY] = "Zone Is Read Only",
144 [NVME_SC_ZONE_OFFLINE] = "Zone Is Offline",
145 [NVME_SC_ZONE_INVALID_WRITE] = "Zone Invalid Write",
146 [NVME_SC_ZONE_TOO_MANY_ACTIVE] = "Too Many Active Zones",
147 [NVME_SC_ZONE_TOO_MANY_OPEN] = "Too Many Open Zones",
148 [NVME_SC_ZONE_INVALID_TRANSITION] = "Invalid Zone State Transition",
149 [NVME_SC_WRITE_FAULT] = "Write Fault",
150 [NVME_SC_READ_ERROR] = "Unrecovered Read Error",
151 [NVME_SC_GUARD_CHECK] = "End-to-end Guard Check Error",
152 [NVME_SC_APPTAG_CHECK] = "End-to-end Application Tag Check Error",
153 [NVME_SC_REFTAG_CHECK] = "End-to-end Reference Tag Check Error",
154 [NVME_SC_COMPARE_FAILED] = "Compare Failure",
155 [NVME_SC_ACCESS_DENIED] = "Access Denied",
156 [NVME_SC_UNWRITTEN_BLOCK] = "Deallocated or Unwritten Logical Block",
157 [NVME_SC_INTERNAL_PATH_ERROR] = "Internal Pathing Error",
158 [NVME_SC_ANA_PERSISTENT_LOSS] = "Asymmetric Access Persistent Loss",
159 [NVME_SC_ANA_INACCESSIBLE] = "Asymmetric Access Inaccessible",
160 [NVME_SC_ANA_TRANSITION] = "Asymmetric Access Transition",
161 [NVME_SC_CTRL_PATH_ERROR] = "Controller Pathing Error",
162 [NVME_SC_HOST_PATH_ERROR] = "Host Pathing Error",
163 [NVME_SC_HOST_ABORTED_CMD] = "Host Aborted Command",
164 };
165
nvme_get_error_status_str(u16 status)166 const unsigned char *nvme_get_error_status_str(u16 status)
167 {
168 status &= 0x7ff;
169 if (status < ARRAY_SIZE(nvme_statuses) && nvme_statuses[status])
170 return nvme_statuses[status & 0x7ff];
171 return "Unknown";
172 }
173
nvme_get_opcode_str(u8 opcode)174 const unsigned char *nvme_get_opcode_str(u8 opcode)
175 {
176 if (opcode < ARRAY_SIZE(nvme_ops) && nvme_ops[opcode])
177 return nvme_ops[opcode];
178 return "Unknown";
179 }
180 EXPORT_SYMBOL_GPL(nvme_get_opcode_str);
181
nvme_get_admin_opcode_str(u8 opcode)182 const unsigned char *nvme_get_admin_opcode_str(u8 opcode)
183 {
184 if (opcode < ARRAY_SIZE(nvme_admin_ops) && nvme_admin_ops[opcode])
185 return nvme_admin_ops[opcode];
186 return "Unknown";
187 }
188