xref: /linux/include/scsi/scsi_ioctl.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #ifndef _SCSI_IOCTL_H
31da177e4SLinus Torvalds #define _SCSI_IOCTL_H
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds #define SCSI_IOCTL_SEND_COMMAND 1
61da177e4SLinus Torvalds #define SCSI_IOCTL_TEST_UNIT_READY 2
71da177e4SLinus Torvalds #define SCSI_IOCTL_BENCHMARK_COMMAND 3
81da177e4SLinus Torvalds #define SCSI_IOCTL_SYNC 4			/* Request synchronous parameters */
91da177e4SLinus Torvalds #define SCSI_IOCTL_START_UNIT 5
101da177e4SLinus Torvalds #define SCSI_IOCTL_STOP_UNIT 6
111da177e4SLinus Torvalds /* The door lock/unlock constants are compatible with Sun constants for
121da177e4SLinus Torvalds    the cdrom */
131da177e4SLinus Torvalds #define SCSI_IOCTL_DOORLOCK 0x5380		/* lock the eject mechanism */
141da177e4SLinus Torvalds #define SCSI_IOCTL_DOORUNLOCK 0x5381		/* unlock the mechanism	  */
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds #define	SCSI_REMOVAL_PREVENT	1
171da177e4SLinus Torvalds #define	SCSI_REMOVAL_ALLOW	0
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds #ifdef __KERNEL__
201da177e4SLinus Torvalds 
212e27f576SChristoph Hellwig struct gendisk;
221da177e4SLinus Torvalds struct scsi_device;
23f2542a3bSChristoph Hellwig struct sg_io_hdr;
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds /*
261da177e4SLinus Torvalds  * Structures used for scsi_ioctl et al.
271da177e4SLinus Torvalds  */
281da177e4SLinus Torvalds 
291da177e4SLinus Torvalds typedef struct scsi_ioctl_command {
301da177e4SLinus Torvalds 	unsigned int inlen;
311da177e4SLinus Torvalds 	unsigned int outlen;
325febf6d6SGustavo A. R. Silva 	unsigned char data[];
331da177e4SLinus Torvalds } Scsi_Ioctl_Command;
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds typedef struct scsi_idlun {
361da177e4SLinus Torvalds 	__u32 dev_id;
371da177e4SLinus Torvalds 	__u32 host_unique_id;
381da177e4SLinus Torvalds } Scsi_Idlun;
391da177e4SLinus Torvalds 
401da177e4SLinus Torvalds /* Fibre Channel WWN, port_id struct */
411da177e4SLinus Torvalds typedef struct scsi_fctargaddress {
421da177e4SLinus Torvalds 	__u32 host_port_id;
431da177e4SLinus Torvalds 	unsigned char host_wwn[8]; // include NULL term.
441da177e4SLinus Torvalds } Scsi_FCTargAddress;
451da177e4SLinus Torvalds 
46906d15fbSChristoph Hellwig int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev,
47906d15fbSChristoph Hellwig 		int cmd, bool ndelay);
48*2e80089cSChristoph Hellwig int scsi_ioctl(struct scsi_device *sdev, bool open_for_write, int cmd,
49a30e3441SChristoph Hellwig 		void __user *arg);
50f2542a3bSChristoph Hellwig int get_sg_io_hdr(struct sg_io_hdr *hdr, const void __user *argp);
51f2542a3bSChristoph Hellwig int put_sg_io_hdr(const struct sg_io_hdr *hdr, void __user *argp);
525f4eb9d5SChristoph Hellwig bool scsi_cmd_allowed(unsigned char *cmd, bool open_for_write);
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds #endif /* __KERNEL__ */
551da177e4SLinus Torvalds #endif /* _SCSI_IOCTL_H */
56