Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2017 21:07:46 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r312845 - in stable/10/sys/cam: . ctl scsi
Message-ID:  <201701262107.v0QL7ksv006840@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Jan 26 21:07:46 2017
New Revision: 312845
URL: https://svnweb.freebsd.org/changeset/base/312845

Log:
  MFC r312026: Improve CAM_CDB_POINTER support.

Modified:
  stable/10/sys/cam/cam_ccb.h
  stable/10/sys/cam/cam_periph.c
  stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c
  stable/10/sys/cam/ctl/scsi_ctl.c
  stable/10/sys/cam/scsi/scsi_all.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/cam_ccb.h
==============================================================================
--- stable/10/sys/cam/cam_ccb.h	Thu Jan 26 21:06:59 2017	(r312844)
+++ stable/10/sys/cam/cam_ccb.h	Thu Jan 26 21:07:46 2017	(r312845)
@@ -760,6 +760,13 @@ struct ccb_accept_tio {
 	struct     scsi_sense_data sense_data;
 };
 
+static __inline uint8_t *
+atio_cdb_ptr(struct ccb_accept_tio *ccb)
+{
+	return ((ccb->ccb_h.flags & CAM_CDB_POINTER) ?
+	    ccb->cdb_io.cdb_ptr : ccb->cdb_io.cdb_bytes);
+}
+
 /* Release SIM Queue */
 struct ccb_relsim {
 	struct ccb_hdr ccb_h;

Modified: stable/10/sys/cam/cam_periph.c
==============================================================================
--- stable/10/sys/cam/cam_periph.c	Thu Jan 26 21:06:59 2017	(r312844)
+++ stable/10/sys/cam/cam_periph.c	Thu Jan 26 21:07:46 2017	(r312845)
@@ -1909,10 +1909,7 @@ cam_periph_devctl_notify(union ccb *ccb)
 
 	if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
 		sbuf_printf(&sb, "CDB=\"");
-		if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0)
-			scsi_cdb_sbuf(ccb->csio.cdb_io.cdb_ptr, &sb);
-		else
-			scsi_cdb_sbuf(ccb->csio.cdb_io.cdb_bytes, &sb);
+		scsi_cdb_sbuf(scsiio_cdb_ptr(&ccb->csio), &sb);
 		sbuf_printf(&sb, "\" ");
 	} else if (ccb->ccb_h.func_code == XPT_ATA_IO) {
 		sbuf_printf(&sb, "ACB=\"");

Modified: stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c	Thu Jan 26 21:06:59 2017	(r312844)
+++ stable/10/sys/cam/ctl/ctl_frontend_cam_sim.c	Thu Jan 26 21:07:46 2017	(r312845)
@@ -587,8 +587,7 @@ cfcs_action(struct cam_sim *sim, union c
 			       __func__, csio->cdb_len, sizeof(io->scsiio.cdb));
 		}
 		io->scsiio.cdb_len = min(csio->cdb_len, sizeof(io->scsiio.cdb));
-		bcopy(csio->cdb_io.cdb_bytes, io->scsiio.cdb,
-		      io->scsiio.cdb_len);
+		bcopy(scsiio_cdb_ptr(csio), io->scsiio.cdb, io->scsiio.cdb_len);
 
 		ccb->ccb_h.status |= CAM_SIM_QUEUED;
 		err = ctl_queue(io);

