xref: /kernel/linux/linux-5.10/drivers/s390/char/vmur.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Linux driver for System z and s390 unit record devices
48c2ecf20Sopenharmony_ci * (z/VM virtual punch, reader, printer)
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright IBM Corp. 2001, 2007
78c2ecf20Sopenharmony_ci * Authors: Malcolm Beattie <beattiem@uk.ibm.com>
88c2ecf20Sopenharmony_ci *	    Michael Holzheu <holzheu@de.ibm.com>
98c2ecf20Sopenharmony_ci *	    Frank Munzert <munzert@de.ibm.com>
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef _VMUR_H_
138c2ecf20Sopenharmony_ci#define _VMUR_H_
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/refcount.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define DEV_CLASS_UR_I 0x20 /* diag210 unit record input device class */
188c2ecf20Sopenharmony_ci#define DEV_CLASS_UR_O 0x10 /* diag210 unit record output device class */
198c2ecf20Sopenharmony_ci/*
208c2ecf20Sopenharmony_ci * we only support z/VM's default unit record devices:
218c2ecf20Sopenharmony_ci * both in SPOOL directory control statement and in CP DEFINE statement
228c2ecf20Sopenharmony_ci *	RDR defaults to 2540 reader
238c2ecf20Sopenharmony_ci *	PUN defaults to 2540 punch
248c2ecf20Sopenharmony_ci *	PRT defaults to 1403 printer
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci#define READER_PUNCH_DEVTYPE	0x2540
278c2ecf20Sopenharmony_ci#define PRINTER_DEVTYPE		0x1403
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* z/VM spool file control block SFBLOK */
308c2ecf20Sopenharmony_cistruct file_control_block {
318c2ecf20Sopenharmony_ci	char reserved_1[8];
328c2ecf20Sopenharmony_ci	char user_owner[8];
338c2ecf20Sopenharmony_ci	char user_orig[8];
348c2ecf20Sopenharmony_ci	__s32 data_recs;
358c2ecf20Sopenharmony_ci	__s16 rec_len;
368c2ecf20Sopenharmony_ci	__s16 file_num;
378c2ecf20Sopenharmony_ci	__u8  file_stat;
388c2ecf20Sopenharmony_ci	__u8  dev_type;
398c2ecf20Sopenharmony_ci	char  reserved_2[6];
408c2ecf20Sopenharmony_ci	char  file_name[12];
418c2ecf20Sopenharmony_ci	char  file_type[12];
428c2ecf20Sopenharmony_ci	char  create_date[8];
438c2ecf20Sopenharmony_ci	char  create_time[8];
448c2ecf20Sopenharmony_ci	char  reserved_3[6];
458c2ecf20Sopenharmony_ci	__u8  file_class;
468c2ecf20Sopenharmony_ci	__u8  sfb_lok;
478c2ecf20Sopenharmony_ci	__u64 distr_code;
488c2ecf20Sopenharmony_ci	__u32 reserved_4;
498c2ecf20Sopenharmony_ci	__u8  current_starting_copy_number;
508c2ecf20Sopenharmony_ci	__u8  sfblock_cntrl_flags;
518c2ecf20Sopenharmony_ci	__u8  reserved_5;
528c2ecf20Sopenharmony_ci	__u8  more_status_flags;
538c2ecf20Sopenharmony_ci	char  rest[200];
548c2ecf20Sopenharmony_ci} __attribute__ ((packed));
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define FLG_SYSTEM_HOLD	0x04
578c2ecf20Sopenharmony_ci#define FLG_CP_DUMP	0x10
588c2ecf20Sopenharmony_ci#define FLG_USER_HOLD	0x20
598c2ecf20Sopenharmony_ci#define FLG_IN_USE	0x80
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/*
628c2ecf20Sopenharmony_ci * A struct urdev is created for each ur device that is made available
638c2ecf20Sopenharmony_ci * via the ccw_device driver model.
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_cistruct urdev {
668c2ecf20Sopenharmony_ci	struct ccw_device *cdev;	/* Backpointer to ccw device */
678c2ecf20Sopenharmony_ci	struct mutex io_mutex;		/* Serialises device IO */
688c2ecf20Sopenharmony_ci	struct completion *io_done;	/* do_ur_io waits; irq completes */
698c2ecf20Sopenharmony_ci	struct device *device;
708c2ecf20Sopenharmony_ci	struct cdev *char_device;
718c2ecf20Sopenharmony_ci	struct ccw_dev_id dev_id;	/* device id */
728c2ecf20Sopenharmony_ci	size_t reclen;			/* Record length for *write* CCWs */
738c2ecf20Sopenharmony_ci	int class;			/* VM device class */
748c2ecf20Sopenharmony_ci	int io_request_rc;		/* return code from I/O request */
758c2ecf20Sopenharmony_ci	refcount_t ref_count;		/* reference counter */
768c2ecf20Sopenharmony_ci	wait_queue_head_t wait;		/* wait queue to serialize open */
778c2ecf20Sopenharmony_ci	int open_flag;			/* "urdev is open" flag */
788c2ecf20Sopenharmony_ci	spinlock_t open_lock;		/* serialize critical sections */
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/*
828c2ecf20Sopenharmony_ci * A struct urfile is allocated at open() time for each device and
838c2ecf20Sopenharmony_ci * freed on release().
848c2ecf20Sopenharmony_ci */
858c2ecf20Sopenharmony_cistruct urfile {
868c2ecf20Sopenharmony_ci	struct urdev *urd;
878c2ecf20Sopenharmony_ci	unsigned int flags;
888c2ecf20Sopenharmony_ci	size_t dev_reclen;
898c2ecf20Sopenharmony_ci	__u16 file_reclen;
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci/*
938c2ecf20Sopenharmony_ci * Device major/minor definitions.
948c2ecf20Sopenharmony_ci */
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define UR_MAJOR 0	/* get dynamic major */
978c2ecf20Sopenharmony_ci/*
988c2ecf20Sopenharmony_ci * We map minor numbers directly to device numbers (0-FFFF) for simplicity.
998c2ecf20Sopenharmony_ci * This avoids having to allocate (and manage) slot numbers.
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_ci#define NUM_MINORS 65536
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci/* Limiting each I/O to 511 records limits chan prog to 4KB (511 r/w + 1 NOP) */
1048c2ecf20Sopenharmony_ci#define MAX_RECS_PER_IO		511
1058c2ecf20Sopenharmony_ci#define WRITE_CCW_CMD		0x01
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define TRACE(x...) debug_sprintf_event(vmur_dbf, 1, x)
1088c2ecf20Sopenharmony_ci#define CCWDEV_CU_DI(cutype, di) \
1098c2ecf20Sopenharmony_ci		CCW_DEVICE(cutype, 0x00), .driver_info = (di)
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define FILE_RECLEN_OFFSET	4064 /* reclen offset in spool data block */
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#endif /* _VMUR_H_ */
114