aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/isci')
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.h20
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.c2
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.h4
-rw-r--r--drivers/scsi/isci/core/scic_sds_request.c24
-rw-r--r--drivers/scsi/isci/remote_device.c110
-rw-r--r--drivers/scsi/isci/remote_device.h34
-rw-r--r--drivers/scsi/isci/remote_node_context.c63
-rw-r--r--drivers/scsi/isci/request.c19
-rw-r--r--drivers/scsi/isci/task.c20
9 files changed, 118 insertions, 178 deletions
diff --git a/drivers/scsi/isci/core/scic_sds_controller.h b/drivers/scsi/isci/core/scic_sds_controller.h
index e15c4e2fd76d..ce81286e52fd 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.h
+++ b/drivers/scsi/isci/core/scic_sds_controller.h
@@ -74,9 +74,9 @@
74#include "scic_sds_port.h" 74#include "scic_sds_port.h"
75#include "scic_sds_phy.h" 75#include "scic_sds_phy.h"
76#include "remote_node_table.h" 76#include "remote_node_table.h"
77#include "remote_device.h"
77#include "scu_registers.h" 78#include "scu_registers.h"
78#include "scu_constants.h" 79#include "scu_constants.h"
79#include "scu_remote_node_context.h"
80#include "scu_task_context.h" 80#include "scu_task_context.h"
81#include "scu_unsolicited_frame.h" 81#include "scu_unsolicited_frame.h"
82#include "scic_sds_unsolicited_frame_control.h" 82#include "scic_sds_unsolicited_frame_control.h"
@@ -498,14 +498,16 @@ enum scic_sds_controller_states {
498#define scic_sds_io_sequence_increment(value) \ 498#define scic_sds_io_sequence_increment(value) \
499 ((value) = (((value) + 1) & 0x000F)) 499 ((value) = (((value) + 1) & 0x000F))
500 500
501#define scic_sds_remote_device_node_count(device) \ 501/* expander attached sata devices require 3 rnc slots */
502 (\ 502static inline int scic_sds_remote_device_node_count(struct scic_sds_remote_device *sci_dev)
503 (\ 503{
504 (device)->target_protocols.u.bits.attached_stp_target \ 504 struct domain_device *dev = sci_dev_to_domain(sci_dev);
505 && ((device)->is_direct_attached != true) \ 505
506 ) \ 506 if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) &&
507 ? SCU_STP_REMOTE_NODE_COUNT : SCU_SSP_REMOTE_NODE_COUNT \ 507 !sci_dev->is_direct_attached)
508 ) 508 return SCU_STP_REMOTE_NODE_COUNT;
509 return SCU_SSP_REMOTE_NODE_COUNT;
510}
509 511
510/** 512/**
511 * scic_sds_controller_set_invalid_phy() - 513 * scic_sds_controller_set_invalid_phy() -
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c
index b07e48e2f188..057f95a79be9 100644
--- a/drivers/scsi/isci/core/scic_sds_port.c
+++ b/drivers/scsi/isci/core/scic_sds_port.c
@@ -434,7 +434,7 @@ void scic_sds_port_get_attached_sas_address(
434 * multi-protocol support. 434 * multi-protocol support.
435 * 435 *
436 */ 436 */
437void scic_sds_port_get_attached_protocols( 437static void scic_sds_port_get_attached_protocols(
438 struct scic_sds_port *sci_port, 438 struct scic_sds_port *sci_port,
439 struct sci_sas_identify_address_frame_protocols *protocols) 439 struct sci_sas_identify_address_frame_protocols *protocols)
440{ 440{
diff --git a/drivers/scsi/isci/core/scic_sds_port.h b/drivers/scsi/isci/core/scic_sds_port.h
index 964e3885dbf2..59c76cd3902f 100644
--- a/drivers/scsi/isci/core/scic_sds_port.h
+++ b/drivers/scsi/isci/core/scic_sds_port.h
@@ -447,8 +447,4 @@ void scic_sds_port_get_attached_sas_address(
447 struct scic_sds_port *sci_port, 447 struct scic_sds_port *sci_port,
448 struct sci_sas_address *sas_address); 448 struct sci_sas_address *sas_address);
449 449
450void scic_sds_port_get_attached_protocols(
451 struct scic_sds_port *sci_port,
452 struct sci_sas_identify_address_frame_protocols *protocols);
453
454#endif /* _SCIC_SDS_PORT_H_ */ 450#endif /* _SCIC_SDS_PORT_H_ */
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c
index dfb94121d445..a66e7b248b24 100644
--- a/drivers/scsi/isci/core/scic_sds_request.c
+++ b/drivers/scsi/isci/core/scic_sds_request.c
@@ -1758,8 +1758,8 @@ enum sci_status scic_io_request_construct(struct scic_sds_controller *scic,
1758 struct scic_sds_request *sci_req, 1758 struct scic_sds_request *sci_req,
1759 struct scic_sds_request **new_scic_io_request_handle) 1759 struct scic_sds_request **new_scic_io_request_handle)
1760{ 1760{
1761 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1761 enum sci_status status = SCI_SUCCESS; 1762 enum sci_status status = SCI_SUCCESS;
1762 struct smp_discover_response_protocols device_protocol;
1763 1763
1764 /* Build the common part of the request */ 1764 /* Build the common part of the request */
1765 scic_sds_general_request_construct(scic, sci_dev, io_tag, 1765 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,
1768 if (sci_dev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) 1768 if (sci_dev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
1769 return SCI_FAILURE_INVALID_REMOTE_DEVICE; 1769 return SCI_FAILURE_INVALID_REMOTE_DEVICE;
1770 1770
1771 scic_remote_device_get_protocols(sci_dev, &device_protocol); 1771 if (dev->dev_type == SAS_END_DEV) {
1772
1773 if (device_protocol.u.bits.attached_ssp_target) {
1774 scic_sds_ssp_io_request_assign_buffers(sci_req); 1772 scic_sds_ssp_io_request_assign_buffers(sci_req);
1775 } else if (device_protocol.u.bits.attached_stp_target) { 1773 } else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
1776 scic_sds_stp_request_assign_buffers(sci_req); 1774 scic_sds_stp_request_assign_buffers(sci_req);
1777 memset(sci_req->command_buffer, 0, sizeof(struct sata_fis_reg_h2d)); 1775 memset(sci_req->command_buffer, 0, sizeof(struct sata_fis_reg_h2d));
1778 } else if (device_protocol.u.bits.attached_smp_target) { 1776 } else if (dev_is_expander(dev)) {
1779 scic_sds_smp_request_assign_buffers(sci_req); 1777 scic_sds_smp_request_assign_buffers(sci_req);
1780 memset(sci_req->command_buffer, 0, sizeof(struct smp_request)); 1778 memset(sci_req->command_buffer, 0, sizeof(struct smp_request));
1781 } else { 1779 } else
1782 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; 1780 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
1783 }
1784 1781
1785 if (status == SCI_SUCCESS) { 1782 if (status == SCI_SUCCESS) {
1786 memset(sci_req->task_context_buffer, 0, 1783 memset(sci_req->task_context_buffer, 0,
@@ -1798,17 +1795,15 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
1798 struct scic_sds_request *sci_req, 1795 struct scic_sds_request *sci_req,
1799 struct scic_sds_request **new_sci_req) 1796 struct scic_sds_request **new_sci_req)
1800{ 1797{
1798 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1801 enum sci_status status = SCI_SUCCESS; 1799 enum sci_status status = SCI_SUCCESS;
1802 struct smp_discover_response_protocols device_protocol;
1803 1800
1804 /* Build the common part of the request */ 1801 /* Build the common part of the request */
1805 scic_sds_general_request_construct(scic, sci_dev, io_tag, 1802 scic_sds_general_request_construct(scic, sci_dev, io_tag,
1806 user_io_request_object, 1803 user_io_request_object,
1807 sci_req); 1804 sci_req);
1808 1805
1809 scic_remote_device_get_protocols(sci_dev, &device_protocol); 1806 if (dev->dev_type == SAS_END_DEV) {
1810
1811 if (device_protocol.u.bits.attached_ssp_target) {
1812 scic_sds_ssp_task_request_assign_buffers(sci_req); 1807 scic_sds_ssp_task_request_assign_buffers(sci_req);
1813 1808
1814 sci_req->has_started_substate_machine = true; 1809 sci_req->has_started_substate_machine = true;
@@ -1820,11 +1815,10 @@ enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
1820 scic_sds_io_request_started_task_mgmt_substate_table, 1815 scic_sds_io_request_started_task_mgmt_substate_table,
1821 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION 1816 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
1822 ); 1817 );
1823 } else if (device_protocol.u.bits.attached_stp_target) { 1818 } else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))
1824 scic_sds_stp_request_assign_buffers(sci_req); 1819 scic_sds_stp_request_assign_buffers(sci_req);
1825 } else { 1820 else
1826 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; 1821 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
1827 }
1828 1822
1829 if (status == SCI_SUCCESS) { 1823 if (status == SCI_SUCCESS) {
1830 sci_req->is_task_management_request = true; 1824 sci_req->is_task_management_request = true;
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 70641818f602..fc79a5b47f72 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -100,13 +100,6 @@ enum sas_linkrate scic_remote_device_get_connection_rate(
100} 100}
101 101
102 102
103void scic_remote_device_get_protocols(
104 struct scic_sds_remote_device *sci_dev,
105 struct smp_discover_response_protocols *pr)
106{
107 pr->u.all = sci_dev->target_protocols.u.all;
108}
109
110#if !defined(DISABLE_ATAPI) 103#if !defined(DISABLE_ATAPI)
111bool scic_remote_device_is_atapi(struct scic_sds_remote_device *sci_dev) 104bool scic_remote_device_is_atapi(struct scic_sds_remote_device *sci_dev)
112{ 105{
@@ -1490,7 +1483,7 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
1490{ 1483{
1491 enum sci_status status; 1484 enum sci_status status;
1492 u16 remote_node_index; 1485 u16 remote_node_index;
1493 struct sci_sas_identify_address_frame_protocols protocols; 1486 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1494 1487
1495 scic_remote_device_construct(sci_port, sci_dev); 1488 scic_remote_device_construct(sci_port, sci_dev);
1496 1489
@@ -1498,53 +1491,46 @@ static enum sci_status scic_remote_device_da_construct(struct scic_sds_port *sci
1498 * This information is request to determine how many remote node context 1491 * This information is request to determine how many remote node context
1499 * entries will be needed to store the remote node. 1492 * entries will be needed to store the remote node.
1500 */ 1493 */
1501 scic_sds_port_get_attached_protocols(sci_dev->owning_port, &protocols);
1502 sci_dev->target_protocols.u.all = protocols.u.all;
1503 sci_dev->is_direct_attached = true; 1494 sci_dev->is_direct_attached = true;
1504#if !defined(DISABLE_ATAPI) 1495 status = scic_sds_controller_allocate_remote_node_context(sci_port->owning_controller,
1505 sci_dev->is_atapi = scic_sds_remote_device_is_atapi(sci_dev); 1496 sci_dev,
1506#endif 1497 &remote_node_index);
1507 1498
1508 status = scic_sds_controller_allocate_remote_node_context( 1499 if (status != SCI_SUCCESS)
1509 sci_dev->owning_port->owning_controller, 1500 return status;
1510 sci_dev,
1511 &remote_node_index);
1512 1501
1513 if (status == SCI_SUCCESS) { 1502 sci_dev->rnc.remote_node_index = remote_node_index;
1514 sci_dev->rnc.remote_node_index = remote_node_index;
1515 1503
1516 scic_sds_port_get_attached_sas_address( 1504 scic_sds_port_get_attached_sas_address(sci_port, &sci_dev->device_address);
1517 sci_dev->owning_port, &sci_dev->device_address);
1518 1505
1519 if (sci_dev->target_protocols.u.bits.attached_ssp_target) { 1506 if (dev->dev_type == SAS_END_DEV)
1520 sci_dev->has_ready_substate_machine = false; 1507 sci_dev->has_ready_substate_machine = false;
1521 } else if (sci_dev->target_protocols.u.bits.attached_stp_target) { 1508 else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
1522 sci_dev->has_ready_substate_machine = true; 1509 sci_dev->has_ready_substate_machine = true;
1523 1510
1524 sci_base_state_machine_construct( 1511 sci_base_state_machine_construct(
1525 &sci_dev->ready_substate_machine, 1512 &sci_dev->ready_substate_machine,
1526 &sci_dev->parent, 1513 &sci_dev->parent,
1527 scic_sds_stp_remote_device_ready_substate_table, 1514 scic_sds_stp_remote_device_ready_substate_table,
1528 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); 1515 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
1529 } else if (sci_dev->target_protocols.u.bits.attached_smp_target) { 1516 } else if (dev_is_expander(dev)) {
1530 sci_dev->has_ready_substate_machine = true; 1517 sci_dev->has_ready_substate_machine = true;
1531 1518
1532 /* add the SMP ready substate machine construction here */ 1519 /* add the SMP ready substate machine construction here */
1533 sci_base_state_machine_construct( 1520 sci_base_state_machine_construct(
1534 &sci_dev->ready_substate_machine, 1521 &sci_dev->ready_substate_machine,
1535 &sci_dev->parent, 1522 &sci_dev->parent,
1536 scic_sds_smp_remote_device_ready_substate_table, 1523 scic_sds_smp_remote_device_ready_substate_table,
1537 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); 1524 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
1538 } 1525 } else
1526 return SCI_FAILURE_UNSUPPORTED_PROTOCOL;
1539 1527
1540 sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed( 1528 sci_dev->connection_rate = scic_sds_port_get_max_allowed_speed(sci_port);
1541 sci_dev->owning_port);
1542 1529
1543 /* / @todo Should I assign the port width by reading all of the phys on the port? */ 1530 /* / @todo Should I assign the port width by reading all of the phys on the port? */
1544 sci_dev->device_port_width = 1; 1531 sci_dev->device_port_width = 1;
1545 }
1546 1532
1547 return status; 1533 return SCI_SUCCESS;
1548} 1534}
1549 1535
1550static void scic_sds_remote_device_get_info_from_smp_discover_response( 1536static 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(
1557 1543
1558 sci_dev->device_address.low = 1544 sci_dev->device_address.low =
1559 discover_response->attached_sas_address.low; 1545 discover_response->attached_sas_address.low;
1560
1561 sci_dev->target_protocols.u.all = discover_response->protocols.u.all;
1562} 1546}
1563 1547
1564/** 1548/**
@@ -1579,6 +1563,7 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
1579 struct smp_response_discover *discover_response) 1563 struct smp_response_discover *discover_response)
1580{ 1564{
1581 struct scic_sds_controller *scic = sci_port->owning_controller; 1565 struct scic_sds_controller *scic = sci_port->owning_controller;
1566 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1582 enum sci_status status; 1567 enum sci_status status;
1583 1568
1584 scic_remote_device_construct(sci_port, sci_dev); 1569 scic_remote_device_construct(sci_port, sci_dev);
@@ -1588,43 +1573,42 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
1588 1573
1589 status = scic_sds_controller_allocate_remote_node_context( 1574 status = scic_sds_controller_allocate_remote_node_context(
1590 scic, sci_dev, &sci_dev->rnc.remote_node_index); 1575 scic, sci_dev, &sci_dev->rnc.remote_node_index);
1576 if (status != SCI_SUCCESS)
1577 return status;
1591 1578
1592 if (status == SCI_SUCCESS) { 1579 if (dev->dev_type == SAS_END_DEV)
1593 if (sci_dev->target_protocols.u.bits.attached_ssp_target) { 1580 sci_dev->has_ready_substate_machine = false;
1594 sci_dev->has_ready_substate_machine = false; 1581 else if (dev_is_expander(dev)) {
1595 } else if (sci_dev->target_protocols.u.bits.attached_smp_target) { 1582 sci_dev->has_ready_substate_machine = true;
1596 sci_dev->has_ready_substate_machine = true;
1597 1583
1598 /* add the SMP ready substate machine construction here */ 1584 /* add the SMP ready substate machine construction here */
1599 sci_base_state_machine_construct( 1585 sci_base_state_machine_construct(
1600 &sci_dev->ready_substate_machine, 1586 &sci_dev->ready_substate_machine,
1601 &sci_dev->parent, 1587 &sci_dev->parent,
1602 scic_sds_smp_remote_device_ready_substate_table, 1588 scic_sds_smp_remote_device_ready_substate_table,
1603 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); 1589 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
1604 } else if (sci_dev->target_protocols.u.bits.attached_stp_target) { 1590 } else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
1605 sci_dev->has_ready_substate_machine = true; 1591 sci_dev->has_ready_substate_machine = true;
1606 1592
1607 sci_base_state_machine_construct( 1593 sci_base_state_machine_construct(
1608 &sci_dev->ready_substate_machine, 1594 &sci_dev->ready_substate_machine,
1609 &sci_dev->parent, 1595 &sci_dev->parent,
1610 scic_sds_stp_remote_device_ready_substate_table, 1596 scic_sds_stp_remote_device_ready_substate_table,
1611 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); 1597 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
1612 } 1598 }
1613 1599
1614 /* 1600 /*
1615 * For SAS-2 the physical link rate is actually a logical link 1601 * For SAS-2 the physical link rate is actually a logical link
1616 * rate that incorporates multiplexing. The SCU doesn't 1602 * rate that incorporates multiplexing. The SCU doesn't
1617 * incorporate multiplexing and for the purposes of the 1603 * incorporate multiplexing and for the purposes of the
1618 * connection the logical link rate is that same as the 1604 * connection the logical link rate is that same as the
1619 * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay 1605 * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay
1620 * one another, so this code works for both situations. */ 1606 * one another, so this code works for both situations. */
1621 sci_dev->connection_rate = min_t(u16, 1607 sci_dev->connection_rate = min_t(u16, scic_sds_port_get_max_allowed_speed(sci_port),
1622 scic_sds_port_get_max_allowed_speed(sci_port),
1623 discover_response->u2.sas1_1.negotiated_physical_link_rate); 1608 discover_response->u2.sas1_1.negotiated_physical_link_rate);
1624 1609
1625 /* / @todo Should I assign the port width by reading all of the phys on the port? */ 1610 /* / @todo Should I assign the port width by reading all of the phys on the port? */
1626 sci_dev->device_port_width = 1; 1611 sci_dev->device_port_width = 1;
1627 }
1628 1612
1629 return status; 1613 return status;
1630} 1614}
@@ -1665,7 +1649,7 @@ static enum sci_status isci_remote_device_construct(
1665 enum sci_status status = SCI_SUCCESS; 1649 enum sci_status status = SCI_SUCCESS;
1666 1650
1667 if (isci_device->domain_dev->parent && 1651 if (isci_device->domain_dev->parent &&
1668 (isci_device->domain_dev->parent->dev_type == EDGE_DEV)) { 1652 dev_is_expander(isci_device->domain_dev->parent)) {
1669 int i; 1653 int i;
1670 1654
1671 /* struct smp_response_discover discover_response; */ 1655 /* struct smp_response_discover discover_response; */
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h
index 9d8fcbf72ded..39821601022b 100644
--- a/drivers/scsi/isci/remote_device.h
+++ b/drivers/scsi/isci/remote_device.h
@@ -100,11 +100,6 @@ struct scic_sds_remote_device {
100 enum sas_linkrate connection_rate; 100 enum sas_linkrate connection_rate;
101 101
102 /** 102 /**
103 * This field contains the allowed target protocols for this remote device.
104 */
105 struct smp_discover_response_protocols target_protocols;
106
107 /**
108 * This field contains the device SAS address. 103 * This field contains the device SAS address.
109 */ 104 */
110 struct sci_sas_address device_address; 105 struct sci_sas_address device_address;
@@ -264,23 +259,6 @@ enum sci_status scic_remote_device_reset_complete(
264enum sas_linkrate scic_remote_device_get_connection_rate( 259enum sas_linkrate scic_remote_device_get_connection_rate(
265 struct scic_sds_remote_device *remote_device); 260 struct scic_sds_remote_device *remote_device);
266 261
267/**
268 * scic_remote_device_get_protocols() - This method will indicate which
269 * protocols are supported by this remote device.
270 * @remote_device: This parameter specifies the device for which to return the
271 * protocol.
272 * @protocols: This parameter specifies the output values, from the remote
273 * device object, which indicate the protocols supported by the supplied
274 * remote_device.
275 *
276 * The type of protocols supported by this device. The values are returned as
277 * part of a bit mask in order to allow for multi-protocol support.
278 */
279void scic_remote_device_get_protocols(
280 struct scic_sds_remote_device *remote_device,
281 struct smp_discover_response_protocols *protocols);
282
283
284#if !defined(DISABLE_ATAPI) 262#if !defined(DISABLE_ATAPI)
285/** 263/**
286 * scic_remote_device_is_atapi() - 264 * scic_remote_device_is_atapi() -
@@ -477,6 +455,18 @@ static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_n
477 return sci_dev; 455 return sci_dev;
478} 456}
479 457
458static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev)
459{
460 struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci);
461
462 return idev->domain_dev;
463}
464
465static inline bool dev_is_expander(struct domain_device *dev)
466{
467 return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV;
468}
469
480typedef enum sci_status (*scic_sds_remote_device_request_handler_t)( 470typedef enum sci_status (*scic_sds_remote_device_request_handler_t)(
481 struct scic_sds_remote_device *device, 471 struct scic_sds_remote_device *device,
482 struct scic_sds_request *request); 472 struct scic_sds_request *request);
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index bdf0b5101cfa..285232fd5e63 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -106,8 +106,9 @@ bool scic_sds_remote_node_context_is_ready(
106static void scic_sds_remote_node_context_construct_buffer( 106static void scic_sds_remote_node_context_construct_buffer(
107 struct scic_sds_remote_node_context *sci_rnc) 107 struct scic_sds_remote_node_context *sci_rnc)
108{ 108{
109 union scu_remote_node_context *rnc;
110 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc); 109 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
110 struct domain_device *dev = sci_dev_to_domain(sci_dev);
111 union scu_remote_node_context *rnc;
111 struct scic_sds_controller *scic; 112 struct scic_sds_controller *scic;
112 113
113 scic = scic_sds_remote_device_get_controller(sci_dev); 114 scic = scic_sds_remote_device_get_controller(sci_dev);
@@ -134,11 +135,7 @@ static void scic_sds_remote_node_context_construct_buffer(
134 135
135 rnc->ssp.arbitration_wait_time = 0; 136 rnc->ssp.arbitration_wait_time = 0;
136 137
137 138 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
138 if (
139 sci_dev->target_protocols.u.bits.attached_sata_device
140 || sci_dev->target_protocols.u.bits.attached_stp_target
141 ) {
142 rnc->ssp.connection_occupancy_timeout = 139 rnc->ssp.connection_occupancy_timeout =
143 scic->user_parameters.sds1.stp_max_occupancy_timeout; 140 scic->user_parameters.sds1.stp_max_occupancy_timeout;
144 rnc->ssp.connection_inactivity_timeout = 141 rnc->ssp.connection_inactivity_timeout =
@@ -639,45 +636,30 @@ static enum sci_status scic_sds_remote_node_context_tx_suspended_state_resume_ha
639 scics_sds_remote_node_context_callback callback, 636 scics_sds_remote_node_context_callback callback,
640 void *callback_parameter) 637 void *callback_parameter)
641{ 638{
642 enum sci_status status; 639 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
643 struct smp_discover_response_protocols protocols; 640 struct domain_device *dev = sci_dev_to_domain(sci_dev);
641 enum sci_status status = SCI_SUCCESS;
644 642
645 scic_sds_remote_node_context_setup_to_resume( 643 scic_sds_remote_node_context_setup_to_resume(sci_rnc, callback,
646 sci_rnc, callback, callback_parameter 644 callback_parameter);
647 );
648 645
649 /* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */ 646 /* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */
650 647 if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev))
651 scic_remote_device_get_protocols(rnc_to_dev(sci_rnc), &protocols); 648 sci_base_state_machine_change_state(&sci_rnc->state_machine,
652 649 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
653 if ( 650 else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
654 (protocols.u.bits.attached_ssp_target == 1) 651 if (sci_dev->is_direct_attached) {
655 || (protocols.u.bits.attached_smp_target == 1)
656 ) {
657 sci_base_state_machine_change_state(
658 &sci_rnc->state_machine,
659 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE
660 );
661
662 status = SCI_SUCCESS;
663 } else if (protocols.u.bits.attached_stp_target == 1) {
664 if (rnc_to_dev(sci_rnc)->is_direct_attached) {
665 /* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */ 652 /* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */
666 sci_base_state_machine_change_state( 653 sci_base_state_machine_change_state(
667 &sci_rnc->state_machine, 654 &sci_rnc->state_machine,
668 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE 655 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
669 );
670 } else { 656 } else {
671 sci_base_state_machine_change_state( 657 sci_base_state_machine_change_state(
672 &sci_rnc->state_machine, 658 &sci_rnc->state_machine,
673 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE 659 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
674 );
675 } 660 }
676 661 } else
677 status = SCI_SUCCESS;
678 } else {
679 status = SCI_FAILURE; 662 status = SCI_FAILURE;
680 }
681 663
682 return status; 664 return status;
683} 665}
@@ -932,6 +914,7 @@ static void scic_sds_remote_node_context_validate_context_buffer(
932 struct scic_sds_remote_node_context *sci_rnc) 914 struct scic_sds_remote_node_context *sci_rnc)
933{ 915{
934 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc); 916 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
917 struct domain_device *dev = sci_dev_to_domain(sci_dev);
935 union scu_remote_node_context *rnc_buffer; 918 union scu_remote_node_context *rnc_buffer;
936 919
937 rnc_buffer = scic_sds_controller_get_remote_node_context_buffer( 920 rnc_buffer = scic_sds_controller_get_remote_node_context_buffer(
@@ -942,7 +925,7 @@ static void scic_sds_remote_node_context_validate_context_buffer(
942 rnc_buffer->ssp.is_valid = true; 925 rnc_buffer->ssp.is_valid = true;
943 926
944 if (!sci_dev->is_direct_attached && 927 if (!sci_dev->is_direct_attached &&
945 sci_dev->target_protocols.u.bits.attached_stp_target) { 928 (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))) {
946 scic_sds_remote_device_post_request(sci_dev, 929 scic_sds_remote_device_post_request(sci_dev,
947 SCU_CONTEXT_COMMAND_POST_RNC_96); 930 SCU_CONTEXT_COMMAND_POST_RNC_96);
948 } else { 931 } else {
@@ -1063,11 +1046,12 @@ static void scic_sds_remote_node_context_resuming_state_enter(
1063 struct sci_base_object *object) 1046 struct sci_base_object *object)
1064{ 1047{
1065 struct scic_sds_remote_node_context *rnc; 1048 struct scic_sds_remote_node_context *rnc;
1066 struct smp_discover_response_protocols protocols;
1067 struct scic_sds_remote_device *sci_dev; 1049 struct scic_sds_remote_device *sci_dev;
1050 struct domain_device *dev;
1068 1051
1069 rnc = (struct scic_sds_remote_node_context *)object; 1052 rnc = (struct scic_sds_remote_node_context *)object;
1070 sci_dev = rnc_to_dev(rnc); 1053 sci_dev = rnc_to_dev(rnc);
1054 dev = sci_dev_to_domain(sci_dev);
1071 1055
1072 SET_STATE_HANDLER( 1056 SET_STATE_HANDLER(
1073 rnc, 1057 rnc,
@@ -1081,13 +1065,10 @@ static void scic_sds_remote_node_context_resuming_state_enter(
1081 * resume because of a target reset we also need to update 1065 * resume because of a target reset we also need to update
1082 * the STPTLDARNI register with the RNi of the device 1066 * the STPTLDARNI register with the RNi of the device
1083 */ 1067 */
1084 scic_remote_device_get_protocols(sci_dev, &protocols); 1068 if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) &&
1085 1069 sci_dev->is_direct_attached)
1086 if (protocols.u.bits.attached_stp_target == 1 &&
1087 sci_dev->is_direct_attached) {
1088 scic_sds_port_setup_transports(sci_dev->owning_port, 1070 scic_sds_port_setup_transports(sci_dev->owning_port,
1089 rnc->remote_node_index); 1071 rnc->remote_node_index);
1090 }
1091 1072
1092 scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME); 1073 scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME);
1093} 1074}
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index ff5c05a19543..281a556f5eeb 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -175,7 +175,6 @@ static enum sci_status isci_io_request_build(
175 struct isci_request *request, 175 struct isci_request *request,
176 struct isci_remote_device *isci_device) 176 struct isci_remote_device *isci_device)
177{ 177{
178 struct smp_discover_response_protocols dev_protocols;
179 enum sci_status status = SCI_SUCCESS; 178 enum sci_status status = SCI_SUCCESS;
180 struct sas_task *task = isci_request_access_task(request); 179 struct sas_task *task = isci_request_access_task(request);
181 struct scic_sds_remote_device *sci_device = &isci_device->sci; 180 struct scic_sds_remote_device *sci_device = &isci_device->sci;
@@ -228,15 +227,19 @@ static enum sci_status isci_io_request_build(
228 227
229 sci_object_set_association(request->sci_request_handle, request); 228 sci_object_set_association(request->sci_request_handle, request);
230 229
231 /* Determine protocol and call the appropriate basic constructor */ 230 switch (task->task_proto) {
232 scic_remote_device_get_protocols(sci_device, &dev_protocols); 231 case SAS_PROTOCOL_SMP:
233 if (dev_protocols.u.bits.attached_ssp_target) 232 status = isci_smp_request_build(request);
233 break;
234 case SAS_PROTOCOL_SSP:
234 status = isci_request_ssp_request_construct(request); 235 status = isci_request_ssp_request_construct(request);
235 else if (dev_protocols.u.bits.attached_stp_target) 236 break;
237 case SAS_PROTOCOL_SATA:
238 case SAS_PROTOCOL_STP:
239 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
236 status = isci_request_stp_request_construct(request); 240 status = isci_request_stp_request_construct(request);
237 else if (dev_protocols.u.bits.attached_smp_target) 241 break;
238 status = isci_smp_request_build(request); 242 default:
239 else {
240 dev_warn(&isci_host->pdev->dev, 243 dev_warn(&isci_host->pdev->dev,
241 "%s: unknown protocol\n", __func__); 244 "%s: unknown protocol\n", __func__);
242 return SCI_FAILURE; 245 return SCI_FAILURE;
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index e011d668949d..c6f1ffd713a8 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -273,15 +273,14 @@ static enum sci_status isci_task_request_build(
273 enum sci_status status = SCI_FAILURE; 273 enum sci_status status = SCI_FAILURE;
274 struct isci_request *request = NULL; 274 struct isci_request *request = NULL;
275 struct isci_remote_device *isci_device; 275 struct isci_remote_device *isci_device;
276/* struct sci_sas_identify_address_frame_protocols dev_protocols; */ 276 struct domain_device *dev;
277 struct smp_discover_response_protocols dev_protocols;
278
279 277
280 dev_dbg(&isci_host->pdev->dev, 278 dev_dbg(&isci_host->pdev->dev,
281 "%s: isci_tmf = %p\n", __func__, isci_tmf); 279 "%s: isci_tmf = %p\n", __func__, isci_tmf);
282 280
283 isci_device = isci_tmf->device; 281 isci_device = isci_tmf->device;
284 sci_device = &isci_device->sci; 282 sci_device = &isci_device->sci;
283 dev = isci_device->domain_dev;
285 284
286 /* do common allocation and init of request object. */ 285 /* do common allocation and init of request object. */
287 status = isci_request_alloc_tmf( 286 status = isci_request_alloc_tmf(
@@ -319,16 +318,8 @@ static enum sci_status isci_task_request_build(
319 request 318 request
320 ); 319 );
321 320
322 scic_remote_device_get_protocols( 321 /* XXX convert to get this from task->tproto like other drivers */
323 sci_device, 322 if (dev->dev_type == SAS_END_DEV) {
324 &dev_protocols
325 );
326
327 /* let the core do it's protocol
328 * specific construction.
329 */
330 if (dev_protocols.u.bits.attached_ssp_target) {
331
332 isci_tmf->proto = SAS_PROTOCOL_SSP; 323 isci_tmf->proto = SAS_PROTOCOL_SSP;
333 status = scic_task_request_construct_ssp( 324 status = scic_task_request_construct_ssp(
334 request->sci_request_handle 325 request->sci_request_handle
@@ -337,8 +328,7 @@ static enum sci_status isci_task_request_build(
337 goto errout; 328 goto errout;
338 } 329 }
339 330
340 if (dev_protocols.u.bits.attached_stp_target) { 331 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
341
342 isci_tmf->proto = SAS_PROTOCOL_SATA; 332 isci_tmf->proto = SAS_PROTOCOL_SATA;
343 status = isci_sata_management_task_request_build(request); 333 status = isci_sata_management_task_request_build(request);
344 334