xref: /linux/arch/s390/include/uapi/asm/tape390.h (revision d91517839e5d95adc0cf4b28caa7af62a71de526)
1 /*************************************************************************
2  *
3  *	   enables user programs to display messages and control encryption
4  *	   on s390 tape devices
5  *
6  *	   Copyright IBM Corp. 2001, 2006
7  *	   Author(s): Michael Holzheu <holzheu@de.ibm.com>
8  *
9  *************************************************************************/
10 
11 #ifndef _TAPE390_H
12 #define _TAPE390_H
13 
14 #define TAPE390_DISPLAY _IOW('d', 1, struct display_struct)
15 
16 /*
17  * The TAPE390_DISPLAY ioctl calls the Load Display command
18  * which transfers 17 bytes of data from the channel to the subsystem:
19  *     - 1 format control byte, and
20  *     - two 8-byte messages
21  *
22  * Format control byte:
23  *   0-2: New Message Overlay
24  *     3: Alternate Messages
25  *     4: Blink Message
26  *     5: Display Low/High Message
27  *     6: Reserved
28  *     7: Automatic Load Request
29  *
30  */
31 
32 typedef struct display_struct {
33         char cntrl;
34         char message1[8];
35         char message2[8];
36 } display_struct;
37 
38 /*
39  * Tape encryption support
40  */
41 
42 struct tape390_crypt_info {
43 	char capability;
44 	char status;
45 	char medium_status;
46 } __attribute__ ((packed));
47 
48 
49 /* Macros for "capable" field */
50 #define TAPE390_CRYPT_SUPPORTED_MASK 0x01
51 #define TAPE390_CRYPT_SUPPORTED(x) \
52 	((x.capability & TAPE390_CRYPT_SUPPORTED_MASK))
53 
54 /* Macros for "status" field */
55 #define TAPE390_CRYPT_ON_MASK 0x01
56 #define TAPE390_CRYPT_ON(x) (((x.status) & TAPE390_CRYPT_ON_MASK))
57 
58 /* Macros for "medium status" field */
59 #define TAPE390_MEDIUM_LOADED_MASK 0x01
60 #define TAPE390_MEDIUM_ENCRYPTED_MASK 0x02
61 #define TAPE390_MEDIUM_ENCRYPTED(x) \
62 	(((x.medium_status) & TAPE390_MEDIUM_ENCRYPTED_MASK))
63 #define TAPE390_MEDIUM_LOADED(x) \
64 	(((x.medium_status) & TAPE390_MEDIUM_LOADED_MASK))
65 
66 /*
67  * The TAPE390_CRYPT_SET ioctl is used to switch on/off encryption.
68  * The "encryption_capable" and "tape_status" fields are ignored for this ioctl!
69  */
70 #define TAPE390_CRYPT_SET _IOW('d', 2, struct tape390_crypt_info)
71 
72 /*
73  * The TAPE390_CRYPT_QUERY ioctl is used to query the encryption state.
74  */
75 #define TAPE390_CRYPT_QUERY _IOR('d', 3, struct tape390_crypt_info)
76 
77 /* Values for "kekl1/2_type" and "kekl1/2_type_on_tape" fields */
78 #define TAPE390_KEKL_TYPE_NONE 0
79 #define TAPE390_KEKL_TYPE_LABEL 1
80 #define TAPE390_KEKL_TYPE_HASH 2
81 
82 struct tape390_kekl {
83 	unsigned char type;
84 	unsigned char type_on_tape;
85 	char label[65];
86 } __attribute__ ((packed));
87 
88 struct tape390_kekl_pair {
89 	struct tape390_kekl kekl[2];
90 } __attribute__ ((packed));
91 
92 /*
93  * The TAPE390_KEKL_SET ioctl is used to set Key Encrypting Key labels.
94  */
95 #define TAPE390_KEKL_SET _IOW('d', 4, struct tape390_kekl_pair)
96 
97 /*
98  * The TAPE390_KEKL_QUERY ioctl is used to query Key Encrypting Key labels.
99  */
100 #define TAPE390_KEKL_QUERY _IOR('d', 5, struct tape390_kekl_pair)
101 
102 #endif
103