2 ===================================================================
3 --- os_freebsd.cpp.orig 2018-12-05 18:30:46 UTC
9 +#include <sys/endian.h>
11 #include <sys/types.h>
13 @@ -522,29 +523,29 @@ bool freebsd_nvme_device::nvme_pass_through(const nvme
14 pt.cmd.opc = in.opcode;
16 pt.cmd.opc = in.opcode;
17 - pt.cmd.nsid = in.nsid;
18 + pt.cmd.nsid = htole32(in.nsid);
21 - pt.cmd.cdw10 = in.cdw10;
22 - pt.cmd.cdw11 = in.cdw11;
23 - pt.cmd.cdw12 = in.cdw12;
24 - pt.cmd.cdw13 = in.cdw13;
25 - pt.cmd.cdw14 = in.cdw14;
26 - pt.cmd.cdw15 = in.cdw15;
27 + pt.cmd.cdw10 = htole32(in.cdw10);
28 + pt.cmd.cdw11 = htole32(in.cdw11);
29 + pt.cmd.cdw12 = htole32(in.cdw12);
30 + pt.cmd.cdw13 = htole32(in.cdw13);
31 + pt.cmd.cdw14 = htole32(in.cdw14);
32 + pt.cmd.cdw15 = htole32(in.cdw15);
33 pt.is_read = 1; // should we use in.direction()?
35 int status = ioctl(get_fd(), NVME_PASSTHROUGH_CMD, &pt);
38 return set_err(errno, "NVME_PASSTHROUGH_CMD: %s", strerror(errno));
40 +#if __FreeBSD_version >= 1200058
41 + nvme_completion_swapbytes(&pt.cpl);
44 out.result=cp_p->cdw0; // Command specific result (DW0)
46 if (nvme_completion_is_error(cp_p)) { /* ignore DNR and More bits */
47 - uint16_t nvme_status = ((cp_p->status.sct << 8) | cp_p->status.sc) & 0x3ff;
49 - return set_nvme_err(out, nvme_status);
50 + return set_nvme_err(out, nvme_completion_is_error(&pt.cpl));