summaryrefslogtreecommitdiffstats
path: root/sys/scsi/scsi_base.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* TL;DR -- don't configure devices that return insufficient INQUIRY data.krw2020-11-191-24/+27
| | | | | | | | | | | | | | | Treat INQUIRY data with fewer than SID_SCSI2_HDRLEN bytes as invalid. Use only INQUIRY data returned by the device. Get all available INQUIRY data (up to sizeof(struct scsi_inquiry_data)) even when SCSIDEBUG is not set. Tweak returned INQUIRY data so additional_length field does not point past end of returned data when available data is greater than sizeof(struct scsi_inquiry_data). Missing dmafree() spotted by gnezdo@. ok jmatthew@.
* Introduce scsi_copy_internal_data() to copy 'faked' data from a driver to akrw2020-10-141-1/+21
| | | | | scsi_xfer. Will replace various equivalent functions/hand-rolled chunks, none of which were setting xs->resid.
* Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'krw2020-09-221-16/+15
| | | | | | | | | | | | member of 'struct scsi_xfer' has always been pointed at the 'struct scsi_generic cmdstore' member of the same instance. So nuke 'cmdstore' and remove the '*' from cmd. Take the address of cmd as required by the various casts. No intentional functional change. luna88k test by aoyama@, sparc64 test by jmatthew@ Identification of 2009's last *cmd use and ok jmatthew@
* If SCSI_IGNORE_ILLEGAL_REQUEST is set no error is returned from scsi_xs_sync()krw2020-09-081-2/+5
| | | | | | | | | | | when the request is unsupported. So check mode sense(6) and mode sense(10) results for valid headers before passing the results back. Avoid overwriting any error that was returned. ok jmatthew@
* Rename SID_INQUIRY_HDR (a.k.a. 5) to more explicit SID_SCSI2_HDRLEN and use itkrw2020-09-051-7/+8
| | | | | | | | to replace various uses of '5' when calculating the amount of data in the INQUIRY response. Matches up more naturally with SID_SCSI2_ALEN. Also use to fix SCSIDEBUG display of INQUIRY responses to show correct count of bytes received/available.
* Rename [READ|WRITE]_BIG to [READ|WRITE]_10. Rename struct scsi_rw_big tokrw2020-09-011-6/+6
| | | | | | struct scsi_rw_10. ok gnezdo@ jmatthew@ (who also did sparc64 compile test)
* Compactify SDEV_/ADEV_ flags & quirks to eliminate the gaps in bit use and thuskrw2020-08-301-8/+1
| | | | allow shrinking the names arrays.
* Nuke CDF_ANCIENT, SDF_ANCIENT SDEV_ONLYBIG and bogus check of SID_RelAdr inkrw2020-08-281-2/+2
| | | | | | | favour of simply using the device's claimed SCSI level of support. Except of course for ATAPI/USB devices which often don't claim anything. Keep assuming they are at least SCSI-2. Use consistant tests in sdminphys/cdminphys/sdstart/cdstart.
* Replace last 2 'blah & (flag1 | flag2) == 0' with !ISSET(blah, (flag1 | flag2)).krw2020-08-191-2/+2
|
* Explicitly #include <scsi/scsi_debug.h> rather than assuming scsiconf.h will dokrw2020-08-111-1/+2
| | | | | | | it. Prepares for removal of #include <scsi/scsi_debug.h> from scsiconf.h as soon as the alpha tester digs out from hurricane to compile last untested files.
* Refactor scsi_show_flags() to allow 32-bit flags. Display unnamed flags as onekrw2020-07-271-23/+30
| | | | | hex value after named flags. Make flag name arrays NULL terminated rathar than fixed size.
* SDEV_2NDBUS is gone. Update flagnames[] appropriately.krw2020-07-271-2/+2
|
* Access scsibus_softc info (luns, adapter, adapter_target,krw2020-07-161-2/+2
| | | | | adapter_softc, adapter_buswidth) via link->bus rather than using copies currently residing in the link.
* Pass scsi_mode_sense_buf pointers to scsi_mode_sense[_buf]() ratherkrw2020-03-121-12/+13
| | | | | | | | | than scsi_mode_header[_big] pointers to the same data. Continues the umtamgling and simplification of the mode sense code. CID 1491299 CID 1491297
* Check for short mode sense error inside scsi_mode_sense_big()krw2020-03-121-3/+4
| | | | | | rather than after the only invocation. No functional change.
* Eliminate 'len' parameter from scsi_mode_sense[_big](). It'skrw2020-03-121-9/+13
| | | | | | always sizeof(struct scsi_mode_sense_buf). No functional change.
* No need to pass 20000 to scsi_mode_sense[_big]() as the desiredkrw2020-03-111-9/+9
| | | | | | | | xs->timeout. Just set xs->timeout to 20000 and drop the parameter. No functional change.
* scsi_delay(): sleep without lboltcheloha2020-01-221-7/+8
| | | | | | | | | | | | | | If we want to sleep for a multiple of seconds we can do that without involving lbolt. This may cause some paths to sleep longer than they have on average, as sleeping on lbolt wakes you up within one second, not after one second. If this is a problem we will need to shorten the intervals given to scsi_delay(). With insight from deraadt@. ok krw@
* Various cleanup tweaks. 'return' is not a function. KNF. Whitespace,krw2019-12-061-155/+155
| | | | Comment fixes.
* Don't discard error from mode sense (6) if mode sense (10) iskrw2019-12-051-4/+5
| | | | not attempted.
* Shrink scsi_mode_do_sense() parameter list by eliminating the threekrw2019-12-051-19/+10
| | | | | | | | | | | pointers returning possible block descriptor values for block size, block count and density. Most calls were passing "NULL, NULL, NULL" since they did not care. Call scsi_parse_blkdesc() directly in those few cases where one or more of the values is of interest. No intentional functional change.
* No need for 'byte2' parameter to scsi_mode_sense[_big]() since wekrw2019-12-051-9/+7
| | | | | always pass 0. i.e. never disable block descriptors, never accept long LBA values.
* Move prototypes for scsi_mode_sense(), scsi_mode_sense_big(),krw2019-12-051-1/+9
| | | | | | | scsi_mode_sense_page() and scsi_mode_sense_big_page() into scsi_base.c. They are just internal helper functions for scsi_do_mode_sense().
* Convert infinite sleeps to {m,t}sleep_nsec(9).mpi2019-12-041-5/+6
| | | | ok krw@, jca@
* Check for expected mode sense page code as well as expected mode page length whenkrw2019-12-031-11/+24
| | | | | | constructing the pointer to the page data. Remove now unneeded DISK_PGCODE(). Usual misc whitespace/modernization tweaks to functions being modified.
* Add display of mode sense data to SCSIDEBUG.krw2019-12-031-20/+46
|
* Have SCSIDEBUG show the number of bytes of VPD inquiry data received,krw2019-12-021-1/+3
| | | | not the number of bytes that were available in the buffer.
* Don't forget the scsi_vpd_header when calculating the number of byteskrw2019-12-021-2/+3
| | | | obtained by scsi_inquire_vpd().
* Tweak variable names to be consistent with 'pg_code' and 'pg_length'krw2019-12-011-14/+14
| | | | field names in sense mode structs.
* Make prototype and implementation signatures the same by removingkrw2019-12-011-3/+3
| | | | 'const' from the only two 'const int' instances.
* Abstract mode sense block descriptor parsing into a separate function.krw2019-11-281-36/+50
|
* Align an annoying comment.krw2019-11-281-2/+2
|
* Always pass a pointer to 'big' to scsi_do_mode_sense().krw2019-11-281-6/+3
| | | | Sets up some simplifications.
* Don't zero existing values for density, block_count and block_size inkrw2019-11-261-7/+1
| | | | | | | | | | scsi_do_mode_sense(). Just update the values when valid data is available. Initialize the variables passed to scsi_do_mode_sense() in the one instance where they weren't already set. Fixes issue with softraid crypto volumes on 4K-sector disks. Found, fix tested, and ok tim@
* Move struct scsi_read_cap_data and struct scsi_read_cap_data_16 tokrw2019-11-251-1/+73
| | | | | | | | | | | | | | | scsi_all.h. Add scsi_read_cap_10() and scsi_read_cap_16() functions to scsi_base.c, i.e. move logic to do actual READ_CAPACITY commands out of sd_read_cap() and sd_read_cap_16(). This will allow the READ_CAPACITY code to be reused by cd(4). Return -1 for errors where the error code is just discarded, reducing ENOMEM, ENXIO, EIO uses. No intentional functional change.
* Consistently use ISSET() to check for set flags.krw2019-11-231-14/+14
|
* Consistently use !ISSET() to check for unset flags.krw2019-11-231-4/+4
|
* Be consistent and always use CLR() to clear flags.krw2019-11-221-4/+4
|
* Be consistent and always use [!]ISSET() to test flags in xs->flags.krw2019-11-211-8/+8
|
* Be consistent and always use SET() to set flags in xs->flags.krw2019-11-211-2/+2
|
* Fix SCSIDEBUG display of VPD inquiry data.krw2019-11-091-5/+9
| | | | Remove extraneous whitespace in SCSIDEBUG read capacity display.
* Introduce SC_DEBUG_SENSE() and simplify code by eliminating a bunchkrw2019-09-291-4/+2
| | | | of three line SCSIDEBUG chunks.
* Move some logic inside scsi_show_xs() instead of surrounding thekrw2019-09-291-6/+8
| | | | single invocation of the same. Clearer.
* Tweak some whitespace to make autoindenter happy. Use consistent naming idiom forkrw2019-09-291-5/+5
| | | | the debug functions.
* Add/tweak #endif comments to make spelunking via grep more rewarding.krw2019-09-271-12/+12
|
* Shuffle and consolidate SCSIDEBUG declarations into fewer sections inkrw2019-09-271-66/+142
| | | | more intuitive locations.
* When printing the scsi_link info under SCSIDEBUG show state, luns,krw2019-09-231-1/+20
| | | | openings, flags and quirks.
* Expand scsi_inquiry_data to 96 bytes to include new fields. If thekrw2019-09-211-11/+34
| | | | | | | | device claims to have more than the 36 bytes of SCSI2 data, issue a 2nd INQUIRY (under SCSIDEBUG!) to get up to 96 bytes of data. Add some length sanity checks to debug output. Print VPD data under SCSIDEBUG.
* Print inquiry and read capacity (10 and 16) data under SCSIDEBUG.krw2019-09-201-1/+8
|
* Adopt the SCSI versioning #define's from FreeBSD. Eliminate thekrw2019-09-011-11/+7
| | | | | | | | | | | now unneeded version_to_spc() mapping array, a duplicate #define and a couple of magic numbers. Toss in some comments for future generations of spelunkers. Makes it possible to check for specific SPC versions when new features or eliminated features require such a check. No intentional functional change.