diff options
Diffstat (limited to 'drivers/scsi/isci/remote_device.c')
-rw-r--r-- | drivers/scsi/isci/remote_device.c | 110 |
1 files changed, 47 insertions, 63 deletions
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 | ||
103 | void 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) |
111 | bool scic_remote_device_is_atapi(struct scic_sds_remote_device *sci_dev) | 104 | bool 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 | ||
1550 | static void scic_sds_remote_device_get_info_from_smp_discover_response( | 1536 | 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( | |||
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; */ |