From: Hannes Reinecke Date: Fri, 5 Apr 2024 14:31:25 +0000 (+0200) Subject: ioctl: add nvme_set_features_host_id2() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0782b381f3f1d1f1aabbc602aec1be549367b501;p=users%2Fsagi%2Flibnvme.git ioctl: add nvme_set_features_host_id2() All 'set features' commands have an 'result' field as the last argument, so add an alternative function nvme_set_features_host_id2() to follow the same calling convention. Signed-off-by: Hannes Reinecke --- diff --git a/src/libnvme.map b/src/libnvme.map index c2a23e3a..85f4a4a1 100644 --- a/src/libnvme.map +++ b/src/libnvme.map @@ -12,6 +12,7 @@ LIBNVME_1.9 { nvme_ctrl_get_cntlid; nvme_set_features_timestamp2; nvme_set_features_host_behavior2; + nvme_set_features_host_id2; }; LIBNVME_1_8 { diff --git a/src/nvme/ioctl.c b/src/nvme/ioctl.c index d54b367c..dfd17e46 100644 --- a/src/nvme/ioctl.c +++ b/src/nvme/ioctl.c @@ -717,6 +717,18 @@ int nvme_set_features_sw_progress(int fd, __u8 pbslc, bool save, } int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid) +{ + __u32 result = 0; + int err; + + err = nvme_set_features_host_id2(fd, exhid, save, hostid, &result); + if (err && result) + err = result; + return err; +} + +int nvme_set_features_host_id2(int fd, bool exhid, bool save, __u8 *hostid, + __u32 *result) { __u32 len = exhid ? 16 : 8; __u32 value = !!exhid; @@ -733,7 +745,7 @@ int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid) .data_len = len, .data = hostid, .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, - .result = NULL, + .result = result, }; return nvme_set_features(&args); diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index a952a761..e3f6450c 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -2903,6 +2903,20 @@ int nvme_set_features_sw_progress(int fd, __u8 pbslc, bool save, */ int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid); +/** + * nvme_set_features_host_id2() - Set enable extended host identifiers feature + * @fd: File descriptor of nvme device + * @exhid: Enable Extended Host Identifier + * @save: Save value across power states + * @hostid: Host ID to set + * @result: The command completion result from CQE dword0 + * + * Return: 0 if the ioctl was successful, -1 with errno set to EPROTO when + * a non-zero state is returned in @result, or -1 with errno set otherwise. + */ +int nvme_set_features_host_id2(int fd, bool exhid, bool save, __u8 *hostid, + __u32 *result); + /** * nvme_set_features_resv_mask() - Set reservation notification mask feature *