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