sci_base_domain.h revision 230557
176082Sbmah/*-
276082Sbmah * This file is provided under a dual BSD/GPLv2 license.  When using or
376082Sbmah * redistributing this file, you may do so under either license.
476082Sbmah *
576082Sbmah * GPL LICENSE SUMMARY
676082Sbmah *
776082Sbmah * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
876082Sbmah *
976082Sbmah * This program is free software; you can redistribute it and/or modify
1082350Sbmah * it under the terms of version 2 of the GNU General Public License as
1182350Sbmah * published by the Free Software Foundation.
1276082Sbmah *
1376082Sbmah * This program is distributed in the hope that it will be useful, but
1476082Sbmah * WITHOUT ANY WARRANTY; without even the implied warranty of
1582666Sbmah * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1682666Sbmah * General Public License for more details.
1781327Sbmah *
1882666Sbmah * You should have received a copy of the GNU General Public License
1981484Sbmah * along with this program; if not, write to the Free Software
2082666Sbmah * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
2181327Sbmah * The full GNU General Public License is included in this distribution
2282666Sbmah * in the file called LICENSE.GPL.
2382666Sbmah *
2482666Sbmah * BSD LICENSE
2582666Sbmah *
2682666Sbmah * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
2782666Sbmah * All rights reserved.
2881327Sbmah *
2982666Sbmah * Redistribution and use in source and binary forms, with or without
3082666Sbmah * modification, are permitted provided that the following conditions
3182666Sbmah * are met:
3282666Sbmah *
3382666Sbmah *   * Redistributions of source code must retain the above copyright
3482666Sbmah *     notice, this list of conditions and the following disclaimer.
3581327Sbmah *   * Redistributions in binary form must reproduce the above copyright
3682666Sbmah *     notice, this list of conditions and the following disclaimer in
3782666Sbmah *     the documentation and/or other materials provided with the
3881327Sbmah *     distribution.
3982666Sbmah *
4082666Sbmah * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4181327Sbmah * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4282666Sbmah * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4382666Sbmah * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4481327Sbmah * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4582666Sbmah * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4682666Sbmah * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4782666Sbmah * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4883092Sbmah * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4982666Sbmah * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5082666Sbmah * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5182666Sbmah *
5282666Sbmah * $FreeBSD$
5381327Sbmah */
5482666Sbmah#ifndef _SCI_BASE_DOMAIN_H_
5582666Sbmah#define _SCI_BASE_DOMAIN_H_
5682666Sbmah
5782666Sbmah/**
5882666Sbmah * @file
5982666Sbmah *
6082666Sbmah * @brief This file contains all of the structures, constants, and methods
6181327Sbmah *        common to all domain object definitions.
6282666Sbmah */
6382666Sbmah
6482666Sbmah#ifdef __cplusplus
6582666Sbmahextern "C" {
6682666Sbmah#endif // __cplusplus
6782666Sbmah
6882666Sbmah#include <dev/isci/scil/sci_base_object.h>
6982666Sbmah#include <dev/isci/scil/sci_base_logger.h>
7082666Sbmah#include <dev/isci/scil/sci_base_state_machine.h>
7182666Sbmah#include <dev/isci/scil/sci_base_state_machine_logger.h>
7282666Sbmah
7382666Sbmah/**
7482666Sbmah * @enum SCI_BASE_DOMAIN_STATES
7582666Sbmah *
7682666Sbmah * @brief This enumeration depicts the standard states common to all domain
7782666Sbmah *        state machine implementations.
7882666Sbmah */
7981339Sbmahtypedef enum _SCI_BASE_DOMAIN_STATES
8081327Sbmah{
8182666Sbmah   /**
8282666Sbmah    * Simply the initial state for the base domain state machine.
8382666Sbmah    */
8482666Sbmah   SCI_BASE_DOMAIN_STATE_INITIAL,
8582666Sbmah
8682666Sbmah   /**
8781327Sbmah    * This state indicates that the domain has successfully been stopped.
8882666Sbmah    * In this state no new IO operations are permitted.
8982666Sbmah    * This state is entered from the INITIAL state.
9083425Sbmah    * This state is entered from the DISCOVERING state.
9182666Sbmah    */
9282666Sbmah   SCI_BASE_DOMAIN_STATE_STARTING,
9382666Sbmah
9482666Sbmah   /**
9582666Sbmah    * This state indicates the the domain is now ready.  Thus, the user
9682666Sbmah    * is able to perform IO operations to remote devices in this domain.
9782666Sbmah    * This state is entered from the STOPPED state.
9882666Sbmah    * This state is entered from the STOPPING state.
9981339Sbmah    * This state is entered from the DISCOVERING state.
10081339Sbmah    */
10181339Sbmah   SCI_BASE_DOMAIN_STATE_READY,
10282666Sbmah
10382666Sbmah   /**
10482666Sbmah    * This state indicates that the domain is in the process of stopping.
10582666Sbmah    * In this state no new IO operations are permitted, but existing IO
10682666Sbmah    * operations in the domain are allowed to complete.
10782666Sbmah    * This state is entered from the READY state.
10881339Sbmah    * This state is entered from the DISCOVERING state.
10981339Sbmah    */
11082666Sbmah   SCI_BASE_DOMAIN_STATE_STOPPING,
11182666Sbmah
11281339Sbmah   /**
11382666Sbmah    * This state indicates that the domain has successfully been stopped.
11482666Sbmah    * In this state no new IO operations are permitted.
11581327Sbmah    * This state is entered from the INITIAL state.
11682666Sbmah    * This state is entered from the STOPPING state.
11782666Sbmah    */
11882666Sbmah   SCI_BASE_DOMAIN_STATE_STOPPED,
11982666Sbmah
12081327Sbmah   /**
12182666Sbmah    * This state indicates that the domain is actively attempting to
12282666Sbmah    * discover what remote devices are contained in it.  In this state no
12381327Sbmah    * new user IO requests are permitted.
12482666Sbmah    * This state is entered from the READY state.
12582666Sbmah    */
12682666Sbmah   SCI_BASE_DOMAIN_STATE_DISCOVERING,
12782666Sbmah
12882666Sbmah   SCI_BASE_DOMAIN_MAX_STATES
12982666Sbmah
13082666Sbmah} SCI_BASE_DOMAIN_STATES;
13181327Sbmah
13282666Sbmah/**
13382666Sbmah * @struct SCI_BASE_DOMAIN
13482666Sbmah *
13582666Sbmah * @brief This structure defines all of the fields common to DOMAIN objects.
13682666Sbmah */
13781327Sbmahtypedef struct SCI_BASE_DOMAIN
13882666Sbmah{
13982666Sbmah   /**
14081327Sbmah    * This field depicts the parent object (SCI_BASE_OBJECT) for the domain.
14182666Sbmah    */
14282666Sbmah   SCI_BASE_OBJECT_T parent;
14382666Sbmah
14482666Sbmah   /**
14582666Sbmah    * This field contains the information for the base domain state machine.
14681327Sbmah    */
14782666Sbmah   SCI_BASE_STATE_MACHINE_T state_machine;
14882666Sbmah
14982666Sbmah   #ifdef SCI_LOGGING
15082666Sbmah   SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
15182666Sbmah   #endif // SCI_LOGGING
15282666Sbmah
15382666Sbmah} SCI_BASE_DOMAIN_T;
15481327Sbmah
15582666Sbmahstruct SCI_BASE_CONTROLLER;
15682666Sbmahstruct SCI_BASE_REMOTE_DEVICE;
15782666Sbmahstruct SCI_BASE_REQUEST;
15881327Sbmahstruct SCI_BASE_REQUEST;
15982666Sbmah
16082666Sbmahtypedef SCI_STATUS (*SCI_BASE_DOMAIN_TIMED_HANDLER_T)(
16182666Sbmah   SCI_BASE_DOMAIN_T *,
16282666Sbmah   U32,
16382666Sbmah   U32
16481327Sbmah);
16582666Sbmah
16682666Sbmahtypedef SCI_STATUS (*SCI_BASE_DOMAIN_HANDLER_T)(
16781327Sbmah   SCI_BASE_DOMAIN_T *
16882666Sbmah);
16982666Sbmah
17081327Sbmahtypedef SCI_STATUS (*SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T)(
17182666Sbmah   SCI_BASE_DOMAIN_T *,
17282666Sbmah   U32
17381327Sbmah);
17482666Sbmah
17582666Sbmahtypedef SCI_STATUS (*SCI_BASE_DOMAIN_DEVICE_HANDLER_T)(
17681327Sbmah   SCI_BASE_DOMAIN_T *,
17783425Sbmah   struct SCI_BASE_REMOTE_DEVICE *
17882666Sbmah);
17982666Sbmah
18082666Sbmahtypedef SCI_STATUS (*SCI_BASE_DOMAIN_REQUEST_HANDLER_T)(
18181327Sbmah   SCI_BASE_DOMAIN_T *,
18282666Sbmah   struct SCI_BASE_REMOTE_DEVICE *,
18382666Sbmah   struct SCI_BASE_REQUEST *
18482666Sbmah);
18582666Sbmah
18682666Sbmahtypedef SCI_STATUS (*SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T)(
18782666Sbmah   SCI_BASE_DOMAIN_T *,
18881327Sbmah   struct SCI_BASE_REMOTE_DEVICE *,
18982666Sbmah   struct SCI_BASE_REQUEST *,
19082666Sbmah   void *,
19182666Sbmah   SCI_IO_STATUS
19282666Sbmah);
19382666Sbmah
19481327Sbmah
19582666Sbmah/**
19682666Sbmah * @struct SCI_BASE_DOMAIN_STATE_HANDLER
19782666Sbmah *
19882666Sbmah * @brief This structure contains all of the state handler methods common to
19982666Sbmah *        base domain state machines.  Handler methods provide the ability
20082666Sbmah *        to change the behavior for user requests or transitions depending
20182666Sbmah *        on the state the machine is in.
20282666Sbmah */
20382666Sbmahtypedef struct SCI_BASE_DOMAIN_STATE_HANDLER
20482666Sbmah{
20581327Sbmah   /**
20682666Sbmah    * The discover_handler specifies the method invoked when a user attempts
20782666Sbmah    * to discover a domain.
20882666Sbmah    */
20982666Sbmah   SCI_BASE_DOMAIN_TIMED_HANDLER_T discover_handler;
21082666Sbmah
21182666Sbmah   /**
21281327Sbmah    * The port_ready_handler specifies the method invoked an SCI Core
21382666Sbmah    * informs the domain object that it's associated port is now ready
21482666Sbmah    * for IO operation.
21581327Sbmah    */
21682666Sbmah   SCI_BASE_DOMAIN_HANDLER_T port_ready_handler;
21782666Sbmah
21882666Sbmah   /**
21982666Sbmah    * The port_not_ready_handler specifies the method invoked an SCI Core
22081327Sbmah    * informs the domain object that it's associated port is no longer ready
22182666Sbmah    * for IO operation.
22282666Sbmah    */
22382666Sbmah   SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T port_not_ready_handler;
22482666Sbmah
22582666Sbmah   /**
22682666Sbmah    * The device_start_complete_handler specifies the method invoked when a
22782666Sbmah    * remote device start operation in the domain completes.
22882666Sbmah    */
22982666Sbmah   SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_start_complete_handler;
23082666Sbmah
23182666Sbmah   /**
23282666Sbmah    * The device_stop_complete_handler specifies the method invoked when a
23381327Sbmah    * remote device stop operation in the domain completes.
23482666Sbmah    */
23582666Sbmah   SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_stop_complete_handler;
23682666Sbmah
23782666Sbmah   /**
23882666Sbmah    * The device_destruct_handler specifies the method invoked when sci user
23981327Sbmah    * destruct a remote device of this domain.
24082666Sbmah    */
24182666Sbmah   SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_destruct_handler;
24282666Sbmah
24382666Sbmah   /**
24482666Sbmah    * The start_io_handler specifies the method invoked when a user
24581339Sbmah    * attempts to start an IO request for a domain.
24682666Sbmah    */
24782666Sbmah   SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_io_handler;
24881339Sbmah
24982666Sbmah   /**
25082666Sbmah    * The start_high_priority_io_handler specifies the method invoked when a user
25181339Sbmah    * attempts to start an high priority request for a domain.
25282666Sbmah    */
25382666Sbmah   SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_high_priority_io_handler;
25482666Sbmah
25582666Sbmah   /**
25682666Sbmah    * The complete_io_handler specifies the method invoked when a user
25782666Sbmah    * attempts to complete an IO request for a domain.
25882666Sbmah    */
25982666Sbmah   SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_io_handler;
26081339Sbmah
26182666Sbmah   /**
26282666Sbmah    * The complete_high_priority_io_handler specifies the method invoked when a
26382666Sbmah    * user attempts to complete an high priority IO request for a domain.
26482666Sbmah    */
26582666Sbmah   SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T complete_high_priority_io_handler;
26682666Sbmah
26782666Sbmah   /**
26881339Sbmah    * The continue_io_handler specifies the method invoked when a user
26982666Sbmah    * attempts to continue an IO request for a domain.
27082666Sbmah    */
27182666Sbmah   SCI_BASE_DOMAIN_REQUEST_HANDLER_T continue_io_handler;
27282666Sbmah
27382666Sbmah   /**
27482666Sbmah    * The start_task_handler specifies the method invoked when a user
27581339Sbmah    * attempts to start a task management request for a domain.
27682666Sbmah    */
27782666Sbmah   SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_task_handler;
27882666Sbmah
27982666Sbmah   /**
28082666Sbmah    * The complete_task_handler specifies the method invoked when a user
28181339Sbmah    * attempts to complete a task management request for a domain.
28282666Sbmah    */
28382666Sbmah   SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_task_handler;
28482666Sbmah
28582666Sbmah} SCI_BASE_DOMAIN_STATE_HANDLER_T;
28682666Sbmah
28781339Sbmah/**
28882666Sbmah * @brief Construct the base domain
28982666Sbmah *
29082666Sbmah * @param[in] this_domain This parameter specifies the base domain to be
29182666Sbmah *            constructed.
29282666Sbmah * @param[in] logger This parameter specifies the logger associated with
29382666Sbmah *            this base domain object.
29482666Sbmah * @param[in] state_table This parameter specifies the table of state
29582666Sbmah *            definitions to be utilized for the domain state machine.
29682666Sbmah *
29782666Sbmah * @return none
29882666Sbmah */
29982666Sbmahvoid sci_base_domain_construct(
30081339Sbmah   SCI_BASE_DOMAIN_T * this_domain,
30183425Sbmah   SCI_BASE_LOGGER_T * logger,
30283425Sbmah   SCI_BASE_STATE_T  * state_table
30383425Sbmah);
30483425Sbmah
30581339Sbmah#ifdef __cplusplus
30682666Sbmah}
30782666Sbmah#endif // __cplusplus
30882666Sbmah
30982666Sbmah#endif // _SCI_BASE_DOMAIN_H_
31082666Sbmah