Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
libiscsi.h File Reference
#include <linux/types.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
#include <linux/kfifo.h>
#include <scsi/iscsi_proto.h>
#include <scsi/iscsi_if.h>
#include <scsi/scsi_transport_iscsi.h>

Go to the source code of this file.

Data Structures

struct  iscsi_r2t_info
 
struct  iscsi_task
 
struct  iscsi_conn
 
struct  iscsi_pool
 
struct  iscsi_session
 
struct  iscsi_host
 

Macros

#define ISCSI_DEF_XMIT_CMDS_MAX   128 /* must be power of 2 */
 
#define ISCSI_MGMT_CMDS_MAX   15
 
#define ISCSI_DEF_CMD_PER_LUN   32
 
#define ISCSI_SUSPEND_BIT   1
 
#define ISCSI_ITT_MASK   0x1fff
 
#define ISCSI_TOTAL_CMDS_MAX   4096
 
#define ISCSI_TOTAL_CMDS_MIN   16
 
#define ISCSI_AGE_SHIFT   28
 
#define ISCSI_AGE_MASK   0xf
 
#define ISCSI_ADDRESS_BUF_LEN   64
 
#define iscsi_host_priv(_shost)   (shost_priv(_shost) + sizeof(struct iscsi_host))
 
#define iscsi_session_printk(prefix, _sess, fmt, a...)   iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a)
 
#define iscsi_conn_printk(prefix, _c, fmt, a...)
 

Enumerations

enum  {
  TMF_INITIAL, TMF_QUEUED, TMF_SUCCESS, TMF_FAILED,
  TMF_TIMEDOUT, TMF_NOT_FOUND
}
 
enum  { ISCSI_MAX_AHS_SIZE, ISCSI_DIGEST_SIZE = sizeof(__u32) }
 
enum  {
  ISCSI_TASK_FREE, ISCSI_TASK_COMPLETED, ISCSI_TASK_PENDING, ISCSI_TASK_RUNNING,
  ISCSI_TASK_ABRT_TMF, ISCSI_TASK_ABRT_SESS_RECOV, ISCSI_TASK_REQUEUE_SCSIQ
}
 
enum  { ISCSI_CONN_INITIAL_STAGE, ISCSI_CONN_STARTED, ISCSI_CONN_STOPPED, ISCSI_CONN_CLEANUP_WAIT }
 
enum  {
  ISCSI_STATE_FREE = 1, ISCSI_STATE_LOGGED_IN, ISCSI_STATE_FAILED, ISCSI_STATE_TERMINATE,
  ISCSI_STATE_IN_RECOVERY, ISCSI_STATE_RECOVERY_FAILED, ISCSI_STATE_LOGGING_OUT
}
 
enum  { ISCSI_HOST_SETUP, ISCSI_HOST_REMOVED }
 

Functions

int iscsi_change_queue_depth (struct scsi_device *sdev, int depth, int reason)
 
int iscsi_eh_abort (struct scsi_cmnd *sc)
 
int iscsi_eh_recover_target (struct scsi_cmnd *sc)
 
int iscsi_eh_session_reset (struct scsi_cmnd *sc)
 
int iscsi_eh_device_reset (struct scsi_cmnd *sc)
 
int iscsi_queuecommand (struct Scsi_Host *host, struct scsi_cmnd *sc)
 
int iscsi_host_set_param (struct Scsi_Host *shost, enum iscsi_host_param param, char *buf, int buflen)
 
int iscsi_host_get_param (struct Scsi_Host *shost, enum iscsi_host_param param, char *buf)
 
int iscsi_host_add (struct Scsi_Host *shost, struct device *pdev)
 
struct Scsi_Hostiscsi_host_alloc (struct scsi_host_template *sht, int dd_data_size, bool xmit_can_sleep)
 
void iscsi_host_remove (struct Scsi_Host *shost)
 
void iscsi_host_free (struct Scsi_Host *shost)
 
int iscsi_target_alloc (struct scsi_target *starget)
 
struct iscsi_cls_sessioniscsi_session_setup (struct iscsi_transport *, struct Scsi_Host *shost, uint16_t, int, int, uint32_t, unsigned int)
 
void iscsi_session_teardown (struct iscsi_cls_session *)
 
void iscsi_session_recovery_timedout (struct iscsi_cls_session *)
 
int iscsi_set_param (struct iscsi_cls_conn *cls_conn, enum iscsi_param param, char *buf, int buflen)
 
int iscsi_session_get_param (struct iscsi_cls_session *cls_session, enum iscsi_param param, char *buf)
 
struct iscsi_cls_conniscsi_conn_setup (struct iscsi_cls_session *, int, uint32_t)
 
void iscsi_conn_teardown (struct iscsi_cls_conn *)
 
int iscsi_conn_start (struct iscsi_cls_conn *)
 
void iscsi_conn_stop (struct iscsi_cls_conn *, int)
 
int iscsi_conn_bind (struct iscsi_cls_session *, struct iscsi_cls_conn *, int)
 
void iscsi_conn_failure (struct iscsi_conn *conn, enum iscsi_err err)
 
void iscsi_session_failure (struct iscsi_session *session, enum iscsi_err err)
 
int iscsi_conn_get_param (struct iscsi_cls_conn *cls_conn, enum iscsi_param param, char *buf)
 
int iscsi_conn_get_addr_param (struct sockaddr_storage *addr, enum iscsi_param param, char *buf)
 
void iscsi_suspend_tx (struct iscsi_conn *conn)
 
void iscsi_suspend_queue (struct iscsi_conn *conn)
 
void iscsi_conn_queue_work (struct iscsi_conn *conn)
 
void iscsi_update_cmdsn (struct iscsi_session *, struct iscsi_nopin *)
 
void iscsi_prep_data_out_pdu (struct iscsi_task *task, struct iscsi_r2t_info *r2t, struct iscsi_data *hdr)
 
int iscsi_conn_send_pdu (struct iscsi_cls_conn *, struct iscsi_hdr *, char *, uint32_t)
 
int iscsi_complete_pdu (struct iscsi_conn *, struct iscsi_hdr *, char *, int)
 
int __iscsi_complete_pdu (struct iscsi_conn *, struct iscsi_hdr *, char *, int)
 
int iscsi_verify_itt (struct iscsi_conn *, itt_t)
 
struct iscsi_taskiscsi_itt_to_ctask (struct iscsi_conn *, itt_t)
 
struct iscsi_taskiscsi_itt_to_task (struct iscsi_conn *, itt_t)
 
void iscsi_requeue_task (struct iscsi_task *task)
 
void iscsi_put_task (struct iscsi_task *task)
 
void __iscsi_put_task (struct iscsi_task *task)
 
void __iscsi_get_task (struct iscsi_task *task)
 
void iscsi_complete_scsi_task (struct iscsi_task *task, uint32_t exp_cmdsn, uint32_t max_cmdsn)
 
void iscsi_pool_free (struct iscsi_pool *)
 
int iscsi_pool_init (struct iscsi_pool *, int, void ***, int)
 

Macro Definition Documentation

#define ISCSI_ADDRESS_BUF_LEN   64

Definition at line 75 of file libiscsi.h.

#define ISCSI_AGE_MASK   0xf

Definition at line 73 of file libiscsi.h.

#define ISCSI_AGE_SHIFT   28

Definition at line 72 of file libiscsi.h.

#define iscsi_conn_printk (   prefix,
  _c,
  fmt,
  a... 
)
Value:
iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
fmt, ##a)

Definition at line 398 of file libiscsi.h.

#define ISCSI_DEF_CMD_PER_LUN   32

Definition at line 53 of file libiscsi.h.

#define ISCSI_DEF_XMIT_CMDS_MAX   128 /* must be power of 2 */

Definition at line 50 of file libiscsi.h.

#define iscsi_host_priv (   _shost)    (shost_priv(_shost) + sizeof(struct iscsi_host))

Definition at line 345 of file libiscsi.h.

#define ISCSI_ITT_MASK   0x1fff

Definition at line 68 of file libiscsi.h.

#define ISCSI_MGMT_CMDS_MAX   15

Definition at line 51 of file libiscsi.h.

#define iscsi_session_printk (   prefix,
  _sess,
  fmt,
  a... 
)    iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a)

