Solaris Generic SCSI driver : Summary

From: Fabien Collin (fabien@sun2.cern.ch)
Date: Sun Aug 20 1995 - 08:20:05 CDT


        Thanks to all the people who replied to my original question :
"Is there a generic SCSI driver in Solaris". You will find at the end of
this message the answers I got by email.

        I succeeded in using the USCSICMD ioctl method described below but it
seems that it has a MAJOR DRAWBACK : In case of a SCSI error (that is status
= CHECK CONDITION), the generic SCSI driver fetches the sense bytes from the
device, displays an error message in the kernel buffer (see dmesg output), but
doesn't return them to the sending user process. This is really stupid !
(Sending a REQUEST SENSE SCSI command after the SCSI command which returned
the error is of no use since the driver has already reclaimed the sense bytes).

        Is someone aware of this problem ? How to solve it ? Any help will
be greatly appreciated.

        The only solution I see at the moment is to patch the public domain
version of the generic SCSI driver (see below).

        The SunOS 4.1.3 version of the generic SCSI driver is really poor
(the amount of data returned by a SCSI command is unknown, some flags are missing, etc...) but at least it doesn't fetches the sense bytes in case of
error ! Solaris know includes a scsi_resid field to solve this problem. That's
fine but what about sense bytes ?

                                                        Fabien

---
----------------------------------------------------------------------
Fabien COLLIN                       Hewlett Packard OS Engineer
CERN				             
CN Division			    e-mail : Fabien.Collin@cern.ch
Building 513 Office R-037	             Fabien.Collin@loria.fr
1211 Geneva 23                      Tel : + 41 22 767 9457
SWITZERLAND			    Fax : + 41 22 767 9345
----------------------------------------------------------------------

>From lupe@alanya.m.isar.de Fri Aug 18 07:19:44 1995 Return-Path: <lupe@alanya.m.isar.de> Received: from dxmint.cern.ch by sun2.cern.ch (4.1/SMI-3.2) id AA25716; Fri, 18 Aug 95 07:19:43 +0200 Received: (from Ualanya@localhost) by nymphe.m.isar.de (8.6.12/ny-1.1) with UUCP id HAA06135 for fabien@sun2.cern.ch; Fri, 18 Aug 1995 07:29:53 +0200 Received: (from lupe@localhost) by alanya.m.isar.de (8.6.12/8.6.12) id HAA12961; Fri, 18 Aug 1995 07:23:32 +0200 Date: Fri, 18 Aug 1995 07:23:32 +0200 From: Lupe Christoph <lupe@alanya.m.isar.de> Message-Id: <199508180523.HAA12961@alanya.m.isar.de> To: fabien@sun2.cern.ch Subject: Re: Is there a Generic SCSI driver in Solaris ? Newsgroups: comp.unix.solaris References: <DDGsMw.vI@news.cern.ch> Status: RO

In comp.unix.solaris you write:

> Does Solaris include a generic SCSI driver (I mean >a kernel layer which enables a user process to send a SCSI >command to any SCSI device) ?

You can use USCSI to send commands to tapes and disks. For other devices you can either get the DDK (contains a SCSI sample driver), or purchase Kevin Sheehan SG (SCSI Generic) which is both a sample driver and a general user SCSI interface.

I'm selling SG (DM 5000); I also use it as the basis for a product that controls tape and MO autochangers. If you're interested, send mail to lupe@octogon.isar.de (office email). -- | lupe@alanya.m.isar.de (private, I.S.A.R.) | GAT d-- -p+ c++(+++) | | lupe@octogon.isar.de (business, I.S.A.R.) | l- u+(++) e++(*) m+ | | | s-/+ n+ h f* g+ w+ t+ | | Non sunt multiplicanda entia praeter necessitatem. | r+ !y |

