56 #define SAN_COMMAND_TIMEOUT ( 15 * TICKS_PER_SEC ) 66 #define SAN_DEFAULT_RETRIES 10 76 #define SAN_REOPEN_DELAY_SECS 5 129 for ( i = 0 ; i < sandev->
paths ; i++ ) {
206 DBGC ( sandev->
drive,
"SAN %#02x.%d could not (re)open URI: " 253 if ( sanpath == sandev->
active ) {
274 DBGC ( sandev->
drive,
"SAN %#02x.%d closed: %s\n",
304 if ( sanpath == sandev->
active )
316 DBGC ( sandev->
drive,
"SAN %#02x.%d is active\n",
320 DBGC ( sandev->
drive,
"SAN %#02x.%d is available\n",
513 unsigned int retries = 0;
603 unsigned int remaining;
615 while ( remaining ) {
618 if ( params.
rw.
count > remaining )
709 if ( (
rc =
desc->model->complete (
desc ) ) != 0 ) {
710 DBGC ( sandev->
drive,
"SAN %#02x.%d could not " 711 "be described: %s\n", sandev->
drive,
723 if ( (
rc =
desc->model->complete (
desc ) ) != 0 )
743 if ( sanpath->
desc ) {
774 unsigned int blksize_shift;
789 goto invalid_blksize;
792 count = ( 1 << blksize_shift );
804 DBGC ( sandev->
drive,
"SAN %#02x could not read ISO9660 " 805 "primary volume descriptor: %s\n",
811 if (
memcmp ( &scratch->primary.fixed, &primary_check,
812 sizeof ( primary_check ) ) == 0 ) {
813 DBGC ( sandev->
drive,
"SAN %#02x contains an ISO9660 " 814 "filesystem; treating as CD-ROM\n", sandev->
drive );
853 for ( i = 0 ; i <
count ; i++ ) {
878 unsigned int flags ) {
953 DBGC ( sandev->
drive,
"SAN %#02x unregistered\n", sandev->
drive );
960 .description =
"SAN drive number",
962 .type = &setting_type_uint8,
984 .
name =
"san-retries",
985 .description =
"SAN retry count",
987 .type = &setting_type_int8,
An ISO9660 Primary Volume Descriptor.
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.
An object interface operation.
#define ECONNRESET
Connection reset.
int sandev_reset(struct san_device *sandev)
Reset SAN device.
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 int sandev_command_read_capacity(struct san_device *sandev, const union san_command_params *params __unused)
Initiate SAN device read capacity command.
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
static void sandev_command_capacity(struct san_device *sandev, struct block_device_capacity *capacity)
Record SAN device capacity.
Dynamic Host Configuration Protocol.
#define SETTING_SANBOOT_EXTRA
SAN boot additional settings.
unsigned int max_count
Maximum number of blocks per single transfer.
static void uri_put(struct uri *uri)
Decrement URI reference count.
SAN device command parameters.
static struct interface_descriptor sandev_command_desc
SAN device command interface descriptor.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
#define DHCP_EB_SAN_RETRY
SAN retry count.
struct san_path path[0]
SAN paths.
static struct interface_operation sanpath_block_op[]
SAN path block interface operations.
static void sandev_free(struct refcnt *refcnt)
Free SAN device.
struct list_head list
List of open/closed paths.
#define DHCP_EB_SAN_DRIVE
SAN drive number.
#define ref_init(refcnt, free)
Initialise a reference counter.
static int sandev_rw(struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer, int(*block_rw)(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len))
Read from or write to SAN device.
int command_rc
Command status.
LIST_HEAD(san_devices)
List of SAN devices.
void block_capacity(struct interface *intf, struct block_device_capacity *capacity)
Report block device capacity.
struct ib_cm_path primary
Primary path.
int xfer_open_uri(struct interface *intf, struct uri *uri)
Open URI.
void unregister_sandev(struct san_device *sandev)
Unregister SAN device.
#define EADDRINUSE
Address already in use.
uint64_t desc
Microcode descriptor list physical address.
struct interface block
Underlying block device interface.
int32_t before
Initial microcode version.
#define ISO9660_ID
ISO9660 identifier.
unsigned long long uint64_t
unsigned int san_default_drive(void)
Get default SAN drive number.
struct list_head san_devices
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 int sandev_needs_reopen(struct san_device *sandev)
Check if SAN device needs to be reopened.
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.
struct settings_applicator sandev_applicator __settings_applicator
Settings applicator.
uint8_t drive
Drive number.
struct list_head opened
List of opened SAN paths.
void process_del(struct process *process)
Remove process from process list.
size_t xfer_window(struct interface *intf)
Check flow control window.
void intfs_restart(int rc,...)
Shut down and restart multiple object interfaces.
unsigned int index
Path index.
struct interface command
Command interface.
Data transfer interfaces.
void acpi_del(struct acpi_descriptor *desc)
Remove ACPI descriptor.
#define list_empty(list)
Test whether a list is empty.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
#define ISO9660_TYPE_PRIMARY
ISO9660 Primary Volume Descriptor type.
static void sandev_undescribe(struct san_device *sandev)
Remove SAN device descriptors.
struct san_command_rw_params rw
Read/write command parameters.
#define list_del(list)
Delete an entry from a list.
#define ENOMEM
Not enough space.
userptr_t userptr_add(userptr_t userptr, off_t offset)
Add offset to user pointer.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint32_t userptr_t
A pointer to a user buffer.
#define __unused
Declare a variable or data structure as unused.
#define SAN_REOPEN_DELAY_SECS
Delay between reopening attempts.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
void quiesce(void)
Quiesce system.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
An ISO9660 Primary Volume Descriptor (fixed portion)
struct list_head list
List of ACPI descriptors for this model.
unsigned int drive
Drive number.
int register_sandev(struct san_device *sandev, unsigned int drive, unsigned int flags)
Register SAN device.
uint16_t count
Number of entries.
static int sandev_describe(struct san_device *sandev)
Describe SAN device.
unsigned int blksize_shift
Block size shift.
ISO9660 CD-ROM specification.
userptr_t buffer
Data buffer.
static struct interface_descriptor sanpath_block_desc
SAN path block interface descriptor.
#define EINPROGRESS
Operation in progress.
void process_add(struct process *process)
Add process to process list.
#define ENOTCONN
The socket is not connected.
static void sanpath_block_close(struct san_path *sanpath, int rc)
Handle closure of underlying block device interface.
An object interface descriptor.
char * strerror(int errno)
Retrieve string representation of error number.
struct list_head closed
List of closed SAN paths.
static void(* free)(struct refcnt *refcnt))
int is_cdrom
Drive is a CD-ROM.
void * zalloc(size_t size)
Allocate cleared memory.
static size_t sanpath_block_window(struct san_path *sanpath __unused)
Check flow control window.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
int sandev_read(struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer)
Read from SAN device.
struct list_head list
List of SAN devices.
#define ENODEV
No such device.
SAN device read/write command parameters.
uint64_t lba
Starting block number.
Data transfer interface opening.
Device should not be included in description tables.
#define for_each_sandev(sandev)
Iterate over all SAN devices.
int fetch_uint_setting(struct settings *settings, const struct setting *setting, unsigned long *value)
Fetch value of unsigned integer setting.
struct san_device * sandev_next(unsigned int drive)
Find next SAN device by drive number.
static void process_init_stopped(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process without adding to process list.
struct acpi_descriptor * acpi_describe(struct interface *intf)
Get object's ACPI descriptor.
void * malloc(size_t size)
Allocate memory.
unsigned int paths
Number of paths.
static void sandev_command_expired(struct retry_timer *timer, int over __unused)
Handle SAN device command timeout.
static int sandev_parse_iso9660(struct san_device *sandev)
Configure SAN device as a CD-ROM, if applicable.
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
static unsigned long san_retries
Number of times to retry commands.
#define SAN_COMMAND_TIMEOUT
Timeout for block device commands (in ticks)
unsigned int count
Block count.
struct uri * uri
SAN device URI.
struct block_device_capacity capacity
Raw block device capacity.
uint8_t type
Descriptor type.
static void sanpath_close(struct san_path *sanpath, int rc)
Close SAN path.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
An ACPI descriptor (used to construct ACPI tables)
void stop_timer(struct retry_timer *timer)
Stop timer.
const struct setting san_drive_setting __setting(SETTING_SANBOOT_EXTRA, san-drive)
The "san-drive" setting.
struct process process
Process.
static int sandev_command(struct san_device *sandev, int(*command)(struct san_device *sandev, const union san_command_params *params), const union san_command_params *params)
Execute a single SAN device command and wait for completion.
struct refcnt refcnt
Reference count.
struct san_device * sandev_find(unsigned int drive)
Find SAN device by drive number.
uint8_t block[3][8]
DES-encrypted blocks.
int(* block_rw)(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len)
SAN device read/write operation.
void * priv
Driver private data.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static struct interface_operation sandev_command_op[]
SAN device command interface operations.
void step(void)
Single-step a single process.
static struct process_descriptor sanpath_process_desc
SAN path process descriptor.
#define ISO9660_BLKSIZE
ISO9660 block size.
uint64_t lba
Starting LBA.
void sleep_fixed(unsigned int secs)
Sleep (uninterruptibly) for a fixed number of seconds.
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
uint8_t size
Entry size (in 32-bit words)
uint8_t data[48]
Additional event data.
static void sandev_restart(struct san_device *sandev, int rc)
Restart SAN device interface.
int(* apply)(void)
Apply updated settings.
#define ISO9660_PRIMARY_LBA
ISO9660 Primary Volume Descriptor block address.
A Uniform Resource Identifier.
static void sandev_command_close(struct san_device *sandev, int rc)
Close SAN device command.
uint32_t blksize
Cipher block size.
struct san_path * active
Current active path.
#define SAN_DEFAULT_DRIVE
Default SAN drive number.
#define SAN_DEFAULT_RETRIES
Default number of times to retry commands.
int block_read_capacity(struct interface *control, struct interface *data)
Read block device capacity.
struct retry_timer timer
Command timeout timer.
static int sandev_command_rw(struct san_device *sandev, const union san_command_params *params)
Initiate SAN device read/write command.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
static int sandev_apply(void)
Apply SAN boot settings.
#define list_check_contains_entry(entry, head, member)
Check list contains a specified entry.
static int sanpath_open(struct san_path *sanpath)
Open SAN path.
void unquiesce(void)
Unquiesce system.
struct acpi_descriptor * desc
ACPI descriptor (if applicable)
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
void acpi_add(struct acpi_descriptor *desc)
Add ACPI descriptor.
int sandev_reopen(struct san_device *sandev)
(Re)open SAN device
#define NULL
NULL pointer (VOID *)
int sandev_write(struct san_device *sandev, uint64_t lba, unsigned int count, userptr_t buffer)
Write to SAN device.
#define ETIMEDOUT
Connection timed out.
struct san_device * sandev
Containing SAN device.
static void sanpath_step(struct san_path *sanpath)
SAN path process.
struct san_device * alloc_sandev(struct uri **uris, unsigned int count, size_t priv_size)
Allocate SAN device.
size_t blksize
Block size.