Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_cxn.c File Reference
#include "ocs.h"
#include "ocs_iscsi.h"
#include "ocs_iscsi_spec.h"
#include "ocs_common.h"
#include "ocs_hal.h"
#include "ocs_iscsi_api.h"
#include "ocs_login.h"
#include "ocs_session.h"
#include "ocs_cxn.h"

Go to the source code of this file.

Detailed Description

OCS iSCSI connection management functions.

Definition in file ocs_cxn.c.

Macros

#define std_cxn_state_decl(...)
 
#define cxn_sm_trace()
 

Functions

void ocs_mgmt_node_list (ocs_textbuf_t *textbuf, void *node)
 
void ocs_mgmt_node_get_all (ocs_textbuf_t *textbuf, void *node)
 
int ocs_mgmt_node_get (ocs_textbuf_t *textbuf, char *parent, char *name, void *node)
 
int ocs_mgmt_node_set (char *parent, char *name, char *value, void *node)
 
int ocs_mgmt_node_exec (char *parent, char *action, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length, void *node)
 
static void * __ocs_cxn_connect (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Connect to a remote node. More...
 
static void * __ocs_cxn_connect_wait (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Waiting for the connection to complete. More...
 
static void * __ocs_cxn_connect_delay (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Connection to target failed, delay before retrying. More...
 
static void * __ocs_cxn_get_info (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Get information on the connection. More...
 
static void * __ocs_cxn_get_info_wait (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Waiting for connection information request to complete. More...
 
static void * __ocs_cxn_offload (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Offload the connection to the chip. More...
 
static void * __ocs_cxn_offload_wait (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Waiting for connection offload request to complete. More...
 
static void * __ocs_cxn_reject (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Reject a connection after some connection protocol started. More...
 
static void * __ocs_cxn_reject_wait (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Waiting for connection reject request to complete. More...
 
static void * __ocs_cxn_connected (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Connected, waiting for the teardown request. More...
 
static void * __ocs_cxn_close_abort_io (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Aborts active IO objects on a connection. More...
 
static void * __ocs_cxn_abort_wait (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Waiting for the IO aborts to complete. More...
 
static void * __ocs_cxn_close_abort_login (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Aborts any login transactions on a connection. More...
 
static void * __ocs_cxn_close (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Closes a TCP connection. More...
 
static void * __ocs_cxn_close_wait (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Closing, waiting for the close callback. More...
 
static void * __ocs_cxn_upload (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Closing, waiting for the close callback. More...
 
static void * __ocs_cxn_upload_wait (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Waiting for connection upload to complete. More...
 
static void * __ocs_cxn_error (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 An error was received, something unexpected occurred. More...
 
static void ocs_cxn_connect_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback for connecting to a target. More...
 
static void ocs_cxn_close_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback for closing a connection. More...
 
static void ocs_cxn_upload_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 This function is the callback for uploading a connection. More...
 
static void ocs_cxn_get_info_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 Function to receive the notification that the connection info is available. More...
 
static void ocs_cxn_offload_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 Function to receive the notification that the connection info is available. More...
 
static void ocs_cxn_reject_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 Function to receive the notification that the connection reject is complete. More...
 
int32_t ocs_cxn_initialize (ocs_iscsi_t *iscsi)
 Initialize the iSCSI connection objects. More...
 
void ocs_cxn_teardown (ocs_iscsi_t *iscsi)
 Free the iSCSI connection objects. More...
 
void ocs_cxn_force_free (ocs_cxn_t *cxn)
 Free memory resources of a node object. More...
 
static void ocs_cxn_transition (ocs_cxn_t *cxn, ocs_sm_function_t state, void *data)
 Transition state of a node. More...
 
static void ocs_cxn_retry_timeout (void *arg)
 This function is called on timer expiration and sends an event to the the state machine. More...
 
static void ocs_cxn_set_sm_retry_timer (ocs_cxn_t *cxn, uint32_t timeout)
 Set the SM timer to retry a command at a later time. More...
 
static void * __ocs_cxn_common (const char *funcname, ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Common device event handler. More...
 
static void * __ocs_cxn_initial (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 State: Initial state. More...
 
int32_t ocs_cxn_connect (ocs_iscsi_t *iscsi, ocs_hal_ip_address_t *remote_ip, uint16_t tcp_port, char *tgt_name)
 Log an initiator into the specified target address. More...
 
int32_t ocs_cxn_new_tgt_connection (ocs_iscsi_t *iscsi, uint32_t conn_hdl)
 Function to receive new TCP connections. More...
 
static void ocs_tgt_cxn_invalidate_cb (void *ul_arg, int32_t status, uint32_t ext_status, void *params)
 
void ocs_tgt_cxn_invalidate (ocs_cxn_t *cxn)
 
int32_t ocs_cxn_close (ocs_cxn_t *cxn, uint8_t sendRst)
 Issues a request to the HAL to close the connection. More...
 
ocs_cxn_t * ocs_cxn_alloc (ocs_iscsi_t *iscsi, uint32_t conn_hdl)
 Allocates a connection and initializes the fields as required. More...
 
int ocs_ddump_node (ocs_textbuf_t *textbuf, ocs_node_t *node)
 Generate node ddump data. More...
 

Variables

static ocs_mgmt_functions_t node_mgmt_functions
 

Macro Details

#define cxn_sm_trace ( )
Value:
do { \
ocs_log_info(cxn->ocs, "[%s] %-20s %-20s\n", cxn->display_name, __func__, ocs_sm_event_name(evt)); \
} while (0)
#define OCS_DEBUG_ENABLE_SM_TRACE
Definition: ocs_debug.h:159
const char * ocs_sm_event_name(ocs_sm_event_t evt)
Definition: ocs_sm.c:93
int ocs_debug_is_enabled(uint32_t mask)
return true if debug bits are enabled
Definition: ocs_debug.c:122

Definition at line 66 of file ocs_cxn.c.

#define std_cxn_state_decl (   ...)
Value:
ocs_cxn_t *cxn = NULL; \
ocs_iscsi_t *iscsi = NULL; \
ocs_t *ocs = NULL; \
ocs_assert(ctx, NULL); \
cxn = ctx->app; \
ocs_assert(cxn, NULL); \
iscsi = cxn->iscsi; \
ocs_assert(iscsi, NULL); \
ocs = cxn->ocs; \
ocs_assert(ocs, NULL); \
#define ocs_assert(cond,...)
Definition: ocs_debug.h:163

Definition at line 53 of file ocs_cxn.c.

Function Details

ocs_cxn_t* ocs_cxn_alloc ( ocs_iscsi_t *  iscsi,
uint32_t  conn_hdl 
)

Allocates a connection and initializes the fields as required.

Parameters
iscsiPointer to the iSCSI structure that represents this device.
conn_hdlConnection handle from the firmware.
Returns
Returns 0 on success.

Definition at line 1666 of file ocs_cxn.c.

static void ocs_cxn_close_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback for closing a connection.

Parameters
ul_argPointer to the iSCSI object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPoints to NULL.

Definition at line 1467 of file ocs_cxn.c.

static void ocs_cxn_connect_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback for connecting to a target.

Parameters
ul_argPointer to the iSCSI object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPointer to ocs_hal_ip_address_subnet_t.

Definition at line 1413 of file ocs_cxn.c.

void ocs_cxn_force_free ( ocs_cxn_t *  cxn)

Free memory resources of a node object.

Description
The node object's child objects are freed after which the node object is freed.
Parameters
cxnPointer to connection.
Returns
None.

Definition at line 174 of file ocs_cxn.c.

void ocs_cxn_get_info_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

Function to receive the notification that the connection info is available.

Parameters
ul_argPointer to the cxn structure.
statusStatus of the command.
ext_statusExtended status of the command.
paramsNULL for this call.
Returns
Returns 0 on success.

Definition at line 1377 of file ocs_cxn.c.

int32_t ocs_cxn_initialize ( ocs_iscsi_t *  iscsi)

Initialize the iSCSI connection objects.

Parameters
iscsiPointer to the iSCSI object.
Returns
Returns 0 on success, or a non-zero value otherwise.

Definition at line 121 of file ocs_cxn.c.

void ocs_cxn_offload_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

Function to receive the notification that the connection info is available.

Parameters
ul_argPointer to the cxn structure.
statusStatus of the command.
ext_statusExtended status of the command.
paramsNULL for this call.
Returns
Returns 0 on success.

Definition at line 1345 of file ocs_cxn.c.

void ocs_cxn_reject_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

Function to receive the notification that the connection reject is complete.

Parameters
ul_argPointer to the cxn structure.
statusStatus of the command.
ext_statusExtended status of the command.
paramsNULL for this call.

Definition at line 1315 of file ocs_cxn.c.

static void ocs_cxn_retry_timeout ( void *  arg)
static

This function is called on timer expiration and sends an event to the the state machine.

Parameters
argPointer to the cxn object.

Definition at line 247 of file ocs_cxn.c.

static void ocs_cxn_set_sm_retry_timer ( ocs_cxn_t *  cxn,
uint32_t  timeout 
)
static

Set the SM timer to retry a command at a later time.

Parameters
cxnPointer to the connection object.
timeoutTimeout value in milliseconds.

Definition at line 261 of file ocs_cxn.c.

void ocs_cxn_teardown ( ocs_iscsi_t *  iscsi)

Free the iSCSI connection objects.

Parameters
iscsiPointer to the iSCSI object.
Returns
Returns 0 on success, or a non-zero value otherwise.

Definition at line 155 of file ocs_cxn.c.

static void ocs_cxn_transition ( ocs_cxn_t *  cxn,
ocs_sm_function_t  state,
void *  data 
)
static

Transition state of a node.

Description
The connection's state is transitioned to the requested state. Entry/Exit events are posted as needed.
Parameters
cxnPointer to connection.
stateState to transition to.
dataTransition data.
Returns
None.

Definition at line 227 of file ocs_cxn.c.

static void ocs_cxn_upload_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

This function is the callback for uploading a connection.

Parameters
ul_argPointer to the iSCSI object.
statusStatus of the command.
ext_statusExtended status of the command.
paramsPoints to NULL.

Definition at line 1439 of file ocs_cxn.c.

int ocs_ddump_node ( ocs_textbuf_t *  textbuf,
ocs_node_t *  node 
)

Generate node ddump data.

Description
Generates the node ddump data.
Parameters
textbufPointer to text buffer.
nodePointer to node context.
Returns
Returns 0 on success, or a negative value on failure.

Definition at line 1738 of file ocs_cxn.c.

int ocs_mgmt_node_exec ( char *  parent,
char *  action,
void *  arg_in,
uint32_t  arg_in_length,
void *  arg_out,
uint32_t  arg_out_length,
void *  node 
)

Definition at line 2003 of file ocs_cxn.c.

int ocs_mgmt_node_get ( ocs_textbuf_t *  textbuf,
char *  parent,
char *  name,
void *  node 
)

Definition at line 1833 of file ocs_cxn.c.

void ocs_mgmt_node_get_all ( ocs_textbuf_t *  textbuf,
void *  node 
)

Definition at line 1929 of file ocs_cxn.c.

void ocs_mgmt_node_list ( ocs_textbuf_t *  textbuf,
void *  node 
)

Definition at line 1783 of file ocs_cxn.c.

int ocs_mgmt_node_set ( char *  parent,
char *  name,
char *  value,
void *  node 
)

Definition at line 1973 of file ocs_cxn.c.

void ocs_tgt_cxn_invalidate ( ocs_cxn_t *  cxn)

Definition at line 1617 of file ocs_cxn.c.

static void ocs_tgt_cxn_invalidate_cb ( void *  ul_arg,
int32_t  status,
uint32_t  ext_status,
void *  params 
)
static

Definition at line 1598 of file ocs_cxn.c.

Variable Details

ocs_mgmt_functions_t node_mgmt_functions
static
Initial value:
= {
.get_list_handler = ocs_mgmt_node_list,
.get_handler = ocs_mgmt_node_get,
.get_all_handler = ocs_mgmt_node_get_all,
.set_handler = ocs_mgmt_node_set,
.exec_handler = ocs_mgmt_node_exec,
}
int ocs_mgmt_node_set(char *parent, char *name, char *value, void *node)
Definition: ocs_cxn.c:1973
void ocs_mgmt_node_get_all(ocs_textbuf_t *textbuf, void *node)
Definition: ocs_cxn.c:1929
int ocs_mgmt_node_get(ocs_textbuf_t *textbuf, char *parent, char *name, void *node)
Definition: ocs_cxn.c:1833
int ocs_mgmt_node_exec(char *parent, char *action, void *arg_in, uint32_t arg_in_length, void *arg_out, uint32_t arg_out_length, void *node)
Definition: ocs_cxn.c:2003
void ocs_mgmt_node_list(ocs_textbuf_t *textbuf, void *node)
Definition: ocs_cxn.c:1783

Definition at line 78 of file ocs_cxn.c.