u32 index;
enum sci_status port_status;
enum sci_status status = SCI_SUCCESS;
+ struct isci_host *ihost = scic_to_ihost(scic);
for (index = 0; index < scic->logical_port_entries; index++) {
- struct scic_sds_port *sci_port = &scic->port_table[index];
+ struct scic_sds_port *sci_port = &ihost->ports[index].sci;
scic_sds_port_handler_t stop;
stop = sci_port->state_handlers->stop_handler;
(result == SCI_SUCCESS);
index++) {
result = scic_sds_port_initialize(
- &scic->port_table[index],
+ &ihost->ports[index].sci,
&scic->scu_registers->peg0.ptsg.port[index],
&scic->scu_registers->peg0.ptsg.protocol_engine,
&scic->scu_registers->peg0.viit[index]);
}
enum sci_status scic_controller_start(struct scic_sds_controller *scic,
- u32 timeout)
+ u32 timeout)
{
+ struct isci_host *ihost = scic_to_ihost(scic);
enum sci_status result;
u16 index;
/* Start all of the ports on this controller */
for (index = 0; index < scic->logical_port_entries; index++) {
- struct scic_sds_port *sci_port = &scic->port_table[index];
+ struct scic_sds_port *sci_port = &ihost->ports[index].sci;
- result = sci_port->state_handlers->start_handler(
- sci_port);
+ result = sci_port->state_handlers->start_handler(sci_port);
if (result)
return result;
}
/* Construct the ports for this controller */
for (i = 0; i < SCI_MAX_PORTS; i++)
- scic_sds_port_construct(&scic->port_table[i], i, scic);
- scic_sds_port_construct(&scic->port_table[i], SCIC_SDS_DUMMY_PORT, scic);
+ scic_sds_port_construct(&ihost->ports[i].sci, i, scic);
+ scic_sds_port_construct(&ihost->ports[i].sci, SCIC_SDS_DUMMY_PORT, scic);
/* Construct the phys for this controller */
for (i = 0; i < SCI_MAX_PHYS; i++) {
/* Add all the PHYs to the dummy port */
scic_sds_phy_construct(&ihost->phys[i].sci,
- &scic->port_table[SCI_MAX_PORTS], i);
+ &ihost->ports[SCI_MAX_PORTS].sci, i);
}
scic->invalid_phy_mask = 0;
*/
struct scic_sds_port_configuration_agent port_agent;
- /**
- * This field is the array of port objects that are controlled by this
- * controller object. There is one dummy port object also contained within
- * this controller object.
- */
- struct scic_sds_port port_table[SCI_MAX_PORTS + 1];
-
/**
* This field is the array of device objects that are currently constructed
* for this controller object. This table is used as a fast lookup of device
struct scic_sds_phy *phy)
{
/* Make sure that this phy is part of this port */
- if (
- (port->phy_table[phy->phy_index] == phy)
- && (scic_sds_phy_get_port(phy) == port)
- ) {
- /* Yep it is assigned to this port so remove it */
- scic_sds_phy_set_port(
- phy,
- &scic_sds_port_get_controller(port)->port_table[SCI_MAX_PORTS]
- );
+ if (port->phy_table[phy->phy_index] == phy &&
+ scic_sds_phy_get_port(phy) == port) {
+ struct scic_sds_controller *scic = port->owning_controller;
+ struct isci_host *ihost = scic_to_ihost(scic);
+ /* Yep it is assigned to this port so remove it */
+ scic_sds_phy_set_port(phy, &ihost->ports[SCI_MAX_PORTS].sci);
port->phy_table[phy->phy_index] = NULL;
-
return SCI_SUCCESS;
}
bool do_notify_user)
{
struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
- struct isci_port *iport = sci_port->iport;
+ struct isci_port *iport = sci_port_to_iport(sci_port);
struct isci_host *ihost = scic_to_ihost(scic);
struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
{
u32 index;
struct scic_sds_port *sci_port = object;
- struct scic_sds_controller *scic =
- scic_sds_port_get_controller(sci_port);
+ struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic);
- struct isci_port *iport = sci_port->iport;
+ struct isci_port *iport = sci_port_to_iport(sci_port);
scic_sds_port_set_ready_state_handlers(
sci_port,
static void scic_sds_port_ready_substate_operational_exit(void *object)
{
struct scic_sds_port *sci_port = object;
- struct scic_sds_controller *scic =
- scic_sds_port_get_controller(sci_port);
+ struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic);
- struct isci_port *iport = sci_port->iport;
+ struct isci_port *iport = sci_port_to_iport(sci_port);
/*
* Kill the dummy task for this port if it has not yet posted
static void scic_sds_port_ready_substate_configuring_enter(void *object)
{
struct scic_sds_port *sci_port = object;
- struct scic_sds_controller *scic =
- scic_sds_port_get_controller(sci_port);
+ struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic);
- struct isci_port *iport = sci_port->iport;
+ struct isci_port *iport = sci_port_to_iport(sci_port);
scic_sds_port_set_ready_state_handlers(
sci_port,
struct scic_sds_port *sci_port = object;
struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic);
- struct isci_port *iport = sci_port->iport;
+ struct isci_port *iport = sci_port_to_iport(sci_port);
u32 prev_state;
/* Put the ready state handlers in place though they will not be there long */
static void scic_sds_port_failed_state_enter(void *object)
{
struct scic_sds_port *sci_port = object;
- struct isci_port *iport = sci_port->iport;
+ struct isci_port *iport = sci_port_to_iport(sci_port);
scic_sds_port_set_base_state_handlers(sci_port,
SCI_BASE_PORT_STATE_FAILED);
}
};
-void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
+void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index,
struct scic_sds_controller *scic)
{
- u32 index;
-
sci_base_state_machine_construct(&sci_port->state_machine,
sci_port,
scic_sds_port_state_table,
SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
- sci_port->physical_port_index = port_index;
+ sci_port->physical_port_index = index;
sci_port->active_phy_mask = 0;
sci_port->owning_controller = scic;
sci_port->reserved_tci = SCU_DUMMY_INDEX;
sci_port->timer_handle = NULL;
-
sci_port->port_task_scheduler_registers = NULL;
for (index = 0; index < SCI_MAX_PHYS; index++)
};
-struct isci_port;
/**
* struct scic_sds_port
*
* The core port object provides the the abstraction for an SCU port.
*/
struct scic_sds_port {
- /**
- * The field specifies the peer object for the port.
- */
- struct isci_port *iport;
/**
* This field contains the information for the base port state machine.
scic_sds_phy_get_attached_sas_address(phy, &phy_attached_device_address);
for (i = 0; i < scic->logical_port_entries; i++) {
- struct scic_sds_port *port = &scic->port_table[i];
+ struct isci_host *ihost = scic_to_ihost(scic);
+ struct scic_sds_port *sci_port = &ihost->ports[i].sci;
- scic_sds_port_get_sas_address(port, &port_sas_address);
- scic_sds_port_get_attached_sas_address(port, &port_attached_device_address);
+ scic_sds_port_get_sas_address(sci_port, &port_sas_address);
+ scic_sds_port_get_attached_sas_address(sci_port, &port_attached_device_address);
- if ((sci_sas_address_compare(port_sas_address, phy_sas_address) == 0) &&
- (sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0))
- return port;
+ if (sci_sas_address_compare(port_sas_address, phy_sas_address) == 0 &&
+ sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0)
+ return sci_port;
}
return NULL;
port_agent->phy_valid_port_range[phy_index].min_index = port_index;
port_agent->phy_valid_port_range[phy_index].max_index = phy_index;
- scic_sds_port_add_phy(&controller->port_table[port_index],
+ scic_sds_port_add_phy(&ihost->ports[port_index].sci,
&ihost->phys[phy_index].sci);
assigned_phy_mask |= (1 << phy_index);
enum sci_status status;
struct scic_sds_port *port;
enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY;
+ struct isci_host *ihost = scic_to_ihost(controller);
port = scic_sds_port_configuration_agent_find_port(controller, phy);
port_index++
) {
- port = &controller->port_table[port_index];
+ port = &ihost->ports[port_index].sci;
/* First we must make sure that this PHY can be added to this Port. */
if (scic_sds_port_is_valid_phy_assignment(port, phy->phy_index)) {
isci_host_change_state(ihost, isci_stopping);
for (i = 0; i < SCI_MAX_PORTS; i++) {
- struct isci_port *port = &ihost->isci_ports[i];
+ struct isci_port *iport = &ihost->ports[i];
struct isci_remote_device *idev, *d;
- list_for_each_entry_safe(idev, d, &port->remote_dev_list, node) {
+ list_for_each_entry_safe(idev, d, &iport->remote_dev_list, node) {
isci_remote_device_change_state(idev, isci_stopping);
isci_remote_device_stop(ihost, idev);
}
return -ENOMEM;
for (i = 0; i < SCI_MAX_PORTS; i++)
- isci_port_init(&isci_host->isci_ports[i], isci_host, i);
+ isci_port_init(&isci_host->ports[i], isci_host, i);
for (i = 0; i < SCI_MAX_PHYS; i++)
isci_phy_init(&isci_host->phys[i], isci_host, i);
struct dma_pool *dma_pool;
unsigned int dma_pool_alloc_size;
struct isci_phy phys[SCI_MAX_PHYS];
-
- /* isci_ports and sas_ports are implicitly parallel to the
- * ports maintained by the core
- */
- struct isci_port isci_ports[SCI_MAX_PORTS];
- struct asd_sas_port sas_ports[SCI_MAX_PORTS];
+ struct isci_port ports[SCI_MAX_PORTS + 1]; /* includes dummy port */
struct sas_ha_struct sas_ha;
int can_queue;
/* set the array of phy and port structs. */
for (i = 0; i < SCI_MAX_PHYS; i++) {
- sas_phys[i] = &(isci_host->phys[i].sas_phy);
- sas_ports[i] = &(isci_host->sas_ports[i]);
+ sas_phys[i] = &isci_host->phys[i].sas_phy;
+ sas_ports[i] = &isci_host->ports[i].sas_port;
}
sas_ha->sas_phy = sas_phys;
#include "request.h"
#include "core/scic_sds_controller.h"
-static void isci_port_change_state(
- struct isci_port *isci_port,
- enum isci_status status);
+static void isci_port_change_state(struct isci_port *iport, enum isci_status status)
+{
+ unsigned long flags;
+ dev_dbg(&iport->isci_host->pdev->dev,
+ "%s: iport = %p, state = 0x%x\n",
+ __func__, iport, status);
+ /* XXX pointless lock */
+ spin_lock_irqsave(&iport->state_lock, flags);
+ iport->status = status;
+ spin_unlock_irqrestore(&iport->state_lock, flags);
+}
void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index)
{
- struct scic_sds_port *sci_port;
-
INIT_LIST_HEAD(&iport->remote_dev_list);
INIT_LIST_HEAD(&iport->domain_dev_list);
spin_lock_init(&iport->state_lock);
init_completion(&iport->start_complete);
iport->isci_host = ihost;
isci_port_change_state(iport, isci_freed);
-
- sci_port = &ihost->sci.port_table[index];
- iport->sci_port_handle = sci_port;
- sci_port->iport = iport;
}
-
/**
* isci_port_get_state() - This function gets the status of the port object.
* @isci_port: This parameter points to the isci_port object
return isci_port->status;
}
-static void isci_port_change_state(
- struct isci_port *isci_port,
- enum isci_status status)
-{
- unsigned long flags;
-
- dev_dbg(&isci_port->isci_host->pdev->dev,
- "%s: isci_port = %p, state = 0x%x\n",
- __func__, isci_port, status);
-
- spin_lock_irqsave(&isci_port->state_lock, flags);
- isci_port->status = status;
- spin_unlock_irqrestore(&isci_port->state_lock, flags);
-}
-
void isci_port_bc_change_received(struct isci_host *ihost,
struct scic_sds_port *sci_port,
struct scic_sds_phy *sci_phy)
unsigned long flags;
struct scic_port_properties properties;
struct isci_phy *isci_phy = sci_phy_to_iphy(phy);
- struct isci_port *isci_port = port->iport;
+ struct isci_port *isci_port = sci_port_to_iport(port);
unsigned long success = true;
BUG_ON(isci_phy->isci_port != NULL);
spin_lock_irqsave(&ihost->scic_lock, flags);
#define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT
- status = scic_port_hard_reset(iport->sci_port_handle,
- ISCI_PORT_RESET_TIMEOUT);
+ status = scic_port_hard_reset(&iport->sci, ISCI_PORT_RESET_TIMEOUT);
spin_unlock_irqrestore(&ihost->scic_lock, flags);
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/**
- * This file contains the isci_port object definition.
- *
- * port.h
- */
-
-#if !defined(_ISCI_PORT_H_)
+#ifndef _ISCI_PORT_H_
#define _ISCI_PORT_H_
+#include "scic_sds_port.h"
struct isci_phy;
struct isci_host;
-struct scic_sds_phy;
-
enum isci_status {
isci_freed = 0x00,
*
*/
struct isci_port {
-
- struct scic_sds_port *sci_port_handle;
-
enum isci_status status;
struct isci_host *isci_host;
struct asd_sas_port sas_port;
struct completion start_complete;
struct completion hard_reset_complete;
enum sci_status hard_reset_status;
+ struct scic_sds_port sci;
};
-#define to_isci_port(p) \
- container_of(p, struct isci_port, sas_port);
+static inline struct isci_port *sci_port_to_iport(struct scic_sds_port *sci_port)
+{
+ struct isci_port *iport = container_of(sci_port, typeof(*iport), sci);
+
+ return iport;
+}
enum isci_status isci_port_get_state(
struct isci_port *isci_port);
-
-
void isci_port_formed(
struct asd_sas_phy *);
static enum sci_status isci_remote_device_construct(struct isci_port *iport,
struct isci_remote_device *idev)
{
- struct scic_sds_port *sci_port = iport->sci_port_handle;
+ struct scic_sds_port *sci_port = &iport->sci;
struct isci_host *ihost = iport->isci_host;
struct domain_device *dev = idev->domain_dev;
enum sci_status status;
static inline struct device *sciport_to_dev(struct scic_sds_port *sci_port)
{
- struct isci_port *iport = sci_port->iport;
+ struct isci_port *iport = sci_port_to_iport(sci_port);
if (!iport || !iport->isci_host)
return NULL;