summaryrefslogtreecommitdiff
path: root/sys/scsi
AgeCommit message (Collapse)Author
2021-10-24Constify struct cfattach.Martin Pieuchot
ok visa@ a long time ago, ok krw@
2021-08-31add support for obtaining sense status and source slot of a mediaRobert Nagy
this fixes a bug in bacula where the catalog was not properly kept up-to-date if a tape was in a drive becuse its source slot was unknown based on code from FreeBSD; ok krw@ picker 0: sense: <0x00/0x00> voltag: <:0> avoltag: <:0> source: <> slot 0: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1168L1:0> avoltag: <:0> source: <slot 0> slot 1: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1187L1:0> avoltag: <:0> source: <slot 1> slot 2: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1184L1:0> avoltag: <:0> source: <slot 2> slot 3: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1195L1:0> avoltag: <:0> source: <slot 3> slot 4: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1037L1:0> avoltag: <:0> source: <slot 4> slot 5: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1038L1:0> avoltag: <:0> source: <slot 5> slot 6: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1166L1:0> avoltag: <:0> source: <slot 6> slot 7: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1167L1:0> avoltag: <:0> source: <slot 7> slot 8: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1180L1:0> avoltag: <:0> source: <slot 8> slot 9: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1186L1:0> avoltag: <:0> source: <slot 9> slot 10: <ACCESS> sense: <0x00/0x00> voltag: <:0> avoltag: <:0> source: <picker 0> slot 11: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1182L1:0> avoltag: <:0> source: <slot 11> slot 12: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1181L1:0> avoltag: <:0> source: <slot 12> slot 13: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1196L1:0> avoltag: <:0> source: <slot 13> slot 14: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1169L1:0> avoltag: <:0> source: <slot 14> slot 15: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1197L1:0> avoltag: <:0> source: <slot 15> slot 16: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1165L1:0> avoltag: <:0> source: <slot 16> slot 17: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1199L1:0> avoltag: <:0> source: <slot 17> slot 18: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1189L1:0> avoltag: <:0> source: <slot 18> slot 19: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1185L1:0> avoltag: <:0> source: <slot 19> slot 20: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1198L1:0> avoltag: <:0> source: <slot 20> slot 21: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1039L1:0> avoltag: <:0> source: <slot 21> slot 22: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1035L1:0> avoltag: <:0> source: <slot 22> slot 23: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1188L1:0> avoltag: <:0> source: <slot 23> drive 0: <ACCESS,FULL> sense: <0x00/0x00> voltag: <XX1183L1:0> avoltag: <:0> source: <slot 10>
2021-05-13Whitespace fix for unintentional unindenting event in r1.260.Kenneth R Westerback
Reported by Ashton Fagg via tech@. Thanks!
2021-03-12spellingJonathan Gray
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-23Remove 'void *sc_sdhook' member of sd_softc.Kenneth R Westerback
Unused since mpi@ removed sd_shutdown() in 2014.
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-14No need to check for SDEV_DYING as the first thing in both branches of anKenneth R Westerback
if/else. Just do it once before the if. Move the SC_DEBUG() documenting entry into sdopen() to before the various error bailouts.
2020-09-13Always use READ(16)/WRITE(16) commands for disks large enough to requireKenneth R Westerback
READ(16)/WRITE(16) to access the last sectors Fixes (at least) large 512E (a.k.a. emulated 512-byte sector) devices plugged into overly helpful USB <-> ATA/ATAPI bridges. Which can tell you they are using 512-byte sector addresses but spontaneously/silently interpret READ(10)/WRITE(10) commands as using 4K sector addresses/sizes. Diagnosed and fix tested with James Cook. Thanks!
2020-09-12Use SID_SCSI2_RESPONSE instead of '2' when checking INQUIRY data format.Kenneth R Westerback
2020-09-12No need to check inq for NULL when it always points at the inqdata inside aKenneth R Westerback
scsi_link.
2020-09-12No need to ask for extra INQUIRY data, all available data is already cached inKenneth R Westerback
scsi_link's inqdata.
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-02Add #define SID_SCSI2_RESPONSE 0x2 to allow elimination of another bunch ofKenneth R Westerback
magic numbers. As the nearby comment says '< 2 is obsolete. >2 is reserved'. So 0x2 is just right.
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-29More recent MMC specificiations add READ(12)/WRITE(12). So add cd_cmd_rw12()Kenneth R Westerback
and let cdstart() use it if the requested i/o is unable to fit into a READ(10). Certainly better than silently truncating the i/o into a READ(10)/WRITE(10).
2020-08-29Use ISSET() to check b_flags for B_READ.Kenneth R Westerback
2020-08-29Missing u_int -> u_int32_t chunks from previous.Kenneth R Westerback
2020-08-29Use u_int32_t for nsecs, making it crystal clear that the valuesKenneth R Westerback
are expected to fit into a 4-byte field.
2020-08-29Have [cd|sd]_cmd_rw[6|10|12|16] return the length of the created command andKenneth R Westerback
have the caller assign it to xs->cmdlen. Pass in xs->cmd instead of xs. A slightly cleaner API that provides the potential of detecting and reacting to a failure to create the desired command.
2020-08-28Shuffle [cd|sd]start code into closer alignment. Move the initialization of theKenneth R Westerback
xs fields to a more convenient location, shrinking upcoming diffs. Nuke some Captain Obvious comments.
2020-08-28Abstract cd_cmd_rw6() and cd_cmd_rw10() a la sd_cmd_rw6() and sd_cmd_rw10().Kenneth R Westerback
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-26Remove needless uses of SDEV_ONLYBIG. It was always set when SDEV_UMASS was set,Kenneth R Westerback
and was always checked in concert with SDEV_ATAPI. Just rely on SDEV_ATAPI and SDEV_UMASS in all but the one place sd(4) where SDEV_ONLYBIG is set independently of SDEV_ATAPI/_UMASS. ok jmatthew@
2020-08-22The last timeout_add(sc_timeout) died in the great XS_NO_CCB purge of 2017. NukeKenneth R Westerback
pointless timeout_set(sc_timoeut) and timeout_del(sc_timeout) calls and the sc_timeout fields themselves.
2020-08-20Revert DYING. At least some USB memory sticks get very upset.Kenneth R Westerback
2020-08-19Replace last 2 'blah & (flag1 | flag2) == 0' with !ISSET(blah, (flag1 | flag2)).Kenneth R Westerback
2020-08-19Nuke SDF_DYING, CDF_DYING and ST_DYING flags. Use the scsi_link flagKenneth R Westerback
SDEV_S_DYING instead. Makes it clear that the scsi_link and the [cd|sd|st] device always agree on their state.
2020-08-18Try to avoid a theoretical infinite loop while detaching all the scsi_link's onKenneth R Westerback
the bus. Use SLIST_FOREACH_SAFE() rather than 'while (!SLIST_EMPTY())'' as there is a condition which would cause scsi_detach_link() to return without removing the scsi_link from the SLIST.
2020-08-16Don't include scsi_debug.h via scsiconf.h. Nobody but scsi/* should be using theKenneth R Westerback
contents thereof. Compile tests by martjn@ (alpha), visa@ (sgi) jmatthew@ (sparc64) aoyama@ (luna88k)
2020-08-15The last SET()s of CDF_WAITING, SDF_WAITING, and ST_WAITING died in the greatKenneth R Westerback
XS_NO_CCB purge of 2017. Nuke pointless ISSET()/CLR() checks and the #define's.
2020-08-14Redistribute and tweak the scsi_[attach|probe|detach]_[bus|target|lun]() code toKenneth R Westerback
make the three variants more similar and easier to understand. Ensures consistent error checks and eliminates pointless adapter_buswidth checks when processing the list of scsi_links.
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-08-10Minor code shuffle to get all *_activate(), *_probe() and *_detach() functionsKenneth R Westerback
nestled together. Rename scsibusprint() to scsibussubprint() since it is used with scsibussubmatch().
2020-08-09More code shuffling. Fix a rename missed in previous.Kenneth R Westerback
2020-08-09Shuffle functions and declarations around to more logical grouping. Nuke someKenneth R Westerback
leading whitespace. Rename some local functions.
2020-08-08scsi_link's are born knowing their bus. Use that instead of passing extraKenneth R Westerback
scsibus_softc pointers around.
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-22Nuke unused struct scsi_link members of adapter softc's where theKenneth R Westerback
driver successfully compiles on one or more of amd64, i386, hppa.
2020-07-20Move remaining scsi bus initialization info from "prototype scsi link"Kenneth R Westerback
fields to struct scsibus_attach_args. Nuke the struct scsi_link * (saa_sc_link) in scaibus_attach_args. Explicitly initialize each field in scsibus_attach_args variables.
2020-07-19Move the adapter related items (luns, adapter, adapter_target,Kenneth R Westerback
adapter_buswidth, adapter_softc) from struct scsi_link to struct scsibus_attach_args. Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).
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-07-16Beef up struct scsibus_softc to hold the information needed toKenneth R Westerback
initialize the scsi_link's on the bus. After sucking this information out of the "prototype" link provided by the scsibus_attach_arg, no need to keep a pointer to that prototype.
2020-07-05Nuke struct scsi_link's "scsibus" member. The two drivers using itKenneth R Westerback
(ahc(4) and qlw(4)) can just compare the values of the "bus" member directly. A slightly different path to the same result that matthew@ traversed in his work culminating in scsiconf.h r1.146.
2020-06-30Nuke unneeded 'sa_inqbuf' member of struct scsi_attach_args. It alwaysKenneth R Westerback
points to the inquiry data contained in the struct scsi_link pointed to by the other member, sa_sc_link.
2020-06-30Garbage collect SDEV_S_WAITING, last used in scsi_base.c r1.167 inKenneth R Westerback
2010. Part of matthew@'s reverted scsiconf.h r1.146.