>From aa@info.ucl.ac.be Fri Aug 18 09:01:31 1995 Return-Path: <aa@info.ucl.ac.be> Received: from dxmint.cern.ch by sun2.cern.ch (4.1/SMI-3.2) id AA03076; Fri, 18 Aug 95 09:01:31 +0200 Received: from nimitz.info.ucl.ac.be by info-sparc1 (4.1/SMI-4.1 (version MX - hb 27/07/92 -)) id AA25142; Fri, 18 Aug 95 09:18:11 +0200 Received: by nimitz.info.ucl.ac.be (5.x/SMI-SVR4) id AA06192; Fri, 18 Aug 1995 09:16:19 +0200 Date: Fri, 18 Aug 1995 09:16:19 +0200 Message-Id: <9508180716.AA06192@nimitz.info.ucl.ac.be> X-Newsreader: knews 0.9.0 Organization: Departement d'Ingenierie Informatique (Universite Catholique de Louvain) References: <DDGsMw.vI@news.cern.ch> From: aa@info.ucl.ac.be (Andre April) Subject: Re: Is there a Generic SCSI driver in Solaris ? Newsgroups: comp.unix.solaris In-Reply-To: <DDGsMw.vI@news.cern.ch> To: fabien@sun2.cern.ch (Fabien Collin) Status: RO

In article <DDGsMw.vI@news.cern.ch>, fabien@sun2.cern.ch (Fabien Collin) writes: > Hello there, > > Does Solaris include a generic SCSI driver (I mean >a kernel layer which enables a user process to send a SCSI >command to any SCSI device) ? > > Any information about this subject are welcome. > > Thanks. > > Fabien

Look for something like sample_drivers.tar.Z on sunsite.unc.edu. The file contains a directory called sst (simple scsi target). There should also be a document called solaris2_scsa_tutorial.tar.Z

The driver support a USCSI ioctl which passes user commands directly to the SCSI device.

Andri.

------------------------------------------------------------------- Andri April Dipartement d'inginierie informatique E-mail: aa@info.ucl.ac.be Place Sainte Barbe, 2 Tel: +32 (0)10/47.31.13 1348 Louvain-la-Neuve Fax: +32 (0)10/45.03.45 Belgium

>From wd@uebemc.siemens.de Fri Aug 18 09:32:06 1995 Return-Path: <wd@uebemc.siemens.de> Received: from dxmint.cern.ch by sun2.cern.ch (4.1/SMI-3.2) id AA03136; Fri, 18 Aug 95 09:32:05 +0200 Received: from isar.uebemc.siemens.de by david.zfe.siemens.de with SMTP id AA06658 (5.67a/IDA-1.5 for <fabien@sun2.cern.ch>); Fri, 18 Aug 1995 09:43:24 +0200 Received: from uebemc.siemens.de ([180.71.2.21]) by isar.uebemc.siemens.de (4.1/isar V1.2 for fabien@sun2.cern.ch) id AA26674; Fri, 18 Aug 95 09:43:17 +0200 Received: from rahel by uebemc.siemens.de (4.1/SMI-4.1) id AA18274; Fri, 18 Aug 95 09:43:16 +0200 Received: from nicole by rahel (5.0/Solaris2-Server 0.9) id AA09634; Fri, 18 Aug 1995 09:43:15 +0200 Received: by nicole (5.0/NFS-Client-1.0-Sol) id AA00834; Fri, 18 Aug 1995 09:43:14 +0200 Date: Fri, 18 Aug 1995 09:43:14 +0200 Message-Id: <9508180743.AA00834@nicole> To: fabien@sun2.cern.ch Subject: Re: Is there a Generic SCSI driver in Solaris ? Newsgroups: comp.unix.solaris References: <DDGsMw.vI@news.cern.ch> From: Wolfgang Denk <wd@uebemc.siemens.de> Content-Length: 8123 Status: RO

In comp.unix.solaris you write:

> Does Solaris include a generic SCSI driver (I mean >a kernel layer which enables a user process to send a SCSI >command to any SCSI device) ?

Yes. You may have a look at the example programs below.

/**************************************************************** * * SUN_dc_xtrl.c * * Hack to control DC in an HP DDS drive from a SUN * * Use: SUN_dc_xtrl device-file-name 1 Turns DC on * SUN_dc_xtrl device-file-name 0 Turns DC off * * Note: Switch 2 on the underside of the drive must be ON * in order for this utility to work. * ****************************************************************** * Kevin Jones. | Hewlett Packard Ltd, * | Computer Peripherals Bristol, * kev%hpcpbla@hplb.hpl.hp.com | Filton Road, * | Stoke Gifford, * | Bristol. BS12 6QZ. * | ENGLAND. ****************************************************************** * * This code is not official HP code. * It is provided for informational purposes only. * It is supplied without warranty of any kind. * ****************************************************************/

