aboutsummaryrefslogtreecommitdiffstats
path: root/sys/cam/nvme/nvme_da.c
diff options
context:
space:
mode:
authorWojciech Macek <wma@FreeBSD.org>2018-02-22 13:32:31 +0000
committerWojciech Macek <wma@FreeBSD.org>2018-02-22 13:32:31 +0000
commit0d787e9b35c2fc01e724f06b4eda2807774e7f4e (patch)
tree7d726d1f69ac9c9898d000ebe2371389a02be550 /sys/cam/nvme/nvme_da.c
parentde2cb430adf18cf00184df694fc62e0eab9dfabe (diff)
downloadsrc-0d787e9b35c2fc01e724f06b4eda2807774e7f4e.tar.gz
src-0d787e9b35c2fc01e724f06b4eda2807774e7f4e.zip
NVMe: Add big-endian support
Remove bitfields from defined structures as they are not portable. Instead use shift and mask macros in the driver and nvmecontrol application. NVMe is now working on powerpc64 host. Submitted by: Michal Stanek <mst@semihalf.com> Obtained from: Semihalf Reviewed by: imp, wma Sponsored by: IBM, QCM Technologies Differential revision: https://reviews.freebsd.org/D13916
Notes
Notes: svn path=/head/; revision=329824
Diffstat (limited to 'sys/cam/nvme/nvme_da.c')
-rw-r--r--sys/cam/nvme/nvme_da.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 1afe840b733e..0cd4cc4b9512 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -676,6 +676,7 @@ ndaregister(struct cam_periph *periph, void *arg)
const struct nvme_namespace_data *nsd;
const struct nvme_controller_data *cd;
char announce_buf[80];
+ uint8_t flbas_fmt, lbads, vwc_present;
u_int maxio;
int quirks;
@@ -744,13 +745,19 @@ ndaregister(struct cam_periph *periph, void *arg)
else if (maxio > MAXPHYS)
maxio = MAXPHYS; /* for safety */
disk->d_maxsize = maxio;
- disk->d_sectorsize = 1 << nsd->lbaf[nsd->flbas.format].lbads;
+ flbas_fmt = (nsd->flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) &
+ NVME_NS_DATA_FLBAS_FORMAT_MASK;
+ lbads = (nsd->lbaf[flbas_fmt] >> NVME_NS_DATA_LBAF_LBADS_SHIFT) &
+ NVME_NS_DATA_LBAF_LBADS_MASK;
+ disk->d_sectorsize = 1 << lbads;
disk->d_mediasize = (off_t)(disk->d_sectorsize * nsd->nsze);
disk->d_delmaxsize = disk->d_mediasize;
disk->d_flags = DISKFLAG_DIRECT_COMPLETION;
// if (cd->oncs.dsm) // XXX broken?
disk->d_flags |= DISKFLAG_CANDELETE;
- if (cd->vwc.present)
+ vwc_present = (cd->vwc >> NVME_CTRLR_DATA_VWC_PRESENT_SHIFT) &
+ NVME_CTRLR_DATA_VWC_PRESENT_MASK;
+ if (vwc_present)
disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
if ((cpi.hba_misc & PIM_UNMAPPED) != 0) {
disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
@@ -905,9 +912,9 @@ ndastart(struct cam_periph *periph, union ccb *start_ccb)
return;
}
dsm_range->length =
- bp->bio_bcount / softc->disk->d_sectorsize;
+ htole32(bp->bio_bcount / softc->disk->d_sectorsize);
dsm_range->starting_lba =
- bp->bio_offset / softc->disk->d_sectorsize;
+ htole64(bp->bio_offset / softc->disk->d_sectorsize);
bp->bio_driver2 = dsm_range;
nda_nvme_trim(softc, &start_ccb->nvmeio, dsm_range, 1);
start_ccb->ccb_h.ccb_state = NDA_CCB_TRIM;