[ndctl] ndctl: updates for libnd
diff mbox

Message ID 20150428202325.36525.64812.stgit@dwillia2-desk3.amr.corp.intel.com
State Superseded
Headers show

Commit Message

Dan Williams April 28, 2015, 8:24 p.m. UTC
The new 'libnd' organization of the kernel enabling means that nfit
specifics are pushed out of the generic core.  Update libndctl to find
nfit-specific attributes in an 'nfit' attribute sub-directory of an nd
device.

Cc: Toshi Kani <toshi.kani@hp.com>
Cc: Robert Elliott <Elliott@hp.com>
Cc: Linda Knippers <linda.knippers@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl.c       |  248 +++++++++++++++++++++++++++-----------------------
 lib/libndctl.sym     |    1 
 lib/ndctl/libndctl.h |    1 
 lib/test-dpa-alloc.c |    2 
 lib/test-libndctl.c  |   46 +++++----
 ndctl.h              |  136 ++++++++++++++-------------
 6 files changed, 230 insertions(+), 204 deletions(-)

Patch
diff mbox

diff --git a/lib/libndctl.c b/lib/libndctl.c
index 73e241fcee80..3274c094b7f6 100644
--- a/lib/libndctl.c
+++ b/lib/libndctl.c
@@ -98,6 +98,7 @@  struct ndctl_bus {
 	int dimms_init;
 	int btts_init;
 	int regions_init;
+	int has_nfit;
 	char *bus_path;
 	char *bus_buf;
 	size_t buf_len;
@@ -326,10 +327,10 @@  struct ndctl_cmd {
 	} iter;
 	struct ndctl_cmd *source;
 	union {
-		struct nfit_cmd_get_config_size get_size[0];
-		struct nfit_cmd_get_config_data_hdr get_data[0];
-		struct nfit_cmd_set_config_hdr set_data[0];
-		struct nfit_cmd_vendor_hdr vendor[0];
+		struct nd_cmd_get_config_size get_size[0];
+		struct nd_cmd_get_config_data_hdr get_data[0];
+		struct nd_cmd_set_config_hdr set_data[0];
+		struct nd_cmd_vendor_hdr vendor[0];
 		char cmd_buf[0];
 	};
 };