Definition at line 374 of file libiscsi.h.

#define ISCSI_SUSPEND_BIT   1

Definition at line 66 of file libiscsi.h.

#define ISCSI_TOTAL_CMDS_MAX   4096

Definition at line 69 of file libiscsi.h.

#define ISCSI_TOTAL_CMDS_MIN   16

Definition at line 71 of file libiscsi.h.

Enumeration Type Documentation

anonymous enum
Enumerator:
TMF_INITIAL 
TMF_QUEUED 
TMF_SUCCESS 
TMF_FAILED 
TMF_TIMEDOUT 
TMF_NOT_FOUND 

Definition at line 56 of file libiscsi.h.

anonymous enum
Enumerator:
ISCSI_MAX_AHS_SIZE 
ISCSI_DIGEST_SIZE 

Definition at line 77 of file libiscsi.h.

anonymous enum
Enumerator:
ISCSI_TASK_FREE 
ISCSI_TASK_COMPLETED 
ISCSI_TASK_PENDING 
ISCSI_TASK_RUNNING 
ISCSI_TASK_ABRT_TMF 
ISCSI_TASK_ABRT_SESS_RECOV 
ISCSI_TASK_REQUEUE_SCSIQ 

Definition at line 85 of file libiscsi.h.

anonymous enum
Enumerator:
ISCSI_CONN_INITIAL_STAGE 
ISCSI_CONN_STARTED 
ISCSI_CONN_STOPPED 
ISCSI_CONN_CLEANUP_WAIT 

Definition at line 152 of file libiscsi.h.

anonymous enum
Enumerator:
ISCSI_STATE_FREE 
ISCSI_STATE_LOGGED_IN 
ISCSI_STATE_FAILED 
ISCSI_STATE_TERMINATE 
ISCSI_STATE_IN_RECOVERY 
ISCSI_STATE_RECOVERY_FAILED 
ISCSI_STATE_LOGGING_OUT 

Definition at line 239 of file libiscsi.h.

anonymous enum
Enumerator:
ISCSI_HOST_SETUP 
ISCSI_HOST_REMOVED 

Definition at line 310 of file libiscsi.h.

Function Documentation

int __iscsi_complete_pdu ( struct iscsi_conn conn,
struct iscsi_hdr hdr,
char data,
int  datalen 
)

__iscsi_complete_pdu - complete pdu : iscsi conn : iscsi header : data buffer : len of data buffer

Completes pdu processing by freeing any resources allocated at queuecommand or send generic. session lock must be held and verify itt must have been called.

Definition at line 1110 of file libiscsi.c.

void __iscsi_get_task ( struct iscsi_task task)

Definition at line 522 of file libiscsi.c.

void __iscsi_put_task ( struct iscsi_task task)

Definition at line 528 of file libiscsi.c.

int iscsi_change_queue_depth ( struct scsi_device sdev,
int  depth,
int  reason 
)

Definition at line 1718 of file libiscsi.c.

int iscsi_complete_pdu ( struct iscsi_conn ,
struct iscsi_hdr ,
char ,
int   
)

Definition at line 1246 of file libiscsi.c.

void iscsi_complete_scsi_task ( struct iscsi_task task,
uint32_t  exp_cmdsn,
uint32_t  max_cmdsn 
)

iscsi_complete_scsi_task - finish scsi task normally : iscsi task for scsi cmd : expected cmd sn in cpu format : max cmd sn in cpu format

This is used when drivers do not need or cannot perform lower level pdu processing.

Called with session lock

Definition at line 591 of file libiscsi.c.

int iscsi_conn_bind ( struct iscsi_cls_session ,
struct iscsi_cls_conn ,
int   
)

Definition at line 3125 of file libiscsi.c.

void iscsi_conn_failure ( struct iscsi_conn conn,
enum iscsi_err  err 
)

Definition at line 1351 of file libiscsi.c.

int iscsi_conn_get_addr_param ( struct sockaddr_storage addr,
enum iscsi_param  param,
char buf 
)

Definition at line 3337 of file libiscsi.c.

int iscsi_conn_get_param ( struct iscsi_cls_conn cls_conn,
enum iscsi_param  param,
char buf 
)

Definition at line 3378 of file libiscsi.c.

void iscsi_conn_queue_work ( struct iscsi_conn conn)
inline

Definition at line 88 of file libiscsi.c.

int iscsi_conn_send_pdu ( struct iscsi_cls_conn ,
struct iscsi_hdr ,
char ,
uint32_t   
)

Definition at line 788 of file libiscsi.c.

struct iscsi_cls_conn* iscsi_conn_setup ( struct iscsi_cls_session cls_session,
int  dd_size,
uint32_t  conn_idx 
)
read

iscsi_conn_setup - create iscsi_cls_conn and iscsi_conn : iscsi_cls_session : private driver data size : cid

Definition at line 2827 of file libiscsi.c.

int iscsi_conn_start ( struct iscsi_cls_conn )

Definition at line 2954 of file libiscsi.c.

void iscsi_conn_stop ( struct iscsi_cls_conn ,
int   
)

Definition at line 3108 of file libiscsi.c.

void iscsi_conn_teardown ( struct iscsi_cls_conn cls_conn)

iscsi_conn_teardown - teardown iscsi connection cls_conn: iscsi class connection

TODO: we may need to make this into a two step process like scsi-mls remove + put host

Definition at line 2896 of file libiscsi.c.

int iscsi_eh_abort ( struct scsi_cmnd sc)

Definition at line 2085 of file libiscsi.c.

int iscsi_eh_device_reset ( struct scsi_cmnd sc)

Definition at line 2225 of file libiscsi.c.

int iscsi_eh_recover_target ( struct scsi_cmnd sc)

iscsi_eh_recover_target - reset target and possibly the session : scsi command

This will attempt to send a warm target reset. If that fails, we will escalate to ERL0 session recovery.

Definition at line 2468 of file libiscsi.c.

int iscsi_eh_session_reset ( struct scsi_cmnd sc)

iscsi_eh_session_reset - drop session and attempt relogin : scsi command

This function will wait for a relogin, session termination from userspace, or a recovery/replacement timeout.

Definition at line 2319 of file libiscsi.c.

int iscsi_host_add ( struct Scsi_Host shost,
struct device pdev 
)

iscsi_host_add - add host to system : scsi host : parent device

This should be called by partial offload and software iscsi drivers to add a host to the system.

Definition at line 2544 of file libiscsi.c.

struct Scsi_Host* iscsi_host_alloc ( struct scsi_host_template sht,
int  dd_data_size,
bool  xmit_can_sleep 
)
read

iscsi_host_alloc - allocate a host and driver data : scsi host template : driver host data size : bool indicating if LLD will queue IO from a work queue

This should be called by partial offload and software iscsi drivers. To access the driver specific memory use the iscsi_host_priv() macro.

Definition at line 2567 of file libiscsi.c.

void iscsi_host_free ( struct Scsi_Host shost)

Definition at line 2631 of file libiscsi.c.

int iscsi_host_get_param ( struct Scsi_Host shost,
enum iscsi_host_param  param,
char buf 
)

Definition at line 3426 of file libiscsi.c.

void iscsi_host_remove ( struct Scsi_Host shost)

iscsi_host_remove - remove host and sessions : scsi host

If there are any sessions left, this will initiate the removal and wait for the completion.

Definition at line 2610 of file libiscsi.c.

int iscsi_host_set_param ( struct Scsi_Host shost,
enum iscsi_host_param  param,
char buf,
int  buflen 
)

Definition at line 3450 of file libiscsi.c.

struct iscsi_task* iscsi_itt_to_ctask ( struct iscsi_conn conn,
itt_t  itt 
)
read

iscsi_itt_to_ctask - look up ctask by itt : iscsi connection : itt

This should be used for cmd tasks.

The session lock must be held.

Definition at line 1299 of file libiscsi.c.

struct iscsi_task* iscsi_itt_to_task ( struct iscsi_conn conn,
itt_t  itt 
)
read

iscsi_itt_to_task - look up task by itt : iscsi connection : itt

This should be used for mgmt tasks like login and nops, or if the LDD's itt space does not include the session age.

The session lock must be held.

Definition at line 1080 of file libiscsi.c.

