Skip to content

Commit a67f3e4

Browse files
ikegami-tigaw
authored andcommitted
nvme-print-stdout: fix get feature 128-bit host id print
Since implemented as always 64-bit host id print. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 212b536 commit a67f3e4

3 files changed

Lines changed: 37 additions & 7 deletions

File tree

libnvme/src/nvme/types.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9051,6 +9051,8 @@ enum nvme_features_id {
90519051
* @NVME_FEAT_FDP_INDEX_MASK:
90529052
* @NVME_FEAT_FDP_EVENTS_ENABLE_SHIFT:
90539053
* @NVME_FEAT_FDP_EVENTS_ENABLE_MASK:
9054+
* @NVME_FEAT_HOST_ID_EXHID_SHIFT:
9055+
* @NVME_FEAT_HOST_ID_EXHID_MASK:
90549056
* @NVME_FEAT_BPWPC_BP0WPS_SHIFT:
90559057
* @NVME_FEAT_BPWPC_BP0WPS_MASK:
90569058
* @NVME_FEAT_BPWPC_BP1WPS_SHIFT:
@@ -9227,6 +9229,8 @@ enum nvme_feat {
92279229
NVME_FEAT_FDP_INDEX_MASK = 0xf,
92289230
NVME_FEAT_FDP_EVENTS_ENABLE_SHIFT = 0,
92299231
NVME_FEAT_FDP_EVENTS_ENABLE_MASK = 0x1,
9232+
NVME_FEAT_HOST_ID_EXHID_SHIFT = 0,
9233+
NVME_FEAT_HOST_ID_EXHID_MASK = 0x1,
92309234
NVME_FEAT_BPWPC_BP0WPS_SHIFT = 0,
92319235
NVME_FEAT_BPWPC_BP0WPS_MASK = 0x7,
92329236
NVME_FEAT_BPWPC_BP1WPS_SHIFT = 3,
@@ -10758,6 +10762,14 @@ nvme_feature_decode_perf_characteristics(__u32 value, __u8 *attri, bool *rvspa)
1075810762
*rvspa = NVME_FEAT_PERFC_RVSPA(value);
1075910763
}
1076010764

10765+
#define NVME_FEAT_HOST_ID_EXHID(v) NVME_GET(v, FEAT_HOST_ID_EXHID)
10766+
10767+
static inline void
10768+
nvme_feature_decode_host_id(__u32 value, bool *exhid)
10769+
{
10770+
*exhid = NVME_FEAT_HOST_ID_EXHID(value);
10771+
}
10772+
1076110773
#define NVME_FEAT_SPM_PBSLC(v) NVME_GET(v, FEAT_SPM_PBSLC)
1076210774

1076310775
static inline void

nvme-print-stdout.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5133,6 +5133,29 @@ static void stdout_host_metadata(enum nvme_features_id fid,
51335133
}
51345134
}
51355135

5136+
static void stdout_feat_host_id(unsigned int result, unsigned char *hostid)
5137+
{
5138+
uint64_t ull;
5139+
bool exhid;
5140+
5141+
if (!hostid)
5142+
return;
5143+
5144+
nvme_feature_decode_host_id(result, &exhid);
5145+
5146+
if (exhid) {
5147+
printf("\tHost Identifier (HOSTID): %s\n",
5148+
uint128_t_to_l10n_string(le128_to_cpu(hostid)));
5149+
return;
5150+
}
5151+
5152+
ull = hostid[7]; ull <<= 8; ull |= hostid[6]; ull <<= 8;
5153+
ull |= hostid[5]; ull <<= 8; ull |= hostid[4]; ull <<= 8;
5154+
ull |= hostid[3]; ull <<= 8; ull |= hostid[2]; ull <<= 8;
5155+
ull |= hostid[1]; ull <<= 8; ull |= hostid[0];
5156+
printf("\tHost Identifier (HOSTID): %" PRIu64 "\n", ull);
5157+
}
5158+
51365159
static void stdout_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
51375160
{
51385161
printf("get-feature:%#0*x (%s), %s value:%#0*x\n", fid ? 4 : 2, fid,
@@ -5146,7 +5169,6 @@ static void stdout_feature_show_fields(enum nvme_features_id fid,
51465169
const char *async = "Send async event";
51475170
const char *no_async = "Do not send async event";
51485171
__u8 field;
5149-
uint64_t ull;
51505172

51515173
switch (fid) {
51525174
case NVME_FEAT_FID_ARBITRATION:
@@ -5354,12 +5376,7 @@ static void stdout_feature_show_fields(enum nvme_features_id fid,
53545376
printf("\tPre-boot Software Load Count (PBSLC): %u\n", NVME_FEAT_SPM_PBSLC(result));
53555377
break;
53565378
case NVME_FEAT_FID_HOST_ID:
5357-
if (buf) {
5358-
ull = buf[7]; ull <<= 8; ull |= buf[6]; ull <<= 8; ull |= buf[5]; ull <<= 8;
5359-
ull |= buf[4]; ull <<= 8; ull |= buf[3]; ull <<= 8; ull |= buf[2]; ull <<= 8;
5360-
ull |= buf[1]; ull <<= 8; ull |= buf[0];
5361-
printf("\tHost Identifier (HOSTID): %" PRIu64 "\n", ull);
5362-
}
5379+
stdout_feat_host_id(result, buf);
53635380
break;
53645381
case NVME_FEAT_FID_RESV_MASK:
53655382
printf("\tMask Reservation Preempted Notification (RESPRE): %s\n",

nvme.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4875,6 +4875,7 @@ static bool is_get_feature_result_set(enum nvme_features_id feature_id)
48754875
{
48764876
switch (feature_id) {
48774877
case NVME_FEAT_FID_PERF_CHARACTERISTICS:
4878+
case NVME_FEAT_FID_HOST_ID:
48784879
return false;
48794880
default:
48804881
break;

0 commit comments

Comments
 (0)