From 7bde339ba918740c3158dd24a31f8f3971af58ce Mon Sep 17 00:00:00 2001 From: Brandon Paupore Date: Thu, 18 Dec 2025 17:44:00 -0600 Subject: [PATCH] plugins: update default telemetry retrieval DA Instead of retrieving just Data Area 3, check for DA4 support and use that if available by default. This should ensure the default case captures as much telemetry data as possible, while still allowing explicit capture of a smaller data area. Signed-off-by: Brandon Paupore Reviewed-by: Jeffrey Lien --- plugins/sandisk/sandisk-nvme.c | 37 +++++++++++++++++++++++----- plugins/sandisk/sandisk-nvme.h | 2 +- plugins/wdc/wdc-nvme.c | 44 +++++++++++++++++++++++++++------- plugins/wdc/wdc-nvme.h | 2 +- 4 files changed, 69 insertions(+), 16 deletions(-) diff --git a/plugins/sandisk/sandisk-nvme.c b/plugins/sandisk/sandisk-nvme.c index eba5db105e..1bb73d0abb 100644 --- a/plugins/sandisk/sandisk-nvme.c +++ b/plugins/sandisk/sandisk-nvme.c @@ -281,6 +281,27 @@ static int sndk_do_cap_udui(struct nvme_transport_handle *hdl, char *file, return ret; } +static int sndk_get_default_telemetry_da(struct nvme_transport_handle *hdl, + int *data_area) +{ + struct nvme_id_ctrl ctrl; + int err; + + memset(&ctrl, 0, sizeof(struct nvme_id_ctrl)); + err = nvme_identify_ctrl(hdl, &ctrl); + if (err) { + fprintf(stderr, "ERROR: SNDK: nvme_identify_ctrl() failed 0x%x\n", err); + return err; + } + + if (ctrl.lpa & 0x40) + *data_area = 4; + else + *data_area = 3; + + return 0; +} + static int sndk_vs_internal_fw_log(int argc, char **argv, struct command *command, struct plugin *plugin) @@ -423,9 +444,11 @@ static int sndk_vs_internal_fw_log(int argc, char **argv, /* Supported through WDC plugin for non-telemetry */ if ((capabilities & SNDK_DRIVE_CAP_INTERNAL_LOG) && (telemetry_type != SNDK_TELEMETRY_TYPE_NONE)) { - /* Set the default DA to 3 if not specified */ - if (!telemetry_data_area) - telemetry_data_area = 3; + if (sndk_get_default_telemetry_da(hdl, &telemetry_data_area)) { + fprintf(stderr, "%s: Error determining default telemetry data area\n", + __func__); + return -EINVAL; + } ret = sndk_do_cap_telemetry_log(ctx, hdl, f, xfer_size, telemetry_type, telemetry_data_area); @@ -435,9 +458,11 @@ static int sndk_vs_internal_fw_log(int argc, char **argv, if (capabilities & SNDK_DRIVE_CAP_UDUI) { if ((telemetry_type == SNDK_TELEMETRY_TYPE_HOST) || (telemetry_type == SNDK_TELEMETRY_TYPE_CONTROLLER)) { - /* Set the default DA to 3 if not specified */ - if (!telemetry_data_area) - telemetry_data_area = 3; + if (sndk_get_default_telemetry_da(hdl, &telemetry_data_area)) { + fprintf(stderr, "%s: Error determining default telemetry data area\n", + __func__); + return -EINVAL; + } ret = sndk_do_cap_telemetry_log(ctx, hdl, f, xfer_size, telemetry_type, telemetry_data_area); diff --git a/plugins/sandisk/sandisk-nvme.h b/plugins/sandisk/sandisk-nvme.h index 6f8297be9c..0101b7e7bd 100644 --- a/plugins/sandisk/sandisk-nvme.h +++ b/plugins/sandisk/sandisk-nvme.h @@ -5,7 +5,7 @@ #if !defined(SANDISK_NVME) || defined(CMD_HEADER_MULTI_READ) #define SANDISK_NVME -#define SANDISK_PLUGIN_VERSION "3.0.8" +#define SANDISK_PLUGIN_VERSION "3.1.0" #include "cmd.h" PLUGIN(NAME("sndk", "Sandisk vendor specific extensions", SANDISK_PLUGIN_VERSION), diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index 53a23ec0e7..066a64b4c4 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -4268,6 +4268,27 @@ static int dump_internal_logs(struct nvme_transport_handle *hdl, const char *dir return err; } +static int wdc_get_default_telemetry_da(struct nvme_transport_handle *hdl, + int *data_area) +{ + struct nvme_id_ctrl ctrl; + int err; + + memset(&ctrl, 0, sizeof(struct nvme_id_ctrl)); + err = nvme_identify_ctrl(hdl, &ctrl); + if (err) { + fprintf(stderr, "ERROR: WDC: nvme_identify_ctrl() failed 0x%x\n", err); + return err; + } + + if (ctrl.lpa & 0x40) + *data_area = 4; + else + *data_area = 3; + + return 0; +} + static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd, struct plugin *plugin) { @@ -4451,9 +4472,11 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd, capabilities = wdc_get_drive_capabilities(ctx, hdl); if ((capabilities & WDC_DRIVE_CAP_INTERNAL_LOG) == WDC_DRIVE_CAP_INTERNAL_LOG) { if (!wdc_is_sn861(device_id)) { - /* Set the default DA to 3 if not specified */ - if (!telemetry_data_area) - telemetry_data_area = 3; + if (wdc_get_default_telemetry_da(hdl, &telemetry_data_area)) { + fprintf(stderr, "%s: Error determining default telemetry data area\n", + __func__); + return -EINVAL; + } ret = wdc_do_cap_diag(ctx, hdl, f, xfer_size, telemetry_type, telemetry_data_area); @@ -4491,8 +4514,11 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd, if ((capabilities & WDC_DRIVE_CAP_DUI) == WDC_DRIVE_CAP_DUI) { if ((telemetry_type == WDC_TELEMETRY_TYPE_HOST) || (telemetry_type == WDC_TELEMETRY_TYPE_CONTROLLER)) { - if (!telemetry_data_area) - telemetry_data_area = 3; /* Set the default DA to 3 if not specified */ + if (wdc_get_default_telemetry_da(hdl, &telemetry_data_area)) { + fprintf(stderr, "%s: Error determining default telemetry data area\n", + __func__); + return -EINVAL; + } /* Get the desired telemetry log page */ ret = wdc_do_cap_telemetry_log(ctx, hdl, f, xfer_size, telemetry_type, telemetry_data_area); @@ -4514,9 +4540,11 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd, if ((capabilities & WDC_DRIVE_CAP_DUI_DATA) == WDC_DRIVE_CAP_DUI_DATA) { if ((telemetry_type == WDC_TELEMETRY_TYPE_HOST) || (telemetry_type == WDC_TELEMETRY_TYPE_CONTROLLER)) { - if (!telemetry_data_area) - telemetry_data_area = 3; /* Set the default DA to 3 if not specified */ - /* Get the desired telemetry log page */ + if (wdc_get_default_telemetry_da(hdl, &telemetry_data_area)) { + fprintf(stderr, "%s: Error determining default telemetry data area\n", + __func__); + return -EINVAL; + } ret = wdc_do_cap_telemetry_log(ctx, hdl, f, xfer_size, telemetry_type, telemetry_data_area); goto out; diff --git a/plugins/wdc/wdc-nvme.h b/plugins/wdc/wdc-nvme.h index 82747cb3ae..78e2f0fe74 100644 --- a/plugins/wdc/wdc-nvme.h +++ b/plugins/wdc/wdc-nvme.h @@ -5,7 +5,7 @@ #if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ) #define WDC_NVME -#define WDC_PLUGIN_VERSION "2.14.7" +#define WDC_PLUGIN_VERSION "2.15.0" #include "cmd.h" PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION),