提交 068b2c03 编写于 作者: D Dan Williams

isci: kill some long macros

Delete some macros that are longer to type than the open coded operation
that they perform.

scic_sds_phy_get_base_state_machine
scic_sds_phy_get_starting_substate_machine
scic_sds_port_get_base_state_machine
scic_sds_port_get_ready_substate_machine
scic_sds_remote_device_get_base_state_machine
scic_sds_remote_device_get_ready_substate_machine
scic_sds_remote_node_context_set_remote_node_index
scic_sds_controller_get_base_state_machine

Also performs some collateral cleanups like killing casts that assume
structure member ordering, and consolidating a lot of duplicated default
handler code (the primary callers of the *_get_base_state_machine macros) via
a helper.
Reported-by: NChristoph Hellwig <hch@infradead.org>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
上级 f942f32e
......@@ -739,9 +739,8 @@ static void scic_sds_controller_transition_to_ready(
* We move into the ready state, because some of the phys/ports
* may be up and operational.
*/
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_READY);
sci_base_state_machine_change_state(&scic->parent.state_machine,
SCI_BASE_CONTROLLER_STATE_READY);
isci_host_start_complete(ihost, status);
}
......@@ -751,18 +750,12 @@ void scic_sds_controller_timeout_handler(void *_scic)
{
struct scic_sds_controller *scic = _scic;
struct isci_host *ihost = sci_object_get_association(scic);
enum sci_base_controller_states current_state;
current_state = sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(scic));
struct sci_base_state_machine *sm = &scic->parent.state_machine;
if (current_state == SCI_BASE_CONTROLLER_STATE_STARTING) {
scic_sds_controller_transition_to_ready(
scic, SCI_FAILURE_TIMEOUT);
} else if (current_state == SCI_BASE_CONTROLLER_STATE_STOPPING) {
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_FAILED);
if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STARTING)
scic_sds_controller_transition_to_ready(scic, SCI_FAILURE_TIMEOUT);
else if (sm->current_state_id == SCI_BASE_CONTROLLER_STATE_STOPPING) {
sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_FAILED);
isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT);
} else /* / @todo Now what do we want to do in this case? */
dev_err(scic_to_dev(scic),
......@@ -1619,16 +1612,15 @@ void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
dev_err(scic_to_dev(scic), "%s: status: %#x\n", __func__,
interrupt_status);
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_FAILED);
sci_base_state_machine_change_state(&scic->parent.state_machine,
SCI_BASE_CONTROLLER_STATE_FAILED);
return;
}
/*
* If we dont process any completions I am not sure that we want to do this.
* We are in the middle of a hardware fault and should probably be reset. */
/* If we dont process any completions I am not sure that we want to do this.
* We are in the middle of a hardware fault and should probably be reset.
*/
SMU_IMR_WRITE(scic, 0x00000000);
}
......@@ -1655,12 +1647,8 @@ void scic_sds_controller_link_up(
else
dev_dbg(scic_to_dev(scic),
"%s: SCIC Controller linkup event from phy %d in "
"unexpected state %d\n",
__func__,
sci_phy->phy_index,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
"unexpected state %d\n", __func__, sci_phy->phy_index,
state);
}
......@@ -2125,11 +2113,7 @@ enum sci_status scic_controller_initialize(
else
dev_warn(scic_to_dev(scic),
"%s: SCIC Controller initialize operation requested "
"in invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
"in invalid state %d\n", __func__, state);
return status;
}
......@@ -2180,11 +2164,7 @@ enum sci_status scic_controller_start(
else
dev_warn(scic_to_dev(scic),
"%s: SCIC Controller start operation requested in "
"invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
"invalid state %d\n", __func__, state);
return status;
}
......@@ -2207,11 +2187,7 @@ enum sci_status scic_controller_stop(
else
dev_warn(scic_to_dev(scic),
"%s: SCIC Controller stop operation requested in "
"invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
"invalid state %d\n", __func__, state);
return status;
}
......@@ -2233,11 +2209,7 @@ enum sci_status scic_controller_reset(
else
dev_warn(scic_to_dev(scic),
"%s: SCIC Controller reset operation requested in "
"invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
scic)));
"invalid state %d\n", __func__, state);
return status;
}
......@@ -2765,128 +2737,57 @@ struct scic_sds_controller *scic_controller_alloc(struct device *dev)
return devm_kzalloc(dev, sizeof(struct scic_sds_controller), GFP_KERNEL);
}
/*
* *****************************************************************************
* * DEFAULT STATE HANDLERS
* ***************************************************************************** */
static enum sci_status default_controller_handler(struct sci_base_controller *base_scic,
const char *func)
{
struct scic_sds_controller *scic = container_of(base_scic, typeof(*scic), parent);
u32 state = base_scic->state_machine.current_state_id;
dev_warn(scic_to_dev(scic), "%s: invalid state %d\n", func, state);
return SCI_FAILURE_INVALID_STATE;
}
/**
*
* @controller: This is struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
* @remote_device: This is struct sci_base_remote_device which, if it was used, would
* be cast to a struct scic_sds_remote_device.
* @io_request: This is the struct sci_base_request which, if it was used, would be
* cast to a SCIC_SDS_IO_REQUEST.
* @io_tag: This is the IO tag to be assigned to the IO request or
* SCI_CONTROLLER_INVALID_IO_TAG.
*
* This method is called when the struct scic_sds_controller default start io/task
* handler is in place. - Issue a warning message enum sci_status
* SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_controller_default_start_operation_handler(
struct sci_base_controller *controller,
struct sci_base_controller *base_scic,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request,
u16 io_tag)
{
struct scic_sds_controller *this_controller;
this_controller = (struct scic_sds_controller *)controller;
dev_warn(scic_to_dev(this_controller),
"%s: SCIC Controller requested to start an io/task from "
"invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
this_controller)));
return SCI_FAILURE_INVALID_STATE;
return default_controller_handler(base_scic, __func__);
}
/**
*
* @controller: This is struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
* @remote_device: This is struct sci_base_remote_device which, if it was used, would
* be cast to a struct scic_sds_remote_device.
* @io_request: This is the struct sci_base_request which, if it was used, would be
* cast to a SCIC_SDS_IO_REQUEST.
*
* This method is called when the struct scic_sds_controller default request handler
* is in place. - Issue a warning message enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_controller_default_request_handler(
struct sci_base_controller *controller,
struct sci_base_controller *base_scic,
struct sci_base_remote_device *remote_device,
struct sci_base_request *io_request)
{
struct scic_sds_controller *this_controller;
this_controller = (struct scic_sds_controller *)controller;
dev_warn(scic_to_dev(this_controller),
"%s: SCIC Controller request operation from invalid state %d\n",
__func__,
sci_base_state_machine_get_state(
scic_sds_controller_get_base_state_machine(
this_controller)));
return SCI_FAILURE_INVALID_STATE;
return default_controller_handler(base_scic, __func__);
}
/*
* *****************************************************************************
* * GENERAL (COMMON) STATE HANDLERS
* ***************************************************************************** */
/**
*
* @controller: The struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
*
* This method is called when the struct scic_sds_controller is in the ready state
* reset handler is in place. - Transition to
* SCI_BASE_CONTROLLER_STATE_RESETTING enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_controller_general_reset_handler(
struct sci_base_controller *controller)
static enum sci_status scic_sds_controller_general_reset_handler(struct sci_base_controller *base_scic)
{
struct scic_sds_controller *this_controller;
this_controller = (struct scic_sds_controller *)controller;
/*
* The reset operation is not a graceful cleanup just perform the state
* transition. */
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(this_controller),
SCI_BASE_CONTROLLER_STATE_RESETTING
);
/* The reset operation is not a graceful cleanup just perform the state
* transition.
*/
sci_base_state_machine_change_state(&base_scic->state_machine,
SCI_BASE_CONTROLLER_STATE_RESETTING);
return SCI_SUCCESS;
}
/*
* *****************************************************************************
* * RESET STATE HANDLERS
* ***************************************************************************** */
static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct sci_base_controller *base_scic)
{
struct sci_base_state_machine *sm = &base_scic->state_machine;
enum sci_status result = SCI_SUCCESS;
struct scic_sds_controller *scic;
struct isci_host *ihost;
u32 index;
u32 index, state;
scic = container_of(base_scic, typeof(*scic), parent);
ihost = sci_object_get_association(scic);
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_INITIALIZING);
sci_base_state_machine_change_state(sm, SCI_BASE_CONTROLLER_STATE_INITIALIZING);
scic->timeout_timer = isci_timer_create(ihost,
scic,
......@@ -3028,13 +2929,10 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct
/* Advance the controller state machine */
if (result == SCI_SUCCESS)
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_INITIALIZED);
state = SCI_BASE_CONTROLLER_STATE_INITIALIZED;
else
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_FAILED);
state = SCI_BASE_CONTROLLER_STATE_FAILED;
sci_base_state_machine_change_state(sm, state);
return result;
}
......@@ -3065,14 +2963,14 @@ static enum sci_status scic_sds_controller_reset_state_initialize_handler(struct
* descriptor fields is invalid.
*/
static enum sci_status scic_sds_controller_initialized_state_start_handler(
struct sci_base_controller *controller,
struct sci_base_controller *base_scic,
u32 timeout)
{
u16 index;
enum sci_status result;
struct scic_sds_controller *scic;
scic = (struct scic_sds_controller *)controller;
scic = container_of(base_scic, typeof(*scic), parent);
/*
* Make sure that the SCI User filled in the memory descriptor
......@@ -3135,9 +3033,8 @@ static enum sci_status scic_sds_controller_initialized_state_start_handler(
isci_timer_start(scic->timeout_timer, timeout);
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_STARTING);
sci_base_state_machine_change_state(&base_scic->state_machine,
SCI_BASE_CONTROLLER_STATE_STARTING);
}
return result;
......@@ -3197,33 +3094,15 @@ static void scic_sds_controller_starting_state_link_down_handler(
/* scic_sds_port_link_down(port, phy); */
}
/*
* *****************************************************************************
* * READY STATE HANDLERS
* ***************************************************************************** */
/**
*
* @controller: The struct sci_base_controller object which is cast into a
* struct scic_sds_controller object.
* @timeout: The timeout for when the stop operation should report a failure.
*
* This method is called when the struct scic_sds_controller is in the ready state
* stop handler is called. - Start the timeout timer - Transition to
* SCI_BASE_CONTROLLER_STATE_STOPPING. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_controller_ready_state_stop_handler(
struct sci_base_controller *controller,
u32 timeout)
static enum sci_status scic_sds_controller_ready_state_stop_handler(struct sci_base_controller *base_scic,
u32 timeout)
{
struct scic_sds_controller *scic =
(struct scic_sds_controller *)controller;
struct scic_sds_controller *scic;
scic = container_of(base_scic, typeof(*scic), parent);
isci_timer_start(scic->timeout_timer, timeout);
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(scic),
SCI_BASE_CONTROLLER_STATE_STOPPING);
sci_base_state_machine_change_state(&base_scic->state_machine,
SCI_BASE_CONTROLLER_STATE_STOPPING);
return SCI_SUCCESS;
}
......@@ -3749,33 +3628,16 @@ static inline void scic_sds_controller_stopping_state_exit(
isci_timer_stop(scic->timeout_timer);
}
/**
*
* @object: This is the struct sci_base_object which is cast to a struct scic_sds_controller
* object.
*
* This method implements the actions taken by the struct scic_sds_controller on entry
* to the SCI_BASE_CONTROLLER_STATE_RESETTING. - Set the state handlers to the
* controllers resetting state. - Write to the SCU hardware reset register to
* force a reset - Transition to the SCI_BASE_CONTROLLER_STATE_RESET none
*/
static void scic_sds_controller_resetting_state_enter(
struct sci_base_object *object)
static void scic_sds_controller_resetting_state_enter(struct sci_base_object *object)
{
struct scic_sds_controller *this_controller;
this_controller = (struct scic_sds_controller *)object;
scic_sds_controller_reset_hardware(this_controller);
struct scic_sds_controller *scic;
sci_base_state_machine_change_state(
scic_sds_controller_get_base_state_machine(this_controller),
SCI_BASE_CONTROLLER_STATE_RESET
);
scic = container_of(object, typeof(*scic), parent.parent);
scic_sds_controller_reset_hardware(scic);
sci_base_state_machine_change_state(&scic->parent.state_machine,
SCI_BASE_CONTROLLER_STATE_RESET);
}
/* --------------------------------------------------------------------------- */
const struct sci_base_state scic_sds_controller_state_table[] = {
[SCI_BASE_CONTROLLER_STATE_INITIAL] = {
.enter_state = scic_sds_controller_initial_state_enter,
......@@ -3800,4 +3662,3 @@ const struct sci_base_state scic_sds_controller_state_table[] = {
[SCI_BASE_CONTROLLER_STATE_STOPPED] = {},
[SCI_BASE_CONTROLLER_STATE_FAILED] = {}
};
......@@ -420,15 +420,6 @@ extern const struct sci_base_state scic_sds_controller_state_table[];
} \
}
/**
* scic_sds_controller_get_base_state_machine() -
*
* This is a helper macro that gets the base state machine for the controller
* object
*/
#define scic_sds_controller_get_base_state_machine(this_controller) \
(&(this_controller)->parent.state_machine)
/**
* scic_sds_controller_get_port_configuration_agent() -
*
......
......@@ -316,24 +316,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha
#define scic_sds_phy_get_controller(phy) \
(scic_sds_port_get_controller((phy)->owning_port))
/**
* scic_sds_phy_get_base_state_machine() - This macro returns the state machine
* for the base phy
*
*
*/
#define scic_sds_phy_get_base_state_machine(phy) \
(&(phy)->parent.state_machine)
/**
* scic_sds_phy_get_starting_substate_machine() - This macro returns the
* starting substate machine for this phy
*
*
*/
#define scic_sds_phy_get_starting_substate_machine(phy) \
(&(phy)->starting_substate_machine)
/**
* scic_sds_phy_set_state_handlers() - This macro sets the state handlers for
* this phy object
......@@ -354,27 +336,6 @@ extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_ha
&scic_sds_phy_state_handler_table[(state_id)] \
)
/**
* scic_sds_phy_is_ready() -
*
* This macro returns true if the current base state for this phy is
* SCI_BASE_PHY_STATE_READY
*/
#define scic_sds_phy_is_ready(phy) \
(\
SCI_BASE_PHY_STATE_READY \
== sci_base_state_machine_get_state(\
scic_sds_phy_get_base_state_machine(phy) \
) \
)
/* --------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------- */
void scic_sds_phy_construct(
struct scic_sds_phy *this_phy,
struct scic_sds_port *owning_port,
......@@ -404,8 +365,6 @@ enum sci_status scic_sds_phy_reset(
void scic_sds_phy_sata_timeout(
void *cookie);
/* --------------------------------------------------------------------------- */
void scic_sds_phy_suspend(
struct scic_sds_phy *this_phy);
......@@ -416,8 +375,6 @@ void scic_sds_phy_setup_transport(
struct scic_sds_phy *this_phy,
u32 device_id);
/* --------------------------------------------------------------------------- */
enum sci_status scic_sds_phy_event_handler(
struct scic_sds_phy *this_phy,
u32 event_code);
......@@ -445,11 +402,6 @@ void scic_sds_phy_get_attached_phy_protocols(
struct scic_sds_phy *this_phy,
struct sci_sas_identify_address_frame_protocols *protocols);
/*
* ****************************************************************************-
* * SCIC SDS PHY Handler Methods
* ****************************************************************************- */
enum sci_status scic_sds_phy_default_start_handler(
struct sci_base_phy *phy);
......
......@@ -576,12 +576,10 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table);
sci_base_state_machine_construct(
scic_sds_port_get_ready_substate_machine(sci_port),
&sci_port->parent.parent,
scic_sds_port_ready_substate_table,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING
);
sci_base_state_machine_construct(&sci_port->ready_substate_machine,
&sci_port->parent.parent,
scic_sds_port_ready_substate_table,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
sci_port->physical_port_index = port_index;
......@@ -1339,9 +1337,9 @@ static void scic_sds_port_ready_operational_substate_link_up_handler(
/**
* scic_sds_port_ready_operational_substate_link_down_handler() -
* @this_port: This is the struct scic_sds_port object that which has a phy that has
* @sci_port: This is the struct scic_sds_port object that which has a phy that has
* gone link down.
* @the_phy: This is the struct scic_sds_phy object that has gone link down.
* @sci_phy: This is the struct scic_sds_phy object that has gone link down.
*
* This method is the ready operational substate link down handler for the
* struct scic_sds_port object. This function notifies the SCI User that the phy has
......@@ -1349,21 +1347,18 @@ static void scic_sds_port_ready_operational_substate_link_up_handler(
* state to the ready waiting substate. none
*/
static void scic_sds_port_ready_operational_substate_link_down_handler(
struct scic_sds_port *this_port,
struct scic_sds_phy *the_phy)
struct scic_sds_port *sci_port,
struct scic_sds_phy *sci_phy)
{
scic_sds_port_deactivate_phy(this_port, the_phy, true);
scic_sds_port_deactivate_phy(sci_port, sci_phy, true);
/*
* If there are no active phys left in the port, then transition
* the port to the WAITING state until such time as a phy goes
* link up. */
if (this_port->active_phy_mask == 0) {
sci_base_state_machine_change_state(
scic_sds_port_get_ready_substate_machine(this_port),
SCIC_SDS_PORT_READY_SUBSTATE_WAITING
);
}
if (sci_port->active_phy_mask == 0)
sci_base_state_machine_change_state(&sci_port->ready_substate_machine,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
}
/**
......@@ -1820,169 +1815,52 @@ const struct sci_base_state scic_sds_port_ready_substate_table[] = {
},
};
/*
* ***************************************************************************
* * DEFAULT HANDLERS
* *************************************************************************** */
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for port a start request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_start_handler(
struct sci_base_port *port)
static enum sci_status default_port_handler(struct sci_base_port *base_port, const char *func)
{
struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
struct scic_sds_port *sci_port;
sci_port = container_of(base_port, typeof(*sci_port), parent);
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to start while in invalid "
"state %d\n",
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
"%s: in wrong state: %d\n", func,
sci_base_state_machine_get_state(&base_port->state_machine));
return SCI_FAILURE_INVALID_STATE;
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port stop request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_port_default_stop_handler(
struct sci_base_port *port)
enum sci_status scic_sds_port_default_start_handler(struct sci_base_port *base_port)
{
struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to stop while in invalid "
"state %d\n",
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
return default_port_handler(base_port, __func__);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port destruct request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_destruct_handler(
struct sci_base_port *port)
static enum sci_status scic_sds_port_default_stop_handler(struct sci_base_port *base_port)
{
struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to destruct while in invalid "
"state %d\n",
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
return default_port_handler(base_port, __func__);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
* @timeout: This is the timeout for the reset request to complete.
*
* This is the default method for a port reset request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_reset_handler(
struct sci_base_port *port,
u32 timeout)
enum sci_status scic_sds_port_default_destruct_handler(struct sci_base_port *base_port)
{
struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to reset while in invalid "
"state %d\n",
__func__,
port,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
return default_port_handler(base_port, __func__);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port add phy request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_port_default_add_phy_handler(
struct sci_base_port *port,
struct sci_base_phy *phy)
enum sci_status scic_sds_port_default_reset_handler(struct sci_base_port *base_port,
u32 timeout)
{
struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to add phy 0x%p while in "
"invalid state %d\n",
__func__,
port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return SCI_FAILURE_INVALID_STATE;
return default_port_handler(base_port, __func__);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port remove phy request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_remove_phy_handler(
struct sci_base_port *port,
struct sci_base_phy *phy)
static enum sci_status scic_sds_port_default_add_phy_handler(struct sci_base_port *base_port,
struct sci_base_phy *base_phy)
{
struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
dev_warn(sciport_to_dev(sci_port),
"%s: SCIC Port 0x%p requested to remove phy 0x%p while in "
"invalid state %d\n",
__func__,
port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
return default_port_handler(base_port, __func__);
}
return SCI_FAILURE_INVALID_STATE;
enum sci_status scic_sds_port_default_remove_phy_handler(struct sci_base_port *base_port,
struct sci_base_phy *base_phy)
{
return default_port_handler(base_port, __func__);
}
/**
*
* scic_sds_port_default_frame_handler
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
......@@ -1991,149 +1869,48 @@ enum sci_status scic_sds_port_default_remove_phy_handler(
* possible to receive an unsolicited frame directed to a port object? It
* seems possible if we implementing virtual functions but until then?
*/
enum sci_status scic_sds_port_default_frame_handler(
struct scic_sds_port *port,
u32 frame_index)
{
dev_warn(sciport_to_dev(port),
"%s: SCIC Port 0x%p requested to process frame %d while in "
"invalid state %d\n",
__func__,
port,
frame_index,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(port)));
scic_sds_controller_release_frame(
scic_sds_port_get_controller(port), frame_index
);
return SCI_FAILURE_INVALID_STATE;
}
enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port,
u32 frame_index)
{
struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port event request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_event_handler(
struct scic_sds_port *port,
u32 event_code)
{
dev_warn(sciport_to_dev(port),
"%s: SCIC Port 0x%p requested to process event 0x%x while "
"in invalid state %d\n",
__func__,
port,
event_code,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(
(struct scic_sds_port *)port)));
default_port_handler(&sci_port->parent, __func__);
scic_sds_controller_release_frame(scic, frame_index);
return SCI_FAILURE_INVALID_STATE;
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port link up notification. It will report
* a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
void scic_sds_port_default_link_up_handler(
struct scic_sds_port *this_port,
struct scic_sds_phy *phy)
enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port,
u32 event_code)
{
dev_warn(sciport_to_dev(this_port),
"%s: SCIC Port 0x%p received link_up notification from phy "
"0x%p while in invalid state %d\n",
__func__,
this_port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
return default_port_handler(&sci_port->parent, __func__);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port link down notification. It will
* report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
void scic_sds_port_default_link_down_handler(
struct scic_sds_port *this_port,
struct scic_sds_phy *phy)
void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port,
struct scic_sds_phy *sci_phy)
{
dev_warn(sciport_to_dev(this_port),
"%s: SCIC Port 0x%p received link down notification from "
"phy 0x%p while in invalid state %d\n",
__func__,
this_port,
phy,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
default_port_handler(&sci_port->parent, __func__);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port start io request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
enum sci_status scic_sds_port_default_start_io_handler(
struct scic_sds_port *this_port,
struct scic_sds_remote_device *device,
struct scic_sds_request *io_request)
void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port,
struct scic_sds_phy *sci_phy)
{
dev_warn(sciport_to_dev(this_port),
"%s: SCIC Port 0x%p requested to start io request 0x%p "
"while in invalid state %d\n",
__func__,
this_port,
io_request,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
return SCI_FAILURE_INVALID_STATE;
default_port_handler(&sci_port->parent, __func__);
}
/**
*
* @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
* object.
*
* This is the default method for a port complete io request. It will report a
* warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
*/
static enum sci_status scic_sds_port_default_complete_io_handler(
struct scic_sds_port *this_port,
struct scic_sds_remote_device *device,
struct scic_sds_request *io_request)
enum sci_status scic_sds_port_default_start_io_handler(struct scic_sds_port *sci_port,
struct scic_sds_remote_device *sci_dev,
struct scic_sds_request *sci_req)
{
dev_warn(sciport_to_dev(this_port),
"%s: SCIC Port 0x%p requested to complete io request 0x%p "
"while in invalid state %d\n",
__func__,
this_port,
io_request,
sci_base_state_machine_get_state(
scic_sds_port_get_base_state_machine(this_port)));
return SCI_FAILURE_INVALID_STATE;
return default_port_handler(&sci_port->parent, __func__);
}
/*
* ****************************************************************************
* * GENERAL STATE HANDLERS
* **************************************************************************** */
static enum sci_status scic_sds_port_default_complete_io_handler(struct scic_sds_port *sci_port,
struct scic_sds_remote_device *sci_dev,
struct scic_sds_request *sci_req)
{
return default_port_handler(&sci_port->parent, __func__);
}
/**
*
......@@ -2160,11 +1937,6 @@ static enum sci_status scic_sds_port_general_complete_io_handler(
return SCI_SUCCESS;
}
/*
* ****************************************************************************
* * STOPPED STATE HANDLERS
* **************************************************************************** */
/**
* scic_sds_port_stopped_state_start_handler() - stop a port from "started"
*
......@@ -2242,9 +2014,8 @@ scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port)
* silicon.
*/
if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) {
sci_base_state_machine_change_state(
scic_sds_port_get_base_state_machine(sci_port),
SCI_BASE_PORT_STATE_READY);
sci_base_state_machine_change_state(&base_port->state_machine,
SCI_BASE_PORT_STATE_READY);
return SCI_SUCCESS;
} else
......@@ -2390,19 +2161,15 @@ static enum sci_status scic_sds_port_stopped_state_remove_phy_handler(
* object will transition to the stopped state. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_port_stopping_state_complete_io_handler(
struct scic_sds_port *port,
struct scic_sds_port *sci_port,
struct scic_sds_remote_device *device,
struct scic_sds_request *io_request)
{
struct scic_sds_port *this_port = (struct scic_sds_port *)port;
scic_sds_port_decrement_request_count(this_port);
scic_sds_port_decrement_request_count(sci_port);
if (this_port->started_request_count == 0) {
sci_base_state_machine_change_state(
scic_sds_port_get_base_state_machine(this_port),
SCI_BASE_PORT_STATE_STOPPED
);
if (sci_port->started_request_count == 0) {
sci_base_state_machine_change_state(&sci_port->parent.state_machine,
SCI_BASE_PORT_STATE_STOPPED);
}
return SCI_SUCCESS;
......@@ -2727,9 +2494,8 @@ static void scic_sds_port_stopped_state_exit(
}
/**
*
* @object: This is the struct sci_base_object which is cast to a
* struct scic_sds_port object.
* scic_sds_port_ready_state_enter -
* @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
*
* This method will perform the actions required by the struct scic_sds_port on
* entering the SCI_BASE_PORT_STATE_READY. This function sets the ready state
......@@ -2738,50 +2504,40 @@ static void scic_sds_port_stopped_state_exit(
*/
static void scic_sds_port_ready_state_enter(struct sci_base_object *object)
{
struct scic_sds_port *sci_port = (struct scic_sds_port *)object;
struct isci_port *iport = sci_object_get_association(sci_port);
struct scic_sds_controller *scic =
scic_sds_port_get_controller(sci_port);
struct isci_host *ihost = sci_object_get_association(scic);
struct scic_sds_controller *scic;
struct scic_sds_port *sci_port;
struct isci_port *iport;
struct isci_host *ihost;
u32 prev_state;
/*
* Put the ready state handlers in place though they will not be
* there long
*/
scic_sds_port_set_base_state_handlers(sci_port,
SCI_BASE_PORT_STATE_READY);
sci_port = container_of(object, typeof(*sci_port), parent.parent);
scic = scic_sds_port_get_controller(sci_port);
ihost = sci_object_get_association(scic);
iport = sci_object_get_association(sci_port);
if (sci_port->parent.state_machine.previous_state_id ==
SCI_BASE_PORT_STATE_RESETTING)
/* Put the ready state handlers in place though they will not be there long */
scic_sds_port_set_base_state_handlers(sci_port, SCI_BASE_PORT_STATE_READY);
prev_state = sci_port->parent.state_machine.previous_state_id;
if (prev_state == SCI_BASE_PORT_STATE_RESETTING)
isci_port_hard_reset_complete(iport, SCI_SUCCESS);
else /* Notify the caller that the port is not yet ready */
else
isci_port_not_ready(ihost, iport);
/* Post and suspend the dummy remote node context for this port. */
scic_sds_port_post_dummy_remote_node(sci_port);
/* Start the ready substate machine */
sci_base_state_machine_start(
scic_sds_port_get_ready_substate_machine(sci_port));
sci_base_state_machine_start(&sci_port->ready_substate_machine);
}
/**
*
* @object: This is the struct sci_base_object which is cast to a struct scic_sds_port object.
*
* This method will perform the actions required by the struct scic_sds_port on
* exiting the SCI_BASE_STATE_READY. This function does nothing. none
*/
static void scic_sds_port_ready_state_exit(
struct sci_base_object *object)
static void scic_sds_port_ready_state_exit(struct sci_base_object *object)
{
struct scic_sds_port *this_port;
this_port = (struct scic_sds_port *)object;
sci_base_state_machine_stop(&this_port->ready_substate_machine);
struct scic_sds_port *sci_port;
scic_sds_port_invalidate_dummy_remote_node(this_port);
sci_port = container_of(object, typeof(*sci_port), parent.parent);
sci_base_state_machine_stop(&sci_port->ready_substate_machine);
scic_sds_port_invalidate_dummy_remote_node(sci_port);
}
/**
......
......@@ -250,14 +250,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t
#define scic_sds_port_get_controller(this_port) \
((this_port)->owning_controller)
/**
* scic_sds_port_get_base_state_machine() -
*
* Helper macro to get the base state machine for this port
*/
#define scic_sds_port_get_base_state_machine(this_port) \
(&(this_port)->parent.state_machine)
/**
* scic_sds_port_set_base_state_handlers() -
*
......@@ -267,14 +259,6 @@ extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_t
scic_sds_port_set_state_handlers(\
(this_port), &scic_sds_port_state_handler_table[(state_id)])
/**
* scic_sds_port_get_ready_substate_machine() -
*
* Helper macro to get the ready substate machine for this port
*/
#define scic_sds_port_get_ready_substate_machine(this_port) \
(&(this_port)->ready_substate_machine)
/**
* scic_sds_port_set_state_handlers() -
*
......
......@@ -376,22 +376,6 @@ extern const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_dev
#define scic_sds_remote_device_set_state_handlers(this_device, handlers) \
((this_device)->state_handlers = (handlers))
/**
* scic_sds_remote_device_get_base_state_machine() -
*
* This macro returns the base sate machine object for the remote device.
*/
#define scic_sds_remote_device_get_base_state_machine(this_device) \
(&(this_device)->parent.state_machine)
/**
* scic_sds_remote_device_get_ready_substate_machine() -
*
* This macro returns the remote device ready substate machine
*/
#define scic_sds_remote_device_get_ready_substate_machine(this_device) \
(&(this_device)->ready_substate_machine)
/**
* scic_sds_remote_device_get_port() -
*
......
......@@ -296,9 +296,6 @@ void scic_sds_remote_node_context_construct_buffer(
bool scic_sds_remote_node_context_is_ready(
struct scic_sds_remote_node_context *this_rnc);
#define scic_sds_remote_node_context_set_remote_node_index(rnc, rni) \
((rnc)->remote_node_index = (rni))
#define scic_sds_remote_node_context_get_remote_node_index(rcn) \
((rnc)->remote_node_index)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册