Skip to content

Commit

Permalink
print: id-ctrl print updated based on NVMe v2.1
Browse files Browse the repository at this point in the history
new fields, missing fields print added

Signed-off-by: Steven Seungcheol Lee <[email protected]>
  • Loading branch information
sc108-lee authored and igaw committed Dec 10, 2024
1 parent c07ccbe commit d035094
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nvme-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,15 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
obj_add_uint(r, "oaes", le32_to_cpu(ctrl->oaes));
obj_add_uint(r, "ctratt", le32_to_cpu(ctrl->ctratt));
obj_add_int(r, "rrls", le16_to_cpu(ctrl->rrls));
obj_add_int(r, "bpcap", ctrl->bpcap);
obj_add_uint(r, "nssl", le32_to_cpu(ctrl->nssl));
obj_add_int(r, "plsi", ctrl->plsi);
obj_add_int(r, "cntrltype", ctrl->cntrltype);
obj_add_str(r, "fguid", util_uuid_to_string(ctrl->fguid));
obj_add_int(r, "crdt1", le16_to_cpu(ctrl->crdt1));
obj_add_int(r, "crdt2", le16_to_cpu(ctrl->crdt2));
obj_add_int(r, "crdt3", le16_to_cpu(ctrl->crdt3));
obj_add_int(r, "crcap", ctrl->crcap);
obj_add_int(r, "nvmsr", ctrl->nvmsr);
obj_add_int(r, "vwci", ctrl->vwci);
obj_add_int(r, "mec", ctrl->mec);
Expand Down Expand Up @@ -393,8 +397,11 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
obj_add_uint(r, "nanagrpid", le32_to_cpu(ctrl->nanagrpid));
obj_add_uint(r, "pels", le32_to_cpu(ctrl->pels));
obj_add_int(r, "domainid", le16_to_cpu(ctrl->domainid));
obj_add_int(r, "kpioc", ctrl->kpioc);
obj_add_int(r, "mptfawr", le16_to_cpu(ctrl->mptfawr));
obj_add_uint128(r, "megcap", megcap);
obj_add_int(r, "tmpthha", ctrl->tmpthha);
obj_add_int(r, "cqt", le16_to_cpu(ctrl->cqt));
obj_add_int(r, "sqes", ctrl->sqes);
obj_add_int(r, "cqes", ctrl->cqes);
obj_add_int(r, "maxcmd", le16_to_cpu(ctrl->maxcmd));
Expand All @@ -414,6 +421,18 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
obj_add_uint128(r, "maxdna", maxdna);
obj_add_uint(r, "maxcna", le32_to_cpu(ctrl->maxcna));
obj_add_uint(r, "oaqd", le32_to_cpu(ctrl->oaqd));
obj_add_int(r, "rhiri", ctrl->rhiri);
obj_add_int(r, "hirt", ctrl->hirt);
obj_add_int(r, "cmmrtd", le16_to_cpu(ctrl->cmmrtd));
obj_add_int(r, "nmmrtd", le16_to_cpu(ctrl->nmmrtd));
obj_add_int(r, "minmrtg", ctrl->minmrtg);
obj_add_int(r, "maxmrtg", ctrl->maxmrtg);
obj_add_int(r, "trattr", ctrl->trattr);
obj_add_int(r, "mcudmq", le16_to_cpu(ctrl->mcudmq));
obj_add_int(r, "mnsudmq", le16_to_cpu(ctrl->mnsudmq));
obj_add_int(r, "mcmr", le16_to_cpu(ctrl->mcmr));
obj_add_int(r, "nmcmr", le16_to_cpu(ctrl->nmcmr));
obj_add_int(r, "mcdqpc", le16_to_cpu(ctrl->mcdqpc));

if (strlen(subnqn))
obj_add_str(r, "subnqn", subnqn);
Expand Down
116 changes: 116 additions & 0 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,59 @@ static void stdout_id_ctrl_ctratt(__le32 ctrl_ctratt)
printf("\n");
}

