summaryrefslogtreecommitdiffstats
path: root/sys/cam/scsi/scsi_all.c
Commit message (Collapse)AuthorAgeFilesLines
* The divide by zero panic must have been due to a bogusmjacob2005-04-141-0/+9
| | | | | | | | | period value. I suppose the BT adapter driver should be fixed, but more importantly we should protect against dividing by zero. PR: kern/75603 MFC after: 1 week
* Reference a pointer correctly when copying to it's location.scottl2005-02-211-1/+1
| | | | Submitted by: Coverity Prevent analysis tool
* Start each of the license/copyright comments with /*-imp2005-01-051-1/+1
|
* When printing out an unknown sense code we should print it in hex, notmjacob2004-08-131-3/+1
| | | | | | decimal. Reviewed by: gibbs, nate, kdm
* SS_FATAL|ENXIO rather than SS_RDEF for illegal track mode.obrien2003-12-011-1/+1
| | | | | | | | This reduces the 90+ lines boot output of spewage GEOM does for my Plextor SCSI burner. Submitted by: scottl Approved by: scottl
* (scsi_request_sense): Set allocation length in REQUEST_SENSE CCB.thomas2003-09-211-0/+1
| | | | Reviewed by: ken
* Use __FBSDID().obrien2003-06-101-2/+3
|
* Don't use return(foo(...)); in a function returning void.phk2003-05-311-6/+8
| | | | Found by: FlexeLint
* Add support to CAM for devices with more than 2^32 blocks. (2TB if you'reken2003-04-301-14/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | using 512 byte blocks). cam_ccb.h: Bump up volume_size and cylinders in ccb_calc_geometry to 64 bits and 32 bits respectively, so we can hold larger device sizes. cylinders would overflow at about 500GB. Bump CAM_VERSION for this change. Note that this will require a recompile of all applications that talk to the pass(4) driver. scsi_all.c: Add descriptions for READ/WRITE(16), update READ/WRITE(12) descriptions, add descriptions for SERVICE ACTION IN/OUT. Add a new function, scsi_read_capacity_16(), that issues the read capacity service action. (Necessary for arrays larger than 2^32 sectors.) Update scsi_read_write() to use a 64 bit LBA and issue READ(16) or WRITE(16) if necessary. NOTE the API change. This should be largely transparnet to most userland applications at compile time, but will break binary compatibility. The CAM_VERSION bump, above, also serves the purpose of forcing a recompile for any applications that talk to CAM. scsi_all.h: Add 16 byte READ/WRITE structures, structures for 16 byte READ CAPACITY/SERVICE ACTION IN. Add scsi_u64to8b() and scsi_8btou64. scsi_da.c: The da(4) driver probe now has two stages for devices larger than 2TB. If a standard READ CAPACITY(10) returns 0xffffffff, we issue the 16 byte version of read capacity to determine the true array capacity. We also do the same thing in daopen() -- use the 16 byte read capacity if the device is large enough. The sysctl/loader code has also been updated to accept 16 bytes as a minimum command size.
* Fix ATAPI/USB/Firewire CDROM drive handling in cd(4) and hopefully fixken2003-02-211-4/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a number of related problems along the way. - Automatically detect CDROM drives that can't handle 6 byte mode sense and mode select, and adjust our command size accordingly. We have to handle this in the cd(4) driver (where the buffers are allocated), since the parameter list length is different for the 6 and 10 byte mode sense commands. - Remove MODE_SENSE and MODE_SELECT translation removed in ATAPICAM and in the umass(4) driver, since there's no way for that to work properly. - Add a quirk entry for CDROM drives that just hang when they get a 6 byte mode sense or mode select. The reason for the quirk must be documented in a PR, and all quirks must be approved by ken@FreeBSD.org. This is to make sure that we fully understand why each quirk is needed. Once the CAM_NEW_TRAN_CODE is finished, we should be able to remove any such quirks, since we'll know what protocol the drive speaks (SCSI, ATAPI, etc.) and therefore whether we should use 6 or 10 byte mode sense/select commands. - Change the way the da(4) handles the no_6_byte sysctl. There is now a per-drive sysctl to set the minimum command size for that particular disk. (Since you could have multiple disks with multiple requirements in one system.) - Loader tunable support for all the sysctls in the da(4) and cd(4) drivers. - Add a CDIOCCLOSE ioctl for cd(4) (bde pointed this out a long time ago). - Add a media validation routine (cdcheckmedia()) to the cd(4) driver, to fix some problems bde pointed out a long time ago. We now allow open() to succeed no matter what, but if we don't detect valid media, the user can only issue CDIOCCLOSE or CDIOCEJECT ioctls. - The media validation routine also reads the table of contents off the drive. We use the table of contents to implement the CDIOCPLAYTRACKS ioctl using the PLAY AUDIO MSF command. The PLAY AUDIO TRACK INDEX command that we previously used was deprecated after SCSI-2. It works in every SCSI CDROM I've tried, but doesn't seem to work on ATAPI CDROM drives. We still use the play audio track index command if we don't have a valid TOC, but I suppose it'll fail anyway in that case. - Add _len() versions of scsi_mode_sense() and scsi_mode_select() so that we can specify the minimum command length. - Fix a couple of formatting problems in the sense printing code. MFC after: 4 weeks
* A SCSI_DELAY of zero is a legitimate value to have.mjacob2002-09-231-2/+4
| | | | The notion that you must "always" have a delay is at best misinformed.
* Make SCSI_DELAY setable at boot time and runtime via thebrooks2002-09-021-0/+80
| | | | | | kern.cam.scsi_delay tunable/sysctl. Reviewed by: mdodd, njl
* Adjust scsi_calc_syncparam() to the exception table changing from 10ths togibbs2002-08-261-2/+4
| | | | | 100ths of ns. This should correct a problem with camcontrol "ignoring" requests to negotiate to slower speeds.
* Add the 160MHz syncrate to scsi_calc_syncrate() sync period exception table.gibbs2002-06-051-6/+7
|
* Add REPORT LUNS basic infrastructure.mjacob2002-06-041-15/+39
|
* Remove unused static variable quantum.marcel2002-04-231-2/+0
|
* Fix 3 of the four problems with my last indentation fix. ("fixing" theken2002-04-011-4/+2
| | | | | | | | fourth would be a divergence from the prevailing style.) Thanks to bde for catching this. Pointed out by: bde
* Fix an indentation problem.ken2002-04-011-7/+7
|
* Add support for Simplified Direct Access Device in scsi_op_desc().simokawa2002-03-111-0/+4
|
* - Add support for Simplified Direct Access Device, mostly forsimokawa2002-02-211-0/+6
| | | | | | | | Firewire/SBP-II devices. - Add quirk for Logitec USB/Firewire HDD. MFC after: 3 days.
* Fix bug in scsi_read_write() where it might use 6-byte commands whenkbyanc2001-11-061-5/+4
| | | | | | | 10/12-byte-specific flags where specified. Reviewed by: ken MFC after: 1 day
* Add interfaces for SCSI LOG SELECT and LOG SENSE commands.kbyanc2001-08-271-0/+67
| | | | Reviewed by: ken
* Eliminate the hot-spare 'r' in Arrray.phk2001-08-101-1/+1
| | | | Submitted by: Søren Schrøder <sch@chaos.dk>
* Print out the asc/ascq and description even when both the asc and ascqken2001-05-271-4/+2
| | | | | are zero. This is so that users will see the "no addtional sense" printout and know that they have the full sense information.
* Add q quirk for the old SONY SMO drive i've been sitting upon in myjoerg2001-05-051-0/+16
| | | | | private tree for too long now. This (pre SCSI-2) drive returns a mystic code when the medium is inserted but not spun up.
* Add sense key table entries for DATA PROTECT and BLANK CHECK. This willken2001-04-301-0/+2
| | | | | | | prevent scsi_sense_desc() from deferencing a NULL pointer when a drive happens to return one of these sense keys. Reported by: Michael Samuel <michael@miknet.net>
* Fix an errant search and replace that broke SCSI start unit commands.ken2001-04-301-1/+1
| | | | This should fix automatic spinups as well as 'camcontrol start'.
* Rewrite of the CAM error recovery code.ken2001-03-271-999/+835
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
* In the SCSI_NO_SENSE_STRINGS case, properly fill the table with thegibbs2001-02-241-1/+1
| | | | | | | asc and ascq pair rather than asc, asc. PR: 25291 Submitted by: Stephen Ferrari <sferrari@yahoo.com>
* Restore a print_sense=FALSE that got nuked by accident in last delta.mjacob2001-02-221-0/+1
| | | | Noticed by: Dan Nelson <dnelson@emsphone.com>
* 1. The key SSD_KEY_RECOVERED_ERROR is not an error at all and shouldmjacob2001-02-111-7/+15
| | | | | | | | | | | | | | | | | | | | not be retried. It is an indication that there was an error that was corrected during the execution of the command. This is per ANSI SCSI2 spec. It's possible that these should also be noted to the console (as indicative, perhaps, of growing media defect lists in drives), but the default of printing errors out if bootverbose in this case is probably enough. Also, there'd been a missing ERESTART for that clause anyway. 2. If you have an ABORTED COMMAND, it's almost invariably a SCSI parity error. You should never be silent about these since users should do something about this if it occurs (moving that power cord *away* from the SCSI cable is always a good first start). This should print irrespective of bootverbose because it's an actual real error even if we retry a transmission. Reviewed by: audit@freebsd.org, gibbs@freebsd.org
* Remove unused #includesphk2000-10-301-1/+0
| | | | Reviewed by: ken
* Add quirk entries from Andre Albsmeier to disable the sync cache commandken2000-08-291-8/+0
| | | | | | | | | | | | | | for the Quantum "MAVERICK 540S" and "LPS525S". Also, add common string variables, since we seem to have a few Quantum and Micropolis drives in here. Fix the 'quantum' variable usage in scsi_all.c that likely got broken when someone staticized things in cam_xpt.c. (That particular problem would cause Quantum Fireball ST drives to not get spun up if they were not already spinning.) Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
* scsi_all.c:gibbs2000-07-181-7/+6
| | | | | | | | | Clean up the comments related to the high speed sync rate table for SPI. scsi_message.h: Bring in some SCSI3 message terminology. All SCSI2 names are still preserved for backwards compatibility.
* Fix 'camcontrol inquiry'. The inquiry data structure changes (increased token2000-02-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 256 bytes) caused it to break on many devices. The SCSI spec says that for commands with 8-bit length fields, a value of 0 means 256 bytes. As it turns out, many devices don't deal with that properly. Some interpret the 0 as 0, and return no data. Others return more than 256 bytes of data, and cause an overrun. The fix is to tell the device we've only allocated SHORT_INQUIRY_LENGTH (36 bytes) of inquiry data, instead of sizeof(struct scsi_inquiry_data). camcontrol.c: Change inq_len in the call to scsi_inquiry() to SHORT_INQUIRY_LENGTH, and add a long comment explaining the reason for the change. scsi_all.h: Add a comment above the definitinon of SHORT_INQUIRY_LENGTH alerting people that it is both the initial probe inquiry length, and the minimum amount of data needed for scsi_print_inquiry() to function. scsi_all.c: Add a comment about SHORT_INQUIRY_LENGTH being the minimum amount of data needed for scsi_print_inquiry() to function. Reviewed by: gibbs Approved by: jkh Reported by: "John W. DeBoskey" <jwd@unx.sas.com>
* Go for the gusto and do the full 256 bytes for inquiry data.mjacob2000-01-251-0/+7
| | | | Obtained from:gibbs@freebsd.org
* Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"peter1999-12-291-10/+10
| | | | | | is an application space macro and the applications are supposed to be free to use it as they please (but cannot). This is consistant with the other BSD's who made this change quite some time ago. More commits to come.
* Add FAST-80 timing to the scsi syncrates table.obrien1999-12-161-0/+1
| | | | Submitted by: Gerard Roudier <groudier@club-internet.fr>
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Do not attempt to retry commands that fail with ILLEGAL REQUEST status.gibbs1998-12-111-3/+3
|
* print the appropriate SCSI revision (with CCS as a proper name for the ↵mjacob1998-12-061-4/+8
| | | | announce message
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()archie1998-12-041-13/+4
| | | | | | | | | | | | | | for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com>
* Fix several potential buffer overrun conditions. These changes have beenken1998-10-151-23/+109
| | | | | | | | tested both in the kernel and in userland. Also, fix a couple of printf warnings that show up when CAMDEBUG is defined. Reviewed by: imp Partially submitted by: imp
* Add a new CAM debugging mode, CAM_DEBUG_CDB. This causes the kernel token1998-10-021-2/+2
| | | | | | | | | | | | | print out a one line description/dump of every SCSI CDB sent to a particular debugging target or targets. This is a good bit more useful than the other debugging modes, I think. Change some things in LINT to note the availability of this new option. Fix an erroneous argument to scsi_cdb_string() in scsi_all.c Reviewed by: gibbs
* In the bootverbose case, print out error messages for all errors that willken1998-09-291-7/+16
| | | | | | not be retried again, even if the SF_NO_PRINT flag is set. Reviewed by: gibbs
* Fix error recovery in scsi_interpret_sense(). It turns out that ERESTARTken1998-09-191-15/+27
| | | | | | | | | | | wasn't getting sent back for most errors, even if there were retries left on the command. I'm not sure how I ever let this slip by before... In any case, we now send back ERESTART if there are retries left for the command, and send back the default error code when there are no retries left. Reviewed by: gibbs
* Fix the CAM code so that people can compile kernels with the CD driver butken1998-09-181-5/+138
| | | | | | | | | | | | | | | | | without the DA driver. The problem was that the CD driver depended on scsi_read_write() and scsi_start_stop(), which were defined in scsi_da.c. I moved both functions, and their associated data structures and defines from scsi_da.* to scsi_all.*. This is technically the "wrong" thing to do since those commands are really only for direct-access type devices, not for all SCSI devices. I think, though, that the advantage (allowing people to compile kernels without the disk driver) outweighs any architectural purity arguments. PR: kern/7969 Reviewed by: gibbs
* SCSI Peripheral drivers for CAM:gibbs1998-09-151-0/+2678
da - Direct Access Devices (disks, optical devices, SS disks) cd - CDROM (or devices that can act like them, WORM, CD-RW, etc) ch - Medium Changer devices. sa - Sequential Access Devices (tape drives) pass - Application pass-thru driver targ - Target Mode "Processor Target" Emulator pt - Processor Target Devices (scanners, cpus, etc.) Submitted by: The CAM Team
OpenPOWER on IntegriCloud