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@
This commit is contained in:
parent
850564b948
commit
519772814d
@ -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 */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
|
@ -1396,15 +1396,11 @@ passmemsetup(struct cam_periph *periph, struct pass_io_req *io_req)
|
||||
|
||||
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;
|
||||
|
@ -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 {
|
||||
|
||||
@ -517,6 +518,20 @@ nvme_allocate_request_bio(struct bio *bio, nvme_cb_fn_t cb_fn, void *cb_arg)
|
||||
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);
|
||||
}
|
||||
|
||||
#define nvme_free_request(req) uma_zfree(nvme_request_zone, req)
|
||||
|
||||
void nvme_notify_async_consumers(struct nvme_controller *ctrlr,
|
||||
|
@ -851,6 +851,14 @@ _nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req)
|
||||
"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;
|
||||
|
@ -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
|
||||
|
@ -225,7 +225,7 @@ _bus_dmamap_load_ccb(bus_dma_tag_t dmat, bus_dmamap_t map, union ccb *ccb,
|
||||
nvmeio = &ccb->nvmeio;
|
||||
data_ptr = nvmeio->data_ptr;
|
||||
dxfer_len = nvmeio->dxfer_len;
|
||||
sglist_cnt = 0;
|
||||
sglist_cnt = nvmeio->sglist_cnt;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user