*/
#include "intel_sas.h"
-#include "sci_base_port.h"
#include "scic_controller.h"
#include "scic_phy.h"
#include "scic_port.h"
#define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000)
#define SCU_DUMMY_INDEX (0xFFFF)
-static void sci_base_port_construct(
- struct sci_base_port *base_port,
- const struct sci_base_state *state_table)
-{
- base_port->parent.private = NULL;
- sci_base_state_machine_construct(
- &base_port->state_machine,
- &base_port->parent,
- state_table,
- SCI_BASE_PORT_STATE_STOPPED
- );
-
- sci_base_state_machine_start(
- &base_port->state_machine
- );
-}
/**
*
struct scic_sds_port *this_port,
struct scic_sds_phy *the_phy)
{
- return this_port->state_handlers->parent.add_phy_handler(
- &this_port->parent, &the_phy->parent);
+ return this_port->state_handlers->add_phy_handler(
+ this_port, &the_phy->parent);
}
struct scic_sds_port *this_port,
struct scic_sds_phy *the_phy)
{
- return this_port->state_handlers->parent.remove_phy_handler(
- &this_port->parent, &the_phy->parent);
+ return this_port->state_handlers->remove_phy_handler(
+ this_port, &the_phy->parent);
}
/**
struct scic_sds_port *port,
u32 reset_timeout)
{
- return port->state_handlers->parent.reset_handler(
- &port->parent, reset_timeout);
+ return port->state_handlers->reset_handler(
+ port, reset_timeout);
}
/**
if ((phy_sas_address.high == port_sas_address.high &&
phy_sas_address.low == port_sas_address.low) ||
sci_port->active_phy_mask == 0) {
- struct sci_base_state_machine *sm = &sci_port->parent.state_machine;
+ struct sci_base_state_machine *sm = &sci_port->state_machine;
scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user);
if (sm->current_state_id == SCI_BASE_PORT_STATE_RESETTING)
u32 current_state;
current_state = sci_base_state_machine_get_state(
- &sci_port->parent.state_machine);
+ &sci_port->state_machine);
if (current_state == SCI_BASE_PORT_STATE_RESETTING) {
/*
* timeout fired before the reset completed.
*/
sci_base_state_machine_change_state(
- &sci_port->parent.state_machine,
+ &sci_port->state_machine,
SCI_BASE_PORT_STATE_FAILED);
} else if (current_state == SCI_BASE_PORT_STATE_STOPPED) {
/*
* * READY SUBSTATE HANDLERS
* **************************************************************************** */
-/**
- *
- * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
- * object.
- *
+/*
* This method is the general ready state stop handler for the struct scic_sds_port
* object. This function will transition the ready substate machine to its
* final state. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_port_ready_substate_stop_handler(
- struct sci_base_port *port)
+ struct scic_sds_port *port)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
-
sci_base_state_machine_change_state(
- &this_port->parent.state_machine,
+ &port->state_machine,
SCI_BASE_PORT_STATE_STOPPING
);
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(port);
return SCI_SUCCESS;
}
static enum sci_status scic_sds_port_ready_substate_add_phy_handler(
- struct sci_base_port *port,
+ struct scic_sds_port *port,
struct sci_base_phy *phy)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
enum sci_status status;
- status = scic_sds_port_set_phy(this_port, this_phy);
+ status = scic_sds_port_set_phy(port, this_phy);
if (status == SCI_SUCCESS) {
- scic_sds_port_general_link_up_handler(this_port, this_phy, true);
+ scic_sds_port_general_link_up_handler(port, this_phy, true);
- this_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
+ port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
sci_base_state_machine_change_state(
- &this_port->ready_substate_machine,
+ &port->ready_substate_machine,
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
);
}
static enum sci_status scic_sds_port_ready_substate_remove_phy_handler(
- struct sci_base_port *port,
+ struct scic_sds_port *port,
struct sci_base_phy *phy)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
enum sci_status status;
- status = scic_sds_port_clear_phy(this_port, this_phy);
+ status = scic_sds_port_clear_phy(port, this_phy);
if (status == SCI_SUCCESS) {
- scic_sds_port_deactivate_phy(this_port, this_phy, true);
+ scic_sds_port_deactivate_phy(port, this_phy, true);
- this_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
+ port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING;
sci_base_state_machine_change_state(
- &this_port->ready_substate_machine,
+ &port->ready_substate_machine,
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
);
}
* * READY SUBSTATE OPERATIONAL HANDLERS
* **************************************************************************** */
-/**
- *
- * @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 method will casue the port to reset. enum sci_status SCI_SUCCESS
*/
static enum
sci_status scic_sds_port_ready_operational_substate_reset_handler(
- struct sci_base_port *port,
+ struct scic_sds_port *port,
u32 timeout)
{
enum sci_status status = SCI_FAILURE_INVALID_PHY;
u32 phy_index;
- struct scic_sds_port *sci_port = (struct scic_sds_port *)port;
struct scic_sds_phy *selected_phy = NULL;
for (phy_index = 0;
(phy_index < SCI_MAX_PHYS) && (selected_phy == NULL);
phy_index++) {
- selected_phy = sci_port->phy_table[phy_index];
+ selected_phy = port->phy_table[phy_index];
if ((selected_phy != NULL) &&
- !scic_sds_port_active_phy(sci_port, selected_phy)) {
+ !scic_sds_port_active_phy(port, selected_phy)) {
/*
* We found a phy but it is not ready select
* different phy
status = scic_sds_phy_reset(selected_phy);
if (status == SCI_SUCCESS) {
- isci_timer_start(sci_port->timer_handle, timeout);
- sci_port->not_ready_reason =
+ isci_timer_start(port->timer_handle, timeout);
+ port->not_ready_reason =
SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED;
sci_base_state_machine_change_state(
- &sci_port->parent.state_machine,
+ &port->state_machine,
SCI_BASE_PORT_STATE_RESETTING);
}
}
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_increment_request_count(this_port);
+ scic_sds_port_increment_request_count(port);
return SCI_SUCCESS;
}
* * READY SUBSTATE OPERATIONAL HANDLERS
* **************************************************************************** */
-/**
- * scic_sds_port_ready_configuring_substate_add_phy_handler() -
- * @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_ready_configuring_substate_add_phy_handler(
- struct sci_base_port *port,
+ struct scic_sds_port *port,
struct sci_base_phy *phy)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
enum sci_status status;
- status = scic_sds_port_set_phy(this_port, this_phy);
+ status = scic_sds_port_set_phy(port, this_phy);
if (status == SCI_SUCCESS) {
- scic_sds_port_general_link_up_handler(this_port, this_phy, true);
+ scic_sds_port_general_link_up_handler(port, this_phy, true);
/*
* Re-enter the configuring state since this may be the last phy in
* the port. */
sci_base_state_machine_change_state(
- &this_port->ready_substate_machine,
+ &port->ready_substate_machine,
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
);
}
return status;
}
-/**
- * scic_sds_port_ready_configuring_substate_remove_phy_handler() -
- * @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
*/
static enum sci_status scic_sds_port_ready_configuring_substate_remove_phy_handler(
- struct sci_base_port *port,
+ struct scic_sds_port *port,
struct sci_base_phy *phy)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
enum sci_status status;
- status = scic_sds_port_clear_phy(this_port, this_phy);
+ status = scic_sds_port_clear_phy(port, this_phy);
if (status == SCI_SUCCESS) {
- scic_sds_port_deactivate_phy(this_port, this_phy, true);
+ scic_sds_port_deactivate_phy(port, this_phy, true);
/*
* Re-enter the configuring state since this may be the last phy in
* the port. */
sci_base_state_machine_change_state(
- &this_port->ready_substate_machine,
+ &port->ready_substate_machine,
SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING
);
}
* the request count goes to 0 then the port can be reprogrammed with its new
* phy data.
*/
-static enum sci_status scic_sds_port_ready_configuring_substate_complete_io_handler(
+static enum sci_status
+scic_sds_port_ready_configuring_substate_complete_io_handler(
struct scic_sds_port *port,
struct scic_sds_remote_device *device,
struct scic_sds_request *io_request)
return SCI_SUCCESS;
}
-static enum sci_status default_port_handler(struct sci_base_port *base_port, const char *func)
+static enum sci_status default_port_handler(struct scic_sds_port *sci_port,
+ const char *func)
{
- struct scic_sds_port *sci_port;
-
- sci_port = container_of(base_port, typeof(*sci_port), parent);
dev_warn(sciport_to_dev(sci_port),
"%s: in wrong state: %d\n", func,
- sci_base_state_machine_get_state(&base_port->state_machine));
+ sci_base_state_machine_get_state(&sci_port->state_machine));
return SCI_FAILURE_INVALID_STATE;
}
-static enum sci_status scic_sds_port_default_start_handler(struct sci_base_port *base_port)
+static enum sci_status
+scic_sds_port_default_start_handler(struct scic_sds_port *sci_port)
{
- return default_port_handler(base_port, __func__);
+ return default_port_handler(sci_port, __func__);
}
-static enum sci_status scic_sds_port_default_stop_handler(struct sci_base_port *base_port)
+static enum sci_status
+scic_sds_port_default_stop_handler(struct scic_sds_port *sci_port)
{
- return default_port_handler(base_port, __func__);
+ return default_port_handler(sci_port, __func__);
}
-static enum sci_status scic_sds_port_default_destruct_handler(struct sci_base_port *base_port)
+static enum sci_status
+scic_sds_port_default_destruct_handler(struct scic_sds_port *sci_port)
{
- return default_port_handler(base_port, __func__);
+ return default_port_handler(sci_port, __func__);
}
-static enum sci_status scic_sds_port_default_reset_handler(struct sci_base_port *base_port,
- u32 timeout)
+static enum sci_status
+scic_sds_port_default_reset_handler(struct scic_sds_port *sci_port,
+ u32 timeout)
{
- return default_port_handler(base_port, __func__);
+ return default_port_handler(sci_port, __func__);
}
-static enum sci_status scic_sds_port_default_add_phy_handler(struct sci_base_port *base_port,
- struct sci_base_phy *base_phy)
+static enum sci_status
+scic_sds_port_default_add_phy_handler(struct scic_sds_port *sci_port,
+ struct sci_base_phy *base_phy)
{
- return default_port_handler(base_port, __func__);
+ return default_port_handler(sci_port, __func__);
}
-static enum sci_status scic_sds_port_default_remove_phy_handler(struct sci_base_port *base_port,
- struct sci_base_phy *base_phy)
+static enum sci_status
+scic_sds_port_default_remove_phy_handler(struct scic_sds_port *sci_port,
+ struct sci_base_phy *base_phy)
{
- return default_port_handler(base_port, __func__);
+ return default_port_handler(sci_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.
- *
+/*
* This is the default method for a port unsolicited frame request. It will
* report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even
* possible to receive an unsolicited frame directed to a port object? It
* seems possible if we implementing virtual functions but until then?
*/
-static enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port,
- u32 frame_index)
+static 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);
- default_port_handler(&sci_port->parent, __func__);
+ default_port_handler(sci_port, __func__);
scic_sds_controller_release_frame(scic, frame_index);
return SCI_FAILURE_INVALID_STATE;
static enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port,
u32 event_code)
{
- return default_port_handler(&sci_port->parent, __func__);
+ return default_port_handler(sci_port, __func__);
}
static void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port,
struct scic_sds_phy *sci_phy)
{
- default_port_handler(&sci_port->parent, __func__);
+ default_port_handler(sci_port, __func__);
}
static void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port,
struct scic_sds_phy *sci_phy)
{
- default_port_handler(&sci_port->parent, __func__);
+ default_port_handler(sci_port, __func__);
}
static 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)
{
- return default_port_handler(&sci_port->parent, __func__);
+ return default_port_handler(sci_port, __func__);
}
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__);
+ return default_port_handler(sci_port, __func__);
}
static struct scic_sds_port_state_handler
-scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] =
-{
- /* SCIC_SDS_PORT_READY_SUBSTATE_WAITING */
+scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] = {
{
- {
- scic_sds_port_default_start_handler,
- scic_sds_port_ready_substate_stop_handler,
- scic_sds_port_default_destruct_handler,
- scic_sds_port_default_reset_handler,
- scic_sds_port_ready_substate_add_phy_handler,
- scic_sds_port_default_remove_phy_handler
- },
+ /* SCIC_SDS_PORT_READY_SUBSTATE_WAITING */
+ scic_sds_port_default_start_handler,
+ scic_sds_port_ready_substate_stop_handler,
+ scic_sds_port_default_destruct_handler,
+ scic_sds_port_default_reset_handler,
+ scic_sds_port_ready_substate_add_phy_handler,
+ scic_sds_port_default_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_ready_waiting_substate_link_up_handler,
scic_sds_port_ready_waiting_substate_start_io_handler,
scic_sds_port_ready_substate_complete_io_handler,
},
- /* SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL */
+
{
- {
- scic_sds_port_default_start_handler,
- scic_sds_port_ready_substate_stop_handler,
- scic_sds_port_default_destruct_handler,
- scic_sds_port_ready_operational_substate_reset_handler,
- scic_sds_port_ready_substate_add_phy_handler,
- scic_sds_port_ready_substate_remove_phy_handler
- },
+ /* SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL */
+ scic_sds_port_default_start_handler,
+ scic_sds_port_ready_substate_stop_handler,
+ scic_sds_port_default_destruct_handler,
+ scic_sds_port_ready_operational_substate_reset_handler,
+ scic_sds_port_ready_substate_add_phy_handler,
+ scic_sds_port_ready_substate_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_ready_operational_substate_link_up_handler,
scic_sds_port_ready_operational_substate_link_down_handler,
scic_sds_port_ready_operational_substate_start_io_handler,
- scic_sds_port_ready_substate_complete_io_handler
+ scic_sds_port_ready_substate_complete_io_handler,
},
- /* SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING */
+
{
- {
- scic_sds_port_default_start_handler,
- scic_sds_port_ready_substate_stop_handler,
- scic_sds_port_default_destruct_handler,
- scic_sds_port_default_reset_handler,
- scic_sds_port_ready_configuring_substate_add_phy_handler,
- scic_sds_port_ready_configuring_substate_remove_phy_handler
- },
+ /* SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING */
+ scic_sds_port_default_start_handler,
+ scic_sds_port_ready_substate_stop_handler,
+ scic_sds_port_default_destruct_handler,
+ scic_sds_port_default_reset_handler,
+ scic_sds_port_ready_configuring_substate_add_phy_handler,
+ scic_sds_port_ready_configuring_substate_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_default_link_up_handler,
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(port);
return SCI_SUCCESS;
}
/**
* scic_sds_port_stopped_state_start_handler() - stop a port from "started"
*
- * @port: This is the struct sci_base_port object which is cast into a
+ * @port: This is the struct scic_sds_port object which is cast into a
* struct scic_sds_port object.
*
* This function takes the struct scic_sds_port from a stopped state and
* has transitioned to the SCI_BASE_PORT_STATE_READY.
*/
static enum sci_status
-scic_sds_port_stopped_state_start_handler(struct sci_base_port *base_port)
+scic_sds_port_stopped_state_start_handler(struct scic_sds_port *sci_port)
{
- struct scic_sds_port *sci_port =
- container_of(base_port, typeof(*sci_port), parent);
struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = sci_object_get_association(scic);
enum sci_status status = SCI_SUCCESS;
* silicon.
*/
if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) {
- sci_base_state_machine_change_state(&base_port->state_machine,
- SCI_BASE_PORT_STATE_READY);
+ sci_base_state_machine_change_state(
+ &sci_port->state_machine,
+ SCI_BASE_PORT_STATE_READY);
return SCI_SUCCESS;
} else
return status;
}
-/**
- *
- * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
- * object.
- *
+/*
* This method takes the struct scic_sds_port that is in a stopped state and handles a
* stop request. This function takes no action. enum sci_status SCI_SUCCESS the
* stop request is successful as the struct scic_sds_port object is already stopped.
*/
static enum sci_status scic_sds_port_stopped_state_stop_handler(
- struct sci_base_port *port)
+ struct scic_sds_port *port)
{
/* We are already stopped so there is nothing to do here */
return SCI_SUCCESS;
}
-/**
- *
- * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
- * object.
- *
+/*
* This method takes the struct scic_sds_port that is in a stopped state and handles
* the destruct request. The stopped state is the only state in which the
* struct scic_sds_port can be destroyed. This function causes the port object to
* transition to the SCI_BASE_PORT_STATE_FINAL. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_port_stopped_state_destruct_handler(
- struct sci_base_port *port)
+ struct scic_sds_port *port)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
-
- sci_base_state_machine_stop(&this_port->parent.state_machine);
+ sci_base_state_machine_stop(&port->state_machine);
return SCI_SUCCESS;
}
-/**
- *
- * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
- * object.
- * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
- * object.
- *
+/*
* This method takes the struct scic_sds_port that is in a stopped state and handles
* the add phy request. In MPC mode the only time a phy can be added to a port
* is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status
* be added to the port. SCI_SUCCESS if the phy is added to the port.
*/
static enum sci_status scic_sds_port_stopped_state_add_phy_handler(
- struct sci_base_port *port,
+ struct scic_sds_port *port,
struct sci_base_phy *phy)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
struct sci_sas_address port_sas_address;
/* Read the port assigned SAS Address if there is one */
- scic_sds_port_get_sas_address(this_port, &port_sas_address);
+ scic_sds_port_get_sas_address(port, &port_sas_address);
if (port_sas_address.high != 0 && port_sas_address.low != 0) {
struct sci_sas_address phy_sas_address;
}
}
- return scic_sds_port_set_phy(this_port, this_phy);
+ return scic_sds_port_set_phy(port, this_phy);
}
-/**
- *
- * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
- * object.
- * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
- * object.
- *
+/*
* This method takes the struct scic_sds_port that is in a stopped state and handles
* the remove phy request. In MPC mode the only time a phy can be removed from
* a port is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status
* be added to the port. SCI_SUCCESS if the phy is added to the port.
*/
static enum sci_status scic_sds_port_stopped_state_remove_phy_handler(
- struct sci_base_port *port,
+ struct scic_sds_port *port,
struct sci_base_phy *phy)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
struct scic_sds_phy *this_phy = (struct scic_sds_phy *)phy;
- return scic_sds_port_clear_phy(this_port, this_phy);
+ return scic_sds_port_clear_phy(port, this_phy);
}
/*
* * STOPPING STATE HANDLERS
* **************************************************************************** */
-/**
- *
- * @port: This is the struct scic_sds_port object on which the io request count will
- * be decremented.
- * @device: This is the struct scic_sds_remote_device object to which the io request
- * is being directed. This parameter is not required to complete this
- * operation.
- * @io_request: This is the request that is being completed on this port
- * object. This parameter is not required to complete this operation.
- *
+/*
* This method takes the struct scic_sds_port that is in a stopping state and handles
* the complete io request. Should the request count reach 0 then the port
* object will transition to the stopped state. enum sci_status SCI_SUCCESS
scic_sds_port_decrement_request_count(sci_port);
if (sci_port->started_request_count == 0) {
- sci_base_state_machine_change_state(&sci_port->parent.state_machine,
+ sci_base_state_machine_change_state(&sci_port->state_machine,
SCI_BASE_PORT_STATE_STOPPED);
}
* stopping state. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_port_reset_state_stop_handler(
- struct sci_base_port *port)
+ struct scic_sds_port *port)
{
- struct scic_sds_port *this_port = (struct scic_sds_port *)port;
-
sci_base_state_machine_change_state(
- &this_port->parent.state_machine,
+ &port->state_machine,
SCI_BASE_PORT_STATE_STOPPING
);
return SCI_SUCCESS;
}
-/**
- *
- * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
- * object.
- *
+/*
* This method will transition a failed port to its ready state. The port
* failed because a hard reset request timed out but at some time later one or
* more phys in the port became ready. enum sci_status SCI_SUCCESS
*/
static void scic_sds_port_reset_state_link_up_handler(
- struct scic_sds_port *this_port,
+ struct scic_sds_port *port,
struct scic_sds_phy *phy)
{
/*
/*
* In the resetting state we don't notify the user regarding
* link up and link down notifications. */
- scic_sds_port_general_link_up_handler(this_port, phy, false);
+ scic_sds_port_general_link_up_handler(port, phy, false);
}
-/**
- *
- * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
- * object.
- *
+/*
* This method process link down notifications that occur during a port reset
* operation. Link downs can occur during the reset operation. enum sci_status
* SCI_SUCCESS
*/
static void scic_sds_port_reset_state_link_down_handler(
- struct scic_sds_port *this_port,
+ struct scic_sds_port *port,
struct scic_sds_phy *phy)
{
/*
* In the resetting state we don't notify the user regarding
* link up and link down notifications. */
- scic_sds_port_deactivate_phy(this_port, phy, false);
+ scic_sds_port_deactivate_phy(port, phy, false);
}
static struct scic_sds_port_state_handler
{
/* SCI_BASE_PORT_STATE_STOPPED */
{
- {
- scic_sds_port_stopped_state_start_handler,
- scic_sds_port_stopped_state_stop_handler,
- scic_sds_port_stopped_state_destruct_handler,
- scic_sds_port_default_reset_handler,
- scic_sds_port_stopped_state_add_phy_handler,
- scic_sds_port_stopped_state_remove_phy_handler
- },
+ scic_sds_port_stopped_state_start_handler,
+ scic_sds_port_stopped_state_stop_handler,
+ scic_sds_port_stopped_state_destruct_handler,
+ scic_sds_port_default_reset_handler,
+ scic_sds_port_stopped_state_add_phy_handler,
+ scic_sds_port_stopped_state_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_default_link_up_handler,
},
/* SCI_BASE_PORT_STATE_STOPPING */
{
- {
- scic_sds_port_default_start_handler,
- scic_sds_port_default_stop_handler,
- scic_sds_port_default_destruct_handler,
- scic_sds_port_default_reset_handler,
- scic_sds_port_default_add_phy_handler,
- scic_sds_port_default_remove_phy_handler
- },
+ scic_sds_port_default_start_handler,
+ scic_sds_port_default_stop_handler,
+ scic_sds_port_default_destruct_handler,
+ scic_sds_port_default_reset_handler,
+ scic_sds_port_default_add_phy_handler,
+ scic_sds_port_default_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_default_link_up_handler,
},
/* SCI_BASE_PORT_STATE_READY */
{
- {
- scic_sds_port_default_start_handler,
- scic_sds_port_default_stop_handler,
- scic_sds_port_default_destruct_handler,
- scic_sds_port_default_reset_handler,
- scic_sds_port_default_add_phy_handler,
- scic_sds_port_default_remove_phy_handler
- },
+ scic_sds_port_default_start_handler,
+ scic_sds_port_default_stop_handler,
+ scic_sds_port_default_destruct_handler,
+ scic_sds_port_default_reset_handler,
+ scic_sds_port_default_add_phy_handler,
+ scic_sds_port_default_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_default_link_up_handler,
},
/* SCI_BASE_PORT_STATE_RESETTING */
{
- {
- scic_sds_port_default_start_handler,
- scic_sds_port_reset_state_stop_handler,
- scic_sds_port_default_destruct_handler,
- scic_sds_port_default_reset_handler,
- scic_sds_port_default_add_phy_handler,
- scic_sds_port_default_remove_phy_handler
- },
+ scic_sds_port_default_start_handler,
+ scic_sds_port_reset_state_stop_handler,
+ scic_sds_port_default_destruct_handler,
+ scic_sds_port_default_reset_handler,
+ scic_sds_port_default_add_phy_handler,
+ scic_sds_port_default_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_reset_state_link_up_handler,
},
/* SCI_BASE_PORT_STATE_FAILED */
{
- {
- scic_sds_port_default_start_handler,
- scic_sds_port_default_stop_handler,
- scic_sds_port_default_destruct_handler,
- scic_sds_port_default_reset_handler,
- scic_sds_port_default_add_phy_handler,
- scic_sds_port_default_remove_phy_handler
- },
+ scic_sds_port_default_start_handler,
+ scic_sds_port_default_stop_handler,
+ scic_sds_port_default_destruct_handler,
+ scic_sds_port_default_reset_handler,
+ scic_sds_port_default_add_phy_handler,
+ scic_sds_port_default_remove_phy_handler,
scic_sds_port_default_frame_handler,
scic_sds_port_default_event_handler,
scic_sds_port_default_link_up_handler,
if (
SCI_BASE_PORT_STATE_STOPPING
- == this_port->parent.state_machine.previous_state_id
+ == this_port->state_machine.previous_state_id
) {
/*
* If we enter this state becasuse of a request to stop
struct isci_host *ihost;
u32 prev_state;
- sci_port = container_of(object, typeof(*sci_port), parent.parent);
+ sci_port = container_of(object, typeof(*sci_port), parent);
scic = scic_sds_port_get_controller(sci_port);
ihost = sci_object_get_association(scic);
iport = sci_object_get_association(sci_port);
/* 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;
+ prev_state = sci_port->state_machine.previous_state_id;
if (prev_state == SCI_BASE_PORT_STATE_RESETTING)
isci_port_hard_reset_complete(iport, SCI_SUCCESS);
else
{
struct scic_sds_port *sci_port;
- sci_port = container_of(object, typeof(*sci_port), parent.parent);
+ sci_port = container_of(object, typeof(*sci_port), parent);
sci_base_state_machine_stop(&sci_port->ready_substate_machine);
scic_sds_port_invalidate_dummy_remote_node(sci_port);
}
{
u32 index;
- sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table);
+ sci_port->parent.private = NULL;
+ sci_base_state_machine_construct(&sci_port->state_machine,
+ &sci_port->parent,
+ scic_sds_port_state_table,
+ SCI_BASE_PORT_STATE_STOPPED);
+
+ sci_base_state_machine_start(&sci_port->state_machine);
sci_base_state_machine_construct(&sci_port->ready_substate_machine,
- &sci_port->parent.parent,
+ &sci_port->parent,
scic_sds_port_ready_substate_table,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
#ifndef _SCIC_SDS_PORT_H_
#define _SCIC_SDS_PORT_H_
-/**
- * This file contains the structures, constants and prototypes for the
- * struct scic_sds_port object.
- *
- *
- */
-
#include <linux/kernel.h>
#include "sci_controller_constants.h"
#include "intel_sas.h"
-#include "sci_base_port.h"
#include "sci_base_phy.h"
#include "scu_registers.h"
#define SCIC_SDS_DUMMY_PORT 0xFF
+struct scic_sds_controller;
+struct scic_sds_phy;
+struct scic_sds_remote_device;
+struct scic_sds_request;
+
/**
* This constant defines the value utilized by SCI Components to indicate
* an invalid handle.
SCIC_SDS_PORT_READY_MAX_SUBSTATES
};
-struct scic_sds_controller;
-struct scic_sds_phy;
-struct scic_sds_remote_device;
-struct scic_sds_request;
+/**
+ * enum scic_sds_port_states - This enumeration depicts all the states for the
+ * common port state machine.
+ *
+ *
+ */
+enum scic_sds_port_states {
+ /**
+ * This state indicates that the port has successfully been stopped.
+ * In this state no new IO operations are permitted.
+ * This state is entered from the STOPPING state.
+ */
+ SCI_BASE_PORT_STATE_STOPPED,
+
+ /**
+ * This state indicates that the port is in the process of stopping.
+ * In this state no new IO operations are permitted, but existing IO
+ * operations are allowed to complete.
+ * This state is entered from the READY state.
+ */
+ SCI_BASE_PORT_STATE_STOPPING,
+
+ /**
+ * This state indicates the port is now ready. Thus, the user is
+ * able to perform IO operations on this port.
+ * This state is entered from the STARTING state.
+ */
+ SCI_BASE_PORT_STATE_READY,
+
+ /**
+ * This state indicates the port is in the process of performing a hard
+ * reset. Thus, the user is unable to perform IO operations on this
+ * port.
+ * This state is entered from the READY state.
+ */
+ SCI_BASE_PORT_STATE_RESETTING,
+
+ /**
+ * This state indicates the port has failed a reset request. This state
+ * is entered when a port reset request times out.
+ * This state is entered from the RESETTING state.
+ */
+ SCI_BASE_PORT_STATE_FAILED,
+
+ SCI_BASE_PORT_MAX_STATES
+
+};
/**
* struct scic_sds_port -
*/
struct scic_sds_port {
/**
- * This field is the oommon base port object.
+ * The field specifies that the parent object for the base controller
+ * is the base object itself.
*/
- struct sci_base_port parent;
+ struct sci_base_object parent;
+
+ /**
+ * This field contains the information for the base port state machine.
+ */
+ struct sci_base_state_machine state_machine;
/**
* This field is the port index that is reported to the SCI USER.
};
+struct sci_base_phy;
+
+typedef enum sci_status (*scic_sds_port_handler_t)(struct scic_sds_port *);
+
+typedef enum sci_status (*scic_sds_port_phy_handler_t)(struct scic_sds_port *,
+ struct sci_base_phy *);
+
+typedef enum sci_status (*scic_sds_port_reset_handler_t)(struct scic_sds_port *,
+ u32 timeout);
typedef enum sci_status (*scic_sds_port_event_handler_t)(struct scic_sds_port *, u32);
typedef void (*scic_sds_port_link_handler_t)(struct scic_sds_port *, struct scic_sds_phy *);
-typedef enum sci_status (*scic_sds_port_io_request_handler_t)(
- struct scic_sds_port *,
- struct scic_sds_remote_device *,
- struct scic_sds_request *);
+typedef enum sci_status (*scic_sds_port_io_request_handler_t)(struct scic_sds_port *,
+ struct scic_sds_remote_device *,
+ struct scic_sds_request *);
struct scic_sds_port_state_handler {
- struct sci_base_port_state_handler parent;
+ /**
+ * The start_handler specifies the method invoked when a user
+ * attempts to start a port.
+ */
+ scic_sds_port_handler_t start_handler;
+
+ /**
+ * The stop_handler specifies the method invoked when a user
+ * attempts to stop a port.
+ */
+ scic_sds_port_handler_t stop_handler;
+
+ /**
+ * The destruct_handler specifies the method invoked when attempting to
+ * destruct a port.
+ */
+ scic_sds_port_handler_t destruct_handler;
+
+ /**
+ * The reset_handler specifies the method invoked when a user
+ * attempts to hard reset a port.
+ */
+ scic_sds_port_reset_handler_t reset_handler;
+
+ /**
+ * The add_phy_handler specifies the method invoked when a user
+ * attempts to add another phy into the port.
+ */
+ scic_sds_port_phy_handler_t add_phy_handler;
+
+ /**
+ * The remove_phy_handler specifies the method invoked when a user
+ * attempts to remove a phy from the port.
+ */
+ scic_sds_port_phy_handler_t remove_phy_handler;
scic_sds_port_frame_handler_t frame_handler;
scic_sds_port_event_handler_t event_handler;
#define scic_sds_port_active_phy(port, phy) \
(((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0)
-/* --------------------------------------------------------------------------- */
-
-
-
-
-/* --------------------------------------------------------------------------- */
-
-/* --------------------------------------------------------------------------- */
-
void scic_sds_port_construct(
struct scic_sds_port *this_port,
u8 port_index,
void __iomem *port_configuration_regsiter,
void __iomem *viit_registers);
-/* --------------------------------------------------------------------------- */
-
enum sci_status scic_sds_port_add_phy(
struct scic_sds_port *this_port,
struct scic_sds_phy *the_phy);
struct scic_sds_phy *phy,
bool do_notify_user);
-
-
-
bool scic_sds_port_link_detected(
struct scic_sds_port *this_port,
struct scic_sds_phy *phy);
struct scic_sds_port *this_port,
struct scic_sds_phy *phy);
-/* --------------------------------------------------------------------------- */
-
-
-/* --------------------------------------------------------------------------- */
-
enum sci_status scic_sds_port_start_io(
struct scic_sds_port *this_port,
struct scic_sds_remote_device *the_device,
struct scic_sds_remote_device *the_device,
struct scic_sds_request *the_io_request);
-/* --------------------------------------------------------------------------- */
-
-
-/* --------------------------------------------------------------------------- */
-
-
-
-
-
-
-
-
-
-
-
-
-
enum sci_sas_link_rate scic_sds_port_get_max_allowed_speed(
struct scic_sds_port *this_port);
struct scic_sds_port *this_port,
u32 phy_index);
-
-
void scic_sds_port_get_sas_address(
struct scic_sds_port *this_port,
struct sci_sas_address *sas_address);
struct scic_sds_port *this_port,
struct sci_sas_identify_address_frame_protocols *protocols);
-
-
-
-
#endif /* _SCIC_SDS_PORT_H_ */