void iscsi_pool_free ( struct iscsi_pool )

Definition at line 2526 of file libiscsi.c.

int iscsi_pool_init ( struct iscsi_pool ,
int  ,
void ***  ,
int   
)

Definition at line 2486 of file libiscsi.c.

void iscsi_prep_data_out_pdu ( struct iscsi_task task,
struct iscsi_r2t_info r2t,
struct iscsi_data hdr 
)

iscsi_prep_data_out_pdu - initialize Data-Out : scsi command task : R2T info : iscsi data in pdu

Notes: Initialize Data-Out within this R2T sequence and finds proper data_offset within this SCSI command.

This function is called with connection lock taken.

Definition at line 144 of file libiscsi.c.

void iscsi_put_task ( struct iscsi_task task)

Definition at line 535 of file libiscsi.c.

int iscsi_queuecommand ( struct Scsi_Host host,
struct scsi_cmnd sc 
)

Definition at line 1588 of file libiscsi.c.

void iscsi_requeue_task ( struct iscsi_task task)

iscsi_requeue_task - requeue task to run from session workqueue : task to requeue

LLDs that need to run a task from the session workqueue should call this. The session lock must be held. This should only be called by software drivers.

Definition at line 1417 of file libiscsi.c.

void iscsi_session_failure ( struct iscsi_session session,
enum iscsi_err  err 
)

Definition at line 1321 of file libiscsi.c.

int iscsi_session_get_param ( struct iscsi_cls_session cls_session,
enum iscsi_param  param,
char buf 
)

Definition at line 3259 of file libiscsi.c.

void iscsi_session_recovery_timedout ( struct iscsi_cls_session )

Definition at line 2298 of file libiscsi.c.

struct iscsi_cls_session* iscsi_session_setup ( struct iscsi_transport iscsit,
struct Scsi_Host shost,
uint16_t  cmds_max,
int  dd_size,
int  cmd_task_size,
uint32_t  initial_cmdsn,
unsigned int  id 
)
read

iscsi_session_setup - create iscsi cls session and host and session : iscsi transport template : scsi host : session can queue : LLD task private data size : initial CmdSN

This can be used by software iscsi_transports that allocate a session per scsi host.

Callers should set cmds_max to the largest total numer (mgmt + scsi) of tasks they support. The iscsi layer reserves ISCSI_MGMT_CMDS_MAX tasks for nop handling and login/logout requests.

Definition at line 2679 of file libiscsi.c.

void iscsi_session_teardown ( struct iscsi_cls_session cls_session)

iscsi_session_teardown - destroy session, host, and cls_session : iscsi session

The driver must have called iscsi_remove_session before calling this.

Definition at line 2797 of file libiscsi.c.

int iscsi_set_param ( struct iscsi_cls_conn cls_conn,
enum iscsi_param  param,
char buf,
int  buflen 
)

Definition at line 3163 of file libiscsi.c.

void iscsi_suspend_queue ( struct iscsi_conn conn)

iscsi_suspend_queue - suspend iscsi_queuecommand : iscsi conn to stop queueing IO on

This grabs the session lock to make sure no one is in xmit_task/queuecommand, and then sets suspend to prevent new commands from being queued. This only needs to be called by offload drivers that need to sync a path like ep disconnect with the iscsi_queuecommand/xmit_task. To start IO again libiscsi will call iscsi_start_tx and iscsi_unblock_session when in FFP.

Definition at line 1848 of file libiscsi.c.

void iscsi_suspend_tx ( struct iscsi_conn conn)

iscsi_suspend_tx - suspend iscsi_data_xmit : iscsi conn tp stop processing IO on.

This function sets the suspend bit to prevent iscsi_data_xmit from sending new IO, and if work is queued on the xmit thread it will wait for it to be completed.

Definition at line 1864 of file libiscsi.c.

int iscsi_target_alloc ( struct scsi_target starget)

Definition at line 1737 of file libiscsi.c.

void iscsi_update_cmdsn ( struct iscsi_session ,
struct iscsi_nopin  
)

Definition at line 125 of file libiscsi.c.

int iscsi_verify_itt ( struct iscsi_conn ,
itt_t   
)

Definition at line 1258 of file libiscsi.c.