#include <stdio.h> #include <fcntl.h> #include <errno.h> #include <sys/ioctl.h> #include <sys/scsi/impl/uscsi.h>

int fd; unsigned char msel_data[] = { 0,0,0x10,0,0xf,0xe,0x40,0x80,0,0,0,0x20,0,0,0,0,0,0,0,0 };

main (argc, argv) int argc; char *argv[];

{ struct uscsi_cmd scsi_cmd, *cmd = &scsi_cmd; char cmd_cdb[6];

if (argc != 3) printf ("Usage: SUN_dc_xtrl device-file-name [01]\n");

if ((fd = open(argv[1], O_RDWR | O_NONBLOCK)) < 0) { if ((fd = open(argv[1], O_RDWR | O_NONBLOCK)) < 0) { printf ("Failed to open device %s\n", argv[1]); exit (1); } }

if (*(argv[2]) == '1') msel_data[6] = 0xC0;

cmd->uscsi_cdblen = 0x06; cmd->uscsi_timeout = 5000; cmd->uscsi_flags = USCSI_WRITE; cmd->uscsi_bufaddr = msel_data; cmd->uscsi_buflen = sizeof (msel_data); cmd->uscsi_cdb = cmd_cdb; cmd->uscsi_cdb[0] = 0x15; cmd->uscsi_cdb[1] = 0x10; cmd->uscsi_cdb[2] = 0x0; cmd->uscsi_cdb[3] = 0x0; cmd->uscsi_cdb[4] = 0x14; cmd->uscsi_cdb[5] = 0x0;

if (ioctl (fd, USCSICMD ,cmd) < 0) { printf ("Mode Select command failed :-(\n"); exit (1); }

exit (0); }

>Newsgroups: comp.sys.sun.admin,alt.sys.sun,comp.sys.hp.hardware >From: kev@bri.hp.com (Kevin Jones) >Subject: Re: DAT AUTOLOADER SCSI COMMANDS IN SunOS 4.1.3 >Message-ID: <DAKADA.Byy@bri.hp.com> >Date: Thu, 22 Jun 1995 06:36:46 GMT >Organization: Hewlett-Packard

Donald McCarthy (D.McCarthy@ftel.co.uk) wrote: : Hi we have some HP C1553A Autoloading DDS2 DAT tape drives attached to Suns running : SunOS 4.1.3.

: At present I cannot for example change what tape is loaded via software. Is there a : program available that would allow me to fully manipulate the stat of the drive?

You should be able to change to the next tape using 'mt offl' once a stacking sequence has been initiated via the front panel.

As far as random tape selection via software is concerned, I know of no solution for SunOS 4.1.3. The driver in SunOS does not allow SCSI commands to be "passed thru" to the device. If it did this then there's no problem. The SOLARIS driver allows this, and I've appended a program to change tapes under Solaris just in case you ever switch OS's.

----------------------------------------------------------------- Kevin Jones. | Hewlett Packard Ltd, | Computer Peripherals Bristol, kev%hpcpbla@hplb.hpl.hp.com | Filton Road, | Stoke Gifford, | Bristol. BS12 6QZ. | ENGLAND. -----------------------------------------------------------------

This response does not represent the official position of, or statement by, the Hewlett-Packard Company. The above data is provided for informational purposes only. It is supplied without warranty of any kind.

/************************************************************* * * dds_changer.c * * Utility to control a DDS autochanger (eg. C1553A, C156XA) * HP S700 and SOLARIS only. * * Kevin Jones kev@hpcpbla.bri.hp.com * * eg. dds_changer [123456ne] /dev/rmt/3hcn * * 1..6 = Select cartridge * n = next cartridge * e = eject magazine * ******************************************************************* * * To make: cc -o dds_changer dds_changer.c * * For HPUX * You must use with major number 121, eg. * crw-rw-rw- 1 bin bin 121 0x20130f Feb 26 1993 3hcn * ***************************************************************/

#define SOLARIS

