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

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

isci: kill smp_discover_response_protocols in favor of domain_device.dev_type



This is step 1 of removing the contortions to:
1/ unparse expander phy data into a smp discover frame
2/ open-code-parse the smp discover fram into a domain_device.dev_type equivalent

libsas has already spent cycles determining the dev_type, so now that
scic_sds_remote_device is unified with isci_remote_device we can
directly reference dev_type.

This might also change multi-level expander detection as we previously only
looked at dev_type == EDGE_DEV and we did not consider the FANOUT_DEV case.

Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent b87ee307
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -74,9 +74,9 @@
#include "scic_sds_port.h"
#include "scic_sds_phy.h"
#include "remote_node_table.h"
#include "remote_device.h"
#include "scu_registers.h"
#include "scu_constants.h"
#include "scu_remote_node_context.h"
#include "scu_task_context.h"
#include "scu_unsolicited_frame.h"
#include "scic_sds_unsolicited_frame_control.h"
@@ -498,14 +498,16 @@ enum scic_sds_controller_states {
#define scic_sds_io_sequence_increment(value) \
	((value) = (((value) + 1) & 0x000F))

#define scic_sds_remote_device_node_count(device) \
	(\
		(\
			(device)->target_protocols.u.bits.attached_stp_target \
			&& ((device)->is_direct_attached != true) \
		) \
		? SCU_STP_REMOTE_NODE_COUNT : SCU_SSP_REMOTE_NODE_COUNT	\
	)
/* expander attached sata devices require 3 rnc slots */
static inline int scic_sds_remote_device_node_count(struct scic_sds_remote_device *sci_dev)
{
	struct domain_device *dev = sci_dev_to_domain(sci_dev);

	if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) &&
	    !sci_dev->is_direct_attached)
		return SCU_STP_REMOTE_NODE_COUNT;
	return SCU_SSP_REMOTE_NODE_COUNT;
}

/**
 * scic_sds_controller_set_invalid_phy() -
+1 −1
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ void scic_sds_port_get_attached_sas_address(
 *    multi-protocol support.
 *
 */
