1/*
2 * File...........: linux/drivers/s390/block/dasd_3370_erp.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 2000
6 */
7
8#include <asm/ccwcache.h>
9
10#include "dasd_int.h"
11#include "dasd_3370_erp.h"
12#ifdef PRINTK_HEADER
13#undef PRINTK_HEADER
14#define PRINTK_HEADER "dasd_erp(3370)"
15#endif				/* PRINTK_HEADER */
16
17/*
18 * DASD_3370_ERP_EXAMINE
19 *
20 * DESCRIPTION
21 *   Checks only for fatal/no/recover error.
22 *   A detailed examination of the sense data is done later outside
23 *   the interrupt handler.
24 *
25 *   The logic is based on the 'IBM 3880 Storage Control Reference' manual
26 *   'Chapter 7. 3370 Sense Data'.
27 *
28 * RETURN VALUES
29 *   dasd_era_none      no error
30 *   dasd_era_fatal     for all fatal (unrecoverable errors)
31 *   dasd_era_recover   for all others.
32 */
33dasd_era_t
34dasd_3370_erp_examine (ccw_req_t * cqr, devstat_t * stat)
35{
36	char *sense = stat->ii.sense.data;
37
38	/* check for successful execution first */
39	if (stat->cstat == 0x00 &&
40	    stat->dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END))
41		    return dasd_era_none;
42	if (sense[0] & 0x80) {	/* CMD reject */
43		return dasd_era_fatal;
44	}
45	if (sense[0] & 0x40) {	/* Drive offline */
46		return dasd_era_recover;
47	}
48	if (sense[0] & 0x20) {	/* Bus out parity */
49		return dasd_era_recover;
50	}
51	if (sense[0] & 0x10) {	/* equipment check */
52		if (sense[1] & 0x80) {
53			return dasd_era_fatal;
54		}
55		return dasd_era_recover;
56	}
57	if (sense[0] & 0x08) {	/* data check */
58		if (sense[1] & 0x80) {
59			return dasd_era_fatal;
60		}
61		return dasd_era_recover;
62	}
63	if (sense[0] & 0x04) {	/* overrun */
64		if (sense[1] & 0x80) {
65			return dasd_era_fatal;
66		}
67		return dasd_era_recover;
68	}
69	if (sense[1] & 0x40) {	/* invalid blocksize */
70		return dasd_era_fatal;
71	}
72	if (sense[1] & 0x04) {	/* file protected */
73		return dasd_era_recover;
74	}
75	if (sense[1] & 0x01) {	/* operation incomplete */
76		return dasd_era_recover;
77	}
78	if (sense[2] & 0x80) {	/* check data erroor */
79		return dasd_era_recover;
80	}
81	if (sense[2] & 0x10) {	/* Env. data present */
82		return dasd_era_recover;
83	}
84	/* examine the 24 byte sense data */
85	return dasd_era_recover;
86
87}				/* END dasd_3370_erp_examine */
88
89/*
90 * Overrides for Emacs so that we follow Linus's tabbing style.
91 * Emacs will notice this stuff at the end of the file and automatically
92 * adjust the settings for this buffer only.  This must remain at the end
93 * of the file.
94 * ---------------------------------------------------------------------------
95 * Local variables:
96 * c-indent-level: 4
97 * c-brace-imaginary-offset: 0
98 * c-brace-offset: -4
99 * c-argdecl-indent: 4
100 * c-label-offset: -4
101 * c-continued-statement-offset: 4
102 * c-continued-brace-offset: 0
103 * indent-tabs-mode: nil
104 * tab-width: 8
105 * End:
106 */
107