45#define SCSI_READY_MAX_RETRIES 10
48#define EIO_NO_SENSE __einfo_error ( EINFO_EIO_NO_SENSE )
49#define EINFO_EIO_NO_SENSE \
50 __einfo_uniqify ( EINFO_EIO, 0x00, "No sense" )
51#define EIO_RECOVERED_ERROR __einfo_error ( EINFO_EIO_RECOVERED_ERROR )
52#define EINFO_EIO_RECOVERED_ERROR \
53 __einfo_uniqify ( EINFO_EIO, 0x01, "Recovered error" )
54#define EIO_NOT_READY __einfo_error ( EINFO_EIO_NOT_READY )
55#define EINFO_EIO_NOT_READY \
56 __einfo_uniqify ( EINFO_EIO, 0x02, "Not ready" )
57#define EIO_MEDIUM_ERROR __einfo_error ( EINFO_EIO_MEDIUM_ERROR )
58#define EINFO_EIO_MEDIUM_ERROR \
59 __einfo_uniqify ( EINFO_EIO, 0x03, "Medium error" )
60#define EIO_HARDWARE_ERROR __einfo_error ( EINFO_EIO_HARDWARE_ERROR )
61#define EINFO_EIO_HARDWARE_ERROR \
62 __einfo_uniqify ( EINFO_EIO, 0x04, "Hardware error" )
63#define EIO_ILLEGAL_REQUEST __einfo_error ( EINFO_EIO_ILLEGAL_REQUEST )
64#define EINFO_EIO_ILLEGAL_REQUEST \
65 __einfo_uniqify ( EINFO_EIO, 0x05, "Illegal request" )
66#define EIO_UNIT_ATTENTION __einfo_error ( EINFO_EIO_UNIT_ATTENTION )
67#define EINFO_EIO_UNIT_ATTENTION \
68 __einfo_uniqify ( EINFO_EIO, 0x06, "Unit attention" )
69#define EIO_DATA_PROTECT __einfo_error ( EINFO_EIO_DATA_PROTECT )
70#define EINFO_EIO_DATA_PROTECT \
71 __einfo_uniqify ( EINFO_EIO, 0x07, "Data protect" )
72#define EIO_BLANK_CHECK __einfo_error ( EINFO_EIO_BLANK_CHECK )
73#define EINFO_EIO_BLANK_CHECK \
74 __einfo_uniqify ( EINFO_EIO, 0x08, "Blank check" )
75#define EIO_VENDOR_SPECIFIC __einfo_error ( EINFO_EIO_VENDOR_SPECIFIC )
76#define EINFO_EIO_VENDOR_SPECIFIC \
77 __einfo_uniqify ( EINFO_EIO, 0x09, "Vendor specific" )
78#define EIO_COPY_ABORTED __einfo_error ( EINFO_EIO_COPY_ABORTED )
79#define EINFO_EIO_COPY_ABORTED \
80 __einfo_uniqify ( EINFO_EIO, 0x0a, "Copy aborted" )
81#define EIO_ABORTED_COMMAND __einfo_error ( EINFO_EIO_ABORTED_COMMAND )
82#define EINFO_EIO_ABORTED_COMMAND \
83 __einfo_uniqify ( EINFO_EIO, 0x0b, "Aborted command" )
84#define EIO_RESERVED __einfo_error ( EINFO_EIO_RESERVED )
85#define EINFO_EIO_RESERVED \
86 __einfo_uniqify ( EINFO_EIO, 0x0c, "Reserved" )
87#define EIO_VOLUME_OVERFLOW __einfo_error ( EINFO_EIO_VOLUME_OVERFLOW )
88#define EINFO_EIO_VOLUME_OVERFLOW \
89 __einfo_uniqify ( EINFO_EIO, 0x0d, "Volume overflow" )
90#define EIO_MISCOMPARE __einfo_error ( EINFO_EIO_MISCOMPARE )
91#define EINFO_EIO_MISCOMPARE \
92 __einfo_uniqify ( EINFO_EIO, 0x0e, "Miscompare" )
93#define EIO_COMPLETED __einfo_error ( EINFO_EIO_COMPLETED )
94#define EINFO_EIO_COMPLETED \
95 __einfo_uniqify ( EINFO_EIO, 0x0f, "Completed" )
96#define EIO_SENSE( key ) \
97 EUNIQ ( EINFO_EIO, (key), EIO_NO_SENSE, EIO_RECOVERED_ERROR, \
98 EIO_NOT_READY, EIO_MEDIUM_ERROR, EIO_HARDWARE_ERROR, \
99 EIO_ILLEGAL_REQUEST, EIO_UNIT_ATTENTION, \
100 EIO_DATA_PROTECT, EIO_BLANK_CHECK, EIO_VENDOR_SPECIFIC, \
101 EIO_COPY_ABORTED, EIO_ABORTED_COMMAND, EIO_RESERVED, \
102 EIO_VOLUME_OVERFLOW, EIO_MISCOMPARE, EIO_COMPLETED )
124 p = (
char * ) lun_string;
125 for ( i = 0 ; i < 4 ; i++ ) {
152 memset ( sense, 0,
sizeof ( *sense ) );
155 if (
len <
sizeof ( sns->
desc ) )
157 memcpy ( sense, &sns->
desc, sizeof ( *sense ) );
214 op (
object, response );
368 return scsicmd->
priv;
397 DBGC ( scsidev,
"SCSI %p tag %08x closed: %s\n",
431 DBGC ( scsidev,
"SCSI %p could not issue command: %s\n",
437 if ( scsicmd->
tag ) {
438 DBGC ( scsidev,
"SCSI %p tag %08x is now tag %08x\n",
439 scsidev, scsicmd->
tag,
tag );
477 if ( response->
status == 0 ) {
480 DBGC ( scsidev,
"SCSI %p tag %08x status %02x",
481 scsidev, scsicmd->
tag, response->
status );
484 DBGC ( scsidev,
" overrun +%zd", overrun );
485 }
else if ( response->
overrun < 0 ) {
486 underrun = -(response->
overrun);
487 DBGC ( scsidev,
" underrun -%zd", underrun );
489 DBGC ( scsidev,
" sense %02x key %02x additional %04x\n",
596 command->data_in_len =
sizeof ( *capacity16 );
601 command->data_in_len =
sizeof ( *capacity10 );
639 if ( capacity.
blocks == 0 ) {
662 .name =
"READ CAPACITY",
683 .name =
"TEST UNIT READY",
730 scsicmd =
zalloc (
sizeof ( *scsicmd ) +
type->priv_len );
892 DBGC ( scsidev,
"SCSI %p unit is ready\n", scsidev );
897 DBGC ( scsidev,
"SCSI %p not ready: %s\n", scsidev,
strerror (
rc ) );
911 DBGC ( scsidev,
"SCSI %p retrying (retry %d)\n",
919 DBGC ( scsidev,
"SCSI %p never became ready: %s\n",
949 DBGC ( scsidev,
"SCSI %p waiting for unit to become ready\n",
990 scsidev =
zalloc (
sizeof ( *scsidev ) );
#define NULL
NULL pointer (VOID *)
struct arbelprm_rc_send_wqe rc
unsigned long long uint64_t
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
int block_read_capacity(struct interface *control, struct interface *data)
Read block device capacity.
int block_write(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len)
Write to block device.
int block_read(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len)
Read from block device.
void block_capacity(struct interface *intf, struct block_device_capacity *capacity)
Report block device capacity.
uint64_t tag
Identity tag.
uint8_t lun
Logical Unit Number.
uint32_t type
Operating system type.
uint8_t data[48]
Additional event data.
#define __unused
Declare a variable or data structure as unused.
static unsigned int count
Number of entries.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
uint64_t lba
Starting block number.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define EINVAL
Invalid argument.
#define EOPNOTSUPP
Operation not supported on socket.
#define ENOMEM
Not enough space.
#define SCSI_CDB_DATA(cdb)
printf() parameters for dumping a scsi_cdb
#define SCSI_CDB_FORMAT
printf() format for dumping a scsi_cdb
#define SCSI_OPCODE_SERVICE_ACTION_IN
SERVICE ACTION IN.
#define SCSI_OPCODE_READ_10
READ (10)
#define SCSI_OPCODE_TEST_UNIT_READY
TEST UNIT READY.
#define SCSI_OPCODE_WRITE_16
WRITE (16)
#define SCSI_OPCODE_READ_CAPACITY_10
READ CAPACITY (10)
#define SCSI_OPCODE_READ_16
READ (16)
#define SCSI_OPCODE_WRITE_10
WRITE (10)
#define SCSI_SERVICE_ACTION_READ_CAPACITY_16
READ CAPACITY (16)
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
#define be32_to_cpu(value)
#define cpu_to_be16(value)
#define cpu_to_be32(value)
#define cpu_to_be64(value)
#define be64_to_cpu(value)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
void intf_close(struct interface *intf, int rc)
Close an object interface.
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
void intfs_shutdown(int rc,...)
Shut down multiple object interfaces.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
#define list_del(list)
Delete an entry from a list.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define list_add(new, head)
Add a new entry to the head of a list.
void * zalloc(size_t size)
Allocate cleared memory.
uint8_t block[3][8]
DES-encrypted blocks.
static uint16_t struct vmbus_xfer_pages_operations * op
void process_del(struct process *process)
Remove process from process list.
void process_add(struct process *process)
Add process to process list.
#define PROC_DESC_ONCE(object_type, process, _step)
Define a process descriptor for a process that runs only once.
static void process_init(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process and add to process list.
static void(* free)(struct refcnt *refcnt))
#define ref_get(refcnt)
Get additional reference to object.
#define ref_put(refcnt)
Drop reference to object.
#define ref_init(refcnt, free)
Initialise a reference counter.
static struct scsi_device * scsidev_get(struct scsi_device *scsidev)
Get reference to SCSI device.
#define SCSI_READY_MAX_RETRIES
Maximum number of TEST UNIT READY retries.
static void scsicmd_read_cmd(struct scsi_command *scsicmd, struct scsi_cmd *command)
Construct SCSI READ command.
static int scsicmd_command(struct scsi_command *scsicmd)
Construct and issue SCSI command.
static struct scsi_command_type scsicmd_read
SCSI READ command type.
scsi_device_flags
SCSI device flags.
@ SCSIDEV_UNIT_READY
TEST UNIT READY has completed successfully.
@ SCSIDEV_UNIT_TESTED
TEST UNIT READY has been issued.
static struct interface_descriptor scsicmd_scsi_desc
SCSI command SCSI interface descriptor.
static struct scsi_command_type scsicmd_write
SCSI WRITE command type.
static struct interface_descriptor scsidev_ready_desc
SCSI device TEST UNIT READY interface descriptor.
static int scsidev_write(struct scsi_device *scsidev, struct interface *block, uint64_t lba, unsigned int count, void *buffer, size_t len)
Issue SCSI block write.
int scsi_open(struct interface *block, struct interface *scsi, struct scsi_lun *lun)
Open SCSI device.
static struct interface_descriptor scsidev_scsi_desc
SCSI device SCSI interface descriptor.
static struct interface_descriptor scsidev_block_desc
SCSI device block interface descriptor.
static void scsicmd_write_cmd(struct scsi_command *scsicmd, struct scsi_cmd *command)
Construct SCSI WRITE command.
static struct interface_descriptor scsicmd_block_desc
SCSI command block interface descriptor.
static void scsidev_put(struct scsi_device *scsidev)
Drop reference to SCSI device.
static void scsidev_step(struct scsi_device *scsidev)
SCSI TEST UNIT READY process.
static int scsidev_test_unit_ready(struct scsi_device *scsidev, struct interface *block)
Test to see if SCSI device is ready.
static int scsidev_command(struct scsi_device *scsidev, struct interface *block, struct scsi_command_type *type, uint64_t lba, unsigned int count, void *buffer, size_t len)
Create SCSI command.
static void scsicmd_done(struct scsi_command *scsicmd, int rc)
Handle SCSI command completion.
static void scsicmd_read_capacity_cmd(struct scsi_command *scsicmd, struct scsi_cmd *command)
Construct SCSI READ CAPACITY command.
static void scsidev_ready(struct scsi_device *scsidev, int rc)
Handle SCSI TEST UNIT READY response.
static void scsicmd_put(struct scsi_command *scsicmd)
Drop reference to SCSI command.
static struct interface_operation scsicmd_scsi_op[]
SCSI command SCSI interface operations.
static void scsicmd_close(struct scsi_command *scsicmd, int rc)
Close SCSI command.
static size_t scsidev_window(struct scsi_device *scsidev)
Check SCSI device flow-control window.
static void scsicmd_free(struct refcnt *refcnt)
Free SCSI command.
static struct process_descriptor scsidev_process_desc
SCSI device process descriptor.
int scsi_command(struct interface *control, struct interface *data, struct scsi_cmd *command)
Issue SCSI command.
static void * scsicmd_priv(struct scsi_command *scsicmd)
Get SCSI command private data.
static struct scsi_command_type scsicmd_test_unit_ready
SCSI TEST UNIT READY command type.
static struct interface_operation scsidev_ready_op[]
SCSI device TEST UNIT READY interface operations.
static int scsidev_read_capacity(struct scsi_device *scsidev, struct interface *block)
Read SCSI device capacity.
static int scsidev_read(struct scsi_device *scsidev, struct interface *block, uint64_t lba, unsigned int count, void *buffer, size_t len)
Issue SCSI block read.
static void scsicmd_test_unit_ready_cmd(struct scsi_command *scsicmd __unused, struct scsi_cmd *command)
Construct SCSI TEST UNIT READY command.
static struct scsi_command_type scsicmd_read_capacity
SCSI READ CAPACITY command type.
static void scsidev_close(struct scsi_device *scsidev, int rc)
Close SCSI device.
static void scsicmd_response(struct scsi_command *scsicmd, struct scsi_rsp *response)
Handle SCSI response.
void scsi_response(struct interface *intf, struct scsi_rsp *response)
Report SCSI response.
static void scsicmd_read_capacity_done(struct scsi_command *scsicmd, int rc)
Handle SCSI READ CAPACITY command completion.
static struct scsi_command * scsicmd_get(struct scsi_command *scsicmd)
Get reference to SCSI command.
static struct interface_operation scsicmd_block_op[]
SCSI command block interface operations.
void scsi_parse_sense(const void *data, size_t len, struct scsi_sns_descriptor *sense)
Parse SCSI sense data.
static struct interface_operation scsidev_scsi_op[]
SCSI device SCSI interface operations.
static struct interface_operation scsidev_block_op[]
SCSI device block interface operations.
int scsi_parse_lun(const char *lun_string, struct scsi_lun *lun)
Parse SCSI LUN.
#define SCSI_SENSE_KEY_MASK
SCSI sense key mask.
#define scsi_response_TYPE(object_type)
#define SCSI_SENSE_FIXED(code)
Test if SCSI sense data is in fixed format.
#define SCSI_SENSE_CODE_MASK
SCSI sense response code mask.
#define SCSI_LUN_FORMAT
printf() format for dumping a scsi_lun
#define SCSI_MAX_BLOCK_10
Maximum block for READ/WRITE (10) commands.
#define SCSI_LUN_DATA(lun)
printf() parameters for dumping a scsi_lun
#define scsi_command_TYPE(object_type)
#define container_of(ptr, type, field)
Get containing structure.
char * strerror(int errno)
Retrieve string representation of error number.
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
uint64_t blocks
Total number of blocks.
unsigned int max_count
Maximum number of blocks per single transfer.
size_t blksize
Block size.
An object interface descriptor.
An object interface operation.
struct interface * intf
Original interface.
A doubly-linked list entry (or list head)
SCSI "READ CAPACITY (10)" parameter data.
uint32_t lba
Maximum logical block number.
uint32_t blksize
Block length in bytes.
SCSI "READ CAPACITY (16)" parameter data.
uint32_t blksize
Block length in bytes.
uint64_t lba
Maximum logical block number.
A SCSI "READ CAPACITY (10)" CDB.
uint8_t opcode
Opcode (0x25)
A SCSI "READ CAPACITY (16)" CDB.
uint8_t service_action
Service action.
uint8_t opcode
Opcode (0x9e)
uint32_t len
Transfer length.
A SCSI "TEST UNIT READY" CDB.
uint8_t opcode
Opcode (0x00)
A SCSI command information unit.
void(* cmd)(struct scsi_command *scsicmd, struct scsi_cmd *command)
Construct SCSI command IU.
size_t priv_len
Additional working space.
void(* done)(struct scsi_command *scsicmd, int rc)
Handle SCSI command completion.
struct interface block
Block data interface.
struct scsi_device * scsidev
SCSI device.
uint64_t lba
Starting logical block address.
struct list_head list
List of SCSI commands.
struct scsi_command_type * type
Command type.
struct refcnt refcnt
Reference count.
unsigned int count
Number of blocks.
struct interface scsi
SCSI data interface.
size_t len
Length of data buffer.
void * buffer
Data buffer.
uint8_t priv[0]
Private data.
struct interface scsi
SCSI control interface.
struct interface ready
TEST UNIT READY interface.
struct list_head cmds
List of commands.
struct process process
TEST UNIT READY process.
struct scsi_lun lun
SCSI LUN.
struct interface block
Block control interface.
struct refcnt refcnt
Reference count.
unsigned int retries
TEST UNIT READY retry count.
SCSI READ CAPACITY private data.
union scsi_read_capacity_private::@157220360031237207314360002042125031004242325101 capacity
Data buffer for READ CAPACITY commands.
struct scsi_capacity_16 capacity16
Data buffer for READ CAPACITY (16)
int use16
Use READ CAPACITY (16)
struct scsi_capacity_10 capacity10
Data buffer for READ CAPACITY (10)
A SCSI response information unit.
struct scsi_sns_descriptor sense
Autosense data (if any)
uint8_t status
SCSI status code.
ssize_t overrun
Data overrun (or negative underrun)
SCSI descriptor-format sense data.
uint8_t code
Response code.
uint16_t additional
Additional sense code and qualifier.
uint16_t additional
Additional sense code and qualifier.
static struct tlan_private * priv
struct scsi_sns_fixed fixed
Fixed-format sense data.
uint8_t code
Response code.
struct scsi_sns_descriptor desc
Descriptor-format sense data.
size_t xfer_window(struct interface *intf)
Check flow control window.
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Data transfer interfaces.