void scic_sds_port_get_attached_protocols(
static void scic_sds_port_get_attached_protocols(
	struct scic_sds_port *sci_port,
	struct sci_sas_identify_address_frame_protocols *protocols)
{
+0 −4
Original line number Diff line number Diff line
@@ -447,8 +447,4 @@ void scic_sds_port_get_attached_sas_address(
	struct scic_sds_port *sci_port,
	struct sci_sas_address *sas_address);

void scic_sds_port_get_attached_protocols(
	struct scic_sds_port *sci_port,
	struct sci_sas_identify_address_frame_protocols *protocols);

#endif /* _SCIC_SDS_PORT_H_ */
+9 −15
Original line number Diff line number Diff line
@@ -1758,8 +1758,8 @@ enum sci_status scic_io_request_construct(struct scic_sds_controller *scic,
					  struct scic_sds_request *sci_req,
					  struct scic_sds_request **new_scic_io_request_handle)
{
	struct domain_device *dev = sci_dev_to_domain(sci_dev);
	enum sci_status status = SCI_SUCCESS;
	struct smp_discover_response_protocols device_protocol;

	/* Build the common part of the request */
	scic_sds_general_request_construct(scic, sci_dev, io_tag,
@@ -1768,19 +1768,16 @@ enum sci_status scic_io_request_construct(struct scic_sds_controller *scic,
	if (sci_dev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
		return SCI_FAILURE_INVALID_REMOTE_DEVICE;

	scic_remote_device_get_protocols(sci_dev, &device_protocol);

	if (device_protocol.u.bits.attached_ssp_target) {
	if (dev->dev_type == SAS_END_DEV) {
		scic_sds_ssp_io_request_assign_buffers(sci_req);
	} else if (device_protocol.u.bits.attached_stp_target) {
	} else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
		scic_sds_stp_request_assign_buffers(sci_req);
		memset(sci_req->command_buffer, 0, sizeof(struct sata_fis_reg_h2d));
	} else if (device_protocol.u.bits.attached_smp_target) {
	} else if (dev_is_expander(dev)) {
		scic_sds_smp_request_assign_buffers(sci_req);
		memset(sci_req->command_buffer, 0, sizeof(struct smp_request));
	} else {
	} else
		status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
	}

	if (status == SCI_SUCCESS) {
		memset(sci_req->task_context_buffer, 0,
@@ -1798,17 +1795,15 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
					    struct scic_sds_request *sci_req,
					    struct scic_sds_request **new_sci_req)
{
	struct domain_device *dev = sci_dev_to_domain(sci_dev);
	enum sci_status status = SCI_SUCCESS;
	struct smp_discover_response_protocols device_protocol;

	/* Build the common part of the request */
	scic_sds_general_request_construct(scic, sci_dev, io_tag,
					   user_io_request_object,
					   sci_req);

	scic_remote_device_get_protocols(sci_dev, &device_protocol);

	if (device_protocol.u.bits.attached_ssp_target) {
	if (dev->dev_type == SAS_END_DEV) {
		scic_sds_ssp_task_request_assign_buffers(sci_req);

		sci_req->has_started_substate_machine = true;
@@ -1820,11 +1815,10 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
			scic_sds_io_request_started_task_mgmt_substate_table,
			SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
			);
	} else if (device_protocol.u.bits.attached_stp_target) {
	} else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))
		scic_sds_stp_request_assign_buffers(sci_req);
	} else {
	else
		status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
	}

	if (status == SCI_SUCCESS) {
		sci_req->is_task_management_request = true;
+47 −63
Original line number Diff line number Diff line
@@ -100,13 +100,6 @@ enum sas_linkrate scic_remote_device_get_connection_rate(
}


void scic_remote_device_get_protocols(
	struct scic_sds_remote_device *sci_dev,
	struct smp_discover_response_protocols *pr)
{
	pr->u.all = sci_dev->target_protocols.u.all;
}

#if !defined(DISABLE_ATAPI)
bool scic_remote_device_is_atapi(struct scic_sds_remote_device *sci_dev)
{
@@ -1490,7 +1483,7 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
{
	enum sci_status status;
	u16 remote_node_index;
	struct sci_sas_identify_address_frame_protocols protocols;
	struct domain_device *dev = sci_dev_to_domain(sci_dev);

	scic_remote_device_construct(sci_port, sci_dev);

@@ -1498,27 +1491,21 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
	 * This information is request to determine how many remote node context
	 * entries will be needed to store the remote node.
	 */
	scic_sds_port_get_attached_protocols(sci_dev->owning_port, &protocols);
	sci_dev->target_protocols.u.all = protocols.u.all;
	sci_dev->is_direct_attached = true;
#if !defined(DISABLE_ATAPI)
	sci_dev->is_atapi = scic_sds_remote_device_is_atapi(sci_dev);
#endif

	status = scic_sds_controller_allocate_remote_node_context(
		sci_dev->owning_port->owning_controller,
	status = scic_sds_controller_allocate_remote_node_context(sci_port->owning_controller,
								  sci_dev,
								  &remote_node_index);

	if (status == SCI_SUCCESS) {
	if (status != SCI_SUCCESS)
		return status;

	sci_dev->rnc.remote_node_index = remote_node_index;

		scic_sds_port_get_attached_sas_address(
			sci_dev->owning_port, &sci_dev->device_address);
	scic_sds_port_get_attached_sas_address(sci_port, &sci_dev->device_address);

		if (sci_dev->target_protocols.u.bits.attached_ssp_target) {
	if (dev->dev_type == SAS_END_DEV)
		sci_dev->has_ready_substate_machine = false;
		} else if (sci_dev->target_protocols.u.bits.attached_stp_target) {
	else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
		sci_dev->has_ready_substate_machine = true;

		sci_base_state_machine_construct(
@@ -1526,7 +1513,7 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
				&sci_dev->parent,
				scic_sds_stp_remote_device_ready_substate_table,
				SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
		} else if (sci_dev->target_protocols.u.bits.attached_smp_target) {
	} else if (dev_is_expander(dev)) {
		sci_dev->has_ready_substate_machine = true;

		/* add the SMP ready substate machine construction here */
@@ -1535,16 +1522,15 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
				&sci_dev->parent,
				scic_sds_smp_remote_device_ready_substate_table,
				SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
		}
	} else
		return SCI_FAILURE_UNSUPPORTED_PROTOCOL;

		sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed(
			sci_dev->owning_port);
	sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed(sci_port);

	/* / @todo Should I assign the port width by reading all of the phys on the port? */
	sci_dev->device_port_width = 1;
	}

	return status;
	return SCI_SUCCESS;
}

static void scic_sds_remote_device_get_info_from_smp_discover_response(
@@ -1557,8 +1543,6 @@ static void scic_sds_remote_device_get_info_from_smp_discover_response(

	sci_dev->device_address.low =
		discover_response->attached_sas_address.low;

	sci_dev->target_protocols.u.all = discover_response->protocols.u.all;
}

/**
@@ -1579,6 +1563,7 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
						       struct smp_response_discover *discover_response)
{
	struct scic_sds_controller *scic = sci_port->owning_controller;
	struct domain_device *dev = sci_dev_to_domain(sci_dev);
	enum sci_status status;

	scic_remote_device_construct(sci_port, sci_dev);
@@ -1588,11 +1573,12 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci

	status = scic_sds_controller_allocate_remote_node_context(
		scic, sci_dev, &sci_dev->rnc.remote_node_index);
	if (status != SCI_SUCCESS)
		return status;

	if (status == SCI_SUCCESS) {
		if (sci_dev->target_protocols.u.bits.attached_ssp_target) {
	if (dev->dev_type == SAS_END_DEV)
		sci_dev->has_ready_substate_machine = false;
		} else if (sci_dev->target_protocols.u.bits.attached_smp_target) {
	else if (dev_is_expander(dev)) {
		sci_dev->has_ready_substate_machine = true;

		/* add the SMP ready substate machine construction here */
@@ -1601,7 +1587,7 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
				&sci_dev->parent,
				scic_sds_smp_remote_device_ready_substate_table,
				SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
		} else if (sci_dev->target_protocols.u.bits.attached_stp_target) {
	} else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
		sci_dev->has_ready_substate_machine = true;

		sci_base_state_machine_construct(
@@ -1618,13 +1604,11 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
	 * connection the logical link rate is that same as the
	 * physical.  Furthermore, the SAS-2 and SAS-1.1 fields overlay
	 * one another, so this code works for both situations. */
		sci_dev->connection_rate = min_t(u16,
			scic_sds_port_get_max_allowed_speed(sci_port),
	sci_dev->connection_rate = min_t(u16, scic_sds_port_get_max_allowed_speed(sci_port),
			discover_response->u2.sas1_1.negotiated_physical_link_rate);

	/* / @todo Should I assign the port width by reading all of the phys on the port? */
	sci_dev->device_port_width = 1;
	}

	return status;
}
@@ -1665,7 +1649,7 @@ static enum sci_status isci_remote_device_construct(
	enum sci_status status = SCI_SUCCESS;

	if (isci_device->domain_dev->parent &&
	    (isci_device->domain_dev->parent->dev_type == EDGE_DEV)) {
	    dev_is_expander(isci_device->domain_dev->parent)) {
		int i;

		/* struct smp_response_discover discover_response; */
Loading