Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Dec 2022 17:14:37 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7467a6953683 - main - CTL: Allow userland supply tags via ioctl frontend.
Message-ID:  <202212031714.2B3HEbAF007363@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=7467a6953683b439f7b31c2b42533cb893ed6be3

commit 7467a6953683b439f7b31c2b42533cb893ed6be3
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-12-03 17:05:05 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-12-03 17:05:05 +0000

    CTL: Allow userland supply tags via ioctl frontend.
    
    Before this ioctl frontend always replaced tags with sequential ones.
    It was done for ctladm, that can not keep track of global tag list.
    But in case of virtio-scsi in bhyve we can pass provided tags as-is.
    It should be on virtio-scsi initiator to provide us valid tags.  It
    should allow proper task management, error reporting, etc.  In case
    of several virtio-scsi devices, they should use different CTL ports
    or initiator IDs to avoid conflicts, but this is expected by design.
    
    PR:     267539
---
 sys/cam/ctl/ctl_frontend_ioctl.c | 5 +++--
 sys/cam/ctl/ctl_io.h             | 2 +-
 usr.sbin/bhyve/pci_virtio_scsi.c | 2 ++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/sys/cam/ctl/ctl_frontend_ioctl.c b/sys/cam/ctl/ctl_frontend_ioctl.c
index f53dae694867..af2cb459fbcd 100644
--- a/sys/cam/ctl/ctl_frontend_ioctl.c
+++ b/sys/cam/ctl/ctl_frontend_ioctl.c
@@ -632,8 +632,9 @@ ctl_ioctl_io(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
 	 */
 	io->io_hdr.nexus.targ_port = cfi->port.targ_port;
 	io->io_hdr.flags |= CTL_FLAG_USER_REQ;
-	if ((io->io_hdr.io_type == CTL_IO_SCSI) &&
-	    (io->scsiio.tag_type != CTL_TAG_UNTAGGED))
+	if ((io->io_hdr.flags & CTL_FLAG_USER_TAG) == 0 &&
+	    io->io_hdr.io_type == CTL_IO_SCSI &&
+	    io->scsiio.tag_type != CTL_TAG_UNTAGGED)
 		io->scsiio.tag_num = atomic_fetchadd_int(&cfi->cur_tag_num, 1);
 
 	retval = cfi_submit_wait(io);
diff --git a/sys/cam/ctl/ctl_io.h b/sys/cam/ctl/ctl_io.h
index 9f22898e3ee5..30384bf80a02 100644
--- a/sys/cam/ctl/ctl_io.h
+++ b/sys/cam/ctl/ctl_io.h
@@ -88,7 +88,7 @@ typedef enum {
 	CTL_FLAG_DATA_OUT	= 0x00000002,	/* DATA OUT */
 	CTL_FLAG_DATA_NONE	= 0x00000003,	/* no data */
 	CTL_FLAG_DATA_MASK	= 0x00000003,
-	CTL_FLAG_DO_AUTOSENSE	= 0x00000020,	/* grab sense info */
+	CTL_FLAG_USER_TAG	= 0x00000020,	/* userland provides tag */
 	CTL_FLAG_USER_REQ	= 0x00000040,	/* request came from userland */
 	CTL_FLAG_ALLOCATED	= 0x00000100,	/* data space allocated */
 	CTL_FLAG_ABORT_STATUS	= 0x00000400,	/* return TASK ABORTED status */
diff --git a/usr.sbin/bhyve/pci_virtio_scsi.c b/usr.sbin/bhyve/pci_virtio_scsi.c
index 20f08b149af8..617074469fa7 100644
--- a/usr.sbin/bhyve/pci_virtio_scsi.c
+++ b/usr.sbin/bhyve/pci_virtio_scsi.c
@@ -406,6 +406,7 @@ pci_vtscsi_tmf_handle(struct pci_vtscsi_softc *sc,
 	io->io_hdr.nexus.targ_lun = pci_vtscsi_get_lun(tmf->lun);
 	io->taskio.tag_type = CTL_TAG_SIMPLE;
 	io->taskio.tag_num = tmf->id;
+	io->io_hdr.flags |= CTL_FLAG_USER_TAG;
 
 	switch (tmf->subtype) {
 	case VIRTIO_SCSI_T_TMF_ABORT_TASK:
@@ -520,6 +521,7 @@ pci_vtscsi_request_handle(struct pci_vtscsi_queue *q, struct iovec *iov_in,
 
 	io->scsiio.sense_len = sc->vss_config.sense_size;
 	io->scsiio.tag_num = cmd_rd->id;
+	io->io_hdr.flags |= CTL_FLAG_USER_TAG;
 	switch (cmd_rd->task_attr) {
 	case VIRTIO_SCSI_S_ORDERED:
 		io->scsiio.tag_type = CTL_TAG_ORDERED;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202212031714.2B3HEbAF007363>