Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_node.c File Reference
#include "ocs.h"
#include "spv.h"
#include "ocs_els.h"
#include "ocs_device.h"

Go to the source code of this file.

Detailed Description

OCS driver remote node handler. This file contains code that is shared between fabric (ocs_fabric.c) and device (ocs_device.c) nodes.

Definition in file ocs_node.c.

Macros

#define SCSI_IOFMT   "[%04x][i:%0*x t:%0*x h:%04x]"
 
#define SCSI_ITT_SIZE(ocs)   ((ocs->ocs_xport == OCS_XPORT_FC) ? 4 : 8)
 
#define SCSI_IOFMT_ARGS(io)   io->instance_index, SCSI_ITT_SIZE(io->ocs), io->init_task_tag, SCSI_ITT_SIZE(io->ocs), io->tgt_task_tag, io->hw_tag
 
#define scsi_io_printf(io, fmt,...)
 

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)
 
void ocs_node_abort_all_els (ocs_node_t *node)
 Device node state machine wait for all ELS's to complete. More...
 
int32_t ocs_remote_node_cb (void *arg, ocs_hal_remote_node_event_e event, void *data)
 Handle remote node events from HAL. More...
 
ocs_node_t * ocs_node_find (ocs_sport_t *sport, uint32_t port_id)
 Find an FC node structure given the FC port ID. More...
 
ocs_node_t * ocs_node_find_wwpn (ocs_sport_t *sport, uint64_t wwpn)
 Find an FC node structure given the WWPN. More...
 
ocs_node_t * ocs_node_find_wwnn (ocs_sport_t *sport, uint64_t wwnn)
 Find an FC node structure given the WWNN. More...
 
int32_t ocs_node_create_pool (ocs_t *ocs, uint32_t node_count)
 allocate node object pool More...
 
void ocs_node_free_pool (ocs_t *ocs)
 free node object pool More...
 
ocs_node_t * ocs_node_get_instance (ocs_t *ocs, uint32_t index)
 return pointer to node object given instance index More...
 
ocs_node_t * ocs_node_alloc (ocs_sport_t *sport, uint32_t port_id, uint8_t init, uint8_t targ)
 Allocate an fc node structure and add to node list. More...
 
int32_t ocs_node_free (ocs_node_t *node)
 free a node structure More...
 
void ocs_node_force_free (ocs_node_t *node)
 free memory resources of a node object More...
 
int32_t ocs_node_attach (ocs_node_t *node)
 Perform HAL call to attach a remote node. More...
 
void ocs_node_fcid_display (uint32_t fc_id, char *buffer, uint32_t buffer_length)
 Generate text for a node's fc_id. More...
 
void ocs_node_update_display_name (ocs_node_t *node)
 update the node's display name More...
 
void ocs_node_send_ls_io_cleanup (ocs_node_t *node)
 cleans up an XRI for the pending link services accept by aborting the XRI if required. More...
 
static int ocs_node_process_plogi_frame (ocs_node_t *node)
 
