Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_ramd.h File Reference
#include "ocs_ramdisc.h"
#include "ocs_dif.h"
#include "scsi_asc_ascq.h"
#include "ocs_ramd_thread.h"

Go to the source code of this file.

Detailed Description

SCSI RAMD target-service declarations.

Definition in file ocs_ramd.h.

Macros

#define SNS_ILLEGAL_REQ   0x05 /* sense key is byte 3 ([2]) */
 
#define SNS_UNIT_ATTENTION   0x06
 
#define SNS_ABORTED_CMD   0x0B /* sense key - aborted command */
 
#define SNSCODE_INV_CMDIU   0x0E /* INVALID FIELD IN COMMAND IU */
 
#define SNSCODE_DIF_ERR   0x10 /* ID CRC OR ECC ERROR */
 
#define SNSCODE_BAD_CMD   0x20 /* INVALID COMMAND OPERATION CODE */
 
#define SNSCODE_LBA_OOR   0x21 /* LOGICAL BLOCK ADDRESS OUT OF RANGE */
 
#define SNSCODE_INV_CDB   0x24 /* INVALID FIELD IN CDB */
 
#define SNSCODE_INV_PRM   0x26 /* INVALID FIELD IN PARAMETER LIST */
 
#define SNSCODE_ABORTED_CMD   0x47 /* Aborted command */
 
#define SNSCODE_OFF_ERR   0x4B /* DATA PHASE ERROR */
 
#define SNSCODE_SAVE_NOT_SUPPORTED   0x39 /* SAVING PARAMETERS NOT SUPPORTED */
 
#define SNSCODEQUAL_INV_CMDIU   0x03 /* INVALID FIELD IN COMMAND IU */
 
#define scsi_pack_result(key, code, qualifier)   (((key & 0xff) << 16) | ((code && 0xff) << 8) | (qualifier & 0xff))
 

Enumerations

enum  ocs_ramd_hndlr_rtn_e {
  SCSI_HANDLER_DATAPHASE_STARTED = 1, SCSI_HANDLER_RESP_STARTED, SCSI_HANDLER_VALIDATED_DATAPHASE_STARTED, SCSI_HANDLER_WRITE_SAME_DATAPHASE_STARTED,
  SCSI_HANDLER_NOT_STARTED, SCSI_CMD_NOT_SUPPORTED
}
 

Functions

int32_t _ocs_scsi_recv_cmd (ocs_io_t *io, uint32_t lun, uint8_t *cdb, uint32_t cdb_len, uint32_t flags)
 Receive an FCP SCSI command. More...
 
int32_t ocs_scsi_recv_cmd_common (ocs_io_t *io, uint32_t lun, uint8_t *cdb, uint32_t cdb_len, uint32_t flags, uint8_t has_first_burst, ocs_dma_t first_burst_buffers[], uint32_t first_burst_bytes)
 Common code used by ocs_scsi_recv_cmd() and ocs_scsi_recv_cmd_first_burst(). More...
 
ocs_ramd_hndlr_rtn_e ocs_ramd_check_cond (ocs_io_t *io, uint8_t sense_key, uint8_t asc, uint8_t ascq)
 Send a SCSI check condition. More...
 
ocs_ramd_hndlr_rtn_e ocs_ramd_task_set_full_or_busy (ocs_io_t *io)
 Send a SCSI task set full or busy status. More...
 
ocs_ramd_hndlr_rtn_e ocs_ramd_good_status (ocs_io_t *io)
 Send a good SCSI status. More...
 
int32_t scsi_io_cb (ocs_io_t *io, ocs_scsi_io_status_e scsi_status, uint32_t flags, void *arg)
 
int32_t _scsi_io_cb (ocs_io_t *io, ocs_scsi_io_status_e scsi_status, uint32_t flags, void *arg)
 Response phase callback. More...
 
int32_t scsi_dataphase_cb (ocs_io_t *io, ocs_scsi_io_status_e scsi_status, uint32_t flags, void *arg)
 
int32_t _scsi_dataphase_cb (ocs_io_t *io, ocs_scsi_io_status_e scsi_status, uint32_t flags, void *arg)
 Command data phase callback. More...
 
ocs_ramdisc_t * ocs_ramd_lookup (ocs_io_t *io, uint32_t lun)
 Given an IO and a LUN number, return the ramdisc to which the IO is directed. More...
 
ocs_ramdisc_t * ocs_ramd_lookup_by_tgt (ocs_t *ocs, uint32_t tgt, uint32_t lun)
 Given an TGT number and a LUN number, return the corresponding ramdisc. More...
 
void ocs_ramd_post_ua (ocs_t *ocs, ocs_ramdisc_t *ramdisc, uint8_t asc, uint8_t ascq, ocs_node_t *except_node)
 Post a Unit Attention condition to a ramdisc. More...
 