@@ -742,11 +743,11 @@  static int to_dsm_index(const char *name, int dimm)
 	int i, end_cmd;
 
 	if (dimm) {
-		end_cmd = NFIT_CMD_VENDOR;
-		cmd_name_fn = nfit_dimm_cmd_name;
+		end_cmd = ND_CMD_VENDOR;
+		cmd_name_fn = nd_dimm_cmd_name;
 	} else {
-		end_cmd = NFIT_CMD_ARS_QUERY;
-		cmd_name_fn = nfit_bus_cmd_name;
+		end_cmd = ND_CMD_ARS_QUERY;
+		cmd_name_fn = nd_bus_cmd_name;
 	}
 
 	for (i = 1; i <= end_cmd; i++) {
@@ -784,7 +785,7 @@  static int add_bus(void *parent, int id, const char *ctl_base)
 	struct ndctl_bus *bus;
 	char buf[SYSFS_ATTR_SIZE];
 	struct ndctl_ctx *ctx = parent;
-	char *path = calloc(1, strlen(ctl_base) + 20);
+	char *path = calloc(1, strlen(ctl_base) + 100);
 
 	if (!path)
 		return -ENOMEM;
@@ -809,10 +810,14 @@  static int add_bus(void *parent, int id, const char *ctl_base)
 		goto err_read;
 	bus->dsm_mask = parse_commands(buf, 0);
 
-	sprintf(path, "%s/device/revision", ctl_base);
-	if (sysfs_read_attr(ctx, path, buf) < 0)
-		goto err_read;
-	bus->revision = strtoul(buf, NULL, 0);
+	sprintf(path, "%s/device/nfit/revision", ctl_base);
+	if (sysfs_read_attr(ctx, path, buf) < 0) {
+		bus->has_nfit = 0;
+		bus->revision = -1;
+	} else {
+		bus->has_nfit = 1;
+		bus->revision = strtoul(buf, NULL, 0);
+	}
 
 	sprintf(path, "%s/device/provider", ctl_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
@@ -890,6 +895,11 @@  NDCTL_EXPORT struct ndctl_bus *ndctl_bus_get_next(struct ndctl_bus *bus)
 	return list_next(&ctx->busses, bus, list);
 }
 
+NDCTL_EXPORT int ndctl_bus_has_nfit(struct ndctl_bus *bus)
+{
+	return bus->has_nfit;
+}
+
 /**
  * ndctl_bus_get_major - nd bus character device major number
  * @bus: ndctl_bus instance returned from ndctl_bus_get_{first|next}
@@ -950,7 +960,7 @@  NDCTL_EXPORT struct ndctl_btt *ndctl_bus_get_btt_seed(struct ndctl_bus *bus)
 
 NDCTL_EXPORT const char *ndctl_bus_get_cmd_name(struct ndctl_bus *bus, int cmd)
 {
-	return nfit_bus_cmd_name(cmd);
+	return nd_bus_cmd_name(cmd);
 }
 
 NDCTL_EXPORT int ndctl_bus_is_cmd_supported(struct ndctl_bus *bus,
@@ -1020,7 +1030,7 @@  static int add_dimm(void *parent, int id, const char *dimm_base)
 	char buf[SYSFS_ATTR_SIZE];
 	struct ndctl_bus *bus = parent;
 	struct ndctl_ctx *ctx = bus->ctx;
-	char *path = calloc(1, strlen(dimm_base) + 20);
+	char *path = calloc(1, strlen(dimm_base) + 100);
 
 	if (!path)
 		return -ENOMEM;
@@ -1039,60 +1049,62 @@  static int add_dimm(void *parent, int id, const char *dimm_base)
 	if (sscanf(buf, "%d:%d", &dimm->major, &dimm->minor) != 2)
 		goto err_read;
 
-	sprintf(path, "%s/handle", dimm_base);
+	sprintf(path, "%s/commands", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
 		goto err_read;
-	dimm->handle = strtoul(buf, NULL, 0);
+	dimm->dsm_mask = parse_commands(buf, 1);
 
-	sprintf(path, "%s/phys_id", dimm_base);
-	if (sysfs_read_attr(ctx, path, buf) < 0)
-		goto err_read;
-	dimm->phys_id = strtoul(buf, NULL, 0);
+        dimm->dimm_buf = calloc(1, strlen(dimm_base) + 50);
+        if (!dimm->dimm_buf)
+                goto err_read;
+        dimm->buf_len = strlen(dimm_base) + 50;
 
 	dimm->dimm_path = strdup(dimm_base);
 	if (!dimm->dimm_path)
 		goto err_read;
 
-        dimm->dimm_buf = calloc(1, strlen(dimm_base) + 50);
-        if (!dimm->dimm_buf)
-                goto err_read;
-        dimm->buf_len = strlen(dimm_base) + 50;
+	dimm->handle = -1;
+	dimm->phys_id = -1;
+	dimm->vendor_id = -1;
+	dimm->serial = -1;
+	dimm->device_id = -1;
+	dimm->revision_id = -1;
+	dimm->format_id = -1;
+	if (!ndctl_bus_has_nfit(bus))
+		goto out;
 
-	sprintf(path, "%s/vendor", dimm_base);
+	sprintf(path, "%s/nfit/handle", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
-		dimm->vendor_id = -1;
-	else
-		dimm->vendor_id = strtoul(buf, NULL, 0);
+		goto err_read;
+	dimm->handle = strtoul(buf, NULL, 0);
 
-	sprintf(path, "%s/commands", dimm_base);
+	sprintf(path, "%s/nfit/phys_id", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
 		goto err_read;
-	dimm->dsm_mask = parse_commands(buf, 1);
+	dimm->phys_id = strtoul(buf, NULL, 0);
 
-	sprintf(path, "%s/serial", dimm_base);
+	sprintf(path, "%s/nfit/vendor", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
-		dimm->serial = -1;
+		dimm->vendor_id = -1;
 	else
+		dimm->vendor_id = strtoul(buf, NULL, 0);
+
+	sprintf(path, "%s/nfit/serial", dimm_base);
+	if (sysfs_read_attr(ctx, path, buf) == 0)
 		dimm->serial = strtoul(buf, NULL, 0);
 
-	sprintf(path, "%s/device", dimm_base);
-	if (sysfs_read_attr(ctx, path, buf) < 0)
-		dimm->device_id = -1;
-	else
+	sprintf(path, "%s/nfit/device", dimm_base);
+	if (sysfs_read_attr(ctx, path, buf) == 0)
 		dimm->device_id = strtoul(buf, NULL, 0);
 
-	sprintf(path, "%s/revision", dimm_base);
-	if (sysfs_read_attr(ctx, path, buf) < 0)
-		dimm->revision_id = -1;
-	else
+	sprintf(path, "%s/nfit/rev_id", dimm_base);
+	if (sysfs_read_attr(ctx, path, buf) == 0)
 		dimm->revision_id = strtoul(buf, NULL, 0);
 
-	sprintf(path, "%s/format", dimm_base);
-	if (sysfs_read_attr(ctx, path, buf) < 0)
-		dimm->format_id = -1;
-	else
+	sprintf(path, "%s/nfit/format", dimm_base);
+	if (sysfs_read_attr(ctx, path, buf) == 0)
 		dimm->format_id = strtoul(buf, NULL, 0);
-
+ out:
 	list_add(&bus->dimms, &dimm->list);
 	free(path);
 
@@ -1185,7 +1197,7 @@  NDCTL_EXPORT const char *ndctl_dimm_get_devname(struct ndctl_dimm *dimm)
 
 NDCTL_EXPORT const char *ndctl_dimm_get_cmd_name(struct ndctl_dimm *dimm, int cmd)
 {
-	return nfit_dimm_cmd_name(cmd);
+	return nd_dimm_cmd_name(cmd);
 }
 
 NDCTL_EXPORT int ndctl_dimm_is_cmd_supported(struct ndctl_dimm *dimm,
@@ -1241,6 +1253,16 @@  NDCTL_EXPORT struct ndctl_dimm *ndctl_dimm_get_by_handle(struct ndctl_bus *bus,
 	return NULL;
 }
 
+static struct ndctl_dimm *ndctl_dimm_get_by_id(struct ndctl_bus *bus, unsigned int id)
+{
+	struct ndctl_dimm *dimm;
+
+	ndctl_dimm_foreach(bus, dimm)
+		if (ndctl_dimm_get_id(dimm) == id)
+			return dimm;
+	return NULL;
+}
+
 static int add_region(void *parent, int id, const char *region_base)
 {
 	int rc = -ENOMEM;
@@ -1248,7 +1270,7 @@  static int add_region(void *parent, int id, const char *region_base)
 	struct ndctl_region *region;
 	struct ndctl_bus *bus = parent;
 	struct ndctl_ctx *ctx = bus->ctx;
-	char *path = calloc(1, strlen(region_base) + 20);
+	char *path = calloc(1, strlen(region_base) + 100);
 
 	if (!path)
 		return -ENOMEM;
@@ -1278,8 +1300,8 @@  static int add_region(void *parent, int id, const char *region_base)
 		goto err_read;
 	region->nstype = strtoul(buf, NULL, 0);
 
-	sprintf(path, "%s/spa_index", region_base);
-	if (region->nstype != ND_DEVICE_NAMESPACE_BLOCK) {
+	sprintf(path, "%s/nfit/spa_index", region_base);
+	if (ndctl_bus_has_nfit(bus)) {
 		if (sysfs_read_attr(ctx, path, buf) < 0)
 			goto err_read;
 		region->spa_index = strtoul(buf, NULL, 0);
@@ -1379,7 +1401,7 @@  NDCTL_EXPORT unsigned long long ndctl_region_get_available_size(
 
 	switch (nstype) {
 	case ND_DEVICE_NAMESPACE_PMEM:
-	case ND_DEVICE_NAMESPACE_BLOCK:
+	case ND_DEVICE_NAMESPACE_BLK:
 		break;
 	default:
 		return 0;
@@ -1414,7 +1436,7 @@  NDCTL_EXPORT unsigned int ndctl_region_get_type(struct ndctl_region *region)
 	case ND_DEVICE_NAMESPACE_PMEM:
 		return ND_DEVICE_REGION_PMEM;
 	default:
-		return ND_DEVICE_REGION_BLOCK;
+		return ND_DEVICE_REGION_BLK;
 	}
 }
 
@@ -1446,13 +1468,13 @@  NDCTL_EXPORT struct ndctl_namespace *ndctl_region_get_namespace_seed(
 static const char *ndctl_device_type_name(int type)
 {
 	switch (type) {
-	case ND_DEVICE_DIMM:            return "dimm";
-	case ND_DEVICE_REGION_PMEM:     return "pmem";
-	case ND_DEVICE_REGION_BLOCK:    return "block";
-	case ND_DEVICE_NAMESPACE_IO:    return "namespace_io";
-	case ND_DEVICE_NAMESPACE_PMEM:  return "namespace_pmem";
-	case ND_DEVICE_NAMESPACE_BLOCK: return "namespace_block";
-	default:                        return "unknown";
+	case ND_DEVICE_DIMM:           return "dimm";
+	case ND_DEVICE_REGION_PMEM:    return "pmem";
+	case ND_DEVICE_REGION_BLK:     return "blk";
+	case ND_DEVICE_NAMESPACE_IO:   return "namespace_io";
+	case ND_DEVICE_NAMESPACE_PMEM: return "namespace_pmem";
+	case ND_DEVICE_NAMESPACE_BLK:  return "namespace_blk";
+	default:                       return "unknown";
 	}
 }
 
@@ -1501,10 +1523,10 @@  NDCTL_EXPORT struct ndctl_dimm *ndctl_region_get_next_dimm(struct ndctl_region *
 	return NULL;
 }
 
-static struct nfit_cmd_vendor_tail *to_vendor_tail(struct ndctl_cmd *cmd)
+static struct nd_cmd_vendor_tail *to_vendor_tail(struct ndctl_cmd *cmd)
 {
-	struct nfit_cmd_vendor_tail *tail = (struct nfit_cmd_vendor_tail *)
-		(cmd->cmd_buf + sizeof(struct nfit_cmd_vendor_hdr)
+	struct nd_cmd_vendor_tail *tail = (struct nd_cmd_vendor_tail *)
+		(cmd->cmd_buf + sizeof(struct nd_cmd_vendor_hdr)
 		 + cmd->vendor->in_length);
 	return tail;
 }
@@ -1518,13 +1540,13 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(
 	struct ndctl_cmd *cmd;
 	size_t size;
 
-	if (!ndctl_dimm_is_cmd_supported(dimm, NFIT_CMD_VENDOR)) {
+	if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_VENDOR)) {
 		dbg(ctx, "unsupported cmd\n");
 		return NULL;
 	}
 
-	size = sizeof(*cmd) + sizeof(struct nfit_cmd_vendor_hdr)
-		+ sizeof(struct nfit_cmd_vendor_tail) + input_size
+	size = sizeof(*cmd) + sizeof(struct nd_cmd_vendor_hdr)
+		+ sizeof(struct nd_cmd_vendor_tail) + input_size
 		+ output_size;
 
 	cmd = calloc(1, size);
@@ -1533,7 +1555,7 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(
 
 	cmd->dimm = dimm;
 	ndctl_cmd_ref(cmd);
-	cmd->type = NFIT_CMD_VENDOR;
+	cmd->type = ND_CMD_VENDOR;
 	cmd->size = size;
 	cmd->status = 1;
 	cmd->vendor->opcode = opcode;
@@ -1547,7 +1569,7 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_vendor_specific(
 NDCTL_EXPORT ssize_t ndctl_cmd_vendor_set_input(struct ndctl_cmd *cmd,
 		void *buf, unsigned int len)
 {
-	if (cmd->type != NFIT_CMD_VENDOR)
+	if (cmd->type != ND_CMD_VENDOR)
 		return -EINVAL;
 	len = min(len, cmd->vendor->in_length);
 	memcpy(cmd->vendor->in_buf, buf, len);
@@ -1556,7 +1578,7 @@  NDCTL_EXPORT ssize_t ndctl_cmd_vendor_set_input(struct ndctl_cmd *cmd,
 
 NDCTL_EXPORT ssize_t ndctl_cmd_vendor_get_output_size(struct ndctl_cmd *cmd)
 {
-	if (cmd->type != NFIT_CMD_VENDOR || cmd->status > 0)
+	if (cmd->type != ND_CMD_VENDOR || cmd->status > 0)
 		return -EINVAL;
 	if (cmd->status < 0)
 		return cmd->status;
@@ -1584,19 +1606,19 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_size(struct ndctl_dimm *di
 	struct ndctl_cmd *cmd;
 	size_t size;
 
-	if (!ndctl_dimm_is_cmd_supported(dimm, NFIT_CMD_GET_CONFIG_SIZE)) {
+	if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_GET_CONFIG_SIZE)) {
 		dbg(ctx, "unsupported cmd\n");
 		return NULL;
 	}
 
-	size = sizeof(*cmd) + sizeof(struct nfit_cmd_get_config_size);
+	size = sizeof(*cmd) + sizeof(struct nd_cmd_get_config_size);
 	cmd = calloc(1, size);
 	if (!cmd)
 		return NULL;
 
 	cmd->dimm = dimm;
 	ndctl_cmd_ref(cmd);
-	cmd->type = NFIT_CMD_GET_CONFIG_SIZE;
+	cmd->type = ND_CMD_GET_CONFIG_SIZE;
 	cmd->size = size;
 	cmd->status = 1;
 	cmd->firmware_status = &cmd->get_size->status;
@@ -1618,12 +1640,12 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_read(struct ndctl_cmd *cfg
 	struct ndctl_cmd *cmd;
 	size_t size;
 
-	if (!ndctl_dimm_is_cmd_supported(dimm, NFIT_CMD_GET_CONFIG_DATA)) {
+	if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_GET_CONFIG_DATA)) {
 		dbg(ctx, "unsupported cmd\n");
 		return NULL;
 	}
 
-	if (cfg_size->type != NFIT_CMD_GET_CONFIG_SIZE
+	if (cfg_size->type != ND_CMD_GET_CONFIG_SIZE
 			|| cfg_size->status != 0) {
 		dbg(ctx, "expected sucessfully completed cfg_size command\n");
 		return NULL;
@@ -1633,7 +1655,7 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_read(struct ndctl_cmd *cfg
 		return NULL;
 	}
 
-	size = sizeof(*cmd) + sizeof(struct nfit_cmd_get_config_data_hdr)
+	size = sizeof(*cmd) + sizeof(struct nd_cmd_get_config_data_hdr)
 		+ cfg_size->get_size->max_xfer;
 	cmd = calloc(1, size);
 	if (!cmd)
@@ -1641,7 +1663,7 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_read(struct ndctl_cmd *cfg
 
 	cmd->dimm = cfg_size->dimm;
 	cmd->refcount = 1;
-	cmd->type = NFIT_CMD_GET_CONFIG_DATA;
+	cmd->type = ND_CMD_GET_CONFIG_DATA;
 	cmd->size = size;
 	cmd->status = 1;
 	cmd->get_data->in_offset = 0;
@@ -1668,13 +1690,13 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_write(struct ndctl_cmd *cf
 	struct ndctl_cmd *cmd;
 	size_t size;
 
-	if (!ndctl_dimm_is_cmd_supported(dimm, NFIT_CMD_SET_CONFIG_DATA)) {
+	if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SET_CONFIG_DATA)) {
 		dbg(ctx, "unsupported cmd\n");
 		return NULL;
 	}
 
 	/* enforce rmw */
-	if (cfg_read->type != NFIT_CMD_GET_CONFIG_DATA
+	if (cfg_read->type != ND_CMD_GET_CONFIG_DATA
 		       || cfg_read->status != 0) {
 		dbg(ctx, "expected sucessfully completed cfg_read command\n");
 		return NULL;
@@ -1685,7 +1707,7 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_write(struct ndctl_cmd *cf
 		return NULL;
 	}
 
-	size = sizeof(*cmd) + sizeof(struct nfit_cmd_set_config_hdr)
+	size = sizeof(*cmd) + sizeof(struct nd_cmd_set_config_hdr)
 		+ cfg_read->iter.max_xfer + 4;
 	cmd = calloc(1, size);
 	if (!cmd)
@@ -1693,13 +1715,13 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_write(struct ndctl_cmd *cf
 
 	cmd->dimm = cfg_read->dimm;
 	ndctl_cmd_ref(cmd);
-	cmd->type = NFIT_CMD_SET_CONFIG_DATA;
+	cmd->type = ND_CMD_SET_CONFIG_DATA;
 	cmd->size = size;
 	cmd->status = 1;
 	cmd->set_data->in_offset = 0;
 	cmd->set_data->in_length = cfg_read->iter.max_xfer;
 	cmd->firmware_status = (u32 *) (cmd->cmd_buf
-		+ sizeof(struct nfit_cmd_set_config_hdr) + cfg_read->iter.max_xfer);
+		+ sizeof(struct nd_cmd_set_config_hdr) + cfg_read->iter.max_xfer);
 	cmd->iter.offset = &cmd->set_data->in_offset;
 	cmd->iter.max_xfer = cfg_read->iter.max_xfer;
 	cmd->iter.data = cmd->set_data->in_buf;
@@ -1714,7 +1736,7 @@  NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_write(struct ndctl_cmd *cf
 
 NDCTL_EXPORT unsigned int ndctl_cmd_cfg_size_get_size(struct ndctl_cmd *cfg_size)
 {
-	if (cfg_size->type == NFIT_CMD_GET_CONFIG_SIZE
+	if (cfg_size->type == ND_CMD_GET_CONFIG_SIZE
 			&& cfg_size->status == 0)
 		return cfg_size->get_size->config_size;
 	return 0;
@@ -1723,7 +1745,7 @@  NDCTL_EXPORT unsigned int ndctl_cmd_cfg_size_get_size(struct ndctl_cmd *cfg_size
 NDCTL_EXPORT ssize_t ndctl_cmd_cfg_read_get_data(struct ndctl_cmd *cfg_read,
 		void *buf, unsigned int len, unsigned int offset)
 {
-	if (cfg_read->type != NFIT_CMD_GET_CONFIG_DATA || cfg_read->status > 0)
+	if (cfg_read->type != ND_CMD_GET_CONFIG_DATA || cfg_read->status > 0)
 		return -EINVAL;
 	if (cfg_read->status < 0)
 		return cfg_read->status;
@@ -1738,7 +1760,7 @@  NDCTL_EXPORT ssize_t ndctl_cmd_cfg_read_get_data(struct ndctl_cmd *cfg_read,
 NDCTL_EXPORT ssize_t ndctl_cmd_cfg_write_set_data(struct ndctl_cmd *cfg_write,
 		void *buf, unsigned int len, unsigned int offset)
 {
-	if (cfg_write->type != NFIT_CMD_SET_CONFIG_DATA || cfg_write->status < 1)
+	if (cfg_write->type != ND_CMD_SET_CONFIG_DATA || cfg_write->status < 1)
 		return -EINVAL;
 	if (cfg_write->status < 0)
 		return cfg_write->status;
@@ -1752,7 +1774,7 @@  NDCTL_EXPORT ssize_t ndctl_cmd_cfg_write_set_data(struct ndctl_cmd *cfg_write,
 
 NDCTL_EXPORT ssize_t ndctl_cmd_cfg_write_zero_data(struct ndctl_cmd *cfg_write)
 {
-	if (cfg_write->type != NFIT_CMD_SET_CONFIG_DATA || cfg_write->status < 1)
+	if (cfg_write->type != ND_CMD_SET_CONFIG_DATA || cfg_write->status < 1)
 		return -EINVAL;
 	if (cfg_write->status < 0)
 		return cfg_write->status;
@@ -1838,24 +1860,24 @@  static int to_ioctl_cmd(int cmd, int dimm)
 {
 	if (!dimm) {
 		switch (cmd) {
-		case NFIT_CMD_ARS_CAP:         return NFIT_IOCTL_ARS_CAP;
-		case NFIT_CMD_ARS_START:       return NFIT_IOCTL_ARS_START;
-		case NFIT_CMD_ARS_QUERY:       return NFIT_IOCTL_ARS_QUERY;
+		case ND_CMD_ARS_CAP:         return ND_IOCTL_ARS_CAP;
+		case ND_CMD_ARS_START:       return ND_IOCTL_ARS_START;
+		case ND_CMD_ARS_QUERY:       return ND_IOCTL_ARS_QUERY;
 		default:
 						       return 0;
 		};
 	}
 
 	switch (cmd) {
-	case NFIT_CMD_SMART:                  return NFIT_IOCTL_SMART;
-	case NFIT_CMD_SMART_THRESHOLD:        return NFIT_IOCTL_SMART_THRESHOLD;
-	case NFIT_CMD_DIMM_FLAGS:             return NFIT_IOCTL_DIMM_FLAGS;
-	case NFIT_CMD_GET_CONFIG_SIZE:        return NFIT_IOCTL_GET_CONFIG_SIZE;
-	case NFIT_CMD_GET_CONFIG_DATA:        return NFIT_IOCTL_GET_CONFIG_DATA;
-	case NFIT_CMD_SET_CONFIG_DATA:        return NFIT_IOCTL_SET_CONFIG_DATA;
-	case NFIT_CMD_VENDOR:                 return NFIT_IOCTL_VENDOR;
-	case NFIT_CMD_VENDOR_EFFECT_LOG_SIZE:
-	case NFIT_CMD_VENDOR_EFFECT_LOG:
+	case ND_CMD_SMART:                  return ND_IOCTL_SMART;
+	case ND_CMD_SMART_THRESHOLD:        return ND_IOCTL_SMART_THRESHOLD;
+	case ND_CMD_DIMM_FLAGS:             return ND_IOCTL_DIMM_FLAGS;
+	case ND_CMD_GET_CONFIG_SIZE:        return ND_IOCTL_GET_CONFIG_SIZE;
+	case ND_CMD_GET_CONFIG_DATA:        return ND_IOCTL_GET_CONFIG_DATA;
+	case ND_CMD_SET_CONFIG_DATA:        return ND_IOCTL_SET_CONFIG_DATA;
+	case ND_CMD_VENDOR:                 return ND_IOCTL_VENDOR;
+	case ND_CMD_VENDOR_EFFECT_LOG_SIZE:
+	case ND_CMD_VENDOR_EFFECT_LOG:
 	default:
 					      return 0;
 	}
@@ -1877,10 +1899,11 @@  static int do_cmd(int fd, int ioctl_cmd, struct ndctl_cmd *cmd)
 
 	if (iter->total_xfer == 0) {
 		rc = ioctl(fd, ioctl_cmd, cmd->cmd_buf);
-		dbg(ctx, "bus: %d dimm: %#x cmd: %s status: %d fw: %d\n",
+		dbg(ctx, "bus: %d dimm: %#x cmd: %s status: %d fw: %d (%s)\n",
 				bus->id, cmd->dimm
 				? ndctl_dimm_get_handle(cmd->dimm) : 0,
-				name, rc, *(cmd->firmware_status));
+				name, rc, *(cmd->firmware_status), rc < 0 ?
+				strerror(errno) : "success");
 		return rc;
 	}
 
@@ -1891,10 +1914,11 @@  static int do_cmd(int fd, int ioctl_cmd, struct ndctl_cmd *cmd)
 					iter->max_xfer);
 		*(cmd->iter.offset) = offset;
 		rc = ioctl(fd, ioctl_cmd, cmd->cmd_buf);
-		dbg(ctx, "bus: %d dimm: %#x cmd: %s offset: %d status: (%d:%d)\n",
+		dbg(ctx, "bus: %d dimm: %#x cmd: %s offset: %d status: %d fw: %d (%s)\n",
 				bus->id, cmd->dimm
 				? ndctl_dimm_get_handle(cmd->dimm) : 0,
-				name, offset, rc, *(cmd->firmware_status));
+				name, offset, rc, *(cmd->firmware_status),
+				rc < 0 ? strerror(errno) : "success");
 		if (rc)
 			return rc;
 
@@ -2215,7 +2239,7 @@  static void mappings_init(struct ndctl_region *region)
 		return;
 	region->mappings_init = 1;
 
-	mapping_path = calloc(1, strlen(region->region_path) + 20);
+	mapping_path = calloc(1, strlen(region->region_path) + 100);
 	if (!mapping_path) {
 		err(ctx, "bus%d region%d: allocation failure\n",
 				bus->id, region->id);
@@ -2226,7 +2250,7 @@  static void mappings_init(struct ndctl_region *region)
 		struct ndctl_mapping *mapping;
 		unsigned long long offset, length;
 		struct ndctl_dimm *dimm;
-		unsigned int handle;
+		unsigned int dimm_id;
 
 		sprintf(mapping_path, "%s/mapping%d", region->region_path, i);
 		if (sysfs_read_attr(ctx, mapping_path, buf) < 0) {
@@ -2235,17 +2259,17 @@  static void mappings_init(struct ndctl_region *region)
 			continue;
 		}
 
-		if (sscanf(buf, "%x,%llu,%llu", &handle, &offset,
+		if (sscanf(buf, "nmem%u,%llu,%llu", &dimm_id, &offset,
 					&length) != 3) {
 			err(ctx, "bus%d mapping parse failure\n",
 					ndctl_bus_get_id(bus));
 			continue;
 		}
 
-		dimm = ndctl_dimm_get_by_handle(bus, handle);
+		dimm = ndctl_dimm_get_by_id(bus, dimm_id);
 		if (!dimm) {
-			err(ctx, "bus%d region%d mapping%d: dimm lookup failure\n",
-					bus->id, region->id, i);
+			err(ctx, "bus%d region%d mapping%d: nmem%d lookup failure\n",
+					bus->id, region->id, i, dimm_id);
 			continue;
 		}
 
@@ -2350,7 +2374,7 @@  static int parse_lbasize_supported(struct ndctl_ctx *ctx, const char *buf,
 
 static int add_namespace(void *parent, int id, const char *ndns_base)
 {
-	char *path = calloc(1, strlen(ndns_base) + 20);
+	char *path = calloc(1, strlen(ndns_base) + 100);
 	struct ndctl_namespace *ndns, *ndns_dup;
 	struct ndctl_region *region = parent;
 	struct ndctl_bus *bus = region->bus;
@@ -2379,7 +2403,7 @@  static int add_namespace(void *parent, int id, const char *ndns_base)
 	ndns->size = strtoull(buf, NULL, 0);
 
 	switch (ndns->type) {
-	case ND_DEVICE_NAMESPACE_BLOCK:
+	case ND_DEVICE_NAMESPACE_BLK:
 		sprintf(path, "%s/sector_size", ndns_base);
 		if (sysfs_read_attr(ctx, path, buf) < 0)
 			goto err_read;
@@ -2708,7 +2732,7 @@  NDCTL_EXPORT int ndctl_namespace_is_configured(struct ndctl_namespace *ndns)
 		return pmem_namespace_is_configured(ndns);
 	case ND_DEVICE_NAMESPACE_IO:
 		return 1;
-	case ND_DEVICE_NAMESPACE_BLOCK:
+	case ND_DEVICE_NAMESPACE_BLK:
 		return blk_namespace_is_configured(ndns);
 	default:
 		dbg(ctx, "%s: nstype: %d is_configured() not implemented\n",
@@ -2875,7 +2899,7 @@  NDCTL_EXPORT int ndctl_namespace_set_size(struct ndctl_namespace *ndns,
 
 	switch (ndctl_namespace_get_type(ndns)) {
 	case ND_DEVICE_NAMESPACE_PMEM:
-	case ND_DEVICE_NAMESPACE_BLOCK:
+	case ND_DEVICE_NAMESPACE_BLK:
 		return namespace_set_size(ndns, size);
 	default:
 		dbg(ctx, "%s: nstype: %d set size failed\n",
@@ -2901,7 +2925,7 @@  NDCTL_EXPORT int ndctl_namespace_delete(struct ndctl_namespace *ndns)
 
         switch (ndctl_namespace_get_type(ndns)) {
         case ND_DEVICE_NAMESPACE_PMEM:
-        case ND_DEVICE_NAMESPACE_BLOCK:
+        case ND_DEVICE_NAMESPACE_BLK:
 		break;
 	default:
 		dbg(ctx, "%s: nstype: %d delete failed\n",
@@ -2966,7 +2990,7 @@  static int parse_lbasize_supported(struct ndctl_ctx *ctx, const char *buf,
 
 static int add_btt(void *parent, int id, const char *btt_base)
 {
-	char *path = calloc(1, strlen(btt_base) + 20);
+	char *path = calloc(1, strlen(btt_base) + 100);
 	struct ndctl_bus *bus = parent;
 	struct ndctl_ctx *ctx = bus->ctx;
 	struct ndctl_btt *btt, *btt_dup;
diff --git a/lib/libndctl.sym b/lib/libndctl.sym
index 31f2ffce4b1f..eb62e36d647b 100644
--- a/lib/libndctl.sym
+++ b/lib/libndctl.sym
@@ -27,6 +27,7 @@  global:
 	ndctl_bus_get_btt_seed;
 	ndctl_bus_get_cmd_name;
 	ndctl_bus_is_cmd_supported;
+	ndctl_bus_has_nfit;
 	ndctl_bus_get_revision;
 	ndctl_bus_get_id;
 	ndctl_bus_get_provider;
diff --git a/lib/ndctl/libndctl.h b/lib/ndctl/libndctl.h
index 5c27a435b8fb..126c511e289e 100644
--- a/lib/ndctl/libndctl.h
+++ b/lib/ndctl/libndctl.h
@@ -96,6 +96,7 @@  struct ndctl_bus *ndctl_bus_get_next(struct ndctl_bus *bus);
              bus != NULL; \
              bus = ndctl_bus_get_next(bus))
 struct ndctl_ctx *ndctl_bus_get_ctx(struct ndctl_bus *bus);
+int ndctl_bus_has_nfit(struct ndctl_bus *bus);
 unsigned int ndctl_bus_get_major(struct ndctl_bus *bus);
 unsigned int ndctl_bus_get_minor(struct ndctl_bus *bus);
 const char *ndctl_bus_get_devname(struct ndctl_bus *bus);
diff --git a/lib/test-dpa-alloc.c b/lib/test-dpa-alloc.c
index f94838ac0b9b..9a881f301c7f 100644
--- a/lib/test-dpa-alloc.c
+++ b/lib/test-dpa-alloc.c
@@ -90,7 +90,7 @@  static int do_test(struct ndctl_ctx *ctx)
 	 * to lowest with no excursions into BLK only ranges.
 	 */
 	ndctl_region_foreach(bus, region) {
-		if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLOCK)
+		if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
 			continue;
 		dimm = ndctl_region_get_first_dimm(region);
 		if (!dimm)
diff --git a/lib/test-libndctl.c b/lib/test-libndctl.c
index 710aeb1f52b7..9e59861128bf 100644
--- a/lib/test-libndctl.c
+++ b/lib/test-libndctl.c
@@ -54,7 +54,7 @@ 
  *           +----------------------------+--------+--------+
  *
  * *) In this layout we have four dimms and two memory controllers in one
- *    socket.  Each unique interface ("block" or "pmem") to DPA space
+ *    socket.  Each unique interface ("blk" or "pmem") to DPA space
  *    is identified by a region device with a dynamically assigned id.
  *
  * *) The first portion of dimm0 and dimm1 are interleaved as REGION0.
@@ -185,7 +185,7 @@  static struct namespace namespace1_pmem0 = {
 };
 
 static struct namespace namespace2_blk0 = {
-	0, "namespace_block", NULL, SZ_7M,
+	0, "namespace_blk", NULL, SZ_7M,
 	{ 3, 3, 3, 3,
 	  3, 3, 3, 3,
 	  3, 3, 3, 3,
@@ -193,7 +193,7 @@  static struct namespace namespace2_blk0 = {
 };
 
 static struct namespace namespace2_blk1 = {
-	1, "namespace_block", NULL, SZ_11M,
+	1, "namespace_blk", NULL, SZ_11M,
 	{ 4, 4, 4, 4,
 	  4, 4, 4, 4,
 	  4, 4, 4, 4,
@@ -201,7 +201,7 @@  static struct namespace namespace2_blk1 = {
 };
 
 static struct namespace namespace3_blk0 = {
-	0, "namespace_block", NULL, SZ_7M,
+	0, "namespace_blk", NULL, SZ_7M,
 	{ 5, 5, 5, 5,
 	  5, 5, 5, 5,
 	  5, 5, 5, 5,
@@ -209,7 +209,7 @@  static struct namespace namespace3_blk0 = {
 };
 
 static struct namespace namespace3_blk1 = {
-	1, "namespace_block", NULL, SZ_11M,
+	1, "namespace_blk", NULL, SZ_11M,
 	{ 6, 6, 6, 6,
 	  6, 6, 6, 6,
 	  6, 6, 6, 6,
@@ -217,7 +217,7 @@  static struct namespace namespace3_blk1 = {
 };
 
 static struct namespace namespace4_blk0 = {
-	0, "namespace_block", &btt_settings, SZ_27M,
+	0, "namespace_blk", &btt_settings, SZ_27M,
 	{ 7, 7, 7, 7,
 	  7, 7, 7, 7,
 	  7, 7, 7, 7,
@@ -225,7 +225,7 @@  static struct namespace namespace4_blk0 = {
 };
 
 static struct namespace namespace5_blk0 = {
-	0, "namespace_block", &btt_settings, SZ_27M,
+	0, "namespace_blk", &btt_settings, SZ_27M,
 	{ 8, 8, 8, 8,
 	  8, 8, 8, 8,
 	  8, 8, 8, 8,
@@ -237,13 +237,13 @@  static struct region regions0[] = {
 		{ &namespace0_pmem0, NULL, }, },
 	{ { 2 }, 4, 1, "pmem", SZ_64M, SZ_64M, { 1 },
 		{ &namespace1_pmem0, NULL, }, },
-	{ { DIMM_HANDLE(0, 0, 0, 0, 0) }, 1, 1, "block", SZ_18M, SZ_32M, { },
+	{ { DIMM_HANDLE(0, 0, 0, 0, 0) }, 1, 1, "blk", SZ_18M, SZ_32M, { },
 		{ &namespace2_blk0, &namespace2_blk1, NULL, }, },
-	{ { DIMM_HANDLE(0, 0, 0, 0, 1) }, 1, 1, "block", SZ_18M, SZ_32M, { },
+	{ { DIMM_HANDLE(0, 0, 0, 0, 1) }, 1, 1, "blk", SZ_18M, SZ_32M, { },
 		{ &namespace3_blk0, &namespace3_blk1, NULL, }, },
-	{ { DIMM_HANDLE(0, 0, 1, 0, 0) }, 1, 1, "block", SZ_27M, SZ_32M, { },
+	{ { DIMM_HANDLE(0, 0, 1, 0, 0) }, 1, 1, "blk", SZ_27M, SZ_32M, { },
 		{ &namespace4_blk0, NULL, }, },
-	{ { DIMM_HANDLE(0, 0, 1, 0, 1) }, 1, 1, "block", SZ_27M, SZ_32M, { },
+	{ { DIMM_HANDLE(0, 0, 1, 0, 1) }, 1, 1, "blk", SZ_27M, SZ_32M, { },
 		{ &namespace5_blk0, NULL, }, },
 };
 
@@ -252,7 +252,7 @@  static struct namespace namespace1 = {
 };
 
 static struct region regions1[] = {
-	{ { 1 }, 0, 1, "pmem", 0, SZ_32M,
+	{ { 1 }, 1, 1, "pmem", 0, SZ_32M,
 		.namespaces = {
 			[0] = &namespace1,
 		},
@@ -267,9 +267,9 @@  static struct btt btts1[] = {
 	{ 0, { 0, }, 2, { 512, 4096, }, },
 };
 
-static unsigned long commands0 = 1UL << NFIT_CMD_GET_CONFIG_SIZE
-		| 1UL << NFIT_CMD_GET_CONFIG_DATA
-		| 1UL << NFIT_CMD_SET_CONFIG_DATA;
+static unsigned long commands0 = 1UL << ND_CMD_GET_CONFIG_SIZE
+		| 1UL << ND_CMD_GET_CONFIG_DATA
+		| 1UL << ND_CMD_SET_CONFIG_DATA;
 
 static struct ndctl_dimm *get_dimm_by_handle(struct ndctl_bus *bus, unsigned int handle)
 {
@@ -339,7 +339,7 @@  static struct ndctl_region *get_blk_region_by_dimm_handle(struct ndctl_bus *bus,
 	ndctl_region_foreach(bus, region) {
 		struct ndctl_mapping *map;
 
-		if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLOCK)
+		if (ndctl_region_get_type(region) != ND_DEVICE_REGION_BLK)
 			continue;
 		ndctl_mapping_foreach(region, map) {
 			struct ndctl_dimm *dimm = ndctl_mapping_get_dimm(map);
@@ -904,7 +904,7 @@  static int check_get_config_size(struct ndctl_dimm *dimm, struct check_cmd *chec
 
 static int check_get_config_data(struct ndctl_dimm *dimm, struct check_cmd *check)
 {
-	struct ndctl_cmd *cmd_size = check_cmds[NFIT_CMD_GET_CONFIG_SIZE].cmd;
+	struct ndctl_cmd *cmd_size = check_cmds[ND_CMD_GET_CONFIG_SIZE].cmd;
 	struct ndctl_cmd *cmd = ndctl_dimm_cmd_new_cfg_read(cmd_size);
 	static char buf[SZ_128K];
 	ssize_t rc;
@@ -937,7 +937,7 @@  static int check_get_config_data(struct ndctl_dimm *dimm, struct check_cmd *chec
 
 static int check_set_config_data(struct ndctl_dimm *dimm, struct check_cmd *check)
 {
-	struct ndctl_cmd *cmd_read = check_cmds[NFIT_CMD_GET_CONFIG_DATA].cmd;
+	struct ndctl_cmd *cmd_read = check_cmds[ND_CMD_GET_CONFIG_DATA].cmd;
 	struct ndctl_cmd *cmd = ndctl_dimm_cmd_new_cfg_write(cmd_read);
 	char buf[20], result[sizeof(buf)];
 	size_t rc;
@@ -1010,15 +1010,15 @@  static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 	 * For now, by coincidence, these are indexed in test execution
 	 * order such that check_get_config_data can assume that
 	 * check_get_config_size has updated
-	 * check_cmd[NFIT_CMD_GET_CONFIG_SIZE].cmd and
+	 * check_cmd[ND_CMD_GET_CONFIG_SIZE].cmd and
 	 * check_set_config_data can assume that both
 	 * check_get_config_size and check_get_config_data have run
 	 */
 	static struct check_cmd __check_cmds[] = {
-		[NFIT_CMD_GET_CONFIG_SIZE] = { check_get_config_size },
-		[NFIT_CMD_GET_CONFIG_DATA] = { check_get_config_data },
-		[NFIT_CMD_SET_CONFIG_DATA] = { check_set_config_data },
-		[NFIT_CMD_SMART_THRESHOLD] = { },
+		[ND_CMD_GET_CONFIG_SIZE] = { check_get_config_size },
+		[ND_CMD_GET_CONFIG_DATA] = { check_get_config_data },
+		[ND_CMD_SET_CONFIG_DATA] = { check_set_config_data },
+		[ND_CMD_SMART_THRESHOLD] = { },
 	};
 	unsigned int i, rc;
 
diff --git a/ndctl.h b/ndctl.h
index abddfdd2cfb4..baf1c506fee8 100644
--- a/ndctl.h
+++ b/ndctl.h
@@ -1,5 +1,5 @@ 
 /*
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2014-2015, Intel Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU Lesser General Public License,
@@ -15,60 +15,60 @@ 
 
 #include <linux/types.h>
 
-struct nfit_cmd_smart {
+struct nd_cmd_smart {
 	__u32 status;
 	__u8 data[128];
 } __attribute__((packed));
 
-struct nfit_cmd_smart_threshold {
+struct nd_cmd_smart_threshold {
 	__u32 status;
 	__u8 data[8];
 } __attribute__((packed));
 
-struct nfit_cmd_dimm_flags {
+struct nd_cmd_dimm_flags {
 	__u32 status;
 	__u32 flags;
 } __attribute__((packed));
 
-struct nfit_cmd_get_config_size {
+struct nd_cmd_get_config_size {
 	__u32 status;
 	__u32 config_size;
 	__u32 max_xfer;
 } __attribute__((packed));
 
-struct nfit_cmd_get_config_data_hdr {
+struct nd_cmd_get_config_data_hdr {
 	__u32 in_offset;
 	__u32 in_length;
 	__u32 status;
 	__u8 out_buf[0];
 } __attribute__((packed));
 
-struct nfit_cmd_set_config_hdr {
+struct nd_cmd_set_config_hdr {
 	__u32 in_offset;
 	__u32 in_length;
 	__u8 in_buf[0];
 } __attribute__((packed));
 
-struct nfit_cmd_vendor_hdr {
+struct nd_cmd_vendor_hdr {
 	__u32 opcode;
 	__u32 in_length;
 	__u8 in_buf[0];
 } __attribute__((packed));
 
-struct nfit_cmd_vendor_tail {
+struct nd_cmd_vendor_tail {
 	__u32 status;
 	__u32 out_length;
 	__u8 out_buf[0];
 } __attribute__((packed));
 
-struct nfit_cmd_ars_cap {
+struct nd_cmd_ars_cap {
 	__u64 address;
 	__u64 length;
 	__u32 status;
 	__u32 max_ars_out;
 } __attribute__((packed));
 
-struct nfit_cmd_ars_start {
+struct nd_cmd_ars_start {
 	__u64 address;
 	__u64 length;
 	__u16 type;
@@ -76,15 +76,15 @@  struct nfit_cmd_ars_start {
 	__u32 status;
 } __attribute__((packed));
 
-struct nfit_cmd_ars_query {
+struct nd_cmd_ars_query {
 	__u32 status;
-	__u16 out_length;
+	__u32 out_length;
 	__u64 address;
 	__u64 length;
 	__u16 type;
 	__u32 num_records;
-	struct nfit_ars_record {
-		__u32 nfit_handle;
+	struct nd_ars_record {
+		__u32 handle;
 		__u32 flags;
 		__u64 err_address;
 		__u64 mask;
@@ -92,31 +92,31 @@  struct nfit_cmd_ars_query {
 } __attribute__((packed));
 
 enum {
-	NFIT_CMD_IMPLEMENTED = 0,
+	ND_CMD_IMPLEMENTED = 0,
 
 	/* bus commands */
-	NFIT_CMD_ARS_CAP = 1,
-	NFIT_CMD_ARS_START = 2,
-	NFIT_CMD_ARS_QUERY = 3,
+	ND_CMD_ARS_CAP = 1,
+	ND_CMD_ARS_START = 2,
+	ND_CMD_ARS_QUERY = 3,
 
 	/* per-dimm commands */
-	NFIT_CMD_SMART = 1,
-	NFIT_CMD_SMART_THRESHOLD = 2,
-	NFIT_CMD_DIMM_FLAGS = 3,
-	NFIT_CMD_GET_CONFIG_SIZE = 4,
-	NFIT_CMD_GET_CONFIG_DATA = 5,
-	NFIT_CMD_SET_CONFIG_DATA = 6,
-	NFIT_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
-	NFIT_CMD_VENDOR_EFFECT_LOG = 8,
-	NFIT_CMD_VENDOR = 9,
+	ND_CMD_SMART = 1,
+	ND_CMD_SMART_THRESHOLD = 2,
+	ND_CMD_DIMM_FLAGS = 3,
+	ND_CMD_GET_CONFIG_SIZE = 4,
+	ND_CMD_GET_CONFIG_DATA = 5,
+	ND_CMD_SET_CONFIG_DATA = 6,
+	ND_CMD_VENDOR_EFFECT_LOG_SIZE = 7,
+	ND_CMD_VENDOR_EFFECT_LOG = 8,
+	ND_CMD_VENDOR = 9,
 };
 
-static __inline__ const char *nfit_bus_cmd_name(unsigned cmd)
+static __inline__ const char *nd_bus_cmd_name(unsigned cmd)
 {
-	static const char *names[] = {
-		[NFIT_CMD_ARS_CAP] = "ars_cap",
-		[NFIT_CMD_ARS_START] = "ars_start",
-		[NFIT_CMD_ARS_QUERY] = "ars_query",
+	static const char * const names[] = {
+		[ND_CMD_ARS_CAP] = "ars_cap",
+		[ND_CMD_ARS_START] = "ars_start",
+		[ND_CMD_ARS_QUERY] = "ars_query",
 	};
 
 	if (cmd < ARRAY_SIZE(names) && names[cmd])
@@ -124,18 +124,18 @@  static __inline__ const char *nfit_bus_cmd_name(unsigned cmd)
 	return "unknown";
 }
 
-static __inline__ const char *nfit_dimm_cmd_name(unsigned cmd)
+static __inline__ const char *nd_dimm_cmd_name(unsigned cmd)
 {
-	static const char *names[] = {
-		[NFIT_CMD_SMART] = "smart",
-		[NFIT_CMD_SMART_THRESHOLD] = "smart_thresh",
-		[NFIT_CMD_DIMM_FLAGS] = "flags",
-		[NFIT_CMD_GET_CONFIG_SIZE] = "get_size",
-		[NFIT_CMD_GET_CONFIG_DATA] = "get_data",
-		[NFIT_CMD_SET_CONFIG_DATA] = "set_data",
-		[NFIT_CMD_VENDOR_EFFECT_LOG_SIZE] = "effect_size",
-		[NFIT_CMD_VENDOR_EFFECT_LOG] = "effect_log",
-		[NFIT_CMD_VENDOR] = "vendor",
+	static const char * const names[] = {
+		[ND_CMD_SMART] = "smart",
+		[ND_CMD_SMART_THRESHOLD] = "smart_thresh",
+		[ND_CMD_DIMM_FLAGS] = "flags",
+		[ND_CMD_GET_CONFIG_SIZE] = "get_size",
+		[ND_CMD_GET_CONFIG_DATA] = "get_data",
+		[ND_CMD_SET_CONFIG_DATA] = "set_data",
+		[ND_CMD_VENDOR_EFFECT_LOG_SIZE] = "effect_size",
+		[ND_CMD_VENDOR_EFFECT_LOG] = "effect_log",
+		[ND_CMD_VENDOR] = "vendor",
 	};
 
 	if (cmd < ARRAY_SIZE(names) && names[cmd])
@@ -145,51 +145,51 @@  static __inline__ const char *nfit_dimm_cmd_name(unsigned cmd)
 
 #define ND_IOCTL 'N'
 
-#define NFIT_IOCTL_SMART		_IOWR(ND_IOCTL, NFIT_CMD_SMART,\
-					struct nfit_cmd_smart)
+#define ND_IOCTL_SMART			_IOWR(ND_IOCTL, ND_CMD_SMART,\
+					struct nd_cmd_smart)
 
-#define NFIT_IOCTL_SMART_THRESHOLD	_IOWR(ND_IOCTL, NFIT_CMD_SMART_THRESHOLD,\
-					struct nfit_cmd_smart_threshold)
+#define ND_IOCTL_SMART_THRESHOLD	_IOWR(ND_IOCTL, ND_CMD_SMART_THRESHOLD,\
+					struct nd_cmd_smart_threshold)
 
-#define NFIT_IOCTL_DIMM_FLAGS		_IOWR(ND_IOCTL, NFIT_CMD_DIMM_FLAGS,\
-					struct nfit_cmd_dimm_flags)
+#define ND_IOCTL_DIMM_FLAGS		_IOWR(ND_IOCTL, ND_CMD_DIMM_FLAGS,\
+					struct nd_cmd_dimm_flags)
 
-#define NFIT_IOCTL_GET_CONFIG_SIZE	_IOWR(ND_IOCTL, NFIT_CMD_GET_CONFIG_SIZE,\
-					struct nfit_cmd_get_config_size)
+#define ND_IOCTL_GET_CONFIG_SIZE	_IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_SIZE,\
+					struct nd_cmd_get_config_size)
 
-#define NFIT_IOCTL_GET_CONFIG_DATA	_IOWR(ND_IOCTL, NFIT_CMD_GET_CONFIG_DATA,\
-					struct nfit_cmd_get_config_data_hdr)
+#define ND_IOCTL_GET_CONFIG_DATA	_IOWR(ND_IOCTL, ND_CMD_GET_CONFIG_DATA,\
+					struct nd_cmd_get_config_data_hdr)
 
-#define NFIT_IOCTL_SET_CONFIG_DATA	_IOWR(ND_IOCTL, NFIT_CMD_SET_CONFIG_DATA,\
-					struct nfit_cmd_set_config_hdr)
+#define ND_IOCTL_SET_CONFIG_DATA	_IOWR(ND_IOCTL, ND_CMD_SET_CONFIG_DATA,\
+					struct nd_cmd_set_config_hdr)
 
-#define NFIT_IOCTL_VENDOR		_IOWR(ND_IOCTL, NFIT_CMD_VENDOR,\
-					struct nfit_cmd_vendor_hdr)
+#define ND_IOCTL_VENDOR			_IOWR(ND_IOCTL, ND_CMD_VENDOR,\
+					struct nd_cmd_vendor_hdr)
 
-#define NFIT_IOCTL_ARS_CAP		_IOWR(ND_IOCTL, NFIT_CMD_ARS_CAP,\
-					struct nfit_cmd_ars_cap)
+#define ND_IOCTL_ARS_CAP		_IOWR(ND_IOCTL, ND_CMD_ARS_CAP,\
+					struct nd_cmd_ars_cap)
 
-#define NFIT_IOCTL_ARS_START		_IOWR(ND_IOCTL, NFIT_CMD_ARS_START,\
-					struct nfit_cmd_ars_start)
+#define ND_IOCTL_ARS_START		_IOWR(ND_IOCTL, ND_CMD_ARS_START,\
+					struct nd_cmd_ars_start)
 
-#define NFIT_IOCTL_ARS_QUERY		_IOWR(ND_IOCTL, NFIT_CMD_ARS_QUERY,\
-					struct nfit_cmd_ars_query)
+#define ND_IOCTL_ARS_QUERY		_IOWR(ND_IOCTL, ND_CMD_ARS_QUERY,\
+					struct nd_cmd_ars_query)
 
 #define ND_DEVICE_DIMM 1            /* nd_dimm: container for "config data" */
 #define ND_DEVICE_REGION_PMEM 2     /* nd_region: (parent of pmem namespaces) */
-#define ND_DEVICE_REGION_BLOCK 3    /* nd_region: (parent of block namespaces) */
+#define ND_DEVICE_REGION_BLK 3      /* nd_region: (parent of blk namespaces) */
 #define ND_DEVICE_NAMESPACE_IO 4    /* legacy persistent memory */
 #define ND_DEVICE_NAMESPACE_PMEM 5  /* persistent memory namespace (may alias) */
-#define ND_DEVICE_NAMESPACE_BLOCK 6 /* block-data-window namespace (may alias) */
+#define ND_DEVICE_NAMESPACE_BLK 6   /* block-data-window namespace (may alias) */
 #define ND_DEVICE_BTT 7		    /* block-translation table device */
 
 enum nd_driver_flags {
 	ND_DRIVER_DIMM            = 1 << ND_DEVICE_DIMM,
 	ND_DRIVER_REGION_PMEM     = 1 << ND_DEVICE_REGION_PMEM,
-	ND_DRIVER_REGION_BLOCK    = 1 << ND_DEVICE_REGION_BLOCK,
+	ND_DRIVER_REGION_BLK      = 1 << ND_DEVICE_REGION_BLK,
 	ND_DRIVER_NAMESPACE_IO    = 1 << ND_DEVICE_NAMESPACE_IO,
 	ND_DRIVER_NAMESPACE_PMEM  = 1 << ND_DEVICE_NAMESPACE_PMEM,
-	ND_DRIVER_NAMESPACE_BLOCK = 1 << ND_DEVICE_NAMESPACE_BLOCK,
+	ND_DRIVER_NAMESPACE_BLK   = 1 << ND_DEVICE_NAMESPACE_BLK,
 	ND_DRIVER_BTT		  = 1 << ND_DEVICE_BTT,
 };