Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jul 1996 13:13:47 +1000 (EST)
From:      John Hartley <jbh@labyrinth.net.au>
To:        freebsd-scsi@freebsd.org
Subject:   Re: tandberg scsi tape + FreeBSD 2.1/2.0.5
Message-ID:  <199607180313.NAA07553@minotaur.labyrinth.net.au>

next in thread | raw e-mail | index | archive | help
At 13:06 17/07/96 +0200, you wrote:
>
>Ick.  This is weird (and it cannot work this way).  Neither this
>blocksize nor this density will be accepted by the drive.  As long as
>you're getting this, all other attempts are in vaine.
>
>However, this looks as if the `rogue' code wouldn't work as expected.
>(Sorry, i cannot reproduce this, this code has been taken out
>meanwhile.  The entire rogue handling has been moved out to
>scsiconf.c, that's what is #ifdef NEW_SCSICONF for you.)
>
>Something like
>
>	mt -f /dev/st0ctl.0 blocksize 0
>	mt -f /dev/st0ctl.0 density 0x15

Tried lots of these but no luck. Also I think that this is kind of
dangerous.  What is I change the type of tape I put into the drive?
Surely dealing with what media I put into the drive should be a function
of the tape drive and not the controlling software...

>
>is the least that must work.  Try experimenting with this.
>
>> >I wonder whether we should always use the following kludge:
>> >
>> >@@ -1530,7 +1530,9 @@
>> > 	scsi_cmd.length = dat_len;
>> > 	dat.header.blk_desc_len = sizeof(struct blk_desc);
>> > 	dat.header.dev_spec |= SMH_DSP_BUFF_MODE_ON;
>> >-	dat.blk_desc.density = st->density;
>> >+	dat.blk_desc.density =
>> >+		st->density? st->density:
>> >+			     0x7f /* use previous density */;
>> > 	if (st->flags & ST_FIXEDBLOCKS) {
>> > 		scsi_uto3b(st->blksiz, dat.blk_desc.blklen);
>> > 	}
>> >
>> >
>> >
>> 
>> I didn't try this as the previous test failed!!
>
>Hmm, no, if you kill the rogue entry, the above _should_ work
>nevertheless.  (As long as the rogue entry is there, it seems the
>kernel uses 1024 byte blocksize, but i remember that this wasn't the
>case before for your drive.)
>

I tried this code but still got the problems.....

>> I guess the question is is what is it that the FreeBSD drivers are doing
>> that is different from the dos ASPI and Windows NT tape driver???
>
>The BSD driver should perhaps by default not even try to MODE SELECT
>the drive.  That's what it is constantly getting wrong in your case.
>Look here:
>
>> Jul 16 17:09:38 qwiff /kernel: st0(ahc0:2:0): command: 15,0,0,0,c,0-[12
bytes]
>> Jul 16 17:09:38 qwiff /kernel: ------------------------------
>> Jul 16 17:09:38 qwiff /kernel: 000: 00 00 10 08 00 00 00 00 00 00 04 00 
>> Jul 16 17:09:38 qwiff /kernel: ------------------------------
>
>That's the interesting line.  It should actually look:
>
>> Jul 16 17:09:38 qwiff /kernel: 000: 00 00 10 08 15 00 00 00 00 00 00 00 
>                                                  ^^                ^^

In a desperate attempt to get the drive up and running I #defined out the
entire st_mode_select section of code, as this seemed to be where all the
errors were coming from.  Also I considered that mechanism as very
fragile in that it allowed no leeway in how the driver "talked" to the
tape drive.
I guess my idea about it was, I ask the tape to read/write a stream of data,
I don't care or want to know how it choices to do this.  It a smart fellow
it will work something out.... ;-)

The following is the modified code!!!!

errval
st_mode_select(unit, flags, page, pagelen)
	u_int32 unit, flags;
	struct tape_pages *page;
	u_int32 pagelen;
{
#define MAJOR_HACK_JBH
#ifdef MAJOR_HACK_JBH
  return(0);
#else
	u_int32 dat_len;
	struct scsi_mode_select scsi_cmd;
	struct {
		struct scsi_mode_header header;
		struct blk_desc blk_desc;
		struct tape_pages page;
	} dat;
	struct scsi_link *sc_link = SCSI_LINK(&st_switch, unit);
	struct scsi_data *st = sc_link->sd;

	/*
	 * Check if we need to use a default page..
	 * Gee, hope we saved one before now........
	 */
	if ((st->quirks & ST_Q_NEEDS_PAGE_0) && (!page)) {
		pagelen = PAGE_0_SENSE_DATA_SIZE;
		page = (struct tape_pages *) st->saved_page0;
	}
	/*
	 * Now work out the total dat size etc.
	 */
	dat_len = sizeof(struct scsi_mode_header)
		+ sizeof(struct blk_desc)
		+ (page ? pagelen : 0);
	/*
	 * Set up for a mode select
	 */
	bzero(&dat, dat_len);
	bzero(&scsi_cmd, sizeof(scsi_cmd));
	scsi_cmd.op_code = MODE_SELECT;
	scsi_cmd.length = dat_len;
	dat.header.blk_desc_len = sizeof(struct blk_desc);
	dat.header.dev_spec |= SMH_DSP_BUFF_MODE_ON;
#ifdef ST_TEST_NONE
	dat.blk_desc.density = st->density;
#else                                            /* Test case */
	dat.blk_desc.density = st->density ? st->density :
				0x7f /* use previous density */;
#endif
	if (st->flags & ST_FIXEDBLOCKS) {
		scsi_uto3b(st->blksiz, dat.blk_desc.blklen);
	}
	if (page) {
		bcopy(page, &dat.page, pagelen);
		/* the Tandberg tapes need the block size to */
		/* be set on each mode sense/select. */
	}
	/*
	 * do the command
	 */
	return (scsi_scsi_cmd(sc_link,
		(struct scsi_generic *) &scsi_cmd,
		sizeof(scsi_cmd),
		(u_char *) &dat,
		dat_len,
		ST_RETRIES,
		5000,
		NULL,
		flags | SCSI_DATA_OUT));
#endif
}

Result.....

Success at last....!!!!
The tape now writes and reads...

I then popped out the 1.2 GB cartridge and put in an old QIC-150 (150 MB)
cartridge, with some tar file on it.
It read the tape no problems.
Obviously the drive was being very dumb in its negotiation, but very smart
in its area of strength (reading and writing).
I not sure what you think of this HACK, but it does work...
Thanks a lot for all your help (J"org).
As you say never trust an operating system you don't have sources for...

Cheers.

John Hartley.




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