git: acbc176c3dfd - main - nvmecontrol: Display additional Fabrics-related fields for cdata

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Sat, 23 Mar 2024 00:25:41 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=acbc176c3dfdfebd047507dc7d843f8cc10984a8

commit acbc176c3dfdfebd047507dc7d843f8cc10984a8
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-03-23 00:25:07 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-03-23 00:25:07 +0000

    nvmecontrol: Display additional Fabrics-related fields for cdata
    
    Some of these fields are specific to Fabrics controllers (such as the
    size of capsules) while other fields are shared with PCI-e
    controllers, but are more relevant for Fabrics controllers (such as
    KeepAlive timer properties).
    
    Reviewed by:    imp
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D44449
---
 sbin/nvmecontrol/identify_ext.c | 51 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/sbin/nvmecontrol/identify_ext.c b/sbin/nvmecontrol/identify_ext.c
index e4126da2d685..95ca4b5187d4 100644
--- a/sbin/nvmecontrol/identify_ext.c
+++ b/sbin/nvmecontrol/identify_ext.c
@@ -138,6 +138,36 @@ nvme_print_controller(struct nvme_controller_data *cdata)
 	printf("Version:                     %d.%d.%d\n",
 	    (cdata->ver >> 16) & 0xffff, (cdata->ver >> 8) & 0xff,
 	    cdata->ver & 0xff);
+	printf("Traffic Based Keep Alive:    %sSupported\n",
+	    NVMEV(NVME_CTRLR_DATA_CTRATT_TBKAS, cdata->ctratt) ? "" : "Not ");
+	printf("Controller Type:             ");
+	switch (cdata->cntrltype) {
+	case 0:
+		printf("Not Reported\n");
+		break;
+	case 1:
+		printf("I/O Controller\n");
+		break;
+	case 2:
+		printf("Discovery Controller\n");
+		break;
+	case 3:
+		printf("Administrative Controller\n");
+		break;
+	default:
+		printf("%d (Reserved)\n", cdata->cntrltype);
+		break;
+	}
+	printf("Keep Alive Timer             ");
+	if (cdata->kas == 0)
+		printf("Not Supported\n");
+	else
+		printf("%u ms granularity\n", cdata->kas * 100);
+	printf("Maximum Outstanding Commands ");
+	if (cdata->maxcmd == 0)
+		printf("Not Specified\n");
+	else
+		printf("%u\n", cdata->maxcmd);
 	printf("\n");
 
 	printf("Admin Command Set Attributes\n");
@@ -248,4 +278,25 @@ nvme_print_controller(struct nvme_controller_data *cdata)
 
 	if (cdata->ver >= 0x010201)
 		printf("\nNVM Subsystem Name:          %.256s\n", cdata->subnqn);
+
+	if (cdata->ioccsz != 0) {
+		printf("\n");
+		printf("Fabrics Attributes\n");
+		printf("==================\n");
+		printf("I/O Command Capsule Size:    %d bytes\n",
+		    cdata->ioccsz * 16);
+		printf("I/O Response Capsule Size:   %d bytes\n",
+		    cdata->iorcsz * 16);
+		printf("In Capsule Data Offset:      %d bytes\n",
+		    cdata->icdoff * 16);
+		printf("Controller Model:            %s\n",
+		    (cdata->fcatt & 1) == 0 ? "Dynamic" : "Static");
+		printf("Max SGL Descriptors:         ");
+		if (cdata->msdbd == 0)
+			printf("Unlimited\n");
+		else
+			printf("%d\n", cdata->msdbd);
+		printf("Disconnect of I/O Queues:    %sSupported\n",
+		    (cdata->ofcs & 1) == 1 ? "" : "Not ");
+	}
 }