Commit 38aa74eb authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dan Williams

isci: remove base_request abstraction

Merge struct sci_base_request into scic_sds_request, and also factor the two
types of state machine handlers into one function.  While we're at it also
remove lots of duplicate incorrect kerneldoc comments for the state machine
handlers.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent ca841f0e
......@@ -65,7 +65,7 @@
#include "sci_base_state_machine.h"
struct sci_base_request;
struct scic_sds_request;
/**
* enum sci_base_remote_device_states - This enumeration depicts all the states
......@@ -159,12 +159,12 @@ typedef enum sci_status (*sci_base_remote_device_handler_t)(
typedef enum sci_status (*sci_base_remote_device_request_handler_t)(
struct sci_base_remote_device *,
struct sci_base_request *
struct scic_sds_request *
);
typedef enum sci_status (*sci_base_remote_device_high_priority_request_complete_handler_t)(
struct sci_base_remote_device *,
struct sci_base_request *,
struct scic_sds_request *,
void *,
enum sci_io_status
);
......
/*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
* The full GNU General Public License is included in this distribution
* in the file called LICENSE.GPL.
*
* BSD LICENSE
*
* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SCI_BASE_REQUST_H_
#define _SCI_BASE_REQUST_H_
/**
* This file contains all of the constants, types, and method declarations for
* the SCI base IO and task request objects.
*
*
*/
#include "sci_base_state_machine.h"
/**
* enum sci_base_request_states - This enumeration depicts all the states for
* the common request state machine.
*
*
*/
enum sci_base_request_states {
/**
* Simply the initial state for the base request state machine.
*/
SCI_BASE_REQUEST_STATE_INITIAL,
/**
* This state indicates that the request has been constructed. This state
* is entered from the INITIAL state.
*/
SCI_BASE_REQUEST_STATE_CONSTRUCTED,
/**
* This state indicates that the request has been started. This state is
* entered from the CONSTRUCTED state.
*/
SCI_BASE_REQUEST_STATE_STARTED,
/**
* This state indicates that the request has completed.
* This state is entered from the STARTED state. This state is entered from
* the ABORTING state.
*/
SCI_BASE_REQUEST_STATE_COMPLETED,
/**
* This state indicates that the request is in the process of being
* terminated/aborted.
* This state is entered from the CONSTRUCTED state.
* This state is entered from the STARTED state.
*/
SCI_BASE_REQUEST_STATE_ABORTING,
/**
* Simply the final state for the base request state machine.
*/
SCI_BASE_REQUEST_STATE_FINAL,
};
/**
* struct sci_base_request - The base request object abstracts the fields
* common to all SCI IO and task request objects.
*
*
*/
struct sci_base_request {
/**
* The field specifies that the parent object for the base request is the
* base object itself.
*/
struct sci_base_object parent;
/**
* This field contains the information for the base request state machine.
*/
struct sci_base_state_machine state_machine;
};
typedef enum sci_status (*sci_base_request_handler_t)(
struct sci_base_request *this_request
);
/**
* struct sci_base_request_state_handler - This structure contains all of the
* state handler methods common to base IO and task request state machines.
* Handler methods provide the ability to change the behavior for user
* requests or transitions depending on the state the machine is in.
*
*
*/
struct sci_base_request_state_handler {
/**
* The start_handler specifies the method invoked when a user attempts to
* start a request.
*/
sci_base_request_handler_t start_handler;
/**
* The abort_handler specifies the method invoked when a user attempts to
* abort a request.
*/
sci_base_request_handler_t abort_handler;
/**
* The complete_handler specifies the method invoked when a user attempts to
* complete a request.
*/
sci_base_request_handler_t complete_handler;
/**
* The destruct_handler specifies the method invoked when a user attempts to
* destruct a request.
*/
sci_base_request_handler_t destruct_handler;
};
/**
* sci_base_request_construct() - Construct the base request.
* @this_request: This parameter specifies the base request to be constructed.
* @state_table: This parameter specifies the table of state definitions to be
* utilized for the request state machine.
*
*/
static inline void sci_base_request_construct(
struct sci_base_request *base_req,
const struct sci_base_state *my_state_table)
{
base_req->parent.private = NULL;
sci_base_state_machine_construct(
&base_req->state_machine,
&base_req->parent,
my_state_table,
SCI_BASE_REQUEST_STATE_INITIAL
);
sci_base_state_machine_start(
&base_req->state_machine
);
}
#endif /* _SCI_BASE_REQUST_H_ */
......@@ -2161,7 +2161,7 @@ enum sci_status scic_controller_reset(
enum sci_io_status scic_controller_start_io(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *remote_device,
struct scic_sds_request *io_request,
struct scic_sds_request *request,
u16 io_tag)
{
u32 state;
......@@ -2172,7 +2172,7 @@ enum sci_io_status scic_controller_start_io(
return start_io(scic,
(struct sci_base_remote_device *) remote_device,
(struct sci_base_request *)io_request, io_tag);
request, io_tag);
}
/**
......@@ -2204,7 +2204,7 @@ enum sci_status scic_controller_terminate_request(
return terminate_request(scic,
(struct sci_base_remote_device *)remote_device,
(struct sci_base_request *)request);
request);
}
/**
......@@ -2232,7 +2232,7 @@ enum sci_status scic_controller_terminate_request(
enum sci_status scic_controller_complete_io(
struct scic_sds_controller *scic,
struct scic_sds_remote_device *remote_device,
struct scic_sds_request *io_request)
struct scic_sds_request *request)
{
u32 state;
scic_sds_controller_request_handler_t complete_io;
......@@ -2242,7 +2242,7 @@ enum sci_status scic_controller_complete_io(
return complete_io(scic,
(struct sci_base_remote_device *)remote_device,
(struct sci_base_request *)io_request);
request);
}
/**
......@@ -2289,7 +2289,7 @@ enum sci_task_status scic_controller_start_task(
if (start_task)
status = start_task(scic,
(struct sci_base_remote_device *)remote_device,
(struct sci_base_request *)task_request,
task_request,
task_tag);
else
dev_warn(scic_to_dev(scic),
......@@ -2329,7 +2329,7 @@ enum sci_status scic_controller_complete_task(
if (complete_task)
status = complete_task(scic,
(struct sci_base_remote_device *)remote_device,
(struct sci_base_request *)task_request);
task_request);
else
dev_warn(scic_to_dev(scic),
"%s: SCIC Controller completing task from invalid "
......@@ -2825,7 +2825,7 @@ default_controller_handler(struct scic_sds_controller *scic, const char *func)
static enum sci_status scic_sds_controller_default_start_operation_handler(
struct scic_sds_controller *scic,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request,
struct scic_sds_request *request,
u16 io_tag)
{
return default_controller_handler(scic, __func__);
......@@ -2834,7 +2834,7 @@ static enum sci_status scic_sds_controller_default_start_operation_handler(
static enum sci_status scic_sds_controller_default_request_handler(
struct scic_sds_controller *scic,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request)
struct scic_sds_request *request)
{
return default_controller_handler(scic, __func__);
}
......@@ -3186,26 +3186,24 @@ static enum sci_status scic_sds_controller_ready_state_stop_handler(
static enum sci_status scic_sds_controller_ready_state_start_io_handler(
struct scic_sds_controller *controller,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request,
struct scic_sds_request *request,
u16 io_tag)
{
enum sci_status status;
struct scic_sds_request *the_request;
struct scic_sds_remote_device *the_device;
the_request = (struct scic_sds_request *)io_request;
the_device = (struct scic_sds_remote_device *)remote_device;
status = scic_sds_remote_device_start_io(controller, the_device, the_request);
status = scic_sds_remote_device_start_io(controller, the_device, request);
if (status != SCI_SUCCESS)
return status;
controller->io_request_table[
scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
scic_sds_io_tag_get_index(request->io_tag)] = request;
scic_sds_controller_post_request(controller,
scic_sds_request_get_post_context(the_request));
scic_sds_request_get_post_context(request));
return SCI_SUCCESS;
}
......@@ -3220,22 +3218,20 @@ static enum sci_status scic_sds_controller_ready_state_start_io_handler(
static enum sci_status scic_sds_controller_ready_state_complete_io_handler(
struct scic_sds_controller *controller,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request)
struct scic_sds_request *request)
{
u16 index;
enum sci_status status;
struct scic_sds_request *the_request;
struct scic_sds_remote_device *the_device;
the_request = (struct scic_sds_request *)io_request;
the_device = (struct scic_sds_remote_device *)remote_device;
status = scic_sds_remote_device_complete_io(controller, the_device,
the_request);
request);
if (status != SCI_SUCCESS)
return status;
index = scic_sds_io_tag_get_index(the_request->io_tag);
index = scic_sds_io_tag_get_index(request->io_tag);
controller->io_request_table[index] = NULL;
return SCI_SUCCESS;
}
......@@ -3247,16 +3243,12 @@ static enum sci_status scic_sds_controller_ready_state_complete_io_handler(
static enum sci_status scic_sds_controller_ready_state_continue_io_handler(
struct scic_sds_controller *controller,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request)
struct scic_sds_request *request)
{
struct scic_sds_request *the_request;
the_request = (struct scic_sds_request *)io_request;
controller->io_request_table[
scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
scic_sds_io_tag_get_index(request->io_tag)] = request;
scic_sds_controller_post_request(controller,
scic_sds_request_get_post_context(the_request));
scic_sds_request_get_post_context(request));
return SCI_SUCCESS;
}
......@@ -3273,27 +3265,25 @@ static enum sci_status scic_sds_controller_ready_state_continue_io_handler(
static enum sci_status scic_sds_controller_ready_state_start_task_handler(
struct scic_sds_controller *controller,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request,
struct scic_sds_request *request,
u16 task_tag)
{
struct scic_sds_request *the_request = (struct scic_sds_request *)
io_request;
struct scic_sds_remote_device *the_device = (struct scic_sds_remote_device *)
remote_device;
enum sci_status status;
status = scic_sds_remote_device_start_task(controller, the_device,
the_request);
request);
if (status == SCI_SUCCESS) {
controller->io_request_table[
scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
scic_sds_io_tag_get_index(request->io_tag)] = request;
scic_sds_controller_post_request(controller,
scic_sds_request_get_post_context(the_request));
scic_sds_request_get_post_context(request));
} else if (status == SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS) {
controller->io_request_table[
scic_sds_io_tag_get_index(the_request->io_tag)] = the_request;
scic_sds_io_tag_get_index(request->io_tag)] = request;
/*
* We will let framework know this task request started successfully,
......@@ -3315,13 +3305,11 @@ static enum sci_status scic_sds_controller_ready_state_start_task_handler(
static enum sci_status scic_sds_controller_ready_state_terminate_request_handler(
struct scic_sds_controller *controller,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request)
struct scic_sds_request *request)
{
struct scic_sds_request *the_request = (struct scic_sds_request *)
io_request;
enum sci_status status;
status = scic_sds_io_request_terminate(the_request);
status = scic_sds_io_request_terminate(request);
if (status != SCI_SUCCESS)
return status;
......@@ -3330,7 +3318,7 @@ static enum sci_status scic_sds_controller_ready_state_terminate_request_handler
* request sub-type.
*/
scic_sds_controller_post_request(controller,
scic_sds_request_get_post_context(the_request) |
scic_sds_request_get_post_context(request) |
SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT);
return SCI_SUCCESS;
}
......@@ -3391,7 +3379,7 @@ static void scic_sds_controller_ready_state_link_down_handler(
static enum sci_status scic_sds_controller_stopping_state_complete_io_handler(
struct scic_sds_controller *controller,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request)
struct scic_sds_request *request)
{
/* XXX: Implement this function */
return SCI_FAILURE;
......
......@@ -86,7 +86,6 @@
struct sci_base_remote_device;
struct scic_sds_remote_device;
struct sci_base_request;
struct scic_sds_request;
struct scic_sds_controller;
......@@ -487,11 +486,11 @@ typedef enum sci_status (*scic_sds_controller_timed_handler_t)
typedef enum sci_status (*scic_sds_controller_request_handler_t)
(struct scic_sds_controller *,
struct sci_base_remote_device *,
struct sci_base_request *);
struct scic_sds_request *);
typedef enum sci_status (*scic_sds_controller_start_request_handler_t)
(struct scic_sds_controller *,
struct sci_base_remote_device *,
struct sci_base_request *, u16);
struct scic_sds_request *, u16);
typedef void (*scic_sds_controller_phy_handler_t)
(struct scic_sds_controller *,
struct scic_sds_port *,
......
......@@ -1090,15 +1090,7 @@ static enum sci_status scic_sds_port_ready_substate_stop_handler(
return SCI_SUCCESS;
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
* @device: This is the struct sci_base_remote_device object which is not used in this
* function.
* @io_request: This is the struct sci_base_request object which is not used in this
* function.
*
/*
* This method is the general ready substate complete io handler for the
* struct scic_sds_port object. This function decrments the outstanding request count
* for this port object. enum sci_status SCI_SUCCESS
......@@ -1194,15 +1186,7 @@ static void scic_sds_port_ready_waiting_substate_link_up_handler(
);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
* @device: This is the struct sci_base_remote_device object which is not used in this
* request.
* @io_request: This is the struct sci_base_request object which is not used in this
* function.
*
/*
* This method is the ready waiting substate start io handler for the
* struct scic_sds_port object. The port object can not accept new requests so the
* request is failed. enum sci_status SCI_FAILURE_INVALID_STATE
......@@ -1316,15 +1300,7 @@ static void scic_sds_port_ready_operational_substate_link_down_handler(
SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
* @device: This is the struct sci_base_remote_device object which is not used in this
* function.
* @io_request: This is the struct sci_base_request object which is not used in this
* function.
*
/*
* This method is the ready operational substate start io handler for the
* struct scic_sds_port object. This function incremetns the outstanding request
* count for this port object. enum sci_status SCI_SUCCESS
......
......@@ -363,7 +363,7 @@ enum sci_status scic_sds_remote_device_start_io(
struct scic_sds_request *io_request)
{
return this_device->state_handlers->parent.start_io_handler(
&this_device->parent, &io_request->parent);
&this_device->parent, io_request);
}
/**
......@@ -381,7 +381,7 @@ enum sci_status scic_sds_remote_device_complete_io(
struct scic_sds_request *io_request)
{
return this_device->state_handlers->parent.complete_io_handler(
&this_device->parent, &io_request->parent);
&this_device->parent, io_request);
}
/**
......@@ -399,7 +399,7 @@ enum sci_status scic_sds_remote_device_start_task(
struct scic_sds_request *io_request)
{
return this_device->state_handlers->parent.start_task_handler(
&this_device->parent, &io_request->parent);
&this_device->parent, io_request);
}
/**
......@@ -567,7 +567,7 @@ void scic_sds_remote_device_continue_request(void *dev)
scic_sds_controller_request_handler_t continue_io;
continue_io = scic_sds_controller_state_handler_table[state].continue_io;
continue_io(scic, &sci_req->target_device->parent, &sci_req->parent);
continue_io(scic, &sci_req->target_device->parent, sci_req);
}
}
......@@ -792,21 +792,21 @@ enum sci_status scic_sds_remote_device_default_frame_handler(
enum sci_status scic_sds_remote_device_default_start_request_handler(
struct sci_base_remote_device *base_dev,
struct sci_base_request *request)
struct scic_sds_request *request)
{
return default_device_handler(base_dev, __func__);
}
enum sci_status scic_sds_remote_device_default_complete_request_handler(
struct sci_base_remote_device *base_dev,
struct sci_base_request *request)
struct scic_sds_request *request)
{
return default_device_handler(base_dev, __func__);
}
enum sci_status scic_sds_remote_device_default_continue_request_handler(
struct sci_base_remote_device *base_dev,
struct sci_base_request *request)
struct scic_sds_request *request)
{
return default_device_handler(base_dev, __func__);
}
......@@ -1019,13 +1019,7 @@ enum sci_status scic_sds_remote_device_ready_state_reset_handler(
return SCI_SUCCESS;
}
/**
*
* @device: The struct sci_base_remote_device which is cast to a
* struct scic_sds_remote_device for which the request is to be started.
* @request: The struct sci_base_request which is cast to a SCIC_SDS_IO_REQUEST that
* is to be started.
*
/*
* This method will attempt to start a task request for this device object. The
* remote device object will issue the start request for the task and if
* successful it will start the request for the port object then increment its
......@@ -1035,38 +1029,28 @@ enum sci_status scic_sds_remote_device_ready_state_reset_handler(
*/
static enum sci_status scic_sds_remote_device_ready_state_start_task_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
enum sci_status result;
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device;
struct scic_sds_request *task_request = (struct scic_sds_request *)request;
/* See if the port is in a state where we can start the IO request */
result = scic_sds_port_start_io(
scic_sds_remote_device_get_port(this_device), this_device, task_request);
scic_sds_remote_device_get_port(this_device), this_device, request);
if (result == SCI_SUCCESS) {
result = scic_sds_remote_node_context_start_task(
this_device->rnc, task_request
);
if (result == SCI_SUCCESS) {
result = scic_sds_request_start(task_request);
}
this_device->rnc, request);
if (result == SCI_SUCCESS)
result = scic_sds_request_start(request);
scic_sds_remote_device_start_request(this_device, task_request, result);
scic_sds_remote_device_start_request(this_device, request, result);
}
return result;
}
/**
*
* @device: The struct sci_base_remote_device which is cast to a
* struct scic_sds_remote_device for which the request is to be started.
* @request: The struct sci_base_request which is cast to a SCIC_SDS_IO_REQUEST that
* is to be started.
*
/*
* This method will attempt to start an io request for this device object. The
* remote device object will issue the start request for the io and if
* successful it will start the request for the port object then increment its
......@@ -1076,38 +1060,28 @@ static enum sci_status scic_sds_remote_device_ready_state_start_task_handler(
*/
static enum sci_status scic_sds_remote_device_ready_state_start_io_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
enum sci_status result;
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device;
struct scic_sds_request *io_request = (struct scic_sds_request *)request;
/* See if the port is in a state where we can start the IO request */
result = scic_sds_port_start_io(
scic_sds_remote_device_get_port(this_device), this_device, io_request);
scic_sds_remote_device_get_port(this_device), this_device, request);
if (result == SCI_SUCCESS) {
result = scic_sds_remote_node_context_start_io(
this_device->rnc, io_request
);
this_device->rnc, request);
if (result == SCI_SUCCESS)
result = scic_sds_request_start(request);
if (result == SCI_SUCCESS) {
result = scic_sds_request_start(io_request);
}
scic_sds_remote_device_start_request(this_device, io_request, result);
scic_sds_remote_device_start_request(this_device, request, result);
}
return result;
}
/**
*
* @device: The struct sci_base_remote_device which is cast to a
* struct scic_sds_remote_device for which the request is to be completed.
* @request: The struct sci_base_request which is cast to a SCIC_SDS_IO_REQUEST that
* is to be completed.
*
/*
* This method will complete the request for the remote device object. The
* method will call the completion handler for the request object and if
* successful it will complete the request on the port object then decrement
......@@ -1115,18 +1089,17 @@ static enum sci_status scic_sds_remote_device_ready_state_start_io_handler(
*/
static enum sci_status scic_sds_remote_device_ready_state_complete_request_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
enum sci_status result;
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device;
struct scic_sds_request *the_request = (struct scic_sds_request *)request;
result = scic_sds_request_complete(the_request);
result = scic_sds_request_complete(request);
if (result == SCI_SUCCESS) {
/* See if the port is in a state where we can start the IO request */
result = scic_sds_port_complete_io(
scic_sds_remote_device_get_port(this_device), this_device, the_request);
scic_sds_remote_device_get_port(this_device), this_device, request);
if (result == SCI_SUCCESS) {
scic_sds_remote_device_decrement_request_count(this_device);
......@@ -1178,19 +1151,16 @@ static enum sci_status scic_sds_remote_device_stopping_state_stop_handler(
*/
static enum sci_status scic_sds_remote_device_stopping_state_complete_request_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
enum sci_status status = SCI_SUCCESS;
struct scic_sds_request *this_request = (struct scic_sds_request *)request;
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device;
status = scic_sds_request_complete(this_request);
status = scic_sds_request_complete(request);
if (status == SCI_SUCCESS) {
status = scic_sds_port_complete_io(
scic_sds_remote_device_get_port(this_device),
this_device,
this_request
);
this_device, request);
if (status == SCI_SUCCESS) {
scic_sds_remote_device_decrement_request_count(this_device);
......@@ -1255,11 +1225,7 @@ static enum sci_status scic_sds_remote_device_resetting_state_stop_handler(
return SCI_SUCCESS;
}
/**
*
* @device: The device object for which the request is completing.
* @request: The task request that is being completed.
*
/*
* This method completes requests for this struct scic_sds_remote_device while it is
* in the SCI_BASE_REMOTE_DEVICE_STATE_RESETTING state. This method calls the
* complete method for the request object and if that is successful the port
......@@ -1268,17 +1234,16 @@ static enum sci_status scic_sds_remote_device_resetting_state_stop_handler(
*/
static enum sci_status scic_sds_remote_device_resetting_state_complete_request_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
enum sci_status status = SCI_SUCCESS;
struct scic_sds_request *this_request = (struct scic_sds_request *)request;
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device;
status = scic_sds_request_complete(this_request);
status = scic_sds_request_complete(request);
if (status == SCI_SUCCESS) {
status = scic_sds_port_complete_io(
scic_sds_remote_device_get_port(this_device), this_device, this_request);
scic_sds_remote_device_get_port(this_device), this_device, request);
if (status == SCI_SUCCESS) {
scic_sds_remote_device_decrement_request_count(this_device);
......
......@@ -65,7 +65,6 @@
#include "intel_sas.h"
#include "sci_base_remote_device.h"
#include "sci_base_request.h"
#include "scu_remote_node_context.h"
#include "scic_sds_remote_node_context.h"
......@@ -507,15 +506,15 @@ enum sci_status scic_sds_remote_device_default_reset_complete_handler(
enum sci_status scic_sds_remote_device_default_start_request_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request);
struct scic_sds_request *request);
enum sci_status scic_sds_remote_device_default_complete_request_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request);
struct scic_sds_request *request);
enum sci_status scic_sds_remote_device_default_continue_request_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request);
struct scic_sds_request *request);
enum sci_status scic_sds_remote_device_default_suspend_handler(
struct scic_sds_remote_device *this_device,
......
This diff is collapsed.
......@@ -64,8 +64,7 @@
*/
#include "scic_io_request.h"
#include "sci_base_request.h"
#include "sci_base_state_machine.h"
#include "scu_task_context.h"
#include "intel_sas.h"
......@@ -127,9 +126,15 @@ enum scic_sds_smp_request_started_substates {
*/
struct scic_sds_request {
/**
* This field indictes the parent object of the request.
* The field specifies that the parent object for the base request is the
* base object itself.
*/
struct sci_base_request parent;
struct sci_base_object parent;
/**
* This field contains the information for the base request state machine.
*/
struct sci_base_state_machine state_machine;
void *user_request;
......@@ -231,15 +236,59 @@ struct scic_sds_request {
};
/**
* enum sci_base_request_states - This enumeration depicts all the states for
* the common request state machine.
*
*
*/
enum sci_base_request_states {
/**
* Simply the initial state for the base request state machine.
*/
SCI_BASE_REQUEST_STATE_INITIAL,
/**
* This state indicates that the request has been constructed. This state
* is entered from the INITIAL state.
*/
SCI_BASE_REQUEST_STATE_CONSTRUCTED,
/**
* This state indicates that the request has been started. This state is
* entered from the CONSTRUCTED state.
*/
SCI_BASE_REQUEST_STATE_STARTED,
/**
* This state indicates that the request has completed.
* This state is entered from the STARTED state. This state is entered from
* the ABORTING state.
*/
SCI_BASE_REQUEST_STATE_COMPLETED,
typedef enum sci_status
(*scic_sds_io_request_frame_handler_t)(struct scic_sds_request *req, u32 frame);
/**
* This state indicates that the request is in the process of being
* terminated/aborted.
* This state is entered from the CONSTRUCTED state.
* This state is entered from the STARTED state.
*/
SCI_BASE_REQUEST_STATE_ABORTING,
typedef enum sci_status
(*scic_sds_io_request_event_handler_t)(struct scic_sds_request *req, u32 event);
/**
* Simply the final state for the base request state machine.
*/
SCI_BASE_REQUEST_STATE_FINAL,
};
typedef enum sci_status
(*scic_sds_io_request_task_completion_handler_t)(struct scic_sds_request *req, u32 completion_code);
typedef enum sci_status (*scic_sds_io_request_handler_t)
(struct scic_sds_request *request);
typedef enum sci_status (*scic_sds_io_request_frame_handler_t)
(struct scic_sds_request *req, u32 frame);
typedef enum sci_status (*scic_sds_io_request_event_handler_t)
(struct scic_sds_request *req, u32 event);
typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t)
(struct scic_sds_request *req, u32 completion_code);
/**
* struct scic_sds_io_request_state_handler - This is the SDS core definition
......@@ -248,7 +297,30 @@ typedef enum sci_status
*
*/
struct scic_sds_io_request_state_handler {
struct sci_base_request_state_handler parent;
/**
* The start_handler specifies the method invoked when a user attempts to
* start a request.
*/
scic_sds_io_request_handler_t start_handler;
/**
* The abort_handler specifies the method invoked when a user attempts to
* abort a request.
*/
scic_sds_io_request_handler_t abort_handler;
/**
* The complete_handler specifies the method invoked when a user attempts to
* complete a request.
*/
scic_sds_io_request_handler_t complete_handler;
/**
* The destruct_handler specifies the method invoked when a user attempts to
* destruct a request.
*/
scic_sds_io_request_handler_t destruct_handler;
scic_sds_io_request_task_completion_handler_t tc_completion_handler;
scic_sds_io_request_event_handler_t event_handler;
......@@ -319,7 +391,7 @@ extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substat
}
#define scic_sds_request_complete(a_request) \
((a_request)->state_handlers->parent.complete_handler(&(a_request)->parent))
((a_request)->state_handlers->complete_handler(a_request))
......@@ -331,15 +403,15 @@ extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substat
* struct scic_sds_io_request object.
*/
#define scic_sds_io_request_tc_completion(this_request, completion_code) \
{ \
if (this_request->parent.state_machine.current_state_id \
== SCI_BASE_REQUEST_STATE_STARTED \
&& this_request->has_started_substate_machine \
== false) \
scic_sds_request_started_state_tc_completion_handler(this_request, completion_code); \
else \
this_request->state_handlers->tc_completion_handler(this_request, completion_code); \
}
{ \
if (this_request->state_machine.current_state_id \
== SCI_BASE_REQUEST_STATE_STARTED \
&& this_request->has_started_substate_machine \
== false) \
scic_sds_request_started_state_tc_completion_handler(this_request, completion_code); \
else \
this_request->state_handlers->tc_completion_handler(this_request, completion_code); \
}
/**
* SCU_SGL_ZERO() -
......@@ -426,14 +498,14 @@ enum sci_status scic_sds_task_request_terminate(
* ***************************************************************************** */
enum sci_status scic_sds_request_default_start_handler(
struct sci_base_request *this_request);
struct scic_sds_request *request);
enum sci_status scic_sds_request_default_complete_handler(
struct sci_base_request *this_request);
struct scic_sds_request *request);
enum sci_status scic_sds_request_default_destruct_handler(
struct sci_base_request *this_request);
struct scic_sds_request *request);
enum sci_status scic_sds_request_default_tc_completion_handler(
struct scic_sds_request *this_request,
......@@ -453,7 +525,7 @@ enum sci_status scic_sds_request_default_frame_handler(
* ***************************************************************************** */
enum sci_status scic_sds_request_started_state_abort_handler(
struct sci_base_request *this_request);
struct scic_sds_request *request);
enum sci_status scic_sds_request_started_state_tc_completion_handler(
struct scic_sds_request *this_request,
......
......@@ -78,29 +78,24 @@
*/
static enum sci_status scic_sds_smp_remote_device_ready_idle_substate_start_io_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
enum sci_status status;
struct scic_sds_remote_device *this_device = (struct scic_sds_remote_device *)device;
struct scic_sds_request *io_request = (struct scic_sds_request *)request;
/* Will the port allow the io request to start? */
status = this_device->owning_port->state_handlers->start_io_handler(
this_device->owning_port,
this_device,
io_request
);
this_device->owning_port, this_device, request);
if (status == SCI_SUCCESS) {
status =
scic_sds_remote_node_context_start_io(this_device->rnc, io_request);
scic_sds_remote_node_context_start_io(this_device->rnc, request);
if (status == SCI_SUCCESS) {
status = scic_sds_request_start(io_request);
}
if (status == SCI_SUCCESS)
status = scic_sds_request_start(request);
if (status == SCI_SUCCESS) {
this_device->working_request = io_request;
this_device->working_request = request;
sci_base_state_machine_change_state(
&this_device->ready_substate_machine,
......@@ -108,7 +103,7 @@ static enum sci_status scic_sds_smp_remote_device_ready_idle_substate_start_io_h
);
}
scic_sds_remote_device_start_request(this_device, io_request, status);
scic_sds_remote_device_start_request(this_device, request, status);
}
return status;
......@@ -129,7 +124,7 @@ static enum sci_status scic_sds_smp_remote_device_ready_idle_substate_start_io_h
*/
static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_start_io_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
return SCI_FAILURE_INVALID_STATE;
}
......@@ -144,7 +139,7 @@ static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_start_io_ha
*/
static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_complete_io_handler(
struct sci_base_remote_device *device,
struct sci_base_request *request)
struct scic_sds_request *request)
{
enum sci_status status;
struct scic_sds_remote_device *this_device;
......
......@@ -394,7 +394,7 @@ static enum sci_status scic_sds_smp_request_await_response_frame_handler(
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
&this_request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
}
......@@ -433,9 +433,8 @@ static enum sci_status scic_sds_smp_request_await_response_tc_completion_handler
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
&this_request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR):
......@@ -452,9 +451,8 @@ static enum sci_status scic_sds_smp_request_await_response_tc_completion_handler
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
&this_request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
break;
default:
......@@ -468,9 +466,8 @@ static enum sci_status scic_sds_smp_request_await_response_tc_completion_handler
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
&this_request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
break;
}
......@@ -502,9 +499,8 @@ static enum sci_status scic_sds_smp_request_await_tc_completion_tc_completion_ha
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
&this_request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
break;
default:
......@@ -518,9 +514,8 @@ static enum sci_status scic_sds_smp_request_await_tc_completion_tc_completion_ha
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
&this_request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
break;
}
......@@ -530,22 +525,22 @@ static enum sci_status scic_sds_smp_request_await_tc_completion_tc_completion_ha
static const struct scic_sds_io_request_state_handler scic_sds_smp_request_started_substate_handler_table[] = {
[SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_smp_request_await_response_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_smp_request_await_response_frame_handler,
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_smp_request_await_response_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_smp_request_await_response_frame_handler,
},
[SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_smp_request_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_smp_request_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
}
};
......@@ -626,7 +621,7 @@ enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req)
/* Construct the started sub-state machine. */
sci_base_state_machine_construct(
&sci_req->started_substate_machine,
&sci_req->parent.parent,
&sci_req->parent,
scic_sds_smp_request_started_substate_table,
SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE
);
......@@ -657,10 +652,8 @@ enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req)
scu_smp_request_construct_task_context(sci_req, smp_req);
sci_base_state_machine_change_state(
&sci_req->parent.state_machine,
SCI_BASE_REQUEST_STATE_CONSTRUCTED
);
sci_base_state_machine_change_state(&sci_req->state_machine,
SCI_BASE_REQUEST_STATE_CONSTRUCTED);
kfree(smp_req);
......
......@@ -120,10 +120,8 @@ static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completi
SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
sci_base_state_machine_change_state(&this_request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
break;
}
......@@ -143,20 +141,12 @@ static enum sci_status scic_sds_ssp_task_request_await_tc_completion_tc_completi
* pattern for this particular device).
*/
static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler(
struct sci_base_request *request)
struct scic_sds_request *request)
{
struct scic_sds_request *this_request = (struct scic_sds_request *)request;
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_ABORTING
);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
sci_base_state_machine_change_state(&request->state_machine,
SCI_BASE_REQUEST_STATE_ABORTING);
sci_base_state_machine_change_state(&request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
return SCI_SUCCESS;
}
......@@ -176,41 +166,36 @@ static enum sci_status scic_sds_ssp_task_request_await_tc_response_abort_handler
* probably update to check frame type and make sure it is a response frame.
*/
static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler(
struct scic_sds_request *this_request,
struct scic_sds_request *request,
u32 frame_index)
{
scic_sds_io_request_copy_response(this_request);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
scic_sds_controller_release_frame(
this_request->owning_controller, frame_index
);
scic_sds_io_request_copy_response(request);
sci_base_state_machine_change_state(&request->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
scic_sds_controller_release_frame(request->owning_controller,
frame_index);
return SCI_SUCCESS;
}
static const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = {
[SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_request_started_state_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_ssp_task_request_await_tc_completion_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_default_frame_handler,
},
[SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE] = {
.parent.start_handler = scic_sds_request_default_start_handler,
.parent.abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
.parent.complete_handler = scic_sds_request_default_complete_handler,
.parent.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
.start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_ssp_task_request_await_tc_response_abort_handler,
.complete_handler = scic_sds_request_default_complete_handler,
.destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_default_tc_completion_handler,
.event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_ssp_task_request_await_tc_response_frame_handler,
}
};
......
......@@ -659,16 +659,12 @@ enum sci_status scic_sds_stp_packet_request_command_phase_await_d2h_fis_frame_ha
}
enum sci_status scic_sds_stp_packet_request_started_completion_delay_complete_handler(
struct sci_base_request *request)
struct scic_sds_request *request)
{
struct scic_sds_request *this_request = (struct scic_sds_request *)request;
sci_base_state_machine_change_state(&request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
sci_base_state_machine_change_state(
&this_request->parent.state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED
);
return this_request->sci_status;
return request->sci_status;
}
/* --------------------------------------------------------------------------- */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment