Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Mar 2018 18:43:41 +0000 (UTC)
From:      Marcin Wojtas <mw@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r463911 - head/sysutils/smartmontools/files
Message-ID:  <201803081843.w28IhfiV001931@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mw (src committer)
Date: Thu Mar  8 18:43:41 2018
New Revision: 463911
URL: https://svnweb.freebsd.org/changeset/ports/463911

Log:
  Display NVMe data properly on Big Endian hosts with sysutils/smartmontools
  
  smartctl can now be used with NVMe drives on BE hosts.
  
  Submitted by: Michal Stanek <mst@semihalf.com>
  Reviewed by: cy
  Obtained from: Semihalf
  Sponsored by: IBM, QCM Technologies
  Differential Revision: https://reviews.freebsd.org/D14543

Modified:
  head/sysutils/smartmontools/files/patch-os__freebsd.cpp

Modified: head/sysutils/smartmontools/files/patch-os__freebsd.cpp
==============================================================================
--- head/sysutils/smartmontools/files/patch-os__freebsd.cpp	Thu Mar  8 18:34:26 2018	(r463910)
+++ head/sysutils/smartmontools/files/patch-os__freebsd.cpp	Thu Mar  8 18:43:41 2018	(r463911)
@@ -1,14 +1,15 @@
 --- os_freebsd.cpp.orig	2017-04-24 09:34:16.000000000 -0700
-+++ os_freebsd.cpp	2018-02-22 23:01:44.118712000 -0800
-@@ -15,6 +15,7 @@
-  *
++++ os_freebsd.cpp	2018-02-27 19:15:54.338861000 +0000
+@@ -16,6 +16,8 @@
   */
  
-+#include <sys/param.h>
  #include <stdio.h>
++#include <sys/endian.h>
++#include <sys/param.h>
  #include <sys/types.h>
  #include <dirent.h>
-@@ -484,7 +485,7 @@
+ #include <fcntl.h>
+@@ -484,7 +486,7 @@
    	}
    	nsid = 0xFFFFFFFF; // broadcast id
    }
@@ -17,16 +18,41 @@
    	&ctrlid, &nsid, &tmp) == 2) 
    {
    	if(ctrlid < 0 || nsid < 0) {
-@@ -521,7 +522,11 @@
+@@ -521,16 +523,20 @@
    struct nvme_pt_command pt;
    memset(&pt, 0, sizeof(pt));
  
--  pt.cmd.opc = in.opcode;
 +#if __FreeBSD_version >= 1200058
 +  pt.cmd.opc_fuse = NVME_CMD_SET_OPC(in.opcode);
 +#else
-+  pt.cmd.opc = in.opcode;
+   pt.cmd.opc = in.opcode;
 +#endif
-   pt.cmd.nsid = in.nsid;
+-  pt.cmd.nsid = in.nsid;
++  pt.cmd.nsid = htole32(in.nsid);
    pt.buf = in.buffer;
    pt.len = in.size;
+-  pt.cmd.cdw10 = in.cdw10;
+-  pt.cmd.cdw11 = in.cdw11;
+-  pt.cmd.cdw12 = in.cdw12;
+-  pt.cmd.cdw13 = in.cdw13;
+-  pt.cmd.cdw14 = in.cdw14;
+-  pt.cmd.cdw15 = in.cdw15;
++  pt.cmd.cdw10 = htole32(in.cdw10);
++  pt.cmd.cdw11 = htole32(in.cdw11);
++  pt.cmd.cdw12 = htole32(in.cdw12);
++  pt.cmd.cdw13 = htole32(in.cdw13);
++  pt.cmd.cdw14 = htole32(in.cdw14);
++  pt.cmd.cdw15 = htole32(in.cdw15);
+   pt.is_read = 1; // should we use in.direction()?
+   
+   int status = ioctl(get_fd(), NVME_PASSTHROUGH_CMD, &pt);
+@@ -538,6 +544,9 @@
+   if (status < 0)
+     return set_err(errno, "NVME_PASSTHROUGH_CMD: %s", strerror(errno));
+ 
++#if __FreeBSD_version >= 1200058
++  nvme_completion_swapbytes(&pt.cpl);
++#endif
+   out.result=pt.cpl.cdw0; // Command specific result (DW0)
+ 
+   if (nvme_completion_is_error(&pt.cpl))



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