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