svn commit: r322997 - in head/sys: cam cam/nvme cam/scsi dev/nvme kern
Warner Losh
imp at FreeBSD.org
Tue Aug 29 15:29:59 UTC 2017
Author: imp
Date: Tue Aug 29 15:29:57 2017
New Revision: 322997
URL: https://svnweb.freebsd.org/changeset/base/322997
Log:
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.
Differential Revision: https://reviews.freebsd.org/D11361
Submitted by: Chuck Tuffli
Reviewed by: imp@, scottl@, kenm@
Modified:
head/sys/cam/cam_ccb.h
head/sys/cam/nvme/nvme_da.c
head/sys/cam/scsi/scsi_pass.c
head/sys/dev/nvme/nvme_private.h
head/sys/dev/nvme/nvme_qpair.c
head/sys/dev/nvme/nvme_sim.c
head/sys/kern/subr_bus_dma.c
Modified: head/sys/cam/cam_ccb.h
==============================================================================
--- head/sys/cam/cam_ccb.h Tue Aug 29 07:01:15 2017 (r322996)
+++ head/sys/cam/cam_ccb.h Tue Aug 29 15:29:57 2017 (r322997)
@@ -831,7 +831,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: head/sys/cam/nvme/nvme_da.c
==============================================================================
--- head/sys/cam/nvme/nvme_da.c Tue Aug 29 07:01:15 2017 (r322996)
+++ head/sys/cam/nvme/nvme_da.c Tue Aug 29 15:29:57 2017 (r322997)
@@ -1010,12 +1010,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: head/sys/cam/scsi/scsi_pass.c
==============================================================================
--- head/sys/cam/scsi/scsi_pass.c Tue Aug 29 07:01:15 2017 (r322996)
+++ head/sys/cam/scsi/scsi_pass.c Tue Aug 29 15:29:57 2017 (r322997)
@@ -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: head/sys/dev/nvme/nvme_private.h
==============================================================================
--- head/sys/dev/nvme/nvme_private.h Tue Aug 29 07:01:15 2017 (r322996)
+++ head/sys/dev/nvme/nvme_private.h Tue Aug 29 15:29:57 2017 (r322997)
@@ -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: head/sys/dev/nvme/nvme_qpair.c
==============================================================================
--- head/sys/dev/nvme/nvme_qpair.c Tue Aug 29 07:01:15 2017 (r322996)
+++ head/sys/dev/nvme/nvme_qpair.c Tue Aug 29 15:29:57 2017 (r322997)
@@ -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: head/sys/dev/nvme/nvme_sim.c
==============================================================================
--- head/sys/dev/nvme/nvme_sim.c Tue Aug 29 07:01:15 2017 (r322996)
+++ head/sys/dev/nvme/nvme_sim.c Tue Aug 29 15:29:57 2017 (r322997)
@@ -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: head/sys/kern/subr_bus_dma.c
==============================================================================
--- head/sys/kern/subr_bus_dma.c Tue Aug 29 07:01:15 2017 (r322996)
+++ head/sys/kern/subr_bus_dma.c Tue Aug 29 15:29:57 2017 (r322997)
@@ -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:
More information about the svn-src-all
mailing list