1230557Sjimharris/*- 2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license. When using or 3230557Sjimharris * redistributing this file, you may do so under either license. 4230557Sjimharris * 5230557Sjimharris * GPL LICENSE SUMMARY 6230557Sjimharris * 7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8230557Sjimharris * 9230557Sjimharris * This program is free software; you can redistribute it and/or modify 10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as 11230557Sjimharris * published by the Free Software Foundation. 12230557Sjimharris * 13230557Sjimharris * This program is distributed in the hope that it will be useful, but 14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of 15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16230557Sjimharris * General Public License for more details. 17230557Sjimharris * 18230557Sjimharris * You should have received a copy of the GNU General Public License 19230557Sjimharris * along with this program; if not, write to the Free Software 20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21230557Sjimharris * The full GNU General Public License is included in this distribution 22230557Sjimharris * in the file called LICENSE.GPL. 23230557Sjimharris * 24230557Sjimharris * BSD LICENSE 25230557Sjimharris * 26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 27230557Sjimharris * All rights reserved. 28230557Sjimharris * 29230557Sjimharris * Redistribution and use in source and binary forms, with or without 30230557Sjimharris * modification, are permitted provided that the following conditions 31230557Sjimharris * are met: 32230557Sjimharris * 33230557Sjimharris * * Redistributions of source code must retain the above copyright 34230557Sjimharris * notice, this list of conditions and the following disclaimer. 35230557Sjimharris * * Redistributions in binary form must reproduce the above copyright 36230557Sjimharris * notice, this list of conditions and the following disclaimer in 37230557Sjimharris * the documentation and/or other materials provided with the 38230557Sjimharris * distribution. 39230557Sjimharris * 40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51230557Sjimharris * 52230557Sjimharris * $FreeBSD$ 53230557Sjimharris */ 54230557Sjimharris#ifndef _SCI_BASE_DOMAIN_H_ 55230557Sjimharris#define _SCI_BASE_DOMAIN_H_ 56230557Sjimharris 57230557Sjimharris/** 58230557Sjimharris * @file 59230557Sjimharris * 60230557Sjimharris * @brief This file contains all of the structures, constants, and methods 61230557Sjimharris * common to all domain object definitions. 62230557Sjimharris */ 63230557Sjimharris 64230557Sjimharris#ifdef __cplusplus 65230557Sjimharrisextern "C" { 66230557Sjimharris#endif // __cplusplus 67230557Sjimharris 68230557Sjimharris#include <dev/isci/scil/sci_base_object.h> 69230557Sjimharris#include <dev/isci/scil/sci_base_logger.h> 70230557Sjimharris#include <dev/isci/scil/sci_base_state_machine.h> 71230557Sjimharris#include <dev/isci/scil/sci_base_state_machine_logger.h> 72230557Sjimharris 73230557Sjimharris/** 74230557Sjimharris * @enum SCI_BASE_DOMAIN_STATES 75230557Sjimharris * 76230557Sjimharris * @brief This enumeration depicts the standard states common to all domain 77230557Sjimharris * state machine implementations. 78230557Sjimharris */ 79230557Sjimharristypedef enum _SCI_BASE_DOMAIN_STATES 80230557Sjimharris{ 81230557Sjimharris /** 82230557Sjimharris * Simply the initial state for the base domain state machine. 83230557Sjimharris */ 84230557Sjimharris SCI_BASE_DOMAIN_STATE_INITIAL, 85230557Sjimharris 86230557Sjimharris /** 87230557Sjimharris * This state indicates that the domain has successfully been stopped. 88230557Sjimharris * In this state no new IO operations are permitted. 89230557Sjimharris * This state is entered from the INITIAL state. 90230557Sjimharris * This state is entered from the DISCOVERING state. 91230557Sjimharris */ 92230557Sjimharris SCI_BASE_DOMAIN_STATE_STARTING, 93230557Sjimharris 94230557Sjimharris /** 95240518Seadler * This state indicates the domain is now ready. Thus, the user 96230557Sjimharris * is able to perform IO operations to remote devices in this domain. 97230557Sjimharris * This state is entered from the STOPPED state. 98230557Sjimharris * This state is entered from the STOPPING state. 99230557Sjimharris * This state is entered from the DISCOVERING state. 100230557Sjimharris */ 101230557Sjimharris SCI_BASE_DOMAIN_STATE_READY, 102230557Sjimharris 103230557Sjimharris /** 104230557Sjimharris * This state indicates that the domain is in the process of stopping. 105230557Sjimharris * In this state no new IO operations are permitted, but existing IO 106230557Sjimharris * operations in the domain are allowed to complete. 107230557Sjimharris * This state is entered from the READY state. 108230557Sjimharris * This state is entered from the DISCOVERING state. 109230557Sjimharris */ 110230557Sjimharris SCI_BASE_DOMAIN_STATE_STOPPING, 111230557Sjimharris 112230557Sjimharris /** 113230557Sjimharris * This state indicates that the domain has successfully been stopped. 114230557Sjimharris * In this state no new IO operations are permitted. 115230557Sjimharris * This state is entered from the INITIAL state. 116230557Sjimharris * This state is entered from the STOPPING state. 117230557Sjimharris */ 118230557Sjimharris SCI_BASE_DOMAIN_STATE_STOPPED, 119230557Sjimharris 120230557Sjimharris /** 121230557Sjimharris * This state indicates that the domain is actively attempting to 122230557Sjimharris * discover what remote devices are contained in it. In this state no 123230557Sjimharris * new user IO requests are permitted. 124230557Sjimharris * This state is entered from the READY state. 125230557Sjimharris */ 126230557Sjimharris SCI_BASE_DOMAIN_STATE_DISCOVERING, 127230557Sjimharris 128230557Sjimharris SCI_BASE_DOMAIN_MAX_STATES 129230557Sjimharris 130230557Sjimharris} SCI_BASE_DOMAIN_STATES; 131230557Sjimharris 132230557Sjimharris/** 133230557Sjimharris * @struct SCI_BASE_DOMAIN 134230557Sjimharris * 135230557Sjimharris * @brief This structure defines all of the fields common to DOMAIN objects. 136230557Sjimharris */ 137230557Sjimharristypedef struct SCI_BASE_DOMAIN 138230557Sjimharris{ 139230557Sjimharris /** 140230557Sjimharris * This field depicts the parent object (SCI_BASE_OBJECT) for the domain. 141230557Sjimharris */ 142230557Sjimharris SCI_BASE_OBJECT_T parent; 143230557Sjimharris 144230557Sjimharris /** 145230557Sjimharris * This field contains the information for the base domain state machine. 146230557Sjimharris */ 147230557Sjimharris SCI_BASE_STATE_MACHINE_T state_machine; 148230557Sjimharris 149230557Sjimharris #ifdef SCI_LOGGING 150230557Sjimharris SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger; 151230557Sjimharris #endif // SCI_LOGGING 152230557Sjimharris 153230557Sjimharris} SCI_BASE_DOMAIN_T; 154230557Sjimharris 155230557Sjimharrisstruct SCI_BASE_CONTROLLER; 156230557Sjimharrisstruct SCI_BASE_REMOTE_DEVICE; 157230557Sjimharrisstruct SCI_BASE_REQUEST; 158230557Sjimharrisstruct SCI_BASE_REQUEST; 159230557Sjimharris 160230557Sjimharristypedef SCI_STATUS (*SCI_BASE_DOMAIN_TIMED_HANDLER_T)( 161230557Sjimharris SCI_BASE_DOMAIN_T *, 162230557Sjimharris U32, 163230557Sjimharris U32 164230557Sjimharris); 165230557Sjimharris 166230557Sjimharristypedef SCI_STATUS (*SCI_BASE_DOMAIN_HANDLER_T)( 167230557Sjimharris SCI_BASE_DOMAIN_T * 168230557Sjimharris); 169230557Sjimharris 170230557Sjimharristypedef SCI_STATUS (*SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T)( 171230557Sjimharris SCI_BASE_DOMAIN_T *, 172230557Sjimharris U32 173230557Sjimharris); 174230557Sjimharris 175230557Sjimharristypedef SCI_STATUS (*SCI_BASE_DOMAIN_DEVICE_HANDLER_T)( 176230557Sjimharris SCI_BASE_DOMAIN_T *, 177230557Sjimharris struct SCI_BASE_REMOTE_DEVICE * 178230557Sjimharris); 179230557Sjimharris 180230557Sjimharristypedef SCI_STATUS (*SCI_BASE_DOMAIN_REQUEST_HANDLER_T)( 181230557Sjimharris SCI_BASE_DOMAIN_T *, 182230557Sjimharris struct SCI_BASE_REMOTE_DEVICE *, 183230557Sjimharris struct SCI_BASE_REQUEST * 184230557Sjimharris); 185230557Sjimharris 186230557Sjimharristypedef SCI_STATUS (*SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T)( 187230557Sjimharris SCI_BASE_DOMAIN_T *, 188230557Sjimharris struct SCI_BASE_REMOTE_DEVICE *, 189230557Sjimharris struct SCI_BASE_REQUEST *, 190230557Sjimharris void *, 191230557Sjimharris SCI_IO_STATUS 192230557Sjimharris); 193230557Sjimharris 194230557Sjimharris 195230557Sjimharris/** 196230557Sjimharris * @struct SCI_BASE_DOMAIN_STATE_HANDLER 197230557Sjimharris * 198230557Sjimharris * @brief This structure contains all of the state handler methods common to 199230557Sjimharris * base domain state machines. Handler methods provide the ability 200230557Sjimharris * to change the behavior for user requests or transitions depending 201230557Sjimharris * on the state the machine is in. 202230557Sjimharris */ 203230557Sjimharristypedef struct SCI_BASE_DOMAIN_STATE_HANDLER 204230557Sjimharris{ 205230557Sjimharris /** 206230557Sjimharris * The discover_handler specifies the method invoked when a user attempts 207230557Sjimharris * to discover a domain. 208230557Sjimharris */ 209230557Sjimharris SCI_BASE_DOMAIN_TIMED_HANDLER_T discover_handler; 210230557Sjimharris 211230557Sjimharris /** 212230557Sjimharris * The port_ready_handler specifies the method invoked an SCI Core 213230557Sjimharris * informs the domain object that it's associated port is now ready 214230557Sjimharris * for IO operation. 215230557Sjimharris */ 216230557Sjimharris SCI_BASE_DOMAIN_HANDLER_T port_ready_handler; 217230557Sjimharris 218230557Sjimharris /** 219230557Sjimharris * The port_not_ready_handler specifies the method invoked an SCI Core 220230557Sjimharris * informs the domain object that it's associated port is no longer ready 221230557Sjimharris * for IO operation. 222230557Sjimharris */ 223230557Sjimharris SCI_BASE_DOMAIN_PORT_NOT_READY_HANDLER_T port_not_ready_handler; 224230557Sjimharris 225230557Sjimharris /** 226230557Sjimharris * The device_start_complete_handler specifies the method invoked when a 227230557Sjimharris * remote device start operation in the domain completes. 228230557Sjimharris */ 229230557Sjimharris SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_start_complete_handler; 230230557Sjimharris 231230557Sjimharris /** 232230557Sjimharris * The device_stop_complete_handler specifies the method invoked when a 233230557Sjimharris * remote device stop operation in the domain completes. 234230557Sjimharris */ 235230557Sjimharris SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_stop_complete_handler; 236230557Sjimharris 237230557Sjimharris /** 238230557Sjimharris * The device_destruct_handler specifies the method invoked when sci user 239230557Sjimharris * destruct a remote device of this domain. 240230557Sjimharris */ 241230557Sjimharris SCI_BASE_DOMAIN_DEVICE_HANDLER_T device_destruct_handler; 242230557Sjimharris 243230557Sjimharris /** 244230557Sjimharris * The start_io_handler specifies the method invoked when a user 245230557Sjimharris * attempts to start an IO request for a domain. 246230557Sjimharris */ 247230557Sjimharris SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_io_handler; 248230557Sjimharris 249230557Sjimharris /** 250230557Sjimharris * The start_high_priority_io_handler specifies the method invoked when a user 251230557Sjimharris * attempts to start an high priority request for a domain. 252230557Sjimharris */ 253230557Sjimharris SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_high_priority_io_handler; 254230557Sjimharris 255230557Sjimharris /** 256230557Sjimharris * The complete_io_handler specifies the method invoked when a user 257230557Sjimharris * attempts to complete an IO request for a domain. 258230557Sjimharris */ 259230557Sjimharris SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_io_handler; 260230557Sjimharris 261230557Sjimharris /** 262230557Sjimharris * The complete_high_priority_io_handler specifies the method invoked when a 263230557Sjimharris * user attempts to complete an high priority IO request for a domain. 264230557Sjimharris */ 265230557Sjimharris SCI_BASE_DOMAIN_HIGH_PRIORITY_REQUEST_COMPLETE_HANDLER_T complete_high_priority_io_handler; 266230557Sjimharris 267230557Sjimharris /** 268230557Sjimharris * The continue_io_handler specifies the method invoked when a user 269230557Sjimharris * attempts to continue an IO request for a domain. 270230557Sjimharris */ 271230557Sjimharris SCI_BASE_DOMAIN_REQUEST_HANDLER_T continue_io_handler; 272230557Sjimharris 273230557Sjimharris /** 274230557Sjimharris * The start_task_handler specifies the method invoked when a user 275230557Sjimharris * attempts to start a task management request for a domain. 276230557Sjimharris */ 277230557Sjimharris SCI_BASE_DOMAIN_REQUEST_HANDLER_T start_task_handler; 278230557Sjimharris 279230557Sjimharris /** 280230557Sjimharris * The complete_task_handler specifies the method invoked when a user 281230557Sjimharris * attempts to complete a task management request for a domain. 282230557Sjimharris */ 283230557Sjimharris SCI_BASE_DOMAIN_REQUEST_HANDLER_T complete_task_handler; 284230557Sjimharris 285230557Sjimharris} SCI_BASE_DOMAIN_STATE_HANDLER_T; 286230557Sjimharris 287230557Sjimharris/** 288230557Sjimharris * @brief Construct the base domain 289230557Sjimharris * 290230557Sjimharris * @param[in] this_domain This parameter specifies the base domain to be 291230557Sjimharris * constructed. 292230557Sjimharris * @param[in] logger This parameter specifies the logger associated with 293230557Sjimharris * this base domain object. 294230557Sjimharris * @param[in] state_table This parameter specifies the table of state 295230557Sjimharris * definitions to be utilized for the domain state machine. 296230557Sjimharris * 297230557Sjimharris * @return none 298230557Sjimharris */ 299230557Sjimharrisvoid sci_base_domain_construct( 300230557Sjimharris SCI_BASE_DOMAIN_T * this_domain, 301230557Sjimharris SCI_BASE_LOGGER_T * logger, 302230557Sjimharris SCI_BASE_STATE_T * state_table 303230557Sjimharris); 304230557Sjimharris 305230557Sjimharris#ifdef __cplusplus 306230557Sjimharris} 307230557Sjimharris#endif // __cplusplus 308230557Sjimharris 309230557Sjimharris#endif // _SCI_BASE_DOMAIN_H_ 310