int32_t ocs_ramd_get_ua (ocs_t *ocs, ocs_node_t *node, uint32_t lun, uint8_t *asc, uint8_t *ascq)
 Get a pending Unit Attention, if any. More...
 
void ocs_ramd_clear_ua (ocs_t *ocs, ocs_node_t *node, uint32_t lun, uint8_t asc, uint8_t ascq)
 Clear a Unit Attention condition. More...
 
ocs_ramd_hndlr_rtn_e ocs_ramd_mode_sense6 (ocs_io_t *io, uint8_t cdb[])
 Process SCSI Mode Sense 6 command. More...
 
ocs_ramd_hndlr_rtn_e ocs_ramd_mode_sense10 (ocs_io_t *io, uint8_t cdb[])
 Process SCSI Mode Sense 10 command. More...
 
int32_t ocs_port_rdisc_init (ocs_t *ocs)
 Initialize per port ramdisc structure. More...
 
void ocs_port_rdisc_free (ocs_t *ocs)
 Free per port ramdisc structure. More...
 
int32_t ocs_port_rdisc_find (ocs_t *ocs, uint32_t tgt_id, ocs_ramdisc_t ***rdisc, uint32_t *rdisc_count)
 Find a per port ramdisc instance. More...
 
int32_t ocs_port_rdisc_save (ocs_t *ocs, uint32_t tgt_id, ocs_ramdisc_t **rdisc, uint32_t rdisc_count)
 Save a per port ramdisc. More...
 

Macro Details

#define scsi_pack_result (   key,
  code,
  qualifier 
)    (((key & 0xff) << 16) | ((code && 0xff) << 8) | (qualifier & 0xff))

Definition at line 68 of file ocs_ramd.h.

#define SNS_ABORTED_CMD   0x0B /* sense key - aborted command */

Definition at line 51 of file ocs_ramd.h.

#define SNS_ILLEGAL_REQ   0x05 /* sense key is byte 3 ([2]) */

Definition at line 49 of file ocs_ramd.h.

#define SNS_UNIT_ATTENTION   0x06

Definition at line 50 of file ocs_ramd.h.

#define SNSCODE_ABORTED_CMD   0x47 /* Aborted command */

Definition at line 60 of file ocs_ramd.h.

#define SNSCODE_BAD_CMD   0x20 /* INVALID COMMAND OPERATION CODE */

Definition at line 56 of file ocs_ramd.h.

#define SNSCODE_DIF_ERR   0x10 /* ID CRC OR ECC ERROR */

Definition at line 55 of file ocs_ramd.h.

#define SNSCODE_INV_CDB   0x24 /* INVALID FIELD IN CDB */

Definition at line 58 of file ocs_ramd.h.

#define SNSCODE_INV_CMDIU   0x0E /* INVALID FIELD IN COMMAND IU */

Definition at line 54 of file ocs_ramd.h.

#define SNSCODE_INV_PRM   0x26 /* INVALID FIELD IN PARAMETER LIST */

Definition at line 59 of file ocs_ramd.h.

#define SNSCODE_LBA_OOR   0x21 /* LOGICAL BLOCK ADDRESS OUT OF RANGE */

Definition at line 57 of file ocs_ramd.h.

#define SNSCODE_OFF_ERR   0x4B /* DATA PHASE ERROR */

Definition at line 61 of file ocs_ramd.h.

#define SNSCODE_SAVE_NOT_SUPPORTED   0x39 /* SAVING PARAMETERS NOT SUPPORTED */

Definition at line 62 of file ocs_ramd.h.

#define SNSCODEQUAL_INV_CMDIU   0x03 /* INVALID FIELD IN COMMAND IU */

Definition at line 65 of file ocs_ramd.h.

Enumeration Details

Enumerator
SCSI_HANDLER_DATAPHASE_STARTED 
SCSI_HANDLER_RESP_STARTED 
SCSI_HANDLER_VALIDATED_DATAPHASE_STARTED 
SCSI_HANDLER_WRITE_SAME_DATAPHASE_STARTED 
SCSI_HANDLER_NOT_STARTED 
SCSI_CMD_NOT_SUPPORTED 

Definition at line 71 of file ocs_ramd.h.

Function Details

int32_t _scsi_dataphase_cb ( ocs_io_t *  io,
ocs_scsi_io_status_e  scsi_status,
uint32_t  flags,
void *  arg 
)

Command data phase callback.

Description
This function is called when the SCSI command data phase has completed.
Parameters
ioPointer to the IO structure.
scsi_statusCompletion status.
flagsFlags.
argApplication-specified argument.
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 2875 of file ocs_ramd.c.

int32_t _scsi_io_cb ( ocs_io_t *  io,
ocs_scsi_io_status_e  scsi_status,
uint32_t  flags,
void *  arg 
)

Response phase callback.

Description
This function is called when the response phase for an IO completes.
Parameters
ioPointer to the IO structure.
scsi_statusCompletion status.
flagsFlags.
argApplication-specified argument.
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 2846 of file ocs_ramd.c.

