Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_scsi.c File Reference
#include "ocs.h"
#include "ocs_iscsi_spec.h"
#include "ocs_vpd.h"
#include "sli4_iscsi.h"
#include "ocs_login.h"
#include "ocs_dif.h"

Go to the source code of this file.

Detailed Description

OCS Linux SCSI API base driver implementation

Definition in file ocs_scsi.c.

Macros

#define OCS_EXPORT(...)
 

Functions

static int32_t ocs_scsi_build_sgls (ocs_hal_t *hal, ocs_io_t *io, ocs_hal_dif_info_t *hal_dif, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, ocs_hal_io_type_e type)
 Build the SGLs for the IO. More...
 
static int32_t ocs_scsi_convert_dif_info (ocs_t *ocs, ocs_scsi_dif_info_t *scsi_dif_info, ocs_hal_dif_info_t *hal_dif_info)
 Convert SCSI API T10 DIF information into the FC HAL format. More...
 
static int32_t ocs_scsi_check_pending (ocs_t *ocs)
 Check for pending IOs to dispatch. More...
 
static int32_t ocs_scsi_io_dispatch_hal_io (ocs_io_t *io, ocs_hal_io_t *hio, uint8_t lock_held)
 Dispatch IO. More...
 
static void ocs_target_nop_check (ocs_cxn_t *cxn)
 This function sends a target nop. More...
 
static void ocs_target_io_aborted (ocs_io_t *io, ocs_cxn_t *cxn)
 This function is called when an IO is aborted. More...
 
void ocs_target_io_aborted_nop_cmpl (ocs_cxn_t *cxn)
 This function is called whenever a target NOP completes. More...
 
static int32_t ocs_target_io_cb (struct ocs_hal_io_s *hio, ocs_cxn_t *cxn, int32_t status, ocs_ini_cmpl_fields_t *ini_fields, void *ul_arg)
 This function is the callback for a target IO. More...
 
static void ocs_log_sgl (ocs_io_t *io)
 This function logs the SGLs for an IO. More...
 
static int32_t ocs_scsi_check_pending_async_cb (ocs_hal_t *hal, int32_t status, void *arg)
 Check pending error asynchronous callback function/. More...
 
static void ocs_scsi_io_add_to_pending (ocs_t *ocs, ocs_io_t *io, uint8_t lock_held)
 Place an IO on the pending list to retry later when resources are available. More...
 
int32_t ocs_scsi_io_dispatch (ocs_io_t *io, void *cb)
 Attempt to dispatch an IO. More...
 
void ocs_scsi_pending_cleanup (ocs_node_t *node)
 Clean up any IOs on the pending list when a connection goes down. More...
 
int32_t ocs_scsi_send_rd_data (ocs_io_t *io, uint32_t flags, ocs_scsi_dif_info_t *dif_info, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint64_t wire_len, ocs_scsi_io_cb_t cb, void *arg)
 Send read data. More...
 
int32_t ocs_scsi_recv_wr_data (ocs_io_t *io, uint32_t flags, ocs_scsi_dif_info_t *dif_info, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint64_t wire_len, ocs_scsi_io_cb_t cb, void *arg)
 Prepare to receive write data. More...
 
int32_t ocs_scsi_send_resp (ocs_io_t *io, uint32_t flags, ocs_scsi_cmd_resp_t *rsp, ocs_scsi_io_cb_t cb, void *arg)
 Send response data. More...
 
int32_t ocs_scsi_tgt_abort_io (ocs_io_t *io, bool send_abts, ocs_scsi_io_cb_t cb, void *arg)
 Abort a target IO. More...
 
int32_t ocs_scsi_send_tmf_resp (ocs_io_t *io, ocs_scsi_tmf_resp_e rspcode, uint8_t *addl_rsp_info, ocs_scsi_io_cb_t cb, void *arg)
 Send TMF response data. More...
 
int32_t ocs_iscsi_send_tmf_resp (ocs_io_t *io, uint8_t response, ocs_scsi_io_cb_t cb, void *arg)
 send TMF response data More...
 
static int32_t ocs_initiator_io_cb (struct ocs_hal_io_s *hio, ocs_cxn_t *cxn, int32_t status, ocs_ini_cmpl_fields_t *ini_fields, void *ul_arg)
 This function is the callback for a initiator IO. More...
 
