Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/scsi
File: sg.h
/* Copyright (C) 1997-2018 Free Software Foundation, Inc.
[0] Fix | Delete
This file is part of the GNU C Library.
[1] Fix | Delete
[2] Fix | Delete
The GNU C Library is free software; you can redistribute it and/or
[3] Fix | Delete
modify it under the terms of the GNU Lesser General Public
[4] Fix | Delete
License as published by the Free Software Foundation; either
[5] Fix | Delete
version 2.1 of the License, or (at your option) any later version.
[6] Fix | Delete
[7] Fix | Delete
The GNU C Library is distributed in the hope that it will be useful,
[8] Fix | Delete
but WITHOUT ANY WARRANTY; without even the implied warranty of
[9] Fix | Delete
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
[10] Fix | Delete
Lesser General Public License for more details.
[11] Fix | Delete
[12] Fix | Delete
You should have received a copy of the GNU Lesser General Public
[13] Fix | Delete
License along with the GNU C Library; if not, see
[14] Fix | Delete
<http://www.gnu.org/licenses/>. */
[15] Fix | Delete
[16] Fix | Delete
/*
[17] Fix | Delete
History:
[18] Fix | Delete
Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user
[19] Fix | Delete
process control of SCSI devices.
[20] Fix | Delete
Development Sponsored by Killy Corp. NY NY
[21] Fix | Delete
*/
[22] Fix | Delete
[23] Fix | Delete
#ifndef _SCSI_SG_H
[24] Fix | Delete
#define _SCSI_SG_H 1
[25] Fix | Delete
[26] Fix | Delete
#include <features.h>
[27] Fix | Delete
#define __need_size_t
[28] Fix | Delete
#include <stddef.h>
[29] Fix | Delete
[30] Fix | Delete
[31] Fix | Delete
/* New interface introduced in the 3.x SG drivers follows */
[32] Fix | Delete
[33] Fix | Delete
/* Same structure as used by readv() Linux system call. It defines one
[34] Fix | Delete
scatter-gather element. */
[35] Fix | Delete
typedef struct sg_iovec
[36] Fix | Delete
{
[37] Fix | Delete
void * iov_base; /* Starting address */
[38] Fix | Delete
size_t iov_len; /* Length in bytes */
[39] Fix | Delete
} sg_iovec_t;
[40] Fix | Delete
[41] Fix | Delete
[42] Fix | Delete
typedef struct sg_io_hdr
[43] Fix | Delete
{
[44] Fix | Delete
int interface_id; /* [i] 'S' for SCSI generic (required) */
[45] Fix | Delete
int dxfer_direction; /* [i] data transfer direction */
[46] Fix | Delete
unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
[47] Fix | Delete
unsigned char mx_sb_len; /* [i] max length to write to sbp */
[48] Fix | Delete
unsigned short int iovec_count; /* [i] 0 implies no scatter gather */
[49] Fix | Delete
unsigned int dxfer_len; /* [i] byte count of data transfer */
[50] Fix | Delete
void * dxferp; /* [i], [*io] points to data transfer memory
[51] Fix | Delete
or scatter gather list */
[52] Fix | Delete
unsigned char * cmdp; /* [i], [*i] points to command to perform */
[53] Fix | Delete
unsigned char * sbp; /* [i], [*o] points to sense_buffer memory */
[54] Fix | Delete
unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
[55] Fix | Delete
unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */
[56] Fix | Delete
int pack_id; /* [i->o] unused internally (normally) */
[57] Fix | Delete
void * usr_ptr; /* [i->o] unused internally */
[58] Fix | Delete
unsigned char status; /* [o] scsi status */
[59] Fix | Delete
unsigned char masked_status;/* [o] shifted, masked scsi status */
[60] Fix | Delete
unsigned char msg_status; /* [o] messaging level data (optional) */
[61] Fix | Delete
unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
[62] Fix | Delete
unsigned short int host_status; /* [o] errors from host adapter */
[63] Fix | Delete
unsigned short int driver_status;/* [o] errors from software driver */
[64] Fix | Delete
int resid; /* [o] dxfer_len - actual_transferred */
[65] Fix | Delete
unsigned int duration; /* [o] time taken by cmd (unit: millisec) */
[66] Fix | Delete
unsigned int info; /* [o] auxiliary information */
[67] Fix | Delete
} sg_io_hdr_t;
[68] Fix | Delete
[69] Fix | Delete
[70] Fix | Delete
/* Use negative values to flag difference from original sg_header structure. */
[71] Fix | Delete
#define SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */
[72] Fix | Delete
#define SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */
[73] Fix | Delete
#define SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */
[74] Fix | Delete
#define SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the
[75] Fix | Delete
additional property than during indirect
[76] Fix | Delete
IO the user buffer is copied into the
[77] Fix | Delete
kernel buffers before the transfer */
[78] Fix | Delete
[79] Fix | Delete
[80] Fix | Delete
/* following flag values can be "or"-ed together */
[81] Fix | Delete
#define SG_FLAG_DIRECT_IO 1 /* default is indirect IO */
[82] Fix | Delete
#define SG_FLAG_LUN_INHIBIT 2 /* default is to put device's lun into */
[83] Fix | Delete
/* the 2nd byte of SCSI command */
[84] Fix | Delete
#define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */
[85] Fix | Delete
/* user space (debug indirect IO) */
[86] Fix | Delete
[87] Fix | Delete
/* The following 'info' values are "or"-ed together. */
[88] Fix | Delete
#define SG_INFO_OK_MASK 0x1
[89] Fix | Delete
#define SG_INFO_OK 0x0 /* no sense, host nor driver "noise" */
[90] Fix | Delete
#define SG_INFO_CHECK 0x1 /* something abnormal happened */
[91] Fix | Delete
[92] Fix | Delete
#define SG_INFO_DIRECT_IO_MASK 0x6
[93] Fix | Delete
#define SG_INFO_INDIRECT_IO 0x0 /* data xfer via kernel buffers (or no xfer) */
[94] Fix | Delete
#define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */
[95] Fix | Delete
#define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */
[96] Fix | Delete
[97] Fix | Delete
[98] Fix | Delete
/* Request information about a specific SG device, used by
[99] Fix | Delete
SG_GET_SCSI_ID ioctl (). */
[100] Fix | Delete
struct sg_scsi_id {
[101] Fix | Delete
/* Host number as in "scsi<n>" where 'n' is one of 0, 1, 2 etc. */
[102] Fix | Delete
int host_no;
[103] Fix | Delete
int channel;
[104] Fix | Delete
/* SCSI id of target device. */
[105] Fix | Delete
int scsi_id;
[106] Fix | Delete
int lun;
[107] Fix | Delete
/* TYPE_... defined in <scsi/scsi.h>. */
[108] Fix | Delete
int scsi_type;
[109] Fix | Delete
/* Host (adapter) maximum commands per lun. */
[110] Fix | Delete
short int h_cmd_per_lun;
[111] Fix | Delete
/* Device (or adapter) maximum queue length. */
[112] Fix | Delete
short int d_queue_depth;
[113] Fix | Delete
/* Unused, set to 0 for now. */
[114] Fix | Delete
int unused[2];
[115] Fix | Delete
};
[116] Fix | Delete
[117] Fix | Delete
/* Used by SG_GET_REQUEST_TABLE ioctl(). */
[118] Fix | Delete
typedef struct sg_req_info {
[119] Fix | Delete
char req_state; /* 0 -> not used, 1 -> written, 2 -> ready to read */
[120] Fix | Delete
char orphan; /* 0 -> normal request, 1 -> from interruped SG_IO */
[121] Fix | Delete
char sg_io_owned; /* 0 -> complete with read(), 1 -> owned by SG_IO */
[122] Fix | Delete
char problem; /* 0 -> no problem detected, 1 -> error to report */
[123] Fix | Delete
int pack_id; /* pack_id associated with request */
[124] Fix | Delete
void * usr_ptr; /* user provided pointer (in new interface) */
[125] Fix | Delete
unsigned int duration; /* millisecs elapsed since written (req_state==1)
[126] Fix | Delete
or request duration (req_state==2) */
[127] Fix | Delete
int unused;
[128] Fix | Delete
} sg_req_info_t;
[129] Fix | Delete
[130] Fix | Delete
[131] Fix | Delete
/* IOCTLs: Those ioctls that are relevant to the SG 3.x drivers follow.
[132] Fix | Delete
[Those that only apply to the SG 2.x drivers are at the end of the file.]
[133] Fix | Delete
(_GET_s yield result via 'int *' 3rd argument unless otherwise indicated) */
[134] Fix | Delete
[135] Fix | Delete
#define SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
[136] Fix | Delete
[137] Fix | Delete
/* Used to configure SCSI command transformation layer for ATAPI devices */
[138] Fix | Delete
/* Only supported by the ide-scsi driver */
[139] Fix | Delete
#define SG_SET_TRANSFORM 0x2204 /* N.B. 3rd arg is not pointer but value: */
[140] Fix | Delete
/* 3rd arg = 0 to disable transform, 1 to enable it */
[141] Fix | Delete
#define SG_GET_TRANSFORM 0x2205
[142] Fix | Delete
[143] Fix | Delete
#define SG_SET_RESERVED_SIZE 0x2275 /* request a new reserved buffer size */
[144] Fix | Delete
#define SG_GET_RESERVED_SIZE 0x2272 /* actual size of reserved buffer */
[145] Fix | Delete
[146] Fix | Delete
/* The following ioctl has a 'sg_scsi_id_t *' object as its 3rd argument. */
[147] Fix | Delete
#define SG_GET_SCSI_ID 0x2276 /* Yields fd's bus, chan, dev, lun + type */
[148] Fix | Delete
/* SCSI id information can also be obtained from SCSI_IOCTL_GET_IDLUN */
[149] Fix | Delete
[150] Fix | Delete
/* Override host setting and always DMA using low memory ( <16MB on i386) */
[151] Fix | Delete
#define SG_SET_FORCE_LOW_DMA 0x2279 /* 0-> use adapter setting, 1-> force */
[152] Fix | Delete
#define SG_GET_LOW_DMA 0x227a /* 0-> use all ram for dma; 1-> low dma ram */
[153] Fix | Delete
[154] Fix | Delete
/* When SG_SET_FORCE_PACK_ID set to 1, pack_id is input to read() which
[155] Fix | Delete
tries to fetch a packet with a matching pack_id, waits, or returns EAGAIN.
[156] Fix | Delete
If pack_id is -1 then read oldest waiting. When ...FORCE_PACK_ID set to 0
[157] Fix | Delete
then pack_id ignored by read() and oldest readable fetched. */
[158] Fix | Delete
#define SG_SET_FORCE_PACK_ID 0x227b
[159] Fix | Delete
#define SG_GET_PACK_ID 0x227c /* Yields oldest readable pack_id (or -1) */
[160] Fix | Delete
[161] Fix | Delete
#define SG_GET_NUM_WAITING 0x227d /* Number of commands awaiting read() */
[162] Fix | Delete
[163] Fix | Delete
/* Yields max scatter gather tablesize allowed by current host adapter */
[164] Fix | Delete
#define SG_GET_SG_TABLESIZE 0x227F /* 0 implies can't do scatter gather */
[165] Fix | Delete
[166] Fix | Delete
#define SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
[167] Fix | Delete
[168] Fix | Delete
/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */
[169] Fix | Delete
#define SG_SCSI_RESET 0x2284
[170] Fix | Delete
/* Associated values that can be given to SG_SCSI_RESET follow */
[171] Fix | Delete
#define SG_SCSI_RESET_NOTHING 0
[172] Fix | Delete
#define SG_SCSI_RESET_DEVICE 1
[173] Fix | Delete
#define SG_SCSI_RESET_BUS 2
[174] Fix | Delete
#define SG_SCSI_RESET_HOST 3
[175] Fix | Delete
[176] Fix | Delete
/* synchronous SCSI command ioctl, (only in version 3 interface) */
[177] Fix | Delete
#define SG_IO 0x2285 /* similar effect as write() followed by read() */
[178] Fix | Delete
[179] Fix | Delete
#define SG_GET_REQUEST_TABLE 0x2286 /* yields table of active requests */
[180] Fix | Delete
[181] Fix | Delete
/* How to treat EINTR during SG_IO ioctl(), only in SG 3.x series */
[182] Fix | Delete
#define SG_SET_KEEP_ORPHAN 0x2287 /* 1 -> hold for read(), 0 -> drop (def) */
[183] Fix | Delete
#define SG_GET_KEEP_ORPHAN 0x2288
[184] Fix | Delete
[185] Fix | Delete
[186] Fix | Delete
#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */
[187] Fix | Delete
/* Largest size (in bytes) a single scatter-gather list element can have.
[188] Fix | Delete
The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on
[189] Fix | Delete
i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported
[190] Fix | Delete
by adapter then this value is the largest data block that can be
[191] Fix | Delete
read/written by a single scsi command. The user can find the value of
[192] Fix | Delete
PAGE_SIZE by calling getpagesize() defined in unistd.h . */
[193] Fix | Delete
[194] Fix | Delete
#define SG_DEFAULT_RETRIES 1
[195] Fix | Delete
[196] Fix | Delete
/* Defaults, commented if they differ from original sg driver */
[197] Fix | Delete
#define SG_DEF_FORCE_LOW_DMA 0 /* was 1 -> memory below 16MB on i386 */
[198] Fix | Delete
#define SG_DEF_FORCE_PACK_ID 0
[199] Fix | Delete
#define SG_DEF_KEEP_ORPHAN 0
[200] Fix | Delete
#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ /* load time option */
[201] Fix | Delete
[202] Fix | Delete
/* maximum outstanding requests, write() yields EDOM if exceeded */
[203] Fix | Delete
#define SG_MAX_QUEUE 16
[204] Fix | Delete
[205] Fix | Delete
#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE /* for backward compatibility */
[206] Fix | Delete
[207] Fix | Delete
/* Alternate style type names, "..._t" variants preferred */
[208] Fix | Delete
typedef struct sg_io_hdr Sg_io_hdr;
[209] Fix | Delete
typedef struct sg_io_vec Sg_io_vec;
[210] Fix | Delete
typedef struct sg_scsi_id Sg_scsi_id;
[211] Fix | Delete
typedef struct sg_req_info Sg_req_info;
[212] Fix | Delete
[213] Fix | Delete
[214] Fix | Delete
/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
[215] Fix | Delete
/* The older SG interface based on the 'sg_header' structure follows. */
[216] Fix | Delete
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
[217] Fix | Delete
[218] Fix | Delete
#define SG_MAX_SENSE 16 /* this only applies to the sg_header interface */
[219] Fix | Delete
[220] Fix | Delete
struct sg_header
[221] Fix | Delete
{
[222] Fix | Delete
/* Length of incoming packet (including header). */
[223] Fix | Delete
int pack_len;
[224] Fix | Delete
/* Maximal length of expected reply. */
[225] Fix | Delete
int reply_len;
[226] Fix | Delete
/* Id number of packet. */
[227] Fix | Delete
int pack_id;
[228] Fix | Delete
/* 0==ok, otherwise error number. */
[229] Fix | Delete
int result;
[230] Fix | Delete
/* Force 12 byte command length for group 6 & 7 commands. */
[231] Fix | Delete
unsigned int twelve_byte:1;
[232] Fix | Delete
/* SCSI status from target. */
[233] Fix | Delete
unsigned int target_status:5;
[234] Fix | Delete
/* Host status (see "DID" codes). */
[235] Fix | Delete
unsigned int host_status:8;
[236] Fix | Delete
/* Driver status+suggestion. */
[237] Fix | Delete
unsigned int driver_status:8;
[238] Fix | Delete
/* Unused. */
[239] Fix | Delete
unsigned int other_flags:10;
[240] Fix | Delete
/* Output in 3 cases:
[241] Fix | Delete
when target_status is CHECK_CONDITION or
[242] Fix | Delete
when target_status is COMMAND_TERMINATED or
[243] Fix | Delete
when (driver_status & DRIVER_SENSE) is true. */
[244] Fix | Delete
unsigned char sense_buffer[SG_MAX_SENSE];
[245] Fix | Delete
};
[246] Fix | Delete
[247] Fix | Delete
[248] Fix | Delete
/* IOCTLs: The following are not required (or ignored) when the sg_io_hdr_t
[249] Fix | Delete
interface is used. They are kept for backward compatibility with
[250] Fix | Delete
the original and version 2 drivers. */
[251] Fix | Delete
[252] Fix | Delete
#define SG_SET_TIMEOUT 0x2201 /* Set timeout; *(int *)arg==timeout. */
[253] Fix | Delete
#define SG_GET_TIMEOUT 0x2202 /* Get timeout; return timeout. */
[254] Fix | Delete
[255] Fix | Delete
/* Get/set command queuing state per fd (default is SG_DEF_COMMAND_Q). */
[256] Fix | Delete
#define SG_GET_COMMAND_Q 0x2270 /* Yields 0 (queuing off) or 1 (on). */
[257] Fix | Delete
#define SG_SET_COMMAND_Q 0x2271 /* Change queuing state with 0 or 1. */
[258] Fix | Delete
[259] Fix | Delete
/* Turn on error sense trace (1..8), dump this device to log/console (9)
[260] Fix | Delete
or dump all sg device states ( >9 ) to log/console. */
[261] Fix | Delete
#define SG_SET_DEBUG 0x227e /* 0 -> turn off debug */
[262] Fix | Delete
[263] Fix | Delete
#define SG_NEXT_CMD_LEN 0x2283 /* Override SCSI command length with given
[264] Fix | Delete
number on the next write() on this file
[265] Fix | Delete
descriptor. */
[266] Fix | Delete
[267] Fix | Delete
/* Defaults, commented if they differ from original sg driver */
[268] Fix | Delete
#define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */
[269] Fix | Delete
#define SG_DEF_COMMAND_Q 0 /* command queuing is always on when
[270] Fix | Delete
the new interface is used */
[271] Fix | Delete
#define SG_DEF_UNDERRUN_FLAG 0
[272] Fix | Delete
[273] Fix | Delete
[274] Fix | Delete
#endif /* scsi/sg.h */
[275] Fix | Delete
[276] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function