diff options
author | Piotr Sawicki <piotr.sawicki@intel.com> | 2011-05-12 15:10:03 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:49 -0400 |
commit | bd6713b416bbfc7d7180114f7cc543b152cc1725 (patch) | |
tree | 46c758cf86fe4068a2b2aa9322a395b138a1afb6 /drivers/scsi/isci/port.c | |
parent | e6ec5afde9794f50e60788bd10760fcd0d609252 (diff) |
isci: unify port reset, add_phy, and remove_phy handlers
Unify the implementations and remove the state handlers.
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/port.c')
-rw-r--r-- | drivers/scsi/isci/port.c | 471 |
1 files changed, 163 insertions, 308 deletions
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index 1a058a27ebc1..5501e14c8d93 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -531,40 +531,6 @@ static enum sci_status scic_sds_port_clear_phy( | |||
531 | return SCI_FAILURE; | 531 | return SCI_FAILURE; |
532 | } | 532 | } |
533 | 533 | ||
534 | /** | ||
535 | * scic_sds_port_add_phy() - | ||
536 | * @sci_port: This parameter specifies the port in which the phy will be added. | ||
537 | * @sci_phy: This parameter is the phy which is to be added to the port. | ||
538 | * | ||
539 | * This method will add a PHY to the selected port. This method returns an | ||
540 | * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other status | ||
541 | * is failre to add the phy to the port. | ||
542 | */ | ||
543 | enum sci_status scic_sds_port_add_phy( | ||
544 | struct scic_sds_port *sci_port, | ||
545 | struct scic_sds_phy *sci_phy) | ||
546 | { | ||
547 | return sci_port->state_handlers->add_phy_handler( | ||
548 | sci_port, sci_phy); | ||
549 | } | ||
550 | |||
551 | |||
552 | /** | ||
553 | * scic_sds_port_remove_phy() - | ||
554 | * @sci_port: This parameter specifies the port in which the phy will be added. | ||
555 | * @sci_phy: This parameter is the phy which is to be added to the port. | ||
556 | * | ||
557 | * This method will remove the PHY from the selected PORT. This method returns | ||
558 | * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any other | ||
559 | * status is failre to add the phy to the port. | ||
560 | */ | ||
561 | enum sci_status scic_sds_port_remove_phy( | ||
562 | struct scic_sds_port *sci_port, | ||
563 | struct scic_sds_phy *sci_phy) | ||
564 | { | ||
565 | return sci_port->state_handlers->remove_phy_handler( | ||
566 | sci_port, sci_phy); | ||
567 | } | ||
568 | 534 | ||
569 | /** | 535 | /** |
570 | * This method requests the SAS address for the supplied SAS port from the SCI | 536 | * This method requests the SAS address for the supplied SAS port from the SCI |
@@ -745,23 +711,6 @@ enum sci_status scic_sds_port_initialize( | |||
745 | return SCI_SUCCESS; | 711 | return SCI_SUCCESS; |
746 | } | 712 | } |
747 | 713 | ||
748 | /** | ||
749 | * scic_port_hard_reset() - perform port hard reset | ||
750 | * @port: a handle corresponding to the SAS port to be hard reset. | ||
751 | * @reset_timeout: This parameter specifies the number of milliseconds in which | ||
752 | * the port reset operation should complete. | ||
753 | * | ||
754 | * The SCI User callback in scic_user_callbacks_t will only be called once for | ||
755 | * each phy in the SAS Port at completion of the hard reset sequence. Return a | ||
756 | * status indicating whether the hard reset started successfully. SCI_SUCCESS | ||
757 | * This value is returned if the hard reset operation started successfully. | ||
758 | */ | ||
759 | static enum sci_status scic_port_hard_reset(struct scic_sds_port *port, | ||
760 | u32 reset_timeout) | ||
761 | { | ||
762 | return port->state_handlers->reset_handler( | ||
763 | port, reset_timeout); | ||
764 | } | ||
765 | 714 | ||
766 | /** | 715 | /** |
767 | * This method assigns the direct attached device ID for this port. | 716 | * This method assigns the direct attached device ID for this port. |
@@ -1186,48 +1135,6 @@ static enum sci_status scic_sds_port_ready_substate_complete_io_handler( | |||
1186 | return SCI_SUCCESS; | 1135 | return SCI_SUCCESS; |
1187 | } | 1136 | } |
1188 | 1137 | ||
1189 | static enum sci_status scic_sds_port_ready_substate_add_phy_handler(struct scic_sds_port *sci_port, | ||
1190 | struct scic_sds_phy *sci_phy) | ||
1191 | { | ||
1192 | enum sci_status status; | ||
1193 | |||
1194 | status = scic_sds_port_set_phy(sci_port, sci_phy); | ||
1195 | |||
1196 | if (status != SCI_SUCCESS) | ||
1197 | return status; | ||
1198 | |||
1199 | scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); | ||
1200 | sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; | ||
1201 | port_state_machine_change(sci_port, SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1202 | |||
1203 | return status; | ||
1204 | } | ||
1205 | |||
1206 | |||
1207 | static enum sci_status scic_sds_port_ready_substate_remove_phy_handler(struct scic_sds_port *port, | ||
1208 | struct scic_sds_phy *phy) | ||
1209 | { | ||
1210 | enum sci_status status; | ||
1211 | |||
1212 | status = scic_sds_port_clear_phy(port, phy); | ||
1213 | |||
1214 | if (status != SCI_SUCCESS) | ||
1215 | return status; | ||
1216 | |||
1217 | scic_sds_port_deactivate_phy(port, phy, true); | ||
1218 | |||
1219 | port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; | ||
1220 | |||
1221 | port_state_machine_change(port, | ||
1222 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1223 | return status; | ||
1224 | } | ||
1225 | |||
1226 | /* | ||
1227 | * **************************************************************************** | ||
1228 | * * READY SUBSTATE WAITING HANDLERS | ||
1229 | * **************************************************************************** */ | ||
1230 | |||
1231 | /** | 1138 | /** |
1232 | * | 1139 | * |
1233 | * @sci_port: This is the struct scic_sds_port object that which has a phy that has | 1140 | * @sci_port: This is the struct scic_sds_port object that which has a phy that has |
@@ -1264,57 +1171,6 @@ static enum sci_status scic_sds_port_ready_waiting_substate_start_io_handler( | |||
1264 | return SCI_FAILURE_INVALID_STATE; | 1171 | return SCI_FAILURE_INVALID_STATE; |
1265 | } | 1172 | } |
1266 | 1173 | ||
1267 | /* | ||
1268 | * **************************************************************************** | ||
1269 | * * READY SUBSTATE OPERATIONAL HANDLERS | ||
1270 | * **************************************************************************** */ | ||
1271 | |||
1272 | /* | ||
1273 | * This method will casue the port to reset. enum sci_status SCI_SUCCESS | ||
1274 | */ | ||
1275 | static enum | ||
1276 | sci_status scic_sds_port_ready_operational_substate_reset_handler( | ||
1277 | struct scic_sds_port *port, | ||
1278 | u32 timeout) | ||
1279 | { | ||
1280 | enum sci_status status = SCI_FAILURE_INVALID_PHY; | ||
1281 | u32 phy_index; | ||
1282 | struct scic_sds_phy *selected_phy = NULL; | ||
1283 | |||
1284 | |||
1285 | /* Select a phy on which we can send the hard reset request. */ | ||
1286 | for (phy_index = 0; | ||
1287 | (phy_index < SCI_MAX_PHYS) && (selected_phy == NULL); | ||
1288 | phy_index++) { | ||
1289 | selected_phy = port->phy_table[phy_index]; | ||
1290 | |||
1291 | if ((selected_phy != NULL) && | ||
1292 | !scic_sds_port_active_phy(port, selected_phy)) { | ||
1293 | /* | ||
1294 | * We found a phy but it is not ready select | ||
1295 | * different phy | ||
1296 | */ | ||
1297 | selected_phy = NULL; | ||
1298 | } | ||
1299 | } | ||
1300 | |||
1301 | /* If we have a phy then go ahead and start the reset procedure */ | ||
1302 | if (selected_phy != NULL) { | ||
1303 | status = scic_sds_phy_reset(selected_phy); | ||
1304 | |||
1305 | if (status == SCI_SUCCESS) { | ||
1306 | isci_timer_start(port->timer_handle, timeout); | ||
1307 | port->not_ready_reason = | ||
1308 | SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; | ||
1309 | |||
1310 | port_state_machine_change(port, | ||
1311 | SCI_BASE_PORT_STATE_RESETTING); | ||
1312 | } | ||
1313 | } | ||
1314 | |||
1315 | return status; | ||
1316 | } | ||
1317 | |||
1318 | /** | 1174 | /** |
1319 | * scic_sds_port_ready_operational_substate_link_up_handler() - | 1175 | * scic_sds_port_ready_operational_substate_link_up_handler() - |
1320 | * @sci_port: This is the struct scic_sds_port object that which has a phy that has | 1176 | * @sci_port: This is the struct scic_sds_port object that which has a phy that has |
@@ -1372,61 +1228,6 @@ static enum sci_status scic_sds_port_ready_operational_substate_start_io_handler | |||
1372 | return SCI_SUCCESS; | 1228 | return SCI_SUCCESS; |
1373 | } | 1229 | } |
1374 | 1230 | ||
1375 | /* | ||
1376 | * **************************************************************************** | ||
1377 | * * READY SUBSTATE OPERATIONAL HANDLERS | ||
1378 | * **************************************************************************** */ | ||
1379 | |||
1380 | /* | ||
1381 | * This is the default method for a port add phy request. It will report a | ||
1382 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1383 | */ | ||
1384 | static enum sci_status scic_sds_port_ready_configuring_substate_add_phy_handler( | ||
1385 | struct scic_sds_port *port, | ||
1386 | struct scic_sds_phy *phy) | ||
1387 | { | ||
1388 | enum sci_status status; | ||
1389 | |||
1390 | status = scic_sds_port_set_phy(port, phy); | ||
1391 | |||
1392 | if (status == SCI_SUCCESS) { | ||
1393 | scic_sds_port_general_link_up_handler(port, phy, true); | ||
1394 | |||
1395 | /* | ||
1396 | * Re-enter the configuring state since this may be the last phy in | ||
1397 | * the port. */ | ||
1398 | port_state_machine_change(port, | ||
1399 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1400 | } | ||
1401 | |||
1402 | return status; | ||
1403 | } | ||
1404 | |||
1405 | /* | ||
1406 | * This is the default method for a port remove phy request. It will report a | ||
1407 | * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE | ||
1408 | */ | ||
1409 | static enum sci_status scic_sds_port_ready_configuring_substate_remove_phy_handler( | ||
1410 | struct scic_sds_port *port, | ||
1411 | struct scic_sds_phy *phy) | ||
1412 | { | ||
1413 | enum sci_status status; | ||
1414 | |||
1415 | status = scic_sds_port_clear_phy(port, phy); | ||
1416 | |||
1417 | if (status != SCI_SUCCESS) | ||
1418 | return status; | ||
1419 | scic_sds_port_deactivate_phy(port, phy, true); | ||
1420 | |||
1421 | /* Re-enter the configuring state since this may be the last phy in | ||
1422 | * the port | ||
1423 | */ | ||
1424 | port_state_machine_change(port, | ||
1425 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1426 | |||
1427 | return status; | ||
1428 | } | ||
1429 | |||
1430 | /** | 1231 | /** |
1431 | * scic_sds_port_ready_configuring_substate_complete_io_handler() - | 1232 | * scic_sds_port_ready_configuring_substate_complete_io_handler() - |
1432 | * @port: This is the port that is being requested to complete the io request. | 1233 | * @port: This is the port that is being requested to complete the io request. |
@@ -1461,27 +1262,6 @@ static enum sci_status default_port_handler(struct scic_sds_port *sci_port, | |||
1461 | return SCI_FAILURE_INVALID_STATE; | 1262 | return SCI_FAILURE_INVALID_STATE; |
1462 | } | 1263 | } |
1463 | 1264 | ||
1464 | static enum sci_status | ||
1465 | scic_sds_port_default_reset_handler(struct scic_sds_port *sci_port, | ||
1466 | u32 timeout) | ||
1467 | { | ||
1468 | return default_port_handler(sci_port, __func__); | ||
1469 | } | ||
1470 | |||
1471 | static enum sci_status | ||
1472 | scic_sds_port_default_add_phy_handler(struct scic_sds_port *sci_port, | ||
1473 | struct scic_sds_phy *base_phy) | ||
1474 | { | ||
1475 | return default_port_handler(sci_port, __func__); | ||
1476 | } | ||
1477 | |||
1478 | static enum sci_status | ||
1479 | scic_sds_port_default_remove_phy_handler(struct scic_sds_port *sci_port, | ||
1480 | struct scic_sds_phy *base_phy) | ||
1481 | { | ||
1482 | return default_port_handler(sci_port, __func__); | ||
1483 | } | ||
1484 | |||
1485 | /* | 1265 | /* |
1486 | * This is the default method for a port unsolicited frame request. It will | 1266 | * This is the default method for a port unsolicited frame request. It will |
1487 | * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even | 1267 | * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even |
@@ -1818,70 +1598,6 @@ static enum sci_status scic_sds_port_general_complete_io_handler( | |||
1818 | } | 1598 | } |
1819 | 1599 | ||
1820 | /* | 1600 | /* |
1821 | * This method takes the struct scic_sds_port that is in a stopped state and handles | ||
1822 | * the add phy request. In MPC mode the only time a phy can be added to a port | ||
1823 | * is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status | ||
1824 | * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION is returned when the phy can not | ||
1825 | * be added to the port. SCI_SUCCESS if the phy is added to the port. | ||
1826 | */ | ||
1827 | static enum sci_status scic_sds_port_stopped_state_add_phy_handler( | ||
1828 | struct scic_sds_port *port, | ||
1829 | struct scic_sds_phy *phy) | ||
1830 | { | ||
1831 | struct sci_sas_address port_sas_address; | ||
1832 | |||
1833 | /* Read the port assigned SAS Address if there is one */ | ||
1834 | scic_sds_port_get_sas_address(port, &port_sas_address); | ||
1835 | |||
1836 | if (port_sas_address.high != 0 && port_sas_address.low != 0) { | ||
1837 | struct sci_sas_address phy_sas_address; | ||
1838 | |||
1839 | /* | ||
1840 | * Make sure that the PHY SAS Address matches the SAS Address | ||
1841 | * for this port. */ | ||
1842 | scic_sds_phy_get_sas_address(phy, &phy_sas_address); | ||
1843 | |||
1844 | if ( | ||
1845 | (port_sas_address.high != phy_sas_address.high) | ||
1846 | || (port_sas_address.low != phy_sas_address.low) | ||
1847 | ) { | ||
1848 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; | ||
1849 | } | ||
1850 | } | ||
1851 | |||
1852 | return scic_sds_port_set_phy(port, phy); | ||
1853 | } | ||
1854 | |||
1855 | /* | ||
1856 | * This method takes the struct scic_sds_port that is in a stopped state and handles | ||
1857 | * the remove phy request. In MPC mode the only time a phy can be removed from | ||
1858 | * a port is in the SCI_BASE_PORT_STATE_STOPPED. enum sci_status | ||
1859 | * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION is returned when the phy can not | ||
1860 | * be added to the port. SCI_SUCCESS if the phy is added to the port. | ||
1861 | */ | ||
1862 | static enum sci_status scic_sds_port_stopped_state_remove_phy_handler( | ||
1863 | struct scic_sds_port *port, | ||
1864 | struct scic_sds_phy *phy) | ||
1865 | { | ||
1866 | return scic_sds_port_clear_phy(port, phy); | ||
1867 | } | ||
1868 | |||
1869 | /* | ||
1870 | * **************************************************************************** | ||
1871 | * * READY STATE HANDLERS | ||
1872 | * **************************************************************************** */ | ||
1873 | |||
1874 | /* | ||
1875 | * **************************************************************************** | ||
1876 | * * RESETTING STATE HANDLERS | ||
1877 | * **************************************************************************** */ | ||
1878 | |||
1879 | /* | ||
1880 | * **************************************************************************** | ||
1881 | * * STOPPING STATE HANDLERS | ||
1882 | * **************************************************************************** */ | ||
1883 | |||
1884 | /* | ||
1885 | * This method takes the struct scic_sds_port that is in a stopping state and handles | 1601 | * This method takes the struct scic_sds_port that is in a stopping state and handles |
1886 | * the complete io request. Should the request count reach 0 then the port | 1602 | * the complete io request. Should the request count reach 0 then the port |
1887 | * object will transition to the stopped state. enum sci_status SCI_SUCCESS | 1603 | * object will transition to the stopped state. enum sci_status SCI_SUCCESS |
@@ -2044,11 +1760,171 @@ enum sci_status scic_sds_port_stop(struct scic_sds_port *sci_port) | |||
2044 | } | 1760 | } |
2045 | } | 1761 | } |
2046 | 1762 | ||
1763 | static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 timeout) | ||
1764 | { | ||
1765 | enum sci_status status = SCI_FAILURE_INVALID_PHY; | ||
1766 | struct scic_sds_phy *selected_phy = NULL; | ||
1767 | enum scic_sds_port_states state; | ||
1768 | u32 phy_index; | ||
1769 | |||
1770 | state = sci_port->state_machine.current_state_id; | ||
1771 | if (state != SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL) { | ||
1772 | dev_warn(sciport_to_dev(sci_port), | ||
1773 | "%s: in wrong state: %d\n", __func__, state); | ||
1774 | return SCI_FAILURE_INVALID_STATE; | ||
1775 | } | ||
1776 | |||
1777 | /* Select a phy on which we can send the hard reset request. */ | ||
1778 | for (phy_index = 0; phy_index < SCI_MAX_PHYS && !selected_phy; phy_index++) { | ||
1779 | selected_phy = sci_port->phy_table[phy_index]; | ||
1780 | if (selected_phy && | ||
1781 | !scic_sds_port_active_phy(sci_port, selected_phy)) { | ||
1782 | /* | ||
1783 | * We found a phy but it is not ready select | ||
1784 | * different phy | ||
1785 | */ | ||
1786 | selected_phy = NULL; | ||
1787 | } | ||
1788 | } | ||
1789 | |||
1790 | /* If we have a phy then go ahead and start the reset procedure */ | ||
1791 | if (!selected_phy) | ||
1792 | return status; | ||
1793 | status = scic_sds_phy_reset(selected_phy); | ||
1794 | |||
1795 | if (status != SCI_SUCCESS) | ||
1796 | return status; | ||
1797 | |||
1798 | isci_timer_start(sci_port->timer_handle, timeout); | ||
1799 | sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; | ||
1800 | |||
1801 | port_state_machine_change(sci_port, | ||
1802 | SCI_BASE_PORT_STATE_RESETTING); | ||
1803 | return SCI_SUCCESS; | ||
1804 | } | ||
1805 | |||
1806 | /** | ||
1807 | * scic_sds_port_add_phy() - | ||
1808 | * @sci_port: This parameter specifies the port in which the phy will be added. | ||
1809 | * @sci_phy: This parameter is the phy which is to be added to the port. | ||
1810 | * | ||
1811 | * This method will add a PHY to the selected port. This method returns an | ||
1812 | * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other | ||
1813 | * status is a failure to add the phy to the port. | ||
1814 | */ | ||
1815 | enum sci_status scic_sds_port_add_phy(struct scic_sds_port *sci_port, | ||
1816 | struct scic_sds_phy *sci_phy) | ||
1817 | { | ||
1818 | enum sci_status status; | ||
1819 | enum scic_sds_port_states state; | ||
1820 | |||
1821 | state = sci_port->state_machine.current_state_id; | ||
1822 | switch (state) { | ||
1823 | case SCI_BASE_PORT_STATE_STOPPED: { | ||
1824 | struct sci_sas_address port_sas_address; | ||
1825 | |||
1826 | /* Read the port assigned SAS Address if there is one */ | ||
1827 | scic_sds_port_get_sas_address(sci_port, &port_sas_address); | ||
1828 | |||
1829 | if (port_sas_address.high != 0 && port_sas_address.low != 0) { | ||
1830 | struct sci_sas_address phy_sas_address; | ||
1831 | |||
1832 | /* Make sure that the PHY SAS Address matches the SAS Address | ||
1833 | * for this port | ||
1834 | */ | ||
1835 | scic_sds_phy_get_sas_address(sci_phy, &phy_sas_address); | ||
1836 | |||
1837 | if (port_sas_address.high != phy_sas_address.high || | ||
1838 | port_sas_address.low != phy_sas_address.low) | ||
1839 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; | ||
1840 | } | ||
1841 | return scic_sds_port_set_phy(sci_port, sci_phy); | ||
1842 | } | ||
1843 | case SCIC_SDS_PORT_READY_SUBSTATE_WAITING: | ||
1844 | case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: | ||
1845 | status = scic_sds_port_set_phy(sci_port, sci_phy); | ||
1846 | |||
1847 | if (status != SCI_SUCCESS) | ||
1848 | return status; | ||
1849 | |||
1850 | scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); | ||
1851 | sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; | ||
1852 | port_state_machine_change(sci_port, SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1853 | |||
1854 | return status; | ||
1855 | case SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING: | ||
1856 | status = scic_sds_port_set_phy(sci_port, sci_phy); | ||
1857 | |||
1858 | if (status != SCI_SUCCESS) | ||
1859 | return status; | ||
1860 | scic_sds_port_general_link_up_handler(sci_port, sci_phy, true); | ||
1861 | |||
1862 | /* Re-enter the configuring state since this may be the last phy in | ||
1863 | * the port. | ||
1864 | */ | ||
1865 | port_state_machine_change(sci_port, | ||
1866 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1867 | return SCI_SUCCESS; | ||
1868 | default: | ||
1869 | dev_warn(sciport_to_dev(sci_port), | ||
1870 | "%s: in wrong state: %d\n", __func__, state); | ||
1871 | return SCI_FAILURE_INVALID_STATE; | ||
1872 | } | ||
1873 | } | ||
1874 | |||
1875 | /** | ||
1876 | * scic_sds_port_remove_phy() - | ||
1877 | * @sci_port: This parameter specifies the port in which the phy will be added. | ||
1878 | * @sci_phy: This parameter is the phy which is to be added to the port. | ||
1879 | * | ||
1880 | * This method will remove the PHY from the selected PORT. This method returns | ||
1881 | * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any | ||
1882 | * other status is a failure to add the phy to the port. | ||
1883 | */ | ||
1884 | enum sci_status scic_sds_port_remove_phy(struct scic_sds_port *sci_port, | ||
1885 | struct scic_sds_phy *sci_phy) | ||
1886 | { | ||
1887 | enum sci_status status; | ||
1888 | enum scic_sds_port_states state; | ||
1889 | |||
1890 | state = sci_port->state_machine.current_state_id; | ||
1891 | |||
1892 | switch (state) { | ||
1893 | case SCI_BASE_PORT_STATE_STOPPED: | ||
1894 | return scic_sds_port_clear_phy(sci_port, sci_phy); | ||
1895 | case SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL: | ||
1896 | status = scic_sds_port_clear_phy(sci_port, sci_phy); | ||
1897 | if (status != SCI_SUCCESS) | ||
1898 | return status; | ||
1899 | |||
1900 | scic_sds_port_deactivate_phy(sci_port, sci_phy, true); | ||
1901 | sci_port->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; | ||
1902 | port_state_machine_change(sci_port, | ||
1903 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1904 | return SCI_SUCCESS; | ||
1905 | case SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING: | ||
1906 | status = scic_sds_port_clear_phy(sci_port, sci_phy); | ||
1907 | |||
1908 | if (status != SCI_SUCCESS) | ||
1909 | return status; | ||
1910 | scic_sds_port_deactivate_phy(sci_port, sci_phy, true); | ||
1911 | |||
1912 | /* Re-enter the configuring state since this may be the last phy in | ||
1913 | * the port | ||
1914 | */ | ||
1915 | port_state_machine_change(sci_port, | ||
1916 | SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING); | ||
1917 | |||
1918 | return SCI_SUCCESS; | ||
1919 | default: | ||
1920 | dev_warn(sciport_to_dev(sci_port), | ||
1921 | "%s: in wrong state: %d\n", __func__, state); | ||
1922 | return SCI_FAILURE_INVALID_STATE; | ||
1923 | } | ||
1924 | } | ||
1925 | |||
2047 | static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = { | 1926 | static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = { |
2048 | [SCI_BASE_PORT_STATE_STOPPED] = { | 1927 | [SCI_BASE_PORT_STATE_STOPPED] = { |
2049 | .reset_handler = scic_sds_port_default_reset_handler, | ||
2050 | .add_phy_handler = scic_sds_port_stopped_state_add_phy_handler, | ||
2051 | .remove_phy_handler = scic_sds_port_stopped_state_remove_phy_handler, | ||
2052 | .frame_handler = scic_sds_port_default_frame_handler, | 1928 | .frame_handler = scic_sds_port_default_frame_handler, |
2053 | .event_handler = scic_sds_port_default_event_handler, | 1929 | .event_handler = scic_sds_port_default_event_handler, |
2054 | .link_up_handler = scic_sds_port_default_link_up_handler, | 1930 | .link_up_handler = scic_sds_port_default_link_up_handler, |
@@ -2057,9 +1933,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2057 | .complete_io_handler = scic_sds_port_default_complete_io_handler | 1933 | .complete_io_handler = scic_sds_port_default_complete_io_handler |
2058 | }, | 1934 | }, |
2059 | [SCI_BASE_PORT_STATE_STOPPING] = { | 1935 | [SCI_BASE_PORT_STATE_STOPPING] = { |
2060 | .reset_handler = scic_sds_port_default_reset_handler, | ||
2061 | .add_phy_handler = scic_sds_port_default_add_phy_handler, | ||
2062 | .remove_phy_handler = scic_sds_port_default_remove_phy_handler, | ||
2063 | .frame_handler = scic_sds_port_default_frame_handler, | 1936 | .frame_handler = scic_sds_port_default_frame_handler, |
2064 | .event_handler = scic_sds_port_default_event_handler, | 1937 | .event_handler = scic_sds_port_default_event_handler, |
2065 | .link_up_handler = scic_sds_port_default_link_up_handler, | 1938 | .link_up_handler = scic_sds_port_default_link_up_handler, |
@@ -2068,9 +1941,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2068 | .complete_io_handler = scic_sds_port_stopping_state_complete_io_handler | 1941 | .complete_io_handler = scic_sds_port_stopping_state_complete_io_handler |
2069 | }, | 1942 | }, |
2070 | [SCI_BASE_PORT_STATE_READY] = { | 1943 | [SCI_BASE_PORT_STATE_READY] = { |
2071 | .reset_handler = scic_sds_port_default_reset_handler, | ||
2072 | .add_phy_handler = scic_sds_port_default_add_phy_handler, | ||
2073 | .remove_phy_handler = scic_sds_port_default_remove_phy_handler, | ||
2074 | .frame_handler = scic_sds_port_default_frame_handler, | 1944 | .frame_handler = scic_sds_port_default_frame_handler, |
2075 | .event_handler = scic_sds_port_default_event_handler, | 1945 | .event_handler = scic_sds_port_default_event_handler, |
2076 | .link_up_handler = scic_sds_port_default_link_up_handler, | 1946 | .link_up_handler = scic_sds_port_default_link_up_handler, |
@@ -2079,9 +1949,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2079 | .complete_io_handler = scic_sds_port_general_complete_io_handler | 1949 | .complete_io_handler = scic_sds_port_general_complete_io_handler |
2080 | }, | 1950 | }, |
2081 | [SCIC_SDS_PORT_READY_SUBSTATE_WAITING] = { | 1951 | [SCIC_SDS_PORT_READY_SUBSTATE_WAITING] = { |
2082 | .reset_handler = scic_sds_port_default_reset_handler, | ||
2083 | .add_phy_handler = scic_sds_port_ready_substate_add_phy_handler, | ||
2084 | .remove_phy_handler = scic_sds_port_default_remove_phy_handler, | ||
2085 | .frame_handler = scic_sds_port_default_frame_handler, | 1952 | .frame_handler = scic_sds_port_default_frame_handler, |
2086 | .event_handler = scic_sds_port_default_event_handler, | 1953 | .event_handler = scic_sds_port_default_event_handler, |
2087 | .link_up_handler = scic_sds_port_ready_waiting_substate_link_up_handler, | 1954 | .link_up_handler = scic_sds_port_ready_waiting_substate_link_up_handler, |
@@ -2090,9 +1957,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2090 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, | 1957 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, |
2091 | }, | 1958 | }, |
2092 | [SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL] = { | 1959 | [SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL] = { |
2093 | .reset_handler = scic_sds_port_ready_operational_substate_reset_handler, | ||
2094 | .add_phy_handler = scic_sds_port_ready_substate_add_phy_handler, | ||
2095 | .remove_phy_handler = scic_sds_port_ready_substate_remove_phy_handler, | ||
2096 | .frame_handler = scic_sds_port_default_frame_handler, | 1960 | .frame_handler = scic_sds_port_default_frame_handler, |
2097 | .event_handler = scic_sds_port_default_event_handler, | 1961 | .event_handler = scic_sds_port_default_event_handler, |
2098 | .link_up_handler = scic_sds_port_ready_operational_substate_link_up_handler, | 1962 | .link_up_handler = scic_sds_port_ready_operational_substate_link_up_handler, |
@@ -2101,9 +1965,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2101 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, | 1965 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, |
2102 | }, | 1966 | }, |
2103 | [SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING] = { | 1967 | [SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING] = { |
2104 | .reset_handler = scic_sds_port_default_reset_handler, | ||
2105 | .add_phy_handler = scic_sds_port_ready_configuring_substate_add_phy_handler, | ||
2106 | .remove_phy_handler = scic_sds_port_ready_configuring_substate_remove_phy_handler, | ||
2107 | .frame_handler = scic_sds_port_default_frame_handler, | 1968 | .frame_handler = scic_sds_port_default_frame_handler, |
2108 | .event_handler = scic_sds_port_default_event_handler, | 1969 | .event_handler = scic_sds_port_default_event_handler, |
2109 | .link_up_handler = scic_sds_port_default_link_up_handler, | 1970 | .link_up_handler = scic_sds_port_default_link_up_handler, |
@@ -2112,9 +1973,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2112 | .complete_io_handler = scic_sds_port_ready_configuring_substate_complete_io_handler | 1973 | .complete_io_handler = scic_sds_port_ready_configuring_substate_complete_io_handler |
2113 | }, | 1974 | }, |
2114 | [SCI_BASE_PORT_STATE_RESETTING] = { | 1975 | [SCI_BASE_PORT_STATE_RESETTING] = { |
2115 | .reset_handler = scic_sds_port_default_reset_handler, | ||
2116 | .add_phy_handler = scic_sds_port_default_add_phy_handler, | ||
2117 | .remove_phy_handler = scic_sds_port_default_remove_phy_handler, | ||
2118 | .frame_handler = scic_sds_port_default_frame_handler, | 1976 | .frame_handler = scic_sds_port_default_frame_handler, |
2119 | .event_handler = scic_sds_port_default_event_handler, | 1977 | .event_handler = scic_sds_port_default_event_handler, |
2120 | .link_up_handler = scic_sds_port_reset_state_link_up_handler, | 1978 | .link_up_handler = scic_sds_port_reset_state_link_up_handler, |
@@ -2123,9 +1981,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2123 | .complete_io_handler = scic_sds_port_general_complete_io_handler | 1981 | .complete_io_handler = scic_sds_port_general_complete_io_handler |
2124 | }, | 1982 | }, |
2125 | [SCI_BASE_PORT_STATE_FAILED] = { | 1983 | [SCI_BASE_PORT_STATE_FAILED] = { |
2126 | .reset_handler = scic_sds_port_default_reset_handler, | ||
2127 | .add_phy_handler = scic_sds_port_default_add_phy_handler, | ||
2128 | .remove_phy_handler = scic_sds_port_default_remove_phy_handler, | ||
2129 | .frame_handler = scic_sds_port_default_frame_handler, | 1984 | .frame_handler = scic_sds_port_default_frame_handler, |
2130 | .event_handler = scic_sds_port_default_event_handler, | 1985 | .event_handler = scic_sds_port_default_event_handler, |
2131 | .link_up_handler = scic_sds_port_default_link_up_handler, | 1986 | .link_up_handler = scic_sds_port_default_link_up_handler, |