static int32_t ocs_initiator_io_tm_cb (struct ocs_hal_io_s *hio, ocs_cxn_t *cxn, int32_t status, ocs_ini_cmpl_fields_t *ini_fields, void *ul_arg)
 This function is the callback for a initiator TM IO. More...
 
static uint64_t ocs_scsi_convert_lun (ocs_t *ocs, uint32_t lun)
 Sends an initiator command to the chip. More...
 
static int32_t ocs_scsi_send_ini_io (ocs_node_t *node, ocs_io_t *io, ocs_hal_io_type_e io_type, uint32_t lun, void *cdb, uint32_t cdb_len, ocs_scsi_dif_info_t *dif_info, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint32_t wire_len, ocs_scsi_rsp_io_cb_t cb, void *arg)
 Sends an initiator command to the chip. More...
 
int32_t ocs_scsi_send_rd_io (ocs_node_t *node, ocs_io_t *io, uint32_t lun, void *cdb, uint32_t cdb_len, ocs_scsi_dif_info_t *dif_info, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint32_t len, ocs_scsi_rsp_io_cb_t cb, void *arg)
 Initiate initiator read IO. More...
 
int32_t ocs_scsi_send_nodata_io (ocs_node_t *node, ocs_io_t *io, uint32_t lun, void *cdb, uint32_t cdb_len, ocs_scsi_rsp_io_cb_t cb, void *arg)
 Initiate initiator SCSI command with no data. More...
 
int32_t ocs_scsi_send_wr_io (ocs_node_t *node, ocs_io_t *io, uint32_t lun, void *cdb, uint32_t cdb_len, ocs_scsi_dif_info_t *dif_info, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint32_t len, ocs_scsi_rsp_io_cb_t cb, void *arg)
 Initiate initiator write IO. More...
 
int32_t ocs_scsi_send_wr_io_first_burst (ocs_node_t *node, ocs_io_t *io, uint32_t lun, void *cdb, uint32_t cdb_len, ocs_scsi_dif_info_t *dif_info, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint32_t wire_len, uint32_t first_burst, ocs_scsi_rsp_io_cb_t cb, void *arg)
 
static int32_t ocs_scsi_send_tmf_internal (ocs_node_t *node, ocs_io_t *io, ocs_io_t *ref_io, uint32_t lun, ocs_scsi_tmf_cmd_e tmf, ocs_scsi_rsp_io_cb_t cb, void *arg)
 Sends a task management command on an initiator (internal). More...
 
int32_t ocs_scsi_send_tmf (ocs_node_t *node, ocs_io_t *io, ocs_io_t *io_to_abort, uint32_t lun, ocs_scsi_tmf_cmd_e tmf, ocs_scsi_sgl_t *sgl, uint32_t sgl_count, uint32_t len, ocs_scsi_rsp_io_cb_t cb, void *arg)
 initiate initiator task management operation More...
 
void ocs_scsi_io_complete (ocs_io_t *io)
 Notify base that IO is complete. More...
 
uint32_t ocs_scsi_get_property (ocs_t *ocs, ocs_scsi_property_e prop)
 Return SCSI API integer valued property. More...
 
void * ocs_scsi_get_property_ptr (ocs_t *ocs, ocs_scsi_property_e prop)
 return a property pointer. More...
 
ocs_io_t * ocs_scsi_io_alloc (ocs_node_t *node, ocs_scsi_io_role_e role)
 allocate a SCSI IO context. More...
 
void ocs_scsi_io_free (ocs_io_t *io)
 Free a SCSI IO context. More...
 
void ocs_scsi_update_first_burst_transferred (ocs_io_t *io, uint32_t transferred)
 Update transferred count. More...
 
void ocs_scsi_register_bounce (ocs_t *ocs, void(*fctn)(void(*fctn)(void *arg), void *arg, uint32_t s_id, uint32_t d_id, uint32_t ox_id))
 Register bounce callback for multi-threading. More...
 
int ocs_scsi_abort_io (ocs_hal_t *hal, ocs_hal_io_t *hio, ocs_hal_abort_type_e abort_type)
 
