aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2020-10-25 19:34:02 +0000
committerAlexander Motin <mav@FreeBSD.org>2020-10-25 19:34:02 +0000
commit883649681528398dc227778882830fc9da0ce58c (patch)
treee723924a03b24e3f8e7969d4016ff5c79df76e94 /sys/cam/ctl
parent98b04ac35965fa0735c06a4966c6939f8009509e (diff)
downloadsrc-883649681528398dc227778882830fc9da0ce58c.tar.gz
src-883649681528398dc227778882830fc9da0ce58c.zip
Introduce support of SCSI Command Priority.
SAM-3 specification introduced concept of Task Priority, that was renamed to Command Priority in SAM-4, and supported by all modern SCSI transports. It provides 15 levels of relative priorities: 1 - highest, 15 - lowest and 0 - default. SAT specification for SATA devices translates priorities 1-3 into NCQ high priority. This change adds new "priority" field into empty spots of struct ccb_scsiio and struct ccb_accept_tio of CAM and struct ctl_scsiio of CTL. Respective support is added into iscsi(4), isp(4), mpr(4), mps(4) and ocs_fc(4) drivers for both initiator and where applicable target roles. Minimal support was added to CTL to receive the priority value from different frontends, pass it between HA controllers and report in few places. This patch does not add consumers of this functionality, so nothing should really change yet, since the field is still set to 0 (default) on initiator and not actively used on target. Those are to be implemented separately. I've confirmed priority working on WD Red SATA disks connected via mpr(4) and properly transferred to CTL target via iscsi(4), isp(4) and ocs_fc(4). While there, added missing tag_action support to ocs_fc(4) initiator role. MFC after: 1 month Relnotes: yes Sponsored by: iXsystems, Inc.
Notes
Notes: svn path=/head/; revision=367044
Diffstat (limited to 'sys/cam/ctl')
-rw-r--r--sys/cam/ctl/ctl.c22
-rw-r--r--sys/cam/ctl/ctl_frontend_cam_sim.c1
-rw-r--r--sys/cam/ctl/ctl_frontend_iscsi.c2
-rw-r--r--sys/cam/ctl/ctl_io.h2
-rw-r--r--sys/cam/ctl/ctl_util.c5
-rw-r--r--sys/cam/ctl/scsi_ctl.c1
6 files changed, 22 insertions, 11 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 7887009d351c..37962eb3522c 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -1457,6 +1457,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_event event, int param)
if (softc->ha_mode != CTL_HA_MODE_XFER)
io->io_hdr.flags |= CTL_FLAG_INT_COPY;
io->io_hdr.nexus = msg->hdr.nexus;
+ io->scsiio.priority = msg->scsi.priority;
io->scsiio.tag_num = msg->scsi.tag_num;
io->scsiio.tag_type = msg->scsi.tag_type;
#ifdef CTL_TIME_IO
@@ -11603,8 +11604,9 @@ ctl_scsiio_precheck(struct ctl_softc *softc, struct ctl_scsiio *ctsio)
msg_info.hdr.nexus = ctsio->io_hdr.nexus;
msg_info.scsi.tag_num = ctsio->tag_num;
msg_info.scsi.tag_type = ctsio->tag_type;
- msg_info.scsi.cdb_len = ctsio->cdb_len;
memcpy(msg_info.scsi.cdb, ctsio->cdb, CTL_MAX_CDBLEN);
+ msg_info.scsi.cdb_len = ctsio->cdb_len;
+ msg_info.scsi.priority = ctsio->priority;
if ((isc_retval = ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info,
sizeof(msg_info.scsi) - sizeof(msg_info.scsi.sense_data),
@@ -12480,12 +12482,13 @@ ctl_datamove(union ctl_io *io)
ctl_scsi_command_string(&io->scsiio, NULL, &sb);
sbuf_printf(&sb, "\n");
sbuf_cat(&sb, path_str);
- sbuf_printf(&sb, "Tag: 0x%04x, type %d\n",
- io->scsiio.tag_num, io->scsiio.tag_type);
+ sbuf_printf(&sb, "Tag: 0x%04x/%d, Prio: %d\n",
+ io->scsiio.tag_num, io->scsiio.tag_type,
+ io->scsiio.priority);
break;
case CTL_IO_TASK:
- sbuf_printf(&sb, "Task I/O type: %d, Tag: 0x%04x, "
- "Tag Type: %d\n", io->taskio.task_action,
+ sbuf_printf(&sb, "Task Action: %d Tag: 0x%04x/%d\n",
+ io->taskio.task_action,
io->taskio.tag_num, io->taskio.tag_type);
break;
default:
@@ -12978,12 +12981,13 @@ ctl_process_done(union ctl_io *io)
ctl_scsi_command_string(&io->scsiio, NULL, &sb);
sbuf_printf(&sb, "\n");
sbuf_cat(&sb, path_str);
- sbuf_printf(&sb, "Tag: 0x%04x, type %d\n",
- io->scsiio.tag_num, io->scsiio.tag_type);
+ sbuf_printf(&sb, "Tag: 0x%04x/%d, Prio: %d\n",
+ io->scsiio.tag_num, io->scsiio.tag_type,
+ io->scsiio.priority);
break;
case CTL_IO_TASK:
- sbuf_printf(&sb, "Task I/O type: %d, Tag: 0x%04x, "
- "Tag Type: %d\n", io->taskio.task_action,
+ sbuf_printf(&sb, "Task Action: %d Tag: 0x%04x/%d\n",
+ io->taskio.task_action,
io->taskio.tag_num, io->taskio.tag_type);
break;
default:
diff --git a/sys/cam/ctl/ctl_frontend_cam_sim.c b/sys/cam/ctl/ctl_frontend_cam_sim.c
index 319c8069fbdc..fdcccee2f569 100644
--- a/sys/cam/ctl/ctl_frontend_cam_sim.c
+++ b/sys/cam/ctl/ctl_frontend_cam_sim.c
@@ -539,6 +539,7 @@ cfcs_action(struct cam_sim *sim, union ccb *ccb)
io->io_hdr.nexus.targ_port = softc->port.targ_port;
io->io_hdr.nexus.targ_lun = ctl_decode_lun(
CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun));
+ io->scsiio.priority = csio->priority;
/*
* This tag scheme isn't the best, since we could in theory
* have a very long-lived I/O and tag collision, especially
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index 0b91d4fd39c1..694ce99763f6 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -530,6 +530,8 @@ cfiscsi_pdu_handle_scsi_command(struct icl_pdu *request)
io->io_hdr.nexus.initid = cs->cs_ctl_initid;
io->io_hdr.nexus.targ_port = cs->cs_target->ct_port.targ_port;
io->io_hdr.nexus.targ_lun = ctl_decode_lun(be64toh(bhssc->bhssc_lun));
+ io->scsiio.priority = (bhssc->bhssc_pri & BHSSC_PRI_MASK) >>
+ BHSSC_PRI_SHIFT;
io->scsiio.tag_num = bhssc->bhssc_initiator_task_tag;
switch ((bhssc->bhssc_flags & BHSSC_FLAGS_ATTR)) {
case BHSSC_FLAGS_ATTR_UNTAGGED:
diff --git a/sys/cam/ctl/ctl_io.h b/sys/cam/ctl/ctl_io.h
index 6427685f99a8..2ad499f7f147 100644
--- a/sys/cam/ctl/ctl_io.h
+++ b/sys/cam/ctl/ctl_io.h
@@ -323,6 +323,7 @@ struct ctl_scsiio {
uint8_t sense_len; /* Returned sense length */
uint8_t scsi_status; /* SCSI status byte */
uint8_t sense_residual; /* Unused. */
+ uint8_t priority; /* Command priority */
uint32_t residual; /* Unused */
uint32_t tag_num; /* tag number */
ctl_tag_type tag_type; /* simple, ordered, head of queue,etc.*/
@@ -484,6 +485,7 @@ struct ctl_ha_msg_scsi {
uint8_t cdb_len; /* CDB length */
uint8_t scsi_status; /* SCSI status byte */
uint8_t sense_len; /* Returned sense length */
+ uint8_t priority; /* Command priority */
uint32_t port_status; /* trans status, set by FETD,
0 = good*/
uint32_t kern_data_resid; /* for DATAMOVE_DONE */
diff --git a/sys/cam/ctl/ctl_util.c b/sys/cam/ctl/ctl_util.c
index d00b96527b07..245c3e89dfb9 100644
--- a/sys/cam/ctl/ctl_util.c
+++ b/sys/cam/ctl/ctl_util.c
@@ -740,8 +740,9 @@ ctl_io_sbuf(union ctl_io *io, struct sbuf *sb)
case CTL_IO_SCSI:
sbuf_cat(sb, path_str);
ctl_scsi_command_string(&io->scsiio, NULL, sb);
- sbuf_printf(sb, " Tag: %#x/%d\n",
- io->scsiio.tag_num, io->scsiio.tag_type);
+ sbuf_printf(sb, " Tag: %#x/%d, Prio: %d\n",
+ io->scsiio.tag_num, io->scsiio.tag_type,
+ io->scsiio.priority);
break;
case CTL_IO_TASK:
sbuf_cat(sb, path_str);
diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c
index 569923f9be70..074ac4cd1894 100644
--- a/sys/cam/ctl/scsi_ctl.c
+++ b/sys/cam/ctl/scsi_ctl.c
@@ -1151,6 +1151,7 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
} else {
io->io_hdr.nexus.targ_lun = atio->ccb_h.target_lun;
}
+ io->scsiio.priority = atio->priority;
io->scsiio.tag_num = atio->tag_id;
switch (atio->tag_action) {
case CAM_TAG_ACTION_NONE: