Subject: review of minor SCSIbus midlayer change, #1, possibly for 5.0
To: None <tech-kern@netbsd.org>
From: Matthew Jacob <mjacob@feral.com>
List: tech-kern
Date: 08/07/2000 16:46:15
This allows both dynamic flag setting for 'acceleration' from userland as well
as from initial configuration for host adapters that support the ioctl
function.

Thoughts? Makes things cleaner, and is a start toward finer control.


Index: sys/scsiio.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/scsiio.h,v
retrieving revision 1.7
diff -u -r1.7 scsiio.h
--- scsiio.h	1998/10/10 03:18:51	1.7
+++ scsiio.h	2000/08/07 23:43:34
@@ -90,4 +90,15 @@
 
 #define	SCBUSIORESET	_IO('U', 1)	/* reset SCSI bus */
 
+/* enable/disable device properties */
+struct scbusaccel_args {
+	int	sa_target;	/* target to set property on */
+	int	sa_lun;		/* lun to set property on */
+	int	sa_flags;	/* flags to set or clear */
+};
+#define	SC_ACCEL_SYNC	0x01	/* enable sync mode */
+#define	SC_ACCEL_WIDE	0x02	/* enable wide transfers */
+#define	SC_ACCEL_TAGS	0x04	/* enable tagged queuing */
+#define	SCBUSACCEL	_IOW('U', 2, struct scbusaccel_args)
+
 #endif /* _SYS_SCSIIO_H_ */
Index: dev/scsipi/scsiconf.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/scsipi/scsiconf.c,v
retrieving revision 1.148
diff -u -r1.148 scsiconf.c
--- scsiconf.c	2000/08/03 12:36:08	1.148
+++ scsiconf.c	2000/08/07 23:43:35
@@ -817,7 +817,7 @@
 	default:
 		break;
 	}
-	if (checkdtype)
+	if (checkdtype) {
 		switch (inqbuf.device & SID_TYPE) {
 		case T_DIRECT:
 		case T_SEQUENTIAL:
@@ -841,6 +841,25 @@
 		case T_NODEVICE:
 			goto bad;
 		}
+		/*
+		 * At this point we can also tell the adapter that it
+		 * may negotiate things as appropriate.
+		 */
+		if (sc_link->adapter->scsipi_ioctl) {
+			struct scbusaccel_args s;
+			s.sa_target = target;
+			s.sa_lun = lun;
+			s.sa_flags = 0;
+			if ((sc_link->quirks & SDEV_NOTAG) == 0)
+				s.sa_flags |= SC_ACCEL_TAGS;
+			if ((sc_link->quirks & SDEV_NOSYNC) == 0)
+				s.sa_flags |= SC_ACCEL_SYNC;
+			if ((sc_link->quirks & SDEV_NOWIDE) == 0)
+				s.sa_flags |= SC_ACCEL_WIDE;
+			(void) (*sc_link->adapter->scsipi_ioctl)
+			    (sc_link, SCBUSACCEL, (caddr_t)&s, FWRITE, curproc);
+		}
+	}
 
 	if ((cf = config_search(scsibussubmatch, (struct device *)scsi,
 	    &sa)) != NULL) {