[Midnightbsd-cvs] src [8916] trunk/sys/dev/aac/aac_cam.c: Some aac(4) adapters will always report that a direct access device is offline in response to an INQUIRY command.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Sep 26 18:52:31 EDT 2016


Revision: 8916
          http://svnweb.midnightbsd.org/src/?rev=8916
Author:   laffer1
Date:     2016-09-26 18:52:31 -0400 (Mon, 26 Sep 2016)
Log Message:
-----------
Some aac(4) adapters will always report that a direct access device is offline in response to an INQUIRY command.

Modified Paths:
--------------
    trunk/sys/dev/aac/aac_cam.c

Modified: trunk/sys/dev/aac/aac_cam.c
===================================================================
--- trunk/sys/dev/aac/aac_cam.c	2016-09-26 22:50:22 UTC (rev 8915)
+++ trunk/sys/dev/aac/aac_cam.c	2016-09-26 22:52:31 UTC (rev 8916)
@@ -1,4 +1,4 @@
-/* $MidnightBSD: src/sys/dev/aac/aac_cam.c,v 1.4 2012/04/12 01:20:08 laffer1 Exp $ */
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002 Adaptec, Inc.
  * All rights reserved.
@@ -527,6 +527,53 @@
 }
 
 static void
+aac_cam_fix_inquiry(struct aac_softc *sc, union ccb *ccb)
+{
+	struct scsi_inquiry_data *inq;
+	uint8_t *data;
+	uint8_t device, qual;
+
+	/* If this is an inquiry command, fake things out */
+	if (ccb->ccb_h.flags & CAM_CDB_POINTER)
+		data = ccb->csio.cdb_io.cdb_ptr;
+	else
+		data = ccb->csio.cdb_io.cdb_bytes;
+
+	if (data[0] != INQUIRY)
+		return;
+
+	if (ccb->ccb_h.status == CAM_REQ_CMP) {
+		inq = (struct scsi_inquiry_data *)ccb->csio.data_ptr;
+		device = SID_TYPE(inq);
+		qual = SID_QUAL(inq);
+
+		/*
+		 * We want DASD and PROC devices to only be
+		 * visible through the pass device.
+		 */
+		if (((device == T_DIRECT) ||
+		    (device == T_PROCESSOR) ||
+		    (sc->flags & AAC_FLAGS_CAM_PASSONLY))) {
+			/*
+			 * Some aac(4) adapters will always report that a direct
+			 * access device is offline in response to a INQUIRY
+			 * command that does not retreive vital product data.
+			 * Force the qualifier to connected so that upper layers
+			 * correctly recognize that a disk is present.
+			 */
+			if ((data[1] & SI_EVPD) == 0 && device == T_DIRECT &&
+			    qual == SID_QUAL_LU_OFFLINE)
+				qual = SID_QUAL_LU_CONNECTED;
+			ccb->csio.data_ptr[0] = (qual << 5) | T_NODEVICE;
+		}
+	} else if (ccb->ccb_h.status == CAM_SEL_TIMEOUT &&
+		ccb->ccb_h.target_lun != 0) {
+		/* fix for INQUIRYs on Lun>0 */
+		ccb->ccb_h.status = CAM_DEV_NOT_THERE;
+	}
+}
+
+static void
 aac_cam_complete(struct aac_command *cm)
 {
 	union	ccb *ccb;
@@ -551,8 +598,6 @@
 
 		/* Take care of SCSI_IO ops. */
 		if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
-			u_int8_t command, device;
-
 			ccb->csio.scsi_status = srbr->scsi_status;
 
 			/* Take care of autosense */
@@ -572,31 +617,7 @@
 				// scsi_sense_print(&ccb->csio);
 			}
 
-			/* If this is an inquiry command, fake things out */
-			if (ccb->ccb_h.flags & CAM_CDB_POINTER)
-				command = ccb->csio.cdb_io.cdb_ptr[0];
-			else
-				command = ccb->csio.cdb_io.cdb_bytes[0];
-
-			if (command == INQUIRY) {
-				if (ccb->ccb_h.status == CAM_REQ_CMP) {
-				device = ccb->csio.data_ptr[0] & 0x1f;
-				/*
-				 * We want DASD and PROC devices to only be
-				 * visible through the pass device.
-				 */
-				if ((device == T_DIRECT) ||
-				    (device == T_PROCESSOR) ||
-				    (sc->flags & AAC_FLAGS_CAM_PASSONLY))
-					ccb->csio.data_ptr[0] =
-					    ((ccb->csio.data_ptr[0] & 0xe0) |
-					    T_NODEVICE);
-				} else if (ccb->ccb_h.status == CAM_SEL_TIMEOUT &&
-					ccb->ccb_h.target_lun != 0) {
-					/* fix for INQUIRYs on Lun>0 */
-					ccb->ccb_h.status = CAM_DEV_NOT_THERE;
-				}
-			}
+			aac_cam_fix_inquiry(sc, ccb);
 		}
 	}
 



More information about the Midnightbsd-cvs mailing list