static void stdout_id_ctrl_bpcap(__u8 ctrl_bpcap)
{
__u8 rsvd3 = (ctrl_bpcap >> 3);
__u8 sfbpwps = NVME_GET(ctrl_bpcap, CTRL_BACAP_SFBPWPS);
__u8 rpmbbpwps = NVME_GET(ctrl_bpcap, CTRL_BACAP_RPMBBPWPS);
static const char * const rpmbbpwps_def[] = {
"Support Not Specified",
"Not Supported",
"Supported"
};

if (rsvd3)
printf(" [7:3] : %#x\tReserved\n", rsvd3);

printf(" [2:2] : %#x\tSet Features Boot Partition Write Protection %sSupported\n",
sfbpwps, sfbpwps ? "" : "Not ");
printf(" [1:0] : %#x\tRPMB Boot Partition Write Protection %s\n",
rpmbbpwps, rpmbbpwps_def[rpmbbpwps]);
printf("\n");
}

static void stdout_id_ctrl_plsi(__u8 ctrl_plsi)
{
__u8 rsvd2 = (ctrl_plsi >> 2);
__u8 plsfq = NVME_GET(ctrl_plsi, CTRL_PLSI_PLSFQ);
__u8 plsepf = NVME_GET(ctrl_plsi, CTRL_PLSI_PLSEPF);

if (rsvd2)
printf(" [7:2] : %#x\tReserved\n", rsvd2);

printf(" [1:1] : %#x\tPower Loss Signaling with Forced Quiescence %sSupported\n",
plsfq, plsfq ? "" : "Not ");
printf(" [0:0] : %#x\tPower Loss Signaling with Emergency Power Fail %sSupported\n",
plsepf, plsepf ? "" : "Not ");
printf("\n");
}

static void stdout_id_ctrl_crcap(__u8 ctrl_crcap)
{
__u8 rsvd2 = (ctrl_crcap >> 2);
__u8 rgidc = NVME_GET(ctrl_crcap, CTRL_CRCAP_RGIDC);
__u8 rrsup = NVME_GET(ctrl_crcap, CTRL_CRCAP_RRSUP);

if (rsvd2)
printf(" [7:2] : %#x\tReserved\n", rsvd2);

printf(" [1:1] : %#x\tRGRPID %s while the namespace is attached to any controller.\n",
rgidc, rgidc ? "does not change" : "may change");
printf(" [0:0] : %#x\tReachability Reporting %sSupported\n",
rrsup, rrsup ? "" : "Not ");
printf("\n");
}

static void stdout_id_ctrl_cntrltype(__u8 cntrltype)
{
__u8 rsvd = (cntrltype & 0xFC) >> 2;
Expand Down Expand Up @@ -2143,6 +2196,22 @@ static void stdout_id_ctrl_anacap(__u8 anacap)
printf("\n");
}

static void stdout_id_ctrl_kpioc(__u8 ctrl_kpioc)
{
__u8 rsvd2 = (ctrl_kpioc >> 2);
__u8 kpiosc = NVME_GET(ctrl_kpioc, CTRL_KPIOC_KPIOSC);
__u8 kpios = NVME_GET(ctrl_kpioc, CTRL_KPIOC_KPIOS);

if (rsvd2)
printf(" [7:2] : %#x\tReserved\n", rsvd2);

printf(" [1:1] : %#x\tKey Per I/O capability %s to all namespaces\n",
kpiosc, kpiosc ? "applies" : "Not apply");
printf(" [0:0] : %#x\tKey Per I/O capability %sSupported\n",
kpios, kpios ? "" : "Not ");
printf("\n");
}

static void stdout_id_ctrl_tmpthha(__u8 tmpthha)
{
__u8 rsvd3 = (tmpthha & 0xf8) >> 3;
Expand Down Expand Up @@ -2381,6 +2450,24 @@ static void stdout_id_ctrl_sgls(__le32 ctrl_sgls)
printf("\n");
}

static void stdout_id_ctrl_trattr(__u8 ctrl_trattr)
{
__u8 rsvd3 = (ctrl_trattr >> 3);
__u8 mrtll = NVME_GET(ctrl_trattr, CTRL_TRATTR_MRTLL);
__u8 tudcs = NVME_GET(ctrl_trattr, CTRL_TRATTR_TUDCS);
__u8 thmcs = NVME_GET(ctrl_trattr, CTRL_TRATTR_THMCS);

if (rsvd3)
printf(" [7:3] : %#x\tReserved\n", rsvd3);

printf(" [2:2] : %#x\tMemory Range Tracking Length Limit\n", mrtll);
printf(" [1:1] : %#x\tTracking User Data Changes %sSupported\n",
tudcs, tudcs ? "" : "Not ");
printf(" [0:0] : %#x\tTrack Host Memory Changes %sSupported\n",
thmcs, thmcs ? "" : "Not ");
printf("\n");
}

