summaryrefslogtreecommitdiffstats
path: root/src/nvme/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvme/util.c')
-rw-r--r--src/nvme/util.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/nvme/util.c b/src/nvme/util.c
index 799c0cf..ff5e0d8 100644
--- a/src/nvme/util.c
+++ b/src/nvme/util.c
@@ -23,6 +23,9 @@
#include "util.h"
#include "log.h"
+/* Source Code Control System, query version of binary with 'what' */
+const char sccsid[] = "@(#)libnvme " GIT_VERSION;
+
static inline __u8 nvme_generic_status_to_errno(__u16 status)
{
switch (status) {
@@ -389,6 +392,21 @@ void nvme_init_copy_range(struct nvme_copy_range *copy, __u16 *nlbs,
}
}
+void nvme_init_copy_range_f1(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
+ __u64 *slbas, __u64 *eilbrts, __u32 *elbatms,
+ __u32 *elbats, __u16 nr)
+{
+ int i;
+
+ for (i = 0; i < nr; i++) {
+ copy[i].nlb = cpu_to_le16(nlbs[i]);
+ copy[i].slba = cpu_to_le64(slbas[i]);
+ copy[i].elbt[2] = cpu_to_le64(eilbrts[i]);
+ copy[i].elbatm = cpu_to_le16(elbatms[i]);
+ copy[i].elbat = cpu_to_le16(elbats[i]);
+ }
+}
+
void nvme_init_dsm_range(struct nvme_dsm_range *dsm, __u32 *ctx_attrs,
__u32 *llbas, __u64 *slbas, __u16 nr_ranges)
{
@@ -432,6 +450,9 @@ int nvme_get_feature_length(int fid, __u32 cdw11, __u32 *len)
case NVME_FEAT_FID_HOST_ID:
*len = (cdw11 & 0x1) ? 16 : 8;
break;
+ case NVME_FEAT_FID_HOST_MEM_BUF:
+ *len = sizeof(struct nvme_host_mem_buf_attrs);
+ break;
case NVME_FEAT_FID_ARBITRATION:
case NVME_FEAT_FID_POWER_MGMT:
case NVME_FEAT_FID_TEMP_THRESH:
@@ -442,7 +463,6 @@ int nvme_get_feature_length(int fid, __u32 cdw11, __u32 *len)
case NVME_FEAT_FID_IRQ_CONFIG:
case NVME_FEAT_FID_WRITE_ATOMIC:
case NVME_FEAT_FID_ASYNC_EVENT:
- case NVME_FEAT_FID_HOST_MEM_BUF:
case NVME_FEAT_FID_KATO:
case NVME_FEAT_FID_HCTM:
case NVME_FEAT_FID_NOPSC:
@@ -516,6 +536,11 @@ static const char * const libnvme_status[] = {
[ENVME_CONNECT_INVAL_TR] = "invalid transport type",
[ENVME_CONNECT_LOOKUP_SUBSYS_NAME] = "failed to lookup subsystem name",
[ENVME_CONNECT_LOOKUP_SUBSYS] = "failed to lookup subsystem",
+ [ENVME_CONNECT_ALREADY] = "already connnected",
+ [ENVME_CONNECT_INVAL] = "invalid arguments/configuration",
+ [ENVME_CONNECT_ADDRINUSE] = "hostnqn already in use",
+ [ENVME_CONNECT_NODEV] = "invalid interface",
+ [ENVME_CONNECT_OPNOTSUPP] ="not supported",
};
const char *nvme_errno_to_string(int status)
@@ -775,3 +800,15 @@ struct nvmf_ext_attr *nvmf_exat_ptr_next(struct nvmf_ext_attr *p)
return (struct nvmf_ext_attr *)
((uintptr_t)p + (ptrdiff_t)nvmf_exat_size(le16_to_cpu(p->exatlen)));
}
+
+const char *nvme_get_version(enum nvme_version type)
+{
+ switch(type) {
+ case NVME_VERSION_PROJECT:
+ return PROJECT_VERSION;
+ case NVME_VERSION_GIT:
+ return GIT_VERSION;
+ default:
+ return "n/a";
+ }
+}