#include <stdio.h> #include <fcntl.h> #include <sys/ioctl.h>

#ifdef HPUX #include <sys/scsi.h> #else #ifdef SOLARIS #include <sys/scsi/impl/uscsi.h> #endif #endif

int fd; int temp = 1;

main(argc, argv)

int argc; char *argv[];

{ #ifdef HPUX struct sctl_io sctl_io; #else #ifdef SOLARIS struct uscsi_cmd scsi_cmd, *cmd = &scsi_cmd; #endif #endif

if (argc < 3) { fprintf (stderr, "Usage: dds_changer [123456ne] device-filename\n"); exit(1); }

#ifdef HPUX if ((fd = open (argv[2], O_RDWR | O_NDELAY)) < 0) #else #ifdef SOLARIS if ((fd = open(argv[1], O_RDWR | O_NONBLOCK)) < 0) if ((fd = open(argv[1], O_RDWR | O_NONBLOCK)) < 0) #endif #endif { fprintf (stderr, "Couldn't open device: %s\n", argv[2]); exit(1); }

#ifdef HPUX sctl_io.cdb_length = 6; sctl_io.data_length = 0; sctl_io.max_msecs = 100000; /* Allow 100 seconds */ sctl_io.flags = 0; /* Wrt, No WDTR, No ADTR, Use ATN */ sctl_io.cdb[0] = 0x1B; sctl_io.cdb[1] = 0x00; sctl_io.cdb[2] = 0x00; sctl_io.cdb[3] = 0x00; sctl_io.cdb[4] = 0x00; sctl_io.cdb[5] = 0x00; #else #ifdef SOLARIS cmd->uscsi_cdblen = 0x06; cmd->uscsi_timeout = 30000; cmd->uscsi_flags = USCSI_WRITE; cmd->uscsi_bufaddr = 0; cmd->uscsi_buflen = 0; cmd->uscsi_cdb[0] = 0x1B; cmd->uscsi_cdb[1] = 0x00; cmd->uscsi_cdb[2] = 0x00; cmd->uscsi_cdb[3] = 0x00; cmd->uscsi_cdb[4] = 0x00; cmd->uscsi_cdb[5] = 0x00; #endif #endif

switch (*argv[1]) { case 'e' : #ifdef HPUX sctl_io.cdb[5] = 0x80; #else #ifdef SOLARIS cmd->uscsi_cdb[5] = 0x80; #endif #endif break; case 'n' : break; default : if ((*argv[1] >= '1') && (*argv[1] <= '6')) { #ifdef HPUX sctl_io.cdb[3] = *argv[1] - '0'; sctl_io.cdb[4] = 0x01; #else #ifdef SOLARIS cmd->uscsi_cdb[3] = *argv[1] - '0'; cmd->uscsi_cdb[4] = 0x01; #endif #endif break; } fprintf (stderr, "Unrecognized option\n"); close (fd); exit (1); }

for (temp = 0; temp < 2; ++temp) /* 2 tries in case we hit unit attention */ { #ifdef HPUX if (ioctl(fd, SIOC_IO, sctl_io) < 0) #else #ifdef SOLARIS if (ioctl (fd, USCSICMD ,cmd) < 0) #endif #endif { fprintf (stderr, "Failed to exec IOCTL command !\n"); close (fd); exit (1); }

#ifdef HPUX if (sctl_io.cdb_status == S_GOOD) { close (fd); exit (0); } else if ( (sctl_io.cdb_status != S_CHECK_CONDITION) || (sctl_io.sense_status != S_GOOD) || ((sctl_io.sense[2] & 0xF) != S_UNIT_ATTENTION) ) break; #endif }

fprintf (stderr, "Device Reported Error !\n"); close (fd); exit (1); }

Wolfgang Denk

Office: (+49)-89-722-41782 wd@uebemc.siemens.de Private: (+49)-89-95720-110, Fax -112 wd@denx.muc.de : I've tried (in vi) "g/[a-z]\n[a-z]/s//_/"...but that doesn't : cut it. Any ideas? (I take it that it may be a two-pass sort of solution). In the first pass, install perl. :-) Larry Wall <6849@jpl-devvax.JPL.NASA.GOV>



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:31 CDT