Commit | Line | Data |
---|---|---|
6f231dda DW |
1 | /* |
2 | * This file is provided under a dual BSD/GPLv2 license. When using or | |
3 | * redistributing this file, you may do so under either license. | |
4 | * | |
5 | * GPL LICENSE SUMMARY | |
6 | * | |
7 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of version 2 of the GNU General Public License as | |
11 | * published by the Free Software Foundation. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
21 | * The full GNU General Public License is included in this distribution | |
22 | * in the file called LICENSE.GPL. | |
23 | * | |
24 | * BSD LICENSE | |
25 | * | |
26 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. | |
27 | * All rights reserved. | |
28 | * | |
29 | * Redistribution and use in source and binary forms, with or without | |
30 | * modification, are permitted provided that the following conditions | |
31 | * are met: | |
32 | * | |
33 | * * Redistributions of source code must retain the above copyright | |
34 | * notice, this list of conditions and the following disclaimer. | |
35 | * * Redistributions in binary form must reproduce the above copyright | |
36 | * notice, this list of conditions and the following disclaimer in | |
37 | * the documentation and/or other materials provided with the | |
38 | * distribution. | |
39 | * * Neither the name of Intel Corporation nor the names of its | |
40 | * contributors may be used to endorse or promote products derived | |
41 | * from this software without specific prior written permission. | |
42 | * | |
43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
44 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
45 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
46 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
47 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
48 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
49 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
54 | */ | |
55 | ||
88f3b62a | 56 | #ifndef _ISCI_REMOTE_DEVICE_H_ |
6f231dda | 57 | #define _ISCI_REMOTE_DEVICE_H_ |
88f3b62a DW |
58 | #include <scsi/libsas.h> |
59 | #include "sci_status.h" | |
60 | #include "intel_sas.h" | |
61 | #include "scu_remote_node_context.h" | |
62 | #include "remote_node_context.h" | |
63 | #include "port.h" | |
6f231dda | 64 | |
88f3b62a DW |
65 | enum scic_remote_device_not_ready_reason_code { |
66 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED, | |
67 | SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED, | |
68 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, | |
69 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, | |
70 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, | |
71 | ||
72 | SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX | |
73 | ||
74 | }; | |
75 | ||
76 | struct scic_sds_remote_device { | |
88f3b62a DW |
77 | /** |
78 | * This field contains the information for the base remote device state | |
79 | * machine. | |
80 | */ | |
81 | struct sci_base_state_machine state_machine; | |
82 | ||
83 | /** | |
84 | * This field is the programmed device port width. This value is | |
85 | * written to the RCN data structure to tell the SCU how many open | |
86 | * connections this device can have. | |
87 | */ | |
88 | u32 device_port_width; | |
89 | ||
90 | /** | |
91 | * This field is the programmed connection rate for this remote device. It is | |
92 | * used to program the TC with the maximum allowed connection rate. | |
93 | */ | |
94 | enum sas_linkrate connection_rate; | |
95 | ||
88f3b62a DW |
96 | /** |
97 | * This filed is assinged the value of true if the device is directly | |
98 | * attached to the port. | |
99 | */ | |
100 | bool is_direct_attached; | |
101 | ||
88f3b62a DW |
102 | /** |
103 | * This filed contains a pointer back to the port to which this device | |
104 | * is assigned. | |
105 | */ | |
106 | struct scic_sds_port *owning_port; | |
107 | ||
108 | /** | |
109 | * This field contains the SCU silicon remote node context specific | |
110 | * information. | |
111 | */ | |
112 | struct scic_sds_remote_node_context rnc; | |
113 | ||
114 | /** | |
115 | * This field contains the stated request count for the remote device. The | |
116 | * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all | |
117 | * requests are complete and the rnc_posted value is false. | |
118 | */ | |
119 | u32 started_request_count; | |
120 | ||
121 | /** | |
122 | * This field contains a pointer to the working request object. It is only | |
123 | * used only for SATA requests since the unsolicited frames we get from the | |
124 | * hardware have no Tag value to look up the io request object. | |
125 | */ | |
126 | struct scic_sds_request *working_request; | |
127 | ||
128 | /** | |
129 | * This field contains the reason for the remote device going not_ready. It is | |
130 | * assigned in the state handlers and used in the state transition. | |
131 | */ | |
132 | u32 not_ready_reason; | |
133 | ||
134 | /** | |
135 | * This field is true if this remote device has an initialzied ready substate | |
136 | * machine. SSP devices do not have a ready substate machine and STP devices | |
137 | * have a ready substate machine. | |
138 | */ | |
139 | bool has_ready_substate_machine; | |
140 | ||
141 | /** | |
142 | * This field contains the state machine for the ready substate machine for | |
143 | * this struct scic_sds_remote_device object. | |
144 | */ | |
145 | struct sci_base_state_machine ready_substate_machine; | |
146 | ||
147 | /** | |
148 | * This field maintains the set of state handlers for the remote device | |
149 | * object. These are changed each time the remote device enters a new state. | |
150 | */ | |
151 | const struct scic_sds_remote_device_state_handler *state_handlers; | |
152 | }; | |
6f231dda DW |
153 | |
154 | struct isci_remote_device { | |
6f231dda | 155 | enum isci_status status; |
6ad31fec DW |
156 | #define IDEV_START_PENDING 0 |
157 | #define IDEV_STOP_PENDING 1 | |
d9c37390 | 158 | #define IDEV_ALLOCATED 2 |
6ad31fec | 159 | unsigned long flags; |
6f231dda DW |
160 | struct isci_port *isci_port; |
161 | struct domain_device *domain_dev; | |
6f231dda DW |
162 | struct list_head node; |
163 | struct list_head reqs_in_process; | |
6f231dda | 164 | spinlock_t state_lock; |
57f20f4e | 165 | struct scic_sds_remote_device sci; |
6f231dda DW |
166 | }; |
167 | ||
6f231dda DW |
168 | #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 |
169 | ||
6ad31fec DW |
170 | enum sci_status isci_remote_device_stop(struct isci_host *ihost, |
171 | struct isci_remote_device *idev); | |
4393aa4e DW |
172 | void isci_remote_device_nuke_requests(struct isci_host *ihost, |
173 | struct isci_remote_device *idev); | |
037afc78 DW |
174 | void isci_remote_device_ready(struct isci_host *ihost, |
175 | struct isci_remote_device *idev); | |
037afc78 DW |
176 | void isci_remote_device_not_ready(struct isci_host *ihost, |
177 | struct isci_remote_device *idev, u32 reason); | |
4393aa4e DW |
178 | void isci_remote_device_gone(struct domain_device *domain_dev); |
179 | int isci_remote_device_found(struct domain_device *domain_dev); | |
180 | bool isci_device_is_reset_pending(struct isci_host *ihost, | |
181 | struct isci_remote_device *idev); | |
182 | void isci_device_clear_reset_pending(struct isci_host *ihost, | |
183 | struct isci_remote_device *idev); | |
184 | void isci_remote_device_change_state(struct isci_remote_device *idev, | |
185 | enum isci_status status); | |
88f3b62a DW |
186 | /** |
187 | * scic_remote_device_stop() - This method will stop both transmission and | |
188 | * reception of link activity for the supplied remote device. This method | |
189 | * disables normal IO requests from flowing through to the remote device. | |
190 | * @remote_device: This parameter specifies the device to be stopped. | |
191 | * @timeout: This parameter specifies the number of milliseconds in which the | |
192 | * stop operation should complete. | |
193 | * | |
194 | * An indication of whether the device was successfully stopped. SCI_SUCCESS | |
195 | * This value is returned if the transmission and reception for the device was | |
196 | * successfully stopped. | |
197 | */ | |
198 | enum sci_status scic_remote_device_stop( | |
199 | struct scic_sds_remote_device *remote_device, | |
200 | u32 timeout); | |
201 | ||
202 | /** | |
203 | * scic_remote_device_reset() - This method will reset the device making it | |
204 | * ready for operation. This method must be called anytime the device is | |
205 | * reset either through a SMP phy control or a port hard reset request. | |
206 | * @remote_device: This parameter specifies the device to be reset. | |
207 | * | |
208 | * This method does not actually cause the device hardware to be reset. This | |
209 | * method resets the software object so that it will be operational after a | |
210 | * device hardware reset completes. An indication of whether the device reset | |
211 | * was accepted. SCI_SUCCESS This value is returned if the device reset is | |
212 | * started. | |
213 | */ | |
214 | enum sci_status scic_remote_device_reset( | |
215 | struct scic_sds_remote_device *remote_device); | |
216 | ||
217 | /** | |
218 | * scic_remote_device_reset_complete() - This method informs the device object | |
219 | * that the reset operation is complete and the device can resume operation | |
220 | * again. | |
221 | * @remote_device: This parameter specifies the device which is to be informed | |
222 | * of the reset complete operation. | |
223 | * | |
224 | * An indication that the device is resuming operation. SCI_SUCCESS the device | |
225 | * is resuming operation. | |
226 | */ | |
227 | enum sci_status scic_remote_device_reset_complete( | |
228 | struct scic_sds_remote_device *remote_device); | |
229 | ||
230 | ||
231 | ||
232 | /** | |
233 | * scic_remote_device_get_connection_rate() - This method simply returns the | |
234 | * link rate at which communications to the remote device occur. | |
235 | * @remote_device: This parameter specifies the device for which to get the | |
236 | * connection rate. | |
237 | * | |
238 | * Return the link rate at which we transfer for the supplied remote device. | |
239 | */ | |
240 | enum sas_linkrate scic_remote_device_get_connection_rate( | |
241 | struct scic_sds_remote_device *remote_device); | |
242 | ||
88f3b62a | 243 | #define scic_remote_device_is_atapi(device_handle) false |
88f3b62a DW |
244 | |
245 | /** | |
246 | * enum scic_sds_remote_device_states - This enumeration depicts all the states | |
247 | * for the common remote device state machine. | |
248 | * | |
249 | * | |
250 | */ | |
251 | enum scic_sds_remote_device_states { | |
252 | /** | |
253 | * Simply the initial state for the base remote device state machine. | |
254 | */ | |
255 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL, | |
256 | ||
257 | /** | |
258 | * This state indicates that the remote device has successfully been | |
259 | * stopped. In this state no new IO operations are permitted. | |
260 | * This state is entered from the INITIAL state. | |
261 | * This state is entered from the STOPPING state. | |
262 | */ | |
263 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPED, | |
264 | ||
265 | /** | |
266 | * This state indicates the the remote device is in the process of | |
267 | * becoming ready (i.e. starting). In this state no new IO operations | |
268 | * are permitted. | |
269 | * This state is entered from the STOPPED state. | |
270 | */ | |
271 | SCI_BASE_REMOTE_DEVICE_STATE_STARTING, | |
272 | ||
273 | /** | |
274 | * This state indicates the remote device is now ready. Thus, the user | |
275 | * is able to perform IO operations on the remote device. | |
276 | * This state is entered from the STARTING state. | |
277 | */ | |
278 | SCI_BASE_REMOTE_DEVICE_STATE_READY, | |
279 | ||
280 | /** | |
281 | * This state indicates that the remote device is in the process of | |
282 | * stopping. In this state no new IO operations are permitted, but | |
283 | * existing IO operations are allowed to complete. | |
284 | * This state is entered from the READY state. | |
285 | * This state is entered from the FAILED state. | |
286 | */ | |
287 | SCI_BASE_REMOTE_DEVICE_STATE_STOPPING, | |
288 | ||
289 | /** | |
290 | * This state indicates that the remote device has failed. | |
291 | * In this state no new IO operations are permitted. | |
292 | * This state is entered from the INITIALIZING state. | |
293 | * This state is entered from the READY state. | |
294 | */ | |
295 | SCI_BASE_REMOTE_DEVICE_STATE_FAILED, | |
296 | ||
297 | /** | |
298 | * This state indicates the device is being reset. | |
299 | * In this state no new IO operations are permitted. | |
300 | * This state is entered from the READY state. | |
301 | */ | |
302 | SCI_BASE_REMOTE_DEVICE_STATE_RESETTING, | |
303 | ||
304 | /** | |
305 | * Simply the final state for the base remote device state machine. | |
306 | */ | |
307 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL, | |
308 | }; | |
309 | ||
310 | /** | |
311 | * enum scic_sds_ssp_remote_device_ready_substates - | |
312 | * | |
313 | * This is the enumeration of the ready substates for the | |
314 | * struct scic_sds_remote_device. | |
315 | */ | |
316 | enum scic_sds_ssp_remote_device_ready_substates { | |
317 | /** | |
318 | * This is the initial state for the remote device ready substate. | |
319 | */ | |
320 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL, | |
321 | ||
322 | /** | |
323 | * This is the ready operational substate for the remote device. | |
324 | * This is the normal operational state for a remote device. | |
325 | */ | |
326 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL, | |
327 | ||
328 | /** | |
329 | * This is the suspended state for the remote device. This is the state | |
330 | * that the device is placed in when a RNC suspend is received by | |
331 | * the SCU hardware. | |
332 | */ | |
333 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED, | |
334 | ||
335 | /** | |
336 | * This is the final state that the device is placed in before a change | |
337 | * to the base state machine. | |
338 | */ | |
339 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL, | |
340 | ||
341 | SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES | |
342 | }; | |
343 | ||
344 | /** | |
345 | * enum scic_sds_stp_remote_device_ready_substates - | |
346 | * | |
347 | * This is the enumeration for the struct scic_sds_remote_device ready substates | |
348 | * for the STP remote device. | |
349 | */ | |
350 | enum scic_sds_stp_remote_device_ready_substates { | |
351 | /** | |
352 | * This is the idle substate for the stp remote device. When there are no | |
353 | * active IO for the device it is is in this state. | |
354 | */ | |
355 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | |
356 | ||
357 | /** | |
358 | * This is the command state for for the STP remote device. This state is | |
359 | * entered when the device is processing a non-NCQ command. The device object | |
360 | * will fail any new start IO requests until this command is complete. | |
361 | */ | |
362 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | |
363 | ||
364 | /** | |
365 | * This is the NCQ state for the STP remote device. This state is entered | |
366 | * when the device is processing an NCQ reuqest. It will remain in this state | |
367 | * so long as there is one or more NCQ requests being processed. | |
368 | */ | |
369 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ, | |
370 | ||
371 | /** | |
372 | * This is the NCQ error state for the STP remote device. This state is | |
373 | * entered when an SDB error FIS is received by the device object while in the | |
374 | * NCQ state. The device object will only accept a READ LOG command while in | |
375 | * this state. | |
376 | */ | |
377 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR, | |
378 | ||
88f3b62a DW |
379 | /** |
380 | * This is the READY substate indicates the device is waiting for the RESET task | |
381 | * coming to be recovered from certain hardware specific error. | |
382 | */ | |
383 | SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET, | |
384 | }; | |
385 | ||
386 | /** | |
387 | * enum scic_sds_smp_remote_device_ready_substates - | |
388 | * | |
389 | * This is the enumeration of the ready substates for the SMP REMOTE DEVICE. | |
390 | */ | |
391 | enum scic_sds_smp_remote_device_ready_substates { | |
392 | /** | |
393 | * This is the ready operational substate for the remote device. This is the | |
394 | * normal operational state for a remote device. | |
395 | */ | |
396 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE, | |
397 | ||
398 | /** | |
399 | * This is the suspended state for the remote device. This is the state that | |
400 | * the device is placed in when a RNC suspend is received by the SCU hardware. | |
401 | */ | |
402 | SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD, | |
403 | }; | |
404 | ||
405 | static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc) | |
406 | { | |
407 | struct scic_sds_remote_device *sci_dev; | |
408 | ||
409 | sci_dev = container_of(rnc, typeof(*sci_dev), rnc); | |
410 | ||
411 | return sci_dev; | |
412 | } | |
413 | ||
5d937e96 | 414 | static inline struct isci_remote_device *sci_dev_to_idev(struct scic_sds_remote_device *sci_dev) |
a1a113b0 DW |
415 | { |
416 | struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci); | |
417 | ||
5d937e96 MP |
418 | return idev; |
419 | } | |
420 | ||
421 | static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev) | |
422 | { | |
423 | return sci_dev_to_idev(sci_dev)->domain_dev; | |
a1a113b0 DW |
424 | } |
425 | ||
426 | static inline bool dev_is_expander(struct domain_device *dev) | |
427 | { | |
428 | return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV; | |
429 | } | |
430 | ||
88f3b62a DW |
431 | typedef enum sci_status (*scic_sds_remote_device_request_handler_t)( |
432 | struct scic_sds_remote_device *device, | |
433 | struct scic_sds_request *request); | |
434 | ||
435 | typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)( | |
436 | struct scic_sds_remote_device *device, | |
437 | struct scic_sds_request *request, | |
438 | void *, | |
439 | enum sci_io_status); | |
440 | ||
441 | typedef enum sci_status (*scic_sds_remote_device_handler_t)( | |
442 | struct scic_sds_remote_device *sci_dev); | |
443 | ||
444 | typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)( | |
445 | struct scic_sds_remote_device *sci_dev, | |
446 | u32 suspend_type); | |
447 | ||
448 | typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)( | |
449 | struct scic_sds_remote_device *sci_dev); | |
450 | ||
451 | typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)( | |
452 | struct scic_sds_remote_device *sci_dev, | |
453 | u32 frame_index); | |
454 | ||
455 | typedef enum sci_status (*scic_sds_remote_device_event_handler_t)( | |
456 | struct scic_sds_remote_device *sci_dev, | |
457 | u32 event_code); | |
458 | ||
459 | typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)( | |
460 | struct scic_sds_remote_device *sci_dev); | |
461 | ||
462 | /** | |
463 | * struct scic_sds_remote_device_state_handler - This structure conains the | |
464 | * state handlers that are needed to process requests for the SCU remote | |
465 | * device objects. | |
466 | * | |
467 | * | |
468 | */ | |
469 | struct scic_sds_remote_device_state_handler { | |
470 | /** | |
471 | * The start_handler specifies the method invoked when a user | |
472 | * attempts to start a remote device. | |
473 | */ | |
474 | scic_sds_remote_device_handler_t start_handler; | |
475 | ||
476 | /** | |
477 | * The stop_handler specifies the method invoked when a user attempts to | |
478 | * stop a remote device. | |
479 | */ | |
480 | scic_sds_remote_device_handler_t stop_handler; | |
481 | ||
482 | /** | |
483 | * The fail_handler specifies the method invoked when a remote device | |
484 | * failure has occurred. A failure may be due to an inability to | |
485 | * initialize/configure the device. | |
486 | */ | |
487 | scic_sds_remote_device_handler_t fail_handler; | |
488 | ||
489 | /** | |
490 | * The destruct_handler specifies the method invoked when attempting to | |
491 | * destruct a remote device. | |
492 | */ | |
493 | scic_sds_remote_device_handler_t destruct_handler; | |
494 | ||
495 | /** | |
496 | * The reset handler specifies the method invloked when requesting to | |
497 | * reset a remote device. | |
498 | */ | |
499 | scic_sds_remote_device_handler_t reset_handler; | |
500 | ||
501 | /** | |
502 | * The reset complete handler specifies the method invloked when | |
503 | * reporting that a reset has completed to the remote device. | |
504 | */ | |
505 | scic_sds_remote_device_handler_t reset_complete_handler; | |
506 | ||
507 | /** | |
508 | * The start_io_handler specifies the method invoked when a user | |
509 | * attempts to start an IO request for a remote device. | |
510 | */ | |
511 | scic_sds_remote_device_request_handler_t start_io_handler; | |
512 | ||
513 | /** | |
514 | * The complete_io_handler specifies the method invoked when a user | |
515 | * attempts to complete an IO request for a remote device. | |
516 | */ | |
517 | scic_sds_remote_device_request_handler_t complete_io_handler; | |
518 | ||
519 | /** | |
520 | * The continue_io_handler specifies the method invoked when a user | |
521 | * attempts to continue an IO request for a remote device. | |
522 | */ | |
523 | scic_sds_remote_device_request_handler_t continue_io_handler; | |
524 | ||
525 | /** | |
526 | * The start_task_handler specifies the method invoked when a user | |
527 | * attempts to start a task management request for a remote device. | |
528 | */ | |
529 | scic_sds_remote_device_request_handler_t start_task_handler; | |
530 | ||
531 | /** | |
532 | * The complete_task_handler specifies the method invoked when a user | |
533 | * attempts to complete a task management request for a remote device. | |
534 | */ | |
535 | scic_sds_remote_device_request_handler_t complete_task_handler; | |
536 | ||
537 | ||
538 | scic_sds_remote_device_suspend_handler_t suspend_handler; | |
539 | scic_sds_remote_device_resume_handler_t resume_handler; | |
540 | scic_sds_remote_device_event_handler_t event_handler; | |
541 | scic_sds_remote_device_frame_handler_t frame_handler; | |
542 | }; | |
543 | ||
544 | extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[]; | |
545 | extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[]; | |
546 | extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[]; | |
547 | ||
548 | /** | |
549 | * scic_sds_remote_device_increment_request_count() - | |
550 | * | |
551 | * This macro incrments the request count for this device | |
552 | */ | |
553 | #define scic_sds_remote_device_increment_request_count(sci_dev) \ | |
554 | ((sci_dev)->started_request_count++) | |
555 | ||
556 | /** | |
557 | * scic_sds_remote_device_decrement_request_count() - | |
558 | * | |
559 | * This macro decrements the request count for this device. This count will | |
560 | * never decrment past 0. | |
561 | */ | |
562 | #define scic_sds_remote_device_decrement_request_count(sci_dev) \ | |
563 | ((sci_dev)->started_request_count > 0 ? \ | |
564 | (sci_dev)->started_request_count-- : 0) | |
565 | ||
566 | /** | |
567 | * scic_sds_remote_device_get_request_count() - | |
568 | * | |
569 | * This is a helper macro to return the current device request count. | |
570 | */ | |
571 | #define scic_sds_remote_device_get_request_count(sci_dev) \ | |
572 | ((sci_dev)->started_request_count) | |
573 | ||
574 | /** | |
575 | * scic_sds_remote_device_get_port() - | |
576 | * | |
577 | * This macro returns the owning port of this remote device obejct. | |
578 | */ | |
579 | #define scic_sds_remote_device_get_port(sci_dev) \ | |
580 | ((sci_dev)->owning_port) | |
581 | ||
582 | /** | |
583 | * scic_sds_remote_device_get_controller() - | |
584 | * | |
585 | * This macro returns the controller object that contains this device object | |
586 | */ | |
587 | #define scic_sds_remote_device_get_controller(sci_dev) \ | |
588 | scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev)) | |
589 | ||
590 | /** | |
591 | * scic_sds_remote_device_set_state_handlers() - | |
592 | * | |
593 | * This macro sets the remote device state handlers pointer and is set on entry | |
594 | * to each device state. | |
595 | */ | |
596 | #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \ | |
597 | ((sci_dev)->state_handlers = (handlers)) | |
598 | ||
599 | /** | |
600 | * scic_sds_remote_device_get_port() - | |
601 | * | |
602 | * This macro returns the owning port of this device | |
603 | */ | |
604 | #define scic_sds_remote_device_get_port(sci_dev) \ | |
605 | ((sci_dev)->owning_port) | |
606 | ||
607 | /** | |
608 | * scic_sds_remote_device_get_sequence() - | |
609 | * | |
610 | * This macro returns the remote device sequence value | |
611 | */ | |
612 | #define scic_sds_remote_device_get_sequence(sci_dev) \ | |
613 | (\ | |
614 | scic_sds_remote_device_get_controller(sci_dev)-> \ | |
615 | remote_device_sequence[(sci_dev)->rnc.remote_node_index] \ | |
616 | ) | |
617 | ||
618 | /** | |
619 | * scic_sds_remote_device_get_controller_peg() - | |
620 | * | |
621 | * This macro returns the controllers protocol engine group | |
622 | */ | |
623 | #define scic_sds_remote_device_get_controller_peg(sci_dev) \ | |
624 | (\ | |
625 | scic_sds_controller_get_protocol_engine_group(\ | |
626 | scic_sds_port_get_controller(\ | |
627 | scic_sds_remote_device_get_port(sci_dev) \ | |
628 | ) \ | |
629 | ) \ | |
630 | ) | |
631 | ||
88f3b62a DW |
632 | /** |
633 | * scic_sds_remote_device_get_index() - | |
634 | * | |
635 | * This macro returns the remote node index for this device object | |
636 | */ | |
637 | #define scic_sds_remote_device_get_index(sci_dev) \ | |
638 | ((sci_dev)->rnc.remote_node_index) | |
639 | ||
640 | /** | |
641 | * scic_sds_remote_device_build_command_context() - | |
642 | * | |
643 | * This macro builds a remote device context for the SCU post request operation | |
644 | */ | |
645 | #define scic_sds_remote_device_build_command_context(device, command) \ | |
646 | ((command) \ | |
647 | | (scic_sds_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \ | |
1f4fa1f9 | 648 | | ((device)->owning_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \ |
88f3b62a DW |
649 | | (scic_sds_remote_device_get_index((device))) \ |
650 | ) | |
651 | ||
652 | /** | |
653 | * scic_sds_remote_device_set_working_request() - | |
654 | * | |
655 | * This macro makes the working request assingment for the remote device | |
656 | * object. To clear the working request use this macro with a NULL request | |
657 | * object. | |
658 | */ | |
659 | #define scic_sds_remote_device_set_working_request(device, request) \ | |
660 | ((device)->working_request = (request)) | |
661 | ||
662 | enum sci_status scic_sds_remote_device_frame_handler( | |
663 | struct scic_sds_remote_device *sci_dev, | |
664 | u32 frame_index); | |
665 | ||
666 | enum sci_status scic_sds_remote_device_event_handler( | |
667 | struct scic_sds_remote_device *sci_dev, | |
668 | u32 event_code); | |
669 | ||
670 | enum sci_status scic_sds_remote_device_start_io( | |
671 | struct scic_sds_controller *controller, | |
672 | struct scic_sds_remote_device *sci_dev, | |
673 | struct scic_sds_request *io_request); | |
674 | ||
675 | enum sci_status scic_sds_remote_device_complete_io( | |
676 | struct scic_sds_controller *controller, | |
677 | struct scic_sds_remote_device *sci_dev, | |
678 | struct scic_sds_request *io_request); | |
679 | ||
680 | enum sci_status scic_sds_remote_device_resume( | |
681 | struct scic_sds_remote_device *sci_dev); | |
682 | ||
683 | enum sci_status scic_sds_remote_device_suspend( | |
684 | struct scic_sds_remote_device *sci_dev, | |
685 | u32 suspend_type); | |
686 | ||
687 | enum sci_status scic_sds_remote_device_start_task( | |
688 | struct scic_sds_controller *controller, | |
689 | struct scic_sds_remote_device *sci_dev, | |
690 | struct scic_sds_request *io_request); | |
691 | ||
692 | void scic_sds_remote_device_post_request( | |
693 | struct scic_sds_remote_device *sci_dev, | |
694 | u32 request); | |
695 | ||
88f3b62a | 696 | #define scic_sds_remote_device_is_atapi(sci_dev) false |
88f3b62a DW |
697 | |
698 | void scic_sds_remote_device_start_request( | |
699 | struct scic_sds_remote_device *sci_dev, | |
700 | struct scic_sds_request *sci_req, | |
701 | enum sci_status status); | |
702 | ||
703 | void scic_sds_remote_device_continue_request(void *sci_dev); | |
704 | ||
705 | enum sci_status scic_sds_remote_device_default_start_handler( | |
706 | struct scic_sds_remote_device *sci_dev); | |
707 | ||
708 | enum sci_status scic_sds_remote_device_default_fail_handler( | |
709 | struct scic_sds_remote_device *sci_dev); | |
710 | ||
711 | enum sci_status scic_sds_remote_device_default_destruct_handler( | |
712 | struct scic_sds_remote_device *sci_dev); | |
713 | ||
714 | enum sci_status scic_sds_remote_device_default_reset_handler( | |
715 | struct scic_sds_remote_device *device); | |
716 | ||
717 | enum sci_status scic_sds_remote_device_default_reset_complete_handler( | |
718 | struct scic_sds_remote_device *device); | |
719 | ||
720 | enum sci_status scic_sds_remote_device_default_start_request_handler( | |
721 | struct scic_sds_remote_device *device, | |
722 | struct scic_sds_request *request); | |
723 | ||
724 | enum sci_status scic_sds_remote_device_default_complete_request_handler( | |
725 | struct scic_sds_remote_device *device, | |
726 | struct scic_sds_request *request); | |
727 | ||
728 | enum sci_status scic_sds_remote_device_default_continue_request_handler( | |
729 | struct scic_sds_remote_device *device, | |
730 | struct scic_sds_request *request); | |
731 | ||
732 | enum sci_status scic_sds_remote_device_default_suspend_handler( | |
733 | struct scic_sds_remote_device *sci_dev, | |
734 | u32 suspend_type); | |
735 | ||
736 | enum sci_status scic_sds_remote_device_default_resume_handler( | |
737 | struct scic_sds_remote_device *sci_dev); | |
738 | ||
739 | ||
740 | enum sci_status scic_sds_remote_device_default_frame_handler( | |
741 | struct scic_sds_remote_device *sci_dev, | |
742 | u32 frame_index); | |
743 | ||
744 | enum sci_status scic_sds_remote_device_ready_state_stop_handler( | |
745 | struct scic_sds_remote_device *device); | |
746 | ||
747 | enum sci_status scic_sds_remote_device_ready_state_reset_handler( | |
748 | struct scic_sds_remote_device *device); | |
749 | ||
750 | enum sci_status scic_sds_remote_device_general_frame_handler( | |
751 | struct scic_sds_remote_device *sci_dev, | |
752 | u32 frame_index); | |
753 | ||
754 | enum sci_status scic_sds_remote_device_general_event_handler( | |
755 | struct scic_sds_remote_device *sci_dev, | |
756 | u32 event_code); | |
757 | ||
758 | enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler( | |
759 | struct scic_sds_remote_device *sci_dev); | |
760 | ||
761 | ||
6f231dda DW |
762 | |
763 | #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ |