Skip to content

Commit

Permalink
nvme: Add show-regs and get-property commands NSSD print outputs
Browse files Browse the repository at this point in the history
Output the NVM Subsystem Shutdown property.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t authored and igaw committed Mar 5, 2024
1 parent c90d3d7 commit 59ae541
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
19 changes: 19 additions & 0 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,11 @@ static void json_registers_nssr(__u32 nssr, struct json_object *r)
obj_add_uint(r, "NVM Subsystem Reset Control (NSSRC)", nssr);
}

static void json_registers_nssd(__u32 nssd, struct json_object *r)
{
obj_add_uint_nx(r, "NVM Subsystem Shutdown Control (NSSC)", nssd);
}

static void json_registers_crto(__u32 crto, struct json_object *r)
{
obj_add_uint_x(r, "crto", crto);
Expand Down Expand Up @@ -1254,6 +1259,9 @@ static void json_single_property_human(int offset, uint64_t value64, struct json
case NVME_REG_NSSR:
json_registers_nssr(value32, r);
break;
case NVME_REG_NSSD:
json_registers_nssd(value32, r);
break;
case NVME_REG_CRTO:
json_registers_crto(value32, r);
break;
Expand Down Expand Up @@ -2482,6 +2490,16 @@ static void json_ctrl_registers_nssr(void *bar, struct json_object *r)
obj_add_int(r, "nssr", nssr);
}

static void json_ctrl_registers_nssd(void *bar, struct json_object *r)
{
uint32_t nssd = mmio_read32(bar + NVME_REG_NSSD);

if (human())
json_registers_nssd(nssd, obj_create_array_obj(r, "nssd"));
else
obj_add_int(r, "nssd", nssd);
}

static void json_ctrl_registers_crto(void *bar, struct json_object *r)
{
uint32_t crto = mmio_read32(bar + NVME_REG_CRTO);
Expand Down Expand Up @@ -2673,6 +2691,7 @@ static void json_ctrl_registers(void *bar, bool fabrics)
json_ctrl_registers_cc(bar, r);
json_ctrl_registers_csts(bar, r);
json_ctrl_registers_nssr(bar, r);
json_ctrl_registers_nssd(bar, r);
json_ctrl_registers_crto(bar, r);
json_ctrl_registers_aqa(bar, r);
json_ctrl_registers_asq(bar, r);
Expand Down
9 changes: 9 additions & 0 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,11 @@ static void stdout_registers_csts(__u32 csts)

}

static void stdout_registers_nssd(__u32 nssd)
{
printf("\tNVM Subsystem Shutdown Control (NSSC): %#x\n\n", nssd);
}

static void stdout_registers_crto(__u32 crto)
{
printf("\tCRIMT : %d secs\n", NVME_CRTO_CRIMT(crto) / 2);
Expand Down Expand Up @@ -1621,6 +1626,10 @@ static void stdout_single_property(int offset, uint64_t value64)
printf("nssr : %x\n", value32);
printf("\tNVM Subsystem Reset Control (NSSRC): %u\n\n", value32);
break;
case NVME_REG_NSSD:
printf("nssd : %x\n", value32);
stdout_registers_nssd(value32);
break;
case NVME_REG_CRTO:
printf("crto : %x\n", value32);
stdout_registers_crto(value32);
Expand Down
2 changes: 1 addition & 1 deletion nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -5380,7 +5380,7 @@ static int get_property(int argc, char **argv, struct command *cmd, struct plugi
{
const char *desc = "Reads and shows the defined NVMe controller property\n"
"for NVMe over Fabric. Property offset must be one of:\n"
"CAP=0x0, VS=0x8, CC=0x14, CSTS=0x1c, NSSR=0x20";
"CAP=0x0, VS=0x8, CC=0x14, CSTS=0x1c, NSSR=0x20, NSSD=0x64, CRTO=0x68";
const char *offset = "offset of the requested property";
const char *human_readable = "show property in readable format";

Expand Down

0 comments on commit 59ae541

Please sign in to comment.