int32_t ocs_port_rdisc_find ( ocs_t *  ocs,
uint32_t  tgt_id,
ocs_ramdisc_t ***  rdisc,
uint32_t *  rdisc_count 
)

Find a per port ramdisc instance.

Description
A per port ramdisc instance is searched for given its target id (tgt_id), if found, the rdisc/rdisc_count arguments are updated with the persisted ramdisc information.
Parameters
ocsPointer to OCS structure.
tgt_idTarget id.
rdiscPointer to ramdiscs.
rdisc_countCount of ramdiscs.
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 7188 of file ocs_ramd.c.

void ocs_port_rdisc_free ( ocs_t *  ocs)

Free per port ramdisc structure.

Description
The per port ramdisc persistence data structure is freed along with the ramdisc objects
Parameters
ocsPointer to OCS instance.
Returns
None.

Definition at line 7158 of file ocs_ramd.c.

int32_t ocs_port_rdisc_init ( ocs_t *  ocs)

Initialize per port ramdisc structure.

Description
The per port ramdisc persistence data structure is initialized.
Parameters
ocspointer to OCS instance
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 7140 of file ocs_ramd.c.

int32_t ocs_port_rdisc_save ( ocs_t *  ocs,
uint32_t  tgt_id,
ocs_ramdisc_t **  rdisc,
uint32_t  rdisc_count 
)

Save a per port ramdisc.

Description
The ramdisc instance given by rdisc/rdisc_count is saved in the per port ramdisc persist structure.
Parameters
ocsPointer to OCS structure.
tgt_idTarget id for this ramdisc.
rdiscPointer to ramdiscs.
rdisc_countCount of ramdiscs.
Returns
Returns 0 for success, or a negative error code value on failure.

Definition at line 7220 of file ocs_ramd.c.

ocs_ramdisc_t* ocs_ramd_lookup ( ocs_io_t *  io,
uint32_t  lun 
)

Given an IO and a LUN number, return the ramdisc to which the IO is directed.

Description
From the IO, get the ocs, then the target private area for the ocs. Check if a global RAMD (one RAMD for all SLI Ports) is used. If so, then find the RAMD in the target private area. If not, then go from IO to node to SLI Port to find the SLI Port's list of ramdiscs.
Parameters
ioPointer to the IO context.
lunLUN for the command.
Returns
Returns a pointer to the ramdisc, or NULL if lun is not valid.

Definition at line 471 of file ocs_ramd.c.

ocs_ramdisc_t* ocs_ramd_lookup_by_tgt ( ocs_t *  ocs,
uint32_t  tgt,
uint32_t  lun 
)

Given an TGT number and a LUN number, return the corresponding ramdisc.

Description
This function is used by the mgmt interface to access ramdisc data out-of-band rather than through a SCSI IO. The TGT number is assumed to correspond to a sport on the first domain. TGT 0 is domain[1]/sport[1], TGT 1 is domain[1]/sport[2], etc.

If the global RAMD is being used then the TGT number must be 0. In this case the ramdisc for LUN n is at ocs->tgt_ocs.rdisc[n].

If per-port RAMD is being used then the TGT number is used to find the correct sport, then LUN n is at sport->tgt_sport.rdisc[n].

Parameters
ocsPointer to the ocs.
tgtTGT number, 0..n.
lunLUN number, 0..n.
Returns
Returns a pointer to a ramdisc structure on success, or NULL on failure.

Definition at line 519 of file ocs_ramd.c.

int32_t ocs_scsi_recv_cmd_common ( ocs_io_t *  io,
uint32_t  lun,
uint8_t *  cdb,
uint32_t  cdb_len,
uint32_t  flags,
uint8_t  has_first_burst,
ocs_dma_t  first_burst_buffers[],
uint32_t  first_burst_bytes 
)

Common code used by ocs_scsi_recv_cmd() and ocs_scsi_recv_cmd_first_burst().

Description
Receive a new FCP SCSI command from the base driver, possibly with the first burst data.
Parameters
ioPointer to the IO context.
lunLUN for this IO.
cdbPointer to the SCSI CDB.
cdb_lenLength of the CDB, in bytes.
flagsCommand flags.
has_first_burstTRUE if the command has first burst data.
first_burst_buffersFirst burst buffer.
first_burst_bytesThe number of bytes received in the first burst.
Returns
Returns 0 on success, or a negative error code value on failure.

Definition at line 1302 of file ocs_ramd.c.

int32_t scsi_dataphase_cb ( ocs_io_t *  io,
ocs_scsi_io_status_e  scsi_status,
uint32_t  flags,
void *  arg 
)

Definition at line 317 of file ocs_ramd_thread.c.

int32_t scsi_io_cb ( ocs_io_t *  io,
ocs_scsi_io_status_e  scsi_status,
uint32_t  flags,
void *  arg 
)

Definition at line 351 of file ocs_ramd_thread.c.