bool ocs_scsi_check_cxn_wq_full (ocs_t *ocs, ocs_cxn_t *cxn)
 Check Connection WQ's full status. More...
 
 OCS_EXPORT (ocs_scsi_io_alloc)
 
 OCS_EXPORT (ocs_scsi_io_free)
 
 OCS_EXPORT (ocs_scsi_send_rd_data)
 
 OCS_EXPORT (ocs_scsi_recv_wr_data)
 
 OCS_EXPORT (ocs_scsi_send_resp)
 
 OCS_EXPORT (ocs_scsi_send_tmf_resp)
 
 OCS_EXPORT (ocs_scsi_tgt_abort_io)
 
 OCS_EXPORT (ocs_scsi_io_complete)
 
 OCS_EXPORT (ocs_scsi_get_property)
 
 OCS_EXPORT (ocs_scsi_get_property_ptr)
 
 OCS_EXPORT (ocs_scsi_send_rd_io)
 
 OCS_EXPORT (ocs_scsi_send_wr_io)
 
 OCS_EXPORT (ocs_scsi_send_tmf)
 
 OCS_EXPORT (ocs_scsi_send_nodata_io)
 
 OCS_EXPORT (ocs_scsi_abort_io)
 
 OCS_EXPORT (ocs_scsi_check_cxn_wq_full)
 

Macro Details

#define OCS_EXPORT (   ...)

Definition at line 2387 of file ocs_scsi.c.

Function Details

OCS_EXPORT ( ocs_scsi_io_alloc  )
OCS_EXPORT ( ocs_scsi_io_free  )
OCS_EXPORT ( ocs_scsi_send_rd_data  )
OCS_EXPORT ( ocs_scsi_recv_wr_data  )
OCS_EXPORT ( ocs_scsi_send_resp  )
OCS_EXPORT ( ocs_scsi_send_tmf_resp  )
OCS_EXPORT ( ocs_scsi_tgt_abort_io  )
OCS_EXPORT ( ocs_scsi_io_complete  )
OCS_EXPORT ( ocs_scsi_get_property  )
OCS_EXPORT ( ocs_scsi_get_property_ptr  )
OCS_EXPORT ( ocs_scsi_send_rd_io  )
OCS_EXPORT ( ocs_scsi_send_wr_io  )
OCS_EXPORT ( ocs_scsi_send_tmf  )
OCS_EXPORT ( ocs_scsi_send_nodata_io  )
OCS_EXPORT ( ocs_scsi_abort_io  )
OCS_EXPORT ( ocs_scsi_check_cxn_wq_full  )
static int32_t ocs_initiator_io_cb ( struct ocs_hal_io_s *  hio,
ocs_cxn_t *  cxn,
int32_t  status,
ocs_ini_cmpl_fields_t *  ini_fields,
void *  ul_arg 
)
static

This function is the callback for a initiator IO.

Parameters
hioPointer to the HAL io object.
cxnPointer to the connection object.
statusStatus of the command
ini_fieldsPointer to the initiator completion fields
ul_argPoints to the io object

Definition at line 1380 of file ocs_scsi.c.

static int32_t ocs_initiator_io_tm_cb ( struct ocs_hal_io_s *  hio,
ocs_cxn_t *  cxn,
int32_t  status,
ocs_ini_cmpl_fields_t *  ini_fields,
void *  ul_arg 
)
static

This function is the callback for a initiator TM IO.

Parameters
hioPointer to the io object.
cxnPointer to the connection object.
statusStatus of the command.
ini_fieldsPointer to the initiator completion fields.
ul_argPoints to the io object.

Definition at line 1477 of file ocs_scsi.c.

static void ocs_log_sgl ( ocs_io_t *  io)
static

This function logs the SGLs for an IO.

Parameters
ioPointer to IO context.

Definition at line 270 of file ocs_scsi.c.

int ocs_scsi_abort_io ( ocs_hal_t *  hal,
ocs_hal_io_t *  hio,
ocs_hal_abort_type_e  abort_type 
)

Definition at line 2342 of file ocs_scsi.c.

static int32_t ocs_scsi_build_sgls ( ocs_hal_t *  hal,
ocs_io_t *  io,
ocs_hal_dif_info_t *  hal_dif,
ocs_scsi_sgl_t *  sgl,
uint32_t  sgl_count,
ocs_hal_io_type_e  type 
)
static

