lib/nvmf/vfio_user.c
/*
 * Map an I/O command's buffers.
 *
 * Returns 0 on success and -errno on failure.
 */
Map an I/O command's buffers.
Returns 0 on success and -errno on failure.
Map an I / O command ' s buffers . Returns 0 on success and - errno on failure .
static int
map_io_cmd_req(struct nvmf_vfio_user_ctrlr *ctrlr, struct spdk_nvmf_request *req)
{
	int len, iovcnt;
	struct spdk_nvme_cmd *cmd;
	assert(ctrlr != NULL);
	assert(req != NULL);
	cmd = &req->cmd->nvme_cmd;
	req->xfer = spdk_nvme_opc_get_data_transfer(cmd->opc);
	req->length = 0;
	req->data = NULL;
	if (spdk_unlikely(req->xfer == SPDK_NVME_DATA_NONE)) {
		return 0;
	}
	len = get_nvmf_io_req_length(req);
	if (len < 0) {
		return -EINVAL;
	}
	req->length = len;
	iovcnt = vfio_user_map_cmd(ctrlr, req, req->iov, req->length);
	if (iovcnt < 0) {
		SPDK_ERRLOG("%s: failed to map IO OPC %u\n", ctrlr_id(ctrlr), cmd->opc);
		return -EFAULT;
	}
	req->data = req->iov[0].iov_base;
	req->iovcnt = iovcnt;
	return 0;
}
static int map_io_cmd_req ( struct nvmf_vfio_user_ctrlr * ctrlr , struct spdk_nvmf_request * req ) { int len , iovcnt ; struct spdk_nvme_cmd * cmd ; assert ( ctrlr != NULL ) ; assert ( req != NULL ) ; cmd = & req -> cmd -> nvme_cmd ; req -> xfer = spdk_nvme_opc_get_data_transfer ( cmd -> opc ) ; req -> length = 0 ; req -> data = NULL ; if ( spdk_unlikely ( req -> xfer == SPDK_NVME_DATA_NONE ) ) { return 0 ; } len = get_nvmf_io_req_length ( req ) ; if ( len < 0 ) { return - EINVAL ; } req -> length = len ; iovcnt = vfio_user_map_cmd ( ctrlr , req , req -> iov , req -> length ) ; if ( iovcnt < 0 ) { SPDK_ERRLOG ( " \n " , ctrlr_id ( ctrlr ) , cmd -> opc ) ; return - EFAULT ; } req -> data = req -> iov [ 0 ] . iov_base ; req -> iovcnt = iovcnt ; return 0 ; }
Map an I/O command's buffers.
Map an I / O command ' s buffers .