xref: /openbmc/linux/drivers/s390/char/tape_3590.h (revision 56a0eccd)
1 /*
2  *    tape device discipline for 3590 tapes.
3  *
4  *    Copyright IBM Corp. 2001, 2006
5  *    Author(s): Stefan Bader <shbader@de.ibm.com>
6  *		 Michael Holzheu <holzheu@de.ibm.com>
7  *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
8  */
9 
10 #ifndef _TAPE_3590_H
11 #define _TAPE_3590_H
12 
13 #define MEDIUM_SENSE	0xc2
14 #define READ_PREVIOUS	0x0a
15 #define MODE_SENSE	0xcf
16 #define PERFORM_SS_FUNC 0x77
17 #define READ_SS_DATA	0x3e
18 
19 #define PREP_RD_SS_DATA 0x18
20 #define RD_ATTMSG	0x3
21 
22 #define SENSE_BRA_PER  0
23 #define SENSE_BRA_CONT 1
24 #define SENSE_BRA_RE   2
25 #define SENSE_BRA_DRE  3
26 
27 #define SENSE_FMT_LIBRARY	0x23
28 #define SENSE_FMT_UNSOLICITED	0x40
29 #define SENSE_FMT_COMMAND_REJ	0x41
30 #define SENSE_FMT_COMMAND_EXEC0 0x50
31 #define SENSE_FMT_COMMAND_EXEC1 0x51
32 #define SENSE_FMT_EVENT0	0x60
33 #define SENSE_FMT_EVENT1	0x61
34 #define SENSE_FMT_MIM		0x70
35 #define SENSE_FMT_SIM		0x71
36 
37 #define MSENSE_UNASSOCIATED	 0x00
38 #define MSENSE_ASSOCIATED_MOUNT	 0x01
39 #define MSENSE_ASSOCIATED_UMOUNT 0x02
40 #define MSENSE_CRYPT_MASK	 0x00000010
41 
42 #define TAPE_3590_MAX_MSG	 0xb0
43 
44 /* Datatypes */
45 
46 struct tape_3590_disc_data {
47 	struct tape390_crypt_info crypt_info;
48 	int read_back_op;
49 };
50 
51 #define TAPE_3590_CRYPT_INFO(device) \
52 	((struct tape_3590_disc_data*)(device->discdata))->crypt_info
53 #define TAPE_3590_READ_BACK_OP(device) \
54 	((struct tape_3590_disc_data*)(device->discdata))->read_back_op
55 
56 struct tape_3590_sense {
57 
58 	unsigned int command_rej:1;
59 	unsigned int interv_req:1;
60 	unsigned int bus_out_check:1;
61 	unsigned int eq_check:1;
62 	unsigned int data_check:1;
63 	unsigned int overrun:1;
64 	unsigned int def_unit_check:1;
65 	unsigned int assgnd_elsew:1;
66 
67 	unsigned int locate_fail:1;
68 	unsigned int inst_online:1;
69 	unsigned int reserved:1;
70 	unsigned int blk_seq_err:1;
71 	unsigned int begin_part:1;
72 	unsigned int wr_mode:1;
73 	unsigned int wr_prot:1;
74 	unsigned int not_cap:1;
75 
76 	unsigned int bra:2;
77 	unsigned int lc:3;
78 	unsigned int vlf_active:1;
79 	unsigned int stm:1;
80 	unsigned int med_pos:1;
81 
82 	unsigned int rac:8;
83 
84 	unsigned int rc_rqc:16;
85 
86 	unsigned int mc:8;
87 
88 	unsigned int sense_fmt:8;
89 
90 	union {
91 		struct {
92 			unsigned int emc:4;
93 			unsigned int smc:4;
94 			unsigned int sev:2;
95 			unsigned int reserved:6;
96 			unsigned int md:8;
97 			unsigned int refcode:8;
98 			unsigned int mid:16;
99 			unsigned int mp:16;
100 			unsigned char volid[6];
101 			unsigned int fid:8;
102 		} f70;
103 		struct {
104 			unsigned int emc:4;
105 			unsigned int smc:4;
106 			unsigned int sev:2;
107 			unsigned int reserved1:5;
108 			unsigned int mdf:1;
109 			unsigned char md[3];
110 			unsigned int simid:8;
111 			unsigned int uid:16;
112 			unsigned int refcode1:16;
113 			unsigned int refcode2:16;
114 			unsigned int refcode3:16;
115 			unsigned int reserved2:8;
116 		} f71;
117 		unsigned char data[14];
118 	} fmt;
119 	unsigned char pad[10];
120 
121 } __attribute__ ((packed));
122 
123 struct tape_3590_med_sense {
124 	unsigned int macst:4;
125 	unsigned int masst:4;
126 	char pad1[7];
127 	unsigned int flags;
128 	char pad2[116];
129 } __attribute__ ((packed));
130 
131 struct tape_3590_rdc_data {
132 	char data[64];
133 } __attribute__ ((packed));
134 
135 /* Datastructures for 3592 encryption support */
136 
137 struct tape3592_kekl {
138 	__u8 flags;
139 	char label[64];
140 } __attribute__ ((packed));
141 
142 struct tape3592_kekl_pair {
143 	__u8 count;
144 	struct tape3592_kekl kekl[2];
145 } __attribute__ ((packed));
146 
147 struct tape3592_kekl_query_data {
148 	__u16 len;
149 	__u8  fmt;
150 	__u8  mc;
151 	__u32 id;
152 	__u8  flags;
153 	struct tape3592_kekl_pair kekls;
154 	char reserved[116];
155 } __attribute__ ((packed));
156 
157 struct tape3592_kekl_query_order {
158 	__u8 code;
159 	__u8 flags;
160 	char reserved1[2];
161 	__u8 max_count;
162 	char reserved2[35];
163 } __attribute__ ((packed));
164 
165 struct tape3592_kekl_set_order {
166 	__u8 code;
167 	__u8 flags;
168 	char reserved1[2];
169 	__u8 op;
170 	struct tape3592_kekl_pair kekls;
171 	char reserved2[120];
172 } __attribute__ ((packed));
173 
174 #endif /* _TAPE_3590_H */
175