Build the SGLs for the IO.

Parameters
halPointer to HAL object.
ioPointer to IO context.
sglPointer to payload scatter-gather list.
sgl_countCount of scatter-gather list elements.
typeIO type.
hal_difPointer to the HAL DIF structure.
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 633 of file ocs_scsi.c.

bool ocs_scsi_check_cxn_wq_full ( ocs_t *  ocs,
ocs_cxn_t *  cxn 
)

Check Connection WQ's full status.

Parameters
ocsPointer to OCS object
cxnPointer to connection object
Returns
true if connection WQ is full, otherwise false

Definition at line 2374 of file ocs_scsi.c.

static int32_t ocs_scsi_check_pending ( ocs_t *  ocs)
static

Check for pending IOs to dispatch.

Description
If there are IOs on the pending list, and a HAL IO is available, then dispatch the IOs.
Parameters
ocsPointer to the OCS structure.
Returns
Returns 0 for success, or -1 if no IO could be dispatched.

Definition at line 346 of file ocs_scsi.c.

static int32_t ocs_scsi_check_pending_async_cb ( ocs_hal_t *  hal,
int32_t  status,
void *  arg 
)
static

Check pending error asynchronous callback function/.

Description
Invoke the HAL callback function for a given IO. This function is called from the NOP mailbox completion context.
Parameters
halPointer to HAL object.
statusCompletion status.
argGeneral purpose argument.
Returns
Returns 0.

Definition at line 318 of file ocs_scsi.c.

static uint64_t ocs_scsi_convert_lun ( ocs_t *  ocs,
uint32_t  lun 
)
static

Sends an initiator command to the chip.

Parameters
lun32-bit LUN for this IO.
ocsPointer to the ocs structure.

Definition at line 1521 of file ocs_scsi.c.

static void ocs_scsi_io_add_to_pending ( ocs_t *  ocs,
ocs_io_t *  io,
uint8_t  lock_held 
)
static

Place an IO on the pending list to retry later when resources are available.

Parameters
ocsPointer to the ocs structure.
ioPointer to the IO structure.
lock_heldinform this function if the ocs lock is already held

Definition at line 444 of file ocs_scsi.c.

int32_t ocs_scsi_io_dispatch ( ocs_io_t *  io,
void *  cb 
)

Attempt to dispatch an IO.

Description
An IO is dispatched. The steps are as follows:
  1. Try to allocate a HAL IO. If none is available, place this IO at the tail of the pending IO list.
  2. With a HAL IO in hand, if there are IOs on the pending IO list, push this IO on the tail of the pending list and pop the head of the pending list.
  3. Attach this IO to the HAL IO and submit it.
Parameters
ioPointer to IO structure.
cbCallback function.
Returns
Returns 0 for success, or a negative error code value for failure.

Definition at line 475 of file ocs_scsi.c.

static int32_t ocs_scsi_io_dispatch_hal_io ( ocs_io_t *  io,
ocs_hal_io_t *  hio,
uint8_t  lock_held 
)
static

Dispatch IO.

Description
An IO and its associated HAL IO is dispatched to the HAL.
Parameters
ioPointer to IO structure.
hioPointer to HAL IO structure from which IO will be dispatched.
lock_heldinform this function if the ocs lock is already held
Returns
Returns 0 on success, a negative error code value on failure.

Definition at line 554 of file ocs_scsi.c.

void ocs_scsi_pending_cleanup ( ocs_node_t *  node)

Clean up any IOs on the pending list when a connection goes down.

Parameters
nodePointer to node structure.

Definition at line 598 of file ocs_scsi.c.

void ocs_scsi_register_bounce ( ocs_t *  ocs,
void(*)(void(*fctn)(void *arg), void *arg, uint32_t s_id, uint32_t d_id, uint32_t ox_id)  fctn 
)

Register bounce callback for multi-threading.

Description
Register the back end bounce function.
Parameters
ocsPointer to device object.
fctnFunction pointer of bounce function.
Returns
None.

Definition at line 2331 of file ocs_scsi.c.

