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