@@ -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+
42714292static 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 ;
0 commit comments