18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *    tape device discipline for 3590 tapes.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *    Copyright IBM Corp. 2001, 2006
68c2ecf20Sopenharmony_ci *    Author(s): Stefan Bader <shbader@de.ibm.com>
78c2ecf20Sopenharmony_ci *		 Michael Holzheu <holzheu@de.ibm.com>
88c2ecf20Sopenharmony_ci *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef _TAPE_3590_H
128c2ecf20Sopenharmony_ci#define _TAPE_3590_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define MEDIUM_SENSE	0xc2
158c2ecf20Sopenharmony_ci#define READ_PREVIOUS	0x0a
168c2ecf20Sopenharmony_ci#define MODE_SENSE	0xcf
178c2ecf20Sopenharmony_ci#define PERFORM_SS_FUNC 0x77
188c2ecf20Sopenharmony_ci#define READ_SS_DATA	0x3e
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define PREP_RD_SS_DATA 0x18
218c2ecf20Sopenharmony_ci#define RD_ATTMSG	0x3
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define SENSE_BRA_PER  0
248c2ecf20Sopenharmony_ci#define SENSE_BRA_CONT 1
258c2ecf20Sopenharmony_ci#define SENSE_BRA_RE   2
268c2ecf20Sopenharmony_ci#define SENSE_BRA_DRE  3
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define SENSE_FMT_LIBRARY	0x23
298c2ecf20Sopenharmony_ci#define SENSE_FMT_UNSOLICITED	0x40
308c2ecf20Sopenharmony_ci#define SENSE_FMT_COMMAND_REJ	0x41
318c2ecf20Sopenharmony_ci#define SENSE_FMT_COMMAND_EXEC0 0x50
328c2ecf20Sopenharmony_ci#define SENSE_FMT_COMMAND_EXEC1 0x51
338c2ecf20Sopenharmony_ci#define SENSE_FMT_EVENT0	0x60
348c2ecf20Sopenharmony_ci#define SENSE_FMT_EVENT1	0x61
358c2ecf20Sopenharmony_ci#define SENSE_FMT_MIM		0x70
368c2ecf20Sopenharmony_ci#define SENSE_FMT_SIM		0x71
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define MSENSE_UNASSOCIATED	 0x00
398c2ecf20Sopenharmony_ci#define MSENSE_ASSOCIATED_MOUNT	 0x01
408c2ecf20Sopenharmony_ci#define MSENSE_ASSOCIATED_UMOUNT 0x02
418c2ecf20Sopenharmony_ci#define MSENSE_CRYPT_MASK	 0x00000010
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define TAPE_3590_MAX_MSG	 0xb0
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* Datatypes */
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistruct tape_3590_disc_data {
488c2ecf20Sopenharmony_ci	struct tape390_crypt_info crypt_info;
498c2ecf20Sopenharmony_ci	int read_back_op;
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define TAPE_3590_CRYPT_INFO(device) \
538c2ecf20Sopenharmony_ci	((struct tape_3590_disc_data*)(device->discdata))->crypt_info
548c2ecf20Sopenharmony_ci#define TAPE_3590_READ_BACK_OP(device) \
558c2ecf20Sopenharmony_ci	((struct tape_3590_disc_data*)(device->discdata))->read_back_op
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistruct tape_3590_sense {
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	unsigned int command_rej:1;
608c2ecf20Sopenharmony_ci	unsigned int interv_req:1;
618c2ecf20Sopenharmony_ci	unsigned int bus_out_check:1;
628c2ecf20Sopenharmony_ci	unsigned int eq_check:1;
638c2ecf20Sopenharmony_ci	unsigned int data_check:1;
648c2ecf20Sopenharmony_ci	unsigned int overrun:1;
658c2ecf20Sopenharmony_ci	unsigned int def_unit_check:1;
668c2ecf20Sopenharmony_ci	unsigned int assgnd_elsew:1;
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	unsigned int locate_fail:1;
698c2ecf20Sopenharmony_ci	unsigned int inst_online:1;
708c2ecf20Sopenharmony_ci	unsigned int reserved:1;
718c2ecf20Sopenharmony_ci	unsigned int blk_seq_err:1;
728c2ecf20Sopenharmony_ci	unsigned int begin_part:1;
738c2ecf20Sopenharmony_ci	unsigned int wr_mode:1;
748c2ecf20Sopenharmony_ci	unsigned int wr_prot:1;
758c2ecf20Sopenharmony_ci	unsigned int not_cap:1;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	unsigned int bra:2;
788c2ecf20Sopenharmony_ci	unsigned int lc:3;
798c2ecf20Sopenharmony_ci	unsigned int vlf_active:1;
808c2ecf20Sopenharmony_ci	unsigned int stm:1;
818c2ecf20Sopenharmony_ci	unsigned int med_pos:1;
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	unsigned int rac:8;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	unsigned int rc_rqc:16;
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	unsigned int mc:8;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	unsigned int sense_fmt:8;
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	union {
928c2ecf20Sopenharmony_ci		struct {
938c2ecf20Sopenharmony_ci			unsigned int emc:4;
948c2ecf20Sopenharmony_ci			unsigned int smc:4;
958c2ecf20Sopenharmony_ci			unsigned int sev:2;
968c2ecf20Sopenharmony_ci			unsigned int reserved:6;
978c2ecf20Sopenharmony_ci			unsigned int md:8;
988c2ecf20Sopenharmony_ci			unsigned int refcode:8;
998c2ecf20Sopenharmony_ci			unsigned int mid:16;
1008c2ecf20Sopenharmony_ci			unsigned int mp:16;
1018c2ecf20Sopenharmony_ci			unsigned char volid[6];
1028c2ecf20Sopenharmony_ci			unsigned int fid:8;
1038c2ecf20Sopenharmony_ci		} f70;
1048c2ecf20Sopenharmony_ci		struct {
1058c2ecf20Sopenharmony_ci			unsigned int emc:4;
1068c2ecf20Sopenharmony_ci			unsigned int smc:4;
1078c2ecf20Sopenharmony_ci			unsigned int sev:2;
1088c2ecf20Sopenharmony_ci			unsigned int reserved1:5;
1098c2ecf20Sopenharmony_ci			unsigned int mdf:1;
1108c2ecf20Sopenharmony_ci			unsigned char md[3];
1118c2ecf20Sopenharmony_ci			unsigned int simid:8;
1128c2ecf20Sopenharmony_ci			unsigned int uid:16;
1138c2ecf20Sopenharmony_ci			unsigned int refcode1:16;
1148c2ecf20Sopenharmony_ci			unsigned int refcode2:16;
1158c2ecf20Sopenharmony_ci			unsigned int refcode3:16;
1168c2ecf20Sopenharmony_ci			unsigned int reserved2:8;
1178c2ecf20Sopenharmony_ci		} f71;
1188c2ecf20Sopenharmony_ci		unsigned char data[14];
1198c2ecf20Sopenharmony_ci	} fmt;
1208c2ecf20Sopenharmony_ci	unsigned char pad[10];
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistruct tape_3590_med_sense {
1258c2ecf20Sopenharmony_ci	unsigned int macst:4;
1268c2ecf20Sopenharmony_ci	unsigned int masst:4;
1278c2ecf20Sopenharmony_ci	char pad1[7];
1288c2ecf20Sopenharmony_ci	unsigned int flags;
1298c2ecf20Sopenharmony_ci	char pad2[116];
1308c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistruct tape_3590_rdc_data {
1338c2ecf20Sopenharmony_ci	char data[64];
1348c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci/* Datastructures for 3592 encryption support */
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistruct tape3592_kekl {
1398c2ecf20Sopenharmony_ci	__u8 flags;
1408c2ecf20Sopenharmony_ci	char label[64];
1418c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistruct tape3592_kekl_pair {
1448c2ecf20Sopenharmony_ci	__u8 count;
1458c2ecf20Sopenharmony_ci	struct tape3592_kekl kekl[2];
1468c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cistruct tape3592_kekl_query_data {
1498c2ecf20Sopenharmony_ci	__u16 len;
1508c2ecf20Sopenharmony_ci	__u8  fmt;
1518c2ecf20Sopenharmony_ci	__u8  mc;
1528c2ecf20Sopenharmony_ci	__u32 id;
1538c2ecf20Sopenharmony_ci	__u8  flags;
1548c2ecf20Sopenharmony_ci	struct tape3592_kekl_pair kekls;
1558c2ecf20Sopenharmony_ci	char reserved[116];
1568c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistruct tape3592_kekl_query_order {
1598c2ecf20Sopenharmony_ci	__u8 code;
1608c2ecf20Sopenharmony_ci	__u8 flags;
1618c2ecf20Sopenharmony_ci	char reserved1[2];
1628c2ecf20Sopenharmony_ci	__u8 max_count;
1638c2ecf20Sopenharmony_ci	char reserved2[35];
1648c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cistruct tape3592_kekl_set_order {
1678c2ecf20Sopenharmony_ci	__u8 code;
1688c2ecf20Sopenharmony_ci	__u8 flags;
1698c2ecf20Sopenharmony_ci	char reserved1[2];
1708c2ecf20Sopenharmony_ci	__u8 op;
1718c2ecf20Sopenharmony_ci	struct tape3592_kekl_pair kekls;
1728c2ecf20Sopenharmony_ci	char reserved2[120];
1738c2ecf20Sopenharmony_ci} __attribute__ ((packed));
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci#endif /* _TAPE_3590_H */
176