Modified: stable/10/sys/cam/ctl/scsi_ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/scsi_ctl.c	Thu Jan 26 21:06:59 2017	(r312844)
+++ stable/10/sys/cam/ctl/scsi_ctl.c	Thu Jan 26 21:07:46 2017	(r312845)
@@ -941,7 +941,7 @@ ctlfestart(struct cam_periph *periph, un
 	  && (csio->sglist_cnt != 0))) {
 		printf("%s: tag %04x cdb %02x flags %#x dxfer_len "
 		       "%d sg %u\n", __func__, atio->tag_id,
-		       atio->cdb_io.cdb_bytes[0], flags, dxfer_len,
+		       atio_cdb_ptr(atio)[0], flags, dxfer_len,
 		       csio->sglist_cnt);
 		printf("%s: tag %04x io status %#x\n", __func__,
 		       atio->tag_id, io->io_hdr.status);
@@ -1027,8 +1027,7 @@ ctlfe_adjust_cdb(struct ccb_accept_tio *
 {
 	uint64_t lba;
 	uint32_t num_blocks, nbc;
-	uint8_t *cmdbyt = (atio->ccb_h.flags & CAM_CDB_POINTER)?
-	    atio->cdb_io.cdb_ptr : atio->cdb_io.cdb_bytes;
+	uint8_t *cmdbyt = atio_cdb_ptr(atio);
 
 	nbc = offset >> 9;	/* ASSUMING 512 BYTE BLOCKS */
 
@@ -1206,8 +1205,7 @@ ctlfedone(struct cam_periph *periph, uni
 			       __func__, atio->cdb_len, sizeof(io->scsiio.cdb));
 		}
 		io->scsiio.cdb_len = min(atio->cdb_len, sizeof(io->scsiio.cdb));
-		bcopy(atio->cdb_io.cdb_bytes, io->scsiio.cdb,
-		      io->scsiio.cdb_len);
+		bcopy(atio_cdb_ptr(atio), io->scsiio.cdb, io->scsiio.cdb_len);
 
 #ifdef CTLFEDEBUG
 		printf("%s: %u:%u:%u: tag %04x CDB %02x\n", __func__,
@@ -1388,7 +1386,7 @@ ctlfedone(struct cam_periph *periph, uni
 					printf("%s: tag %04x no status or "
 					       "len cdb = %02x\n", __func__,
 					       atio->tag_id,
-					atio->cdb_io.cdb_bytes[0]);
+					       atio_cdb_ptr(atio)[0]);
 					printf("%s: tag %04x io status %#x\n",
 					       __func__, atio->tag_id,
 					       io->io_hdr.status);

Modified: stable/10/sys/cam/scsi/scsi_all.c
==============================================================================
--- stable/10/sys/cam/scsi/scsi_all.c	Thu Jan 26 21:06:59 2017	(r312844)
+++ stable/10/sys/cam/scsi/scsi_all.c	Thu Jan 26 21:07:46 2017	(r312845)
@@ -3616,15 +3616,9 @@ scsi_command_string(struct cam_device *d
 
 #endif /* _KERNEL/!_KERNEL */
 
-	if ((csio->ccb_h.flags & CAM_CDB_POINTER) != 0) {
-		sbuf_printf(sb, "%s. CDB: ", 
-			    scsi_op_desc(csio->cdb_io.cdb_ptr[0], inq_data));
-		scsi_cdb_sbuf(csio->cdb_io.cdb_ptr, sb);
-	} else {
-		sbuf_printf(sb, "%s. CDB: ",
-			    scsi_op_desc(csio->cdb_io.cdb_bytes[0], inq_data));
-		scsi_cdb_sbuf(csio->cdb_io.cdb_bytes, sb);
-	}
+	sbuf_printf(sb, "%s. CDB: ",
+		    scsi_op_desc(scsiio_cdb_ptr(csio)[0], inq_data));
+	scsi_cdb_sbuf(scsiio_cdb_ptr(csio), sb);
 
 #ifdef _KERNEL
 	xpt_free_ccb((union ccb *)cgd);
@@ -5029,7 +5023,6 @@ scsi_sense_sbuf(struct cam_device *devic
 	struct	  ccb_getdev *cgd;
 #endif /* _KERNEL */
 	char	  path_str[64];
-	uint8_t	  *cdb;
 
 #ifndef _KERNEL
 	if (device == NULL)
@@ -5127,14 +5120,9 @@ scsi_sense_sbuf(struct cam_device *devic
 			sense = &csio->sense_data;
 	}
 
-	if (csio->ccb_h.flags & CAM_CDB_POINTER)
-		cdb = csio->cdb_io.cdb_ptr;
-	else
-		cdb = csio->cdb_io.cdb_bytes;
-
 	scsi_sense_only_sbuf(sense, csio->sense_len - csio->sense_resid, sb,
-			     path_str, inq_data, cdb, csio->cdb_len);
-			 
+	    path_str, inq_data, scsiio_cdb_ptr(csio), csio->cdb_len);
+
 #ifdef _KERNEL
 	xpt_free_ccb((union ccb*)cgd);
 #endif /* _KERNEL/!_KERNEL */



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