2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 #ifndef _SCIC_SDS_REMOTE_NODE_CONTEXT_H_
55 #define _SCIC_SDS_REMOTE_NODE_CONTEXT_H_
60 * @brief This file contains the structures, constants, and prototypes
61 * associated with the remote node context in the silicon. It
62 * exists to model and manage the remote node context in the silicon.
69 #include <dev/isci/scil/sci_types.h>
70 #include <dev/isci/scil/sci_base_state.h>
71 #include <dev/isci/scil/sci_base_state_machine.h>
72 #include <dev/isci/scil/sci_base_state_machine_logger.h>
74 // ---------------------------------------------------------------------------
77 * This constant represents an invalid remote device id, it is used to program
78 * the STPDARNI register so the driver knows when it has received a SIGNATURE
81 #define SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX 0x0FFF
83 #define SCU_HARDWARE_SUSPENSION (0)
84 #define SCI_SOFTWARE_SUSPENSION (1)
86 struct SCIC_SDS_REQUEST;
87 struct SCIC_SDS_REMOTE_DEVICE;
88 struct SCIC_SDS_REMOTE_NODE_CONTEXT;
90 typedef void (*SCIC_SDS_REMOTE_NODE_CONTEXT_CALLBACK)(void *);
92 typedef SCI_STATUS (*SCIC_SDS_REMOTE_NODE_CONTEXT_OPERATION)(
93 struct SCIC_SDS_REMOTE_NODE_CONTEXT * this_rnc,
94 SCIC_SDS_REMOTE_NODE_CONTEXT_CALLBACK the_callback,
95 void * callback_parameter
98 typedef SCI_STATUS (*SCIC_SDS_REMOTE_NODE_CONTEXT_SUSPEND_OPERATION)(
99 struct SCIC_SDS_REMOTE_NODE_CONTEXT * this_rnc,
101 SCIC_SDS_REMOTE_NODE_CONTEXT_CALLBACK the_callback,
102 void * callback_parameter
105 typedef SCI_STATUS (* SCIC_SDS_REMOTE_NODE_CONTEXT_IO_REQUEST)(
106 struct SCIC_SDS_REMOTE_NODE_CONTEXT * this_rnc,
107 struct SCIC_SDS_REQUEST * the_request
110 typedef SCI_STATUS (*SCIC_SDS_REMOTE_NODE_CONTEXT_EVENT_HANDLER)(
111 struct SCIC_SDS_REMOTE_NODE_CONTEXT * this_rnc,
115 // ---------------------------------------------------------------------------
117 typedef struct _SCIC_SDS_REMOTE_NODE_CONTEXT_HANDLERS
120 * This handle is invoked to stop the RNC. The callback is invoked when after
121 * the hardware notification that the RNC has been invalidated.
123 SCIC_SDS_REMOTE_NODE_CONTEXT_OPERATION destruct_handler;
126 * This handler is invoked when there is a request to suspend the RNC. The
127 * callback is invoked after the hardware notification that the remote node is
130 SCIC_SDS_REMOTE_NODE_CONTEXT_SUSPEND_OPERATION suspend_handler;
133 * This handler is invoked when there is a request to resume the RNC. The
134 * callback is invoked when after the RNC has reached the ready state.
136 SCIC_SDS_REMOTE_NODE_CONTEXT_OPERATION resume_handler;
139 * This handler is invoked when there is a request to start an io request
142 SCIC_SDS_REMOTE_NODE_CONTEXT_IO_REQUEST start_io_handler;
145 * This handler is invoked when there is a request to start a task request
148 SCIC_SDS_REMOTE_NODE_CONTEXT_IO_REQUEST start_task_handler;
151 * This handler is invoked where there is an RNC event that must be processed.
153 SCIC_SDS_REMOTE_NODE_CONTEXT_EVENT_HANDLER event_handler;
155 } SCIC_SDS_REMOTE_NODE_CONTEXT_HANDLERS;
157 // ---------------------------------------------------------------------------
162 * This is the enumeration of the remote node context states.
164 typedef enum _SCIS_SDS_REMOTE_NODE_CONTEXT_STATES
167 * This state is the initial state for a remote node context. On a resume
168 * request the remote node context will transition to the posting state.
170 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE,
173 * This is a transition state that posts the RNi to the hardware. Once the RNC
174 * is posted the remote node context will be made ready.
176 SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE,
179 * This is a transition state that will post an RNC invalidate to the
180 * hardware. Once the invalidate is complete the remote node context will
181 * transition to the posting state.
183 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE,
186 * This is a transition state that will post an RNC resume to the hardare.
187 * Once the event notification of resume complete is received the remote node
188 * context will transition to the ready state.
190 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE,
193 * This is the state that the remote node context must be in to accept io
194 * request operations.
196 SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE,
199 * This is the state that the remote node context transitions to when it gets
200 * a TX suspend notification from the hardware.
202 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE,
205 * This is the state that the remote node context transitions to when it gets
206 * a TX RX suspend notification from the hardware.
208 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE,
211 * This state is a wait state for the remote node context that waits for a
212 * suspend notification from the hardware. This state is entered when either
213 * there is a request to supend the remote node context or when there is a TC
214 * completion where the remote node will be suspended by the hardware.
216 SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE,
218 SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES
220 } SCIS_SDS_REMOTE_NODE_CONTEXT_STATES;
225 * This enumeration is used to define the end destination state for the remote
228 enum SCIC_SDS_REMOTE_NODE_CONTEXT_DESTINATION_STATE
230 SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED,
231 SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY,
232 SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL
236 * @struct SCIC_SDS_REMOTE_NODE_CONTEXT
238 * @brief This structure contains the data associated with the remote
239 * node context object. The remote node context (RNC) object models
240 * the remote device information necessary to manage the
243 typedef struct SCIC_SDS_REMOTE_NODE_CONTEXT
246 * This contains the information used to maintain the loggers for the base
249 SCI_BASE_OBJECT_T parent;
252 * This pointer simply points to the remote device object containing
255 * @todo Consider making the device pointer the associated object of the
258 struct SCIC_SDS_REMOTE_DEVICE * device;
261 * This field indicates the remote node index (RNI) associated with
264 U16 remote_node_index;
267 * This field is the recored suspension code or the reason for the remote node
268 * context suspension.
273 * This field is TRUE if the remote node context is resuming from its current
274 * state. This can cause an automatic resume on receiving a suspension
277 enum SCIC_SDS_REMOTE_NODE_CONTEXT_DESTINATION_STATE destination_state;
280 * This field contains the callback function that the user requested to be
281 * called when the requested state transition is complete.
283 SCIC_SDS_REMOTE_NODE_CONTEXT_CALLBACK user_callback;
286 * This field contains the parameter that is called when the user requested
287 * state transition is completed.
292 * This field contains the data for the object's state machine.
294 SCI_BASE_STATE_MACHINE_T state_machine;
296 SCIC_SDS_REMOTE_NODE_CONTEXT_HANDLERS * state_handlers;
300 * This field conatins the ready substate machine logger. The logger will
301 * emit a message each time the ready substate machine changes state.
303 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
306 } SCIC_SDS_REMOTE_NODE_CONTEXT_T;
308 // ---------------------------------------------------------------------------
310 extern SCI_BASE_STATE_T
311 scic_sds_remote_node_context_state_table[
312 SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES];
314 extern SCIC_SDS_REMOTE_NODE_CONTEXT_HANDLERS
315 scic_sds_remote_node_context_state_handler_table[
316 SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES];
318 // ---------------------------------------------------------------------------
320 void scic_sds_remote_node_context_construct(
321 struct SCIC_SDS_REMOTE_DEVICE * device,
322 SCIC_SDS_REMOTE_NODE_CONTEXT_T * rnc,
323 U16 remote_node_index
326 void scic_sds_remote_node_context_construct_buffer(
327 SCIC_SDS_REMOTE_NODE_CONTEXT_T * rnc
330 BOOL scic_sds_remote_node_context_is_initialized(
331 SCIC_SDS_REMOTE_NODE_CONTEXT_T * rnc
334 BOOL scic_sds_remote_node_context_is_ready(
335 SCIC_SDS_REMOTE_NODE_CONTEXT_T * this_rnc
338 #define scic_sds_remote_node_context_set_remote_node_index(rnc, rni) \
339 ((rnc)->remote_node_index = (rni))
341 #define scic_sds_remote_node_context_get_remote_node_index(rcn) \
342 ((rnc)->remote_node_index)
344 #define scic_sds_remote_node_context_event_handler(rnc, event_code) \
345 ((rnc)->state_handlers->event_handler(rnc, event_code))
347 #define scic_sds_remote_node_context_resume(rnc, callback, parameter) \
348 ((rnc)->state_handlers->resume_handler(rnc, callback, parameter))
350 #define scic_sds_remote_node_context_suspend(rnc, suspend_type, callback, parameter) \
351 ((rnc)->state_handlers->suspend_handler(rnc, suspend_type, callback, parameter))
353 #define scic_sds_remote_node_context_destruct(rnc, callback, parameter) \
354 ((rnc)->state_handlers->destruct_handler(rnc, callback, parameter))
356 #define scic_sds_remote_node_context_start_io(rnc, request) \
357 ((rnc)->state_handlers->start_io_handler(rnc, request))
359 #define scic_sds_remote_node_context_start_task(rnc, task) \
360 ((rnc)->state_handlers->start_task_handler(rnc, task))
362 // ---------------------------------------------------------------------------
365 void scic_sds_remote_node_context_initialize_state_logging(
366 SCIC_SDS_REMOTE_NODE_CONTEXT_T *this_rnc
369 void scic_sds_remote_node_context_deinitialize_state_logging(
370 SCIC_SDS_REMOTE_NODE_CONTEXT_T *this_rnc
373 #define scic_sds_remote_node_context_initialize_state_logging(x)
374 #define scic_sds_remote_node_context_deinitialize_state_logging(x)
375 #endif // SCI_LOGGING
379 #endif // __cplusplus
381 #endif // _SCIC_SDS_REMOTE_NODE_CONTEXT_H_