static int32_t ocs_scsi_send_ini_io ( ocs_node_t *  node,
ocs_io_t *  io,
ocs_hal_io_type_e  io_type,
uint32_t  lun,
void *  cdb,
uint32_t  cdb_len,
ocs_scsi_dif_info_t *  dif_info,
ocs_scsi_sgl_t *  sgl,
uint32_t  sgl_count,
uint32_t  wire_len,
ocs_scsi_rsp_io_cb_t  cb,
void *  arg 
)
static

Sends an initiator command to the chip.

Parameters
nodePointer to the node object.
ioPointer to the io object.
io_typeHAL io type for this initiator command.
lun32-bit LUN for this IO.
cdbPointer to the SCSI CDB.
cdb_lenLength of the SCSI CDB in bytes.
dif_infoPointer to a T10 PI (DIF) information structure.
sglPointer to the SGL list for this IO.
sgl_countNumber of SGLs for the IO.
wire_lenNumber of bytes being transferred for this IO.
cbCallback function to call upon completion.
argArgument to call the callback function.

Definition at line 1562 of file ocs_scsi.c.

static int32_t ocs_scsi_send_tmf_internal ( ocs_node_t *  node,
ocs_io_t *  io,
ocs_io_t *  ref_io,
uint32_t  lun,
ocs_scsi_tmf_cmd_e  tmf,
ocs_scsi_rsp_io_cb_t  cb,
void *  arg 
)
static

Sends a task management command on an initiator (internal).

Parameters
nodePointer to the node object.
ioPointer to the io object.
ref_ioPointer to the referenced io object (for abort task).
lun32-bit LUN for this IO.
tmfDefines the type of TM request.
cbCallback function to call upon completion.
argArgument to call the callback function.

Definition at line 1793 of file ocs_scsi.c.

int32_t ocs_scsi_send_wr_io_first_burst ( ocs_node_t *  node,
ocs_io_t *  io,
uint32_t  lun,
void *  cdb,
uint32_t  cdb_len,
ocs_scsi_dif_info_t *  dif_info,
ocs_scsi_sgl_t *  sgl,
uint32_t  sgl_count,
uint32_t  wire_len,
uint32_t  first_burst,
ocs_scsi_rsp_io_cb_t  cb,
void *  arg 
)

Definition at line 1771 of file ocs_scsi.c.

void ocs_scsi_update_first_burst_transferred ( ocs_io_t *  io,
uint32_t  transferred 
)

Update transferred count.

Description
Updates io->transferred, as required when using first burst, when the amount of first burst data processed differs from the amount of first burst data received.
Parameters
ioPointer to the io object.
transferredNumber of bytes transferred out of first burst buffers.
Returns
None.

Definition at line 2313 of file ocs_scsi.c.

static void ocs_target_io_aborted ( ocs_io_t *  io,
ocs_cxn_t *  cxn 
)
static

This function is called when an IO is aborted.

Description
We need to hold the IO until we receive a TCP ACK for a packet sent after this IO to ensure that the IO is available to be re-used. Hold this IO in the iSCSI transport to prevent it being re-used.
Parameters
ioPointer to the io object.
cxnPointer to the connection object.

Definition at line 99 of file ocs_scsi.c.

void ocs_target_io_aborted_nop_cmpl ( ocs_cxn_t *  cxn)

This function is called whenever a target NOP completes.

Description
Once a TCP ACK is received, the NOP request completes. We can now free any aborted IOs and they are also TCP ACKed.
Parameters
cxnPointer to the connection object.

Definition at line 120 of file ocs_scsi.c.

static int32_t ocs_target_io_cb ( struct ocs_hal_io_s *  hio,
ocs_cxn_t *  cxn,
int32_t  status,
ocs_ini_cmpl_fields_t *  ini_fields,
void *  ul_arg 
)
static

This function is the callback for a target IO.

Parameters
hioPointer to the HAL io object.
cxnPointer to the connection object.
statusStatus of the command.
ini_fieldsPointer to the initiator completion fields.
ul_argPoints to the io object.

Definition at line 167 of file ocs_scsi.c.

static void ocs_target_nop_check ( ocs_cxn_t *  cxn)
static

This function sends a target nop.

Description
This function sends a target nop, if it is not already active. We use this to ensure that the TCP ACK is complete before re-using the ICD.
Parameters
cxnPointer to the connection object.

Definition at line 62 of file ocs_scsi.c.