brintos

brintos / linux-shallow public Read only

0
0
Text · 12.6 KiB · 70e1262 Raw
440 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * This header file contains public constants and structures used by4 * both the SCSI initiator and the SCSI target code.5 *6 * For documentation on the OPCODES, MESSAGES, and SENSE values,7 * please consult the SCSI standard.8 */9 10#ifndef _SCSI_PROTO_H_11#define _SCSI_PROTO_H_12 13#include <linux/build_bug.h>14#include <linux/types.h>15 16/*17 *      SCSI opcodes18 */19 20#define TEST_UNIT_READY       0x0021#define REZERO_UNIT           0x0122#define REQUEST_SENSE         0x0323#define FORMAT_UNIT           0x0424#define READ_BLOCK_LIMITS     0x0525#define REASSIGN_BLOCKS       0x0726#define INITIALIZE_ELEMENT_STATUS 0x0727#define READ_6                0x0828#define WRITE_6               0x0a29#define SEEK_6                0x0b30#define READ_REVERSE          0x0f31#define WRITE_FILEMARKS       0x1032#define SPACE                 0x1133#define INQUIRY               0x1234#define RECOVER_BUFFERED_DATA 0x1435#define MODE_SELECT           0x1536#define RESERVE               0x1637#define RELEASE               0x1738#define COPY                  0x1839#define ERASE                 0x1940#define MODE_SENSE            0x1a41#define START_STOP            0x1b42#define RECEIVE_DIAGNOSTIC    0x1c43#define SEND_DIAGNOSTIC       0x1d44#define ALLOW_MEDIUM_REMOVAL  0x1e45 46#define READ_FORMAT_CAPACITIES 0x2347#define SET_WINDOW            0x2448#define READ_CAPACITY         0x2549#define READ_10               0x2850#define WRITE_10              0x2a51#define SEEK_10               0x2b52#define POSITION_TO_ELEMENT   0x2b53#define WRITE_VERIFY          0x2e54#define VERIFY                0x2f55#define SEARCH_HIGH           0x3056#define SEARCH_EQUAL          0x3157#define SEARCH_LOW            0x3258#define SET_LIMITS            0x3359#define PRE_FETCH             0x3460#define READ_POSITION         0x3461#define SYNCHRONIZE_CACHE     0x3562#define LOCK_UNLOCK_CACHE     0x3663#define READ_DEFECT_DATA      0x3764#define MEDIUM_SCAN           0x3865#define COMPARE               0x3966#define COPY_VERIFY           0x3a67#define WRITE_BUFFER          0x3b68#define READ_BUFFER           0x3c69#define UPDATE_BLOCK          0x3d70#define READ_LONG             0x3e71#define WRITE_LONG            0x3f72#define CHANGE_DEFINITION     0x4073#define WRITE_SAME            0x4174#define UNMAP		      0x4275#define READ_TOC              0x4376#define READ_HEADER           0x4477#define GET_EVENT_STATUS_NOTIFICATION 0x4a78#define LOG_SELECT            0x4c79#define LOG_SENSE             0x4d80#define XDWRITEREAD_10        0x5381#define MODE_SELECT_10        0x5582#define RESERVE_10            0x5683#define RELEASE_10            0x5784#define MODE_SENSE_10         0x5a85#define PERSISTENT_RESERVE_IN 0x5e86#define PERSISTENT_RESERVE_OUT 0x5f87#define VARIABLE_LENGTH_CMD   0x7f88#define REPORT_LUNS           0xa089#define SECURITY_PROTOCOL_IN  0xa290#define MAINTENANCE_IN        0xa391#define MAINTENANCE_OUT       0xa492#define MOVE_MEDIUM           0xa593#define EXCHANGE_MEDIUM       0xa694#define READ_12               0xa895#define SERVICE_ACTION_OUT_12 0xa996#define WRITE_12              0xaa97#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */98#define SERVICE_ACTION_IN_12  0xab99#define WRITE_VERIFY_12       0xae100#define VERIFY_12	      0xaf101#define SEARCH_HIGH_12        0xb0102#define SEARCH_EQUAL_12       0xb1103#define SEARCH_LOW_12         0xb2104#define SECURITY_PROTOCOL_OUT 0xb5105#define READ_ELEMENT_STATUS   0xb8106#define SEND_VOLUME_TAG       0xb6107#define WRITE_LONG_2          0xea108#define EXTENDED_COPY         0x83109#define RECEIVE_COPY_RESULTS  0x84110#define ACCESS_CONTROL_IN     0x86111#define ACCESS_CONTROL_OUT    0x87112#define READ_16               0x88113#define COMPARE_AND_WRITE     0x89114#define WRITE_16              0x8a115#define READ_ATTRIBUTE        0x8c116#define WRITE_ATTRIBUTE	      0x8d117#define WRITE_VERIFY_16	      0x8e118#define VERIFY_16	      0x8f119#define SYNCHRONIZE_CACHE_16  0x91120#define WRITE_SAME_16	      0x93121#define ZBC_OUT		      0x94122#define ZBC_IN		      0x95123#define WRITE_ATOMIC_16	0x9c124#define SERVICE_ACTION_BIDIRECTIONAL 0x9d125#define SERVICE_ACTION_IN_16  0x9e126#define SERVICE_ACTION_OUT_16 0x9f127/* values for service action in */128#define	SAI_READ_CAPACITY_16  0x10129#define SAI_GET_LBA_STATUS    0x12130#define SAI_REPORT_REFERRALS  0x13131#define SAI_GET_STREAM_STATUS 0x16132/* values for maintenance in */133#define MI_REPORT_IDENTIFYING_INFORMATION 0x05134#define MI_REPORT_TARGET_PGS  0x0a135#define MI_REPORT_ALIASES     0x0b136#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c137#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d138#define MI_REPORT_PRIORITY    0x0e139#define MI_REPORT_TIMESTAMP   0x0f140#define MI_MANAGEMENT_PROTOCOL_IN 0x10141/* value for MI_REPORT_TARGET_PGS ext header */142#define MI_EXT_HDR_PARAM_FMT  0x20143/* values for maintenance out */144#define MO_SET_IDENTIFYING_INFORMATION 0x06145#define MO_SET_TARGET_PGS     0x0a146#define MO_CHANGE_ALIASES     0x0b147#define MO_SET_PRIORITY       0x0e148#define MO_SET_TIMESTAMP      0x0f149#define MO_MANAGEMENT_PROTOCOL_OUT 0x10150/* values for ZBC_IN */151#define ZI_REPORT_ZONES	      0x00152/* values for ZBC_OUT */153#define ZO_CLOSE_ZONE	      0x01154#define ZO_FINISH_ZONE	      0x02155#define ZO_OPEN_ZONE	      0x03156#define ZO_RESET_WRITE_POINTER 0x04157/* values for PR in service action */158#define READ_KEYS             0x00159#define READ_RESERVATION      0x01160#define REPORT_CAPABILITES    0x02161#define READ_FULL_STATUS      0x03162/* values for variable length command */163#define XDREAD_32	      0x03164#define XDWRITE_32	      0x04165#define XPWRITE_32	      0x06166#define XDWRITEREAD_32	      0x07167#define READ_32		      0x09168#define VERIFY_32	      0x0a169#define WRITE_32	      0x0b170#define WRITE_VERIFY_32	      0x0c171#define WRITE_SAME_32	      0x0d172#define ATA_32		      0x1ff0173 174/* Values for T10/04-262r7 */175#define	ATA_16		      0x85	/* 16-byte pass-thru */176#define	ATA_12		      0xa1	/* 12-byte pass-thru */177 178/* Vendor specific CDBs start here */179#define VENDOR_SPECIFIC_CDB 0xc0180 181/*182 *	SCSI command lengths183 */184 185#define SCSI_MAX_VARLEN_CDB_SIZE 260186 187/* defined in T10 SCSI Primary Commands-2 (SPC2) */188struct scsi_varlen_cdb_hdr {189	__u8 opcode;        /* opcode always == VARIABLE_LENGTH_CMD */190	__u8 control;191	__u8 misc[5];192	__u8 additional_cdb_length;         /* total cdb length - 8 */193	__be16 service_action;194	/* service specific data follows */195};196 197/*198 *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft199 *  T10/1561-D Revision 4 Draft dated 7th November 2002.200 */201enum sam_status {202	SAM_STAT_GOOD				= 0x00,203	SAM_STAT_CHECK_CONDITION		= 0x02,204	SAM_STAT_CONDITION_MET			= 0x04,205	SAM_STAT_BUSY				= 0x08,206	SAM_STAT_INTERMEDIATE			= 0x10,207	SAM_STAT_INTERMEDIATE_CONDITION_MET	= 0x14,208	SAM_STAT_RESERVATION_CONFLICT		= 0x18,209	SAM_STAT_COMMAND_TERMINATED		= 0x22,	/* obsolete in SAM-3 */210	SAM_STAT_TASK_SET_FULL			= 0x28,211	SAM_STAT_ACA_ACTIVE			= 0x30,212	SAM_STAT_TASK_ABORTED			= 0x40,213};214 215#define STATUS_MASK         0xfe216 217/*218 *  SENSE KEYS219 */220#define NO_SENSE            0x00221#define RECOVERED_ERROR     0x01222#define NOT_READY           0x02223#define MEDIUM_ERROR        0x03224#define HARDWARE_ERROR      0x04225#define ILLEGAL_REQUEST     0x05226#define UNIT_ATTENTION      0x06227#define DATA_PROTECT        0x07228#define BLANK_CHECK         0x08229#define VENDOR_SPECIFIC     0x09230#define COPY_ABORTED        0x0a231#define ABORTED_COMMAND     0x0b232#define VOLUME_OVERFLOW     0x0d233#define MISCOMPARE          0x0e234#define COMPLETED	    0x0f235 236/*237 *  DEVICE TYPES238 *  Please keep them in 0x%02x format for $MODALIAS to work239 */240 241#define TYPE_DISK           0x00242#define TYPE_TAPE           0x01243#define TYPE_PRINTER        0x02244#define TYPE_PROCESSOR      0x03    /* HP scanners use this */245#define TYPE_WORM           0x04    /* Treated as ROM by our system */246#define TYPE_ROM            0x05247#define TYPE_SCANNER        0x06248#define TYPE_MOD            0x07    /* Magneto-optical disk -249				     * - treated as TYPE_DISK */250#define TYPE_MEDIUM_CHANGER 0x08251#define TYPE_COMM           0x09    /* Communications device */252#define TYPE_RAID           0x0c253#define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */254#define TYPE_RBC	    0x0e255#define TYPE_OSD            0x11256#define TYPE_ZBC            0x14257#define TYPE_WLUN           0x1e    /* well-known logical unit */258#define TYPE_NO_LUN         0x7f259 260/* SCSI protocols; these are taken from SPC-3 section 7.5 */261enum scsi_protocol {262	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */263	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */264	SCSI_PROTOCOL_SSA = 2,	/* Serial Storage Architecture - Obsolete */265	SCSI_PROTOCOL_SBP = 3,	/* firewire */266	SCSI_PROTOCOL_SRP = 4,	/* Infiniband RDMA */267	SCSI_PROTOCOL_ISCSI = 5,268	SCSI_PROTOCOL_SAS = 6,269	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */270	SCSI_PROTOCOL_ATA = 8,271	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */272};273 274/*275 * ScsiLun: 8 byte LUN.276 */277struct scsi_lun {278	__u8 scsi_lun[8];279};280 281/* SBC-5 IO advice hints group descriptor */282struct scsi_io_group_descriptor {283#if defined(__BIG_ENDIAN)284	u8 io_advice_hints_mode: 2;285	u8 reserved1: 3;286	u8 st_enble: 1;287	u8 cs_enble: 1;288	u8 ic_enable: 1;289#elif defined(__LITTLE_ENDIAN)290	u8 ic_enable: 1;291	u8 cs_enble: 1;292	u8 st_enble: 1;293	u8 reserved1: 3;294	u8 io_advice_hints_mode: 2;295#else296#error297#endif298	u8 reserved2[3];299	/* Logical block markup descriptor */300#if defined(__BIG_ENDIAN)301	u8 acdlu: 1;302	u8 reserved3: 1;303	u8 rlbsr: 2;304	u8 lbm_descriptor_type: 4;305#elif defined(__LITTLE_ENDIAN)306	u8 lbm_descriptor_type: 4;307	u8 rlbsr: 2;308	u8 reserved3: 1;309	u8 acdlu: 1;310#else311#error312#endif313	u8 params[2];314	u8 reserved4;315	u8 reserved5[8];316};317 318static_assert(sizeof(struct scsi_io_group_descriptor) == 16);319 320/* SCSI stream status descriptor */321struct scsi_stream_status {322#if defined(__BIG_ENDIAN)323	u8 perm: 1;324	u8 reserved1: 7;325#elif defined(__LITTLE_ENDIAN)326	u8 reserved1: 7;327	u8 perm: 1;328#else329#error330#endif331	u8 reserved2;332	__be16 stream_identifier;333#if defined(__BIG_ENDIAN)334	u8 reserved3: 2;335	u8 rel_lifetime: 6;336#elif defined(__LITTLE_ENDIAN)337	u8 rel_lifetime: 6;338	u8 reserved3: 2;339#else340#error341#endif342	u8 reserved4[3];343};344 345static_assert(sizeof(struct scsi_stream_status) == 8);346 347/* GET STREAM STATUS parameter data */348struct scsi_stream_status_header {349	__be32 len;	/* length in bytes of stream_status[] array. */350	u16 reserved;351	__be16 number_of_open_streams;352	DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status);353};354 355static_assert(sizeof(struct scsi_stream_status_header) == 8);356 357/* SPC asymmetric access states */358#define SCSI_ACCESS_STATE_OPTIMAL     0x00359#define SCSI_ACCESS_STATE_ACTIVE      0x01360#define SCSI_ACCESS_STATE_STANDBY     0x02361#define SCSI_ACCESS_STATE_UNAVAILABLE 0x03362#define SCSI_ACCESS_STATE_LBA         0x04363#define SCSI_ACCESS_STATE_OFFLINE     0x0e364#define SCSI_ACCESS_STATE_TRANSITIONING 0x0f365 366/* Values for REPORT TARGET GROUP STATES */367#define SCSI_ACCESS_STATE_MASK        0x0f368#define SCSI_ACCESS_STATE_PREFERRED   0x80369 370/* Reporting options for REPORT ZONES */371enum zbc_zone_reporting_options {372	ZBC_ZONE_REPORTING_OPTION_ALL		= 0x00,373	ZBC_ZONE_REPORTING_OPTION_EMPTY		= 0x01,374	ZBC_ZONE_REPORTING_OPTION_IMPLICIT_OPEN	= 0x02,375	ZBC_ZONE_REPORTING_OPTION_EXPLICIT_OPEN	= 0x03,376	ZBC_ZONE_REPORTING_OPTION_CLOSED	= 0x04,377	ZBC_ZONE_REPORTING_OPTION_FULL		= 0x05,378	ZBC_ZONE_REPORTING_OPTION_READONLY	= 0x06,379	ZBC_ZONE_REPORTING_OPTION_OFFLINE	= 0x07,380	/* 0x08 to 0x0f are reserved */381	ZBC_ZONE_REPORTING_OPTION_NEED_RESET_WP	= 0x10,382	ZBC_ZONE_REPORTING_OPTION_NON_SEQWRITE	= 0x11,383	/* 0x12 to 0x3e are reserved */384	ZBC_ZONE_REPORTING_OPTION_NON_WP	= 0x3f,385};386 387#define ZBC_REPORT_ZONE_PARTIAL 0x80388 389/* Zone types of REPORT ZONES zone descriptors */390enum zbc_zone_type {391	ZBC_ZONE_TYPE_CONV		= 0x1,392	ZBC_ZONE_TYPE_SEQWRITE_REQ	= 0x2,393	ZBC_ZONE_TYPE_SEQWRITE_PREF	= 0x3,394	ZBC_ZONE_TYPE_SEQ_OR_BEFORE_REQ	= 0x4,395	ZBC_ZONE_TYPE_GAP		= 0x5,396	/* 0x6 to 0xf are reserved */397};398 399/* Zone conditions of REPORT ZONES zone descriptors */400enum zbc_zone_cond {401	ZBC_ZONE_COND_NO_WP		= 0x0,402	ZBC_ZONE_COND_EMPTY		= 0x1,403	ZBC_ZONE_COND_IMP_OPEN		= 0x2,404	ZBC_ZONE_COND_EXP_OPEN		= 0x3,405	ZBC_ZONE_COND_CLOSED		= 0x4,406	/* 0x5 to 0xc are reserved */407	ZBC_ZONE_COND_READONLY		= 0xd,408	ZBC_ZONE_COND_FULL		= 0xe,409	ZBC_ZONE_COND_OFFLINE		= 0xf,410};411 412enum zbc_zone_alignment_method {413	ZBC_CONSTANT_ZONE_LENGTH	= 0x1,414	ZBC_CONSTANT_ZONE_START_OFFSET	= 0x8,415};416 417/* Version descriptor values for INQUIRY */418enum scsi_version_descriptor {419	SCSI_VERSION_DESCRIPTOR_FCP4	= 0x0a40,420	SCSI_VERSION_DESCRIPTOR_ISCSI	= 0x0960,421	SCSI_VERSION_DESCRIPTOR_SAM5	= 0x00a0,422	SCSI_VERSION_DESCRIPTOR_SAS3	= 0x0c60,423	SCSI_VERSION_DESCRIPTOR_SBC3	= 0x04c0,424	SCSI_VERSION_DESCRIPTOR_SBP3	= 0x0980,425	SCSI_VERSION_DESCRIPTOR_SPC4	= 0x0460,426	SCSI_VERSION_DESCRIPTOR_SRP	= 0x0940427};428 429enum scsi_support_opcode {430	SCSI_SUPPORT_NO_INFO		= 0,431	SCSI_SUPPORT_NOT_SUPPORTED	= 1,432	SCSI_SUPPORT_FULL		= 3,433	SCSI_SUPPORT_VENDOR		= 5,434};435 436#define SCSI_CONTROL_MASK 0437#define SCSI_GROUP_NUMBER_MASK 0438 439#endif /* _SCSI_PROTO_H_ */440