diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2006-11-27 18:24:44 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2006-11-27 18:24:44 +0000 |
commit | 99c759cf94d99e7cd02f6c3ea2afa67f31d4e728 (patch) | |
tree | 879e7643280a845f27692558dd7311201cdf4935 /sys/scsi | |
parent | 75f8a5de58263b14e936d1dfbac6861eade5ebb9 (diff) |
rework asc/ascq handling to get rid of "magic" 0x values in the code, changes
asc/ascq handling to deal with the pair together rather than seperately, since
modern scsi has long since polluted the "categories" of asc enough that you
pretty much need to always look as ascq.
ok krw@ deraadt@, dlg@
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/ch.c | 23 | ||||
-rw-r--r-- | sys/scsi/scsi_all.h | 36 | ||||
-rw-r--r-- | sys/scsi/scsi_base.c | 103 | ||||
-rw-r--r-- | sys/scsi/st.c | 23 |
4 files changed, 108 insertions, 77 deletions
diff --git a/sys/scsi/ch.c b/sys/scsi/ch.c index d57f25bda3e..c5960f3d2e5 100644 --- a/sys/scsi/ch.c +++ b/sys/scsi/ch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ch.c,v 1.29 2006/10/07 23:40:07 beck Exp $ */ +/* $OpenBSD: ch.c,v 1.30 2006/11/27 18:24:43 beck Exp $ */ /* $NetBSD: ch.c,v 1.26 1997/02/21 22:06:52 thorpej Exp $ */ /* @@ -789,20 +789,13 @@ ch_interpret_sense(xs) case SKEY_NOT_READY: if ((xs->flags & SCSI_IGNORE_NOT_READY) != 0) return (0); - switch (sense->add_sense_code) { - case 0x04: /* LUN not ready */ - switch (sense->add_sense_code_qual) { - case 0x01: /* Becoming Ready */ - SC_DEBUG(sc_link, SDEV_DB1, - ("not ready: busy (%#x)\n", - sense->add_sense_code_qual)); - /* don't count this as a retry */ - xs->retries++; - return (scsi_delay(xs, 1)); - default: - return (EJUSTRETURN); - } - break; + switch (ASC_ASCQ(sense)) { + case SENSE_NOT_READY_BECOMING_READY: + SC_DEBUG(sc_link, SDEV_DB1, ("not ready: busy (%#x)\n", + sense->add_sense_code_qual)); + /* don't count this as a retry */ + xs->retries++; + return (scsi_delay(xs, 1)); default: return (EJUSTRETURN); } diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h index 60f45cd52a5..8afc49003a7 100644 --- a/sys/scsi/scsi_all.h +++ b/sys/scsi/scsi_all.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_all.h,v 1.37 2006/07/29 02:52:49 krw Exp $ */ +/* $OpenBSD: scsi_all.h,v 1.38 2006/11/27 18:24:43 beck Exp $ */ /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */ /* @@ -313,6 +313,40 @@ struct scsi_sense_data { #define SKEY_MISCOMPARE 0x0E #define SKEY_RESERVED 0x0F + +/* Additional sense code info */ +#define ASC_ASCQ(ssd) ((ssd->add_sense_code << 8) | ssd->add_sense_code_qual) + +#define SENSE_NOT_READY_BECOMING_READY 0x0401 +#define SENSE_NOT_READY_FORMAT 0x0404 +#define SENSE_NOT_READY_REBUILD 0x0405 +#define SENSE_NOT_READY_RECALC 0x0406 +#define SENSE_NOT_READY_INPROGRESS 0x0407 +#define SENSE_NOT_READY_LONGWRITE 0x0408 +#define SENSE_NOT_READY_SELFTEST 0x0409 +#define SENSE_POWER_RESET_OR_BUS 0x2900 +#define SENSE_POWER_ON 0x2901 +#define SENSE_BUS_RESET 0x2902 +#define SENSE_BUS_DEVICE_RESET 0x2903 +#define SENSE_DEVICE_INTERNAL_RESET 0x2904 +#define SENSE_TSC_CHANGE_SE 0x2905 +#define SENSE_TSC_CHANGE_LVD 0x2906 +#define SENSE_IT_NEXUS_LOSS 0x2907 +#define SENSE_BAD_MEDIUM 0x3000 +#define SENSE_NR_MEDIUM_UNKNOWN_FORMAT 0x3001 +#define SENSE_NR_MEDIUM_INCOMPATIBLE_FORMAT 0x3002 +#define SENSE_NW_MEDIUM_UNKNOWN_FORMAT 0x3004 +#define SENSE_NW_MEDIUM_INCOMPATIBLE_FORMAT 0x3005 +#define SENSE_NF_MEDIUM_INCOMPATIBLE_FORMAT 0x3006 +#define SENSE_NW_MEDIUM_AC_MISMATCH 0x3008 +#define SENSE_NOMEDIUM 0x3A00 +#define SENSE_NOMEDIUM_TCLOSED 0x3A01 +#define SENSE_NOMEDIUM_TOPEN 0x3A02 +#define SENSE_NOMEDIUM_LOADABLE 0x3A03 +#define SENSE_NOMEDIUM_AUXMEM 0x3A04 +#define SENSE_CARTRIDGE_FAULT 0x5200 +#define SENSE_MEDIUM_REMOVAL_PREVENTED 0x5302 + struct scsi_blk_desc { u_int8_t density; u_int8_t nblocks[3]; diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index 3cc1e309f18..8dc8b415b60 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.114 2006/11/04 06:03:51 dlg Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.115 2006/11/27 18:24:43 beck Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -1092,64 +1092,76 @@ scsi_interpret_sense(struct scsi_xfer *xs) return (0); error = EIO; if (xs->retries) { - switch (sense->add_sense_code) { - case 0x04: /* LUN not ready */ - switch (sense->add_sense_code_qual) { - case 0x01: /* Becoming Ready */ - case 0x04: /* Format In Progress */ - case 0x05: /* Rebuild In Progress */ - case 0x06: /* Recalculation In Progress */ - case 0x07: /* Operation In Progress */ - case 0x08: /* Long Write In Progress */ - case 0x09: /* Self-Test In Progress */ - SC_DEBUG(sc_link, SDEV_DB1, - ("not ready: busy (%#x)\n", - sense->add_sense_code_qual)); - return (scsi_delay(xs, 1)); - } - break; - case 0x3a: /* Medium not present */ + switch (ASC_ASCQ(sense)) { + case SENSE_NOT_READY_BECOMING_READY: + case SENSE_NOT_READY_FORMAT: + case SENSE_NOT_READY_REBUILD: + case SENSE_NOT_READY_RECALC: + case SENSE_NOT_READY_INPROGRESS: + case SENSE_NOT_READY_LONGWRITE: + case SENSE_NOT_READY_SELFTEST: + SC_DEBUG(sc_link, SDEV_DB1, + ("not ready: busy (%#x)\n", + sense->add_sense_code_qual)); + return (scsi_delay(xs, 1)); + case SENSE_NOMEDIUM: + case SENSE_NOMEDIUM_TCLOSED: + case SENSE_NOMEDIUM_TOPEN: + case SENSE_NOMEDIUM_LOADABLE: + case SENSE_NOMEDIUM_AUXMEM: sc_link->flags &= ~SDEV_MEDIA_LOADED; error = ENOMEDIUM; break; + default: + break; } } break; case SKEY_MEDIUM_ERROR: - switch (sense->add_sense_code) { - case 0x3a: /* Medium not present */ - sc_link->flags &= ~SDEV_MEDIA_LOADED; - error = ENOMEDIUM; - break; - case 0x30: /* Medium issues */ - switch (sense->add_sense_code_qual) { - case 0x01: /* (Read) Unknown Format */ - case 0x02: /* (Read) Incompatible Medium */ - case 0x04: /* (Write) Unknown Format */ - case 0x05: /* (Write) Incompatible Medium */ - case 0x06: /* (Format) Incompatible Medium */ - case 0x08: /* (Write/CD) Can't Write Media */ - error = EMEDIUMTYPE; - default: - error = EIO; - } - break; - default: - error = EIO; - break; + switch (ASC_ASCQ(sense)) { + case SENSE_NOMEDIUM: + case SENSE_NOMEDIUM_TCLOSED: + case SENSE_NOMEDIUM_TOPEN: + case SENSE_NOMEDIUM_LOADABLE: + case SENSE_NOMEDIUM_AUXMEM: + sc_link->flags &= ~SDEV_MEDIA_LOADED; + error = ENOMEDIUM; + break; + case SENSE_BAD_MEDIUM: + case SENSE_NR_MEDIUM_UNKNOWN_FORMAT: + case SENSE_NR_MEDIUM_INCOMPATIBLE_FORMAT: + case SENSE_NW_MEDIUM_UNKNOWN_FORMAT: + case SENSE_NW_MEDIUM_INCOMPATIBLE_FORMAT: + case SENSE_NF_MEDIUM_INCOMPATIBLE_FORMAT: + case SENSE_NW_MEDIUM_AC_MISMATCH: + error = EMEDIUMTYPE; + break; + default: + error = EIO; + break; } break; case SKEY_ILLEGAL_REQUEST: if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0) return (0); - if (sense->add_sense_code == 0x53 && - sense->add_sense_code_qual == 0x02) - return(EBUSY); /* Medium Removal Prevented */ + if (ASC_ASCQ(sense) == SENSE_MEDIUM_REMOVAL_PREVENTED) + return(EBUSY); error = EINVAL; break; case SKEY_UNIT_ATTENTION: - if (sense->add_sense_code == 0x29) /* device or bus reset */ + switch (ASC_ASCQ(sense)) { + case SENSE_POWER_RESET_OR_BUS: + case SENSE_POWER_ON: + case SENSE_BUS_RESET: + case SENSE_BUS_DEVICE_RESET: + case SENSE_DEVICE_INTERNAL_RESET: + case SENSE_TSC_CHANGE_SE: + case SENSE_TSC_CHANGE_LVD: + case SENSE_IT_NEXUS_LOSS: return (scsi_delay(xs, 1)); + default: + break; + } if ((sc_link->flags & SDEV_REMOVABLE) != 0) sc_link->flags &= ~SDEV_MEDIA_LOADED; if ((xs->flags & SCSI_IGNORE_MEDIA_CHANGE) != 0 || @@ -1169,9 +1181,8 @@ scsi_interpret_sense(struct scsi_xfer *xs) error = ENOSPC; break; case SKEY_HARDWARE_ERROR: - if (sense->add_sense_code == 0x52 && - sense->add_sense_code_qual == 0x00) - return(EMEDIUMTYPE); /* Cartridge Fault */ + if (ASC_ASCQ(sense) == SENSE_CARTRIDGE_FAULT) + return(EMEDIUMTYPE); error = EIO; break; default: diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 27c5ebceca2..c4bf42ff130 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -1,4 +1,4 @@ -/* $OpenBSD: st.c,v 1.65 2006/10/07 23:40:08 beck Exp $ */ +/* $OpenBSD: st.c,v 1.66 2006/11/27 18:24:43 beck Exp $ */ /* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */ /* @@ -1739,20 +1739,13 @@ st_interpret_sense(xs) case SKEY_NOT_READY: if ((xs->flags & SCSI_IGNORE_NOT_READY) != 0) return (0); - switch (sense->add_sense_code) { - case 0x04: /* LUN not ready */ - switch (sense->add_sense_code_qual) { - case 0x01: /* Becoming Ready */ - SC_DEBUG(sc_link, SDEV_DB1, - ("not ready: busy (%#x)\n", - sense->add_sense_code_qual)); - /* don't count this as a retry */ - xs->retries++; - return (scsi_delay(xs, 1)); - default: - return (EJUSTRETURN); - } - break; + switch (ASC_ASCQ(sense)) { + case SENSE_NOT_READY_BECOMING_READY: + SC_DEBUG(sc_link, SDEV_DB1, ("not ready: busy (%#x)\n", + sense->add_sense_code_qual)); + /* don't count this as a retry */ + xs->retries++; + return (scsi_delay(xs, 1)); default: return (EJUSTRETURN); } |