/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _SCSI_GENERIC_H #define _SCSI_GENERIC_H #include <linux/compiler.h> /* * History: * Started: Aug 9 by Lawrence Foard ([email protected]), to allow user * process control of SCSI devices. * Development Sponsored by Killy Corp. NY NY * * Original driver (sg.h): * Copyright (C) 1992 Lawrence Foard * Version 2 and 3 extensions to driver: * Copyright (C) 1998 - 2014 Douglas Gilbert * * Version: 3.5.36 (20140603) * This version is for 2.6 and 3 series kernels. * * Documentation * ============= * A web site for the SG device driver can be found at: * http://sg.danny.cz/sg [alternatively check the MAINTAINERS file] * The documentation for the sg version 3 driver can be found at: * http://sg.danny.cz/sg/p/sg_v3_ho.html * Also see: <kernel_source>/Documentation/scsi/scsi-generic.rst * * For utility and test programs see: http://sg.danny.cz/sg/sg3_utils.html */ sg_iovec_t; sg_io_hdr_t; /* 64 bytes long (on i386) */ #if defined(__KERNEL__) #include <linux/compat.h> struct compat_sg_io_hdr { … }; #endif #define SG_INTERFACE_ID_ORIG … /* Use negative values to flag difference from original sg_header structure */ #define SG_DXFER_NONE … #define SG_DXFER_TO_DEV … #define SG_DXFER_FROM_DEV … #define SG_DXFER_TO_FROM_DEV … #define SG_DXFER_UNKNOWN … /* following flag values can be "or"-ed together */ #define SG_FLAG_DIRECT_IO … #define SG_FLAG_UNUSED_LUN_INHIBIT … /* command block (when <= SCSI_2) */ #define SG_FLAG_MMAP_IO … #define SG_FLAG_NO_DXFER … /* user space (debug indirect IO) */ /* defaults:: for sg driver: Q_AT_HEAD; for block layer: Q_AT_TAIL */ #define SG_FLAG_Q_AT_TAIL … #define SG_FLAG_Q_AT_HEAD … /* following 'info' values are "or"-ed together */ #define SG_INFO_OK_MASK … #define SG_INFO_OK … #define SG_INFO_CHECK … #define SG_INFO_DIRECT_IO_MASK … #define SG_INFO_INDIRECT_IO … #define SG_INFO_DIRECT_IO … #define SG_INFO_MIXED_IO … /* * Obsolete DRIVER_SENSE driver byte * * Originally the SCSI midlayer would set the DRIVER_SENSE driver byte when * a sense code was generated and a sense buffer was allocated. * However, as nowadays every scsi command has a sense code allocated this * distinction became moot as one could check the sense buffer directly. * Consequently this byte is not set anymore from the midlayer, but SG will * keep setting this byte to be compatible with previous releases. */ #define DRIVER_SENSE … /* Obsolete driver_byte() declaration */ #define driver_byte(result) … /* * Original linux SCSI Status codes. They are shifted 1 bit right * from those found in the SCSI standards. */ #define GOOD … #define CHECK_CONDITION … #define CONDITION_GOOD … #define BUSY … #define INTERMEDIATE_GOOD … #define INTERMEDIATE_C_GOOD … #define RESERVATION_CONFLICT … #define COMMAND_TERMINATED … #define QUEUE_FULL … #define ACA_ACTIVE … #define TASK_ABORTED … /* Obsolete status_byte() declaration */ #define sg_status_byte(result) … sg_scsi_id_t; /* 32 bytes long on i386 */ sg_req_info_t; /* 20 bytes long on i386 */ /* IOCTLs: Those ioctls that are relevant to the SG 3.x drivers follow. [Those that only apply to the SG 2.x drivers are at the end of the file.] (_GET_s yield result via 'int *' 3rd argument unless otherwise indicated) */ #define SG_EMULATED_HOST … /* Used to configure SCSI command transformation layer for ATAPI devices */ /* Only supported by the ide-scsi driver */ #define SG_SET_TRANSFORM … /* 3rd arg = 0 to disable transform, 1 to enable it */ #define SG_GET_TRANSFORM … #define SG_SET_RESERVED_SIZE … #define SG_GET_RESERVED_SIZE … /* The following ioctl has a 'sg_scsi_id_t *' object as its 3rd argument. */ #define SG_GET_SCSI_ID … /* SCSI id information can also be obtained from SCSI_IOCTL_GET_IDLUN */ /* Override host setting and always DMA using low memory ( <16MB on i386) */ #define SG_SET_FORCE_LOW_DMA … #define SG_GET_LOW_DMA … /* When SG_SET_FORCE_PACK_ID set to 1, pack_id is input to read() which tries to fetch a packet with a matching pack_id, waits, or returns EAGAIN. If pack_id is -1 then read oldest waiting. When ...FORCE_PACK_ID set to 0 then pack_id ignored by read() and oldest readable fetched. */ #define SG_SET_FORCE_PACK_ID … #define SG_GET_PACK_ID … #define SG_GET_NUM_WAITING … /* Yields max scatter gather tablesize allowed by current host adapter */ #define SG_GET_SG_TABLESIZE … #define SG_GET_VERSION_NUM … /* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */ #define SG_SCSI_RESET … /* Associated values that can be given to SG_SCSI_RESET follow. * SG_SCSI_RESET_NO_ESCALATE may be OR-ed to the _DEVICE, _TARGET, _BUS * or _HOST reset value so only that action is attempted. */ #define SG_SCSI_RESET_NOTHING … #define SG_SCSI_RESET_DEVICE … #define SG_SCSI_RESET_BUS … #define SG_SCSI_RESET_HOST … #define SG_SCSI_RESET_TARGET … #define SG_SCSI_RESET_NO_ESCALATE … /* synchronous SCSI command ioctl, (only in version 3 interface) */ #define SG_IO … #define SG_GET_REQUEST_TABLE … /* How to treat EINTR during SG_IO ioctl(), only in SG 3.x series */ #define SG_SET_KEEP_ORPHAN … #define SG_GET_KEEP_ORPHAN … /* yields scsi midlevel's access_count for this SCSI device */ #define SG_GET_ACCESS_COUNT … #define SG_SCATTER_SZ … /* Largest size (in bytes) a single scatter-gather list element can have. The value used by the driver is 'max(SG_SCATTER_SZ, PAGE_SIZE)'. This value should be a power of 2 (and may be rounded up internally). If scatter-gather is not supported by adapter then this value is the largest data block that can be read/written by a single scsi command. */ #define SG_DEFAULT_RETRIES … /* Defaults, commented if they differ from original sg driver */ #define SG_DEF_FORCE_PACK_ID … #define SG_DEF_KEEP_ORPHAN … #define SG_DEF_RESERVED_SIZE … /* maximum outstanding requests, write() yields EDOM if exceeded */ #define SG_MAX_QUEUE … #define SG_BIG_BUFF … /* Alternate style type names, "..._t" variants preferred */ Sg_io_hdr; Sg_io_vec; Sg_scsi_id; Sg_req_info; /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ /* The older SG interface based on the 'sg_header' structure follows. */ /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ #define SG_MAX_SENSE … struct sg_header { … }; /* This structure is 36 bytes long on i386 */ /* IOCTLs: The following are not required (or ignored) when the sg_io_hdr_t interface is used. They are kept for backward compatibility with the original and version 2 drivers. */ #define SG_SET_TIMEOUT … #define SG_GET_TIMEOUT … /* Get/set command queuing state per fd (default is SG_DEF_COMMAND_Q. Each time a sg_io_hdr_t object is seen on this file descriptor, this command queuing flag is set on (overriding the previous setting). */ #define SG_GET_COMMAND_Q … #define SG_SET_COMMAND_Q … /* Turn on/off error sense trace (1 and 0 respectively, default is off). Try using: "# cat /proc/scsi/sg/debug" instead in the v3 driver */ #define SG_SET_DEBUG … #define SG_NEXT_CMD_LEN … /* Defaults, commented if they differ from original sg driver */ #ifdef __KERNEL__ #define SG_DEFAULT_TIMEOUT_USER … #else #define SG_DEFAULT_TIMEOUT … #endif #define SG_DEF_COMMAND_Q … #define SG_DEF_UNDERRUN_FLAG … #endif