Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jan 2014 23:51:26 +0000 (UTC)
From:      Jim Harris <jimharris@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r260382 - head/sys/dev/nvme
Message-ID:  <201401062351.s06NpQoL008471@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jimharris
Date: Mon Jan  6 23:51:26 2014
New Revision: 260382
URL: http://svnweb.freebsd.org/changeset/base/260382

Log:
  For IDENTIFY passthrough commands to Chatham prototype controllers, copy
  the spoofed identify data into the user buffer rather than issuing the
  command to the controller, since Chatham IDENTIFY data is always spoofed.
  
  While here, fix a bug in the spoofed data for Chatham submission and
  completion queue entry sizes.
  
  Sponsored by:	Intel
  MFC after:	3 days

Modified:
  head/sys/dev/nvme/nvme_ctrlr.c

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==============================================================================
--- head/sys/dev/nvme/nvme_ctrlr.c	Mon Jan  6 23:48:47 2014	(r260381)
+++ head/sys/dev/nvme/nvme_ctrlr.c	Mon Jan  6 23:51:26 2014	(r260382)
@@ -181,8 +181,8 @@ nvme_chatham_populate_cdata(struct nvme_
 	cdata->lpa.ns_smart = 1;
 	cdata->sqes.min = 6;
 	cdata->sqes.max = 6;
-	cdata->sqes.min = 4;
-	cdata->sqes.max = 4;
+	cdata->cqes.min = 4;
+	cdata->cqes.max = 4;
 	cdata->nn = 1;
 
 	/* Chatham2 doesn't support DSM command */
@@ -1041,6 +1041,27 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_lo
 		break;
 	case NVME_PASSTHROUGH_CMD:
 		pt = (struct nvme_pt_command *)arg;
+#ifdef CHATHAM2
+		/*
+		 * Chatham IDENTIFY data is spoofed, so copy the spoofed data
+		 *  rather than issuing the command to the Chatham controller.
+		 */
+		if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID &&
+                    pt->cmd.opc == NVME_OPC_IDENTIFY) {
+			if (pt->cmd.cdw10 == 1) {
+                        	if (pt->len != sizeof(ctrlr->cdata))
+                                	return (EINVAL);
+                        	return (copyout(&ctrlr->cdata, pt->buf,
+				    pt->len));
+			} else {
+				if (pt->len != sizeof(ctrlr->ns[0].data) ||
+				    pt->cmd.nsid != 1)
+					return (EINVAL);
+				return (copyout(&ctrlr->ns[0].data, pt->buf,
+				    pt->len));
+			}
+		}
+#endif
 		return (nvme_ctrlr_passthrough_cmd(ctrlr, pt, pt->cmd.nsid,
 		    1 /* is_user_buffer */, 1 /* is_admin_cmd */));
 	default:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401062351.s06NpQoL008471>