aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-03-26 19:43:01 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:00:36 -0400
commit35173d579a08c0d145b3020039d3ba33fbf2c184 (patch)
tree3621fd21219c967dd2284c8e51208a6a91ea44b8
parent068b2c03635bf50c9b408b21435e23e7a0b89b0f (diff)
isci: namespacecheck cleanups
* mark needlessly global routines static * delete unused functions * move kernel-doc blocks from header files to source * reorder some functions to delete declarations * more default handler cleanups phy Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/core/sci_base_port.h12
-rw-r--r--drivers/scsi/isci/core/scic_config_parameters.h13
-rw-r--r--drivers/scsi/isci/core/scic_controller.h348
-rw-r--r--drivers/scsi/isci/core/scic_io_request.h2
-rw-r--r--drivers/scsi/isci/core/scic_port.h98
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.c675
-rw-r--r--drivers/scsi/isci/core/scic_sds_controller.h60
-rw-r--r--drivers/scsi/isci/core/scic_sds_phy.c324
-rw-r--r--drivers/scsi/isci/core/scic_sds_phy.h35
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.c444
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.h53
-rw-r--r--drivers/scsi/isci/core/scic_sds_remote_device.c48
-rw-r--r--drivers/scsi/isci/core/scic_sds_remote_device.h5
-rw-r--r--drivers/scsi/isci/core/scic_sds_remote_node_context.c46
-rw-r--r--drivers/scsi/isci/core/scic_sds_remote_node_context.h8
-rw-r--r--drivers/scsi/isci/core/scic_sds_request.c309
-rw-r--r--drivers/scsi/isci/core/scic_sds_request.h7
-rw-r--r--drivers/scsi/isci/core/scic_sds_smp_remote_device.c2
-rw-r--r--drivers/scsi/isci/core/scic_sds_smp_request.c137
-rw-r--r--drivers/scsi/isci/core/scic_sds_ssp_request.c2
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_pio_request.h11
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_remote_device.c2
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_request.c251
-rw-r--r--drivers/scsi/isci/core/scic_sds_stp_request.h23
-rw-r--r--drivers/scsi/isci/firmware/README2
-rw-r--r--drivers/scsi/isci/port.c2
-rw-r--r--drivers/scsi/isci/request.c73
-rw-r--r--drivers/scsi/isci/request.h6
-rw-r--r--drivers/scsi/isci/task.c11
-rw-r--r--drivers/scsi/isci/task.h10
30 files changed, 1056 insertions, 1963 deletions
diff --git a/drivers/scsi/isci/core/sci_base_port.h b/drivers/scsi/isci/core/sci_base_port.h
index 4e2031d195f0..b931c3c2cdf9 100644
--- a/drivers/scsi/isci/core/sci_base_port.h
+++ b/drivers/scsi/isci/core/sci_base_port.h
@@ -188,16 +188,4 @@ struct sci_base_port_state_handler {
188 SCI_BASE_PORT_PHY_HANDLER_T remove_phy_handler; 188 SCI_BASE_PORT_PHY_HANDLER_T remove_phy_handler;
189 189
190}; 190};
191
192/**
193 * sci_base_port_construct() - Construct the base port object
194 * @this_port: This parameter specifies the base port to be constructed.
195 * @state_table: This parameter specifies the table of state definitions to be
196 * utilized for the domain state machine.
197 *
198 */
199void sci_base_port_construct(
200 struct sci_base_port *this_port,
201 const struct sci_base_state *state_table);
202
203#endif /* _SCI_BASE_PORT_H_ */ 191#endif /* _SCI_BASE_PORT_H_ */
diff --git a/drivers/scsi/isci/core/scic_config_parameters.h b/drivers/scsi/isci/core/scic_config_parameters.h
index f64f24fad5a3..cb6abcc7e7cd 100644
--- a/drivers/scsi/isci/core/scic_config_parameters.h
+++ b/drivers/scsi/isci/core/scic_config_parameters.h
@@ -261,19 +261,6 @@ enum sci_status scic_user_parameters_set(
261 union scic_user_parameters *user_parameters); 261 union scic_user_parameters *user_parameters);
262 262
263/** 263/**
264 * scic_user_parameters_get() - This method allows the user to retrieve the
265 * user parameters utilized by the controller.
266 * @controller: This parameter specifies the controller on which to set the
267 * user parameters.
268 * @user_parameters: This parameter specifies the USER_PARAMETERS object into
269 * which the framework shall save it's parameters.
270 *
271 */
272void scic_user_parameters_get(
273 struct scic_sds_controller *controller,
274 union scic_user_parameters *user_parameters);
275
276/**
277 * scic_oem_parameters_set() - This method allows the user to attempt to change 264 * scic_oem_parameters_set() - This method allows the user to attempt to change
278 * the OEM parameters utilized by the controller. 265 * the OEM parameters utilized by the controller.
279 * @controller: This parameter specifies the controller on which to set the 266 * @controller: This parameter specifies the controller on which to set the
diff --git a/drivers/scsi/isci/core/scic_controller.h b/drivers/scsi/isci/core/scic_controller.h
index 481e0de5148b..236c583162ec 100644
--- a/drivers/scsi/isci/core/scic_controller.h
+++ b/drivers/scsi/isci/core/scic_controller.h
@@ -56,14 +56,6 @@
56#ifndef _SCIC_CONTROLLER_H_ 56#ifndef _SCIC_CONTROLLER_H_
57#define _SCIC_CONTROLLER_H_ 57#define _SCIC_CONTROLLER_H_
58 58
59/**
60 * This file contains all of the interface methods that can be called by an
61 * SCIC user on a controller object.
62 *
63 *
64 */
65
66
67#include "sci_status.h" 59#include "sci_status.h"
68#include "sci_controller.h" 60#include "sci_controller.h"
69#include "scic_config_parameters.h" 61#include "scic_config_parameters.h"
@@ -79,417 +71,77 @@ enum sci_controller_mode {
79 SCI_MODE_SIZE /* Optimized for memory use */ 71 SCI_MODE_SIZE /* Optimized for memory use */
80}; 72};
81 73
82
83/**
84 * scic_controller_construct() - This method will attempt to construct a
85 * controller object utilizing the supplied parameter information.
86 * @c: This parameter specifies the controller to be constructed.
87 * @scu_base: mapped base address of the scu registers
88 * @smu_base: mapped base address of the smu registers
89 *
90 * Indicate if the controller was successfully constructed or if it failed in
91 * some way. SCI_SUCCESS This value is returned if the controller was
92 * successfully constructed. SCI_WARNING_TIMER_CONFLICT This value is returned
93 * if the interrupt coalescence timer may cause SAS compliance issues for SMP
94 * Target mode response processing. SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE
95 * This value is returned if the controller does not support the supplied type.
96 * SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION This value is returned if the
97 * controller does not support the supplied initialization data version.
98 */
99enum sci_status scic_controller_construct(struct scic_sds_controller *c, 74enum sci_status scic_controller_construct(struct scic_sds_controller *c,
100 void __iomem *scu_base, 75 void __iomem *scu_base,
101 void __iomem *smu_base); 76 void __iomem *smu_base);
102 77
103/**
104 * scic_controller_enable_interrupts() - This method will enable all controller
105 * interrupts.
106 * @controller: This parameter specifies the controller for which to enable
107 * interrupts.
108 *
109 */
110void scic_controller_enable_interrupts( 78void scic_controller_enable_interrupts(
111 struct scic_sds_controller *controller); 79 struct scic_sds_controller *controller);
112 80
113/**
114 * scic_controller_disable_interrupts() - This method will disable all
115 * controller interrupts.
116 * @controller: This parameter specifies the controller for which to disable
117 * interrupts.
118 *
119 */
120void scic_controller_disable_interrupts( 81void scic_controller_disable_interrupts(
121 struct scic_sds_controller *controller); 82 struct scic_sds_controller *controller);
122 83
123
124/**
125 * scic_controller_initialize() - This method will initialize the controller
126 * hardware managed by the supplied core controller object. This method
127 * will bring the physical controller hardware out of reset and enable the
128 * core to determine the capabilities of the hardware being managed. Thus,
129 * the core controller can determine it's exact physical (DMA capable)
130 * memory requirements.
131 * @controller: This parameter specifies the controller to be initialized.
132 *
133 * The SCI Core user must have called scic_controller_construct() on the
134 * supplied controller object previously. Indicate if the controller was
135 * successfully initialized or if it failed in some way. SCI_SUCCESS This value
136 * is returned if the controller hardware was successfully initialized.
137 */
138enum sci_status scic_controller_initialize( 84enum sci_status scic_controller_initialize(
139 struct scic_sds_controller *controller); 85 struct scic_sds_controller *controller);
140 86
141/**
142 * scic_controller_get_suggested_start_timeout() - This method returns the
143 * suggested scic_controller_start() timeout amount. The user is free to
144 * use any timeout value, but this method provides the suggested minimum
145 * start timeout value. The returned value is based upon empirical
146 * information determined as a result of interoperability testing.
147 * @controller: the handle to the controller object for which to return the
148 * suggested start timeout.
149 *
150 * This method returns the number of milliseconds for the suggested start
151 * operation timeout.
152 */
153u32 scic_controller_get_suggested_start_timeout( 87u32 scic_controller_get_suggested_start_timeout(
154 struct scic_sds_controller *controller); 88 struct scic_sds_controller *controller);
155 89
156/**
157 * scic_controller_start() - This method will start the supplied core
158 * controller. This method will start the staggered spin up operation. The
159 * SCI User completion callback is called when the following conditions are
160 * met: -# the return status of this method is SCI_SUCCESS. -# after all of
161 * the phys have successfully started or been given the opportunity to start.
162 * @controller: the handle to the controller object to start.
163 * @timeout: This parameter specifies the number of milliseconds in which the
164 * start operation should complete.
165 *
166 * The SCI Core user must have filled in the physical memory descriptor
167 * structure via the sci_controller_get_memory_descriptor_list() method. The
168 * SCI Core user must have invoked the scic_controller_initialize() method
169 * prior to invoking this method. The controller must be in the INITIALIZED or
170 * STARTED state. Indicate if the controller start method succeeded or failed
171 * in some way. SCI_SUCCESS if the start operation succeeded.
172 * SCI_WARNING_ALREADY_IN_STATE if the controller is already in the STARTED
173 * state. SCI_FAILURE_INVALID_STATE if the controller is not either in the
174 * INITIALIZED or STARTED states. SCI_FAILURE_INVALID_MEMORY_DESCRIPTOR if
175 * there are inconsistent or invalid values in the supplied
176 * struct sci_physical_memory_descriptor array.
177 */
178enum sci_status scic_controller_start( 90enum sci_status scic_controller_start(
179 struct scic_sds_controller *controller, 91 struct scic_sds_controller *controller,
180 u32 timeout); 92 u32 timeout);
181 93
182/**
183 * scic_controller_stop() - This method will stop an individual controller
184 * object.This method will invoke the associated user callback upon
185 * completion. The completion callback is called when the following
186 * conditions are met: -# the method return status is SCI_SUCCESS. -# the
187 * controller has been quiesced. This method will ensure that all IO
188 * requests are quiesced, phys are stopped, and all additional operation by
189 * the hardware is halted.
190 * @controller: the handle to the controller object to stop.
191 * @timeout: This parameter specifies the number of milliseconds in which the
192 * stop operation should complete.
193 *
194 * The controller must be in the STARTED or STOPPED state. Indicate if the
195 * controller stop method succeeded or failed in some way. SCI_SUCCESS if the
196 * stop operation successfully began. SCI_WARNING_ALREADY_IN_STATE if the
197 * controller is already in the STOPPED state. SCI_FAILURE_INVALID_STATE if the
198 * controller is not either in the STARTED or STOPPED states.
199 */
200enum sci_status scic_controller_stop( 94enum sci_status scic_controller_stop(
201 struct scic_sds_controller *controller, 95 struct scic_sds_controller *controller,
202 u32 timeout); 96 u32 timeout);
203 97
204/**
205 * scic_controller_reset() - This method will reset the supplied core
206 * controller regardless of the state of said controller. This operation is
207 * considered destructive. In other words, all current operations are wiped
208 * out. No IO completions for outstanding devices occur. Outstanding IO
209 * requests are not aborted or completed at the actual remote device.
210 * @controller: the handle to the controller object to reset.
211 *
212 * Indicate if the controller reset method succeeded or failed in some way.
213 * SCI_SUCCESS if the reset operation successfully started. SCI_FATAL_ERROR if
214 * the controller reset operation is unable to complete.
215 */
216enum sci_status scic_controller_reset( 98enum sci_status scic_controller_reset(
217 struct scic_sds_controller *controller); 99 struct scic_sds_controller *controller);
218 100
219/**
220 * scic_controller_start_io() - This method is called by the SCI user to
221 * send/start an IO request. If the method invocation is successful, then
222 * the IO request has been queued to the hardware for processing.
223 * @controller: the handle to the controller object for which to start an IO
224 * request.
225 * @remote_device: the handle to the remote device object for which to start an
226 * IO request.
227 * @io_request: the handle to the io request object to start.
228 * @io_tag: This parameter specifies a previously allocated IO tag that the
229 * user desires to be utilized for this request. This parameter is optional.
230 * The user is allowed to supply SCI_CONTROLLER_INVALID_IO_TAG as the value
231 * for this parameter.
232 *
233 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
234 * to ensure that each of the methods that may allocate or free available IO
235 * tags are handled in a mutually exclusive manner. This method is one of said
236 * methods requiring proper critical code section protection (e.g. semaphore,
237 * spin-lock, etc.). - For SATA, the user is required to manage NCQ tags. As a
238 * result, it is expected the user will have set the NCQ tag field in the host
239 * to device register FIS prior to calling this method. There is also a
240 * requirement for the user to call scic_stp_io_set_ncq_tag() prior to invoking
241 * the scic_controller_start_io() method. scic_controller_allocate_tag() for
242 * more information on allocating a tag. Indicate if the controller
243 * successfully started the IO request. SCI_IO_SUCCESS if the IO request was
244 * successfully started. Determine the failure situations and return values.
245 */
246enum sci_io_status scic_controller_start_io( 101enum sci_io_status scic_controller_start_io(
247 struct scic_sds_controller *controller, 102 struct scic_sds_controller *controller,
248 struct scic_sds_remote_device *remote_device, 103 struct scic_sds_remote_device *remote_device,
249 struct scic_sds_request *io_request, 104 struct scic_sds_request *io_request,
250 u16 io_tag); 105 u16 io_tag);
251 106
252
253/**
254 * scic_controller_start_task() - This method is called by the SCIC user to
255 * send/start a framework task management request.
256 * @controller: the handle to the controller object for which to start the task
257 * management request.
258 * @remote_device: the handle to the remote device object for which to start
259 * the task management request.
260 * @task_request: the handle to the task request object to start.
261 * @io_tag: This parameter specifies a previously allocated IO tag that the
262 * user desires to be utilized for this request. Note this not the io_tag
263 * of the request being managed. It is to be utilized for the task request
264 * itself. This parameter is optional. The user is allowed to supply
265 * SCI_CONTROLLER_INVALID_IO_TAG as the value for this parameter.
266 *
267 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
268 * to ensure that each of the methods that may allocate or free available IO
269 * tags are handled in a mutually exclusive manner. This method is one of said
270 * methods requiring proper critical code section protection (e.g. semaphore,
271 * spin-lock, etc.). - The user must synchronize this task with completion
272 * queue processing. If they are not synchronized then it is possible for the
273 * io requests that are being managed by the task request can complete before
274 * starting the task request. scic_controller_allocate_tag() for more
275 * information on allocating a tag. Indicate if the controller successfully
276 * started the IO request. SCI_TASK_SUCCESS if the task request was
277 * successfully started. SCI_TASK_FAILURE_REQUIRES_SCSI_ABORT This value is
278 * returned if there is/are task(s) outstanding that require termination or
279 * completion before this request can succeed.
280 */
281enum sci_task_status scic_controller_start_task( 107enum sci_task_status scic_controller_start_task(
282 struct scic_sds_controller *controller, 108 struct scic_sds_controller *controller,
283 struct scic_sds_remote_device *remote_device, 109 struct scic_sds_remote_device *remote_device,
284 struct scic_sds_request *task_request, 110 struct scic_sds_request *task_request,
285 u16 io_tag); 111 u16 io_tag);
286 112
287/**
288 * scic_controller_complete_task() - This method will perform core specific
289 * completion operations for task management request. After this method is
290 * invoked, the user should consider the task request as invalid until it is
291 * properly reused (i.e. re-constructed).
292 * @controller: The handle to the controller object for which to complete the
293 * task management request.
294 * @remote_device: The handle to the remote device object for which to complete
295 * the task management request.
296 * @task_request: the handle to the task management request object to complete.
297 *
298 * Indicate if the controller successfully completed the task management
299 * request. SCI_SUCCESS if the completion process was successful.
300 */
301enum sci_status scic_controller_complete_task( 113enum sci_status scic_controller_complete_task(
302 struct scic_sds_controller *controller, 114 struct scic_sds_controller *controller,
303 struct scic_sds_remote_device *remote_device, 115 struct scic_sds_remote_device *remote_device,
304 struct scic_sds_request *task_request); 116 struct scic_sds_request *task_request);
305 117
306
307/**
308 * scic_controller_terminate_request() - This method is called by the SCI Core
309 * user to terminate an ongoing (i.e. started) core IO request. This does
310 * not abort the IO request at the target, but rather removes the IO request
311 * from the host controller.
312 * @controller: the handle to the controller object for which to terminate a
313 * request.
314 * @remote_device: the handle to the remote device object for which to
315 * terminate a request.
316 * @request: the handle to the io or task management request object to
317 * terminate.
318 *
319 * Indicate if the controller successfully began the terminate process for the
320 * IO request. SCI_SUCCESS if the terminate process was successfully started
321 * for the request. Determine the failure situations and return values.
322 */
323enum sci_status scic_controller_terminate_request( 118enum sci_status scic_controller_terminate_request(
324 struct scic_sds_controller *controller, 119 struct scic_sds_controller *controller,
325 struct scic_sds_remote_device *remote_device, 120 struct scic_sds_remote_device *remote_device,
326 struct scic_sds_request *request); 121 struct scic_sds_request *request);
327 122
328/**
329 * scic_controller_complete_io() - This method will perform core specific
330 * completion operations for an IO request. After this method is invoked,
331 * the user should consider the IO request as invalid until it is properly
332 * reused (i.e. re-constructed).
333 * @controller: The handle to the controller object for which to complete the
334 * IO request.
335 * @remote_device: The handle to the remote device object for which to complete
336 * the IO request.
337 * @io_request: the handle to the io request object to complete.
338 *
339 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
340 * to ensure that each of the methods that may allocate or free available IO
341 * tags are handled in a mutually exclusive manner. This method is one of said
342 * methods requiring proper critical code section protection (e.g. semaphore,
343 * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
344 * Core user, using the scic_controller_allocate_io_tag() method, then it is
345 * the responsibility of the caller to invoke the scic_controller_free_io_tag()
346 * method to free the tag (i.e. this method will not free the IO tag). Indicate
347 * if the controller successfully completed the IO request. SCI_SUCCESS if the
348 * completion process was successful.
349 */
350enum sci_status scic_controller_complete_io( 123enum sci_status scic_controller_complete_io(
351 struct scic_sds_controller *controller, 124 struct scic_sds_controller *controller,
352 struct scic_sds_remote_device *remote_device, 125 struct scic_sds_remote_device *remote_device,
353 struct scic_sds_request *io_request); 126 struct scic_sds_request *io_request);
354 127
355
356/**
357 * scic_controller_get_port_handle() - This method simply provides the user
358 * with a unique handle for a given SAS/SATA core port index.
359 * @controller: This parameter represents the handle to the controller object
360 * from which to retrieve a port (SAS or SATA) handle.
361 * @port_index: This parameter specifies the port index in the controller for
362 * which to retrieve the port handle. 0 <= port_index < maximum number of
363 * phys.
364 * @port_handle: This parameter specifies the retrieved port handle to be
365 * provided to the caller.
366 *
367 * Indicate if the retrieval of the port handle was successful. SCI_SUCCESS
368 * This value is returned if the retrieval was successful.
369 * SCI_FAILURE_INVALID_PORT This value is returned if the supplied port id is
370 * not in the supported range.
371 */
372enum sci_status scic_controller_get_port_handle( 128enum sci_status scic_controller_get_port_handle(
373 struct scic_sds_controller *controller, 129 struct scic_sds_controller *controller,
374 u8 port_index, 130 u8 port_index,
375 struct scic_sds_port **port_handle); 131 struct scic_sds_port **port_handle);
376 132
377/**
378 * scic_controller_get_phy_handle() - This method simply provides the user with
379 * a unique handle for a given SAS/SATA phy index/identifier.
380 * @controller: This parameter represents the handle to the controller object
381 * from which to retrieve a phy (SAS or SATA) handle.
382 * @phy_index: This parameter specifies the phy index in the controller for
383 * which to retrieve the phy handle. 0 <= phy_index < maximum number of phys.
384 * @phy_handle: This parameter specifies the retrieved phy handle to be
385 * provided to the caller.
386 *
387 * Indicate if the retrieval of the phy handle was successful. SCI_SUCCESS This
388 * value is returned if the retrieval was successful. SCI_FAILURE_INVALID_PHY
389 * This value is returned if the supplied phy id is not in the supported range.
390 */
391enum sci_status scic_controller_get_phy_handle( 133enum sci_status scic_controller_get_phy_handle(
392 struct scic_sds_controller *controller, 134 struct scic_sds_controller *controller,
393 u8 phy_index, 135 u8 phy_index,
394 struct scic_sds_phy **phy_handle); 136 struct scic_sds_phy **phy_handle);
395 137
396/**
397 * scic_controller_allocate_io_tag() - This method will allocate a tag from the
398 * pool of free IO tags. Direct allocation of IO tags by the SCI Core user
399 * is optional. The scic_controller_start_io() method will allocate an IO
400 * tag if this method is not utilized and the tag is not supplied to the IO
401 * construct routine. Direct allocation of IO tags may provide additional
402 * performance improvements in environments capable of supporting this usage
403 * model. Additionally, direct allocation of IO tags also provides
404 * additional flexibility to the SCI Core user. Specifically, the user may
405 * retain IO tags across the lives of multiple IO requests.
406 * @controller: the handle to the controller object for which to allocate the
407 * tag.
408 *
409 * IO tags are a protected resource. It is incumbent upon the SCI Core user to
410 * ensure that each of the methods that may allocate or free available IO tags
411 * are handled in a mutually exclusive manner. This method is one of said
412 * methods requiring proper critical code section protection (e.g. semaphore,
413 * spin-lock, etc.). An unsigned integer representing an available IO tag.
414 * SCI_CONTROLLER_INVALID_IO_TAG This value is returned if there are no
415 * currently available tags to be allocated. All return other values indicate a
416 * legitimate tag.
417 */
418u16 scic_controller_allocate_io_tag( 138u16 scic_controller_allocate_io_tag(
419 struct scic_sds_controller *controller); 139 struct scic_sds_controller *controller);
420 140
421/**
422 * scic_controller_free_io_tag() - This method will free an IO tag to the pool
423 * of free IO tags. This method provides the SCI Core user more flexibility
424 * with regards to IO tags. The user may desire to keep an IO tag after an
425 * IO request has completed, because they plan on re-using the tag for a
426 * subsequent IO request. This method is only legal if the tag was
427 * allocated via scic_controller_allocate_io_tag().
428 * @controller: This parameter specifies the handle to the controller object
429 * for which to free/return the tag.
430 * @io_tag: This parameter represents the tag to be freed to the pool of
431 * available tags.
432 *
433 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
434 * to ensure that each of the methods that may allocate or free available IO
435 * tags are handled in a mutually exclusive manner. This method is one of said
436 * methods requiring proper critical code section protection (e.g. semaphore,
437 * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
438 * Core user, using the scic_controller_allocate_io_tag() method, then it is
439 * the responsibility of the caller to invoke this method to free the tag. This
440 * method returns an indication of whether the tag was successfully put back
441 * (freed) to the pool of available tags. SCI_SUCCESS This return value
442 * indicates the tag was successfully placed into the pool of available IO
443 * tags. SCI_FAILURE_INVALID_IO_TAG This value is returned if the supplied tag
444 * is not a valid IO tag value.
445 */
446enum sci_status scic_controller_free_io_tag( 141enum sci_status scic_controller_free_io_tag(
447 struct scic_sds_controller *controller, 142 struct scic_sds_controller *controller,
448 u16 io_tag); 143 u16 io_tag);
449 144
450
451
452
453/**
454 * scic_controller_set_mode() - This method allows the user to configure the
455 * SCI core into either a performance mode or a memory savings mode.
456 * @controller: This parameter represents the handle to the controller object
457 * for which to update the operating mode.
458 * @mode: This parameter specifies the new mode for the controller.
459 *
460 * Indicate if the user successfully change the operating mode of the
461 * controller. SCI_SUCCESS The user successfully updated the mode.
462 */
463enum sci_status scic_controller_set_mode(
464 struct scic_sds_controller *controller,
465 enum sci_controller_mode mode);
466
467
468/**
469 * scic_controller_set_interrupt_coalescence() - This method allows the user to
470 * configure the interrupt coalescence.
471 * @controller: This parameter represents the handle to the controller object
472 * for which its interrupt coalesce register is overridden.
473 * @coalesce_number: Used to control the number of entries in the Completion
474 * Queue before an interrupt is generated. If the number of entries exceed
475 * this number, an interrupt will be generated. The valid range of the input
476 * is [0, 256]. A setting of 0 results in coalescing being disabled.
477 * @coalesce_timeout: Timeout value in microseconds. The valid range of the
478 * input is [0, 2700000] . A setting of 0 is allowed and results in no
479 * interrupt coalescing timeout.
480 *
481 * Indicate if the user successfully set the interrupt coalesce parameters.
482 * SCI_SUCCESS The user successfully updated the interrutp coalescence.
483 * SCI_FAILURE_INVALID_PARAMETER_VALUE The user input value is out of range.
484 */
485enum sci_status scic_controller_set_interrupt_coalescence(
486 struct scic_sds_controller *controller,
487 u32 coalesce_number,
488 u32 coalesce_timeout);
489
490struct device; 145struct device;
491struct scic_sds_controller *scic_controller_alloc(struct device *dev); 146struct scic_sds_controller *scic_controller_alloc(struct device *dev);
492
493
494#endif /* _SCIC_CONTROLLER_H_ */ 147#endif /* _SCIC_CONTROLLER_H_ */
495
diff --git a/drivers/scsi/isci/core/scic_io_request.h b/drivers/scsi/isci/core/scic_io_request.h
index a52f33d94abd..fea894a0d28e 100644
--- a/drivers/scsi/isci/core/scic_io_request.h
+++ b/drivers/scsi/isci/core/scic_io_request.h
@@ -325,7 +325,7 @@ enum sci_status scic_io_request_construct(
325 struct scic_sds_remote_device *scic_remote_device, 325 struct scic_sds_remote_device *scic_remote_device,
326 u16 io_tag, 326 u16 io_tag,
327 void *user_io_request_object, 327 void *user_io_request_object,
328 void *scic_io_request_memory, 328 struct scic_sds_request *scic_io_request_memory,
329 struct scic_sds_request **new_scic_io_request_handle); 329 struct scic_sds_request **new_scic_io_request_handle);
330 330
331/** 331/**
diff --git a/drivers/scsi/isci/core/scic_port.h b/drivers/scsi/isci/core/scic_port.h
index 8222443c9fd7..582953343237 100644
--- a/drivers/scsi/isci/core/scic_port.h
+++ b/drivers/scsi/isci/core/scic_port.h
@@ -56,14 +56,6 @@
56#ifndef _SCIC_PORT_H_ 56#ifndef _SCIC_PORT_H_
57#define _SCIC_PORT_H_ 57#define _SCIC_PORT_H_
58 58
59/**
60 * This file contains all of the interface methods that can be called by an SCI
61 * Core user on a SAS or SATA port.
62 *
63 *
64 */
65
66
67#include "sci_status.h" 59#include "sci_status.h"
68#include "intel_sas.h" 60#include "intel_sas.h"
69 61
@@ -78,118 +70,28 @@ enum SCIC_PORT_NOT_READY_REASON_CODE {
78 SCIC_PORT_NOT_READY_REASON_CODE_MAX 70 SCIC_PORT_NOT_READY_REASON_CODE_MAX
79}; 71};
80 72
81/**
82 * struct scic_port_end_point_properties - This structure defines the
83 * properties that can be retrieved for each end-point local or remote
84 * (attached) port in the controller.
85 *
86 *
87 */
88struct scic_port_end_point_properties { 73struct scic_port_end_point_properties {
89 /**
90 * This field indicates the SAS address for the associated end
91 * point in the port.
92 */
93 struct sci_sas_address sas_address; 74 struct sci_sas_address sas_address;
94
95 /**
96 * This field indicates the protocols supported by the associated
97 * end-point in the port.
98 */
99 struct sci_sas_identify_address_frame_protocols protocols; 75 struct sci_sas_identify_address_frame_protocols protocols;
100 76
101}; 77};
102 78
103/**
104 * struct scic_port_properties - This structure defines the properties that can
105 * be retrieved for each port in the controller.
106 *
107 *
108 */
109struct scic_port_properties { 79struct scic_port_properties {
110 /**
111 * This field specifies the logical index of the port (0 relative).
112 */
113 u32 index; 80 u32 index;
114
115 /**
116 * This field indicates the local end-point properties for port.
117 */
118 struct scic_port_end_point_properties local; 81 struct scic_port_end_point_properties local;
119
120 /**
121 * This field indicates the remote (attached) end-point properties
122 * for the port.
123 */
124 struct scic_port_end_point_properties remote; 82 struct scic_port_end_point_properties remote;
125
126 /**
127 * This field specifies the phys contained inside the port.
128 */
129 u32 phy_mask; 83 u32 phy_mask;
130
131}; 84};
132 85
133/**
134 * scic_port_get_properties() - This method simply returns the properties
135 * regarding the port, such as: physical index, protocols, sas address, etc.
136 * @port: this parameter specifies the port for which to retrieve the physical
137 * index.
138 * @properties: This parameter specifies the properties structure into which to
139 * copy the requested information.
140 *
141 * Indicate if the user specified a valid port. SCI_SUCCESS This value is
142 * returned if the specified port was valid. SCI_FAILURE_INVALID_PORT This
143 * value is returned if the specified port is not valid. When this value is
144 * returned, no data is copied to the properties output parameter.
145 */
146enum sci_status scic_port_get_properties( 86enum sci_status scic_port_get_properties(
147 struct scic_sds_port *port, 87 struct scic_sds_port *port,
148 struct scic_port_properties *properties); 88 struct scic_port_properties *properties);
149 89
150/**
151 * scic_port_stop() - This method will make the port no longer ready for
152 * operation. After invoking this method IO operation is not possible.
153 * @port: This parameter specifies the port to be stopped.
154 *
155 * Indicate if the port was successfully stopped. SCI_SUCCESS This value is
156 * returned if the port was successfully stopped. SCI_WARNING_ALREADY_IN_STATE
157 * This value is returned if the port is already stopped or in the process of
158 * stopping. SCI_FAILURE_INVALID_PORT This value is returned if the supplied
159 * port is not valid. SCI_FAILURE_INVALID_STATE This value is returned if a
160 * stop operation can't be completed due to the state of port.
161 */
162enum sci_status scic_port_stop(
163 struct scic_sds_port *port);
164
165/**
166 * scic_port_hard_reset() - This method will request the SCI implementation to
167 * perform a HARD RESET on the SAS Port. If/When the HARD RESET completes
168 * the SCI user will be notified via an SCI OS callback indicating a direct
169 * attached device was found.
170 * @port: a handle corresponding to the SAS port to be hard reset.
171 * @reset_timeout: This parameter specifies the number of milliseconds in which
172 * the port reset operation should complete.
173 *
174 * The SCI User callback in SCIC_USER_CALLBACKS_T will only be called once for
175 * each phy in the SAS Port at completion of the hard reset sequence. Return a
176 * status indicating whether the hard reset started successfully. SCI_SUCCESS
177 * This value is returned if the hard reset operation started successfully.
178 */
179enum sci_status scic_port_hard_reset( 90enum sci_status scic_port_hard_reset(
180 struct scic_sds_port *port, 91 struct scic_sds_port *port,
181 u32 reset_timeout); 92 u32 reset_timeout);
182 93
183/**
184 * scic_port_enable_broadcast_change_notification() - This API method enables
185 * the broadcast change notification from underneath hardware.
186 * @port: The port upon which broadcast change notifications (BCN) are to be
187 * enabled.
188 *
189 */
190void scic_port_enable_broadcast_change_notification( 94void scic_port_enable_broadcast_change_notification(
191 struct scic_sds_port *port); 95 struct scic_sds_port *port);
192 96
193
194#endif /* _SCIC_PORT_H_ */ 97#endif /* _SCIC_PORT_H_ */
195
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c
index 7d25a0aafb66..5cc6f2fa0939 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.c
+++ b/drivers/scsi/isci/core/scic_sds_controller.c
@@ -219,98 +219,33 @@ sci_controller_get_memory_descriptor_list_handle(struct scic_sds_controller *sci
219 return &scic->parent.mdl; 219 return &scic->parent.mdl;
220} 220}
221 221
222/* 222static void scic_sds_controller_initialize_power_control(struct scic_sds_controller *scic)
223 * ****************************************************************************-
224 * * SCIC SDS Controller Initialization Methods
225 * ****************************************************************************- */
226
227/**
228 * This timer is used to start another phy after we have given up on the
229 * previous phy to transition to the ready state.
230 *
231 *
232 */
233static void scic_sds_controller_phy_startup_timeout_handler(
234 void *controller)
235{
236 enum sci_status status;
237 struct scic_sds_controller *this_controller;
238
239 this_controller = (struct scic_sds_controller *)controller;
240
241 this_controller->phy_startup_timer_pending = false;
242
243 status = SCI_FAILURE;
244
245 while (status != SCI_SUCCESS) {
246 status = scic_sds_controller_start_next_phy(this_controller);
247 }
248}
249
250/**
251 *
252 *
253 * This method initializes the phy startup operations for controller start.
254 */
255enum sci_status scic_sds_controller_initialize_phy_startup(
256 struct scic_sds_controller *scic)
257{ 223{
258 struct isci_host *ihost = sci_object_get_association(scic); 224 struct isci_host *ihost = sci_object_get_association(scic);
225 scic->power_control.timer = isci_timer_create(ihost,
226 scic,
227 scic_sds_controller_power_control_timer_handler);
259 228
260 scic->phy_startup_timer = isci_timer_create(ihost, 229 memset(scic->power_control.requesters, 0,
261 scic,
262 scic_sds_controller_phy_startup_timeout_handler);
263
264 if (scic->phy_startup_timer == NULL)
265 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
266 else {
267 scic->next_phy_to_start = 0;
268 scic->phy_startup_timer_pending = false;
269 }
270
271 return SCI_SUCCESS;
272}
273
274/**
275 *
276 *
277 * This method initializes the power control operations for the controller
278 * object.
279 */
280void scic_sds_controller_initialize_power_control(
281 struct scic_sds_controller *scic)
282{
283 struct isci_host *ihost = sci_object_get_association(scic);
284 scic->power_control.timer = isci_timer_create(
285 ihost,
286 scic,
287 scic_sds_controller_power_control_timer_handler);
288
289 memset(scic->power_control.requesters,
290 0,
291 sizeof(scic->power_control.requesters)); 230 sizeof(scic->power_control.requesters));
292 231
293 scic->power_control.phys_waiting = 0; 232 scic->power_control.phys_waiting = 0;
294 scic->power_control.phys_granted_power = 0; 233 scic->power_control.phys_granted_power = 0;
295} 234}
296 235
297/* --------------------------------------------------------------------------- */
298
299#define SCU_REMOTE_NODE_CONTEXT_ALIGNMENT (32) 236#define SCU_REMOTE_NODE_CONTEXT_ALIGNMENT (32)
300#define SCU_TASK_CONTEXT_ALIGNMENT (256) 237#define SCU_TASK_CONTEXT_ALIGNMENT (256)
301#define SCU_UNSOLICITED_FRAME_ADDRESS_ALIGNMENT (64) 238#define SCU_UNSOLICITED_FRAME_ADDRESS_ALIGNMENT (64)
302#define SCU_UNSOLICITED_FRAME_BUFFER_ALIGNMENT (1024) 239#define SCU_UNSOLICITED_FRAME_BUFFER_ALIGNMENT (1024)
303#define SCU_UNSOLICITED_FRAME_HEADER_ALIGNMENT (64) 240#define SCU_UNSOLICITED_FRAME_HEADER_ALIGNMENT (64)
304 241
305/* --------------------------------------------------------------------------- */
306
307/** 242/**
308 * This method builds the memory descriptor table for this controller. 243 * This method builds the memory descriptor table for this controller.
309 * @this_controller: This parameter specifies the controller object for which 244 * @this_controller: This parameter specifies the controller object for which
310 * to build the memory table. 245 * to build the memory table.
311 * 246 *
312 */ 247 */
313void scic_sds_controller_build_memory_descriptor_table( 248static void scic_sds_controller_build_memory_descriptor_table(
314 struct scic_sds_controller *this_controller) 249 struct scic_sds_controller *this_controller)
315{ 250{
316 sci_base_mde_construct( 251 sci_base_mde_construct(
@@ -356,7 +291,7 @@ void scic_sds_controller_build_memory_descriptor_table(
356 * 291 *
357 * enum sci_status 292 * enum sci_status
358 */ 293 */
359enum sci_status scic_sds_controller_validate_memory_descriptor_table( 294static enum sci_status scic_sds_controller_validate_memory_descriptor_table(
360 struct scic_sds_controller *this_controller) 295 struct scic_sds_controller *this_controller)
361{ 296{
362 bool mde_list_valid; 297 bool mde_list_valid;
@@ -410,7 +345,7 @@ enum sci_status scic_sds_controller_validate_memory_descriptor_table(
410 * @this_controller: 345 * @this_controller:
411 * 346 *
412 */ 347 */
413void scic_sds_controller_ram_initialization( 348static void scic_sds_controller_ram_initialization(
414 struct scic_sds_controller *this_controller) 349 struct scic_sds_controller *this_controller)
415{ 350{
416 struct sci_physical_memory_descriptor *mde; 351 struct sci_physical_memory_descriptor *mde;
@@ -457,7 +392,7 @@ void scic_sds_controller_ram_initialization(
457 * @this_controller: 392 * @this_controller:
458 * 393 *
459 */ 394 */
460void scic_sds_controller_assign_task_entries( 395static void scic_sds_controller_assign_task_entries(
461 struct scic_sds_controller *this_controller) 396 struct scic_sds_controller *this_controller)
462{ 397{
463 u32 task_assignment; 398 u32 task_assignment;
@@ -483,7 +418,7 @@ void scic_sds_controller_assign_task_entries(
483 * 418 *
484 * 419 *
485 */ 420 */
486void scic_sds_controller_initialize_completion_queue( 421static void scic_sds_controller_initialize_completion_queue(
487 struct scic_sds_controller *this_controller) 422 struct scic_sds_controller *this_controller)
488{ 423{
489 u32 index; 424 u32 index;
@@ -533,7 +468,7 @@ void scic_sds_controller_initialize_completion_queue(
533 * 468 *
534 * 469 *
535 */ 470 */
536void scic_sds_controller_initialize_unsolicited_frame_queue( 471static void scic_sds_controller_initialize_unsolicited_frame_queue(
537 struct scic_sds_controller *this_controller) 472 struct scic_sds_controller *this_controller)
538{ 473{
539 u32 frame_queue_control_value; 474 u32 frame_queue_control_value;
@@ -565,7 +500,7 @@ void scic_sds_controller_initialize_unsolicited_frame_queue(
565 * 500 *
566 * 501 *
567 */ 502 */
568void scic_sds_controller_enable_port_task_scheduler( 503static void scic_sds_controller_enable_port_task_scheduler(
569 struct scic_sds_controller *this_controller) 504 struct scic_sds_controller *this_controller)
570{ 505{
571 u32 port_task_scheduler_value; 506 u32 port_task_scheduler_value;
@@ -578,8 +513,6 @@ void scic_sds_controller_enable_port_task_scheduler(
578 SCU_PTSGCR_WRITE(this_controller, port_task_scheduler_value); 513 SCU_PTSGCR_WRITE(this_controller, port_task_scheduler_value);
579} 514}
580 515
581/* --------------------------------------------------------------------------- */
582
583/** 516/**
584 * 517 *
585 * 518 *
@@ -591,7 +524,7 @@ void scic_sds_controller_enable_port_task_scheduler(
591/* Initialize the AFE for this phy index. We need to read the AFE setup from 524/* Initialize the AFE for this phy index. We need to read the AFE setup from
592 * the OEM parameters none 525 * the OEM parameters none
593 */ 526 */
594void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic) 527static void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic)
595{ 528{
596 const struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1; 529 const struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
597 u32 afe_status; 530 u32 afe_status;
@@ -746,7 +679,7 @@ static void scic_sds_controller_transition_to_ready(
746 } 679 }
747} 680}
748 681
749void scic_sds_controller_timeout_handler(void *_scic) 682static void scic_sds_controller_timeout_handler(void *_scic)
750{ 683{
751 struct scic_sds_controller *scic = _scic; 684 struct scic_sds_controller *scic = _scic;
752 struct isci_host *ihost = sci_object_get_association(scic); 685 struct isci_host *ihost = sci_object_get_association(scic);
@@ -764,7 +697,7 @@ void scic_sds_controller_timeout_handler(void *_scic)
764 __func__); 697 __func__);
765} 698}
766 699
767enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller *scic) 700static enum sci_status scic_sds_controller_stop_ports(struct scic_sds_controller *scic)
768{ 701{
769 u32 index; 702 u32 index;
770 enum sci_status port_status; 703 enum sci_status port_status;
@@ -802,8 +735,7 @@ static inline void scic_sds_controller_phy_timer_start(
802 scic->phy_startup_timer_pending = true; 735 scic->phy_startup_timer_pending = true;
803} 736}
804 737
805inline void scic_sds_controller_phy_timer_stop( 738static void scic_sds_controller_phy_timer_stop(struct scic_sds_controller *scic)
806 struct scic_sds_controller *scic)
807{ 739{
808 isci_timer_stop(scic->phy_startup_timer); 740 isci_timer_stop(scic->phy_startup_timer);
809 741
@@ -811,16 +743,14 @@ inline void scic_sds_controller_phy_timer_stop(
811} 743}
812 744
813/** 745/**
814 * This method is called internally by the controller object to start the next 746 * scic_sds_controller_start_next_phy - start phy
815 * phy on the controller. If all the phys have been started, then this 747 * @scic: controller
816 * method will attempt to transition the controller to the READY state and
817 * inform the user (scic_cb_controller_start_complete()).
818 * @this_controller: This parameter specifies the controller object for which
819 * to start the next phy.
820 * 748 *
821 * enum sci_status 749 * If all the phys have been started, then attempt to transition the
750 * controller to the READY state and inform the user
751 * (scic_cb_controller_start_complete()).
822 */ 752 */
823enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_controller *scic) 753static enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_controller *scic)
824{ 754{
825 struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1; 755 struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1;
826 struct scic_sds_phy *sci_phy; 756 struct scic_sds_phy *sci_phy;
@@ -907,14 +837,36 @@ enum sci_status scic_sds_controller_start_next_phy(struct scic_sds_controller *s
907 return status; 837 return status;
908} 838}
909 839
910/** 840static void scic_sds_controller_phy_startup_timeout_handler(void *_scic)
911 * 841{
912 * @this_controller: 842 struct scic_sds_controller *scic = _scic;
913 * 843 enum sci_status status;
914 * enum sci_status 844
915 */ 845 scic->phy_startup_timer_pending = false;
916enum sci_status scic_sds_controller_stop_phys( 846 status = SCI_FAILURE;
917 struct scic_sds_controller *this_controller) 847 while (status != SCI_SUCCESS)
848 status = scic_sds_controller_start_next_phy(scic);
849}
850
851static enum sci_status scic_sds_controller_initialize_phy_startup(struct scic_sds_controller *scic)
852{
853 struct isci_host *ihost = sci_object_get_association(scic);
854
855 scic->phy_startup_timer = isci_timer_create(ihost,
856 scic,
857 scic_sds_controller_phy_startup_timeout_handler);
858
859 if (scic->phy_startup_timer == NULL)
860 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
861 else {
862 scic->next_phy_to_start = 0;
863 scic->phy_startup_timer_pending = false;
864 }
865
866 return SCI_SUCCESS;
867}
868
869static enum sci_status scic_sds_controller_stop_phys(struct scic_sds_controller *scic)
918{ 870{
919 u32 index; 871 u32 index;
920 enum sci_status status; 872 enum sci_status status;
@@ -923,7 +875,7 @@ enum sci_status scic_sds_controller_stop_phys(
923 status = SCI_SUCCESS; 875 status = SCI_SUCCESS;
924 876
925 for (index = 0; index < SCI_MAX_PHYS; index++) { 877 for (index = 0; index < SCI_MAX_PHYS; index++) {
926 phy_status = scic_sds_phy_stop(&this_controller->phy_table[index]); 878 phy_status = scic_sds_phy_stop(&scic->phy_table[index]);
927 879
928 if ( 880 if (
929 (phy_status != SCI_SUCCESS) 881 (phy_status != SCI_SUCCESS)
@@ -931,25 +883,18 @@ enum sci_status scic_sds_controller_stop_phys(
931 ) { 883 ) {
932 status = SCI_FAILURE; 884 status = SCI_FAILURE;
933 885
934 dev_warn(scic_to_dev(this_controller), 886 dev_warn(scic_to_dev(scic),
935 "%s: Controller stop operation failed to stop " 887 "%s: Controller stop operation failed to stop "
936 "phy %d because of status %d.\n", 888 "phy %d because of status %d.\n",
937 __func__, 889 __func__,
938 this_controller->phy_table[index].phy_index, phy_status); 890 scic->phy_table[index].phy_index, phy_status);
939 } 891 }
940 } 892 }
941 893
942 return status; 894 return status;
943} 895}
944 896
945/** 897static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controller *scic)
946 *
947 * @this_controller:
948 *
949 * enum sci_status
950 */
951enum sci_status scic_sds_controller_stop_devices(
952 struct scic_sds_controller *this_controller)
953{ 898{
954 u32 index; 899 u32 index;
955 enum sci_status status; 900 enum sci_status status;
@@ -957,19 +902,19 @@ enum sci_status scic_sds_controller_stop_devices(
957 902
958 status = SCI_SUCCESS; 903 status = SCI_SUCCESS;
959 904
960 for (index = 0; index < this_controller->remote_node_entries; index++) { 905 for (index = 0; index < scic->remote_node_entries; index++) {
961 if (this_controller->device_table[index] != NULL) { 906 if (scic->device_table[index] != NULL) {
962 /* / @todo What timeout value do we want to provide to this request? */ 907 /* / @todo What timeout value do we want to provide to this request? */
963 device_status = scic_remote_device_stop(this_controller->device_table[index], 0); 908 device_status = scic_remote_device_stop(scic->device_table[index], 0);
964 909
965 if ((device_status != SCI_SUCCESS) && 910 if ((device_status != SCI_SUCCESS) &&
966 (device_status != SCI_FAILURE_INVALID_STATE)) { 911 (device_status != SCI_FAILURE_INVALID_STATE)) {
967 dev_warn(scic_to_dev(this_controller), 912 dev_warn(scic_to_dev(scic),
968 "%s: Controller stop operation failed " 913 "%s: Controller stop operation failed "
969 "to stop device 0x%p because of " 914 "to stop device 0x%p because of "
970 "status %d.\n", 915 "status %d.\n",
971 __func__, 916 __func__,
972 this_controller->device_table[index], device_status); 917 scic->device_table[index], device_status);
973 } 918 }
974 } 919 }
975 } 920 }
@@ -977,18 +922,7 @@ enum sci_status scic_sds_controller_stop_devices(
977 return status; 922 return status;
978} 923}
979 924
980/* 925static void scic_sds_controller_power_control_timer_start(struct scic_sds_controller *scic)
981 * ****************************************************************************-
982 * * SCIC SDS Controller Power Control (Staggered Spinup)
983 * ****************************************************************************- */
984
985/**
986 * This function starts the power control timer for this controller object.
987 *
988 * @param scic
989 */
990static inline void scic_sds_controller_power_control_timer_start(
991 struct scic_sds_controller *scic)
992{ 926{
993 isci_timer_start(scic->power_control.timer, 927 isci_timer_start(scic->power_control.timer,
994 SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL); 928 SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL);
@@ -996,13 +930,7 @@ static inline void scic_sds_controller_power_control_timer_start(
996 scic->power_control.timer_started = true; 930 scic->power_control.timer_started = true;
997} 931}
998 932
999/** 933static void scic_sds_controller_power_control_timer_stop(struct scic_sds_controller *scic)
1000 * This method stops the power control timer for this controller object.
1001 *
1002 * @param scic
1003 */
1004static inline void scic_sds_controller_power_control_timer_stop(
1005 struct scic_sds_controller *scic)
1006{ 934{
1007 if (scic->power_control.timer_started) { 935 if (scic->power_control.timer_started) {
1008 isci_timer_stop(scic->power_control.timer); 936 isci_timer_stop(scic->power_control.timer);
@@ -1010,24 +938,12 @@ static inline void scic_sds_controller_power_control_timer_stop(
1010 } 938 }
1011} 939}
1012 940
1013/** 941static void scic_sds_controller_power_control_timer_restart(struct scic_sds_controller *scic)
1014 * This method stops and starts the power control timer for this controller
1015 * object.
1016 *
1017 * @param scic
1018 */
1019static inline void scic_sds_controller_power_control_timer_restart(
1020 struct scic_sds_controller *scic)
1021{ 942{
1022 scic_sds_controller_power_control_timer_stop(scic); 943 scic_sds_controller_power_control_timer_stop(scic);
1023 scic_sds_controller_power_control_timer_start(scic); 944 scic_sds_controller_power_control_timer_start(scic);
1024} 945}
1025 946
1026/**
1027 *
1028 *
1029 *
1030 */
1031static void scic_sds_controller_power_control_timer_handler( 947static void scic_sds_controller_power_control_timer_handler(
1032 void *controller) 948 void *controller)
1033{ 949{
@@ -1146,8 +1062,6 @@ static bool scic_sds_controller_completion_queue_has_entries(
1146 return false; 1062 return false;
1147} 1063}
1148 1064
1149/* --------------------------------------------------------------------------- */
1150
1151/** 1065/**
1152 * This method processes a task completion notification. This is called from 1066 * This method processes a task completion notification. This is called from
1153 * within the controller completion handler. 1067 * within the controller completion handler.
@@ -1625,10 +1539,6 @@ void scic_sds_controller_error_handler(struct scic_sds_controller *scic)
1625} 1539}
1626 1540
1627 1541
1628u32 scic_sds_controller_get_object_size(void)
1629{
1630 return sizeof(struct scic_sds_controller);
1631}
1632 1542
1633 1543
1634void scic_sds_controller_link_up( 1544void scic_sds_controller_link_up(
@@ -1703,7 +1613,7 @@ void scic_sds_controller_remote_device_started(struct scic_sds_controller *scic,
1703 * controller are still in the stopping state. 1613 * controller are still in the stopping state.
1704 * 1614 *
1705 */ 1615 */
1706bool scic_sds_controller_has_remote_devices_stopping( 1616static bool scic_sds_controller_has_remote_devices_stopping(
1707 struct scic_sds_controller *this_controller) 1617 struct scic_sds_controller *this_controller)
1708{ 1618{
1709 u32 index; 1619 u32 index;
@@ -2042,62 +1952,20 @@ static void scic_sds_controller_set_default_config_parameters(struct scic_sds_co
2042 scic->user_parameters.sds1.no_outbound_task_timeout = 20; 1952 scic->user_parameters.sds1.no_outbound_task_timeout = 20;
2043} 1953}
2044 1954
2045 1955/**
2046enum sci_status scic_controller_construct(struct scic_sds_controller *controller, 1956 * scic_controller_initialize() - This method will initialize the controller
2047 void __iomem *scu_base, 1957 * hardware managed by the supplied core controller object. This method
2048 void __iomem *smu_base) 1958 * will bring the physical controller hardware out of reset and enable the
2049{ 1959 * core to determine the capabilities of the hardware being managed. Thus,
2050 u8 index; 1960 * the core controller can determine it's exact physical (DMA capable)
2051 1961 * memory requirements.
2052 sci_base_controller_construct( 1962 * @controller: This parameter specifies the controller to be initialized.
2053 &controller->parent, 1963 *
2054 scic_sds_controller_state_table, 1964 * The SCI Core user must have called scic_controller_construct() on the
2055 controller->memory_descriptors, 1965 * supplied controller object previously. Indicate if the controller was
2056 ARRAY_SIZE(controller->memory_descriptors), 1966 * successfully initialized or if it failed in some way. SCI_SUCCESS This value
2057 NULL 1967 * is returned if the controller hardware was successfully initialized.
2058 ); 1968 */
2059
2060 controller->scu_registers = scu_base;
2061 controller->smu_registers = smu_base;
2062
2063 scic_sds_port_configuration_agent_construct(&controller->port_agent);
2064
2065 /* Construct the ports for this controller */
2066 for (index = 0; index < SCI_MAX_PORTS; index++)
2067 scic_sds_port_construct(&controller->port_table[index],
2068 index, controller);
2069 scic_sds_port_construct(&controller->port_table[index],
2070 SCIC_SDS_DUMMY_PORT, controller);
2071
2072 /* Construct the phys for this controller */
2073 for (index = 0; index < SCI_MAX_PHYS; index++) {
2074 /* Add all the PHYs to the dummy port */
2075 scic_sds_phy_construct(
2076 &controller->phy_table[index],
2077 &controller->port_table[SCI_MAX_PORTS],
2078 index
2079 );
2080 }
2081
2082 controller->invalid_phy_mask = 0;
2083
2084 /* Set the default maximum values */
2085 controller->completion_event_entries = SCU_EVENT_COUNT;
2086 controller->completion_queue_entries = SCU_COMPLETION_QUEUE_COUNT;
2087 controller->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
2088 controller->logical_port_entries = SCI_MAX_PORTS;
2089 controller->task_context_entries = SCU_IO_REQUEST_COUNT;
2090 controller->uf_control.buffers.count = SCU_UNSOLICITED_FRAME_COUNT;
2091 controller->uf_control.address_table.count = SCU_UNSOLICITED_FRAME_COUNT;
2092
2093 /* Initialize the User and OEM parameters to default values. */
2094 scic_sds_controller_set_default_config_parameters(controller);
2095
2096 return scic_controller_reset(controller);
2097}
2098
2099/* --------------------------------------------------------------------------- */
2100
2101enum sci_status scic_controller_initialize( 1969enum sci_status scic_controller_initialize(
2102 struct scic_sds_controller *scic) 1970 struct scic_sds_controller *scic)
2103{ 1971{
@@ -2118,8 +1986,18 @@ enum sci_status scic_controller_initialize(
2118 return status; 1986 return status;
2119} 1987}
2120 1988
2121/* --------------------------------------------------------------------------- */ 1989/**
2122 1990 * scic_controller_get_suggested_start_timeout() - This method returns the
1991 * suggested scic_controller_start() timeout amount. The user is free to
1992 * use any timeout value, but this method provides the suggested minimum
1993 * start timeout value. The returned value is based upon empirical
1994 * information determined as a result of interoperability testing.
1995 * @controller: the handle to the controller object for which to return the
1996 * suggested start timeout.
1997 *
1998 * This method returns the number of milliseconds for the suggested start
1999 * operation timeout.
2000 */
2123u32 scic_controller_get_suggested_start_timeout( 2001u32 scic_controller_get_suggested_start_timeout(
2124 struct scic_sds_controller *sc) 2002 struct scic_sds_controller *sc)
2125{ 2003{
@@ -2146,8 +2024,28 @@ u32 scic_controller_get_suggested_start_timeout(
2146 + ((SCI_MAX_PHYS - 1) * SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL); 2024 + ((SCI_MAX_PHYS - 1) * SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL);
2147} 2025}
2148 2026
2149/* --------------------------------------------------------------------------- */ 2027/**
2150 2028 * scic_controller_start() - This method will start the supplied core
2029 * controller. This method will start the staggered spin up operation. The
2030 * SCI User completion callback is called when the following conditions are
2031 * met: -# the return status of this method is SCI_SUCCESS. -# after all of
2032 * the phys have successfully started or been given the opportunity to start.
2033 * @controller: the handle to the controller object to start.
2034 * @timeout: This parameter specifies the number of milliseconds in which the
2035 * start operation should complete.
2036 *
2037 * The SCI Core user must have filled in the physical memory descriptor
2038 * structure via the sci_controller_get_memory_descriptor_list() method. The
2039 * SCI Core user must have invoked the scic_controller_initialize() method
2040 * prior to invoking this method. The controller must be in the INITIALIZED or
2041 * STARTED state. Indicate if the controller start method succeeded or failed
2042 * in some way. SCI_SUCCESS if the start operation succeeded.
2043 * SCI_WARNING_ALREADY_IN_STATE if the controller is already in the STARTED
2044 * state. SCI_FAILURE_INVALID_STATE if the controller is not either in the
2045 * INITIALIZED or STARTED states. SCI_FAILURE_INVALID_MEMORY_DESCRIPTOR if
2046 * there are inconsistent or invalid values in the supplied
2047 * struct sci_physical_memory_descriptor array.
2048 */
2151enum sci_status scic_controller_start( 2049enum sci_status scic_controller_start(
2152 struct scic_sds_controller *scic, 2050 struct scic_sds_controller *scic,
2153 u32 timeout) 2051 u32 timeout)
@@ -2169,8 +2067,24 @@ enum sci_status scic_controller_start(
2169 return status; 2067 return status;
2170} 2068}
2171 2069
2172/* --------------------------------------------------------------------------- */ 2070/**
2173 2071 * scic_controller_stop() - This method will stop an individual controller
2072 * object.This method will invoke the associated user callback upon
2073 * completion. The completion callback is called when the following
2074 * conditions are met: -# the method return status is SCI_SUCCESS. -# the
2075 * controller has been quiesced. This method will ensure that all IO
2076 * requests are quiesced, phys are stopped, and all additional operation by
2077 * the hardware is halted.
2078 * @controller: the handle to the controller object to stop.
2079 * @timeout: This parameter specifies the number of milliseconds in which the
2080 * stop operation should complete.
2081 *
2082 * The controller must be in the STARTED or STOPPED state. Indicate if the
2083 * controller stop method succeeded or failed in some way. SCI_SUCCESS if the
2084 * stop operation successfully began. SCI_WARNING_ALREADY_IN_STATE if the
2085 * controller is already in the STOPPED state. SCI_FAILURE_INVALID_STATE if the
2086 * controller is not either in the STARTED or STOPPED states.
2087 */
2174enum sci_status scic_controller_stop( 2088enum sci_status scic_controller_stop(
2175 struct scic_sds_controller *scic, 2089 struct scic_sds_controller *scic,
2176 u32 timeout) 2090 u32 timeout)
@@ -2192,8 +2106,18 @@ enum sci_status scic_controller_stop(
2192 return status; 2106 return status;
2193} 2107}
2194 2108
2195/* --------------------------------------------------------------------------- */ 2109/**
2196 2110 * scic_controller_reset() - This method will reset the supplied core
2111 * controller regardless of the state of said controller. This operation is
2112 * considered destructive. In other words, all current operations are wiped
2113 * out. No IO completions for outstanding devices occur. Outstanding IO
2114 * requests are not aborted or completed at the actual remote device.
2115 * @controller: the handle to the controller object to reset.
2116 *
2117 * Indicate if the controller reset method succeeded or failed in some way.
2118 * SCI_SUCCESS if the reset operation successfully started. SCI_FATAL_ERROR if
2119 * the controller reset operation is unable to complete.
2120 */
2197enum sci_status scic_controller_reset( 2121enum sci_status scic_controller_reset(
2198 struct scic_sds_controller *scic) 2122 struct scic_sds_controller *scic)
2199{ 2123{
@@ -2214,6 +2138,33 @@ enum sci_status scic_controller_reset(
2214 return status; 2138 return status;
2215} 2139}
2216 2140
2141/**
2142 * scic_controller_start_io() - This method is called by the SCI user to
2143 * send/start an IO request. If the method invocation is successful, then
2144 * the IO request has been queued to the hardware for processing.
2145 * @controller: the handle to the controller object for which to start an IO
2146 * request.
2147 * @remote_device: the handle to the remote device object for which to start an
2148 * IO request.
2149 * @io_request: the handle to the io request object to start.
2150 * @io_tag: This parameter specifies a previously allocated IO tag that the
2151 * user desires to be utilized for this request. This parameter is optional.
2152 * The user is allowed to supply SCI_CONTROLLER_INVALID_IO_TAG as the value
2153 * for this parameter.
2154 *
2155 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
2156 * to ensure that each of the methods that may allocate or free available IO
2157 * tags are handled in a mutually exclusive manner. This method is one of said
2158 * methods requiring proper critical code section protection (e.g. semaphore,
2159 * spin-lock, etc.). - For SATA, the user is required to manage NCQ tags. As a
2160 * result, it is expected the user will have set the NCQ tag field in the host
2161 * to device register FIS prior to calling this method. There is also a
2162 * requirement for the user to call scic_stp_io_set_ncq_tag() prior to invoking
2163 * the scic_controller_start_io() method. scic_controller_allocate_tag() for
2164 * more information on allocating a tag. Indicate if the controller
2165 * successfully started the IO request. SCI_IO_SUCCESS if the IO request was
2166 * successfully started. Determine the failure situations and return values.
2167 */
2217enum sci_io_status scic_controller_start_io( 2168enum sci_io_status scic_controller_start_io(
2218 struct scic_sds_controller *scic, 2169 struct scic_sds_controller *scic,
2219 struct scic_sds_remote_device *remote_device, 2170 struct scic_sds_remote_device *remote_device,
@@ -2231,8 +2182,22 @@ enum sci_io_status scic_controller_start_io(
2231 (struct sci_base_request *)io_request, io_tag); 2182 (struct sci_base_request *)io_request, io_tag);
2232} 2183}
2233 2184
2234/* --------------------------------------------------------------------------- */ 2185/**
2235 2186 * scic_controller_terminate_request() - This method is called by the SCI Core
2187 * user to terminate an ongoing (i.e. started) core IO request. This does
2188 * not abort the IO request at the target, but rather removes the IO request
2189 * from the host controller.
2190 * @controller: the handle to the controller object for which to terminate a
2191 * request.
2192 * @remote_device: the handle to the remote device object for which to
2193 * terminate a request.
2194 * @request: the handle to the io or task management request object to
2195 * terminate.
2196 *
2197 * Indicate if the controller successfully began the terminate process for the
2198 * IO request. SCI_SUCCESS if the terminate process was successfully started
2199 * for the request. Determine the failure situations and return values.
2200 */
2236enum sci_status scic_controller_terminate_request( 2201enum sci_status scic_controller_terminate_request(
2237 struct scic_sds_controller *scic, 2202 struct scic_sds_controller *scic,
2238 struct scic_sds_remote_device *remote_device, 2203 struct scic_sds_remote_device *remote_device,
@@ -2249,8 +2214,28 @@ enum sci_status scic_controller_terminate_request(
2249 (struct sci_base_request *)request); 2214 (struct sci_base_request *)request);
2250} 2215}
2251 2216
2252/* --------------------------------------------------------------------------- */ 2217/**
2253 2218 * scic_controller_complete_io() - This method will perform core specific
2219 * completion operations for an IO request. After this method is invoked,
2220 * the user should consider the IO request as invalid until it is properly
2221 * reused (i.e. re-constructed).
2222 * @controller: The handle to the controller object for which to complete the
2223 * IO request.
2224 * @remote_device: The handle to the remote device object for which to complete
2225 * the IO request.
2226 * @io_request: the handle to the io request object to complete.
2227 *
2228 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
2229 * to ensure that each of the methods that may allocate or free available IO
2230 * tags are handled in a mutually exclusive manner. This method is one of said
2231 * methods requiring proper critical code section protection (e.g. semaphore,
2232 * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
2233 * Core user, using the scic_controller_allocate_io_tag() method, then it is
2234 * the responsibility of the caller to invoke the scic_controller_free_io_tag()
2235 * method to free the tag (i.e. this method will not free the IO tag). Indicate
2236 * if the controller successfully completed the IO request. SCI_SUCCESS if the
2237 * completion process was successful.
2238 */
2254enum sci_status scic_controller_complete_io( 2239enum sci_status scic_controller_complete_io(
2255 struct scic_sds_controller *scic, 2240 struct scic_sds_controller *scic,
2256 struct scic_sds_remote_device *remote_device, 2241 struct scic_sds_remote_device *remote_device,
@@ -2267,9 +2252,34 @@ enum sci_status scic_controller_complete_io(
2267 (struct sci_base_request *)io_request); 2252 (struct sci_base_request *)io_request);
2268} 2253}
2269 2254
2270/* --------------------------------------------------------------------------- */ 2255/**
2271 2256 * scic_controller_start_task() - This method is called by the SCIC user to
2272 2257 * send/start a framework task management request.
2258 * @controller: the handle to the controller object for which to start the task
2259 * management request.
2260 * @remote_device: the handle to the remote device object for which to start
2261 * the task management request.
2262 * @task_request: the handle to the task request object to start.
2263 * @io_tag: This parameter specifies a previously allocated IO tag that the
2264 * user desires to be utilized for this request. Note this not the io_tag
2265 * of the request being managed. It is to be utilized for the task request
2266 * itself. This parameter is optional. The user is allowed to supply
2267 * SCI_CONTROLLER_INVALID_IO_TAG as the value for this parameter.
2268 *
2269 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
2270 * to ensure that each of the methods that may allocate or free available IO
2271 * tags are handled in a mutually exclusive manner. This method is one of said
2272 * methods requiring proper critical code section protection (e.g. semaphore,
2273 * spin-lock, etc.). - The user must synchronize this task with completion
2274 * queue processing. If they are not synchronized then it is possible for the
2275 * io requests that are being managed by the task request can complete before
2276 * starting the task request. scic_controller_allocate_tag() for more
2277 * information on allocating a tag. Indicate if the controller successfully
2278 * started the IO request. SCI_TASK_SUCCESS if the task request was
2279 * successfully started. SCI_TASK_FAILURE_REQUIRES_SCSI_ABORT This value is
2280 * returned if there is/are task(s) outstanding that require termination or
2281 * completion before this request can succeed.
2282 */
2273enum sci_task_status scic_controller_start_task( 2283enum sci_task_status scic_controller_start_task(
2274 struct scic_sds_controller *scic, 2284 struct scic_sds_controller *scic,
2275 struct scic_sds_remote_device *remote_device, 2285 struct scic_sds_remote_device *remote_device,
@@ -2297,8 +2307,20 @@ enum sci_task_status scic_controller_start_task(
2297 return status; 2307 return status;
2298} 2308}
2299 2309
2300/* --------------------------------------------------------------------------- */ 2310/**
2301 2311 * scic_controller_complete_task() - This method will perform core specific
2312 * completion operations for task management request. After this method is
2313 * invoked, the user should consider the task request as invalid until it is
2314 * properly reused (i.e. re-constructed).
2315 * @controller: The handle to the controller object for which to complete the
2316 * task management request.
2317 * @remote_device: The handle to the remote device object for which to complete
2318 * the task management request.
2319 * @task_request: the handle to the task management request object to complete.
2320 *
2321 * Indicate if the controller successfully completed the task management
2322 * request. SCI_SUCCESS if the completion process was successful.
2323 */
2302enum sci_status scic_controller_complete_task( 2324enum sci_status scic_controller_complete_task(
2303 struct scic_sds_controller *scic, 2325 struct scic_sds_controller *scic,
2304 struct scic_sds_remote_device *remote_device, 2326 struct scic_sds_remote_device *remote_device,
@@ -2325,8 +2347,22 @@ enum sci_status scic_controller_complete_task(
2325} 2347}
2326 2348
2327 2349
2328/* --------------------------------------------------------------------------- */ 2350/**
2329 2351 * scic_controller_get_port_handle() - This method simply provides the user
2352 * with a unique handle for a given SAS/SATA core port index.
2353 * @controller: This parameter represents the handle to the controller object
2354 * from which to retrieve a port (SAS or SATA) handle.
2355 * @port_index: This parameter specifies the port index in the controller for
2356 * which to retrieve the port handle. 0 <= port_index < maximum number of
2357 * phys.
2358 * @port_handle: This parameter specifies the retrieved port handle to be
2359 * provided to the caller.
2360 *
2361 * Indicate if the retrieval of the port handle was successful. SCI_SUCCESS
2362 * This value is returned if the retrieval was successful.
2363 * SCI_FAILURE_INVALID_PORT This value is returned if the supplied port id is
2364 * not in the supported range.
2365 */
2330enum sci_status scic_controller_get_port_handle( 2366enum sci_status scic_controller_get_port_handle(
2331 struct scic_sds_controller *scic, 2367 struct scic_sds_controller *scic,
2332 u8 port_index, 2368 u8 port_index,
@@ -2341,8 +2377,20 @@ enum sci_status scic_controller_get_port_handle(
2341 return SCI_FAILURE_INVALID_PORT; 2377 return SCI_FAILURE_INVALID_PORT;
2342} 2378}
2343 2379
2344/* --------------------------------------------------------------------------- */ 2380/**
2345 2381 * scic_controller_get_phy_handle() - This method simply provides the user with
2382 * a unique handle for a given SAS/SATA phy index/identifier.
2383 * @controller: This parameter represents the handle to the controller object
2384 * from which to retrieve a phy (SAS or SATA) handle.
2385 * @phy_index: This parameter specifies the phy index in the controller for
2386 * which to retrieve the phy handle. 0 <= phy_index < maximum number of phys.
2387 * @phy_handle: This parameter specifies the retrieved phy handle to be
2388 * provided to the caller.
2389 *
2390 * Indicate if the retrieval of the phy handle was successful. SCI_SUCCESS This
2391 * value is returned if the retrieval was successful. SCI_FAILURE_INVALID_PHY
2392 * This value is returned if the supplied phy id is not in the supported range.
2393 */
2346enum sci_status scic_controller_get_phy_handle( 2394enum sci_status scic_controller_get_phy_handle(
2347 struct scic_sds_controller *scic, 2395 struct scic_sds_controller *scic,
2348 u8 phy_index, 2396 u8 phy_index,
@@ -2361,8 +2409,28 @@ enum sci_status scic_controller_get_phy_handle(
2361 return SCI_FAILURE_INVALID_PHY; 2409 return SCI_FAILURE_INVALID_PHY;
2362} 2410}
2363 2411
2364/* --------------------------------------------------------------------------- */ 2412/**
2365 2413 * scic_controller_allocate_io_tag() - This method will allocate a tag from the
2414 * pool of free IO tags. Direct allocation of IO tags by the SCI Core user
2415 * is optional. The scic_controller_start_io() method will allocate an IO
2416 * tag if this method is not utilized and the tag is not supplied to the IO
2417 * construct routine. Direct allocation of IO tags may provide additional
2418 * performance improvements in environments capable of supporting this usage
2419 * model. Additionally, direct allocation of IO tags also provides
2420 * additional flexibility to the SCI Core user. Specifically, the user may
2421 * retain IO tags across the lives of multiple IO requests.
2422 * @controller: the handle to the controller object for which to allocate the
2423 * tag.
2424 *
2425 * IO tags are a protected resource. It is incumbent upon the SCI Core user to
2426 * ensure that each of the methods that may allocate or free available IO tags
2427 * are handled in a mutually exclusive manner. This method is one of said
2428 * methods requiring proper critical code section protection (e.g. semaphore,
2429 * spin-lock, etc.). An unsigned integer representing an available IO tag.
2430 * SCI_CONTROLLER_INVALID_IO_TAG This value is returned if there are no
2431 * currently available tags to be allocated. All return other values indicate a
2432 * legitimate tag.
2433 */
2366u16 scic_controller_allocate_io_tag( 2434u16 scic_controller_allocate_io_tag(
2367 struct scic_sds_controller *scic) 2435 struct scic_sds_controller *scic)
2368{ 2436{
@@ -2380,8 +2448,31 @@ u16 scic_controller_allocate_io_tag(
2380 return SCI_CONTROLLER_INVALID_IO_TAG; 2448 return SCI_CONTROLLER_INVALID_IO_TAG;
2381} 2449}
2382 2450
2383/* --------------------------------------------------------------------------- */ 2451/**
2384 2452 * scic_controller_free_io_tag() - This method will free an IO tag to the pool
2453 * of free IO tags. This method provides the SCI Core user more flexibility
2454 * with regards to IO tags. The user may desire to keep an IO tag after an
2455 * IO request has completed, because they plan on re-using the tag for a
2456 * subsequent IO request. This method is only legal if the tag was
2457 * allocated via scic_controller_allocate_io_tag().
2458 * @controller: This parameter specifies the handle to the controller object
2459 * for which to free/return the tag.
2460 * @io_tag: This parameter represents the tag to be freed to the pool of
2461 * available tags.
2462 *
2463 * - IO tags are a protected resource. It is incumbent upon the SCI Core user
2464 * to ensure that each of the methods that may allocate or free available IO
2465 * tags are handled in a mutually exclusive manner. This method is one of said
2466 * methods requiring proper critical code section protection (e.g. semaphore,
2467 * spin-lock, etc.). - If the IO tag for a request was allocated, by the SCI
2468 * Core user, using the scic_controller_allocate_io_tag() method, then it is
2469 * the responsibility of the caller to invoke this method to free the tag. This
2470 * method returns an indication of whether the tag was successfully put back
2471 * (freed) to the pool of available tags. SCI_SUCCESS This return value
2472 * indicates the tag was successfully placed into the pool of available IO
2473 * tags. SCI_FAILURE_INVALID_IO_TAG This value is returned if the supplied tag
2474 * is not a valid IO tag value.
2475 */
2385enum sci_status scic_controller_free_io_tag( 2476enum sci_status scic_controller_free_io_tag(
2386 struct scic_sds_controller *scic, 2477 struct scic_sds_controller *scic,
2387 u16 io_tag) 2478 u16 io_tag)
@@ -2408,8 +2499,6 @@ enum sci_status scic_controller_free_io_tag(
2408 return SCI_FAILURE_INVALID_IO_TAG; 2499 return SCI_FAILURE_INVALID_IO_TAG;
2409} 2500}
2410 2501
2411/* --------------------------------------------------------------------------- */
2412
2413void scic_controller_enable_interrupts( 2502void scic_controller_enable_interrupts(
2414 struct scic_sds_controller *scic) 2503 struct scic_sds_controller *scic)
2415{ 2504{
@@ -2417,8 +2506,6 @@ void scic_controller_enable_interrupts(
2417 SMU_IMR_WRITE(scic, 0x00000000); 2506 SMU_IMR_WRITE(scic, 0x00000000);
2418} 2507}
2419 2508
2420/* --------------------------------------------------------------------------- */
2421
2422void scic_controller_disable_interrupts( 2509void scic_controller_disable_interrupts(
2423 struct scic_sds_controller *scic) 2510 struct scic_sds_controller *scic)
2424{ 2511{
@@ -2426,9 +2513,7 @@ void scic_controller_disable_interrupts(
2426 SMU_IMR_WRITE(scic, 0xffffffff); 2513 SMU_IMR_WRITE(scic, 0xffffffff);
2427} 2514}
2428 2515
2429/* --------------------------------------------------------------------------- */ 2516static enum sci_status scic_controller_set_mode(
2430
2431enum sci_status scic_controller_set_mode(
2432 struct scic_sds_controller *scic, 2517 struct scic_sds_controller *scic,
2433 enum sci_controller_mode operating_mode) 2518 enum sci_controller_mode operating_mode)
2434{ 2519{
@@ -2476,7 +2561,7 @@ enum sci_status scic_controller_set_mode(
2476 * 2561 *
2477 * This method will reset the controller hardware. 2562 * This method will reset the controller hardware.
2478 */ 2563 */
2479void scic_sds_controller_reset_hardware( 2564static void scic_sds_controller_reset_hardware(
2480 struct scic_sds_controller *scic) 2565 struct scic_sds_controller *scic)
2481{ 2566{
2482 /* Disable interrupts so we dont take any spurious interrupts */ 2567 /* Disable interrupts so we dont take any spurious interrupts */
@@ -2495,8 +2580,6 @@ void scic_sds_controller_reset_hardware(
2495 SCU_UFQGP_WRITE(scic, 0x00000000); 2580 SCU_UFQGP_WRITE(scic, 0x00000000);
2496} 2581}
2497 2582
2498/* --------------------------------------------------------------------------- */
2499
2500enum sci_status scic_user_parameters_set( 2583enum sci_status scic_user_parameters_set(
2501 struct scic_sds_controller *scic, 2584 struct scic_sds_controller *scic,
2502 union scic_user_parameters *scic_parms) 2585 union scic_user_parameters *scic_parms)
@@ -2551,17 +2634,6 @@ enum sci_status scic_user_parameters_set(
2551 return SCI_FAILURE_INVALID_STATE; 2634 return SCI_FAILURE_INVALID_STATE;
2552} 2635}
2553 2636
2554/* --------------------------------------------------------------------------- */
2555
2556void scic_user_parameters_get(
2557 struct scic_sds_controller *scic,
2558 union scic_user_parameters *scic_parms)
2559{
2560 memcpy(scic_parms, (&scic->user_parameters), sizeof(*scic_parms));
2561}
2562
2563/* --------------------------------------------------------------------------- */
2564
2565enum sci_status scic_oem_parameters_set( 2637enum sci_status scic_oem_parameters_set(
2566 struct scic_sds_controller *scic, 2638 struct scic_sds_controller *scic,
2567 union scic_oem_parameters *scic_parms) 2639 union scic_oem_parameters *scic_parms)
@@ -2616,8 +2688,6 @@ enum sci_status scic_oem_parameters_set(
2616 return SCI_FAILURE_INVALID_STATE; 2688 return SCI_FAILURE_INVALID_STATE;
2617} 2689}
2618 2690
2619/* --------------------------------------------------------------------------- */
2620
2621void scic_oem_parameters_get( 2691void scic_oem_parameters_get(
2622 struct scic_sds_controller *scic, 2692 struct scic_sds_controller *scic,
2623 union scic_oem_parameters *scic_parms) 2693 union scic_oem_parameters *scic_parms)
@@ -2625,9 +2695,6 @@ void scic_oem_parameters_get(
2625 memcpy(scic_parms, (&scic->oem_parameters), sizeof(*scic_parms)); 2695 memcpy(scic_parms, (&scic->oem_parameters), sizeof(*scic_parms));
2626} 2696}
2627 2697
2628/* --------------------------------------------------------------------------- */
2629
2630
2631#define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS 853 2698#define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS 853
2632#define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS 1280 2699#define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS 1280
2633#define INTERRUPT_COALESCE_TIMEOUT_MAX_US 2700000 2700#define INTERRUPT_COALESCE_TIMEOUT_MAX_US 2700000
@@ -2635,7 +2702,24 @@ void scic_oem_parameters_get(
2635#define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN 7 2702#define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN 7
2636#define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX 28 2703#define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX 28
2637 2704
2638enum sci_status scic_controller_set_interrupt_coalescence( 2705/**
2706 * scic_controller_set_interrupt_coalescence() - This method allows the user to
2707 * configure the interrupt coalescence.
2708 * @controller: This parameter represents the handle to the controller object
2709 * for which its interrupt coalesce register is overridden.
2710 * @coalesce_number: Used to control the number of entries in the Completion
2711 * Queue before an interrupt is generated. If the number of entries exceed
2712 * this number, an interrupt will be generated. The valid range of the input
2713 * is [0, 256]. A setting of 0 results in coalescing being disabled.
2714 * @coalesce_timeout: Timeout value in microseconds. The valid range of the
2715 * input is [0, 2700000] . A setting of 0 is allowed and results in no
2716 * interrupt coalescing timeout.
2717 *
2718 * Indicate if the user successfully set the interrupt coalesce parameters.
2719 * SCI_SUCCESS The user successfully updated the interrutp coalescence.
2720 * SCI_FAILURE_INVALID_PARAMETER_VALUE The user input value is out of range.
2721 */
2722static enum sci_status scic_controller_set_interrupt_coalescence(
2639 struct scic_sds_controller *scic_controller, 2723 struct scic_sds_controller *scic_controller,
2640 u32 coalesce_number, 2724 u32 coalesce_number,
2641 u32 coalesce_timeout) 2725 u32 coalesce_timeout)
@@ -3419,7 +3503,7 @@ static enum sci_status scic_sds_controller_stopping_state_complete_io_handler(
3419 * This method is called when the struct scic_sds_controller is in a stopping state 3503 * This method is called when the struct scic_sds_controller is in a stopping state
3420 * and the remote device has stopped. 3504 * and the remote device has stopped.
3421 **/ 3505 **/
3422void scic_sds_controller_stopping_state_device_stopped_handler( 3506static void scic_sds_controller_stopping_state_device_stopped_handler(
3423 struct scic_sds_controller *controller, 3507 struct scic_sds_controller *controller,
3424 struct scic_sds_remote_device *remote_device 3508 struct scic_sds_remote_device *remote_device
3425) 3509)
@@ -3638,7 +3722,7 @@ static void scic_sds_controller_resetting_state_enter(struct sci_base_object *ob
3638 SCI_BASE_CONTROLLER_STATE_RESET); 3722 SCI_BASE_CONTROLLER_STATE_RESET);
3639} 3723}
3640 3724
3641const struct sci_base_state scic_sds_controller_state_table[] = { 3725static const struct sci_base_state scic_sds_controller_state_table[] = {
3642 [SCI_BASE_CONTROLLER_STATE_INITIAL] = { 3726 [SCI_BASE_CONTROLLER_STATE_INITIAL] = {
3643 .enter_state = scic_sds_controller_initial_state_enter, 3727 .enter_state = scic_sds_controller_initial_state_enter,
3644 }, 3728 },
@@ -3662,3 +3746,64 @@ const struct sci_base_state scic_sds_controller_state_table[] = {
3662 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {}, 3746 [SCI_BASE_CONTROLLER_STATE_STOPPED] = {},
3663 [SCI_BASE_CONTROLLER_STATE_FAILED] = {} 3747 [SCI_BASE_CONTROLLER_STATE_FAILED] = {}
3664}; 3748};
3749
3750/**
3751 * scic_controller_construct() - This method will attempt to construct a
3752 * controller object utilizing the supplied parameter information.
3753 * @c: This parameter specifies the controller to be constructed.
3754 * @scu_base: mapped base address of the scu registers
3755 * @smu_base: mapped base address of the smu registers
3756 *
3757 * Indicate if the controller was successfully constructed or if it failed in
3758 * some way. SCI_SUCCESS This value is returned if the controller was
3759 * successfully constructed. SCI_WARNING_TIMER_CONFLICT This value is returned
3760 * if the interrupt coalescence timer may cause SAS compliance issues for SMP
3761 * Target mode response processing. SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE
3762 * This value is returned if the controller does not support the supplied type.
3763 * SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION This value is returned if the
3764 * controller does not support the supplied initialization data version.
3765 */
3766enum sci_status scic_controller_construct(struct scic_sds_controller *scic,
3767 void __iomem *scu_base,
3768 void __iomem *smu_base)
3769{
3770 u8 i;
3771
3772 sci_base_controller_construct(&scic->parent,
3773 scic_sds_controller_state_table,
3774 scic->memory_descriptors,
3775 ARRAY_SIZE(scic->memory_descriptors), NULL);
3776
3777 scic->scu_registers = scu_base;
3778 scic->smu_registers = smu_base;
3779
3780 scic_sds_port_configuration_agent_construct(&scic->port_agent);
3781
3782 /* Construct the ports for this controller */
3783 for (i = 0; i < SCI_MAX_PORTS; i++)
3784 scic_sds_port_construct(&scic->port_table[i], i, scic);
3785 scic_sds_port_construct(&scic->port_table[i], SCIC_SDS_DUMMY_PORT, scic);
3786
3787 /* Construct the phys for this controller */
3788 for (i = 0; i < SCI_MAX_PHYS; i++) {
3789 /* Add all the PHYs to the dummy port */
3790 scic_sds_phy_construct(&scic->phy_table[i],
3791 &scic->port_table[SCI_MAX_PORTS], i);
3792 }
3793
3794 scic->invalid_phy_mask = 0;
3795
3796 /* Set the default maximum values */
3797 scic->completion_event_entries = SCU_EVENT_COUNT;
3798 scic->completion_queue_entries = SCU_COMPLETION_QUEUE_COUNT;
3799 scic->remote_node_entries = SCI_MAX_REMOTE_DEVICES;
3800 scic->logical_port_entries = SCI_MAX_PORTS;
3801 scic->task_context_entries = SCU_IO_REQUEST_COUNT;
3802 scic->uf_control.buffers.count = SCU_UNSOLICITED_FRAME_COUNT;
3803 scic->uf_control.address_table.count = SCU_UNSOLICITED_FRAME_COUNT;
3804
3805 /* Initialize the User and OEM parameters to default values. */
3806 scic_sds_controller_set_default_config_parameters(scic);
3807
3808 return scic_controller_reset(scic);
3809}
diff --git a/drivers/scsi/isci/core/scic_sds_controller.h b/drivers/scsi/isci/core/scic_sds_controller.h
index aa2698bb7ca1..fedf5032d898 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.h
+++ b/drivers/scsi/isci/core/scic_sds_controller.h
@@ -402,7 +402,6 @@ struct scic_sds_controller_state_handler {
402 402
403extern const struct scic_sds_controller_state_handler 403extern const struct scic_sds_controller_state_handler
404 scic_sds_controller_state_handler_table[]; 404 scic_sds_controller_state_handler_table[];
405extern const struct sci_base_state scic_sds_controller_state_table[];
406 405
407/** 406/**
408 * INCREMENT_QUEUE_GET() - 407 * INCREMENT_QUEUE_GET() -
@@ -535,7 +534,6 @@ extern const struct sci_base_state scic_sds_controller_state_table[];
535 534
536/* --------------------------------------------------------------------------- */ 535/* --------------------------------------------------------------------------- */
537 536
538u32 scic_sds_controller_get_object_size(void);
539 537
540/* --------------------------------------------------------------------------- */ 538/* --------------------------------------------------------------------------- */
541 539
@@ -615,8 +613,6 @@ void scic_sds_controller_link_down(
615 * * CORE CONTROLLER REMOTE DEVICE MESSAGE PROCESSING 613 * * CORE CONTROLLER REMOTE DEVICE MESSAGE PROCESSING
616 * ***************************************************************************** */ 614 * ***************************************************************************** */
617 615
618bool scic_sds_controller_has_remote_devices_stopping(
619 struct scic_sds_controller *this_controller);
620 616
621void scic_sds_controller_remote_device_started( 617void scic_sds_controller_remote_device_started(
622 struct scic_sds_controller *this_controller, 618 struct scic_sds_controller *this_controller,
@@ -626,67 +622,11 @@ void scic_sds_controller_remote_device_stopped(
626 struct scic_sds_controller *this_controller, 622 struct scic_sds_controller *this_controller,
627 struct scic_sds_remote_device *the_device); 623 struct scic_sds_remote_device *the_device);
628 624
629
630/*
631 * *****************************************************************************
632 * * CORE CONTROLLER PRIVATE METHODS
633 * ***************************************************************************** */
634
635enum sci_status scic_sds_controller_validate_memory_descriptor_table(
636 struct scic_sds_controller *this_controller);
637
638void scic_sds_controller_ram_initialization(
639 struct scic_sds_controller *this_controller);
640
641void scic_sds_controller_assign_task_entries(
642 struct scic_sds_controller *this_controller);
643
644void scic_sds_controller_afe_initialization(
645 struct scic_sds_controller *this_controller);
646
647void scic_sds_controller_enable_port_task_scheduler(
648 struct scic_sds_controller *this_controller);
649
650void scic_sds_controller_initialize_completion_queue(
651 struct scic_sds_controller *this_controller);
652
653void scic_sds_controller_initialize_unsolicited_frame_queue(
654 struct scic_sds_controller *this_controller);
655
656void scic_sds_controller_phy_timer_stop(
657 struct scic_sds_controller *this_controller);
658
659enum sci_status scic_sds_controller_start_next_phy(
660 struct scic_sds_controller *this_controller);
661
662enum sci_status scic_sds_controller_stop_phys(
663 struct scic_sds_controller *this_controller);
664
665enum sci_status scic_sds_controller_stop_ports(
666 struct scic_sds_controller *this_controller);
667
668enum sci_status scic_sds_controller_stop_devices(
669 struct scic_sds_controller *this_controller);
670
671void scic_sds_controller_copy_task_context( 625void scic_sds_controller_copy_task_context(
672 struct scic_sds_controller *this_controller, 626 struct scic_sds_controller *this_controller,
673 struct scic_sds_request *this_request); 627 struct scic_sds_request *this_request);
674 628
675void scic_sds_controller_timeout_handler(void *controller);
676
677void scic_sds_controller_initialize_power_control(
678 struct scic_sds_controller *this_controller);
679
680void scic_sds_controller_register_setup( 629void scic_sds_controller_register_setup(
681 struct scic_sds_controller *this_controller); 630 struct scic_sds_controller *this_controller);
682 631
683void scic_sds_controller_reset_hardware(
684 struct scic_sds_controller *this_controller);
685
686enum sci_status scic_sds_controller_initialize_phy_startup(
687 struct scic_sds_controller *this_controller);
688
689void scic_sds_controller_build_memory_descriptor_table(
690 struct scic_sds_controller *this_controller);
691
692#endif /* _SCIC_SDS_CONTROLLER_H_ */ 632#endif /* _SCIC_SDS_CONTROLLER_H_ */
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c
index e546e20f1ffd..532338eb302b 100644
--- a/drivers/scsi/isci/core/scic_sds_phy.c
+++ b/drivers/scsi/isci/core/scic_sds_phy.c
@@ -257,7 +257,7 @@ scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
257 * restart the starting substate machine since we dont know what has actually 257 * restart the starting substate machine since we dont know what has actually
258 * happening. 258 * happening.
259 */ 259 */
260void scic_sds_phy_sata_timeout(void *phy) 260static void scic_sds_phy_sata_timeout(void *phy)
261{ 261{
262 struct scic_sds_phy *sci_phy = phy; 262 struct scic_sds_phy *sci_phy = phy;
263 263
@@ -274,47 +274,6 @@ void scic_sds_phy_sata_timeout(void *phy)
274} 274}
275 275
276/** 276/**
277 * This method will construct the struct scic_sds_phy object
278 * @this_phy:
279 * @owning_port:
280 * @phy_index:
281 *
282 */
283void scic_sds_phy_construct(
284 struct scic_sds_phy *this_phy,
285 struct scic_sds_port *owning_port,
286 u8 phy_index)
287{
288 /*
289 * Call the base constructor first
290 */
291 sci_base_phy_construct(
292 &this_phy->parent,
293 scic_sds_phy_state_table
294 );
295
296 /* Copy the rest of the input data to our locals */
297 this_phy->owning_port = owning_port;
298 this_phy->phy_index = phy_index;
299 this_phy->bcn_received_while_port_unassigned = false;
300 this_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
301 this_phy->link_layer_registers = NULL;
302 this_phy->max_negotiated_speed = SCI_SAS_NO_LINK_RATE;
303 this_phy->sata_timeout_timer = NULL;
304
305 /* Clear out the identification buffer data */
306 memset(&this_phy->phy_type, 0, sizeof(this_phy->phy_type));
307
308 /* Initialize the the substate machines */
309 sci_base_state_machine_construct(
310 &this_phy->starting_substate_machine,
311 &this_phy->parent.parent,
312 scic_sds_phy_starting_substates,
313 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL
314 );
315}
316
317/**
318 * This method returns the port currently containing this phy. If the phy is 277 * This method returns the port currently containing this phy. If the phy is
319 * currently contained by the dummy port, then the phy is considered to not 278 * currently contained by the dummy port, then the phy is considered to not
320 * be part of a port. 279 * be part of a port.
@@ -426,7 +385,7 @@ void scic_sds_phy_setup_transport(
426 * This function will perform the register reads/writes to suspend the SCU 385 * This function will perform the register reads/writes to suspend the SCU
427 * hardware protocol engine. none 386 * hardware protocol engine. none
428 */ 387 */
429void scic_sds_phy_suspend( 388static void scic_sds_phy_suspend(
430 struct scic_sds_phy *this_phy) 389 struct scic_sds_phy *this_phy)
431{ 390{
432 u32 scu_sas_pcfg_value; 391 u32 scu_sas_pcfg_value;
@@ -1416,7 +1375,62 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_p
1416 return SCI_SUCCESS; 1375 return SCI_SUCCESS;
1417} 1376}
1418 1377
1419const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = { 1378static enum sci_status default_phy_handler(struct sci_base_phy *base_phy, const char *func)
1379{
1380 struct scic_sds_phy *sci_phy;
1381
1382 sci_phy = container_of(base_phy, typeof(*sci_phy), parent);
1383 dev_dbg(sciphy_to_dev(sci_phy),
1384 "%s: in wrong state: %d\n", func,
1385 sci_base_state_machine_get_state(&base_phy->state_machine));
1386 return SCI_FAILURE_INVALID_STATE;
1387}
1388
1389static enum sci_status scic_sds_phy_default_start_handler(struct sci_base_phy *base_phy)
1390{
1391 return default_phy_handler(base_phy, __func__);
1392}
1393
1394static enum sci_status scic_sds_phy_default_stop_handler(struct sci_base_phy *base_phy)
1395{
1396 return default_phy_handler(base_phy, __func__);
1397}
1398
1399static enum sci_status scic_sds_phy_default_reset_handler(struct sci_base_phy *base_phy)
1400{
1401 return default_phy_handler(base_phy, __func__);
1402}
1403
1404static enum sci_status scic_sds_phy_default_destroy_handler(struct sci_base_phy *base_phy)
1405{
1406 return default_phy_handler(base_phy, __func__);
1407}
1408
1409static enum sci_status scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy,
1410 u32 frame_index)
1411{
1412 struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
1413
1414 default_phy_handler(&sci_phy->parent, __func__);
1415 scic_sds_controller_release_frame(scic, frame_index);
1416
1417 return SCI_FAILURE_INVALID_STATE;
1418}
1419
1420static enum sci_status scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy,
1421 u32 event_code)
1422{
1423 return default_phy_handler(&sci_phy->parent, __func__);
1424}
1425
1426static enum sci_status scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy)
1427{
1428 return default_phy_handler(&sci_phy->parent, __func__);
1429}
1430
1431
1432
1433static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = {
1420 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { 1434 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
1421 .parent.start_handler = scic_sds_phy_default_start_handler, 1435 .parent.start_handler = scic_sds_phy_default_start_handler,
1422 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler, 1436 .parent.stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
@@ -1867,7 +1881,7 @@ static void scic_sds_phy_starting_final_substate_enter(struct sci_base_object *o
1867 1881
1868/* --------------------------------------------------------------------------- */ 1882/* --------------------------------------------------------------------------- */
1869 1883
1870const struct sci_base_state scic_sds_phy_starting_substates[] = { 1884static const struct sci_base_state scic_sds_phy_starting_substates[] = {
1871 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = { 1885 [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
1872 .enter_state = scic_sds_phy_starting_initial_substate_enter, 1886 .enter_state = scic_sds_phy_starting_initial_substate_enter,
1873 }, 1887 },
@@ -1905,196 +1919,6 @@ const struct sci_base_state scic_sds_phy_starting_substates[] = {
1905 } 1919 }
1906}; 1920};
1907 1921
1908/*
1909 * ***************************************************************************
1910 * * DEFAULT HANDLERS
1911 * *************************************************************************** */
1912
1913/**
1914 *
1915 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
1916 * object.
1917 *
1918 * This is the default method for phy a start request. It will report a
1919 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1920 */
1921enum sci_status scic_sds_phy_default_start_handler(
1922 struct sci_base_phy *phy)
1923{
1924 struct scic_sds_phy *this_phy;
1925
1926 this_phy = (struct scic_sds_phy *)phy;
1927
1928 dev_warn(sciphy_to_dev(this_phy),
1929 "%s: SCIC Phy 0x%p requested to start from invalid "
1930 "state %d\n",
1931 __func__,
1932 this_phy,
1933 sci_base_state_machine_get_state(
1934 &this_phy->parent.state_machine));
1935
1936 return SCI_FAILURE_INVALID_STATE;
1937
1938}
1939
1940/**
1941 *
1942 * @phy: This is the struct sci_base_phy object which is cast into a
1943 * struct scic_sds_phy object.
1944 *
1945 * This is the default method for phy a stop request. It will report a warning
1946 * and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1947 */
1948enum sci_status scic_sds_phy_default_stop_handler(struct sci_base_phy *base_phy)
1949{
1950 struct scic_sds_phy *sci_phy;
1951
1952 sci_phy = (struct scic_sds_phy *)base_phy;
1953
1954 dev_dbg(sciphy_to_dev(sci_phy),
1955 "%s: SCIC Phy 0x%p requested to stop from invalid state %d\n",
1956 __func__,
1957 sci_phy,
1958 sci_base_state_machine_get_state(
1959 &sci_phy->parent.state_machine));
1960
1961 return SCI_FAILURE_INVALID_STATE;
1962}
1963
1964/**
1965 *
1966 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
1967 * object.
1968 *
1969 * This is the default method for phy a reset request. It will report a
1970 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1971 */
1972enum sci_status scic_sds_phy_default_reset_handler(
1973 struct sci_base_phy *phy)
1974{
1975 struct scic_sds_phy *this_phy;
1976
1977 this_phy = (struct scic_sds_phy *)phy;
1978
1979 dev_warn(sciphy_to_dev(this_phy),
1980 "%s: SCIC Phy 0x%p requested to reset from invalid state "
1981 "%d\n",
1982 __func__,
1983 this_phy,
1984 sci_base_state_machine_get_state(
1985 &this_phy->parent.state_machine));
1986
1987 return SCI_FAILURE_INVALID_STATE;
1988}
1989
1990/**
1991 *
1992 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
1993 * object.
1994 *
1995 * This is the default method for phy a destruct request. It will report a
1996 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
1997 */
1998enum sci_status scic_sds_phy_default_destroy_handler(
1999 struct sci_base_phy *phy)
2000{
2001 struct scic_sds_phy *this_phy;
2002
2003 this_phy = (struct scic_sds_phy *)phy;
2004
2005 /* / @todo Implement something for the default */
2006 dev_warn(sciphy_to_dev(this_phy),
2007 "%s: SCIC Phy 0x%p requested to destroy from invalid "
2008 "state %d\n",
2009 __func__,
2010 this_phy,
2011 sci_base_state_machine_get_state(
2012 &this_phy->parent.state_machine));
2013
2014 return SCI_FAILURE_INVALID_STATE;
2015}
2016
2017/**
2018 *
2019 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
2020 * object.
2021 * @frame_index: This is the frame index that was received from the SCU
2022 * hardware.
2023 *
2024 * This is the default method for a phy frame handling request. It will report
2025 * a warning, release the frame and exit. enum sci_status SCI_FAILURE_INVALID_STATE
2026 */
2027enum sci_status scic_sds_phy_default_frame_handler(
2028 struct scic_sds_phy *this_phy,
2029 u32 frame_index)
2030{
2031 dev_warn(sciphy_to_dev(this_phy),
2032 "%s: SCIC Phy 0x%p received unexpected frame data %d "
2033 "while in state %d\n",
2034 __func__,
2035 this_phy,
2036 frame_index,
2037 sci_base_state_machine_get_state(
2038 &this_phy->parent.state_machine));
2039
2040 scic_sds_controller_release_frame(
2041 scic_sds_phy_get_controller(this_phy), frame_index);
2042
2043 return SCI_FAILURE_INVALID_STATE;
2044}
2045
2046/**
2047 *
2048 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
2049 * object.
2050 * @event_code: This is the event code that was received from the SCU hardware.
2051 *
2052 * This is the default method for a phy event handler. It will report a
2053 * warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
2054 */
2055enum sci_status scic_sds_phy_default_event_handler(
2056 struct scic_sds_phy *this_phy,
2057 u32 event_code)
2058{
2059 dev_dbg(sciphy_to_dev(this_phy),
2060 "%s: SCIC Phy 0x%p received unexpected event status %x "
2061 "while in state %d\n",
2062 __func__,
2063 this_phy,
2064 event_code,
2065 sci_base_state_machine_get_state(
2066 &this_phy->parent.state_machine));
2067
2068 return SCI_FAILURE_INVALID_STATE;
2069}
2070
2071/**
2072 *
2073 * @phy: This is the struct sci_base_phy object which is cast into a struct scic_sds_phy
2074 * object.
2075 *
2076 * This is the default method for a phy consume power handler. It will report
2077 * a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE
2078 */
2079enum sci_status scic_sds_phy_default_consume_power_handler(
2080 struct scic_sds_phy *this_phy)
2081{
2082 dev_warn(sciphy_to_dev(this_phy),
2083 "%s: SCIC Phy 0x%p given unexpected permission to consume "
2084 "power while in state %d\n",
2085 __func__,
2086 this_phy,
2087 sci_base_state_machine_get_state(
2088 &this_phy->parent.state_machine));
2089
2090 return SCI_FAILURE_INVALID_STATE;
2091}
2092
2093/*
2094 * ******************************************************************************
2095 * * PHY STOPPED STATE HANDLERS
2096 * ****************************************************************************** */
2097
2098/** 1922/**
2099 * 1923 *
2100 * @phy: This is the struct sci_base_phy object which is cast into a 1924 * @phy: This is the struct sci_base_phy object which is cast into a
@@ -2219,7 +2043,7 @@ static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sd
2219 2043
2220/* --------------------------------------------------------------------------- */ 2044/* --------------------------------------------------------------------------- */
2221 2045
2222const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = { 2046static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = {
2223 [SCI_BASE_PHY_STATE_INITIAL] = { 2047 [SCI_BASE_PHY_STATE_INITIAL] = {
2224 .parent.start_handler = scic_sds_phy_default_start_handler, 2048 .parent.start_handler = scic_sds_phy_default_start_handler,
2225 .parent.stop_handler = scic_sds_phy_default_stop_handler, 2049 .parent.stop_handler = scic_sds_phy_default_stop_handler,
@@ -2563,7 +2387,7 @@ static void scic_sds_phy_final_state_enter(
2563 2387
2564/* --------------------------------------------------------------------------- */ 2388/* --------------------------------------------------------------------------- */
2565 2389
2566const struct sci_base_state scic_sds_phy_state_table[] = { 2390static const struct sci_base_state scic_sds_phy_state_table[] = {
2567 [SCI_BASE_PHY_STATE_INITIAL] = { 2391 [SCI_BASE_PHY_STATE_INITIAL] = {
2568 .enter_state = scic_sds_phy_initial_state_enter, 2392 .enter_state = scic_sds_phy_initial_state_enter,
2569 }, 2393 },
@@ -2585,3 +2409,29 @@ const struct sci_base_state scic_sds_phy_state_table[] = {
2585 }, 2409 },
2586}; 2410};
2587 2411
2412void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
2413 struct scic_sds_port *owning_port, u8 phy_index)
2414{
2415 /*
2416 * Call the base constructor first
2417 */
2418 sci_base_phy_construct(&sci_phy->parent, scic_sds_phy_state_table);
2419
2420 /* Copy the rest of the input data to our locals */
2421 sci_phy->owning_port = owning_port;
2422 sci_phy->phy_index = phy_index;
2423 sci_phy->bcn_received_while_port_unassigned = false;
2424 sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
2425 sci_phy->link_layer_registers = NULL;
2426 sci_phy->max_negotiated_speed = SCI_SAS_NO_LINK_RATE;
2427 sci_phy->sata_timeout_timer = NULL;
2428
2429 /* Clear out the identification buffer data */
2430 memset(&sci_phy->phy_type, 0, sizeof(sci_phy->phy_type));
2431
2432 /* Initialize the the substate machines */
2433 sci_base_state_machine_construct(&sci_phy->starting_substate_machine,
2434 &sci_phy->parent.parent,
2435 scic_sds_phy_starting_substates,
2436 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
2437}
diff --git a/drivers/scsi/isci/core/scic_sds_phy.h b/drivers/scsi/isci/core/scic_sds_phy.h
index af9e24c30945..4745a791f15b 100644
--- a/drivers/scsi/isci/core/scic_sds_phy.h
+++ b/drivers/scsi/isci/core/scic_sds_phy.h
@@ -293,12 +293,6 @@ struct scic_sds_phy_state_handler {
293 293
294}; 294};
295 295
296extern const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[];
297extern const struct sci_base_state scic_sds_phy_state_table[];
298extern const struct sci_base_state scic_sds_phy_starting_substates[];
299extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[];
300
301
302/** 296/**
303 * scic_sds_phy_get_index() - 297 * scic_sds_phy_get_index() -
304 * 298 *
@@ -362,12 +356,6 @@ enum sci_status scic_sds_phy_stop(
362enum sci_status scic_sds_phy_reset( 356enum sci_status scic_sds_phy_reset(
363 struct scic_sds_phy *this_phy); 357 struct scic_sds_phy *this_phy);
364 358
365void scic_sds_phy_sata_timeout(
366 void *cookie);
367
368void scic_sds_phy_suspend(
369 struct scic_sds_phy *this_phy);
370
371void scic_sds_phy_resume( 359void scic_sds_phy_resume(
372 struct scic_sds_phy *this_phy); 360 struct scic_sds_phy *this_phy);
373 361
@@ -402,27 +390,4 @@ void scic_sds_phy_get_attached_phy_protocols(
402 struct scic_sds_phy *this_phy, 390 struct scic_sds_phy *this_phy,
403 struct sci_sas_identify_address_frame_protocols *protocols); 391 struct sci_sas_identify_address_frame_protocols *protocols);
404 392
405enum sci_status scic_sds_phy_default_start_handler(
406 struct sci_base_phy *phy);
407
408enum sci_status scic_sds_phy_default_stop_handler(
409 struct sci_base_phy *phy);
410
411enum sci_status scic_sds_phy_default_reset_handler(
412 struct sci_base_phy *phy);
413
414enum sci_status scic_sds_phy_default_destroy_handler(
415 struct sci_base_phy *phy);
416
417enum sci_status scic_sds_phy_default_frame_handler(
418 struct scic_sds_phy *phy,
419 u32 frame_index);
420
421enum sci_status scic_sds_phy_default_event_handler(
422 struct scic_sds_phy *phy,
423 u32 evnet_code);
424
425enum sci_status scic_sds_phy_default_consume_power_handler(
426 struct scic_sds_phy *phy);
427
428#endif /* _SCIC_SDS_PHY_H_ */ 393#endif /* _SCIC_SDS_PHY_H_ */
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c
index 72b815ef98ca..0a95f649c04f 100644
--- a/drivers/scsi/isci/core/scic_sds_port.c
+++ b/drivers/scsi/isci/core/scic_sds_port.c
@@ -69,19 +69,13 @@
69#include "sci_environment.h" 69#include "sci_environment.h"
70#include "scic_sds_controller_registers.h" 70#include "scic_sds_controller_registers.h"
71 71
72
73static void scic_sds_port_invalid_link_up(
74 struct scic_sds_port *this_port,
75 struct scic_sds_phy *phy);
76static void scic_sds_port_timeout_handler(
77 void *port);
78#define SCIC_SDS_PORT_MIN_TIMER_COUNT (SCI_MAX_PORTS) 72#define SCIC_SDS_PORT_MIN_TIMER_COUNT (SCI_MAX_PORTS)
79#define SCIC_SDS_PORT_MAX_TIMER_COUNT (SCI_MAX_PORTS) 73#define SCIC_SDS_PORT_MAX_TIMER_COUNT (SCI_MAX_PORTS)
80 74
81#define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) 75#define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000)
82#define SCU_DUMMY_INDEX (0xFFFF) 76#define SCU_DUMMY_INDEX (0xFFFF)
83 77
84void sci_base_port_construct( 78static void sci_base_port_construct(
85 struct sci_base_port *base_port, 79 struct sci_base_port *base_port,
86 const struct sci_base_state *state_table) 80 const struct sci_base_state *state_table)
87{ 81{
@@ -168,7 +162,7 @@ bool scic_sds_port_is_valid_phy_assignment(
168 * Return a bit mask indicating which phys are a part of this port. Each bit 162 * Return a bit mask indicating which phys are a part of this port. Each bit
169 * corresponds to a phy identifier (e.g. bit 0 = phy id 0). 163 * corresponds to a phy identifier (e.g. bit 0 = phy id 0).
170 */ 164 */
171u32 scic_sds_port_get_phys(struct scic_sds_port *this_port) 165static u32 scic_sds_port_get_phys(struct scic_sds_port *this_port)
172{ 166{
173 u32 index; 167 u32 index;
174 u32 mask; 168 u32 mask;
@@ -196,7 +190,7 @@ u32 scic_sds_port_get_phys(struct scic_sds_port *this_port)
196 * phy mask can be supported. true if this is a valid phy assignment for the 190 * phy mask can be supported. true if this is a valid phy assignment for the
197 * port false if this is not a valid phy assignment for the port 191 * port false if this is not a valid phy assignment for the port
198 */ 192 */
199bool scic_sds_port_is_phy_mask_valid( 193static bool scic_sds_port_is_phy_mask_valid(
200 struct scic_sds_port *this_port, 194 struct scic_sds_port *this_port,
201 u32 phy_mask) 195 u32 phy_mask)
202{ 196{
@@ -269,7 +263,7 @@ static struct scic_sds_phy *scic_sds_port_get_a_connected_phy(
269 * is a functional test that only fails if the phy is currently assigned to a 263 * is a functional test that only fails if the phy is currently assigned to a
270 * different port. 264 * different port.
271 */ 265 */
272enum sci_status scic_sds_port_set_phy( 266static enum sci_status scic_sds_port_set_phy(
273 struct scic_sds_port *port, 267 struct scic_sds_port *port,
274 struct scic_sds_phy *phy) 268 struct scic_sds_phy *phy)
275{ 269{
@@ -304,7 +298,7 @@ enum sci_status scic_sds_port_set_phy(
304 * this phy is not currently assinged to this port. bool true if the phy is 298 * this phy is not currently assinged to this port. bool true if the phy is
305 * removed from the port. false if this phy is not assined to this port. 299 * removed from the port. false if this phy is not assined to this port.
306 */ 300 */
307enum sci_status scic_sds_port_clear_phy( 301static enum sci_status scic_sds_port_clear_phy(
308 struct scic_sds_port *port, 302 struct scic_sds_port *port,
309 struct scic_sds_phy *phy) 303 struct scic_sds_phy *phy)
310{ 304{
@@ -485,7 +479,7 @@ void scic_sds_port_get_attached_protocols(
485 * This structure will be posted to the hardware to work around a scheduler 479 * This structure will be posted to the hardware to work around a scheduler
486 * error in the hardware. 480 * error in the hardware.
487 */ 481 */
488void scic_sds_port_construct_dummy_rnc(struct scic_sds_port *sci_port, u16 rni) 482static void scic_sds_port_construct_dummy_rnc(struct scic_sds_port *sci_port, u16 rni)
489{ 483{
490 union scu_remote_node_context *rnc; 484 union scu_remote_node_context *rnc;
491 485
@@ -520,7 +514,7 @@ void scic_sds_port_construct_dummy_rnc(struct scic_sds_port *sci_port, u16 rni)
520 * in the hardware. 514 * in the hardware.
521 * 515 *
522 */ 516 */
523void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u16 tci) 517static void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u16 tci)
524{ 518{
525 struct scu_task_context *task_context; 519 struct scu_task_context *task_context;
526 520
@@ -554,7 +548,7 @@ void scic_sds_port_construct_dummy_task(struct scic_sds_port *sci_port, u16 tci)
554 task_context->task_phase = 0x01; 548 task_context->task_phase = 0x01;
555} 549}
556 550
557void scic_sds_port_destroy_dummy_resources(struct scic_sds_port *sci_port) 551static void scic_sds_port_destroy_dummy_resources(struct scic_sds_port *sci_port)
558{ 552{
559 struct scic_sds_controller *scic = sci_port->owning_controller; 553 struct scic_sds_controller *scic = sci_port->owning_controller;
560 554
@@ -569,38 +563,6 @@ void scic_sds_port_destroy_dummy_resources(struct scic_sds_port *sci_port)
569 sci_port->reserved_tci = SCU_DUMMY_INDEX; 563 sci_port->reserved_tci = SCU_DUMMY_INDEX;
570} 564}
571 565
572void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
573 struct scic_sds_controller *scic)
574{
575 u32 index;
576
577 sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table);
578
579 sci_base_state_machine_construct(&sci_port->ready_substate_machine,
580 &sci_port->parent.parent,
581 scic_sds_port_ready_substate_table,
582 SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
583
584 sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
585 sci_port->physical_port_index = port_index;
586 sci_port->active_phy_mask = 0;
587
588 sci_port->owning_controller = scic;
589
590 sci_port->started_request_count = 0;
591 sci_port->assigned_device_count = 0;
592
593 sci_port->reserved_rni = SCU_DUMMY_INDEX;
594 sci_port->reserved_tci = SCU_DUMMY_INDEX;
595
596 sci_port->timer_handle = NULL;
597
598 sci_port->port_task_scheduler_registers = NULL;
599
600 for (index = 0; index < SCI_MAX_PHYS; index++)
601 sci_port->phy_table[index] = NULL;
602}
603
604/** 566/**
605 * This method performs initialization of the supplied port. Initialization 567 * This method performs initialization of the supplied port. Initialization
606 * includes: - state machine initialization - member variable initialization 568 * includes: - state machine initialization - member variable initialization
@@ -627,61 +589,18 @@ enum sci_status scic_sds_port_initialize(
627} 589}
628 590
629/** 591/**
592 * scic_port_get_properties() - This method simply returns the properties
593 * regarding the port, such as: physical index, protocols, sas address, etc.
594 * @port: this parameter specifies the port for which to retrieve the physical
595 * index.
596 * @properties: This parameter specifies the properties structure into which to
597 * copy the requested information.
630 * 598 *
631 * @this_port: This is the struct scic_sds_port object for which has a phy that has 599 * Indicate if the user specified a valid port. SCI_SUCCESS This value is
632 * gone link up. 600 * returned if the specified port was valid. SCI_FAILURE_INVALID_PORT This
633 * @the_phy: This is the struct scic_sds_phy object that has gone link up. 601 * value is returned if the specified port is not valid. When this value is
634 * @do_notify_user: This parameter specifies whether to inform the user (via 602 * returned, no data is copied to the properties output parameter.
635 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
636 *
637 * This method is the a general link up handler for the struct scic_sds_port object.
638 * This function will determine if this struct scic_sds_phy can be assigned to this
639 * struct scic_sds_port object. If the struct scic_sds_phy object can is not a valid PHY for
640 * this port then the function will notify the SCIC_USER. A PHY can only be
641 * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in
642 * the same port. none
643 */ 603 */
644void scic_sds_port_general_link_up_handler(
645 struct scic_sds_port *this_port,
646 struct scic_sds_phy *the_phy,
647 bool do_notify_user)
648{
649 struct sci_sas_address port_sas_address;
650 struct sci_sas_address phy_sas_address;
651
652 scic_sds_port_get_attached_sas_address(this_port, &port_sas_address);
653 scic_sds_phy_get_attached_sas_address(the_phy, &phy_sas_address);
654
655 /*
656 * If the SAS address of the new phy matches the SAS address of
657 * other phys in the port OR this is the first phy in the port,
658 * then activate the phy and allow it to be used for operations
659 * in this port. */
660 if (
661 (
662 (phy_sas_address.high == port_sas_address.high)
663 && (phy_sas_address.low == port_sas_address.low)
664 )
665 || (this_port->active_phy_mask == 0)
666 ) {
667 scic_sds_port_activate_phy(this_port, the_phy, do_notify_user);
668
669 if (this_port->parent.state_machine.current_state_id
670 == SCI_BASE_PORT_STATE_RESETTING) {
671 sci_base_state_machine_change_state(
672 &this_port->parent.state_machine, SCI_BASE_PORT_STATE_READY
673 );
674 }
675 } else {
676 scic_sds_port_invalid_link_up(this_port, the_phy);
677 }
678}
679
680enum sci_status scic_port_stop(struct scic_sds_port *port)
681{
682 return port->state_handlers->parent.stop_handler(&port->parent);
683}
684
685enum sci_status scic_port_get_properties( 604enum sci_status scic_port_get_properties(
686 struct scic_sds_port *port, 605 struct scic_sds_port *port,
687 struct scic_port_properties *prop) 606 struct scic_port_properties *prop)
@@ -700,7 +619,20 @@ enum sci_status scic_port_get_properties(
700 return SCI_SUCCESS; 619 return SCI_SUCCESS;
701} 620}
702 621
703 622/**
623 * scic_port_hard_reset() - This method will request the SCI implementation to
624 * perform a HARD RESET on the SAS Port. If/When the HARD RESET completes
625 * the SCI user will be notified via an SCI OS callback indicating a direct
626 * attached device was found.
627 * @port: a handle corresponding to the SAS port to be hard reset.
628 * @reset_timeout: This parameter specifies the number of milliseconds in which
629 * the port reset operation should complete.
630 *
631 * The SCI User callback in SCIC_USER_CALLBACKS_T will only be called once for
632 * each phy in the SAS Port at completion of the hard reset sequence. Return a
633 * status indicating whether the hard reset started successfully. SCI_SUCCESS
634 * This value is returned if the hard reset operation started successfully.
635 */
704enum sci_status scic_port_hard_reset( 636enum sci_status scic_port_hard_reset(
705 struct scic_sds_port *port, 637 struct scic_sds_port *port,
706 u32 reset_timeout) 638 u32 reset_timeout)
@@ -741,12 +673,11 @@ void scic_sds_port_setup_transports(
741 * the phy to the port - enabling the Protocol Engine in the silicon. - 673 * the phy to the port - enabling the Protocol Engine in the silicon. -
742 * notifying the user that the link is up. none 674 * notifying the user that the link is up. none
743 */ 675 */
744void scic_sds_port_activate_phy(struct scic_sds_port *sci_port, 676static void scic_sds_port_activate_phy(struct scic_sds_port *sci_port,
745 struct scic_sds_phy *sci_phy, 677 struct scic_sds_phy *sci_phy,
746 bool do_notify_user) 678 bool do_notify_user)
747{ 679{
748 struct scic_sds_controller *scic = 680 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
749 scic_sds_port_get_controller(sci_port);
750 struct sci_sas_identify_address_frame_protocols protocols; 681 struct sci_sas_identify_address_frame_protocols protocols;
751 struct isci_host *ihost = sci_object_get_association(scic); 682 struct isci_host *ihost = sci_object_get_association(scic);
752 683
@@ -764,22 +695,11 @@ void scic_sds_port_activate_phy(struct scic_sds_port *sci_port,
764 isci_port_link_up(ihost, sci_port, sci_phy); 695 isci_port_link_up(ihost, sci_port, sci_phy);
765} 696}
766 697
767/**
768 *
769 * @this_port: This is the port on which the phy should be deactivated.
770 * @the_phy: This is the specific phy that is no longer active in the port.
771 * @do_notify_user: This parameter specifies whether to inform the user (via
772 * isci_port_link_down()) as to the fact that a new phy as become
773 * ready.
774 *
775 * This function will deactivate the supplied phy in the port. none
776 */
777void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port, 698void scic_sds_port_deactivate_phy(struct scic_sds_port *sci_port,
778 struct scic_sds_phy *sci_phy, 699 struct scic_sds_phy *sci_phy,
779 bool do_notify_user) 700 bool do_notify_user)
780{ 701{
781 struct scic_sds_controller *scic = 702 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
782 scic_sds_port_get_controller(sci_port);
783 struct isci_port *iport = sci_object_get_association(sci_port); 703 struct isci_port *iport = sci_object_get_association(sci_port);
784 struct isci_host *ihost = sci_object_get_association(scic); 704 struct isci_host *ihost = sci_object_get_association(scic);
785 struct isci_phy *iphy = sci_object_get_association(sci_phy); 705 struct isci_phy *iphy = sci_object_get_association(sci_phy);
@@ -822,6 +742,48 @@ static void scic_sds_port_invalid_link_up(
822} 742}
823 743
824/** 744/**
745 * scic_sds_port_general_link_up_handler - phy can be assigned to port?
746 * @sci_port: scic_sds_port object for which has a phy that has gone link up.
747 * @sci_phy: This is the struct scic_sds_phy object that has gone link up.
748 * @do_notify_user: This parameter specifies whether to inform the user (via
749 * scic_cb_port_link_up()) as to the fact that a new phy as become ready.
750 *
751 * Determine if this phy can be assigned to this
752 * port . If the phy is not a valid PHY for
753 * this port then the function will notify the user. A PHY can only be
754 * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in
755 * the same port. none
756 */
757static void scic_sds_port_general_link_up_handler(struct scic_sds_port *sci_port,
758 struct scic_sds_phy *sci_phy,
759 bool do_notify_user)
760{
761 struct sci_sas_address port_sas_address;
762 struct sci_sas_address phy_sas_address;
763
764 scic_sds_port_get_attached_sas_address(sci_port, &port_sas_address);
765 scic_sds_phy_get_attached_sas_address(sci_phy, &phy_sas_address);
766
767 /* If the SAS address of the new phy matches the SAS address of
768 * other phys in the port OR this is the first phy in the port,
769 * then activate the phy and allow it to be used for operations
770 * in this port.
771 */
772 if ((phy_sas_address.high == port_sas_address.high &&
773 phy_sas_address.low == port_sas_address.low) ||
774 sci_port->active_phy_mask == 0) {
775 struct sci_base_state_machine *sm = &sci_port->parent.state_machine;
776
777 scic_sds_port_activate_phy(sci_port, sci_phy, do_notify_user);
778 if (sm->current_state_id == SCI_BASE_PORT_STATE_RESETTING)
779 sci_base_state_machine_change_state(sm, SCI_BASE_PORT_STATE_READY);
780 } else
781 scic_sds_port_invalid_link_up(sci_port, sci_phy);
782}
783
784
785
786/**
825 * This method returns false if the port only has a single phy object assigned. 787 * This method returns false if the port only has a single phy object assigned.
826 * If there are no phys or more than one phy then the method will return 788 * If there are no phys or more than one phy then the method will return
827 * true. 789 * true.
@@ -1004,7 +966,7 @@ static void scic_sds_port_timeout_handler(void *port)
1004 * 966 *
1005 * 967 *
1006 */ 968 */
1007void scic_sds_port_update_viit_entry(struct scic_sds_port *this_port) 969static void scic_sds_port_update_viit_entry(struct scic_sds_port *this_port)
1008{ 970{
1009 struct sci_sas_address sas_address; 971 struct sci_sas_address sas_address;
1010 972
@@ -1483,9 +1445,106 @@ static enum sci_status scic_sds_port_ready_configuring_substate_complete_io_hand
1483 return SCI_SUCCESS; 1445 return SCI_SUCCESS;
1484} 1446}
1485 1447
1486/* --------------------------------------------------------------------------- */ 1448static enum sci_status default_port_handler(struct sci_base_port *base_port, const char *func)
1449{
1450 struct scic_sds_port *sci_port;
1451
1452 sci_port = container_of(base_port, typeof(*sci_port), parent);
1453 dev_warn(sciport_to_dev(sci_port),
1454 "%s: in wrong state: %d\n", func,
1455 sci_base_state_machine_get_state(&base_port->state_machine));
1456 return SCI_FAILURE_INVALID_STATE;
1457}
1458
1459static enum sci_status scic_sds_port_default_start_handler(struct sci_base_port *base_port)
1460{
1461 return default_port_handler(base_port, __func__);
1462}
1463
1464static enum sci_status scic_sds_port_default_stop_handler(struct sci_base_port *base_port)
1465{
1466 return default_port_handler(base_port, __func__);
1467}
1468
1469static enum sci_status scic_sds_port_default_destruct_handler(struct sci_base_port *base_port)
1470{
1471 return default_port_handler(base_port, __func__);
1472}
1473
1474static enum sci_status scic_sds_port_default_reset_handler(struct sci_base_port *base_port,
1475 u32 timeout)
1476{
1477 return default_port_handler(base_port, __func__);
1478}
1479
1480static enum sci_status scic_sds_port_default_add_phy_handler(struct sci_base_port *base_port,
1481 struct sci_base_phy *base_phy)
1482{
1483 return default_port_handler(base_port, __func__);
1484}
1485
1486static enum sci_status scic_sds_port_default_remove_phy_handler(struct sci_base_port *base_port,
1487 struct sci_base_phy *base_phy)
1488{
1489 return default_port_handler(base_port, __func__);
1490}
1491
1492/**
1493 * scic_sds_port_default_frame_handler
1494 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1495 * object.
1496 *
1497 * This is the default method for a port unsolicited frame request. It will
1498 * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even
1499 * possible to receive an unsolicited frame directed to a port object? It
1500 * seems possible if we implementing virtual functions but until then?
1501 */
1502static enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port,
1503 u32 frame_index)
1504{
1505 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
1506
1507 default_port_handler(&sci_port->parent, __func__);
1508 scic_sds_controller_release_frame(scic, frame_index);
1509
1510 return SCI_FAILURE_INVALID_STATE;
1511}
1512
1513static enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port,
1514 u32 event_code)
1515{
1516 return default_port_handler(&sci_port->parent, __func__);
1517}
1518
1519static void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port,
1520 struct scic_sds_phy *sci_phy)
1521{
1522 default_port_handler(&sci_port->parent, __func__);
1523}
1524
1525static void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port,
1526 struct scic_sds_phy *sci_phy)
1527{
1528 default_port_handler(&sci_port->parent, __func__);
1529}
1487 1530
1488struct scic_sds_port_state_handler 1531static enum sci_status scic_sds_port_default_start_io_handler(struct scic_sds_port *sci_port,
1532 struct scic_sds_remote_device *sci_dev,
1533 struct scic_sds_request *sci_req)
1534{
1535 return default_port_handler(&sci_port->parent, __func__);
1536}
1537
1538static enum sci_status scic_sds_port_default_complete_io_handler(struct scic_sds_port *sci_port,
1539 struct scic_sds_remote_device *sci_dev,
1540 struct scic_sds_request *sci_req)
1541{
1542 return default_port_handler(&sci_port->parent, __func__);
1543}
1544
1545
1546
1547static struct scic_sds_port_state_handler
1489scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] = 1548scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] =
1490{ 1549{
1491 /* SCIC_SDS_PORT_READY_SUBSTATE_WAITING */ 1550 /* SCIC_SDS_PORT_READY_SUBSTATE_WAITING */
@@ -1541,7 +1600,6 @@ scic_sds_port_ready_substate_handler_table[SCIC_SDS_PORT_READY_MAX_SUBSTATES] =
1541 } 1600 }
1542}; 1601};
1543 1602
1544
1545/** 1603/**
1546 * scic_sds_port_set_ready_state_handlers() - 1604 * scic_sds_port_set_ready_state_handlers() -
1547 * 1605 *
@@ -1584,7 +1642,7 @@ static void scic_sds_port_suspend_port_task_scheduler(
1584 * ongoing requests. 1642 * ongoing requests.
1585 * 1643 *
1586 */ 1644 */
1587void scic_sds_port_post_dummy_request(struct scic_sds_port *sci_port) 1645static void scic_sds_port_post_dummy_request(struct scic_sds_port *sci_port)
1588{ 1646{
1589 u32 command; 1647 u32 command;
1590 struct scu_task_context *task_context; 1648 struct scu_task_context *task_context;
@@ -1609,7 +1667,7 @@ void scic_sds_port_post_dummy_request(struct scic_sds_port *sci_port)
1609 * @sci_port: The port on which the task must be aborted. 1667 * @sci_port: The port on which the task must be aborted.
1610 * 1668 *
1611 */ 1669 */
1612void scic_sds_port_abort_dummy_request(struct scic_sds_port *sci_port) 1670static void scic_sds_port_abort_dummy_request(struct scic_sds_port *sci_port)
1613{ 1671{
1614 struct scic_sds_controller *scic = sci_port->owning_controller; 1672 struct scic_sds_controller *scic = sci_port->owning_controller;
1615 u16 tci = sci_port->reserved_tci; 1673 u16 tci = sci_port->reserved_tci;
@@ -1801,7 +1859,7 @@ static void scic_sds_port_ready_substate_configuring_exit(
1801 1859
1802/* --------------------------------------------------------------------------- */ 1860/* --------------------------------------------------------------------------- */
1803 1861
1804const struct sci_base_state scic_sds_port_ready_substate_table[] = { 1862static const struct sci_base_state scic_sds_port_ready_substate_table[] = {
1805 [SCIC_SDS_PORT_READY_SUBSTATE_WAITING] = { 1863 [SCIC_SDS_PORT_READY_SUBSTATE_WAITING] = {
1806 .enter_state = scic_sds_port_ready_substate_waiting_enter, 1864 .enter_state = scic_sds_port_ready_substate_waiting_enter,
1807 }, 1865 },
@@ -1815,103 +1873,6 @@ const struct sci_base_state scic_sds_port_ready_substate_table[] = {
1815 }, 1873 },
1816}; 1874};
1817 1875
1818static enum sci_status default_port_handler(struct sci_base_port *base_port, const char *func)
1819{
1820 struct scic_sds_port *sci_port;
1821
1822 sci_port = container_of(base_port, typeof(*sci_port), parent);
1823 dev_warn(sciport_to_dev(sci_port),
1824 "%s: in wrong state: %d\n", func,
1825 sci_base_state_machine_get_state(&base_port->state_machine));
1826 return SCI_FAILURE_INVALID_STATE;
1827}
1828
1829enum sci_status scic_sds_port_default_start_handler(struct sci_base_port *base_port)
1830{
1831 return default_port_handler(base_port, __func__);
1832}
1833
1834static enum sci_status scic_sds_port_default_stop_handler(struct sci_base_port *base_port)
1835{
1836 return default_port_handler(base_port, __func__);
1837}
1838
1839enum sci_status scic_sds_port_default_destruct_handler(struct sci_base_port *base_port)
1840{
1841 return default_port_handler(base_port, __func__);
1842}
1843
1844enum sci_status scic_sds_port_default_reset_handler(struct sci_base_port *base_port,
1845 u32 timeout)
1846{
1847 return default_port_handler(base_port, __func__);
1848}
1849
1850static enum sci_status scic_sds_port_default_add_phy_handler(struct sci_base_port *base_port,
1851 struct sci_base_phy *base_phy)
1852{
1853 return default_port_handler(base_port, __func__);
1854}
1855
1856enum sci_status scic_sds_port_default_remove_phy_handler(struct sci_base_port *base_port,
1857 struct sci_base_phy *base_phy)
1858{
1859 return default_port_handler(base_port, __func__);
1860}
1861
1862/**
1863 * scic_sds_port_default_frame_handler
1864 * @port: This is the struct sci_base_port object which is cast into a struct scic_sds_port
1865 * object.
1866 *
1867 * This is the default method for a port unsolicited frame request. It will
1868 * report a warning and exit. enum sci_status SCI_FAILURE_INVALID_STATE Is it even
1869 * possible to receive an unsolicited frame directed to a port object? It
1870 * seems possible if we implementing virtual functions but until then?
1871 */
1872enum sci_status scic_sds_port_default_frame_handler(struct scic_sds_port *sci_port,
1873 u32 frame_index)
1874{
1875 struct scic_sds_controller *scic = scic_sds_port_get_controller(sci_port);
1876
1877 default_port_handler(&sci_port->parent, __func__);
1878 scic_sds_controller_release_frame(scic, frame_index);
1879
1880 return SCI_FAILURE_INVALID_STATE;
1881}
1882
1883enum sci_status scic_sds_port_default_event_handler(struct scic_sds_port *sci_port,
1884 u32 event_code)
1885{
1886 return default_port_handler(&sci_port->parent, __func__);
1887}
1888
1889void scic_sds_port_default_link_up_handler(struct scic_sds_port *sci_port,
1890 struct scic_sds_phy *sci_phy)
1891{
1892 default_port_handler(&sci_port->parent, __func__);
1893}
1894
1895void scic_sds_port_default_link_down_handler(struct scic_sds_port *sci_port,
1896 struct scic_sds_phy *sci_phy)
1897{
1898 default_port_handler(&sci_port->parent, __func__);
1899}
1900
1901enum sci_status scic_sds_port_default_start_io_handler(struct scic_sds_port *sci_port,
1902 struct scic_sds_remote_device *sci_dev,
1903 struct scic_sds_request *sci_req)
1904{
1905 return default_port_handler(&sci_port->parent, __func__);
1906}
1907
1908static enum sci_status scic_sds_port_default_complete_io_handler(struct scic_sds_port *sci_port,
1909 struct scic_sds_remote_device *sci_dev,
1910 struct scic_sds_request *sci_req)
1911{
1912 return default_port_handler(&sci_port->parent, __func__);
1913}
1914
1915/** 1876/**
1916 * 1877 *
1917 * @port: This is the struct scic_sds_port object on which the io request count will 1878 * @port: This is the struct scic_sds_port object on which the io request count will
@@ -2248,9 +2209,7 @@ static void scic_sds_port_reset_state_link_down_handler(
2248 scic_sds_port_deactivate_phy(this_port, phy, false); 2209 scic_sds_port_deactivate_phy(this_port, phy, false);
2249} 2210}
2250 2211
2251/* --------------------------------------------------------------------------- */ 2212static struct scic_sds_port_state_handler
2252
2253struct scic_sds_port_state_handler
2254scic_sds_port_state_handler_table[SCI_BASE_PORT_MAX_STATES] = 2213scic_sds_port_state_handler_table[SCI_BASE_PORT_MAX_STATES] =
2255{ 2214{
2256 /* SCI_BASE_PORT_STATE_STOPPED */ 2215 /* SCI_BASE_PORT_STATE_STOPPED */
@@ -2384,7 +2343,7 @@ static void scic_sds_port_disable_port_task_scheduler(
2384 scu_port_task_scheduler_write(this_port, control, pts_control_value); 2343 scu_port_task_scheduler_write(this_port, control, pts_control_value);
2385} 2344}
2386 2345
2387void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port) 2346static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port)
2388{ 2347{
2389 struct scic_sds_controller *scic = sci_port->owning_controller; 2348 struct scic_sds_controller *scic = sci_port->owning_controller;
2390 u8 phys_index = sci_port->physical_port_index; 2349 u8 phys_index = sci_port->physical_port_index;
@@ -2412,7 +2371,7 @@ void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port)
2412 scic_sds_controller_post_request(scic, command); 2371 scic_sds_controller_post_request(scic, command);
2413} 2372}
2414 2373
2415void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci_port) 2374static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci_port)
2416{ 2375{
2417 struct scic_sds_controller *scic = sci_port->owning_controller; 2376 struct scic_sds_controller *scic = sci_port->owning_controller;
2418 u8 phys_index = sci_port->physical_port_index; 2377 u8 phys_index = sci_port->physical_port_index;
@@ -2639,7 +2598,7 @@ static void scic_sds_port_failed_state_enter(struct sci_base_object *object)
2639 2598
2640/* --------------------------------------------------------------------------- */ 2599/* --------------------------------------------------------------------------- */
2641 2600
2642const struct sci_base_state scic_sds_port_state_table[] = { 2601static const struct sci_base_state scic_sds_port_state_table[] = {
2643 [SCI_BASE_PORT_STATE_STOPPED] = { 2602 [SCI_BASE_PORT_STATE_STOPPED] = {
2644 .enter_state = scic_sds_port_stopped_state_enter, 2603 .enter_state = scic_sds_port_stopped_state_enter,
2645 .exit_state = scic_sds_port_stopped_state_exit 2604 .exit_state = scic_sds_port_stopped_state_exit
@@ -2661,3 +2620,34 @@ const struct sci_base_state scic_sds_port_state_table[] = {
2661 } 2620 }
2662}; 2621};
2663 2622
2623void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 port_index,
2624 struct scic_sds_controller *scic)
2625{
2626 u32 index;
2627
2628 sci_base_port_construct(&sci_port->parent, scic_sds_port_state_table);
2629
2630 sci_base_state_machine_construct(&sci_port->ready_substate_machine,
2631 &sci_port->parent.parent,
2632 scic_sds_port_ready_substate_table,
2633 SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
2634
2635 sci_port->logical_port_index = SCIC_SDS_DUMMY_PORT;
2636 sci_port->physical_port_index = port_index;
2637 sci_port->active_phy_mask = 0;
2638
2639 sci_port->owning_controller = scic;
2640
2641 sci_port->started_request_count = 0;
2642 sci_port->assigned_device_count = 0;
2643
2644 sci_port->reserved_rni = SCU_DUMMY_INDEX;
2645 sci_port->reserved_tci = SCU_DUMMY_INDEX;
2646
2647 sci_port->timer_handle = NULL;
2648
2649 sci_port->port_task_scheduler_registers = NULL;
2650
2651 for (index = 0; index < SCI_MAX_PHYS; index++)
2652 sci_port->phy_table[index] = NULL;
2653}
diff --git a/drivers/scsi/isci/core/scic_sds_port.h b/drivers/scsi/isci/core/scic_sds_port.h
index ac81a92c348a..8167f5e3be3d 100644
--- a/drivers/scsi/isci/core/scic_sds_port.h
+++ b/drivers/scsi/isci/core/scic_sds_port.h
@@ -236,12 +236,6 @@ struct scic_sds_port_state_handler {
236 236
237}; 237};
238 238
239extern const struct sci_base_state scic_sds_port_state_table[];
240extern const struct sci_base_state scic_sds_port_ready_substate_table[];
241
242extern struct scic_sds_port_state_handler scic_sds_port_state_handler_table[];
243extern struct scic_sds_port_state_handler scic_sds_port_ready_substate_handler_table[];
244
245/** 239/**
246 * scic_sds_port_get_controller() - 240 * scic_sds_port_get_controller() -
247 * 241 *
@@ -351,10 +345,6 @@ void scic_sds_port_setup_transports(
351 struct scic_sds_port *this_port, 345 struct scic_sds_port *this_port,
352 u32 device_id); 346 u32 device_id);
353 347
354void scic_sds_port_activate_phy(
355 struct scic_sds_port *this_port,
356 struct scic_sds_phy *phy,
357 bool do_notify_user);
358 348
359void scic_sds_port_deactivate_phy( 349void scic_sds_port_deactivate_phy(
360 struct scic_sds_port *this_port, 350 struct scic_sds_port *this_port,
@@ -363,10 +353,6 @@ void scic_sds_port_deactivate_phy(
363 353
364 354
365 355
366void scic_sds_port_general_link_up_handler(
367 struct scic_sds_port *this_port,
368 struct scic_sds_phy *the_phy,
369 bool do_notify_user);
370 356
371bool scic_sds_port_link_detected( 357bool scic_sds_port_link_detected(
372 struct scic_sds_port *this_port, 358 struct scic_sds_port *this_port,
@@ -397,47 +383,19 @@ enum sci_status scic_sds_port_complete_io(
397 383
398/* --------------------------------------------------------------------------- */ 384/* --------------------------------------------------------------------------- */
399 385
400void scic_sds_port_update_viit_entry(
401 struct scic_sds_port *this_port);
402 386
403/* --------------------------------------------------------------------------- */ 387/* --------------------------------------------------------------------------- */
404 388
405enum sci_status scic_sds_port_default_start_handler(
406 struct sci_base_port *port);
407 389
408 390
409enum sci_status scic_sds_port_default_destruct_handler(
410 struct sci_base_port *port);
411 391
412enum sci_status scic_sds_port_default_reset_handler(
413 struct sci_base_port *port,
414 u32 timeout);
415 392
416 393
417enum sci_status scic_sds_port_default_remove_phy_handler(
418 struct sci_base_port *port,
419 struct sci_base_phy *phy);
420 394
421enum sci_status scic_sds_port_default_frame_handler(
422 struct scic_sds_port *port,
423 u32 frame_index);
424 395
425enum sci_status scic_sds_port_default_event_handler(
426 struct scic_sds_port *port,
427 u32 event_code);
428 396
429void scic_sds_port_default_link_up_handler(
430 struct scic_sds_port *this_port,
431 struct scic_sds_phy *phy);
432 397
433void scic_sds_port_default_link_down_handler(
434 struct scic_sds_port *this_port,
435 struct scic_sds_phy *phy);
436 398
437enum sci_status scic_sds_port_default_start_io_handler(
438 struct scic_sds_port *port,
439 struct scic_sds_remote_device *device,
440 struct scic_sds_request *io_request);
441 399
442 400
443enum sci_sas_link_rate scic_sds_port_get_max_allowed_speed( 401enum sci_sas_link_rate scic_sds_port_get_max_allowed_speed(
@@ -451,12 +409,7 @@ bool scic_sds_port_is_valid_phy_assignment(
451 struct scic_sds_port *this_port, 409 struct scic_sds_port *this_port,
452 u32 phy_index); 410 u32 phy_index);
453 411
454bool scic_sds_port_is_phy_mask_valid(
455 struct scic_sds_port *this_port,
456 u32 phy_mask);
457 412
458u32 scic_sds_port_get_phys(
459 struct scic_sds_port *this_port);
460 413
461void scic_sds_port_get_sas_address( 414void scic_sds_port_get_sas_address(
462 struct scic_sds_port *this_port, 415 struct scic_sds_port *this_port,
@@ -470,13 +423,7 @@ void scic_sds_port_get_attached_protocols(
470 struct scic_sds_port *this_port, 423 struct scic_sds_port *this_port,
471 struct sci_sas_identify_address_frame_protocols *protocols); 424 struct sci_sas_identify_address_frame_protocols *protocols);
472 425
473enum sci_status scic_sds_port_set_phy(
474 struct scic_sds_port *port,
475 struct scic_sds_phy *phy);
476 426
477enum sci_status scic_sds_port_clear_phy(
478 struct scic_sds_port *port,
479 struct scic_sds_phy *phy);
480 427
481 428
482 429
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.c b/drivers/scsi/isci/core/scic_sds_remote_device.c
index 05599d178caa..5ab8b0321de5 100644
--- a/drivers/scsi/isci/core/scic_sds_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_remote_device.c
@@ -87,30 +87,6 @@ u32 scic_remote_device_get_object_size(void)
87 + sizeof(struct scic_sds_remote_node_context); 87 + sizeof(struct scic_sds_remote_node_context);
88} 88}
89 89
90/* --------------------------------------------------------------------------- */
91
92void scic_remote_device_construct(struct scic_sds_port *sci_port,
93 struct scic_sds_remote_device *sci_dev)
94{
95 sci_dev->owning_port = sci_port;
96 sci_dev->started_request_count = 0;
97 sci_dev->rnc = (struct scic_sds_remote_node_context *) &sci_dev[1];
98
99 sci_base_remote_device_construct(
100 &sci_dev->parent,
101 scic_sds_remote_device_state_table
102 );
103
104 scic_sds_remote_node_context_construct(
105 sci_dev,
106 sci_dev->rnc,
107 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
108 );
109
110 sci_object_set_association(sci_dev->rnc, sci_dev);
111}
112
113
114enum sci_status scic_remote_device_da_construct( 90enum sci_status scic_remote_device_da_construct(
115 struct scic_sds_remote_device *sci_dev) 91 struct scic_sds_remote_device *sci_dev)
116{ 92{
@@ -1330,7 +1306,7 @@ static enum sci_status scic_sds_remote_device_resetting_state_complete_request_h
1330 1306
1331/* --------------------------------------------------------------------------- */ 1307/* --------------------------------------------------------------------------- */
1332 1308
1333const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = { 1309static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = {
1334 [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { 1310 [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = {
1335 .parent.start_handler = scic_sds_remote_device_default_start_handler, 1311 .parent.start_handler = scic_sds_remote_device_default_start_handler,
1336 .parent.stop_handler = scic_sds_remote_device_default_stop_handler, 1312 .parent.stop_handler = scic_sds_remote_device_default_stop_handler,
@@ -1741,7 +1717,7 @@ static void scic_sds_remote_device_final_state_enter(
1741 1717
1742/* --------------------------------------------------------------------------- */ 1718/* --------------------------------------------------------------------------- */
1743 1719
1744const struct sci_base_state scic_sds_remote_device_state_table[] = { 1720static const struct sci_base_state scic_sds_remote_device_state_table[] = {
1745 [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { 1721 [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = {
1746 .enter_state = scic_sds_remote_device_initial_state_enter, 1722 .enter_state = scic_sds_remote_device_initial_state_enter,
1747 }, 1723 },
@@ -1771,3 +1747,23 @@ const struct sci_base_state scic_sds_remote_device_state_table[] = {
1771 }, 1747 },
1772}; 1748};
1773 1749
1750void scic_remote_device_construct(struct scic_sds_port *sci_port,
1751 struct scic_sds_remote_device *sci_dev)
1752{
1753 sci_dev->owning_port = sci_port;
1754 sci_dev->started_request_count = 0;
1755 sci_dev->rnc = (struct scic_sds_remote_node_context *) &sci_dev[1];
1756
1757 sci_base_remote_device_construct(
1758 &sci_dev->parent,
1759 scic_sds_remote_device_state_table
1760 );
1761
1762 scic_sds_remote_node_context_construct(
1763 sci_dev,
1764 sci_dev->rnc,
1765 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
1766 );
1767
1768 sci_object_set_association(sci_dev->rnc, sci_dev);
1769}
diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.h b/drivers/scsi/isci/core/scic_sds_remote_device.h
index aa466249f229..725c0588f2ab 100644
--- a/drivers/scsi/isci/core/scic_sds_remote_device.h
+++ b/drivers/scsi/isci/core/scic_sds_remote_device.h
@@ -316,15 +316,10 @@ struct scic_sds_remote_device_state_handler {
316 scic_sds_remote_device_frame_handler_t frame_handler; 316 scic_sds_remote_device_frame_handler_t frame_handler;
317}; 317};
318 318
319extern const struct sci_base_state scic_sds_remote_device_state_table[];
320extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[]; 319extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[];
321extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[]; 320extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[];
322extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[]; 321extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[];
323 322
324extern const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[];
325extern const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_device_ready_substate_handler_table[];
326extern const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_device_ready_substate_handler_table[];
327
328/** 323/**
329 * scic_sds_remote_device_increment_request_count() - 324 * scic_sds_remote_device_increment_request_count() -
330 * 325 *
diff --git a/drivers/scsi/isci/core/scic_sds_remote_node_context.c b/drivers/scsi/isci/core/scic_sds_remote_node_context.c
index 253b2d8aa23b..81e4ab34dd30 100644
--- a/drivers/scsi/isci/core/scic_sds_remote_node_context.c
+++ b/drivers/scsi/isci/core/scic_sds_remote_node_context.c
@@ -64,26 +64,6 @@
64#include "scu_event_codes.h" 64#include "scu_event_codes.h"
65#include "scu_task_context.h" 65#include "scu_task_context.h"
66 66
67void scic_sds_remote_node_context_construct(
68 struct scic_sds_remote_device *device,
69 struct scic_sds_remote_node_context *rnc,
70 u16 remote_node_index)
71{
72 memset(rnc, 0, sizeof(struct scic_sds_remote_node_context));
73
74 rnc->remote_node_index = remote_node_index;
75 rnc->device = device;
76 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
77
78 sci_base_state_machine_construct(
79 &rnc->state_machine,
80 &rnc->parent,
81 scic_sds_remote_node_context_state_table,
82 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
83 );
84
85 sci_base_state_machine_start(&rnc->state_machine);
86}
87 67
88/** 68/**
89 * 69 *
@@ -124,7 +104,7 @@ bool scic_sds_remote_node_context_is_ready(
124 * 104 *
125 * This method will construct the RNC buffer for this remote device object. none 105 * This method will construct the RNC buffer for this remote device object. none
126 */ 106 */
127void scic_sds_remote_node_context_construct_buffer( 107static void scic_sds_remote_node_context_construct_buffer(
128 struct scic_sds_remote_node_context *this_rnc) 108 struct scic_sds_remote_node_context *this_rnc)
129{ 109{
130 union scu_remote_node_context *rnc; 110 union scu_remote_node_context *rnc;
@@ -830,7 +810,7 @@ static enum sci_status scic_sds_remote_node_context_await_suspension_state_event
830 810
831/* --------------------------------------------------------------------------- */ 811/* --------------------------------------------------------------------------- */
832 812
833struct scic_sds_remote_node_context_handlers 813static struct scic_sds_remote_node_context_handlers
834scic_sds_remote_node_context_state_handler_table[ 814scic_sds_remote_node_context_state_handler_table[
835 SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES] = 815 SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES] =
836{ 816{
@@ -1218,7 +1198,7 @@ static void scic_sds_remote_node_context_await_suspension_state_enter(
1218 1198
1219/* --------------------------------------------------------------------------- */ 1199/* --------------------------------------------------------------------------- */
1220 1200
1221const struct sci_base_state scic_sds_remote_node_context_state_table[] = { 1201static const struct sci_base_state scic_sds_remote_node_context_state_table[] = {
1222 [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = { 1202 [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = {
1223 .enter_state = scic_sds_remote_node_context_initial_state_enter, 1203 .enter_state = scic_sds_remote_node_context_initial_state_enter,
1224 }, 1204 },
@@ -1245,3 +1225,23 @@ const struct sci_base_state scic_sds_remote_node_context_state_table[] = {
1245 }, 1225 },
1246}; 1226};
1247 1227
1228void scic_sds_remote_node_context_construct(
1229 struct scic_sds_remote_device *device,
1230 struct scic_sds_remote_node_context *rnc,
1231 u16 remote_node_index)
1232{
1233 memset(rnc, 0, sizeof(struct scic_sds_remote_node_context));
1234
1235 rnc->remote_node_index = remote_node_index;
1236 rnc->device = device;
1237 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
1238
1239 sci_base_state_machine_construct(
1240 &rnc->state_machine,
1241 &rnc->parent,
1242 scic_sds_remote_node_context_state_table,
1243 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
1244 );
1245
1246 sci_base_state_machine_start(&rnc->state_machine);
1247}
diff --git a/drivers/scsi/isci/core/scic_sds_remote_node_context.h b/drivers/scsi/isci/core/scic_sds_remote_node_context.h
index c7c75ae6f092..eccad55ea571 100644
--- a/drivers/scsi/isci/core/scic_sds_remote_node_context.h
+++ b/drivers/scsi/isci/core/scic_sds_remote_node_context.h
@@ -279,19 +279,11 @@ struct scic_sds_remote_node_context {
279 struct scic_sds_remote_node_context_handlers *state_handlers; 279 struct scic_sds_remote_node_context_handlers *state_handlers;
280}; 280};
281 281
282extern const struct sci_base_state scic_sds_remote_node_context_state_table[];
283
284extern struct scic_sds_remote_node_context_handlers
285 scic_sds_remote_node_context_state_handler_table[
286 SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES];
287
288void scic_sds_remote_node_context_construct( 282void scic_sds_remote_node_context_construct(
289 struct scic_sds_remote_device *device, 283 struct scic_sds_remote_device *device,
290 struct scic_sds_remote_node_context *rnc, 284 struct scic_sds_remote_node_context *rnc,
291 u16 remote_node_index); 285 u16 remote_node_index);
292 286
293void scic_sds_remote_node_context_construct_buffer(
294 struct scic_sds_remote_node_context *rnc);
295 287
296bool scic_sds_remote_node_context_is_ready( 288bool scic_sds_remote_node_context_is_ready(
297 struct scic_sds_remote_node_context *this_rnc); 289 struct scic_sds_remote_node_context *this_rnc);
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c
index 4542f4e75f7f..45b8571726f7 100644
--- a/drivers/scsi/isci/core/scic_sds_request.c
+++ b/drivers/scsi/isci/core/scic_sds_request.c
@@ -326,59 +326,6 @@ void scic_sds_request_build_sgl(struct scic_sds_request *sds_request)
326} 326}
327 327
328/** 328/**
329 * This method initializes common portions of the io request object. This
330 * includes construction of the struct sci_base_request parent.
331 * @the_controller: This parameter specifies the controller for which the
332 * request is being constructed.
333 * @the_target: This parameter specifies the remote device for which the
334 * request is being constructed.
335 * @io_tag: This parameter specifies the IO tag to be utilized for this
336 * request. This parameter can be set to SCI_CONTROLLER_INVALID_IO_TAG.
337 * @user_io_request_object: This parameter specifies the user request object
338 * for which the request is being constructed.
339 * @this_request: This parameter specifies the request being constructed.
340 *
341 */
342static void scic_sds_general_request_construct(
343 struct scic_sds_controller *the_controller,
344 struct scic_sds_remote_device *the_target,
345 u16 io_tag,
346 void *user_io_request_object,
347 struct scic_sds_request *this_request)
348{
349 sci_base_request_construct(
350 &this_request->parent,
351 scic_sds_request_state_table
352 );
353
354 this_request->io_tag = io_tag;
355 this_request->user_request = user_io_request_object;
356 this_request->owning_controller = the_controller;
357 this_request->target_device = the_target;
358 this_request->has_started_substate_machine = false;
359 this_request->protocol = SCIC_NO_PROTOCOL;
360 this_request->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX;
361 this_request->device_sequence = scic_sds_remote_device_get_sequence(the_target);
362
363 this_request->sci_status = SCI_SUCCESS;
364 this_request->scu_status = 0;
365 this_request->post_context = 0xFFFFFFFF;
366
367 this_request->is_task_management_request = false;
368
369 if (io_tag == SCI_CONTROLLER_INVALID_IO_TAG) {
370 this_request->was_tag_assigned_by_user = false;
371 this_request->task_context_buffer = NULL;
372 } else {
373 this_request->was_tag_assigned_by_user = true;
374
375 this_request->task_context_buffer =
376 scic_sds_controller_get_task_context_buffer(
377 this_request->owning_controller, io_tag);
378 }
379}
380
381/**
382 * This method build the remainder of the IO request object. 329 * This method build the remainder of the IO request object.
383 * @this_request: This parameter specifies the request object being constructed. 330 * @this_request: This parameter specifies the request object being constructed.
384 * 331 *
@@ -754,16 +701,6 @@ static enum sci_status scic_io_request_construct_sata(struct scic_sds_request *s
754 return status; 701 return status;
755} 702}
756 703
757/*
758 * ****************************************************************************
759 * * SCIC Interface Implementation
760 * **************************************************************************** */
761
762
763
764
765/* --------------------------------------------------------------------------- */
766
767u32 scic_io_request_get_object_size(void) 704u32 scic_io_request_get_object_size(void)
768{ 705{
769 u32 ssp_request_size; 706 u32 ssp_request_size;
@@ -777,128 +714,6 @@ u32 scic_io_request_get_object_size(void)
777 return max(ssp_request_size, max(stp_request_size, smp_request_size)); 714 return max(ssp_request_size, max(stp_request_size, smp_request_size));
778} 715}
779 716
780/* --------------------------------------------------------------------------- */
781
782
783/* --------------------------------------------------------------------------- */
784
785
786/* --------------------------------------------------------------------------- */
787
788
789/* --------------------------------------------------------------------------- */
790
791enum sci_status scic_io_request_construct(
792 struct scic_sds_controller *scic_controller,
793 struct scic_sds_remote_device *scic_remote_device,
794 u16 io_tag,
795 void *user_io_request_object,
796 void *scic_io_request_memory,
797 struct scic_sds_request **new_scic_io_request_handle)
798{
799 enum sci_status status = SCI_SUCCESS;
800 struct scic_sds_request *this_request;
801 struct smp_discover_response_protocols device_protocol;
802
803 this_request = (struct scic_sds_request *)scic_io_request_memory;
804
805 /* Build the common part of the request */
806 scic_sds_general_request_construct(
807 (struct scic_sds_controller *)scic_controller,
808 (struct scic_sds_remote_device *)scic_remote_device,
809 io_tag,
810 user_io_request_object,
811 this_request
812 );
813
814 if (
815 scic_sds_remote_device_get_index((struct scic_sds_remote_device *)scic_remote_device)
816 == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX
817 ) {
818 return SCI_FAILURE_INVALID_REMOTE_DEVICE;
819 }
820
821 scic_remote_device_get_protocols(scic_remote_device, &device_protocol);
822
823 if (device_protocol.u.bits.attached_ssp_target) {
824 scic_sds_ssp_io_request_assign_buffers(this_request);
825 } else if (device_protocol.u.bits.attached_stp_target) {
826 scic_sds_stp_request_assign_buffers(this_request);
827 memset(this_request->command_buffer, 0, sizeof(struct sata_fis_reg_h2d));
828 } else if (device_protocol.u.bits.attached_smp_target) {
829 scic_sds_smp_request_assign_buffers(this_request);
830 memset(this_request->command_buffer, 0, sizeof(struct smp_request));
831 } else {
832 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
833 }
834
835 if (status == SCI_SUCCESS) {
836 memset(
837 this_request->task_context_buffer,
838 0,
839 SCI_FIELD_OFFSET(struct scu_task_context, sgl_pair_ab)
840 );
841 *new_scic_io_request_handle = scic_io_request_memory;
842 }
843
844 return status;
845}
846
847/* --------------------------------------------------------------------------- */
848
849
850enum sci_status scic_task_request_construct(
851 struct scic_sds_controller *controller,
852 struct scic_sds_remote_device *remote_device,
853 u16 io_tag,
854 void *user_io_request_object,
855 void *scic_task_request_memory,
856 struct scic_sds_request **new_scic_task_request_handle)
857{
858 enum sci_status status = SCI_SUCCESS;
859 struct scic_sds_request *this_request = (struct scic_sds_request *)
860 scic_task_request_memory;
861 struct smp_discover_response_protocols device_protocol;
862
863 /* Build the common part of the request */
864 scic_sds_general_request_construct(
865 (struct scic_sds_controller *)controller,
866 (struct scic_sds_remote_device *)remote_device,
867 io_tag,
868 user_io_request_object,
869 this_request
870 );
871
872 scic_remote_device_get_protocols(remote_device, &device_protocol);
873
874 if (device_protocol.u.bits.attached_ssp_target) {
875 scic_sds_ssp_task_request_assign_buffers(this_request);
876
877 this_request->has_started_substate_machine = true;
878
879 /* Construct the started sub-state machine. */
880 sci_base_state_machine_construct(
881 &this_request->started_substate_machine,
882 &this_request->parent.parent,
883 scic_sds_io_request_started_task_mgmt_substate_table,
884 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
885 );
886 } else if (device_protocol.u.bits.attached_stp_target) {
887 scic_sds_stp_request_assign_buffers(this_request);
888 } else {
889 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
890 }
891
892 if (status == SCI_SUCCESS) {
893 this_request->is_task_management_request = true;
894 memset(this_request->task_context_buffer, 0x00, sizeof(struct scu_task_context));
895 *new_scic_task_request_handle = scic_task_request_memory;
896 }
897
898 return status;
899}
900
901
902enum sci_status scic_io_request_construct_basic_ssp( 717enum sci_status scic_io_request_construct_basic_ssp(
903 struct scic_sds_request *sci_req) 718 struct scic_sds_request *sci_req)
904{ 719{
@@ -1915,9 +1730,7 @@ static enum sci_status scic_sds_request_aborting_state_frame_handler(
1915 return SCI_SUCCESS; 1730 return SCI_SUCCESS;
1916} 1731}
1917 1732
1918/* --------------------------------------------------------------------------- */ 1733static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = {
1919
1920const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = {
1921 [SCI_BASE_REQUEST_STATE_INITIAL] = { 1734 [SCI_BASE_REQUEST_STATE_INITIAL] = {
1922 .parent.start_handler = scic_sds_request_default_start_handler, 1735 .parent.start_handler = scic_sds_request_default_start_handler,
1923 .parent.abort_handler = scic_sds_request_default_abort_handler, 1736 .parent.abort_handler = scic_sds_request_default_abort_handler,
@@ -2142,9 +1955,7 @@ static void scic_sds_request_final_state_enter(
2142 ); 1955 );
2143} 1956}
2144 1957
2145/* --------------------------------------------------------------------------- */ 1958static const struct sci_base_state scic_sds_request_state_table[] = {
2146
2147const struct sci_base_state scic_sds_request_state_table[] = {
2148 [SCI_BASE_REQUEST_STATE_INITIAL] = { 1959 [SCI_BASE_REQUEST_STATE_INITIAL] = {
2149 .enter_state = scic_sds_request_initial_state_enter, 1960 .enter_state = scic_sds_request_initial_state_enter,
2150 }, 1961 },
@@ -2166,3 +1977,119 @@ const struct sci_base_state scic_sds_request_state_table[] = {
2166 }, 1977 },
2167}; 1978};
2168 1979
1980static void scic_sds_general_request_construct(struct scic_sds_controller *scic,
1981 struct scic_sds_remote_device *sci_dev,
1982 u16 io_tag,
1983 void *user_io_request_object,
1984 struct scic_sds_request *sci_req)
1985{
1986 sci_base_request_construct(&sci_req->parent, scic_sds_request_state_table);
1987 sci_req->io_tag = io_tag;
1988 sci_req->user_request = user_io_request_object;
1989 sci_req->owning_controller = scic;
1990 sci_req->target_device = sci_dev;
1991 sci_req->has_started_substate_machine = false;
1992 sci_req->protocol = SCIC_NO_PROTOCOL;
1993 sci_req->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX;
1994 sci_req->device_sequence = scic_sds_remote_device_get_sequence(sci_dev);
1995
1996 sci_req->sci_status = SCI_SUCCESS;
1997 sci_req->scu_status = 0;
1998 sci_req->post_context = 0xFFFFFFFF;
1999
2000 sci_req->is_task_management_request = false;
2001
2002 if (io_tag == SCI_CONTROLLER_INVALID_IO_TAG) {
2003 sci_req->was_tag_assigned_by_user = false;
2004 sci_req->task_context_buffer = NULL;
2005 } else {
2006 sci_req->was_tag_assigned_by_user = true;
2007
2008 sci_req->task_context_buffer =
2009 scic_sds_controller_get_task_context_buffer(scic, io_tag);
2010 }
2011}
2012
2013enum sci_status scic_io_request_construct(struct scic_sds_controller *scic,
2014 struct scic_sds_remote_device *sci_dev,
2015 u16 io_tag,
2016 void *user_io_request_object,
2017 struct scic_sds_request *sci_req,
2018 struct scic_sds_request **new_scic_io_request_handle)
2019{
2020 enum sci_status status = SCI_SUCCESS;
2021 struct smp_discover_response_protocols device_protocol;
2022
2023 /* Build the common part of the request */
2024 scic_sds_general_request_construct(scic, sci_dev, io_tag,
2025 user_io_request_object, sci_req);
2026
2027 if (sci_dev->rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
2028 return SCI_FAILURE_INVALID_REMOTE_DEVICE;
2029
2030 scic_remote_device_get_protocols(sci_dev, &device_protocol);
2031
2032 if (device_protocol.u.bits.attached_ssp_target) {
2033 scic_sds_ssp_io_request_assign_buffers(sci_req);
2034 } else if (device_protocol.u.bits.attached_stp_target) {
2035 scic_sds_stp_request_assign_buffers(sci_req);
2036 memset(sci_req->command_buffer, 0, sizeof(struct sata_fis_reg_h2d));
2037 } else if (device_protocol.u.bits.attached_smp_target) {
2038 scic_sds_smp_request_assign_buffers(sci_req);
2039 memset(sci_req->command_buffer, 0, sizeof(struct smp_request));
2040 } else {
2041 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
2042 }
2043
2044 if (status == SCI_SUCCESS) {
2045 memset(sci_req->task_context_buffer, 0,
2046 SCI_FIELD_OFFSET(struct scu_task_context, sgl_pair_ab));
2047 *new_scic_io_request_handle = sci_req;
2048 }
2049
2050 return status;
2051}
2052
2053enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
2054 struct scic_sds_remote_device *sci_dev,
2055 u16 io_tag,
2056 void *user_io_request_object,
2057 struct scic_sds_request *sci_req,
2058 struct scic_sds_request **new_sci_req)
2059{
2060 enum sci_status status = SCI_SUCCESS;
2061 struct smp_discover_response_protocols device_protocol;
2062
2063 /* Build the common part of the request */
2064 scic_sds_general_request_construct(scic, sci_dev, io_tag,
2065 user_io_request_object,
2066 sci_req);
2067
2068 scic_remote_device_get_protocols(sci_dev, &device_protocol);
2069
2070 if (device_protocol.u.bits.attached_ssp_target) {
2071 scic_sds_ssp_task_request_assign_buffers(sci_req);
2072
2073 sci_req->has_started_substate_machine = true;
2074
2075 /* Construct the started sub-state machine. */
2076 sci_base_state_machine_construct(
2077 &sci_req->started_substate_machine,
2078 &sci_req->parent.parent,
2079 scic_sds_io_request_started_task_mgmt_substate_table,
2080 SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
2081 );
2082 } else if (device_protocol.u.bits.attached_stp_target) {
2083 scic_sds_stp_request_assign_buffers(sci_req);
2084 } else {
2085 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
2086 }
2087
2088 if (status == SCI_SUCCESS) {
2089 sci_req->is_task_management_request = true;
2090 memset(sci_req->task_context_buffer, 0, sizeof(struct scu_task_context));
2091 *new_sci_req = sci_req;
2092 }
2093
2094 return status;
2095}
diff --git a/drivers/scsi/isci/core/scic_sds_request.h b/drivers/scsi/isci/core/scic_sds_request.h
index 06b53c3b0aa0..c54d8ef79ed8 100644
--- a/drivers/scsi/isci/core/scic_sds_request.h
+++ b/drivers/scsi/isci/core/scic_sds_request.h
@@ -256,14 +256,7 @@ struct scic_sds_io_request_state_handler {
256 256
257}; 257};
258 258
259extern const struct sci_base_state scic_sds_request_state_table[];
260extern const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[];
261
262extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[]; 259extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[];
263extern const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[];
264
265extern const struct sci_base_state scic_sds_smp_request_started_substate_table[];
266extern const struct scic_sds_io_request_state_handler scic_sds_smp_request_started_substate_handler_table[];
267 260
268/** 261/**
269 * 262 *
diff --git a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c b/drivers/scsi/isci/core/scic_sds_smp_remote_device.c
index fb832ef544e5..55202481e091 100644
--- a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_smp_remote_device.c
@@ -207,7 +207,7 @@ static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_frame_handl
207 207
208/* --------------------------------------------------------------------------- */ 208/* --------------------------------------------------------------------------- */
209 209
210const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_device_ready_substate_handler_table[] = { 210static const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_device_ready_substate_handler_table[] = {
211 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { 211 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = {
212 .parent.start_handler = scic_sds_remote_device_default_start_handler, 212 .parent.start_handler = scic_sds_remote_device_default_start_handler,
213 .parent.stop_handler = scic_sds_remote_device_ready_state_stop_handler, 213 .parent.stop_handler = scic_sds_remote_device_ready_state_stop_handler,
diff --git a/drivers/scsi/isci/core/scic_sds_smp_request.c b/drivers/scsi/isci/core/scic_sds_smp_request.c
index 962bd3994f10..84b0fdd7ed91 100644
--- a/drivers/scsi/isci/core/scic_sds_smp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_smp_request.c
@@ -142,73 +142,6 @@ void scic_sds_smp_request_assign_buffers(
142 } 142 }
143 143
144} 144}
145/**
146 * This method is called by the SCI user to build an SMP IO request.
147 *
148 * - The user must have previously called scic_io_request_construct() on the
149 * supplied IO request. Indicate if the controller successfully built the IO
150 * request. SCI_SUCCESS This value is returned if the IO request was
151 * successfully built. SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned
152 * if the remote_device does not support the SMP protocol.
153 * SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the user did not
154 * properly set the association between the SCIC IO request and the user's IO
155 * request. Please refer to the sci_object_set_association() routine for more
156 * information.
157 */
158enum sci_status scic_io_request_construct_smp(
159 struct scic_sds_request *sci_req)
160{
161 struct smp_request *smp_req = kmalloc(sizeof(*smp_req), GFP_KERNEL);
162
163 if (!smp_req)
164 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
165
166 sci_req->protocol = SCIC_SMP_PROTOCOL;
167 sci_req->has_started_substate_machine = true;
168
169 /* Construct the started sub-state machine. */
170 sci_base_state_machine_construct(
171 &sci_req->started_substate_machine,
172 &sci_req->parent.parent,
173 scic_sds_smp_request_started_substate_table,
174 SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE
175 );
176
177 /* Construct the SMP SCU Task Context */
178 memcpy(smp_req, sci_req->command_buffer, sizeof(*smp_req));
179
180 /*
181 * Look at the SMP requests' header fields; for certain SAS 1.x SMP
182 * functions under SAS 2.0, a zero request length really indicates
183 * a non-zero default length. */
184 if (smp_req->header.request_length == 0) {
185 switch (smp_req->header.function) {
186 case SMP_FUNCTION_DISCOVER:
187 case SMP_FUNCTION_REPORT_PHY_ERROR_LOG:
188 case SMP_FUNCTION_REPORT_PHY_SATA:
189 case SMP_FUNCTION_REPORT_ROUTE_INFORMATION:
190 smp_req->header.request_length = 2;
191 break;
192 case SMP_FUNCTION_CONFIGURE_ROUTE_INFORMATION:
193 case SMP_FUNCTION_PHY_CONTROL:
194 case SMP_FUNCTION_PHY_TEST:
195 smp_req->header.request_length = 9;
196 break;
197 /* Default - zero is a valid default for 2.0. */
198 }
199 }
200
201 scu_smp_request_construct_task_context(sci_req, smp_req);
202
203 sci_base_state_machine_change_state(
204 &sci_req->parent.state_machine,
205 SCI_BASE_REQUEST_STATE_CONSTRUCTED
206 );
207
208 kfree(smp_req);
209
210 return SCI_SUCCESS;
211}
212 145
213/** 146/**
214 * This method is called by the SCI user to build an SMP pass-through IO 147 * This method is called by the SCI user to build an SMP pass-through IO
@@ -595,7 +528,7 @@ static enum sci_status scic_sds_smp_request_await_tc_completion_tc_completion_ha
595} 528}
596 529
597 530
598const struct scic_sds_io_request_state_handler scic_sds_smp_request_started_substate_handler_table[] = { 531static const struct scic_sds_io_request_state_handler scic_sds_smp_request_started_substate_handler_table[] = {
599 [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = { 532 [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = {
600 .parent.start_handler = scic_sds_request_default_start_handler, 533 .parent.start_handler = scic_sds_request_default_start_handler,
601 .parent.abort_handler = scic_sds_request_started_state_abort_handler, 534 .parent.abort_handler = scic_sds_request_started_state_abort_handler,
@@ -658,7 +591,7 @@ static void scic_sds_smp_request_started_await_tc_completion_substate_enter(
658 ); 591 );
659} 592}
660 593
661const struct sci_base_state scic_sds_smp_request_started_substate_table[] = { 594static const struct sci_base_state scic_sds_smp_request_started_substate_table[] = {
662 [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = { 595 [SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE] = {
663 .enter_state = scic_sds_smp_request_started_await_response_substate_enter, 596 .enter_state = scic_sds_smp_request_started_await_response_substate_enter,
664 }, 597 },
@@ -667,3 +600,69 @@ const struct sci_base_state scic_sds_smp_request_started_substate_table[] = {
667 }, 600 },
668}; 601};
669 602
603/**
604 * This method is called by the SCI user to build an SMP IO request.
605 *
606 * - The user must have previously called scic_io_request_construct() on the
607 * supplied IO request. Indicate if the controller successfully built the IO
608 * request. SCI_SUCCESS This value is returned if the IO request was
609 * successfully built. SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned
610 * if the remote_device does not support the SMP protocol.
611 * SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the user did not
612 * properly set the association between the SCIC IO request and the user's IO
613 * request. Please refer to the sci_object_set_association() routine for more
614 * information.
615 */
616enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req)
617{
618 struct smp_request *smp_req = kmalloc(sizeof(*smp_req), GFP_KERNEL);
619
620 if (!smp_req)
621 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
622
623 sci_req->protocol = SCIC_SMP_PROTOCOL;
624 sci_req->has_started_substate_machine = true;
625
626 /* Construct the started sub-state machine. */
627 sci_base_state_machine_construct(
628 &sci_req->started_substate_machine,
629 &sci_req->parent.parent,
630 scic_sds_smp_request_started_substate_table,
631 SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE
632 );
633
634 /* Construct the SMP SCU Task Context */
635 memcpy(smp_req, sci_req->command_buffer, sizeof(*smp_req));
636
637 /*
638 * Look at the SMP requests' header fields; for certain SAS 1.x SMP
639 * functions under SAS 2.0, a zero request length really indicates
640 * a non-zero default length. */
641 if (smp_req->header.request_length == 0) {
642 switch (smp_req->header.function) {
643 case SMP_FUNCTION_DISCOVER:
644 case SMP_FUNCTION_REPORT_PHY_ERROR_LOG:
645 case SMP_FUNCTION_REPORT_PHY_SATA:
646 case SMP_FUNCTION_REPORT_ROUTE_INFORMATION:
647 smp_req->header.request_length = 2;
648 break;
649 case SMP_FUNCTION_CONFIGURE_ROUTE_INFORMATION:
650 case SMP_FUNCTION_PHY_CONTROL:
651 case SMP_FUNCTION_PHY_TEST:
652 smp_req->header.request_length = 9;
653 break;
654 /* Default - zero is a valid default for 2.0. */
655 }
656 }
657
658 scu_smp_request_construct_task_context(sci_req, smp_req);
659
660 sci_base_state_machine_change_state(
661 &sci_req->parent.state_machine,
662 SCI_BASE_REQUEST_STATE_CONSTRUCTED
663 );
664
665 kfree(smp_req);
666
667 return SCI_SUCCESS;
668}
diff --git a/drivers/scsi/isci/core/scic_sds_ssp_request.c b/drivers/scsi/isci/core/scic_sds_ssp_request.c
index a826e4bf2928..c9aa35f5cd15 100644
--- a/drivers/scsi/isci/core/scic_sds_ssp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_ssp_request.c
@@ -193,7 +193,7 @@ static enum sci_status scic_sds_ssp_task_request_await_tc_response_frame_handler
193 return SCI_SUCCESS; 193 return SCI_SUCCESS;
194} 194}
195 195
196const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = { 196static const struct scic_sds_io_request_state_handler scic_sds_ssp_task_request_started_substate_handler_table[] = {
197 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = { 197 [SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION] = {
198 .parent.start_handler = scic_sds_request_default_start_handler, 198 .parent.start_handler = scic_sds_request_default_start_handler,
199 .parent.abort_handler = scic_sds_request_started_state_abort_handler, 199 .parent.abort_handler = scic_sds_request_started_state_abort_handler,
diff --git a/drivers/scsi/isci/core/scic_sds_stp_pio_request.h b/drivers/scsi/isci/core/scic_sds_stp_pio_request.h
index 64bf40a6e1d2..d4dc118f2deb 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_pio_request.h
+++ b/drivers/scsi/isci/core/scic_sds_stp_pio_request.h
@@ -99,18 +99,7 @@ enum _SCIC_SDS_STP_REQUEST_STARTED_PIO_SUBSTATES {
99 SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE, 99 SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE,
100}; 100};
101 101
102
103/* --------------------------------------------------------------------------- */
104
105extern const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_pio_substate_handler_table[];
106
107extern const struct sci_base_state scic_sds_stp_request_started_pio_substate_table[];
108
109/* --------------------------------------------------------------------------- */
110
111struct scic_sds_stp_request; 102struct scic_sds_stp_request;
112 103
113struct scu_sgl_element *scic_sds_stp_request_pio_get_next_sgl(
114 struct scic_sds_stp_request *this_request);
115 104
116#endif /* _SCIC_SDS_SATA_PIO_REQUEST_H_ */ 105#endif /* _SCIC_SDS_SATA_PIO_REQUEST_H_ */
diff --git a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c b/drivers/scsi/isci/core/scic_sds_stp_remote_device.c
index cb396d127773..193a95fa90e1 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c
+++ b/drivers/scsi/isci/core/scic_sds_stp_remote_device.c
@@ -565,7 +565,7 @@ enum sci_status scic_sds_stp_remote_device_ready_atapi_error_substate_event_hand
565 565
566/* --------------------------------------------------------------------------- */ 566/* --------------------------------------------------------------------------- */
567 567
568const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_device_ready_substate_handler_table[] = { 568static const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_device_ready_substate_handler_table[] = {
569 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { 569 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = {
570 .parent.start_handler = scic_sds_remote_device_default_start_handler, 570 .parent.start_handler = scic_sds_remote_device_default_start_handler,
571 .parent.stop_handler = scic_sds_remote_device_ready_state_stop_handler, 571 .parent.stop_handler = scic_sds_remote_device_ready_state_stop_handler,
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.c b/drivers/scsi/isci/core/scic_sds_stp_request.c
index 8da309f81ac2..0e961e9cd6eb 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_stp_request.c
@@ -267,7 +267,7 @@ static void scu_sata_reqeust_construct_task_context(
267 * This method will perform any general sata request construction. What part of 267 * This method will perform any general sata request construction. What part of
268 * SATA IO request construction is general? none 268 * SATA IO request construction is general? none
269 */ 269 */
270void scic_sds_stp_non_ncq_request_construct( 270static void scic_sds_stp_non_ncq_request_construct(
271 struct scic_sds_request *this_request) 271 struct scic_sds_request *this_request)
272{ 272{
273 this_request->has_started_substate_machine = true; 273 this_request->has_started_substate_machine = true;
@@ -326,33 +326,6 @@ static void scic_sds_stp_optimized_request_construct(struct scic_sds_request *sc
326 * This method returns an indication as to whether the construction was 326 * This method returns an indication as to whether the construction was
327 * successful. SCI_SUCCESS Currently this method always returns this value. 327 * successful. SCI_SUCCESS Currently this method always returns this value.
328 */ 328 */
329enum sci_status scic_sds_stp_udma_request_construct(struct scic_sds_request *sci_req,
330 u32 len,
331 enum dma_data_direction dir)
332{
333 scic_sds_stp_non_ncq_request_construct(sci_req);
334
335 scic_sds_stp_optimized_request_construct(sci_req, SCU_TASK_TYPE_DMA_IN,
336 len, dir);
337
338 sci_base_state_machine_construct(
339 &sci_req->started_substate_machine,
340 &sci_req->parent.parent,
341 scic_sds_stp_request_started_udma_substate_table,
342 SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE
343 );
344
345 return SCI_SUCCESS;
346}
347
348/**
349 *
350 * @sci_req: This parameter specifies the request to be constructed.
351 *
352 * This method will construct the STP UDMA request and its associated TC data.
353 * This method returns an indication as to whether the construction was
354 * successful. SCI_SUCCESS Currently this method always returns this value.
355 */
356enum sci_status scic_sds_stp_ncq_request_construct(struct scic_sds_request *sci_req, 329enum sci_status scic_sds_stp_ncq_request_construct(struct scic_sds_request *sci_req,
357 u32 len, 330 u32 len,
358 enum dma_data_direction dir) 331 enum dma_data_direction dir)
@@ -364,7 +337,7 @@ enum sci_status scic_sds_stp_ncq_request_construct(struct scic_sds_request *sci_
364} 337}
365 338
366/** 339/**
367 * 340 * scu_stp_raw_request_construct_task_context -
368 * @this_request: This parameter specifies the STP request object for which to 341 * @this_request: This parameter specifies the STP request object for which to
369 * construct a RAW command frame task context. 342 * construct a RAW command frame task context.
370 * @task_context: This parameter specifies the SCU specific task context buffer 343 * @task_context: This parameter specifies the SCU specific task context buffer
@@ -373,7 +346,7 @@ enum sci_status scic_sds_stp_ncq_request_construct(struct scic_sds_request *sci_
373 * This method performs the operations common to all SATA/STP requests 346 * This method performs the operations common to all SATA/STP requests
374 * utilizing the raw frame method. none 347 * utilizing the raw frame method. none
375 */ 348 */
376void scu_stp_raw_request_construct_task_context( 349static void scu_stp_raw_request_construct_task_context(
377 struct scic_sds_stp_request *this_request, 350 struct scic_sds_stp_request *this_request,
378 struct scu_task_context *task_context) 351 struct scu_task_context *task_context)
379{ 352{
@@ -386,59 +359,6 @@ void scu_stp_raw_request_construct_task_context(
386 task_context->transfer_length_bytes = sizeof(struct sata_fis_reg_h2d) - sizeof(u32); 359 task_context->transfer_length_bytes = sizeof(struct sata_fis_reg_h2d) - sizeof(u32);
387} 360}
388 361
389/**
390 *
391 * @this_request: This parameter specifies the core request object to
392 * construction into an STP/SATA non-data request.
393 *
394 * This method will construct the STP Non-data request and its associated TC
395 * data. A non-data request essentially behaves like a 0 length read request
396 * in the SCU. This method currently always returns SCI_SUCCESS
397 */
398enum sci_status scic_sds_stp_non_data_request_construct(
399 struct scic_sds_request *this_request)
400{
401 scic_sds_stp_non_ncq_request_construct(this_request);
402
403 /* Build the STP task context structure */
404 scu_stp_raw_request_construct_task_context(
405 (struct scic_sds_stp_request *)this_request,
406 this_request->task_context_buffer
407 );
408
409 sci_base_state_machine_construct(
410 &this_request->started_substate_machine,
411 &this_request->parent.parent,
412 scic_sds_stp_request_started_non_data_substate_table,
413 SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE
414 );
415
416 return SCI_SUCCESS;
417}
418
419
420enum sci_status scic_sds_stp_soft_reset_request_construct(
421 struct scic_sds_request *this_request)
422{
423 scic_sds_stp_non_ncq_request_construct(this_request);
424
425 /* Build the STP task context structure */
426 scu_stp_raw_request_construct_task_context(
427 (struct scic_sds_stp_request *)this_request,
428 this_request->task_context_buffer
429 );
430
431 sci_base_state_machine_construct(
432 &this_request->started_substate_machine,
433 &this_request->parent.parent,
434 scic_sds_stp_request_started_soft_reset_substate_table,
435 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE
436 );
437
438 return SCI_SUCCESS;
439}
440
441
442void scic_stp_io_request_set_ncq_tag( 362void scic_stp_io_request_set_ncq_tag(
443 struct scic_sds_request *req, 363 struct scic_sds_request *req,
444 u16 ncq_tag) 364 u16 ncq_tag)
@@ -474,7 +394,7 @@ void *scic_stp_io_request_get_d2h_reg_address(
474 * - if there are more SGL element pairs - advance to the next pair and return 394 * - if there are more SGL element pairs - advance to the next pair and return
475 * element A struct scu_sgl_element* 395 * element A struct scu_sgl_element*
476 */ 396 */
477struct scu_sgl_element *scic_sds_stp_request_pio_get_next_sgl(struct scic_sds_stp_request *stp_req) 397static struct scu_sgl_element *scic_sds_stp_request_pio_get_next_sgl(struct scic_sds_stp_request *stp_req)
478{ 398{
479 struct scu_sgl_element *current_sgl; 399 struct scu_sgl_element *current_sgl;
480 struct scic_sds_request *sci_req = &stp_req->parent; 400 struct scic_sds_request *sci_req = &stp_req->parent;
@@ -510,60 +430,6 @@ struct scu_sgl_element *scic_sds_stp_request_pio_get_next_sgl(struct scic_sds_st
510 430
511/** 431/**
512 * 432 *
513 * @scic_io_request: The core request object which is cast to a SATA PIO
514 * request object.
515 *
516 * This method will construct the SATA PIO request. This method returns an
517 * indication as to whether the construction was successful. SCI_SUCCESS
518 * Currently this method always returns this value.
519 */
520enum sci_status scic_sds_stp_pio_request_construct(
521 struct scic_sds_request *scic_io_request,
522 u8 sat_protocol,
523 bool copy_rx_frame)
524{
525 struct scic_sds_stp_request *this_request;
526
527 this_request = (struct scic_sds_stp_request *)scic_io_request;
528
529 scic_sds_stp_non_ncq_request_construct(&this_request->parent);
530
531 scu_stp_raw_request_construct_task_context(
532 this_request, this_request->parent.task_context_buffer
533 );
534
535 this_request->type.pio.current_transfer_bytes = 0;
536 this_request->type.pio.ending_error = 0;
537 this_request->type.pio.ending_status = 0;
538
539 this_request->type.pio.request_current.sgl_offset = 0;
540 this_request->type.pio.request_current.sgl_set = SCU_SGL_ELEMENT_PAIR_A;
541 this_request->type.pio.sat_protocol = sat_protocol;
542
543 if (copy_rx_frame) {
544 scic_sds_request_build_sgl(&this_request->parent);
545 /*
546 * Since the IO request copy of the TC contains the same data as
547 * the actual TC this pointer is vaild for either. */
548 this_request->type.pio.request_current.sgl_pair =
549 &this_request->parent.task_context_buffer->sgl_pair_ab;
550 } else {
551 /* The user does not want the data copied to the SGL buffer location */
552 this_request->type.pio.request_current.sgl_pair = NULL;
553 }
554
555 sci_base_state_machine_construct(
556 &this_request->parent.started_substate_machine,
557 &this_request->parent.parent.parent,
558 scic_sds_stp_request_started_pio_substate_table,
559 SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE
560 );
561
562 return SCI_SUCCESS;
563}
564
565/**
566 *
567 * @this_request: 433 * @this_request:
568 * @completion_code: 434 * @completion_code:
569 * 435 *
@@ -689,7 +555,7 @@ static enum sci_status scic_sds_stp_request_non_data_await_d2h_frame_handler(
689 555
690/* --------------------------------------------------------------------------- */ 556/* --------------------------------------------------------------------------- */
691 557
692const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_non_data_substate_handler_table[] = { 558static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_non_data_substate_handler_table[] = {
693 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = { 559 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = {
694 .parent.start_handler = scic_sds_request_default_start_handler, 560 .parent.start_handler = scic_sds_request_default_start_handler,
695 .parent.abort_handler = scic_sds_request_started_state_abort_handler, 561 .parent.abort_handler = scic_sds_request_started_state_abort_handler,
@@ -740,7 +606,7 @@ static void scic_sds_stp_request_started_non_data_await_d2h_enter(
740 606
741/* --------------------------------------------------------------------------- */ 607/* --------------------------------------------------------------------------- */
742 608
743const struct sci_base_state scic_sds_stp_request_started_non_data_substate_table[] = { 609static const struct sci_base_state scic_sds_stp_request_started_non_data_substate_table[] = {
744 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = { 610 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE] = {
745 .enter_state = scic_sds_stp_request_started_non_data_await_h2d_completion_enter, 611 .enter_state = scic_sds_stp_request_started_non_data_await_h2d_completion_enter,
746 }, 612 },
@@ -749,6 +615,23 @@ const struct sci_base_state scic_sds_stp_request_started_non_data_substate_table
749 }, 615 },
750}; 616};
751 617
618enum sci_status scic_sds_stp_non_data_request_construct(struct scic_sds_request *sci_req)
619{
620 struct scic_sds_stp_request *stp_req = container_of(sci_req, typeof(*stp_req), parent);
621
622 scic_sds_stp_non_ncq_request_construct(sci_req);
623
624 /* Build the STP task context structure */
625 scu_stp_raw_request_construct_task_context(stp_req, sci_req->task_context_buffer);
626
627 sci_base_state_machine_construct(&sci_req->started_substate_machine,
628 &sci_req->parent.parent,
629 scic_sds_stp_request_started_non_data_substate_table,
630 SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE);
631
632 return SCI_SUCCESS;
633}
634
752#define SCU_MAX_FRAME_BUFFER_SIZE 0x400 /* 1K is the maximum SCU frame data payload */ 635#define SCU_MAX_FRAME_BUFFER_SIZE 0x400 /* 1K is the maximum SCU frame data payload */
753 636
754/** 637/**
@@ -1330,7 +1213,7 @@ static enum sci_status scic_sds_stp_request_pio_data_in_await_data_event_handler
1330 1213
1331/* --------------------------------------------------------------------------- */ 1214/* --------------------------------------------------------------------------- */
1332 1215
1333const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_pio_substate_handler_table[] = { 1216static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_pio_substate_handler_table[] = {
1334 [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = { 1217 [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = {
1335 .parent.start_handler = scic_sds_request_default_start_handler, 1218 .parent.start_handler = scic_sds_request_default_start_handler,
1336 .parent.abort_handler = scic_sds_request_started_state_abort_handler, 1219 .parent.abort_handler = scic_sds_request_started_state_abort_handler,
@@ -1422,7 +1305,7 @@ static void scic_sds_stp_request_started_pio_data_out_transmit_data_enter(
1422 1305
1423/* --------------------------------------------------------------------------- */ 1306/* --------------------------------------------------------------------------- */
1424 1307
1425const struct sci_base_state scic_sds_stp_request_started_pio_substate_table[] = { 1308static const struct sci_base_state scic_sds_stp_request_started_pio_substate_table[] = {
1426 [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = { 1309 [SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE] = {
1427 .enter_state = scic_sds_stp_request_started_pio_await_h2d_completion_enter, 1310 .enter_state = scic_sds_stp_request_started_pio_await_h2d_completion_enter,
1428 }, 1311 },
@@ -1437,6 +1320,45 @@ const struct sci_base_state scic_sds_stp_request_started_pio_substate_table[] =
1437 } 1320 }
1438}; 1321};
1439 1322
1323enum sci_status scic_sds_stp_pio_request_construct(struct scic_sds_request *sci_req,
1324 u8 sat_protocol,
1325 bool copy_rx_frame)
1326{
1327 struct scic_sds_stp_request *stp_req = container_of(sci_req, typeof(*stp_req), parent);
1328 struct scic_sds_stp_pio_request *pio = &stp_req->type.pio;
1329
1330 scic_sds_stp_non_ncq_request_construct(sci_req);
1331
1332 scu_stp_raw_request_construct_task_context(stp_req,
1333 sci_req->task_context_buffer);
1334
1335 pio->current_transfer_bytes = 0;
1336 pio->ending_error = 0;
1337 pio->ending_status = 0;
1338
1339 pio->request_current.sgl_offset = 0;
1340 pio->request_current.sgl_set = SCU_SGL_ELEMENT_PAIR_A;
1341 pio->sat_protocol = sat_protocol;
1342
1343 if (copy_rx_frame) {
1344 scic_sds_request_build_sgl(sci_req);
1345 /* Since the IO request copy of the TC contains the same data as
1346 * the actual TC this pointer is vaild for either.
1347 */
1348 pio->request_current.sgl_pair = &sci_req->task_context_buffer->sgl_pair_ab;
1349 } else {
1350 /* The user does not want the data copied to the SGL buffer location */
1351 pio->request_current.sgl_pair = NULL;
1352 }
1353
1354 sci_base_state_machine_construct(&sci_req->started_substate_machine,
1355 &sci_req->parent.parent,
1356 scic_sds_stp_request_started_pio_substate_table,
1357 SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE);
1358
1359 return SCI_SUCCESS;
1360}
1361
1440static void scic_sds_stp_request_udma_complete_request( 1362static void scic_sds_stp_request_udma_complete_request(
1441 struct scic_sds_request *this_request, 1363 struct scic_sds_request *this_request,
1442 u32 scu_status, 1364 u32 scu_status,
@@ -1594,7 +1516,7 @@ static enum sci_status scic_sds_stp_request_udma_await_d2h_reg_fis_frame_handler
1594 1516
1595/* --------------------------------------------------------------------------- */ 1517/* --------------------------------------------------------------------------- */
1596 1518
1597const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_udma_substate_handler_table[] = { 1519static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_udma_substate_handler_table[] = {
1598 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = { 1520 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = {
1599 .parent.start_handler = scic_sds_request_default_start_handler, 1521 .parent.start_handler = scic_sds_request_default_start_handler,
1600 .parent.abort_handler = scic_sds_request_started_state_abort_handler, 1522 .parent.abort_handler = scic_sds_request_started_state_abort_handler,
@@ -1648,7 +1570,7 @@ static void scic_sds_stp_request_started_udma_await_d2h_reg_fis_enter(
1648 1570
1649/* --------------------------------------------------------------------------- */ 1571/* --------------------------------------------------------------------------- */
1650 1572
1651const struct sci_base_state scic_sds_stp_request_started_udma_substate_table[] = { 1573static const struct sci_base_state scic_sds_stp_request_started_udma_substate_table[] = {
1652 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = { 1574 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE] = {
1653 .enter_state = scic_sds_stp_request_started_udma_await_tc_completion_enter, 1575 .enter_state = scic_sds_stp_request_started_udma_await_tc_completion_enter,
1654 }, 1576 },
@@ -1657,6 +1579,25 @@ const struct sci_base_state scic_sds_stp_request_started_udma_substate_table[] =
1657 }, 1579 },
1658}; 1580};
1659 1581
1582enum sci_status scic_sds_stp_udma_request_construct(struct scic_sds_request *sci_req,
1583 u32 len,
1584 enum dma_data_direction dir)
1585{
1586 scic_sds_stp_non_ncq_request_construct(sci_req);
1587
1588 scic_sds_stp_optimized_request_construct(sci_req, SCU_TASK_TYPE_DMA_IN,
1589 len, dir);
1590
1591 sci_base_state_machine_construct(
1592 &sci_req->started_substate_machine,
1593 &sci_req->parent.parent,
1594 scic_sds_stp_request_started_udma_substate_table,
1595 SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE
1596 );
1597
1598 return SCI_SUCCESS;
1599}
1600
1660/** 1601/**
1661 * 1602 *
1662 * @this_request: 1603 * @this_request:
@@ -1831,7 +1772,7 @@ static enum sci_status scic_sds_stp_request_soft_reset_await_d2h_frame_handler(
1831 1772
1832/* --------------------------------------------------------------------------- */ 1773/* --------------------------------------------------------------------------- */
1833 1774
1834const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_soft_reset_substate_handler_table[] = { 1775static const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_soft_reset_substate_handler_table[] = {
1835 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = { 1776 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = {
1836 .parent.start_handler = scic_sds_request_default_start_handler, 1777 .parent.start_handler = scic_sds_request_default_start_handler,
1837 .parent.abort_handler = scic_sds_request_started_state_abort_handler, 1778 .parent.abort_handler = scic_sds_request_started_state_abort_handler,
@@ -1925,9 +1866,7 @@ static void scic_sds_stp_request_started_soft_reset_await_d2h_response_enter(
1925 ); 1866 );
1926} 1867}
1927 1868
1928/* --------------------------------------------------------------------------- */ 1869static const struct sci_base_state scic_sds_stp_request_started_soft_reset_substate_table[] = {
1929
1930const struct sci_base_state scic_sds_stp_request_started_soft_reset_substate_table[] = {
1931 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = { 1870 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE] = {
1932 .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter, 1871 .enter_state = scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter,
1933 }, 1872 },
@@ -1939,3 +1878,19 @@ const struct sci_base_state scic_sds_stp_request_started_soft_reset_substate_tab
1939 }, 1878 },
1940}; 1879};
1941 1880
1881enum sci_status scic_sds_stp_soft_reset_request_construct(struct scic_sds_request *sci_req)
1882{
1883 struct scic_sds_stp_request *stp_req = container_of(sci_req, typeof(*stp_req), parent);
1884
1885 scic_sds_stp_non_ncq_request_construct(sci_req);
1886
1887 /* Build the STP task context structure */
1888 scu_stp_raw_request_construct_task_context(stp_req, sci_req->task_context_buffer);
1889
1890 sci_base_state_machine_construct(&sci_req->started_substate_machine,
1891 &sci_req->parent.parent,
1892 scic_sds_stp_request_started_soft_reset_substate_table,
1893 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE);
1894
1895 return SCI_SUCCESS;
1896}
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.h b/drivers/scsi/isci/core/scic_sds_stp_request.h
index c950bb33ee04..107487978f06 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_request.h
+++ b/drivers/scsi/isci/core/scic_sds_stp_request.h
@@ -76,7 +76,7 @@ struct scic_sds_stp_request {
76 76
77 u32 udma; 77 u32 udma;
78 78
79 struct { 79 struct scic_sds_stp_pio_request {
80 /** 80 /**
81 * Total transfer for the entire PIO request recorded at request constuction 81 * Total transfer for the entire PIO request recorded at request constuction
82 * time. 82 * time.
@@ -169,26 +169,8 @@ enum SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_SUBSTATES {
169 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, 169 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE,
170}; 170};
171 171
172extern const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_udma_substate_handler_table[];
173
174extern const struct sci_base_state scic_sds_stp_request_started_udma_substate_table[];
175
176extern const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_non_data_substate_handler_table[];
177
178extern const struct sci_base_state scic_sds_stp_request_started_non_data_substate_table[];
179
180extern const struct scic_sds_io_request_state_handler scic_sds_stp_request_started_soft_reset_substate_handler_table[];
181
182extern const struct sci_base_state scic_sds_stp_request_started_soft_reset_substate_table[];
183
184/* --------------------------------------------------------------------------- */
185
186u32 scic_sds_stp_request_get_object_size(void); 172u32 scic_sds_stp_request_get_object_size(void);
187 173
188
189void scic_sds_stp_non_ncq_request_construct(
190 struct scic_sds_request *this_request);
191
192enum sci_status scic_sds_stp_pio_request_construct( 174enum sci_status scic_sds_stp_pio_request_construct(
193 struct scic_sds_request *scic_io_request, 175 struct scic_sds_request *scic_io_request,
194 u8 sat_protocol, 176 u8 sat_protocol,
@@ -214,8 +196,5 @@ enum sci_status scic_sds_stp_ncq_request_construct(
214 u32 transfer_length, 196 u32 transfer_length,
215 enum dma_data_direction dir); 197 enum dma_data_direction dir);
216 198
217void scu_stp_raw_request_construct_task_context(
218 struct scic_sds_stp_request *this_request,
219 struct scu_task_context *task_context);
220 199
221#endif /* _SCIC_SDS_STP_REQUEST_T_ */ 200#endif /* _SCIC_SDS_STP_REQUEST_T_ */
diff --git a/drivers/scsi/isci/firmware/README b/drivers/scsi/isci/firmware/README
index cf7e4286e896..8056d2bd233b 100644
--- a/drivers/scsi/isci/firmware/README
+++ b/drivers/scsi/isci/firmware/README
@@ -32,5 +32,5 @@ Header Type - u8: 0xf
32============================================================================== 32==============================================================================
33 33
34Place isci_firmware.bin in /lib/firmware 34Place isci_firmware.bin in /lib/firmware
35Be sure to recreate the initramfs image to include the firmware. 35Be sure to recreate the initramfs image to include the firmware.
36 36
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index 666076a2834e..74dc96dc6b17 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -201,7 +201,7 @@ void isci_port_link_up(
201 call_status = scic_sata_phy_get_properties(phy, 201 call_status = scic_sata_phy_get_properties(phy,
202 &sata_phy_properties); 202 &sata_phy_properties);
203 203
204 /* 204 /*
205 * XXX I am concerned about this "assert". shouldn't we 205 * XXX I am concerned about this "assert". shouldn't we
206 * handle the return appropriately? 206 * handle the return appropriately?
207 */ 207 */
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index eba8e0b3c873..c6ce9d0c50c2 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -1263,47 +1263,6 @@ enum dma_data_direction isci_request_io_request_get_data_direction(
1263 * 1263 *
1264 * physical address in the specified sge. 1264 * physical address in the specified sge.
1265 */ 1265 */
1266dma_addr_t isci_request_sge_get_address_field(
1267 struct isci_request *request,
1268 void *sge_address)
1269{
1270 struct sas_task *task = isci_request_access_task(request);
1271 dma_addr_t ret;
1272 struct isci_host *isci_host = isci_host_from_sas_ha(
1273 task->dev->port->ha);
1274
1275 dev_dbg(&isci_host->pdev->dev,
1276 "%s: request = %p, sge_address = %p\n",
1277 __func__,
1278 request,
1279 sge_address);
1280
1281 if (task->data_dir == PCI_DMA_NONE)
1282 return 0;
1283
1284 /* the case where num_scatter == 0 is special, in that
1285 * task->scatter is the actual buffer address, not an sgl.
1286 * so a map single is required here.
1287 */
1288 if ((task->num_scatter == 0) &&
1289 !sas_protocol_ata(task->task_proto)) {
1290 ret = dma_map_single(
1291 &isci_host->pdev->dev,
1292 task->scatter,
1293 task->total_xfer_len,
1294 task->data_dir
1295 );
1296 request->zero_scatter_daddr = ret;
1297 } else
1298 ret = sg_dma_address(((struct scatterlist *)sge_address));
1299
1300 dev_dbg(&isci_host->pdev->dev,
1301 "%s: bus address = %lx\n",
1302 __func__,
1303 (unsigned long)ret);
1304
1305 return ret;
1306}
1307 1266
1308 1267
1309/** 1268/**
@@ -1314,38 +1273,6 @@ dma_addr_t isci_request_sge_get_address_field(
1314 * 1273 *
1315 * length field value in the specified sge. 1274 * length field value in the specified sge.
1316 */ 1275 */
1317u32 isci_request_sge_get_length_field(
1318 struct isci_request *request,
1319 void *sge_address)
1320{
1321 struct sas_task *task = isci_request_access_task(request);
1322 int ret;
1323
1324 dev_dbg(&request->isci_host->pdev->dev,
1325 "%s: request = %p, sge_address = %p\n",
1326 __func__,
1327 request,
1328 sge_address);
1329
1330 if (task->data_dir == PCI_DMA_NONE)
1331 return 0;
1332
1333 /* the case where num_scatter == 0 is special, in that
1334 * task->scatter is the actual buffer address, not an sgl.
1335 * so we return total_xfer_len here.
1336 */
1337 if (task->num_scatter == 0)
1338 ret = task->total_xfer_len;
1339 else
1340 ret = sg_dma_len((struct scatterlist *)sge_address);
1341
1342 dev_dbg(&request->isci_host->pdev->dev,
1343 "%s: len = %d\n",
1344 __func__,
1345 ret);
1346
1347 return ret;
1348}
1349 1276
1350 1277
1351/** 1278/**
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h
index b45c0f1f057f..4a63bb6de44e 100644
--- a/drivers/scsi/isci/request.h
+++ b/drivers/scsi/isci/request.h
@@ -391,13 +391,7 @@ static inline void *isci_request_io_request_get_next_sge(
391 return ret; 391 return ret;
392} 392}
393 393
394dma_addr_t isci_request_sge_get_address_field(
395 struct isci_request *request,
396 void *sge_address);
397 394
398u32 isci_request_sge_get_length_field(
399 struct isci_request *request,
400 void *sge_address);
401 395
402void *isci_request_ssp_io_request_get_cdb_address( 396void *isci_request_ssp_io_request_get_cdb_address(
403 struct isci_request *request); 397 struct isci_request *request);
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index d48368002504..7e9668402559 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -588,7 +588,7 @@ void isci_task_build_tmf(
588 tmf->cb_data = cb_data; 588 tmf->cb_data = cb_data;
589} 589}
590 590
591void isci_task_build_abort_task_tmf( 591static void isci_task_build_abort_task_tmf(
592 struct isci_tmf *tmf, 592 struct isci_tmf *tmf,
593 struct isci_remote_device *isci_device, 593 struct isci_remote_device *isci_device,
594 enum isci_tmf_function_codes code, 594 enum isci_tmf_function_codes code,
@@ -1528,15 +1528,6 @@ void isci_task_request_complete(
1528 * 1528 *
1529 * lun for specified task request. 1529 * lun for specified task request.
1530 */ 1530 */
1531u32 isci_task_ssp_request_get_lun(struct isci_request *request)
1532{
1533 struct isci_tmf *isci_tmf = isci_request_access_tmf(request);
1534
1535 dev_dbg(&request->isci_host->pdev->dev,
1536 "%s: lun = %d\n", __func__, isci_tmf->lun[0]);
1537/* @todo: build lun from array of bytes to 32 bit */
1538 return isci_tmf->lun[0];
1539}
1540 1531
1541/** 1532/**
1542 * isci_task_ssp_request_get_function() - This function is called by the sci 1533 * isci_task_ssp_request_get_function() - This function is called by the sci
diff --git a/drivers/scsi/isci/task.h b/drivers/scsi/isci/task.h
index 9754b43f5b0b..d7cb6fe268c4 100644
--- a/drivers/scsi/isci/task.h
+++ b/drivers/scsi/isci/task.h
@@ -202,8 +202,6 @@ u16 isci_task_ssp_request_get_io_tag_to_manage(
202u8 isci_task_ssp_request_get_function( 202u8 isci_task_ssp_request_get_function(
203 struct isci_request *request); 203 struct isci_request *request);
204 204
205u32 isci_task_ssp_request_get_lun(
206 struct isci_request *request);
207 205
208void *isci_task_ssp_request_get_response_data_address( 206void *isci_task_ssp_request_get_response_data_address(
209 struct isci_request *request); 207 struct isci_request *request);
@@ -226,14 +224,6 @@ void isci_task_build_tmf(
226 void *), 224 void *),
227 void *cb_data); 225 void *cb_data);
228 226
229void isci_task_build_abort_task_tmf(
230 struct isci_tmf *tmf,
231 struct isci_remote_device *isci_device,
232 enum isci_tmf_function_codes code,
233 void (*tmf_sent_cb)(
234 enum isci_tmf_cb_state,
235 struct isci_tmf *, void *),
236 struct isci_request *old_request);
237 227
238int isci_task_execute_tmf( 228int isci_task_execute_tmf(
239 struct isci_host *isci_host, 229 struct isci_host *isci_host,