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