|
| #define | SCSI_READY_MAX_RETRIES 10 |
| | Maximum number of TEST UNIT READY retries.
|
| #define | EIO_NO_SENSE __einfo_error ( EINFO_EIO_NO_SENSE ) |
| #define | EINFO_EIO_NO_SENSE __einfo_uniqify ( EINFO_EIO, 0x00, "No sense" ) |
| #define | EIO_RECOVERED_ERROR __einfo_error ( EINFO_EIO_RECOVERED_ERROR ) |
| #define | EINFO_EIO_RECOVERED_ERROR __einfo_uniqify ( EINFO_EIO, 0x01, "Recovered error" ) |
| #define | EIO_NOT_READY __einfo_error ( EINFO_EIO_NOT_READY ) |
| #define | EINFO_EIO_NOT_READY __einfo_uniqify ( EINFO_EIO, 0x02, "Not ready" ) |
| #define | EIO_MEDIUM_ERROR __einfo_error ( EINFO_EIO_MEDIUM_ERROR ) |
| #define | EINFO_EIO_MEDIUM_ERROR __einfo_uniqify ( EINFO_EIO, 0x03, "Medium error" ) |
| #define | EIO_HARDWARE_ERROR __einfo_error ( EINFO_EIO_HARDWARE_ERROR ) |
| #define | EINFO_EIO_HARDWARE_ERROR __einfo_uniqify ( EINFO_EIO, 0x04, "Hardware error" ) |
| #define | EIO_ILLEGAL_REQUEST __einfo_error ( EINFO_EIO_ILLEGAL_REQUEST ) |
| #define | EINFO_EIO_ILLEGAL_REQUEST __einfo_uniqify ( EINFO_EIO, 0x05, "Illegal request" ) |
| #define | EIO_UNIT_ATTENTION __einfo_error ( EINFO_EIO_UNIT_ATTENTION ) |
| #define | EINFO_EIO_UNIT_ATTENTION __einfo_uniqify ( EINFO_EIO, 0x06, "Unit attention" ) |
| #define | EIO_DATA_PROTECT __einfo_error ( EINFO_EIO_DATA_PROTECT ) |
| #define | EINFO_EIO_DATA_PROTECT __einfo_uniqify ( EINFO_EIO, 0x07, "Data protect" ) |
| #define | EIO_BLANK_CHECK __einfo_error ( EINFO_EIO_BLANK_CHECK ) |
| #define | EINFO_EIO_BLANK_CHECK __einfo_uniqify ( EINFO_EIO, 0x08, "Blank check" ) |
| #define | EIO_VENDOR_SPECIFIC __einfo_error ( EINFO_EIO_VENDOR_SPECIFIC ) |
| #define | EINFO_EIO_VENDOR_SPECIFIC __einfo_uniqify ( EINFO_EIO, 0x09, "Vendor specific" ) |
| #define | EIO_COPY_ABORTED __einfo_error ( EINFO_EIO_COPY_ABORTED ) |
| #define | EINFO_EIO_COPY_ABORTED __einfo_uniqify ( EINFO_EIO, 0x0a, "Copy aborted" ) |
| #define | EIO_ABORTED_COMMAND __einfo_error ( EINFO_EIO_ABORTED_COMMAND ) |
| #define | EINFO_EIO_ABORTED_COMMAND __einfo_uniqify ( EINFO_EIO, 0x0b, "Aborted command" ) |
| #define | EIO_RESERVED __einfo_error ( EINFO_EIO_RESERVED ) |
| #define | EINFO_EIO_RESERVED __einfo_uniqify ( EINFO_EIO, 0x0c, "Reserved" ) |
| #define | EIO_VOLUME_OVERFLOW __einfo_error ( EINFO_EIO_VOLUME_OVERFLOW ) |
| #define | EINFO_EIO_VOLUME_OVERFLOW __einfo_uniqify ( EINFO_EIO, 0x0d, "Volume overflow" ) |
| #define | EIO_MISCOMPARE __einfo_error ( EINFO_EIO_MISCOMPARE ) |
| #define | EINFO_EIO_MISCOMPARE __einfo_uniqify ( EINFO_EIO, 0x0e, "Miscompare" ) |
| #define | EIO_COMPLETED __einfo_error ( EINFO_EIO_COMPLETED ) |
| #define | EINFO_EIO_COMPLETED __einfo_uniqify ( EINFO_EIO, 0x0f, "Completed" ) |
| #define | EIO_SENSE(key) |
|
| | FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
| | FILE_SECBOOT (PERMITTED) |
| int | scsi_parse_lun (const char *lun_string, struct scsi_lun *lun) |
| | Parse SCSI LUN.
|
| void | scsi_parse_sense (const void *data, size_t len, struct scsi_sns_descriptor *sense) |
| | Parse SCSI sense data.
|
| int | scsi_command (struct interface *control, struct interface *data, struct scsi_cmd *command) |
| | Issue SCSI command.
|
| void | scsi_response (struct interface *intf, struct scsi_rsp *response) |
| | Report SCSI response.
|
| static struct scsi_device * | scsidev_get (struct scsi_device *scsidev) |
| | Get reference to SCSI device.
|
| static void | scsidev_put (struct scsi_device *scsidev) |
| | Drop reference to SCSI device.
|
| static struct scsi_command * | scsicmd_get (struct scsi_command *scsicmd) |
| | Get reference to SCSI command.
|
| static void | scsicmd_put (struct scsi_command *scsicmd) |
| | Drop reference to SCSI command.
|
| static void * | scsicmd_priv (struct scsi_command *scsicmd) |
| | Get SCSI command private data.
|
| static void | scsicmd_free (struct refcnt *refcnt) |
| | Free SCSI command.
|
| static void | scsicmd_close (struct scsi_command *scsicmd, int rc) |
| | Close SCSI command.
|
| static int | scsicmd_command (struct scsi_command *scsicmd) |
| | Construct and issue SCSI command.
|
| static void | scsicmd_done (struct scsi_command *scsicmd, int rc) |
| | Handle SCSI command completion.
|
| static void | scsicmd_response (struct scsi_command *scsicmd, struct scsi_rsp *response) |
| | Handle SCSI response.
|
| static void | scsicmd_read_cmd (struct scsi_command *scsicmd, struct scsi_cmd *command) |
| | Construct SCSI READ command.
|
| static void | scsicmd_write_cmd (struct scsi_command *scsicmd, struct scsi_cmd *command) |
| | Construct SCSI WRITE command.
|
| static void | scsicmd_read_capacity_cmd (struct scsi_command *scsicmd, struct scsi_cmd *command) |
| | Construct SCSI READ CAPACITY command.
|
| static void | scsicmd_read_capacity_done (struct scsi_command *scsicmd, int rc) |
| | Handle SCSI READ CAPACITY command completion.
|
| static void | scsicmd_test_unit_ready_cmd (struct scsi_command *scsicmd __unused, struct scsi_cmd *command) |
| | Construct SCSI TEST UNIT READY command.
|
| 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 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 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.
|
| static int | scsidev_read_capacity (struct scsi_device *scsidev, struct interface *block) |
| | Read SCSI device capacity.
|
| static int | scsidev_test_unit_ready (struct scsi_device *scsidev, struct interface *block) |
| | Test to see if SCSI device is ready.
|
| static size_t | scsidev_window (struct scsi_device *scsidev) |
| | Check SCSI device flow-control window.
|
| static void | scsidev_close (struct scsi_device *scsidev, int rc) |
| | Close SCSI device.
|
| static void | scsidev_ready (struct scsi_device *scsidev, int rc) |
| | Handle SCSI TEST UNIT READY response.
|
| static void | scsidev_step (struct scsi_device *scsidev) |
| | SCSI TEST UNIT READY process.
|
| int | scsi_open (struct interface *block, struct interface *scsi, struct scsi_lun *lun) |
| | Open SCSI device.
|
SCSI block device.
Definition in file scsi.c.
| void scsicmd_close |
( |
struct scsi_command * | scsicmd, |
|
|
int | rc ) |
|
static |
Close SCSI command.
- Parameters
-
| scsicmd | SCSI command |
| rc | Reason for close |
Definition at line 393 of file scsi.c.
393 {
395
397 DBGC ( scsidev,
"SCSI %p tag %08x closed: %s\n",
399 }
400
401
403
404
406
407
409}
#define NULL
NULL pointer (VOID *)
struct arbelprm_rc_send_wqe rc
void intfs_shutdown(int rc,...)
Shut down multiple object interfaces.
#define list_del(list)
Delete an entry from a list.
static void scsicmd_put(struct scsi_command *scsicmd)
Drop reference to SCSI command.
char * strerror(int errno)
Retrieve string representation of error number.
struct interface block
Block data interface.
struct list_head list
List of SCSI commands.
struct interface scsi
SCSI data interface.
References scsi_command::block, DBGC, intfs_shutdown(), scsi_command::list, list_del, NULL, rc, scsi_command::scsi, scsicmd_put(), scsi_command::scsidev, strerror(), and scsi_command::tag.
Referenced by scsicmd_read_capacity_done(), scsidev_close(), and scsidev_command().
Construct and issue SCSI command.
- Return values
-
Definition at line 416 of file scsi.c.
416 {
421
422
426
427
431 DBGC ( scsidev,
"SCSI %p could not issue command: %s\n",
434 }
435
436
437 if ( scsicmd->
tag ) {
438 DBGC ( scsidev,
"SCSI %p tag %08x is now tag %08x\n",
439 scsidev, scsicmd->
tag,
tag );
440 }
445
446 return 0;
447}
uint64_t tag
Identity tag.
#define SCSI_CDB_DATA(cdb)
printf() parameters for dumping a scsi_cdb
#define SCSI_CDB_FORMAT
printf() format for dumping a scsi_cdb
A SCSI command information unit.
void(* cmd)(struct scsi_command *scsicmd, struct scsi_cmd *command)
Construct SCSI command IU.
struct scsi_command_type * type
Command type.
struct interface scsi
SCSI control interface.
struct scsi_lun lun
SCSI LUN.
References scsi_command_type::cmd, DBGC, DBGC2, scsi_device::lun, memcpy(), memset(), scsi_command_type::name, rc, scsi_command::scsi, scsi_device::scsi, SCSI_CDB_DATA, SCSI_CDB_FORMAT, scsi_command::scsidev, strerror(), scsi_command::tag, tag, and scsi_command::type.
Referenced by scsicmd_read_capacity_done(), and scsidev_command().
| void scsicmd_read_capacity_done |
( |
struct scsi_command * | scsicmd, |
|
|
int | rc ) |
|
static |
Handle SCSI READ CAPACITY command completion.
- Parameters
-
| scsicmd | SCSI command |
| rc | Reason for completion |
Definition at line 611 of file scsi.c.
612 {
618
619
622 return;
623 }
624
625
629 } else {
632
633
634
635
636
637
638
639 if ( capacity.blocks == 0 ) {
643 return;
644 }
645 return;
646 }
647 }
649
650
652
653
655
656
658}
void block_capacity(struct interface *intf, struct block_device_capacity *capacity)
Report block device capacity.
#define be32_to_cpu(value)
#define be64_to_cpu(value)
static int scsicmd_command(struct scsi_command *scsicmd)
Construct and issue SCSI command.
static void scsicmd_close(struct scsi_command *scsicmd, int rc)
Close SCSI command.
unsigned int max_count
Maximum number of blocks per single transfer.
uint32_t lba
Maximum logical block number.
uint32_t blksize
Block length in bytes.
uint32_t blksize
Block length in bytes.
uint64_t lba
Maximum logical block number.
References be32_to_cpu, be64_to_cpu, block_device_capacity::blksize, scsi_capacity_10::blksize, scsi_capacity_16::blksize, scsi_command::block, block_capacity(), block_device_capacity::blocks, scsi_capacity_10::lba, scsi_capacity_16::lba, block_device_capacity::max_count, priv, rc, scsi_device::scsi, scsicmd_close(), scsicmd_command(), scsicmd_priv(), and scsi_command::scsidev.
Create SCSI command.
- Parameters
-
| scsidev | SCSI device |
| block | Block data interface |
| type | SCSI command type |
| lba | Starting logical block address |
| count | Number of blocks to transfer |
| buffer | Data buffer |
| len | Length of data buffer |
- Return values
-
Definition at line 721 of file scsi.c.
725 {
728
729
730 scsicmd =
zalloc (
sizeof ( *scsicmd ) +
type->priv_len );
731 if ( ! scsicmd ) {
733 goto err_zalloc;
734 }
746
747
749 goto err_command;
750
751
753 return 0;
754
755 err_command:
758 err_zalloc:
760}
uint32_t type
Operating system type.
static unsigned int count
Number of entries.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
uint64_t lba
Starting block number.
#define ENOMEM
Not enough space.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
#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.
#define ref_init(refcnt, free)
Initialise a reference counter.
static struct scsi_device * scsidev_get(struct scsi_device *scsidev)
Get reference to SCSI device.
static struct interface_descriptor scsicmd_scsi_desc
SCSI command SCSI interface descriptor.
static struct interface_descriptor scsicmd_block_desc
SCSI command block interface descriptor.
static void scsicmd_free(struct refcnt *refcnt)
Free SCSI command.
struct list_head cmds
List of commands.
References block, scsi_command::block, buffer, scsi_command::buffer, scsi_device::cmds, count, scsi_command::count, ENOMEM, intf_init(), intf_plug_plug(), lba, scsi_command::lba, len, scsi_command::len, scsi_command::list, list_add, rc, ref_init, ref_put, scsi_command::refcnt, scsi_command::scsi, scsicmd_block_desc, scsicmd_close(), scsicmd_command(), scsicmd_free(), scsicmd_scsi_desc, scsi_command::scsidev, scsidev_get(), scsi_command::type, type, and zalloc().
Referenced by scsidev_read(), scsidev_read_capacity(), scsidev_test_unit_ready(), and scsidev_write().
| void scsidev_ready |
( |
struct scsi_device * | scsidev, |
|
|
int | rc ) |
|
static |
Handle SCSI TEST UNIT READY response.
- Parameters
-
| scsidev | SCSI device |
| rc | Reason for close |
Definition at line 885 of file scsi.c.
885 {
886
887
889
890
892 DBGC ( scsidev,
"SCSI %p unit is ready\n", scsidev );
895 return;
896 }
897 DBGC ( scsidev,
"SCSI %p not ready: %s\n", scsidev,
strerror (
rc ) );
898
899
900
901
902
903
904
905
906
907
908
909
911 DBGC ( scsidev,
"SCSI %p retrying (retry %d)\n",
915 return;
916 }
917
918
919 DBGC ( scsidev,
"SCSI %p never became ready: %s\n",
922}
void process_add(struct process *process)
Add process to process list.
#define SCSI_READY_MAX_RETRIES
Maximum number of TEST UNIT READY retries.
static void scsidev_close(struct scsi_device *scsidev, int rc)
Close SCSI device.
unsigned int retries
TEST UNIT READY retry count.
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
References scsi_device::block, DBGC, scsi_device::flags, intf_restart(), scsi_device::process, process_add(), rc, scsi_device::ready, scsi_device::retries, SCSI_READY_MAX_RETRIES, scsidev_close(), SCSIDEV_UNIT_READY, SCSIDEV_UNIT_TESTED, strerror(), and xfer_window_changed().
Open SCSI device.
- Parameters
-
| block | Block control interface |
| scsi | SCSI control interface |
| lun | SCSI LUN |
- Return values
-
Definition at line 985 of file scsi.c.
986 {
988
989
990 scsidev =
zalloc (
sizeof ( *scsidev ) );
991 if ( ! scsidev )
1003
1004
1008 return 0;
1009}
#define INIT_LIST_HEAD(list)
Initialise a list head.
static void process_init(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process and add to process list.
static struct interface_descriptor scsidev_ready_desc
SCSI device TEST UNIT READY interface descriptor.
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 struct process_descriptor scsidev_process_desc
SCSI device process descriptor.
#define SCSI_LUN_FORMAT
printf() format for dumping a scsi_lun
#define SCSI_LUN_DATA(lun)
printf() parameters for dumping a scsi_lun
References block, scsi_device::block, scsi_device::cmds, DBGC, ENOMEM, INIT_LIST_HEAD, intf_init(), intf_plug_plug(), lun, scsi_device::lun, memcpy(), NULL, scsi_device::process, process_init(), scsi_device::ready, ref_init, ref_put, scsi_device::refcnt, scsi_device::scsi, SCSI_LUN_DATA, SCSI_LUN_FORMAT, scsidev_block_desc, scsidev_process_desc, scsidev_ready_desc, scsidev_scsi_desc, and zalloc().
Referenced by fcpdev_open(), iscsi_open(), srp_open(), and usbblk_open_uri().