summaryrefslogtreecommitdiff
path: root/sys/scsi/scsi_base.c
AgeCommit message (Collapse)Author
2021-05-13Whitespace fix for unintentional unindenting event in r1.260.Kenneth R Westerback
Reported by Ashton Fagg via tech@. Thanks!
2020-11-19TL;DR -- don't configure devices that return insufficient INQUIRY data.Kenneth R Westerback
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@.
2020-10-14Introduce scsi_copy_internal_data() to copy 'faked' data from a driver to aKenneth R Westerback
scsi_xfer. Will replace various equivalent functions/hand-rolled chunks, none of which were setting xs->resid.
2020-09-22Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'Kenneth R Westerback
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@
2020-09-08If SCSI_IGNORE_ILLEGAL_REQUEST is set no error is returned from scsi_xs_sync()Kenneth R Westerback
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@
2020-09-05Rename SID_INQUIRY_HDR (a.k.a. 5) to more explicit SID_SCSI2_HDRLEN and use itKenneth R Westerback
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.
2020-09-01Rename [READ|WRITE]_BIG to [READ|WRITE]_10. Rename struct scsi_rw_big toKenneth R Westerback
struct scsi_rw_10. ok gnezdo@ jmatthew@ (who also did sparc64 compile test)
2020-08-30Compactify SDEV_/ADEV_ flags & quirks to eliminate the gaps in bit use and thusKenneth R Westerback
allow shrinking the names arrays.
2020-08-28Nuke CDF_ANCIENT, SDF_ANCIENT SDEV_ONLYBIG and bogus check of SID_RelAdr inKenneth R Westerback
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.
2020-08-19Replace last 2 'blah & (flag1 | flag2) == 0' with !ISSET(blah, (flag1 | flag2)).Kenneth R Westerback
2020-08-11Explicitly #include <scsi/scsi_debug.h> rather than assuming scsiconf.h will doKenneth R Westerback
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.
2020-07-27Refactor scsi_show_flags() to allow 32-bit flags. Display unnamed flags as oneKenneth R Westerback
hex value after named flags. Make flag name arrays NULL terminated rathar than fixed size.
2020-07-27SDEV_2NDBUS is gone. Update flagnames[] appropriately.Kenneth R Westerback
2020-07-16Access scsibus_softc info (luns, adapter, adapter_target,Kenneth R Westerback
adapter_softc, adapter_buswidth) via link->bus rather than using copies currently residing in the link.
2020-03-12Pass scsi_mode_sense_buf pointers to scsi_mode_sense[_buf]() ratherKenneth R Westerback
than scsi_mode_header[_big] pointers to the same data. Continues the umtamgling and simplification of the mode sense code. CID 1491299 CID 1491297
2020-03-12Check for short mode sense error inside scsi_mode_sense_big()Kenneth R Westerback
rather than after the only invocation. No functional change.
2020-03-12Eliminate 'len' parameter from scsi_mode_sense[_big](). It'sKenneth R Westerback
always sizeof(struct scsi_mode_sense_buf). No functional change.
2020-03-11No need to pass 20000 to scsi_mode_sense[_big]() as the desiredKenneth R Westerback
xs->timeout. Just set xs->timeout to 20000 and drop the parameter. No functional change.
2020-01-22scsi_delay(): sleep without lboltcheloha
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@
2019-12-06Various cleanup tweaks. 'return' is not a function. KNF. Whitespace,Kenneth R Westerback
Comment fixes.
2019-12-05Don't discard error from mode sense (6) if mode sense (10) isKenneth R Westerback
not attempted.
2019-12-05Shrink scsi_mode_do_sense() parameter list by eliminating the threeKenneth R Westerback
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.
2019-12-05No need for 'byte2' parameter to scsi_mode_sense[_big]() since weKenneth R Westerback
always pass 0. i.e. never disable block descriptors, never accept long LBA values.
2019-12-05Move prototypes for scsi_mode_sense(), scsi_mode_sense_big(),Kenneth R Westerback
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().
2019-12-04Convert infinite sleeps to {m,t}sleep_nsec(9).Martin Pieuchot
ok krw@, jca@
2019-12-03Check for expected mode sense page code as well as expected mode page length ↵Kenneth R Westerback
when constructing the pointer to the page data. Remove now unneeded DISK_PGCODE(). Usual misc whitespace/modernization tweaks to functions being modified.
2019-12-03Add display of mode sense data to SCSIDEBUG.Kenneth R Westerback
2019-12-02Have SCSIDEBUG show the number of bytes of VPD inquiry data received,Kenneth R Westerback
not the number of bytes that were available in the buffer.
2019-12-02Don't forget the scsi_vpd_header when calculating the number of bytesKenneth R Westerback
obtained by scsi_inquire_vpd().
2019-12-01Tweak variable names to be consistent with 'pg_code' and 'pg_length'Kenneth R Westerback
field names in sense mode structs.
2019-12-01Make prototype and implementation signatures the same by removingKenneth R Westerback
'const' from the only two 'const int' instances.
2019-11-28Abstract mode sense block descriptor parsing into a separate function.Kenneth R Westerback
2019-11-28Align an annoying comment.Kenneth R Westerback
2019-11-28Always pass a pointer to 'big' to scsi_do_mode_sense().Kenneth R Westerback
Sets up some simplifications.
2019-11-26Don't zero existing values for density, block_count and block_size inKenneth R Westerback
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@
2019-11-25Move struct scsi_read_cap_data and struct scsi_read_cap_data_16 toKenneth R Westerback
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.
2019-11-23Consistently use ISSET() to check for set flags.Kenneth R Westerback
2019-11-23Consistently use !ISSET() to check for unset flags.Kenneth R Westerback
2019-11-22Be consistent and always use CLR() to clear flags.Kenneth R Westerback
2019-11-21Be consistent and always use [!]ISSET() to test flags in xs->flags.Kenneth R Westerback
2019-11-21Be consistent and always use SET() to set flags in xs->flags.Kenneth R Westerback
2019-11-09Fix SCSIDEBUG display of VPD inquiry data.Kenneth R Westerback
Remove extraneous whitespace in SCSIDEBUG read capacity display.
2019-09-29Introduce SC_DEBUG_SENSE() and simplify code by eliminating a bunchKenneth R Westerback
of three line SCSIDEBUG chunks.
2019-09-29Move some logic inside scsi_show_xs() instead of surrounding theKenneth R Westerback
single invocation of the same. Clearer.
2019-09-29Tweak some whitespace to make autoindenter happy. Use consistent naming ↵Kenneth R Westerback
idiom for the debug functions.
2019-09-27Add/tweak #endif comments to make spelunking via grep more rewarding.Kenneth R Westerback
2019-09-27Shuffle and consolidate SCSIDEBUG declarations into fewer sections inKenneth R Westerback
more intuitive locations.
2019-09-23When printing the scsi_link info under SCSIDEBUG show state, luns,Kenneth R Westerback
openings, flags and quirks.
2019-09-21Expand scsi_inquiry_data to 96 bytes to include new fields. If theKenneth R Westerback
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.
2019-09-20Print inquiry and read capacity (10 and 16) data under SCSIDEBUG.Kenneth R Westerback