6581368 ST:Need st driver support for HP DAT-160 tape drive
authorlh195018
Tue, 31 Jul 2007 19:53:36 -0700
changeset 4771 d1a1daf81470
parent 4770 1eaa93763510
child 4772 519987623196
6581368 ST:Need st driver support for HP DAT-160 tape drive
usr/src/uts/common/io/scsi/targets/st.c
usr/src/uts/common/io/scsi/targets/st_conf.c
--- a/usr/src/uts/common/io/scsi/targets/st.c	Tue Jul 31 16:42:16 2007 -0700
+++ b/usr/src/uts/common/io/scsi/targets/st.c	Tue Jul 31 19:53:36 2007 -0700
@@ -11753,6 +11753,66 @@
 }
 
 static writablity
+st_is_hp_dat_tape_worm(struct scsi_tape *un)
+{
+	writablity wrt;
+
+	ST_FUNC(ST_DEVINFO, st_is_hp_dat_tape_worm);
+
+	/* Mode sense should be current */
+	if (un->un_mspl->media_type == 1) {
+		ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
+		    "Drive has WORM media loaded\n");
+		wrt = WORM;
+	} else {
+		ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
+		    "Drive has non WORM media loaded\n");
+		wrt = RDWR;
+	}
+	return (wrt);
+}
+
+#define	HP_DAT_INQUIRY 0x4A
+static writablity
+st_is_hp_dat_worm(struct scsi_tape *un)
+{
+	char *buf;
+	int result;
+	writablity wrt;
+
+	ST_FUNC(ST_DEVINFO, st_is_hp_dat_worm);
+
+	buf = kmem_zalloc(HP_DAT_INQUIRY, KM_SLEEP);
+
+	result = st_get_special_inquiry(un, HP_DAT_INQUIRY, buf, 0);
+
+	if (result != 0) {
+		ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
+		    "Read Standard Inquiry for WORM support failed");
+		wrt = FAILED;
+	} else if ((buf[40] & 1) == 0) {
+		ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
+		    "Drive is NOT WORMable\n");
+		/* This drive doesn't support it so don't check again */
+		un->un_dp->options &= ~ST_WORMABLE;
+		wrt = RDWR;
+		un->un_wormable = st_is_not_wormable;
+	} else {
+		ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
+		    "Drive supports WORM version %d\n", buf[40] >> 1);
+		un->un_wormable = st_is_hp_dat_tape_worm;
+		wrt = un->un_wormable(un);
+	}
+
+	kmem_free(buf, HP_DAT_INQUIRY);
+
+	/*
+	 * If drive doesn't support it no point in checking further.
+	 */
+	return (wrt);
+}
+
+static writablity
 st_is_hp_lto_tape_worm(struct scsi_tape *un)
 {
 	writablity wrt;
@@ -12187,6 +12247,14 @@
 		}
 		break;
 
+	case MT_ISDAT:
+		if (strncmp("HP ", un->un_dp->vid, 3) == 0) {
+			wrt = st_is_hp_dat_worm(un);
+		} else {
+			wrt = st_is_t10_worm(un);
+		}
+		break;
+
 	default:
 		wrt = FAILED;
 		break;
--- a/usr/src/uts/common/io/scsi/targets/st_conf.c	Tue Jul 31 16:42:16 2007 -0700
+++ b/usr/src/uts/common/io/scsi/targets/st_conf.c	Tue Jul 31 19:53:36 2007 -0700
@@ -1104,6 +1104,41 @@
   },
 
   /*
+   * HP DAT-160
+   */
+  {                           /* Structure member Description                 */
+                              /* ---------------- -----------                 */
+    "HP DDS-6 DAT",           /* .name            Display ("pretty") name     */
+    14,                       /* .length          Length of next item...      */
+    "HP      DAT160",         /* .vid             Vendor-product ID string    */
+    MT_ISDAT,                 /* .type            Numeric type (cf. mtio.h)   */
+    0,                        /* .bsize           Block size (0 = variable)   */
+                              /* .options         Drive option flags:         */
+    ST_VARIABLE         |     /*    00001           Supports variable length  */
+    ST_BSF              |     /*    00008           Supports SPACE block fwd  */
+    ST_BSR              |     /*    00010           Supports SPACE block rev  */
+    ST_KNOWS_EOD        |     /*    00200           Recognizes end-of-data    */
+    ST_UNLOADABLE       |     /*    00400           Driver can be unloaded    */
+    ST_NO_RECSIZE_LIMIT |     /*    08000           Supports blocks > 64KB    */
+    ST_MODE_SEL_COMP    |     /*    10000           Mode select compression   */
+    ST_WORMABLE,              /*  1000000           Drive is WORM capable     */
+                              /*  -------                                     */
+                              /*  1018619                                     */
+    -1,                       /* .max_rretries      Not Used                  */
+    -1,                       /* .max_wretries      Not Used                  */
+    {0x48, 0x48, 0x48, 0x48}, /* .densities       Density codes               */
+    MT_DENSITY4,              /* .default_density (.densities[x])             */
+    {0, 0, 0, 0},             /* .speeds          Speed codes Not Used        */
+    0,                        /* .non_motion_timeout Nothing Special          */
+    MINUTES(5),               /* .io_timeout                                  */
+    MINUTES(10),              /* .rewind_timeout                              */
+    MINUTES(20),              /* .space_timeout                               */
+    MINUTES(10),              /* .load_timeout                                */
+    MINUTES(10),              /* .unload_timeout                              */
+    MINUTES(300)              /* .erase_timeout      5 hours                  */
+  },
+
+  /*
    * HP Ultrium LTO Gen 4
    * [1] This drive supports two densites at this time.
    *     In reality the type of media GEN 3 or GEN 4 selects the density.