OneCore⢠Storage SDK Release 11.2
User Space FC/FCoE Target RAMD Driver (Uspace ocs_fc_ramd)
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
ocs_sm.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011-2015, Emulex
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
*
11
* 2. Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
*
15
* 3. Neither the name of the copyright holder nor the names of its contributors
16
* may be used to endorse or promote products derived from this software
17
* without specific prior written permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
* POSSIBILITY OF SUCH DAMAGE.
30
*
31
*/
32
33
/**
34
* @file
35
* Generic state machine framework declarations.
36
*/
37
38
#ifndef _OCS_SM_H
39
#define _OCS_SM_H
40
41
/**
42
* State Machine (SM) IDs.
43
*/
44
enum
{
45
OCS_SM_COMMON
= 0,
46
OCS_SM_DOMAIN
,
47
OCS_SM_PORT
,
48
OCS_SM_LOGIN
,
49
OCS_SM_LAST
50
};
51
52
#define OCS_SM_EVENT_SHIFT 24
53
#define OCS_SM_EVENT_START(id) ((id) << OCS_SM_EVENT_SHIFT)
54
55
extern
const
char
*
ocs_sm_id
[];
/**< String format of the above enums. */
56
57
/**
58
* State Machine events.
59
*/
60
typedef
enum
{
61
/* Common Events */
62
OCS_EVT_ENTER
=
OCS_SM_EVENT_START
(
OCS_SM_COMMON
),
63
OCS_EVT_REENTER
,
64
OCS_EVT_EXIT
,
65
OCS_EVT_SHUTDOWN
,
66
OCS_EVT_ALL_CHILD_NODES_FREE
,
67
OCS_EVT_RESUME
,
68
OCS_EVT_TIMER_EXPIRED
,
69
70
/* Domain Events */
71
OCS_EVT_RESPONSE
=
OCS_SM_EVENT_START
(
OCS_SM_DOMAIN
),
72
OCS_EVT_ERROR
,
73
74
OCS_EVT_DOMAIN_FOUND
,
75
OCS_EVT_DOMAIN_ALLOC_OK
,
76
OCS_EVT_DOMAIN_ALLOC_FAIL
,
77
OCS_EVT_DOMAIN_REQ_ATTACH
,
78
OCS_EVT_DOMAIN_ATTACH_OK
,
79
OCS_EVT_DOMAIN_ATTACH_FAIL
,
80
OCS_EVT_DOMAIN_LOST
,
81
OCS_EVT_DOMAIN_FREE_OK
,
82
OCS_EVT_DOMAIN_FREE_FAIL
,
83
OCS_EVT_HAL_DOMAIN_REQ_ATTACH
,
84
OCS_EVT_HAL_DOMAIN_REQ_FREE
,
85
86
/* Sport Events */
87
OCS_EVT_SPORT_ALLOC_OK
=
OCS_SM_EVENT_START
(
OCS_SM_PORT
),
88
OCS_EVT_SPORT_ALLOC_FAIL
,
89
OCS_EVT_SPORT_ATTACH_OK
,
90
OCS_EVT_SPORT_ATTACH_FAIL
,
91
OCS_EVT_SPORT_FREE_OK
,
92
OCS_EVT_SPORT_FREE_FAIL
,
93
OCS_EVT_SPORT_TOPOLOGY_NOTIFY
,
94
OCS_EVT_HAL_PORT_ALLOC_OK
,
95
OCS_EVT_HAL_PORT_ALLOC_FAIL
,
96
OCS_EVT_HAL_PORT_ATTACH_OK
,
97
OCS_EVT_HAL_PORT_REQ_ATTACH
,
98
OCS_EVT_HAL_PORT_REQ_FREE
,
99
OCS_EVT_HAL_PORT_FREE_OK
,
100
101
/* Login Events */
102
OCS_EVT_SRRS_ELS_REQ_OK
=
OCS_SM_EVENT_START
(
OCS_SM_LOGIN
),
103
OCS_EVT_SRRS_ELS_CMPL_OK
,
104
OCS_EVT_SRRS_ELS_REQ_FAIL
,
105
OCS_EVT_SRRS_ELS_CMPL_FAIL
,
106
OCS_EVT_SRRS_ELS_REQ_RJT
,
107
OCS_EVT_NODE_ATTACH_OK
,
108
OCS_EVT_NODE_ATTACH_FAIL
,
109
OCS_EVT_NODE_FREE_OK
,
110
OCS_EVT_NODE_FREE_FAIL
,
111
OCS_EVT_ELS_FRAME
,
112
OCS_EVT_ELS_REQ_TIMEOUT
,
113
OCS_EVT_ELS_REQ_ABORTED
,
114
OCS_EVT_ABORT_ELS
,
/**< request an ELS IO be aborted */
115
OCS_EVT_ELS_ABORT_CMPL
,
/**< ELS abort process complete */
116
117
OCS_EVT_ABTS_RCVD
,
118
119
OCS_EVT_NODE_MISSING
,
/**< node is not in the GID_PT payload */
120
OCS_EVT_NODE_REFOUND
,
/**< node is allocated and in the GID_PT payload */
121
OCS_EVT_SHUTDOWN_IMPLICIT_LOGO
,
/**< node shutting down due to PLOGI recvd (implicit logo) */
122
OCS_EVT_SHUTDOWN_EXPLICIT_LOGO
,
/**< node shutting down due to LOGO recvd/sent (explicit logo) */
123
124
OCS_EVT_PLOGI_RCVD
,
125
OCS_EVT_FLOGI_RCVD
,
126
OCS_EVT_LOGO_RCVD
,
127
OCS_EVT_RRQ_RCVD
,
128
OCS_EVT_PRLI_RCVD
,
129
OCS_EVT_PRLO_RCVD
,
130
OCS_EVT_PDISC_RCVD
,
131
OCS_EVT_FDISC_RCVD
,
132
OCS_EVT_ADISC_RCVD
,
133
OCS_EVT_RSCN_RCVD
,
134
OCS_EVT_SCR_RCVD
,
135
OCS_EVT_ELS_RCVD
,
136
137
OCS_EVT_FCP_CMD_RCVD
,
138
139
/* Used by fabric emulation */
140
OCS_EVT_RFT_ID_RCVD
,
141
OCS_EVT_RFF_ID_RCVD
,
142
OCS_EVT_GNN_ID_RCVD
,
143
OCS_EVT_GPN_ID_RCVD
,
144
OCS_EVT_GFPN_ID_RCVD
,
145
OCS_EVT_GFF_ID_RCVD
,
146
OCS_EVT_GID_FT_RCVD
,
147
OCS_EVT_GID_PT_RCVD
,
148
OCS_EVT_RPN_ID_RCVD
,
149
OCS_EVT_RNN_ID_RCVD
,
150
OCS_EVT_RCS_ID_RCVD
,
151
OCS_EVT_RSNN_NN_RCVD
,
152
OCS_EVT_RSPN_ID_RCVD
,
153
OCS_EVT_RHBA_RCVD
,
154
OCS_EVT_RPA_RCVD
,
155
OCS_EVT_GA_NXT_RCVD
,
156
157
OCS_EVT_GIDPT_DELAY_EXPIRED
,
158
159
/* SCSI Target Server events */
160
OCS_EVT_ABORT_IO
,
161
OCS_EVT_ABORT_IO_NO_RESP
,
162
OCS_EVT_IO_CMPL
,
163
OCS_EVT_IO_CMPL_ERRORS
,
164
OCS_EVT_RESP_CMPL
,
165
OCS_EVT_ABORT_CMPL
,
166
OCS_EVT_NODE_ACTIVE_IO_LIST_EMPTY
,
167
OCS_EVT_NODE_LAST_ACTIVE_IO
,
168
OCS_EVT_NODE_DEL_INI_COMPLETE
,
169
OCS_EVT_NODE_DEL_TGT_COMPLETE
,
170
OCS_EVT_IO_ABORTED_BY_TMF
,
171
OCS_EVT_IO_ABORT_IGNORED
,
172
OCS_EVT_IO_FIRST_BURST
,
173
OCS_EVT_IO_FIRST_BURST_ERR
,
174
OCS_EVT_IO_FIRST_BURST_ABORTED
,
175
176
/* Loopback events */
177
OCS_EVT_CT_LOOPBACK_RCVD
,
178
OCS_EVT_CT_LOOPBACK_RCVD_NO_IO
,
179
180
/* Must be last */
181
OCS_EVT_LAST
182
}
ocs_sm_event_t
;
183
184
/* Declare ocs_sm_ctx_s */
185
typedef
struct
ocs_sm_ctx_s
ocs_sm_ctx_t;
186
187
/* State machine state function */
188
typedef
void
*(*ocs_sm_function_t)(ocs_sm_ctx_t *,
ocs_sm_event_t
,
void
*);
189
190
/* State machine context header */
191
struct
ocs_sm_ctx_s
{
192
ocs_sm_function_t
current_state
;
193
const
char
*
description
;
194
void
*
app
;
/** Application-specific handle. */
195
};
196
197
extern
int
ocs_sm_post_event
(ocs_sm_ctx_t *,
ocs_sm_event_t
,
void
*);
198
extern
void
ocs_sm_transition
(ocs_sm_ctx_t *,
ocs_sm_function_t
,
void
*);
199
extern
void
ocs_sm_disable
(ocs_sm_ctx_t *ctx);
200
extern
const
char
*
ocs_sm_event_name
(
ocs_sm_event_t
evt);
201
202
#if 0
203
#define smtrace(sm) ocs_log_debug(NULL, "%s: %-20s --> %s\n", sm, ocs_sm_event_name(evt), __func__)
204
#else
205
#define smtrace(...)
206
#endif
207
208
#endif
/* ! _OCS_SM_H */
OCS_EVT_SPORT_ALLOC_FAIL
Definition:
ocs_sm.h:88
OCS_EVT_NODE_DEL_TGT_COMPLETE
Definition:
ocs_sm.h:169
OCS_EVT_ABORT_CMPL
Definition:
ocs_sm.h:165
OCS_EVT_DOMAIN_FREE_FAIL
Definition:
ocs_sm.h:82
OCS_EVT_NODE_ACTIVE_IO_LIST_EMPTY
Definition:
ocs_sm.h:166
OCS_EVT_RSCN_RCVD
Definition:
ocs_sm.h:133
OCS_EVT_FCP_CMD_RCVD
Definition:
ocs_sm.h:137
OCS_EVT_SCR_RCVD
Definition:
ocs_sm.h:134
OCS_EVT_ABTS_RCVD
Definition:
ocs_sm.h:117
ocs_sm_ctx_s::app
void * app
Definition:
ocs_sm.h:194
OCS_EVT_LAST
Definition:
ocs_sm.h:181
OCS_EVT_ELS_REQ_ABORTED
Definition:
ocs_sm.h:113
OCS_EVT_ALL_CHILD_NODES_FREE
Definition:
ocs_sm.h:66
OCS_SM_COMMON
Definition:
ocs_sm.h:45
OCS_EVT_EXIT
Definition:
ocs_sm.h:64
OCS_EVT_SRRS_ELS_CMPL_FAIL
Definition:
ocs_sm.h:105
OCS_EVT_ELS_ABORT_CMPL
Definition:
ocs_sm.h:115
OCS_EVT_DOMAIN_ATTACH_FAIL
Definition:
ocs_sm.h:79
OCS_EVT_DOMAIN_ATTACH_OK
Definition:
ocs_sm.h:78
OCS_EVT_ABORT_IO
Definition:
ocs_sm.h:160
OCS_EVT_DOMAIN_REQ_ATTACH
Definition:
ocs_sm.h:77
OCS_EVT_NODE_LAST_ACTIVE_IO
Definition:
ocs_sm.h:167
OCS_EVT_SPORT_ATTACH_FAIL
Definition:
ocs_sm.h:90
OCS_EVT_RESUME
Definition:
ocs_sm.h:67
OCS_EVT_LOGO_RCVD
Definition:
ocs_sm.h:126
OCS_EVT_RESP_CMPL
Definition:
ocs_sm.h:164
OCS_EVT_ERROR
Definition:
ocs_sm.h:72
OCS_EVT_RPN_ID_RCVD
Definition:
ocs_sm.h:148
OCS_EVT_SPORT_FREE_FAIL
Definition:
ocs_sm.h:92
OCS_EVT_SRRS_ELS_CMPL_OK
Definition:
ocs_sm.h:103
OCS_EVT_SPORT_FREE_OK
Definition:
ocs_sm.h:91
OCS_EVT_IO_FIRST_BURST_ERR
Definition:
ocs_sm.h:173
OCS_EVT_IO_FIRST_BURST_ABORTED
Definition:
ocs_sm.h:174
OCS_EVT_SRRS_ELS_REQ_FAIL
Definition:
ocs_sm.h:104
OCS_EVT_DOMAIN_LOST
Definition:
ocs_sm.h:80
OCS_EVT_HAL_PORT_FREE_OK
Definition:
ocs_sm.h:99
OCS_EVT_NODE_FREE_OK
Definition:
ocs_sm.h:109
OCS_EVT_GID_PT_RCVD
Definition:
ocs_sm.h:147
OCS_EVT_RCS_ID_RCVD
Definition:
ocs_sm.h:150
OCS_EVT_NODE_DEL_INI_COMPLETE
Definition:
ocs_sm.h:168
ocs_sm_id
const char * ocs_sm_id[]
Definition:
ocs_sm.c:41
OCS_EVT_IO_CMPL_ERRORS
Definition:
ocs_sm.h:163
OCS_EVT_ADISC_RCVD
Definition:
ocs_sm.h:132
OCS_EVT_DOMAIN_FREE_OK
Definition:
ocs_sm.h:81
OCS_EVT_RRQ_RCVD
Definition:
ocs_sm.h:127
ocs_sm_event_name
const char * ocs_sm_event_name(ocs_sm_event_t evt)
Definition:
ocs_sm.c:92
OCS_EVT_SPORT_ATTACH_OK
Definition:
ocs_sm.h:89
OCS_EVT_RESPONSE
Definition:
ocs_sm.h:71
OCS_EVT_SPORT_TOPOLOGY_NOTIFY
Definition:
ocs_sm.h:93
OCS_EVT_RSPN_ID_RCVD
Definition:
ocs_sm.h:152
OCS_EVT_TIMER_EXPIRED
Definition:
ocs_sm.h:68
OCS_EVT_ELS_FRAME
Definition:
ocs_sm.h:111
OCS_EVT_PDISC_RCVD
Definition:
ocs_sm.h:130
OCS_EVT_SRRS_ELS_REQ_RJT
Definition:
ocs_sm.h:106
OCS_EVT_ELS_RCVD
Definition:
ocs_sm.h:135
ocs_sm_function_t
void *(* ocs_sm_function_t)(ocs_sm_ctx_t *, ocs_sm_event_t, void *)
Definition:
ocs_sm.h:188
OCS_EVT_HAL_PORT_ALLOC_OK
Definition:
ocs_sm.h:94
OCS_EVT_REENTER
Definition:
ocs_sm.h:63
OCS_EVT_ENTER
Definition:
ocs_sm.h:62
OCS_EVT_RNN_ID_RCVD
Definition:
ocs_sm.h:149
OCS_EVT_NODE_ATTACH_OK
Definition:
ocs_sm.h:107
OCS_EVT_GPN_ID_RCVD
Definition:
ocs_sm.h:143
OCS_EVT_HAL_PORT_ATTACH_OK
Definition:
ocs_sm.h:96
OCS_EVT_IO_CMPL
Definition:
ocs_sm.h:162
ocs_sm_transition
void ocs_sm_transition(ocs_sm_ctx_t *ctx, ocs_sm_function_t state, void *data)
Transition to a new state.
Definition:
ocs_sm.c:72
OCS_EVT_RFF_ID_RCVD
Definition:
ocs_sm.h:141
OCS_EVT_CT_LOOPBACK_RCVD
Definition:
ocs_sm.h:177
ocs_sm_ctx_s
Definition:
ocs_sm.h:191
OCS_EVT_PRLI_RCVD
Definition:
ocs_sm.h:128
OCS_EVT_SPORT_ALLOC_OK
Definition:
ocs_sm.h:87
OCS_EVT_ABORT_ELS
Definition:
ocs_sm.h:114
OCS_EVT_HAL_PORT_REQ_ATTACH
Definition:
ocs_sm.h:97
ocs_sm_post_event
int ocs_sm_post_event(ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *data)
Post an event to a context.
Definition:
ocs_sm.c:58
OCS_EVT_NODE_REFOUND
Definition:
ocs_sm.h:120
OCS_SM_DOMAIN
Definition:
ocs_sm.h:46
OCS_EVT_DOMAIN_ALLOC_OK
Definition:
ocs_sm.h:75
OCS_EVT_IO_ABORTED_BY_TMF
Definition:
ocs_sm.h:170
OCS_EVT_NODE_FREE_FAIL
Definition:
ocs_sm.h:110
OCS_EVT_HAL_DOMAIN_REQ_FREE
Definition:
ocs_sm.h:84
OCS_EVT_IO_ABORT_IGNORED
Definition:
ocs_sm.h:171
OCS_SM_EVENT_START
#define OCS_SM_EVENT_START(id)
Definition:
ocs_sm.h:53
OCS_EVT_GNN_ID_RCVD
Definition:
ocs_sm.h:142
OCS_EVT_PLOGI_RCVD
Definition:
ocs_sm.h:124
OCS_EVT_FLOGI_RCVD
Definition:
ocs_sm.h:125
OCS_SM_PORT
Definition:
ocs_sm.h:47
OCS_EVT_SHUTDOWN_IMPLICIT_LOGO
Definition:
ocs_sm.h:121
OCS_EVT_GID_FT_RCVD
Definition:
ocs_sm.h:146
OCS_EVT_PRLO_RCVD
Definition:
ocs_sm.h:129
OCS_EVT_NODE_ATTACH_FAIL
Definition:
ocs_sm.h:108
ocs_sm_ctx_s::current_state
ocs_sm_function_t current_state
Definition:
ocs_sm.h:192
OCS_EVT_HAL_PORT_ALLOC_FAIL
Definition:
ocs_sm.h:95
OCS_EVT_GFF_ID_RCVD
Definition:
ocs_sm.h:145
ocs_sm_ctx_s::description
const char * description
Definition:
ocs_sm.h:193
OCS_EVT_SHUTDOWN_EXPLICIT_LOGO
Definition:
ocs_sm.h:122
OCS_EVT_HAL_DOMAIN_REQ_ATTACH
Definition:
ocs_sm.h:83
OCS_EVT_ABORT_IO_NO_RESP
Definition:
ocs_sm.h:161
OCS_EVT_GFPN_ID_RCVD
Definition:
ocs_sm.h:144
OCS_EVT_DOMAIN_FOUND
Definition:
ocs_sm.h:74
OCS_EVT_GIDPT_DELAY_EXPIRED
Definition:
ocs_sm.h:157
OCS_EVT_RFT_ID_RCVD
Definition:
ocs_sm.h:140
ocs_sm_event_t
ocs_sm_event_t
Definition:
ocs_sm.h:60
OCS_EVT_RHBA_RCVD
Definition:
ocs_sm.h:153
OCS_SM_LAST
Definition:
ocs_sm.h:49
OCS_EVT_RPA_RCVD
Definition:
ocs_sm.h:154
OCS_EVT_GA_NXT_RCVD
Definition:
ocs_sm.h:155
OCS_EVT_CT_LOOPBACK_RCVD_NO_IO
Definition:
ocs_sm.h:178
OCS_EVT_SRRS_ELS_REQ_OK
Definition:
ocs_sm.h:102
ocs_sm_disable
void ocs_sm_disable(ocs_sm_ctx_t *ctx)
Disable further state machine processing.
Definition:
ocs_sm.c:87
OCS_EVT_RSNN_NN_RCVD
Definition:
ocs_sm.h:151
OCS_EVT_NODE_MISSING
Definition:
ocs_sm.h:119
OCS_EVT_FDISC_RCVD
Definition:
ocs_sm.h:131
OCS_SM_LOGIN
Definition:
ocs_sm.h:48
OCS_EVT_DOMAIN_ALLOC_FAIL
Definition:
ocs_sm.h:76
OCS_EVT_IO_FIRST_BURST
Definition:
ocs_sm.h:172
OCS_EVT_HAL_PORT_REQ_FREE
Definition:
ocs_sm.h:98
OCS_EVT_SHUTDOWN
Definition:
ocs_sm.h:65
OCS_EVT_ELS_REQ_TIMEOUT
Definition:
ocs_sm.h:112
common
hal
ocs_sm.h