SCSI to bdev translation layer. More...
Data Structures | |
struct | spdk_scsi_task |
Macros | |
#define | SPDK_SCSI_MAX_DEVS 1024 |
#define | SPDK_SCSI_DEV_MAX_PORTS 4 |
#define | SPDK_SCSI_DEV_MAX_NAME 255 |
#define | SPDK_SCSI_PORT_MAX_NAME_LENGTH 255 |
#define | SPDK_SCSI_MAX_TRANSPORT_ID_LENGTH 255 |
Typedefs | |
typedef void(* | spdk_scsi_task_cpl) (struct spdk_scsi_task *task) |
typedef void(* | spdk_scsi_task_free) (struct spdk_scsi_task *task) |
typedef void(* | spdk_scsi_lun_remove_cb_t) (struct spdk_scsi_lun *, void *) |
typedef void(* | spdk_scsi_dev_destruct_cb_t) (void *cb_arg, int rc) |
Functions | |
int | spdk_scsi_init (void) |
Initialize SCSI layer. | |
void | spdk_scsi_fini (void) |
Stop and clean the SCSI layer. | |
int | spdk_scsi_lun_get_id (const struct spdk_scsi_lun *lun) |
Get the LUN id of the given logical unit. | |
const char * | spdk_scsi_lun_get_bdev_name (const struct spdk_scsi_lun *lun) |
Get the name of the bdev associated with the given logical unit. | |
const struct spdk_scsi_dev * | spdk_scsi_lun_get_dev (const struct spdk_scsi_lun *lun) |
Get the SCSI device associated with the given logical unit. | |
bool | spdk_scsi_lun_is_removing (const struct spdk_scsi_lun *lun) |
Check if the logical unit is hot removing. | |
const char * | spdk_scsi_dev_get_name (const struct spdk_scsi_dev *dev) |
Get the name of the given SCSI device. | |
int | spdk_scsi_dev_get_id (const struct spdk_scsi_dev *dev) |
Get the id of the given SCSI device. | |
struct spdk_scsi_lun * | spdk_scsi_dev_get_lun (struct spdk_scsi_dev *dev, int lun_id) |
Get the logical unit of the given SCSI device whose id is lun_id. | |
struct spdk_scsi_lun * | spdk_scsi_dev_get_first_lun (struct spdk_scsi_dev *dev) |
Get the first logical unit of the given SCSI device. | |
struct spdk_scsi_lun * | spdk_scsi_dev_get_next_lun (struct spdk_scsi_lun *prev_lun) |
Get the next logical unit of a SCSI device. | |
bool | spdk_scsi_dev_has_pending_tasks (const struct spdk_scsi_dev *dev, const struct spdk_scsi_port *initiator_port) |
Check whether the SCSI device has any pending task. | |
void | spdk_scsi_dev_destruct (struct spdk_scsi_dev *dev, spdk_scsi_dev_destruct_cb_t cb_fn, void *cb_arg) |
Destruct the SCSI device. | |
void | spdk_scsi_dev_queue_mgmt_task (struct spdk_scsi_dev *dev, struct spdk_scsi_task *task) |
Execute the SCSI management task. | |
void | spdk_scsi_dev_queue_task (struct spdk_scsi_dev *dev, struct spdk_scsi_task *task) |
Execute the SCSI task. | |
int | spdk_scsi_dev_add_port (struct spdk_scsi_dev *dev, uint64_t id, const char *name) |
Add a new port to the given SCSI device. | |
int | spdk_scsi_dev_delete_port (struct spdk_scsi_dev *dev, uint64_t id) |
Delete a specified port of the given SCSI device. | |
struct spdk_scsi_port * | spdk_scsi_dev_find_port_by_id (struct spdk_scsi_dev *dev, uint64_t id) |
Get the port of the given SCSI device whose port ID is id. | |
int | spdk_scsi_dev_allocate_io_channels (struct spdk_scsi_dev *dev) |
Allocate I/O channels for all LUNs of the given SCSI device. | |
void | spdk_scsi_dev_free_io_channels (struct spdk_scsi_dev *dev) |
Free I/O channels from all LUNs of the given SCSI device. | |
struct spdk_scsi_dev * | spdk_scsi_dev_construct (const char *name, const char *bdev_name_list[], int *lun_id_list, int num_luns, uint8_t protocol_id, void(*hotremove_cb)(const struct spdk_scsi_lun *, void *), void *hotremove_ctx) |
Construct a SCSI device object using the given parameters. | |
struct spdk_scsi_dev * | spdk_scsi_dev_construct_ext (const char *name, const char *bdev_name_list[], int *lun_id_list, int num_luns, uint8_t protocol_id, void(*resize_cb)(const struct spdk_scsi_lun *, void *), void *resize_ctx, void(*hotremove_cb)(const struct spdk_scsi_lun *, void *), void *hotremove_ctx) |
Construct a SCSI device object using the more given parameters. | |
void | spdk_scsi_dev_delete_lun (struct spdk_scsi_dev *dev, struct spdk_scsi_lun *lun) |
Delete a logical unit of the given SCSI device. | |
int | spdk_scsi_dev_add_lun (struct spdk_scsi_dev *dev, const char *bdev_name, int lun_id, void(*hotremove_cb)(const struct spdk_scsi_lun *, void *), void *hotremove_ctx) |
Add a new logical unit to the given SCSI device. | |
int | spdk_scsi_dev_add_lun_ext (struct spdk_scsi_dev *dev, const char *bdev_name, int lun_id, void(*resize_cb)(const struct spdk_scsi_lun *, void *), void *resize_ctx, void(*hotremove_cb)(const struct spdk_scsi_lun *, void *), void *hotremove_ctx) |
Add a new logical unit to the given SCSI device with more callbacks. | |
struct spdk_scsi_port * | spdk_scsi_port_create (uint64_t id, uint16_t index, const char *name) |
Create a new SCSI port. | |
void | spdk_scsi_port_free (struct spdk_scsi_port **pport) |
Free the SCSI port. | |
const char * | spdk_scsi_port_get_name (const struct spdk_scsi_port *port) |
Get the name of the SCSI port. | |
void | spdk_scsi_task_construct (struct spdk_scsi_task *task, spdk_scsi_task_cpl cpl_fn, spdk_scsi_task_free free_fn) |
Construct a new SCSI task. | |
void | spdk_scsi_task_put (struct spdk_scsi_task *task) |
Put the SCSI task. | |
void | spdk_scsi_task_set_data (struct spdk_scsi_task *task, void *data, uint32_t len) |
Set internal buffer to given one. | |
int | spdk_scsi_task_scatter_data (struct spdk_scsi_task *task, const void *src, size_t len) |
Single buffer -> vector of buffers. | |
void * | spdk_scsi_task_gather_data (struct spdk_scsi_task *task, int *len) |
Vector of buffers -> single buffer. | |
void | spdk_scsi_task_build_sense_data (struct spdk_scsi_task *task, int sk, int asc, int ascq) |
Build sense data for the SCSI task. | |
void | spdk_scsi_task_set_status (struct spdk_scsi_task *task, int sc, int sk, int asc, int ascq) |
Set SCSI status code to the SCSI task. | |
void | spdk_scsi_task_copy_status (struct spdk_scsi_task *dst, struct spdk_scsi_task *src) |
Copy SCSI status. | |
void | spdk_scsi_task_process_null_lun (struct spdk_scsi_task *task) |
Process the SCSI task when no LUN is attached. | |
void | spdk_scsi_task_process_abort (struct spdk_scsi_task *task) |
Process the aborted SCSI task. | |
int | spdk_scsi_lun_open (struct spdk_scsi_lun *lun, spdk_scsi_lun_remove_cb_t hotremove_cb, void *hotremove_ctx, struct spdk_scsi_lun_desc **desc) |
Open a logical unit for I/O operations. | |
void | spdk_scsi_lun_close (struct spdk_scsi_lun_desc *desc) |
Close an opened logical unit. | |
int | spdk_scsi_lun_allocate_io_channel (struct spdk_scsi_lun_desc *desc) |
Allocate I/O channel for the LUN. | |
void | spdk_scsi_lun_free_io_channel (struct spdk_scsi_lun_desc *desc) |
Free I/O channel from the logical unit. | |
bool | spdk_scsi_lun_get_dif_ctx (struct spdk_scsi_lun *lun, struct spdk_scsi_task *task, struct spdk_dif_ctx *dif_ctx) |
Get DIF context for SCSI LUN and SCSI command. | |
void | spdk_scsi_port_set_iscsi_transport_id (struct spdk_scsi_port *port, char *iscsi_name, uint64_t isid) |
Set iSCSI Initiator port TransportID. | |
uint64_t | spdk_scsi_lun_id_int_to_fmt (int lun_id) |
Convert LUN ID from integer to LUN format. | |
int | spdk_scsi_lun_id_fmt_to_int (uint64_t fmt_lun) |
Convert LUN ID from LUN format to integer. | |
const char * | spdk_scsi_sbc_opcode_string (uint8_t opcode, uint16_t sa) |
Translate SCSI operation code and service action into string. | |
SCSI to bdev translation layer.
int spdk_scsi_dev_add_lun | ( | struct spdk_scsi_dev * | dev, |
const char * | bdev_name, | ||
int | lun_id, | ||
void(* | hotremove_cb )(const struct spdk_scsi_lun *, void *), | ||
void * | hotremove_ctx ) |
Add a new logical unit to the given SCSI device.
dev | SCSI device. |
bdev_name | Name of the bdev attached to the logical unit. |
lun_id | LUN id for the new logical unit. |
hotremove_cb | Callback to lun hotremoval. Will be called once hotremove is first triggered. |
hotremove_ctx | Additional argument to hotremove_cb. |
int spdk_scsi_dev_add_lun_ext | ( | struct spdk_scsi_dev * | dev, |
const char * | bdev_name, | ||
int | lun_id, | ||
void(* | resize_cb )(const struct spdk_scsi_lun *, void *), | ||
void * | resize_ctx, | ||
void(* | hotremove_cb )(const struct spdk_scsi_lun *, void *), | ||
void * | hotremove_ctx ) |
Add a new logical unit to the given SCSI device with more callbacks.
dev | SCSI device. |
bdev_name | Name of the bdev attached to the logical unit. |
lun_id | LUN id for the new logical unit. |
resize_cb | Callback of lun resize. |
resize_ctx | Additional argument to resize_cb. |
hotremove_cb | Callback to lun hotremoval. Will be called once hotremove is first triggered. |
hotremove_ctx | Additional argument to hotremove_cb. |
int spdk_scsi_dev_add_port | ( | struct spdk_scsi_dev * | dev, |
uint64_t | id, | ||
const char * | name ) |
Add a new port to the given SCSI device.
dev | SCSI device. |
id | Port id. |
name | Port name. |
int spdk_scsi_dev_allocate_io_channels | ( | struct spdk_scsi_dev * | dev | ) |
Allocate I/O channels for all LUNs of the given SCSI device.
dev | SCSI device. |
struct spdk_scsi_dev * spdk_scsi_dev_construct | ( | const char * | name, |
const char * | bdev_name_list[], | ||
int * | lun_id_list, | ||
int | num_luns, | ||
uint8_t | protocol_id, | ||
void(* | hotremove_cb )(const struct spdk_scsi_lun *, void *), | ||
void * | hotremove_ctx ) |
Construct a SCSI device object using the given parameters.
name | Name for the SCSI device. |
bdev_name_list | List of bdev names to attach to the LUNs for this SCSI device. |
lun_id_list | List of LUN IDs for the LUN in this SCSI device. Caller is responsible for managing the memory containing this list. lun_id_list[x] is the LUN ID for lun_list[x]. |
num_luns | Number of entries in lun_list and lun_id_list. |
protocol_id | SCSI SPC protocol identifier to report in INQUIRY data |
hotremove_cb | Callback to lun hotremoval. Will be called once hotremove is first triggered. |
hotremove_ctx | Additional argument to hotremove_cb. |
struct spdk_scsi_dev * spdk_scsi_dev_construct_ext | ( | const char * | name, |
const char * | bdev_name_list[], | ||
int * | lun_id_list, | ||
int | num_luns, | ||
uint8_t | protocol_id, | ||
void(* | resize_cb )(const struct spdk_scsi_lun *, void *), | ||
void * | resize_ctx, | ||
void(* | hotremove_cb )(const struct spdk_scsi_lun *, void *), | ||
void * | hotremove_ctx ) |
Construct a SCSI device object using the more given parameters.
name | Name for the SCSI device. |
bdev_name_list | List of bdev names to attach to the LUNs for this SCSI device. |
lun_id_list | List of LUN IDs for the LUN in this SCSI device. Caller is responsible for managing the memory containing this list. lun_id_list[x] is the LUN ID for lun_list[x]. |
num_luns | Number of entries in lun_list and lun_id_list. |
protocol_id | SCSI SPC protocol identifier to report in INQUIRY data |
resize_cb | Callback of lun resize. |
resize_ctx | Additional argument to resize_cb. |
hotremove_cb | Callback to lun hotremoval. Will be called once hotremove is first triggered. |
hotremove_ctx | Additional argument to hotremove_cb. |
void spdk_scsi_dev_delete_lun | ( | struct spdk_scsi_dev * | dev, |
struct spdk_scsi_lun * | lun ) |
Delete a logical unit of the given SCSI device.
dev | SCSI device. |
lun | Logical unit to delete. |
int spdk_scsi_dev_delete_port | ( | struct spdk_scsi_dev * | dev, |
uint64_t | id ) |
Delete a specified port of the given SCSI device.
dev | SCSI device. |
id | Port id. |
void spdk_scsi_dev_destruct | ( | struct spdk_scsi_dev * | dev, |
spdk_scsi_dev_destruct_cb_t | cb_fn, | ||
void * | cb_arg ) |
Destruct the SCSI device.
dev | SCSI device. |
cb_fn | Callback function. |
cb_arg | Argument to callback function. |
struct spdk_scsi_port * spdk_scsi_dev_find_port_by_id | ( | struct spdk_scsi_dev * | dev, |
uint64_t | id ) |
Get the port of the given SCSI device whose port ID is id.
dev | SCSI device. |
id | Port id. |
struct spdk_scsi_lun * spdk_scsi_dev_get_first_lun | ( | struct spdk_scsi_dev * | dev | ) |
Get the first logical unit of the given SCSI device.
dev | SCSI device. |
int spdk_scsi_dev_get_id | ( | const struct spdk_scsi_dev * | dev | ) |
Get the id of the given SCSI device.
dev | SCSI device. |
struct spdk_scsi_lun * spdk_scsi_dev_get_lun | ( | struct spdk_scsi_dev * | dev, |
int | lun_id ) |
Get the logical unit of the given SCSI device whose id is lun_id.
dev | SCSI device. |
lun_id | Id of the logical unit. |
const char * spdk_scsi_dev_get_name | ( | const struct spdk_scsi_dev * | dev | ) |
Get the name of the given SCSI device.
dev | SCSI device. |
struct spdk_scsi_lun * spdk_scsi_dev_get_next_lun | ( | struct spdk_scsi_lun * | prev_lun | ) |
Get the next logical unit of a SCSI device.
prev_lun | Previous logical unit. |
bool spdk_scsi_dev_has_pending_tasks | ( | const struct spdk_scsi_dev * | dev, |
const struct spdk_scsi_port * | initiator_port ) |
Check whether the SCSI device has any pending task.
dev | SCSI device. |
initiator_port | Check tasks only from the initiator if specified, or all all tasks otherwise. |
void spdk_scsi_dev_queue_mgmt_task | ( | struct spdk_scsi_dev * | dev, |
struct spdk_scsi_task * | task ) |
Execute the SCSI management task.
The task can be constructed by the function spdk_scsi_task_construct(). Code of task management function to be executed is set before calling this API.
dev | SCSI device. |
task | SCSI task to be executed. |
void spdk_scsi_dev_queue_task | ( | struct spdk_scsi_dev * | dev, |
struct spdk_scsi_task * | task ) |
Execute the SCSI task.
The task can be constructed by the function spdk_scsi_task_construct().
dev | SCSI device. |
task | Task to be executed. |
int spdk_scsi_init | ( | void | ) |
Initialize SCSI layer.
int spdk_scsi_lun_allocate_io_channel | ( | struct spdk_scsi_lun_desc * | desc | ) |
Allocate I/O channel for the LUN.
desc | Descriptor of the logical unit. |
void spdk_scsi_lun_close | ( | struct spdk_scsi_lun_desc * | desc | ) |
Close an opened logical unit.
desc | Descriptor of the logical unit. |
void spdk_scsi_lun_free_io_channel | ( | struct spdk_scsi_lun_desc * | desc | ) |
Free I/O channel from the logical unit.
desc | Descriptor of the logical unit. |
const char * spdk_scsi_lun_get_bdev_name | ( | const struct spdk_scsi_lun * | lun | ) |
Get the name of the bdev associated with the given logical unit.
lun | Logical unit. |
const struct spdk_scsi_dev * spdk_scsi_lun_get_dev | ( | const struct spdk_scsi_lun * | lun | ) |
Get the SCSI device associated with the given logical unit.
lun | Logical unit. |
bool spdk_scsi_lun_get_dif_ctx | ( | struct spdk_scsi_lun * | lun, |
struct spdk_scsi_task * | task, | ||
struct spdk_dif_ctx * | dif_ctx ) |
Get DIF context for SCSI LUN and SCSI command.
lun | Logical unit. |
task | SCSI task which has the payload. |
dif_ctx | Output parameter which will contain initialized DIF context. |
int spdk_scsi_lun_get_id | ( | const struct spdk_scsi_lun * | lun | ) |
Get the LUN id of the given logical unit.
lun | Logical unit. |
int spdk_scsi_lun_id_fmt_to_int | ( | uint64_t | fmt_lun | ) |
Convert LUN ID from LUN format to integer.
fmt_lun | LUN format of LUN ID |
uint64_t spdk_scsi_lun_id_int_to_fmt | ( | int | lun_id | ) |
Convert LUN ID from integer to LUN format.
lun_id | Integer LUN ID |
bool spdk_scsi_lun_is_removing | ( | const struct spdk_scsi_lun * | lun | ) |
Check if the logical unit is hot removing.
lun | Logical unit |
int spdk_scsi_lun_open | ( | struct spdk_scsi_lun * | lun, |
spdk_scsi_lun_remove_cb_t | hotremove_cb, | ||
void * | hotremove_ctx, | ||
struct spdk_scsi_lun_desc ** | desc ) |
Open a logical unit for I/O operations.
The registered callback function must get all tasks from the upper layer (e.g. iSCSI) to the LUN done, free the IO channel of the LUN if allocated, and then close the LUN.
lun | Logical unit to open. |
hotremove_cb | Callback function for hot removal of the logical unit. |
hotremove_ctx | Param for hot removal callback function. |
desc | Output parameter for the descriptor when operation is successful. |
struct spdk_scsi_port * spdk_scsi_port_create | ( | uint64_t | id, |
uint16_t | index, | ||
const char * | name ) |
Create a new SCSI port.
id | Port id. |
index | Port index. |
name | Port Name. |
void spdk_scsi_port_free | ( | struct spdk_scsi_port ** | pport | ) |
Free the SCSI port.
pport | SCSI port to free. |
const char * spdk_scsi_port_get_name | ( | const struct spdk_scsi_port * | port | ) |
Get the name of the SCSI port.
port | SCSI port to query. |
void spdk_scsi_port_set_iscsi_transport_id | ( | struct spdk_scsi_port * | port, |
char * | iscsi_name, | ||
uint64_t | isid ) |
Set iSCSI Initiator port TransportID.
port | SCSI initiator port. |
iscsi_name | Initiator name. |
isid | Session ID. |
const char * spdk_scsi_sbc_opcode_string | ( | uint8_t | opcode, |
uint16_t | sa ) |
Translate SCSI operation code and service action into string.
opcode | SCSI operation code |
sa | SCSI service action code |
void spdk_scsi_task_build_sense_data | ( | struct spdk_scsi_task * | task, |
int | sk, | ||
int | asc, | ||
int | ascq ) |
Build sense data for the SCSI task.
task | SCSI task. |
sk | Sense key. |
asc | Additional sense code. |
ascq | Additional sense code qualifier. |
void spdk_scsi_task_construct | ( | struct spdk_scsi_task * | task, |
spdk_scsi_task_cpl | cpl_fn, | ||
spdk_scsi_task_free | free_fn ) |
Construct a new SCSI task.
task | SCSI task to construct. |
cpl_fn | Called when the task is completed. |
free_fn | Called when the task is freed |
void spdk_scsi_task_copy_status | ( | struct spdk_scsi_task * | dst, |
struct spdk_scsi_task * | src ) |
Copy SCSI status.
dst | SCSI task whose status is written to. |
src | SCSI task whose status is read from. |
void * spdk_scsi_task_gather_data | ( | struct spdk_scsi_task * | task, |
int * | len ) |
Vector of buffers -> single buffer.
task | SCSI task, |
len | Length of the buffer allocated and written into. |
void spdk_scsi_task_process_abort | ( | struct spdk_scsi_task * | task | ) |
Process the aborted SCSI task.
task | SCSI task. |
void spdk_scsi_task_process_null_lun | ( | struct spdk_scsi_task * | task | ) |
Process the SCSI task when no LUN is attached.
task | SCSI task. |
void spdk_scsi_task_put | ( | struct spdk_scsi_task * | task | ) |
Put the SCSI task.
task | SCSI task to put. |
int spdk_scsi_task_scatter_data | ( | struct spdk_scsi_task * | task, |
const void * | src, | ||
size_t | len ) |
Single buffer -> vector of buffers.
task | SCSI task. |
src | A pointer to the data buffer read from. |
len | Length of the data buffer read from. |
void spdk_scsi_task_set_data | ( | struct spdk_scsi_task * | task, |
void * | data, | ||
uint32_t | len ) |
Set internal buffer to given one.
Caller is owner of that buffer.
task | SCSI task. |
data | Pointer to buffer. |
len | Buffer length. |
void spdk_scsi_task_set_status | ( | struct spdk_scsi_task * | task, |
int | sc, | ||
int | sk, | ||
int | asc, | ||
int | ascq ) |
Set SCSI status code to the SCSI task.
When the status code is CHECK CONDITION, sense data is build too.
task | SCSI task. |
sc | Sense code |
sk | Sense key. |
asc | Additional sense code. |
ascq | Additional sense code qualifier. |