Commit 183ac888 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

external_code/identify: print controller identify data



The application will now print some of the fields from the identify
controller data.

The code has been copied from `examples/nvme/identify`, but, for the
sake of simplicity, trimmed down to printing reduced number of fields.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I838c47deffb0b877344f3cad0e88b6aca19790ea
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6678


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent e4d271f3
Loading
Loading
Loading
Loading
+63 −4
Original line number Diff line number Diff line
@@ -35,12 +35,71 @@
#include "nvme.h"

static void
print_controller(const struct spdk_pci_addr *addr)
print_ascii_string(const void *buf, size_t size)
{
	const uint8_t *str = buf;

	/* Trim trailing spaces */
	while (size > 0 && str[size - 1] == ' ') {
		size--;
	}

	while (size--) {
		if (*str >= 0x20 && *str <= 0x7E) {
			printf("%c", *str);
		} else {
			printf(".");
		}
		str++;
	}
}

static void
print_controller(struct nvme_ctrlr *ctrlr, const struct spdk_pci_addr *addr)
{
	const struct spdk_nvme_ctrlr_data *cdata;
	char fmtaddr[32] = {};

	cdata = nvme_ctrlr_get_data(ctrlr);
	spdk_pci_addr_fmt(fmtaddr, sizeof(fmtaddr), addr);
	printf("Found NVMe controller at: %s\n", fmtaddr);

	printf("=====================================================\n");
	printf("NVMe Controller at %s\n", fmtaddr);
	printf("=====================================================\n");
	printf("Vendor ID:                             %04x\n", cdata->vid);
	printf("Subsystem Vendor ID:                   %04x\n", cdata->ssvid);
	printf("Serial Number:                         ");
	print_ascii_string(cdata->sn, sizeof(cdata->sn));
	printf("\n");
	printf("Model Number:                          ");
	print_ascii_string(cdata->mn, sizeof(cdata->mn));
	printf("\n");
	printf("Firmware Version:                      ");
	print_ascii_string(cdata->fr, sizeof(cdata->fr));
	printf("\n");
	printf("Recommended Arb Burst:                 %d\n", cdata->rab);
	printf("IEEE OUI Identifier:                   %02x %02x %02x\n",
	       cdata->ieee[0], cdata->ieee[1], cdata->ieee[2]);
	printf("Multi-path I/O\n");
	printf("  May have multiple subsystem ports:   %s\n", cdata->cmic.multi_port ? "Yes" : "No");
	printf("  May be connected to multiple hosts:  %s\n", cdata->cmic.multi_host ? "Yes" : "No");
	printf("  Associated with SR-IOV VF:           %s\n", cdata->cmic.sr_iov ? "Yes" : "No");
	printf("Max Number of Namespaces:              %d\n", cdata->nn);
	if (cdata->ver.raw != 0) {
		printf("NVMe Specification Version (Identify): %u.%u",
		       cdata->ver.bits.mjr, cdata->ver.bits.mnr);
		if (cdata->ver.bits.ter) {
			printf(".%u", cdata->ver.bits.ter);
		}
		printf("\n");
	}
	printf("Optional Asynchronous Events Supported\n");
	printf("  Namespace Attribute Notices:         %s\n",
	       cdata->oaes.ns_attribute_notices ? "Supported" : "Not Supported");
	printf("  Firmware Activation Notices:         %s\n",
	       cdata->oaes.fw_activation_notices ? "Supported" : "Not Supported");
	printf("128-bit Host Identifier:               %s\n",
	       cdata->ctratt.host_id_exhid_supported ? "Supported" : "Not Supported");
}

static void
@@ -49,7 +108,7 @@ attach_cb(void *cb_ctx, const struct spdk_pci_addr *addr,
{
	(void)cb_ctx;

	print_controller(addr);
	print_controller(ctrlr, addr);
	nvme_detach(ctrlr);
}

@@ -83,7 +142,7 @@ main(int argc, const char **argv)
			return 1;
		}

		print_controller(&addr);
		print_controller(ctrlr, &addr);
		nvme_detach(ctrlr);
	} else if (argc == 1) {
		rc = nvme_probe(attach_cb, NULL);