void * __ocs_node_shutdown (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 state: shutdown a node More...
 
static int ocs_node_check_els_quiesced (ocs_node_t *node)
 Checks to see if ELS's have been quiesced. More...
 
void ocs_node_initiate_cleanup (ocs_node_t *node)
 Initiate node IO cleanup. More...
 
void * __ocs_node_wait_els_shutdown (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Node state machine: Wait for all ELSs to complete. More...
 
void * __ocs_node_wait_node_free (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Node state machine: Wait for a HAL node free event to complete. More...
 
void * __ocs_node_wait_ios_shutdown (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 state: initiate node shutdown More...
 
void * __ocs_node_common (const char *funcname, ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 state: common node event handler More...
 
void ocs_node_save_sparms (ocs_node_t *node, void *payload)
 save node service parameters More...
 
void ocs_node_post_event (ocs_node_t *node, ocs_sm_event_t evt, void *arg)
 Post event to node state machine context. More...
 
void ocs_node_transition (ocs_node_t *node, ocs_sm_function_t state, void *data)
 transition state of a node More...
 
void ocs_node_build_eui_name (char *buffer, uint32_t buffer_len, uint64_t eui_name)
 build EUI formatted WWN More...
 
uint64_t ocs_node_get_wwpn (ocs_node_t *node)
 return nodes' WWPN as a uint64_t More...
 
uint64_t ocs_node_get_wwnn (ocs_node_t *node)
 return nodes' WWNN as a uint64_t More...
 
int ocs_ddump_node (ocs_textbuf_t *textbuf, ocs_node_t *node)
 Generate node ddump data. More...
 
int32_t node_check_els_req (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg, uint8_t cmd, ocs_node_common_func_t node_common_func, const char *funcname)
 check ELS request completion More...
 
int32_t node_check_ct_req (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg, uint32_t cmd, ocs_node_common_func_t node_common_func, const char *funcname)
 check CT request completion More...
 
int32_t node_check_ct_resp (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 
int ocs_node_active_ios_empty (ocs_node_t *node)
 Return TRUE if active ios list is empty. More...
 
void ocs_node_pause (ocs_node_t *node, ocs_sm_function_t state)
 Pause a node. More...
 
void * __ocs_node_paused (ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
 Paused node state. More...
 
int32_t ocs_node_resume (ocs_node_t *node)
 Resume a paused state. More...
 
int32_t ocs_node_recv_els_frame (ocs_node_t *node, ocs_hal_sequence_t *seq)
 Dispatch a ELS frame. More...
 
int32_t ocs_node_recv_abts_frame (ocs_node_t *node, ocs_hal_sequence_t *seq)
 Dispatch a ABTS frame (RQ Pair/sequence coalescing). More...
 
int32_t ocs_node_recv_ct_frame (ocs_node_t *node, ocs_hal_sequence_t *seq)
 Dispatch a CT frame. More...
 
int32_t ocs_node_recv_fcp_cmd (ocs_node_t *node, ocs_hal_sequence_t *seq)
 Dispatch a FCP command frame when the node is not ready. More...
 
int32_t ocs_node_recv_bls_no_sit (ocs_node_t *node, ocs_hal_sequence_t *seq)
 Stub handler for non-ABTS BLS frames. More...
 
int32_t ocs_node_is_remote_node (ocs_remote_node_t *rnode)
 
int32_t ocs_node_suppress_resp (ocs_remote_node_t *rnode)
 Return node suppress_rsp state. More...
 

Variables

static ocs_mgmt_functions_t node_mgmt_functions
 

Macro Details

#define scsi_io_printf (   io,
  fmt,
  ... 
)
Value:
ocs_log_debug(io->ocs, "[%s]" SCSI_IOFMT fmt, \
io->node->display_name, SCSI_IOFMT_ARGS(io), ##__VA_ARGS__)
#define SCSI_IOFMT
Definition: ocs_node.c:49
#define SCSI_IOFMT_ARGS(io)
Definition: ocs_node.c:52
const char const char * fmt
Definition: ocs_ddump.h:54

Definition at line 54 of file ocs_node.c.

#define SCSI_IOFMT   "[%04x][i:%0*x t:%0*x h:%04x]"

Definition at line 49 of file ocs_node.c.

#define SCSI_IOFMT_ARGS (   io)    io->instance_index, SCSI_ITT_SIZE(io->ocs), io->init_task_tag, SCSI_ITT_SIZE(io->ocs), io->tgt_task_tag, io->hw_tag

Definition at line 52 of file ocs_node.c.

#define SCSI_ITT_SIZE (   ocs)    ((ocs->ocs_xport == OCS_XPORT_FC) ? 4 : 8)

Definition at line 50 of file ocs_node.c.

Function Details

void* __ocs_node_paused ( ocs_sm_ctx_t *  ctx,
ocs_sm_event_t  evt,
void *  arg 
)

Paused node state.

This state is entered when a state is "paused". When resumed, the node is transitioned to a previously saved state (node->ndoedb_state)

Parameters
ctxRemote node state machine context.
evtEvent to process.
argPer event optional argument.
Returns
returns NULL

Definition at line 2160 of file ocs_node.c.

void* __ocs_node_wait_node_free ( ocs_sm_ctx_t *  ctx,
ocs_sm_event_t  evt,
void *  arg 
)

Node state machine: Wait for a HAL node free event to complete.

Description

State waits for the node free event to be received from the HAL.

Parameters
ctxRemote node state machine context.
evtEvent to process.
argPer event optional argument.
Returns
Returns NULL.

Definition at line 1189 of file ocs_node.c.

int32_t node_check_ct_req ( ocs_sm_ctx_t *  ctx,
ocs_sm_event_t  evt,
void *  arg,
uint32_t  cmd,
ocs_node_common_func_t  node_common_func,
const char *  funcname 
)

check CT request completion

Check ELS CY request completion event to make sure it's for the nameserver request we expect. If not, invoke given common event handler and return an error.

Parameters
ctxstate machine context
evtELS request event
argevent argument
cmdnameserver command expected
node_common_funccommon event handler to call if nameserver cmd doesn't match
funcnamefunction name that called this
Returns
zero if CT command matches, -1 otherwise

Definition at line 1788 of file ocs_node.c.

int32_t node_check_ct_resp ( ocs_sm_ctx_t *  ctx,
ocs_sm_event_t  evt,
void *  arg 
)

Definition at line 1821 of file ocs_node.c.

int32_t node_check_els_req ( ocs_sm_ctx_t *  ctx,
ocs_sm_event_t  evt,
void *  arg,
uint8_t  cmd,
ocs_node_common_func_t  node_common_func,
const char *  funcname 
)

check ELS request completion

Check ELS request completion event to make sure it's for the ELS request we expect. If not, invoke given common event handler and return an error.

Parameters
ctxstate machine context
evtELS request event
argevent argument
cmdELS command expected
node_common_funccommon event handler to call if ELS doesn't match
funcnamefunction name that called this
Returns
zero if ELS command matches, -1 otherwise

Definition at line 1738 of file ocs_node.c.

int ocs_ddump_node ( ocs_textbuf_t *  textbuf,
ocs_node_t *  node 
)

Generate node ddump data.

Generates the node ddumpdata

Parameters
textbufpointer to text buffer
nodepointer to node context
Returns
Returns 0 on success, or a negative value on failure.

Definition at line 1636 of file ocs_node.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 2065 of file ocs_node.c.

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

Definition at line 1877 of file ocs_node.c.

void ocs_mgmt_node_get_all ( ocs_textbuf_t *  textbuf,
void *  node 
)

Definition at line 1981 of file ocs_node.c.

void ocs_mgmt_node_list ( ocs_textbuf_t *  textbuf,
void *  node 
)

Definition at line 1837 of file ocs_node.c.

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

Definition at line 2034 of file ocs_node.c.

int ocs_node_active_ios_empty ( ocs_node_t *  node)

Return TRUE if active ios list is empty.

Test if node->active_ios list is empty while holding the node->active_ios_lock.

Parameters
nodepointer to node object
Returns
TRUE if node active ios list is empty

Definition at line 2117 of file ocs_node.c.

static int ocs_node_check_els_quiesced ( ocs_node_t *  node)
static

Checks to see if ELS's have been quiesced.

Check if ELS's have been quiesced. If so, transition to the next state in the shutdown process.

Parameters
nodeNode for which ELS's are checked
Returns
Returns 1 if ELS's have been quiesced, 0 otherwise.

Definition at line 990 of file ocs_node.c.

void ocs_node_force_free ( ocs_node_t *  node)

free memory resources of a node object

The node object's child objects are freed after which the node object is freed.

Parameters
nodepointer to a node object
Returns
none

Definition at line 608 of file ocs_node.c.

void ocs_node_initiate_cleanup ( ocs_node_t *  node)

Initiate node IO cleanup.

Note: this function must be called with a non-attached node or a node for which the node detach (ocs_hal_node_detach()) has already been initiated.

Parameters
nodeNode for which shutdown is initiated
Returns
Returns None.

Definition at line 1025 of file ocs_node.c.

int32_t ocs_node_is_remote_node ( ocs_remote_node_t *  rnode)

Definition at line 2564 of file ocs_node.c.

void ocs_node_pause ( ocs_node_t *  node,
ocs_sm_function_t  state 
)

Pause a node.

The node is placed in the __ocs_node_paused state after saving the state to return to

Parameters
nodePointer to node object
stateState to resume to
Returns
none

Definition at line 2140 of file ocs_node.c.

static int ocs_node_process_plogi_frame ( ocs_node_t *  node)
static

Definition at line 796 of file ocs_node.c.

int32_t ocs_node_resume ( ocs_node_t *  node)

Resume a paused state.

Posts a resume event to the paused node.

Parameters
nodePointer to node object
Returns
returns 0 for success, a negative error code value for failure.

Definition at line 2204 of file ocs_node.c.

void ocs_node_send_ls_io_cleanup ( ocs_node_t *  node)

cleans up an XRI for the pending link services accept by aborting the XRI if required.

Description

This function is called when the LS accept is not sent.

Parameters
nodeNode for which should be cleaned up

Definition at line 779 of file ocs_node.c.

void ocs_node_update_display_name ( ocs_node_t *  node)

update the node's display name

The node's display name is updated, sometimes needed because the sport part is updated after the node is allocated.

Parameters
nodepointer to the node object
Returns
none

Definition at line 755 of file ocs_node.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_node.c:2034
int ocs_mgmt_node_get(ocs_textbuf_t *textbuf, char *parent, char *name, void *node)
Definition: ocs_node.c:1877
void ocs_mgmt_node_list(ocs_textbuf_t *textbuf, void *node)
Definition: ocs_node.c:1837
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_node.c:2065
void ocs_mgmt_node_get_all(ocs_textbuf_t *textbuf, void *node)
Definition: ocs_node.c:1981

Definition at line 63 of file ocs_node.c.