Skip to content

Commit 8a9d01d

Browse files
jeff-lien-sndkigaw
authored andcommitted
id-ctrl: Add NVMe 2.3 id controller fields
Added the following new fields to the id-ctrl output: cdpa, mup, ipmsr, msmt, and ccrl. Signed-off-by: jeff-lien-sndk <[email protected]> Reviewed-by: brandon-paupore-sndk <[email protected]>
1 parent 6c8e658 commit 8a9d01d

4 files changed

Lines changed: 122 additions & 14 deletions

File tree

libnvme/src/nvme/types.h

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,11 +1373,24 @@ struct nvme_id_psd {
13731373
* of a single Endurance Group.
13741374
* @tmpthha: Temperature Threshold Hysteresis Attributes
13751375
* @rsvd385: Reserved
1376-
* @cqt: Command Quiesce Time (CQT). his field indicates the expected
1376+
* @cqt: Command Quiesce Time (CQT). This field indicates the expected
13771377
* worst-case time in 1 millisecond units for the controller to
13781378
* quiesce all outstanding commands after a Keep Alive Timeout or
13791379
* other communication loss.
1380-
* @rsvd388: Reserved
1380+
* @cdpa: Configurable Device Personality Attributes: This field
1381+
* indicates the Configurable Device Personality feature attributes
1382+
* the controller supports.
1383+
* @mup: Maximum Unlimited Power: This field specifies the maximum
1384+
* power for power state 0 that results from removal of a power
1385+
* limit (i.e., the maximum power is not limited).
1386+
* @ipmsr: Interval Power Measurement Sample Rate: This field
1387+
* indicates the maximum interval between power measurement
1388+
* samples used to collect interval power measurements.
1389+
* @msmt: Maximum Stop Measurement Time: This field indicates the
1390+
* maximum stop measurement time allowed to be specified in the
1391+
* SMT field for a Set Features command specifying the Power
1392+
* Measurement feature.
1393+
* @rsvd396: Reserved
13811394
* @sqes: Submission Queue Entry Size, see &enum nvme_id_ctrl_sqes.
13821395
* @cqes: Completion Queue Entry Size, see &enum nvme_id_ctrl_cqes.
13831396
* @maxcmd: Maximum Outstanding Commands indicates the maximum number of
@@ -1485,7 +1498,11 @@ struct nvme_id_psd {
14851498
* @dctype: Discovery Controller Type (DCTYPE). This field indicates what
14861499
* type of Discovery controller the controller is (see enum
14871500
* nvme_id_ctrl_dctype)
1488-
* @rsvd1807: Reserved
1501+
* @ccrl: Cross-Controller Reset Limit: This field indicates the limit
1502+
* on the number of simultaneous in-progress Cross-Controller Reset
1503+
* operations this controller is able to cause to be initiated that
1504+
* are supported.
1505+
* @rsvd1808: Reserved
14891506
* @psd: Power State Descriptors, see &struct nvme_id_psd.
14901507
* @vs: Vendor Specific
14911508
*/
@@ -1564,7 +1581,11 @@ struct nvme_id_ctrl {
15641581
__u8 tmpthha;
15651582
__u8 rsvd385;
15661583
__le16 cqt;
1567-
__u8 rsvd388[124];
1584+
__le16 cdpa;
1585+
__le16 mup;
1586+
__le16 ipmsr;
1587+
__le16 msmt;
1588+
__u8 rsvd396[116];
15681589
__u8 sqes;
15691590
__u8 cqes;
15701591
__le16 maxcmd;
@@ -1609,7 +1630,8 @@ struct nvme_id_ctrl {
16091630
__u8 msdbd;
16101631
__le16 ofcs;
16111632
__u8 dctype;
1612-
__u8 rsvd1807[241];
1633+
__u8 ccrl;
1634+
__u8 rsvd1808[240];
16131635

16141636
struct nvme_id_psd psd[32];
16151637
__u8 vs[1024];
@@ -2278,6 +2300,33 @@ enum nvme_id_ctrl_kpioc {
22782300
NVME_CTRL_KPIOC_KPIOSC_MASK = 0x1,
22792301
};
22802302

2303+
/**
2304+
* enum nvme_id_ctrl_cdpa - Configurable Device Personality Attributes
2305+
* @NVME_CTRL_CDPA_HMAC_SHA_384: If set, then the controller supports
2306+
* the HMAC-SHA-384 standard.
2307+
*/
2308+
enum nvme_id_ctrl_cdpa {
2309+
NVME_CTRL_CDPA_HMAC_SHA_384 = 1 << 0,
2310+
};
2311+
2312+
/**
2313+
* enum nvme_id_ctrl_ipmsr - Interval Power Measurement Sample Rate
2314+
* @NVME_CTRL_IPMSR_SRS_SHIFT: Shift amount to get the Sample Rate
2315+
* Scale from the &struct nvme_id_ctrl.ipmsr field.
2316+
* @NVME_CTRL_IPMSR_SRV_SHIFT: Shift amount to get the Sample Rate
2317+
* Value from the &struct nvme_id_ctrl.ipmsr field.
2318+
* @NVME_CTRL_IPMSR_SRS_MASK: Mask to get the Sample Rate Scale
2319+
* from the &struct nvme_id_ctrl.ipmsr field.
2320+
* @NVME_CTRL_IPMSR_SRV_MASK: Mask to get the Sample Rate Value
2321+
* from the &struct nvme_id_ctrl.ipmsr field.
2322+
*/
2323+
enum nvme_id_ctrl_ipmsr {
2324+
NVME_CTRL_IPMSR_SRS_SHIFT = 8,
2325+
NVME_CTRL_IPMSR_SRV_SHIFT = 0,
2326+
NVME_CTRL_IPMSR_SRS_MASK = 0x00FF,
2327+
NVME_CTRL_IPMSR_SRV_MASK = 0x00FF,
2328+
};
2329+
22812330
/**
22822331
* enum nvme_id_ctrl_sqes - Defines the required and maximum Submission Queue
22832332
* entry size when using the NVM Command Set.

nvme-print-json.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
432432
obj_add_uint128(r, "megcap", megcap);
433433
obj_add_int(r, "tmpthha", ctrl->tmpthha);
434434
obj_add_int(r, "cqt", le16_to_cpu(ctrl->cqt));
435+
obj_add_int(r, "cdpa", le16_to_cpu(ctrl->cdpa));
436+
obj_add_int(r, "mup", le16_to_cpu(ctrl->mup));
437+
obj_add_int(r, "ipmsr", le16_to_cpu(ctrl->ipmsr));
438+
obj_add_int(r, "msmt", le16_to_cpu(ctrl->msmt));
435439
obj_add_int(r, "sqes", ctrl->sqes);
436440
obj_add_int(r, "cqes", ctrl->cqes);
437441
obj_add_int(r, "maxcmd", le16_to_cpu(ctrl->maxcmd));
@@ -473,6 +477,8 @@ void json_nvme_id_ctrl(struct nvme_id_ctrl *ctrl,
473477
obj_add_int(r, "fcatt", ctrl->fcatt);
474478
obj_add_int(r, "msdbd", ctrl->msdbd);
475479
obj_add_int(r, "ofcs", le16_to_cpu(ctrl->ofcs));
480+
obj_add_int(r, "dctype", ctrl->dctype);
481+
obj_add_int(r, "ccrl", ctrl->ccrl);
476482

477483
obj_add_array(r, "psds", psds);
478484

nvme-print-stdout.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,6 +2421,32 @@ static void stdout_id_ctrl_tmpthha(__u8 tmpthha)
24212421
printf("\n");
24222422
}
24232423

2424+
static void stdout_id_ctrl_cdpa(__le16 ctrl_cdpa)
2425+
{
2426+
__u16 cdpa = le16_to_cpu(ctrl_cdpa);
2427+
__u16 rsvd1 = (cdpa >> 1);
2428+
bool hmac_sha_384 = !!(cdpa & NVME_CTRL_CDPA_HMAC_SHA_384);
2429+
2430+
if (rsvd1)
2431+
printf(" [15:1] : %#x\tReserved\n", rsvd1);
2432+
printf(" [0:0] : %#x\tHMAC-SHA-384 %sSupported\n",
2433+
hmac_sha_384, hmac_sha_384 ? "" : "Not ");
2434+
2435+
printf("\n");
2436+
}
2437+
2438+
static void stdout_id_ctrl_ipmsr(__le16 ctrl_ipmsr)
2439+
{
2440+
__u16 ipmsr = le16_to_cpu(ctrl_ipmsr);
2441+
__u16 srs = NVME_GET(ipmsr, CTRL_IPMSR_SRS);
2442+
__u16 srv = NVME_GET(ipmsr, CTRL_IPMSR_SRV);
2443+
2444+
printf(" [15:8] : %#x\tSample Rate Scale\n", srs);
2445+
printf(" [7:0] : %#x\tSample Rate Value\n", srv);
2446+
2447+
printf("\n");
2448+
}
2449+
24242450
static void stdout_id_ctrl_sqes(__u8 sqes)
24252451
{
24262452
__u8 msqes = (sqes & 0xF0) >> 4;
@@ -2690,6 +2716,26 @@ static void stdout_id_ctrl_ofcs(__le16 ofcs)
26902716

26912717
}
26922718

2719+
static void stdout_id_ctrl_dctype(__u8 dctype)
2720+
{
2721+
__u8 rsvd = (dctype & 0xFC) >> 2;
2722+
__u8 dctype_val = dctype & 0x3;
2723+
char *dctype_str;
2724+
2725+
if (rsvd)
2726+
printf(" [7:3] : %#x\tReserved\n", rsvd);
2727+
if (dctype_val == NVME_CTRL_DCTYPE_CDC)
2728+
dctype_str = "CDC";
2729+
else if (dctype_val == NVME_CTRL_DCTYPE_DDC)
2730+
dctype_str = "DDC";
2731+
else
2732+
dctype_str = "not reported";
2733+
2734+
printf(" [0:2] : %#x\tDiscovery Controller Type: %s\n",
2735+
dctype_val, dctype_str);
2736+
printf("\n");
2737+
}
2738+
26932739
static void stdout_id_ns_size(uint64_t nsze, uint64_t ncap, uint64_t nuse)
26942740
{
26952741
printf("nsze : %#"PRIx64"\tTotal size in logical blocks\n",
@@ -3425,6 +3471,14 @@ static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl,
34253471
if (human)
34263472
stdout_id_ctrl_tmpthha(ctrl->tmpthha);
34273473
printf("cqt : %d\n", le16_to_cpu(ctrl->cqt));
3474+
printf("cdpa : %d\n", le16_to_cpu(ctrl->cdpa));
3475+
if (human)
3476+
stdout_id_ctrl_cdpa(ctrl->cdpa);
3477+
printf("mup : %d\n", le16_to_cpu(ctrl->mup));
3478+
printf("ipmsr : %#x\n", le16_to_cpu(ctrl->ipmsr));
3479+
if (human)
3480+
stdout_id_ctrl_ipmsr(ctrl->ipmsr);
3481+
printf("msmt : %#x\n", le16_to_cpu(ctrl->msmt));
34283482
printf("sqes : %#x\n", ctrl->sqes);
34293483
if (human)
34303484
stdout_id_ctrl_sqes(ctrl->sqes);
@@ -3490,6 +3544,10 @@ static void stdout_id_ctrl(struct nvme_id_ctrl *ctrl,
34903544
printf("ofcs : %d\n", le16_to_cpu(ctrl->ofcs));
34913545
if (human)
34923546
stdout_id_ctrl_ofcs(ctrl->ofcs);
3547+
printf("dctype : %d\n", ctrl->dctype);
3548+
if (human)
3549+
stdout_id_ctrl_dctype(ctrl->dctype);
3550+
printf("ccrl : %d\n", ctrl->ccrl);
34933551

34943552
stdout_id_ctrl_power(ctrl);
34953553
if (vendor_show)

plugins/micron/micron-nvme.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4416,27 +4416,22 @@ static int micron_health_info(int argc, char **argv, struct command *acmd,
44164416

44174417
/*
44184418
* Identify Controller field offsets for Micron-specific fields
4419-
* IPMSR: Interval Power Measurement Sample Rate (2 bytes)
4420-
* MSMT: Maximum Stop Measurement Time (2 bytes)
44214419
* PMS: Power Measurement Support - bit 21 of CTRATT
44224420
*/
4423-
#define ID_CTRL_RSVD388_OFFSET 388
4424-
#define ID_CTRL_IPMSR_OFFSET 392
4425-
#define ID_CTRL_MSMT_OFFSET 394
44264421
#define CTRATT_PMS_BIT 21
44274422

44284423
static inline __u16 get_id_ctrl_ipmsr(struct nvme_id_ctrl *ctrl)
44294424
{
4430-
__u8 *p = &ctrl->rsvd388[ID_CTRL_IPMSR_OFFSET - ID_CTRL_RSVD388_OFFSET];
4425+
__le16 *p = (__le16 *)&ctrl->ipmsr;
44314426

4432-
return le16_to_cpu(*(__le16 *)p);
4427+
return le16_to_cpu(*p);
44334428
}
44344429

44354430
static inline __u16 get_id_ctrl_msmt(struct nvme_id_ctrl *ctrl)
44364431
{
4437-
__u8 *p = &ctrl->rsvd388[ID_CTRL_MSMT_OFFSET - ID_CTRL_RSVD388_OFFSET];
4432+
__le16 *p = (__le16 *)&ctrl->msmt;
44384433

4439-
return le16_to_cpu(*(__le16 *)p);
4434+
return le16_to_cpu(*p);
44404435
}
44414436

44424437
static inline bool get_id_ctrl_pms(struct nvme_id_ctrl *ctrl)

0 commit comments

Comments
 (0)