Date: Thu, 1 Feb 2018 18:57:10 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328696 - in stable/11/sys: cam cam/nvme cam/scsi dev/nvme kern Message-ID: <201802011857.w11IvAgU001015@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Thu Feb 1 18:57:10 2018 New Revision: 328696 URL: https://svnweb.freebsd.org/changeset/base/328696 Log: MFC r322997: Add CAM/NVMe support for CAM_DATA_SG This adds support in pass(4) for data to be described with a scatter-gather list (sglist) to augment the existing (single) virtual address. Modified: stable/11/sys/cam/cam_ccb.h stable/11/sys/cam/nvme/nvme_da.c stable/11/sys/cam/scsi/scsi_pass.c stable/11/sys/dev/nvme/nvme_private.h stable/11/sys/dev/nvme/nvme_qpair.c stable/11/sys/dev/nvme/nvme_sim.c stable/11/sys/kern/subr_bus_dma.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_ccb.h ============================================================================== --- stable/11/sys/cam/cam_ccb.h Thu Feb 1 17:59:14 2018 (r328695) +++ stable/11/sys/cam/cam_ccb.h Thu Feb 1 18:57:10 2018 (r328696) @@ -813,7 +813,8 @@ struct ccb_nvmeio { struct nvme_completion cpl; /* NVME completion, per NVME standard */ uint8_t *data_ptr; /* Ptr to the data buf/SG list */ uint32_t dxfer_len; /* Data transfer length */ - uint32_t resid; /* Transfer residual length: 2's comp unused ?*/ + uint16_t sglist_cnt; /* Number of SG list entries */ + uint16_t unused; /* padding for removed uint32_t */ }; /* Modified: stable/11/sys/cam/nvme/nvme_da.c ============================================================================== --- stable/11/sys/cam/nvme/nvme_da.c Thu Feb 1 17:59:14 2018 (r328695) +++ stable/11/sys/cam/nvme/nvme_da.c Thu Feb 1 18:57:10 2018 (r328696) @@ -1006,12 +1006,7 @@ ndadone(struct cam_periph *periph, union ccb *done_ccb bp->bio_resid = bp->bio_bcount; bp->bio_flags |= BIO_ERROR; } else { - if (state == NDA_CCB_TRIM) - bp->bio_resid = 0; - else - bp->bio_resid = nvmeio->resid; - if (bp->bio_resid > 0) - bp->bio_flags |= BIO_ERROR; + bp->bio_resid = 0; } if (state == NDA_CCB_TRIM) free(bp->bio_driver2, M_NVMEDA); Modified: stable/11/sys/cam/scsi/scsi_pass.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_pass.c Thu Feb 1 17:59:14 2018 (r328695) +++ stable/11/sys/cam/scsi/scsi_pass.c Thu Feb 1 18:57:10 2018 (r328696) @@ -1396,15 +1396,11 @@ passmemsetup(struct cam_periph *periph, struct pass_io io_req->data_flags = ccb->ccb_h.flags & CAM_DATA_MASK; - /* - * We only support a single virtual address for NVMe - */ - if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR) - return (EINVAL); - data_ptrs[0] = &ccb->nvmeio.data_ptr; lengths[0] = ccb->nvmeio.dxfer_len; dirs[0] = ccb->ccb_h.flags & CAM_DIR_MASK; + num_segs = ccb->nvmeio.sglist_cnt; + seg_cnt_ptr = &ccb->nvmeio.sglist_cnt; numbufs = 1; maxmap = softc->maxio; break; Modified: stable/11/sys/dev/nvme/nvme_private.h ============================================================================== --- stable/11/sys/dev/nvme/nvme_private.h Thu Feb 1 17:59:14 2018 (r328695) +++ stable/11/sys/dev/nvme/nvme_private.h Thu Feb 1 18:57:10 2018 (r328696) @@ -135,6 +135,7 @@ struct nvme_completion_poll_status { #ifdef NVME_UNMAPPED_BIO_SUPPORT #define NVME_REQUEST_BIO 4 #endif +#define NVME_REQUEST_CCB 5 struct nvme_request { @@ -514,6 +515,20 @@ nvme_allocate_request_bio(struct bio *bio, nvme_cb_fn_ req->payload_size = bio->bio_bcount; #endif } + return (req); +} + +static __inline struct nvme_request * +nvme_allocate_request_ccb(union ccb *ccb, nvme_cb_fn_t cb_fn, void *cb_arg) +{ + struct nvme_request *req; + + req = _nvme_allocate_request(cb_fn, cb_arg); + if (req != NULL) { + req->type = NVME_REQUEST_CCB; + req->u.payload = ccb; + } + return (req); } Modified: stable/11/sys/dev/nvme/nvme_qpair.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_qpair.c Thu Feb 1 17:59:14 2018 (r328695) +++ stable/11/sys/dev/nvme/nvme_qpair.c Thu Feb 1 18:57:10 2018 (r328696) @@ -851,6 +851,14 @@ _nvme_qpair_submit_request(struct nvme_qpair *qpair, s "bus_dmamap_load_bio returned 0x%x!\n", err); break; #endif + case NVME_REQUEST_CCB: + err = bus_dmamap_load_ccb(tr->qpair->dma_tag_payload, + tr->payload_dma_map, req->u.payload, + nvme_payload_map, tr, 0); + if (err != 0) + nvme_printf(qpair->ctrlr, + "bus_dmamap_load_ccb returned 0x%x!\n", err); + break; default: panic("unknown nvme request type 0x%x\n", req->type); break; Modified: stable/11/sys/dev/nvme/nvme_sim.c ============================================================================== --- stable/11/sys/dev/nvme/nvme_sim.c Thu Feb 1 17:59:14 2018 (r328695) +++ stable/11/sys/dev/nvme/nvme_sim.c Thu Feb 1 18:57:10 2018 (r328696) @@ -96,6 +96,8 @@ nvme_sim_nvmeio(struct cam_sim *sim, union ccb *ccb) if ((nvmeio->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_BIO) req = nvme_allocate_request_bio((struct bio *)payload, nvme_sim_nvmeio_done, ccb); + else if ((nvmeio->ccb_h.flags & CAM_DATA_SG) == CAM_DATA_SG) + req = nvme_allocate_request_ccb(ccb, nvme_sim_nvmeio_done, ccb); else if (payload == NULL) req = nvme_allocate_request_null(nvme_sim_nvmeio_done, ccb); else Modified: stable/11/sys/kern/subr_bus_dma.c ============================================================================== --- stable/11/sys/kern/subr_bus_dma.c Thu Feb 1 17:59:14 2018 (r328695) +++ stable/11/sys/kern/subr_bus_dma.c Thu Feb 1 18:57:10 2018 (r328696) @@ -225,7 +225,7 @@ _bus_dmamap_load_ccb(bus_dma_tag_t dmat, bus_dmamap_t nvmeio = &ccb->nvmeio; data_ptr = nvmeio->data_ptr; dxfer_len = nvmeio->dxfer_len; - sglist_cnt = 0; + sglist_cnt = nvmeio->sglist_cnt; break; } default:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802011857.w11IvAgU001015>