Skip to content

Commit a2e1b83

Browse files
brandon-paupore-sndkigaw
authored andcommitted
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 <[email protected]> Reviewed-by: Jeffrey Lien <[email protected]>
1 parent c16be1f commit a2e1b83

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed

plugins/sandisk/sandisk-nvme.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,27 @@ static int sndk_do_cap_udui(struct nvme_transport_handle *hdl, char *file,
281281
return ret;
282282
}
283283

284+
static int sndk_get_default_telemetry_da(struct nvme_transport_handle *hdl,
285+
int *data_area)
286+
{
287+
struct nvme_id_ctrl ctrl;
288+
int err;
289+
290+
memset(&ctrl, 0, sizeof(struct nvme_id_ctrl));
291+
err = nvme_identify_ctrl(hdl, &ctrl);
292+
if (err) {
293+
fprintf(stderr, "ERROR: SNDK: nvme_identify_ctrl() failed 0x%x\n", err);
294+
return err;
295+
}
296+
297+
if (ctrl.lpa & 0x40)
298+
*data_area = 4;
299+
else
300+
*data_area = 3;
301+
302+
return 0;
303+
}
304+
284305
static int sndk_vs_internal_fw_log(int argc, char **argv,
285306
struct command *command,
286307
struct plugin *plugin)
@@ -423,9 +444,11 @@ static int sndk_vs_internal_fw_log(int argc, char **argv,
423444
/* Supported through WDC plugin for non-telemetry */
424445
if ((capabilities & SNDK_DRIVE_CAP_INTERNAL_LOG) &&
425446
(telemetry_type != SNDK_TELEMETRY_TYPE_NONE)) {
426-
/* Set the default DA to 3 if not specified */
427-
if (!telemetry_data_area)
428-
telemetry_data_area = 3;
447+
if (sndk_get_default_telemetry_da(hdl, &telemetry_data_area)) {
448+
fprintf(stderr, "%s: Error determining default telemetry data area\n",
449+
__func__);
450+
return -EINVAL;
451+
}
429452

430453
ret = sndk_do_cap_telemetry_log(ctx, hdl, f, xfer_size,
431454
telemetry_type, telemetry_data_area);
@@ -435,9 +458,11 @@ static int sndk_vs_internal_fw_log(int argc, char **argv,
435458
if (capabilities & SNDK_DRIVE_CAP_UDUI) {
436459
if ((telemetry_type == SNDK_TELEMETRY_TYPE_HOST) ||
437460
(telemetry_type == SNDK_TELEMETRY_TYPE_CONTROLLER)) {
438-
/* Set the default DA to 3 if not specified */
439-
if (!telemetry_data_area)
440-
telemetry_data_area = 3;
461+
if (sndk_get_default_telemetry_da(hdl, &telemetry_data_area)) {
462+
fprintf(stderr, "%s: Error determining default telemetry data area\n",
463+
__func__);
464+
return -EINVAL;
465+
}
441466

442467
ret = sndk_do_cap_telemetry_log(ctx, hdl, f, xfer_size,
443468
telemetry_type, telemetry_data_area);

plugins/sandisk/sandisk-nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if !defined(SANDISK_NVME) || defined(CMD_HEADER_MULTI_READ)
66
#define SANDISK_NVME
77

8-
#define SANDISK_PLUGIN_VERSION "3.0.8"
8+
#define SANDISK_PLUGIN_VERSION "3.1.0"
99
#include "cmd.h"
1010

1111
PLUGIN(NAME("sndk", "Sandisk vendor specific extensions", SANDISK_PLUGIN_VERSION),

plugins/wdc/wdc-nvme.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,6 +4268,27 @@ static int dump_internal_logs(struct nvme_transport_handle *hdl, const char *dir
42684268
return err;
42694269
}
42704270

4271+
static int wdc_get_default_telemetry_da(struct nvme_transport_handle *hdl,
4272+
int *data_area)
4273+
{
4274+
struct nvme_id_ctrl ctrl;
4275+
int err;
4276+
4277+
memset(&ctrl, 0, sizeof(struct nvme_id_ctrl));
4278+
err = nvme_identify_ctrl(hdl, &ctrl);
4279+
if (err) {
4280+
fprintf(stderr, "ERROR: WDC: nvme_identify_ctrl() failed 0x%x\n", err);
4281+
return err;
4282+
}
4283+
4284+
if (ctrl.lpa & 0x40)
4285+
*data_area = 4;
4286+
else
4287+
*data_area = 3;
4288+
4289+
return 0;
4290+
}
4291+
42714292
static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd,
42724293
struct plugin *plugin)
42734294
{
@@ -4451,9 +4472,11 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd,
44514472
capabilities = wdc_get_drive_capabilities(ctx, hdl);
44524473
if ((capabilities & WDC_DRIVE_CAP_INTERNAL_LOG) == WDC_DRIVE_CAP_INTERNAL_LOG) {
44534474
if (!wdc_is_sn861(device_id)) {
4454-
/* Set the default DA to 3 if not specified */
4455-
if (!telemetry_data_area)
4456-
telemetry_data_area = 3;
4475+
if (wdc_get_default_telemetry_da(hdl, &telemetry_data_area)) {
4476+
fprintf(stderr, "%s: Error determining default telemetry data area\n",
4477+
__func__);
4478+
return -EINVAL;
4479+
}
44574480

44584481
ret = wdc_do_cap_diag(ctx, hdl, f, xfer_size,
44594482
telemetry_type, telemetry_data_area);
@@ -4491,8 +4514,11 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd,
44914514
if ((capabilities & WDC_DRIVE_CAP_DUI) == WDC_DRIVE_CAP_DUI) {
44924515
if ((telemetry_type == WDC_TELEMETRY_TYPE_HOST) ||
44934516
(telemetry_type == WDC_TELEMETRY_TYPE_CONTROLLER)) {
4494-
if (!telemetry_data_area)
4495-
telemetry_data_area = 3; /* Set the default DA to 3 if not specified */
4517+
if (wdc_get_default_telemetry_da(hdl, &telemetry_data_area)) {
4518+
fprintf(stderr, "%s: Error determining default telemetry data area\n",
4519+
__func__);
4520+
return -EINVAL;
4521+
}
44964522
/* Get the desired telemetry log page */
44974523
ret = wdc_do_cap_telemetry_log(ctx, hdl, f, xfer_size,
44984524
telemetry_type, telemetry_data_area);
@@ -4514,9 +4540,11 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *acmd,
45144540
if ((capabilities & WDC_DRIVE_CAP_DUI_DATA) == WDC_DRIVE_CAP_DUI_DATA) {
45154541
if ((telemetry_type == WDC_TELEMETRY_TYPE_HOST) ||
45164542
(telemetry_type == WDC_TELEMETRY_TYPE_CONTROLLER)) {
4517-
if (!telemetry_data_area)
4518-
telemetry_data_area = 3; /* Set the default DA to 3 if not specified */
4519-
/* Get the desired telemetry log page */
4543+
if (wdc_get_default_telemetry_da(hdl, &telemetry_data_area)) {
4544+
fprintf(stderr, "%s: Error determining default telemetry data area\n",
4545+
__func__);
4546+
return -EINVAL;
4547+
}
45204548
ret = wdc_do_cap_telemetry_log(ctx, hdl, f, xfer_size,
45214549
telemetry_type, telemetry_data_area);
45224550
goto out;

plugins/wdc/wdc-nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ)
66
#define WDC_NVME
77

8-
#define WDC_PLUGIN_VERSION "2.14.7"
8+
#define WDC_PLUGIN_VERSION "2.15.0"
99
#include "cmd.h"
1010

1111
PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION),

0 commit comments

Comments
 (0)