Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e531381e authored by Dan Williams's avatar Dan Williams
Browse files

isci: unify port data structures



Make scic_sds_port a member of isci_port and merge their lifetimes which
means removing the port table from scic_sds_controller in favor of the
one at the isci_host level.  Merge ihost->sas_ports into ihost->ports.
_
Reported-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 4b33981a
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -623,9 +623,10 @@ static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller
	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;
@@ -2686,7 +2687,7 @@ enum sci_status scic_controller_initialize(struct scic_sds_controller *scic)
		     (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]);
@@ -2711,6 +2712,7 @@ enum sci_status scic_controller_initialize(struct scic_sds_controller *scic)
enum sci_status scic_controller_start(struct scic_sds_controller *scic,
				      u32 timeout)
{
	struct isci_host *ihost = scic_to_ihost(scic);
	enum sci_status result;
	u16 index;

@@ -2752,10 +2754,9 @@ enum sci_status scic_controller_start(struct scic_sds_controller *scic,

	/* 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;
	}
@@ -2944,14 +2945,14 @@ enum sci_status scic_controller_construct(struct scic_sds_controller *scic,

	/* 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;
+0 −7
Original line number Diff line number Diff line
@@ -160,13 +160,6 @@ struct scic_sds_controller {
	 */
	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
+17 −27
Original line number Diff line number Diff line
@@ -283,18 +283,14 @@ static enum sci_status scic_sds_port_clear_phy(
	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;
	}

@@ -643,7 +639,7 @@ void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
				  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);

@@ -1620,10 +1616,9 @@ static void scic_sds_port_ready_substate_operational_enter(void *object)
{
	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,
@@ -1661,10 +1656,9 @@ static void scic_sds_port_ready_substate_operational_enter(void *object)
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
@@ -1692,10 +1686,9 @@ static void scic_sds_port_ready_substate_operational_exit(void *object)
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,
@@ -2259,7 +2252,7 @@ static void scic_sds_port_ready_state_enter(void *object)
	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 */
@@ -2366,7 +2359,7 @@ scic_sds_port_stopping_state_exit(void *object)
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);
@@ -2398,11 +2391,9 @@ static const struct sci_base_state scic_sds_port_state_table[] = {
	}
};

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,
@@ -2416,7 +2407,7 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
					 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;
@@ -2428,7 +2419,6 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
	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++)
+0 −5
Original line number Diff line number Diff line
@@ -151,17 +151,12 @@ enum scic_sds_port_states {

};

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.
+10 −8
Original line number Diff line number Diff line
@@ -141,14 +141,15 @@ static struct scic_sds_port *scic_sds_port_configuration_agent_find_port(
	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;
@@ -324,7 +325,7 @@ static enum sci_status scic_sds_mpc_agent_validate_phy_configuration(
			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);
@@ -550,6 +551,7 @@ static void scic_sds_apc_agent_configure_ports(
	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);

@@ -571,7 +573,7 @@ static void scic_sds_apc_agent_configure_ports(
			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)) {
Loading