diff options
author | Piotr Sawicki <piotr.sawicki@intel.com> | 2011-05-11 19:52:26 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:49 -0400 |
commit | d76f71d988ef48384593ad97ebc762d9257d96a8 (patch) | |
tree | 003e8decebcca6f31461acc3fee9d57349d442b9 | |
parent | e91f41ef809a2d1b8cdba52ac380aecd706c93dd (diff) |
isci: remove port start handler
remove the handler from the port state handler table and implement the
logic directly in scic_sds_port_start().
Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com>
[remove a level of indirection]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/scsi/isci/host.c | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/port.c | 180 | ||||
-rw-r--r-- | drivers/scsi/isci/port.h | 8 |
3 files changed, 80 insertions, 110 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 2ef1c592a16f..7abfb663ca94 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -1108,7 +1108,7 @@ static enum sci_status scic_controller_start(struct scic_sds_controller *scic, | |||
1108 | for (index = 0; index < scic->logical_port_entries; index++) { | 1108 | for (index = 0; index < scic->logical_port_entries; index++) { |
1109 | struct scic_sds_port *sci_port = &ihost->ports[index].sci; | 1109 | struct scic_sds_port *sci_port = &ihost->ports[index].sci; |
1110 | 1110 | ||
1111 | result = sci_port->state_handlers->start_handler(sci_port); | 1111 | result = scic_sds_port_start(sci_port); |
1112 | if (result) | 1112 | if (result) |
1113 | return result; | 1113 | return result; |
1114 | } | 1114 | } |
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index 2ea3d0fe091d..64559e8e568d 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -1480,12 +1480,6 @@ static enum sci_status default_port_handler(struct scic_sds_port *sci_port, | |||
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | static enum sci_status | 1482 | static enum sci_status |
1483 | scic_sds_port_default_start_handler(struct scic_sds_port *sci_port) | ||
1484 | { | ||
1485 | return default_port_handler(sci_port, __func__); | ||
1486 | } | ||
1487 | |||
1488 | static enum sci_status | ||
1489 | scic_sds_port_default_stop_handler(struct scic_sds_port *sci_port) | 1483 | scic_sds_port_default_stop_handler(struct scic_sds_port *sci_port) |
1490 | { | 1484 | { |
1491 | return default_port_handler(sci_port, __func__); | 1485 | return default_port_handler(sci_port, __func__); |
@@ -1853,95 +1847,6 @@ static enum sci_status scic_sds_port_general_complete_io_handler( | |||
1853 | return SCI_SUCCESS; | 1847 | return SCI_SUCCESS; |
1854 | } | 1848 | } |
1855 | 1849 | ||
1856 | /** | ||
1857 | * scic_sds_port_stopped_state_start_handler() - stop a port from "started" | ||
1858 | * | ||
1859 | * @port: This is the struct scic_sds_port object which is cast into a | ||
1860 | * struct scic_sds_port object. | ||
1861 | * | ||
1862 | * This function takes the struct scic_sds_port from a stopped state and | ||
1863 | * attempts to start it. To start a port it must have no assiged devices and | ||
1864 | * it must have at least one phy assigned to it. If those conditions are | ||
1865 | * met then the port can transition to the ready state. | ||
1866 | * enum sci_status | ||
1867 | * SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION | ||
1868 | * This struct scic_sds_port object could not be started because the port | ||
1869 | * configuration is not valid. | ||
1870 | * SCI_SUCCESS | ||
1871 | * the start request is successful and the struct scic_sds_port object | ||
1872 | * has transitioned to the SCI_BASE_PORT_STATE_READY. | ||
1873 | */ | ||
1874 | static enum sci_status | ||
1875 | scic_sds_port_stopped_state_start_handler(struct scic_sds_port *sci_port) | ||
1876 | { | ||
1877 | struct scic_sds_controller *scic = sci_port->owning_controller; | ||
1878 | struct isci_host *ihost = scic_to_ihost(scic); | ||
1879 | enum sci_status status = SCI_SUCCESS; | ||
1880 | u32 phy_mask; | ||
1881 | |||
1882 | if (sci_port->assigned_device_count > 0) { | ||
1883 | /* | ||
1884 | * @todo This is a start failure operation because | ||
1885 | * there are still devices assigned to this port. | ||
1886 | * There must be no devices assigned to a port on a | ||
1887 | * start operation. | ||
1888 | */ | ||
1889 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; | ||
1890 | } | ||
1891 | |||
1892 | sci_port->timer_handle = | ||
1893 | isci_timer_create(ihost, | ||
1894 | sci_port, | ||
1895 | scic_sds_port_timeout_handler); | ||
1896 | |||
1897 | if (!sci_port->timer_handle) | ||
1898 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
1899 | |||
1900 | if (sci_port->reserved_rni == SCU_DUMMY_INDEX) { | ||
1901 | u16 rni = scic_sds_remote_node_table_allocate_remote_node( | ||
1902 | &scic->available_remote_nodes, 1); | ||
1903 | |||
1904 | if (rni != SCU_DUMMY_INDEX) | ||
1905 | scic_sds_port_construct_dummy_rnc(sci_port, rni); | ||
1906 | else | ||
1907 | status = SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
1908 | sci_port->reserved_rni = rni; | ||
1909 | } | ||
1910 | |||
1911 | if (sci_port->reserved_tci == SCU_DUMMY_INDEX) { | ||
1912 | /* Allocate a TCI and remove the sequence nibble */ | ||
1913 | u16 tci = scic_controller_allocate_io_tag(scic); | ||
1914 | |||
1915 | if (tci != SCU_DUMMY_INDEX) | ||
1916 | scic_sds_port_construct_dummy_task(sci_port, tci); | ||
1917 | else | ||
1918 | status = SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
1919 | sci_port->reserved_tci = tci; | ||
1920 | } | ||
1921 | |||
1922 | if (status == SCI_SUCCESS) { | ||
1923 | phy_mask = scic_sds_port_get_phys(sci_port); | ||
1924 | |||
1925 | /* | ||
1926 | * There are one or more phys assigned to this port. Make sure | ||
1927 | * the port's phy mask is in fact legal and supported by the | ||
1928 | * silicon. | ||
1929 | */ | ||
1930 | if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { | ||
1931 | port_state_machine_change(sci_port, | ||
1932 | SCI_BASE_PORT_STATE_READY); | ||
1933 | |||
1934 | return SCI_SUCCESS; | ||
1935 | } else | ||
1936 | status = SCI_FAILURE; | ||
1937 | } | ||
1938 | |||
1939 | if (status != SCI_SUCCESS) | ||
1940 | scic_sds_port_destroy_dummy_resources(sci_port); | ||
1941 | |||
1942 | return status; | ||
1943 | } | ||
1944 | |||
1945 | /* | 1850 | /* |
1946 | * This method takes the struct scic_sds_port that is in a stopped state and handles a | 1851 | * This method takes the struct scic_sds_port that is in a stopped state and handles a |
1947 | * stop request. This function takes no action. enum sci_status SCI_SUCCESS the | 1852 | * stop request. This function takes no action. enum sci_status SCI_SUCCESS the |
@@ -2111,9 +2016,85 @@ static void scic_sds_port_reset_state_link_down_handler( | |||
2111 | scic_sds_port_deactivate_phy(port, phy, false); | 2016 | scic_sds_port_deactivate_phy(port, phy, false); |
2112 | } | 2017 | } |
2113 | 2018 | ||
2019 | enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port) | ||
2020 | { | ||
2021 | struct scic_sds_controller *scic = sci_port->owning_controller; | ||
2022 | struct isci_host *ihost = scic_to_ihost(scic); | ||
2023 | enum sci_status status = SCI_SUCCESS; | ||
2024 | enum scic_sds_port_states state; | ||
2025 | u32 phy_mask; | ||
2026 | |||
2027 | state = sci_port->state_machine.current_state_id; | ||
2028 | if (state != SCI_BASE_PORT_STATE_STOPPED) { | ||
2029 | dev_warn(sciport_to_dev(sci_port), | ||
2030 | "%s: in wrong state: %d\n", __func__, state); | ||
2031 | return SCI_FAILURE_INVALID_STATE; | ||
2032 | } | ||
2033 | |||
2034 | if (sci_port->assigned_device_count > 0) { | ||
2035 | /* TODO This is a start failure operation because | ||
2036 | * there are still devices assigned to this port. | ||
2037 | * There must be no devices assigned to a port on a | ||
2038 | * start operation. | ||
2039 | */ | ||
2040 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; | ||
2041 | } | ||
2042 | |||
2043 | sci_port->timer_handle = | ||
2044 | isci_timer_create(ihost, | ||
2045 | sci_port, | ||
2046 | scic_sds_port_timeout_handler); | ||
2047 | |||
2048 | if (!sci_port->timer_handle) | ||
2049 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
2050 | |||
2051 | if (sci_port->reserved_rni == SCU_DUMMY_INDEX) { | ||
2052 | u16 rni = scic_sds_remote_node_table_allocate_remote_node( | ||
2053 | &scic->available_remote_nodes, 1); | ||
2054 | |||
2055 | if (rni != SCU_DUMMY_INDEX) | ||
2056 | scic_sds_port_construct_dummy_rnc(sci_port, rni); | ||
2057 | else | ||
2058 | status = SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
2059 | sci_port->reserved_rni = rni; | ||
2060 | } | ||
2061 | |||
2062 | if (sci_port->reserved_tci == SCU_DUMMY_INDEX) { | ||
2063 | /* Allocate a TCI and remove the sequence nibble */ | ||
2064 | u16 tci = scic_controller_allocate_io_tag(scic); | ||
2065 | |||
2066 | if (tci != SCU_DUMMY_INDEX) | ||
2067 | scic_sds_port_construct_dummy_task(sci_port, tci); | ||
2068 | else | ||
2069 | status = SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
2070 | sci_port->reserved_tci = tci; | ||
2071 | } | ||
2072 | |||
2073 | if (status == SCI_SUCCESS) { | ||
2074 | phy_mask = scic_sds_port_get_phys(sci_port); | ||
2075 | |||
2076 | /* | ||
2077 | * There are one or more phys assigned to this port. Make sure | ||
2078 | * the port's phy mask is in fact legal and supported by the | ||
2079 | * silicon. | ||
2080 | */ | ||
2081 | if (scic_sds_port_is_phy_mask_valid(sci_port, phy_mask) == true) { | ||
2082 | port_state_machine_change(sci_port, | ||
2083 | SCI_BASE_PORT_STATE_READY); | ||
2084 | |||
2085 | return SCI_SUCCESS; | ||
2086 | } | ||
2087 | status = SCI_FAILURE; | ||
2088 | } | ||
2089 | |||
2090 | if (status != SCI_SUCCESS) | ||
2091 | scic_sds_port_destroy_dummy_resources(sci_port); | ||
2092 | |||
2093 | return status; | ||
2094 | } | ||
2095 | |||
2114 | static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = { | 2096 | static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = { |
2115 | [SCI_BASE_PORT_STATE_STOPPED] = { | 2097 | [SCI_BASE_PORT_STATE_STOPPED] = { |
2116 | .start_handler = scic_sds_port_stopped_state_start_handler, | ||
2117 | .stop_handler = scic_sds_port_stopped_state_stop_handler, | 2098 | .stop_handler = scic_sds_port_stopped_state_stop_handler, |
2118 | .destruct_handler = scic_sds_port_stopped_state_destruct_handler, | 2099 | .destruct_handler = scic_sds_port_stopped_state_destruct_handler, |
2119 | .reset_handler = scic_sds_port_default_reset_handler, | 2100 | .reset_handler = scic_sds_port_default_reset_handler, |
@@ -2127,7 +2108,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2127 | .complete_io_handler = scic_sds_port_default_complete_io_handler | 2108 | .complete_io_handler = scic_sds_port_default_complete_io_handler |
2128 | }, | 2109 | }, |
2129 | [SCI_BASE_PORT_STATE_STOPPING] = { | 2110 | [SCI_BASE_PORT_STATE_STOPPING] = { |
2130 | .start_handler = scic_sds_port_default_start_handler, | ||
2131 | .stop_handler = scic_sds_port_default_stop_handler, | 2111 | .stop_handler = scic_sds_port_default_stop_handler, |
2132 | .destruct_handler = scic_sds_port_default_destruct_handler, | 2112 | .destruct_handler = scic_sds_port_default_destruct_handler, |
2133 | .reset_handler = scic_sds_port_default_reset_handler, | 2113 | .reset_handler = scic_sds_port_default_reset_handler, |
@@ -2141,7 +2121,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2141 | .complete_io_handler = scic_sds_port_stopping_state_complete_io_handler | 2121 | .complete_io_handler = scic_sds_port_stopping_state_complete_io_handler |
2142 | }, | 2122 | }, |
2143 | [SCI_BASE_PORT_STATE_READY] = { | 2123 | [SCI_BASE_PORT_STATE_READY] = { |
2144 | .start_handler = scic_sds_port_default_start_handler, | ||
2145 | .stop_handler = scic_sds_port_default_stop_handler, | 2124 | .stop_handler = scic_sds_port_default_stop_handler, |
2146 | .destruct_handler = scic_sds_port_default_destruct_handler, | 2125 | .destruct_handler = scic_sds_port_default_destruct_handler, |
2147 | .reset_handler = scic_sds_port_default_reset_handler, | 2126 | .reset_handler = scic_sds_port_default_reset_handler, |
@@ -2155,7 +2134,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2155 | .complete_io_handler = scic_sds_port_general_complete_io_handler | 2134 | .complete_io_handler = scic_sds_port_general_complete_io_handler |
2156 | }, | 2135 | }, |
2157 | [SCIC_SDS_PORT_READY_SUBSTATE_WAITING] = { | 2136 | [SCIC_SDS_PORT_READY_SUBSTATE_WAITING] = { |
2158 | .start_handler = scic_sds_port_default_start_handler, | ||
2159 | .stop_handler = scic_sds_port_ready_substate_stop_handler, | 2137 | .stop_handler = scic_sds_port_ready_substate_stop_handler, |
2160 | .destruct_handler = scic_sds_port_default_destruct_handler, | 2138 | .destruct_handler = scic_sds_port_default_destruct_handler, |
2161 | .reset_handler = scic_sds_port_default_reset_handler, | 2139 | .reset_handler = scic_sds_port_default_reset_handler, |
@@ -2169,7 +2147,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2169 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, | 2147 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, |
2170 | }, | 2148 | }, |
2171 | [SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL] = { | 2149 | [SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL] = { |
2172 | .start_handler = scic_sds_port_default_start_handler, | ||
2173 | .stop_handler = scic_sds_port_ready_substate_stop_handler, | 2150 | .stop_handler = scic_sds_port_ready_substate_stop_handler, |
2174 | .destruct_handler = scic_sds_port_default_destruct_handler, | 2151 | .destruct_handler = scic_sds_port_default_destruct_handler, |
2175 | .reset_handler = scic_sds_port_ready_operational_substate_reset_handler, | 2152 | .reset_handler = scic_sds_port_ready_operational_substate_reset_handler, |
@@ -2183,7 +2160,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2183 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, | 2160 | .complete_io_handler = scic_sds_port_ready_substate_complete_io_handler, |
2184 | }, | 2161 | }, |
2185 | [SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING] = { | 2162 | [SCIC_SDS_PORT_READY_SUBSTATE_CONFIGURING] = { |
2186 | .start_handler = scic_sds_port_default_start_handler, | ||
2187 | .stop_handler = scic_sds_port_ready_substate_stop_handler, | 2163 | .stop_handler = scic_sds_port_ready_substate_stop_handler, |
2188 | .destruct_handler = scic_sds_port_default_destruct_handler, | 2164 | .destruct_handler = scic_sds_port_default_destruct_handler, |
2189 | .reset_handler = scic_sds_port_default_reset_handler, | 2165 | .reset_handler = scic_sds_port_default_reset_handler, |
@@ -2197,7 +2173,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2197 | .complete_io_handler = scic_sds_port_ready_configuring_substate_complete_io_handler | 2173 | .complete_io_handler = scic_sds_port_ready_configuring_substate_complete_io_handler |
2198 | }, | 2174 | }, |
2199 | [SCI_BASE_PORT_STATE_RESETTING] = { | 2175 | [SCI_BASE_PORT_STATE_RESETTING] = { |
2200 | .start_handler = scic_sds_port_default_start_handler, | ||
2201 | .stop_handler = scic_sds_port_reset_state_stop_handler, | 2176 | .stop_handler = scic_sds_port_reset_state_stop_handler, |
2202 | .destruct_handler = scic_sds_port_default_destruct_handler, | 2177 | .destruct_handler = scic_sds_port_default_destruct_handler, |
2203 | .reset_handler = scic_sds_port_default_reset_handler, | 2178 | .reset_handler = scic_sds_port_default_reset_handler, |
@@ -2211,7 +2186,6 @@ static struct scic_sds_port_state_handler scic_sds_port_state_handler_table[] = | |||
2211 | .complete_io_handler = scic_sds_port_general_complete_io_handler | 2186 | .complete_io_handler = scic_sds_port_general_complete_io_handler |
2212 | }, | 2187 | }, |
2213 | [SCI_BASE_PORT_STATE_FAILED] = { | 2188 | [SCI_BASE_PORT_STATE_FAILED] = { |
2214 | .start_handler = scic_sds_port_default_start_handler, | ||
2215 | .stop_handler = scic_sds_port_default_stop_handler, | 2189 | .stop_handler = scic_sds_port_default_stop_handler, |
2216 | .destruct_handler = scic_sds_port_default_destruct_handler, | 2190 | .destruct_handler = scic_sds_port_default_destruct_handler, |
2217 | .reset_handler = scic_sds_port_default_reset_handler, | 2191 | .reset_handler = scic_sds_port_default_reset_handler, |
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h index e63c34d02b7d..2ad205100f25 100644 --- a/drivers/scsi/isci/port.h +++ b/drivers/scsi/isci/port.h | |||
@@ -313,12 +313,6 @@ typedef enum sci_status (*scic_sds_port_io_request_handler_t)(struct scic_sds_po | |||
313 | 313 | ||
314 | struct scic_sds_port_state_handler { | 314 | struct scic_sds_port_state_handler { |
315 | /** | 315 | /** |
316 | * The start_handler specifies the method invoked when a user | ||
317 | * attempts to start a port. | ||
318 | */ | ||
319 | scic_sds_port_handler_t start_handler; | ||
320 | |||
321 | /** | ||
322 | * The stop_handler specifies the method invoked when a user | 316 | * The stop_handler specifies the method invoked when a user |
323 | * attempts to stop a port. | 317 | * attempts to stop a port. |
324 | */ | 318 | */ |
@@ -417,6 +411,8 @@ enum sci_status scic_sds_port_initialize( | |||
417 | void __iomem *port_configuration_regsiter, | 411 | void __iomem *port_configuration_regsiter, |
418 | void __iomem *viit_registers); | 412 | void __iomem *viit_registers); |
419 | 413 | ||
414 | enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port); | ||
415 | |||
420 | enum sci_status scic_sds_port_add_phy( | 416 | enum sci_status scic_sds_port_add_phy( |
421 | struct scic_sds_port *sci_port, | 417 | struct scic_sds_port *sci_port, |
422 | struct scic_sds_phy *sci_phy); | 418 | struct scic_sds_phy *sci_phy); |