|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | +/* |
| 3 | + * Copyright (c) 2025 Sandisk Corporation or its affiliates. |
| 4 | + * |
| 5 | + * Author: Jeff Lien <jeff.lien@sandisk.com> |
| 6 | + * Brandon Paupore <brandon.paupore@sandisk.com> |
| 7 | + */ |
| 8 | +#include <stdio.h> |
| 9 | +#include <string.h> |
| 10 | +#include <stdlib.h> |
| 11 | +#include <inttypes.h> |
| 12 | +#include <errno.h> |
| 13 | +#include <limits.h> |
| 14 | +#include <fcntl.h> |
| 15 | +#include <unistd.h> |
| 16 | + |
| 17 | +#include "common.h" |
| 18 | +#include "nvme.h" |
| 19 | +#include "libnvme.h" |
| 20 | +#include "plugin.h" |
| 21 | +#include "linux/types.h" |
| 22 | +#include "util/cleanup.h" |
| 23 | +#include "util/types.h" |
| 24 | +#include "nvme-print.h" |
| 25 | + |
| 26 | +#define CREATE_CMD |
| 27 | +#include "sandisk-nvme.h" |
| 28 | +#include "sandisk-utils.h" |
| 29 | +#include "plugins/wdc/wdc-nvme-cmds.h" |
| 30 | + |
| 31 | + |
| 32 | +static int sndk_vs_internal_fw_log(int argc, char **argv, |
| 33 | + struct command *command, |
| 34 | + struct plugin *plugin) |
| 35 | +{ |
| 36 | + return run_wdc_vs_internal_fw_log(argc, argv, command, plugin); |
| 37 | +} |
| 38 | + |
| 39 | +static int sndk_vs_nand_stats(int argc, char **argv, |
| 40 | + struct command *command, |
| 41 | + struct plugin *plugin) |
| 42 | +{ |
| 43 | + return run_wdc_vs_nand_stats(argc, argv, command, plugin); |
| 44 | +} |
| 45 | + |
| 46 | +static int sndk_vs_smart_add_log(int argc, char **argv, |
| 47 | + struct command *command, |
| 48 | + struct plugin *plugin) |
| 49 | +{ |
| 50 | + return run_wdc_vs_smart_add_log(argc, argv, command, plugin); |
| 51 | +} |
| 52 | + |
| 53 | +static int sndk_clear_pcie_correctable_errors(int argc, char **argv, |
| 54 | + struct command *command, |
| 55 | + struct plugin *plugin) |
| 56 | +{ |
| 57 | + return run_wdc_clear_pcie_correctable_errors(argc, argv, command, plugin); |
| 58 | +} |
| 59 | + |
| 60 | +static int sndk_drive_status(int argc, char **argv, |
| 61 | + struct command *command, |
| 62 | + struct plugin *plugin) |
| 63 | +{ |
| 64 | + return run_wdc_drive_status(argc, argv, command, plugin); |
| 65 | +} |
| 66 | + |
| 67 | +static int sndk_clear_assert_dump(int argc, char **argv, |
| 68 | + struct command *command, |
| 69 | + struct plugin *plugin) |
| 70 | +{ |
| 71 | + return run_wdc_clear_assert_dump(argc, argv, command, plugin); |
| 72 | +} |
| 73 | + |
| 74 | +static int sndk_drive_resize(int argc, char **argv, |
| 75 | + struct command *command, |
| 76 | + struct plugin *plugin) |
| 77 | +{ |
| 78 | + return run_wdc_drive_resize(argc, argv, command, plugin); |
| 79 | +} |
| 80 | + |
| 81 | +static int sndk_vs_fw_activate_history(int argc, char **argv, |
| 82 | + struct command *command, |
| 83 | + struct plugin *plugin) |
| 84 | +{ |
| 85 | + return run_wdc_vs_fw_activate_history(argc, argv, command, plugin); |
| 86 | +} |
| 87 | + |
| 88 | +static int sndk_clear_fw_activate_history(int argc, char **argv, |
| 89 | + struct command *command, |
| 90 | + struct plugin *plugin) |
| 91 | +{ |
| 92 | + return run_wdc_clear_fw_activate_history(argc, argv, command, plugin); |
| 93 | +} |
| 94 | + |
| 95 | +static int sndk_vs_telemetry_controller_option(int argc, char **argv, |
| 96 | + struct command *command, |
| 97 | + struct plugin *plugin) |
| 98 | +{ |
| 99 | + return run_wdc_vs_telemetry_controller_option(argc, argv, command, plugin); |
| 100 | +} |
| 101 | + |
| 102 | +static int sndk_reason_identifier(int argc, char **argv, |
| 103 | + struct command *command, |
| 104 | + struct plugin *plugin) |
| 105 | +{ |
| 106 | + return run_wdc_reason_identifier(argc, argv, command, plugin); |
| 107 | +} |
| 108 | + |
| 109 | +static int sndk_log_page_directory(int argc, char **argv, |
| 110 | + struct command *command, |
| 111 | + struct plugin *plugin) |
| 112 | +{ |
| 113 | + return run_wdc_log_page_directory(argc, argv, command, plugin); |
| 114 | +} |
| 115 | + |
| 116 | +static int sndk_namespace_resize(int argc, char **argv, |
| 117 | + struct command *command, |
| 118 | + struct plugin *plugin) |
| 119 | +{ |
| 120 | + return run_wdc_namespace_resize(argc, argv, command, plugin); |
| 121 | +} |
| 122 | + |
| 123 | +static int sndk_vs_drive_info(int argc, char **argv, |
| 124 | + struct command *command, |
| 125 | + struct plugin *plugin) |
| 126 | +{ |
| 127 | + return run_wdc_vs_drive_info(argc, argv, command, plugin); |
| 128 | +} |
| 129 | + |
| 130 | +static int sndk_capabilities(int argc, char **argv, |
| 131 | + struct command *command, |
| 132 | + struct plugin *plugin) |
| 133 | +{ |
| 134 | + const char *desc = "Send a capabilities command."; |
| 135 | + uint64_t capabilities = 0; |
| 136 | + struct nvme_dev *dev; |
| 137 | + nvme_root_t r; |
| 138 | + int ret; |
| 139 | + |
| 140 | + OPT_ARGS(opts) = { |
| 141 | + OPT_END() |
| 142 | + }; |
| 143 | + |
| 144 | + ret = parse_and_open(&dev, argc, argv, desc, opts); |
| 145 | + if (ret) |
| 146 | + return ret; |
| 147 | + |
| 148 | + /* get capabilities */ |
| 149 | + r = nvme_scan(NULL); |
| 150 | + sndk_check_device(r, dev); |
| 151 | + capabilities = sndk_get_drive_capabilities(r, dev); |
| 152 | + |
| 153 | + /* print command and supported status */ |
| 154 | + printf("Sandisk Plugin Capabilities for NVME device:%s\n", dev->name); |
| 155 | + printf("vs-internal-log : %s\n", |
| 156 | + capabilities & SNDK_DRIVE_CAP_INTERNAL_LOG_MASK ? "Supported" : "Not Supported"); |
| 157 | + printf("vs-nand-stats : %s\n", |
| 158 | + capabilities & SNDK_DRIVE_CAP_NAND_STATS ? "Supported" : "Not Supported"); |
| 159 | + printf("vs-smart-add-log : %s\n", |
| 160 | + capabilities & SNDK_DRIVE_CAP_SMART_LOG_MASK ? "Supported" : "Not Supported"); |
| 161 | + printf("--C0 Log Page : %s\n", |
| 162 | + capabilities & SNDK_DRIVE_CAP_C0_LOG_PAGE ? "Supported" : "Not Supported"); |
| 163 | + printf("--C1 Log Page : %s\n", |
| 164 | + capabilities & SNDK_DRIVE_CAP_C1_LOG_PAGE ? "Supported" : "Not Supported"); |
| 165 | + printf("--C3 Log Page : %s\n", |
| 166 | + capabilities & SNDK_DRIVE_CAP_C3_LOG_PAGE ? "Supported" : "Not Supported"); |
| 167 | + printf("--CA Log Page : %s\n", |
| 168 | + capabilities & SNDK_DRIVE_CAP_CA_LOG_PAGE ? "Supported" : "Not Supported"); |
| 169 | + printf("--D0 Log Page : %s\n", |
| 170 | + capabilities & SNDK_DRIVE_CAP_D0_LOG_PAGE ? "Supported" : "Not Supported"); |
| 171 | + printf("clear-pcie-correctable-errors : %s\n", |
| 172 | + capabilities & SNDK_DRIVE_CAP_CLEAR_PCIE_MASK ? "Supported" : "Not Supported"); |
| 173 | + printf("get-drive-status : %s\n", |
| 174 | + capabilities & SNDK_DRIVE_CAP_DRIVE_STATUS ? "Supported" : "Not Supported"); |
| 175 | + printf("drive-resize : %s\n", |
| 176 | + capabilities & SNDK_DRIVE_CAP_RESIZE ? "Supported" : "Not Supported"); |
| 177 | + printf("vs-fw-activate-history : %s\n", |
| 178 | + capabilities & SNDK_DRIVE_CAP_FW_ACTIVATE_HISTORY_MASK ? "Supported" : |
| 179 | + "Not Supported"); |
| 180 | + printf("clear-fw-activate-history : %s\n", |
| 181 | + capabilities & SNDK_DRIVE_CAP_CLEAR_FW_ACT_HISTORY_MASK ? "Supported" : |
| 182 | + "Not Supported"); |
| 183 | + printf("vs-telemetry-controller-option: %s\n", |
| 184 | + capabilities & SNDK_DRIVE_CAP_DISABLE_CTLR_TELE_LOG ? "Supported" : "Not Supported"); |
| 185 | + printf("vs-error-reason-identifier : %s\n", |
| 186 | + capabilities & SNDK_DRIVE_CAP_REASON_ID ? "Supported" : "Not Supported"); |
| 187 | + printf("log-page-directory : %s\n", |
| 188 | + capabilities & SNDK_DRIVE_CAP_LOG_PAGE_DIR ? "Supported" : "Not Supported"); |
| 189 | + printf("namespace-resize : %s\n", |
| 190 | + capabilities & SNDK_DRIVE_CAP_NS_RESIZE ? "Supported" : "Not Supported"); |
| 191 | + printf("vs-drive-info : %s\n", |
| 192 | + capabilities & SNDK_DRIVE_CAP_INFO ? "Supported" : "Not Supported"); |
| 193 | + printf("vs-temperature-stats : %s\n", |
| 194 | + capabilities & SNDK_DRIVE_CAP_TEMP_STATS ? "Supported" : "Not Supported"); |
| 195 | + printf("cloud-SSD-plugin-version : %s\n", |
| 196 | + capabilities & SNDK_DRIVE_CAP_CLOUD_SSD_VERSION ? "Supported" : "Not Supported"); |
| 197 | + printf("vs-pcie-stats : %s\n", |
| 198 | + capabilities & SNDK_DRIVE_CAP_PCIE_STATS ? "Supported" : "Not Supported"); |
| 199 | + printf("get-error-recovery-log : %s\n", |
| 200 | + capabilities & SNDK_DRIVE_CAP_OCP_C1_LOG_PAGE ? "Supported" : "Not Supported"); |
| 201 | + printf("get-dev-capabilities-log : %s\n", |
| 202 | + capabilities & SNDK_DRIVE_CAP_OCP_C4_LOG_PAGE ? "Supported" : "Not Supported"); |
| 203 | + printf("get-unsupported-reqs-log : %s\n", |
| 204 | + capabilities & SNDK_DRIVE_CAP_OCP_C5_LOG_PAGE ? "Supported" : "Not Supported"); |
| 205 | + printf("get-latency-monitor-log : %s\n", |
| 206 | + capabilities & SNDK_DRIVE_CAP_C3_LOG_PAGE ? "Supported" : "Not Supported"); |
| 207 | + printf("cloud-boot-SSD-version : %s\n", |
| 208 | + capabilities & SNDK_DRIVE_CAP_CLOUD_BOOT_SSD_VERSION ? "Supported" : |
| 209 | + "Not Supported"); |
| 210 | + printf("vs-cloud-log : %s\n", |
| 211 | + capabilities & SNDK_DRIVE_CAP_CLOUD_LOG_PAGE ? "Supported" : "Not Supported"); |
| 212 | + printf("vs-hw-rev-log : %s\n", |
| 213 | + capabilities & SNDK_DRIVE_CAP_HW_REV_LOG_PAGE ? "Supported" : "Not Supported"); |
| 214 | + printf("vs-device_waf : %s\n", |
| 215 | + capabilities & SNDK_DRIVE_CAP_DEVICE_WAF ? "Supported" : "Not Supported"); |
| 216 | + printf("set-latency-monitor-feature : %s\n", |
| 217 | + capabilities & SNDK_DRIVE_CAP_SET_LATENCY_MONITOR ? "Supported" : "Not Supported"); |
| 218 | + printf("capabilities : Supported\n"); |
| 219 | + nvme_free_tree(r); |
| 220 | + dev_close(dev); |
| 221 | + |
| 222 | + return 0; |
| 223 | +} |
| 224 | + |
| 225 | +static int sndk_cloud_ssd_plugin_version(int argc, char **argv, |
| 226 | + struct command *command, |
| 227 | + struct plugin *plugin) |
| 228 | +{ |
| 229 | + return run_wdc_cloud_ssd_plugin_version(argc, argv, command, plugin); |
| 230 | +} |
| 231 | + |
| 232 | +static int sndk_vs_pcie_stats(int argc, char **argv, |
| 233 | + struct command *command, |
| 234 | + struct plugin *plugin) |
| 235 | +{ |
| 236 | + return run_wdc_vs_pcie_stats(argc, argv, command, plugin); |
| 237 | +} |
| 238 | + |
| 239 | +static int sndk_get_latency_monitor_log(int argc, char **argv, |
| 240 | + struct command *command, |
| 241 | + struct plugin *plugin) |
| 242 | +{ |
| 243 | + return run_wdc_get_latency_monitor_log(argc, argv, command, plugin); |
| 244 | +} |
| 245 | + |
| 246 | +static int sndk_get_error_recovery_log(int argc, char **argv, |
| 247 | + struct command *command, |
| 248 | + struct plugin *plugin) |
| 249 | +{ |
| 250 | + return run_wdc_get_error_recovery_log(argc, argv, command, plugin); |
| 251 | +} |
| 252 | + |
| 253 | +static int sndk_get_dev_capabilities_log(int argc, char **argv, |
| 254 | + struct command *command, |
| 255 | + struct plugin *plugin) |
| 256 | +{ |
| 257 | + return run_wdc_get_dev_capabilities_log(argc, argv, command, plugin); |
| 258 | +} |
| 259 | + |
| 260 | +static int sndk_get_unsupported_reqs_log(int argc, char **argv, |
| 261 | + struct command *command, |
| 262 | + struct plugin *plugin) |
| 263 | +{ |
| 264 | + return run_wdc_get_unsupported_reqs_log(argc, argv, command, plugin); |
| 265 | +} |
| 266 | + |
| 267 | +static int sndk_cloud_boot_SSD_version(int argc, char **argv, |
| 268 | + struct command *command, |
| 269 | + struct plugin *plugin) |
| 270 | +{ |
| 271 | + return run_wdc_cloud_boot_SSD_version(argc, argv, command, plugin); |
| 272 | +} |
| 273 | + |
| 274 | +static int sndk_vs_cloud_log(int argc, char **argv, |
| 275 | + struct command *command, |
| 276 | + struct plugin *plugin) |
| 277 | +{ |
| 278 | + return run_wdc_vs_cloud_log(argc, argv, command, plugin); |
| 279 | +} |
| 280 | + |
| 281 | +static int sndk_vs_hw_rev_log(int argc, char **argv, |
| 282 | + struct command *command, |
| 283 | + struct plugin *plugin) |
| 284 | +{ |
| 285 | + return run_wdc_vs_hw_rev_log(argc, argv, command, plugin); |
| 286 | +} |
| 287 | + |
| 288 | +static int sndk_vs_device_waf(int argc, char **argv, |
| 289 | + struct command *command, |
| 290 | + struct plugin *plugin) |
| 291 | +{ |
| 292 | + return run_wdc_vs_device_waf(argc, argv, command, plugin); |
| 293 | +} |
| 294 | + |
| 295 | +static int sndk_set_latency_monitor_feature(int argc, char **argv, |
| 296 | + struct command *command, |
| 297 | + struct plugin *plugin) |
| 298 | +{ |
| 299 | + return run_wdc_set_latency_monitor_feature(argc, argv, command, plugin); |
| 300 | +} |
| 301 | + |
| 302 | +static int sndk_vs_temperature_stats(int argc, char **argv, |
| 303 | + struct command *command, |
| 304 | + struct plugin *plugin) |
| 305 | +{ |
| 306 | + return run_wdc_vs_temperature_stats(argc, argv, command, plugin); |
| 307 | +} |
0 commit comments