Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libnvme/src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -9051,6 +9051,8 @@ enum nvme_features_id {
* @NVME_FEAT_FDP_INDEX_MASK:
* @NVME_FEAT_FDP_EVENTS_ENABLE_SHIFT:
* @NVME_FEAT_FDP_EVENTS_ENABLE_MASK:
* @NVME_FEAT_HOST_ID_EXHID_SHIFT:
* @NVME_FEAT_HOST_ID_EXHID_MASK:
* @NVME_FEAT_BPWPC_BP0WPS_SHIFT:
* @NVME_FEAT_BPWPC_BP0WPS_MASK:
* @NVME_FEAT_BPWPC_BP1WPS_SHIFT:
Expand Down Expand Up @@ -9227,6 +9229,8 @@ enum nvme_feat {
NVME_FEAT_FDP_INDEX_MASK = 0xf,
NVME_FEAT_FDP_EVENTS_ENABLE_SHIFT = 0,
NVME_FEAT_FDP_EVENTS_ENABLE_MASK = 0x1,
NVME_FEAT_HOST_ID_EXHID_SHIFT = 0,
NVME_FEAT_HOST_ID_EXHID_MASK = 0x1,
NVME_FEAT_BPWPC_BP0WPS_SHIFT = 0,
NVME_FEAT_BPWPC_BP0WPS_MASK = 0x7,
NVME_FEAT_BPWPC_BP1WPS_SHIFT = 3,
Expand Down Expand Up @@ -10758,6 +10762,14 @@ nvme_feature_decode_perf_characteristics(__u32 value, __u8 *attri, bool *rvspa)
*rvspa = NVME_FEAT_PERFC_RVSPA(value);
}

#define NVME_FEAT_HOST_ID_EXHID(v) NVME_GET(v, FEAT_HOST_ID_EXHID)

static inline void
nvme_feature_decode_host_id(__u32 value, bool *exhid)
{
*exhid = NVME_FEAT_HOST_ID_EXHID(value);
}

#define NVME_FEAT_SPM_PBSLC(v) NVME_GET(v, FEAT_SPM_PBSLC)

static inline void
Expand Down
36 changes: 27 additions & 9 deletions nvme-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -5083,7 +5083,7 @@ static void stdout_feat_perfc_vs(struct nvme_vs_perf_attr *data)
d((unsigned char *)data->vs, data->attrl, 16, 1);
}

static void stdout_feat_perfc(enum nvme_features_id fid, unsigned int result,
static void stdout_feat_perfc(unsigned int result,
struct nvme_perf_characteristics *data)
{
__u8 attri;
Expand Down Expand Up @@ -5133,6 +5133,29 @@ static void stdout_host_metadata(enum nvme_features_id fid,
}
}

static void stdout_feat_host_id(unsigned int result, unsigned char *hostid)
{
uint64_t ull;
bool exhid;

if (!hostid)
return;

nvme_feature_decode_host_id(result, &exhid);

if (exhid) {
printf("\tHost Identifier (HOSTID): %s\n",
uint128_t_to_l10n_string(le128_to_cpu(hostid)));
return;
}

ull = hostid[7]; ull <<= 8; ull |= hostid[6]; ull <<= 8;
ull |= hostid[5]; ull <<= 8; ull |= hostid[4]; ull <<= 8;
ull |= hostid[3]; ull <<= 8; ull |= hostid[2]; ull <<= 8;
ull |= hostid[1]; ull <<= 8; ull |= hostid[0];
printf("\tHost Identifier (HOSTID): %" PRIu64 "\n", ull);
}

static void stdout_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
{
printf("get-feature:%#0*x (%s), %s value:%#0*x\n", fid ? 4 : 2, fid,
Expand All @@ -5146,7 +5169,6 @@ static void stdout_feature_show_fields(enum nvme_features_id fid,
const char *async = "Send async event";
const char *no_async = "Do not send async event";
__u8 field;
uint64_t ull;

switch (fid) {
case NVME_FEAT_FID_ARBITRATION:
Expand Down Expand Up @@ -5342,7 +5364,8 @@ static void stdout_feature_show_fields(enum nvme_features_id fid,
nvme_pls_mode_to_string(NVME_GET(result, FEAT_PLS_MODE)));
break;
case NVME_FEAT_FID_PERF_CHARACTERISTICS:
stdout_feat_perfc(fid, result, (struct nvme_perf_characteristics *)buf);
stdout_feat_perfc(result,
(struct nvme_perf_characteristics *)buf);
break;
case NVME_FEAT_FID_ENH_CTRL_METADATA:
case NVME_FEAT_FID_CTRL_METADATA:
Expand All @@ -5354,12 +5377,7 @@ static void stdout_feature_show_fields(enum nvme_features_id fid,
printf("\tPre-boot Software Load Count (PBSLC): %u\n", NVME_FEAT_SPM_PBSLC(result));
break;
case NVME_FEAT_FID_HOST_ID:
if (buf) {
ull = buf[7]; ull <<= 8; ull |= buf[6]; ull <<= 8; ull |= buf[5]; ull <<= 8;
ull |= buf[4]; ull <<= 8; ull |= buf[3]; ull <<= 8; ull |= buf[2]; ull <<= 8;
ull |= buf[1]; ull <<= 8; ull |= buf[0];
printf("\tHost Identifier (HOSTID): %" PRIu64 "\n", ull);
}
stdout_feat_host_id(result, buf);
break;
case NVME_FEAT_FID_RESV_MASK:
printf("\tMask Reservation Preempted Notification (RESPRE): %s\n",
Expand Down
1 change: 1 addition & 0 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -4875,6 +4875,7 @@ static bool is_get_feature_result_set(enum nvme_features_id feature_id)
{
switch (feature_id) {
case NVME_FEAT_FID_PERF_CHARACTERISTICS:
case NVME_FEAT_FID_HOST_ID:
return false;
default:
break;
Expand Down