38 #if !defined(__OCS_NODE_H__)
39 #define __OCS_NODE_H__
42 #define node_sm_trace() \
44 if (OCS_LOG_ENABLE_SM_TRACE(node->ocs)) \
45 ocs_log_info(node->ocs, "[%s] %-20s\n", node->display_name, ocs_sm_event_name(evt)); \
48 #define node_printf(node, fmt, ...) ocs_log_info(node->ocs, "[%s] " fmt, node->display_name, ##__VA_ARGS__)
49 #define node_printf_test(node, fmt, ...) ocs_log_test(node->ocs, "[%s] " fmt, node->display_name, ##__VA_ARGS__)
50 #define node_printf_err(node, fmt, ...) ocs_log_err(node->ocs, "[%s] " fmt, node->display_name, ##__VA_ARGS__)
52 #define node_sm_prologue() \
53 if (evt == OCS_EVT_ENTER) { \
54 ocs_strncpy(node->current_state_name, __func__, sizeof(node->current_state_name)); \
55 } else if (evt == OCS_EVT_EXIT) { \
56 ocs_strncpy(node->prev_state_name, node->current_state_name, sizeof(node->prev_state_name)); \
57 ocs_strncpy(node->current_state_name, "invalid", sizeof(node->current_state_name)); \
59 node->prev_evt = node->current_evt; \
60 node->current_evt = evt;
62 #define std_node_state_decl(...) \
63 ocs_node_t *node = NULL; \
66 ocs_assert(node, NULL); \
68 ocs_assert(ocs, NULL); \
71 #define OCS_NODEDB_PAUSE_FABRIC_LOGIN (1U << 0)
72 #define OCS_NODEDB_PAUSE_NAMESERVER (1U << 1)
73 #define OCS_NODEDB_PAUSE_NEW_NODES (1U << 2)
105 node->hold_frames = TRUE;
123 node->hold_frames = FALSE;
133 ocs_rlock_init(node->ocs, &node->lock,
"node rlock");
139 ocs_rlock_free(&node->lock);
142 static inline int32_t
145 return ocs_rlock_try(&node->lock);
151 ocs_rlock_acquire(&node->lock);
156 ocs_rlock_release(&node->lock);
190 if (node->sport->enable_ini) retval |= (1U << 3);
191 if (node->sport->enable_tgt) retval |= (1U << 2);
192 if (node->init) retval |= (1U << 1);
193 if (node->targ) retval |= (1U << 0);
197 typedef void* (*ocs_node_common_func_t)(
const char *funcname, ocs_sm_ctx_t *ctx,
ocs_sm_event_t evt,
void *arg);
204 extern ocs_node_t *
ocs_node_find(ocs_sport_t *sport, uint32_t port_id);
208 extern ocs_node_t *
ocs_node_alloc(ocs_sport_t *sport, uint32_t port_id, uint8_t init, uint8_t targ);
249 #endif // __OCS_NODE_H__
int32_t ocs_node_suppress_resp(ocs_remote_node_t *rnode)
Return node suppress_rsp state.
int32_t ocs_node_recv_bls_no_sit(ocs_node_t *node, ocs_hal_sequence_t *seq)
Stub handler for non-ABTS BLS frames.
int32_t ocs_node_recv_abts_frame(ocs_node_t *node, ocs_hal_sequence_t *seq)
Dispatch a ABTS frame (RQ Pair/sequence coalescing).
void * __ocs_node_paused(ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
Paused node state.
static void ocs_node_lock_free(ocs_node_t *node)
int32_t ocs_node_recv_ct_frame(ocs_node_t *node, ocs_hal_sequence_t *seq)
Dispatch a CT frame.
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
void ocs_node_force_free(ocs_node_t *node)
free memory resources of a node object
void * __ocs_node_shutdown(ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
state: shutdown a node
void ocs_node_post_event(ocs_node_t *node, ocs_sm_event_t evt, void *arg)
Post event to node state machine context.
static void ocs_node_accept_frames(ocs_node_t *node)
accept frames
void ocs_node_transition(ocs_node_t *node, ocs_sm_function_t state, void *data)
transition state of a node
ocs_hal_rq_buffer_t * header
int32_t ocs_node_attach(ocs_node_t *node)
Perform HAL call to attach a remote node.
ocs_node_t * ocs_node_find(ocs_sport_t *sport, uint32_t port_id)
Find an FC node structure given the FC port ID.
void ocs_node_fcid_display(uint32_t fc_id, char *buffer, uint32_t buffer_length)
Generate text for a node's fc_id.
ocs_node_t * ocs_node_get_instance(ocs_t *ocs, uint32_t index)
return pointer to node object given instance index
int ocs_node_active_ios_empty(ocs_node_t *node)
Return TRUE if active ios list is empty.
void *(* ocs_node_common_func_t)(const char *funcname, ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
static int32_t ocs_node_lock_try(ocs_node_t *node)
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.
static ocs_node_enable_e ocs_node_get_enable(ocs_node_t *node)
static void ocs_node_lock_init(ocs_node_t *node)
ocs_node_enable_e
Node initiator/target enable defines.
void ocs_node_update_display_name(ocs_node_t *node)
update the node's display name
int32_t ocs_node_free(ocs_node_t *node)
free a node structure
void *(* ocs_sm_function_t)(ocs_sm_ctx_t *, ocs_sm_event_t, void *)
int32_t ocs_node_create_pool(ocs_t *ocs, uint32_t node_count)
allocate node object pool
int32_t ocs_remote_node_cb(void *arg, ocs_hal_remote_node_event_e event, void *data)
Handle remote node events from HAL.
ocs_node_t * ocs_node_find_wwnn(ocs_sport_t *sport, uint64_t wwnn)
Find an FC node structure given the WWNN.
void ocs_node_initiate_cleanup(ocs_node_t *node)
Initiate node IO cleanup.
Defines a wrapper for the RQ payload buffers so that we can place it back on the proper queue...
ocs_node_t * ocs_node_find_wwpn(ocs_sport_t *sport, uint64_t wwpn)
Find an FC node structure given the WWPN.
uint64_t ocs_node_get_wwnn(ocs_node_t *node)
return nodes' WWNN as a uint64_t
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.
void ocs_node_pause(ocs_node_t *node, ocs_sm_function_t state)
Pause a node.
void ocs_node_build_eui_name(char *buffer, uint32_t buffer_len, uint64_t eui_name)
build EUI formatted WWN
int32_t ocs_node_recv_els_frame(ocs_node_t *node, ocs_hal_sequence_t *seq)
Dispatch a ELS frame.
void * __ocs_node_wait_ios_shutdown(ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
state: initiate node shutdown
void ocs_node_dump(ocs_t *ocs)
static void ocs_node_lock(ocs_node_t *node)
int32_t ocs_node_recv_link_services_frame(ocs_node_t *node, ocs_hal_sequence_t *seq)
int32_t node_check_ct_resp(ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
int32_t ocs_node_resume(ocs_node_t *node)
Resume a paused state.
int32_t ocs_node_is_remote_node(ocs_remote_node_t *rnode)
int ocs_ddump_node(ocs_textbuf_t *textbuf, ocs_node_t *node)
Generate node ddump data.
Defines a general FC sequence object, consisting of a header, payload buffers and a HAL IO in the cas...
void * __ocs_node_common(const char *funcname, ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
state: common node event handler
static void ocs_node_hold_frames(ocs_node_t *node)
hold frames in pending frame list
ocs_hal_rq_buffer_t * payload
Node SM IO Context Callback structure.
void ocs_node_free_pool(ocs_t *ocs)
free node object pool
ocs_hal_remote_node_event_e
#define ocs_assert(cond,...)
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.
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.
void ocs_node_abort_all_els(ocs_node_t *node)
Device node state machine wait for all ELS's to complete.
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
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.
static void ocs_node_unlock(ocs_node_t *node)
void ocs_node_save_sparms(ocs_node_t *node, void *payload)
save node service parameters
uint64_t ocs_node_get_wwpn(ocs_node_t *node)
return nodes' WWPN as a uint64_t