static void stdout_id_ctrl_fcatt(__u8 fcatt)
{
__u8 rsvd = (fcatt & 0xFE) >> 1;
Expand Down Expand Up @@ -2945,13 +3032,23 @@ static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl,
if (human)
stdout_id_ctrl_ctratt(ctrl->ctratt);
printf("rrls : %#x\n", le16_to_cpu(ctrl->rrls));
printf("bpcap : %#x\n", le16_to_cpu(ctrl->bpcap));
if (human)
stdout_id_ctrl_bpcap(ctrl->bpcap);
printf("nssl : %#x\n", le32_to_cpu(ctrl->nssl));
printf("plsi : %u\n", ctrl->plsi);
if (human)
stdout_id_ctrl_plsi(ctrl->plsi);
printf("cntrltype : %d\n", ctrl->cntrltype);
if (human)
stdout_id_ctrl_cntrltype(ctrl->cntrltype);
printf("fguid : %s\n", util_uuid_to_string(ctrl->fguid));
printf("crdt1 : %u\n", le16_to_cpu(ctrl->crdt1));
printf("crdt2 : %u\n", le16_to_cpu(ctrl->crdt2));
printf("crdt3 : %u\n", le16_to_cpu(ctrl->crdt3));
printf("crcap : %u\n", ctrl->crcap);
if (human)
stdout_id_ctrl_crcap(ctrl->crcap);
printf("nvmsr : %u\n", ctrl->nvmsr);
if (human)
stdout_id_ctrl_nvmsr(ctrl->nvmsr);
Expand Down Expand Up @@ -3033,11 +3130,16 @@ static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl,
printf("nanagrpid : %u\n", le32_to_cpu(ctrl->nanagrpid));
printf("pels : %u\n", le32_to_cpu(ctrl->pels));
printf("domainid : %d\n", le16_to_cpu(ctrl->domainid));
printf("kpioc : %u\n", ctrl->kpioc);
if (human)
stdout_id_ctrl_kpioc(ctrl->kpioc);
printf("mptfawr : %d\n", le16_to_cpu(ctrl->mptfawr));
printf("megcap : %s\n",
uint128_t_to_l10n_string(le128_to_cpu(ctrl->megcap)));
printf("tmpthha : %#x\n", ctrl->tmpthha);
if (human)
stdout_id_ctrl_tmpthha(ctrl->tmpthha);
printf("cqt : %d\n", le16_to_cpu(ctrl->cqt));
printf("sqes : %#x\n", ctrl->sqes);
if (human)
stdout_id_ctrl_sqes(ctrl->sqes);
Expand Down Expand Up @@ -3078,6 +3180,20 @@ static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl,
uint128_t_to_l10n_string(le128_to_cpu(ctrl->maxdna)));
printf("maxcna : %u\n", le32_to_cpu(ctrl->maxcna));
printf("oaqd : %u\n", le32_to_cpu(ctrl->oaqd));
printf("rhiri : %d\n", ctrl->rhiri);
printf("hirt : %d\n", ctrl->hirt);
printf("cmmrtd : %d\n", le16_to_cpu(ctrl->cmmrtd));
printf("nmmrtd : %d\n", le16_to_cpu(ctrl->nmmrtd));
printf("minmrtg : %d\n", ctrl->minmrtg);
printf("maxmrtg : %d\n", ctrl->maxmrtg);
printf("trattr : %d\n", ctrl->trattr);
if (human)
stdout_id_ctrl_trattr(ctrl->trattr);
printf("mcudmq : %d\n", le16_to_cpu(ctrl->mcudmq));
printf("mnsudmq : %d\n", le16_to_cpu(ctrl->mnsudmq));
printf("mcmr : %d\n", le16_to_cpu(ctrl->mcmr));
printf("nmcmr : %d\n", le16_to_cpu(ctrl->nmcmr));
printf("mcdqpc : %d\n", le16_to_cpu(ctrl->mcdqpc));
printf("subnqn : %-.*s\n", (int)sizeof(ctrl->subnqn), ctrl->subnqn);
printf("ioccsz : %u\n", le32_to_cpu(ctrl->ioccsz));
printf("iorcsz : %u\n", le32_to_cpu(ctrl->iorcsz));
Expand Down

0 comments on commit d035094

Please sign in to comment.