isci: uplevel port infrastructure
[deliverable/linux.git] / drivers / scsi / isci / remote_node_context.c
CommitLineData
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
cc9203bf 56#include "host.h"
3bff9d54 57#include "state_machine.h"
88f3b62a
DW
58#include "remote_device.h"
59#include "remote_node_context.h"
6f231dda
DW
60#include "scu_event_codes.h"
61#include "scu_task_context.h"
62
6f231dda
DW
63
64/**
65 *
e2023b87 66 * @sci_rnc: The RNC for which the is posted request is being made.
6f231dda
DW
67 *
68 * This method will return true if the RNC is not in the initial state. In all
69 * other states the RNC is considered active and this will return true. The
70 * destroy request of the state machine drives the RNC back to the initial
71 * state. If the state machine changes then this routine will also have to be
72 * changed. bool true if the state machine is not in the initial state false if
73 * the state machine is in the initial state
74 */
75
76/**
77 *
e2023b87 78 * @sci_rnc: The state of the remote node context object to check.
6f231dda
DW
79 *
80 * This method will return true if the remote node context is in a READY state
81 * otherwise it will return false bool true if the remote node context is in
82 * the ready state. false if the remote node context is not in the ready state.
83 */
84bool scic_sds_remote_node_context_is_ready(
e2023b87 85 struct scic_sds_remote_node_context *sci_rnc)
6f231dda 86{
e2023b87 87 u32 current_state = sci_base_state_machine_get_state(&sci_rnc->state_machine);
6f231dda
DW
88
89 if (current_state == SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) {
90 return true;
91 }
92
93 return false;
94}
95
96/**
97 *
e2023b87 98 * @sci_dev: The remote device to use to construct the RNC buffer.
6f231dda
DW
99 * @rnc: The buffer into which the remote device data will be copied.
100 *
101 * This method will construct the RNC buffer for this remote device object. none
102 */
35173d57 103static void scic_sds_remote_node_context_construct_buffer(
e2023b87 104 struct scic_sds_remote_node_context *sci_rnc)
6f231dda 105{
9614395e 106 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
a1a113b0 107 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1f4fa1f9 108 int rni = sci_rnc->remote_node_index;
a1a113b0 109 union scu_remote_node_context *rnc;
e2023b87 110 struct scic_sds_controller *scic;
a3d568f0 111 __le64 sas_addr;
6f231dda 112
9614395e 113 scic = scic_sds_remote_device_get_controller(sci_dev);
1f4fa1f9 114 rnc = scic_sds_controller_get_remote_node_context_buffer(scic, rni);
6f231dda 115
9614395e
DW
116 memset(rnc, 0, sizeof(union scu_remote_node_context)
117 * scic_sds_remote_device_node_count(sci_dev));
6f231dda 118
1f4fa1f9 119 rnc->ssp.remote_node_index = rni;
9614395e 120 rnc->ssp.remote_node_port_width = sci_dev->device_port_width;
1f4fa1f9 121 rnc->ssp.logical_port_index = sci_dev->owning_port->physical_port_index;
6f231dda 122
a3d568f0
DW
123 /* sas address is __be64, context ram format is __le64 */
124 sas_addr = cpu_to_le64(SAS_ADDR(dev->sas_addr));
125 rnc->ssp.remote_sas_address_hi = upper_32_bits(sas_addr);
126 rnc->ssp.remote_sas_address_lo = lower_32_bits(sas_addr);
6f231dda
DW
127
128 rnc->ssp.nexus_loss_timer_enable = true;
129 rnc->ssp.check_bit = false;
130 rnc->ssp.is_valid = false;
131 rnc->ssp.is_remote_node_context = true;
132 rnc->ssp.function_number = 0;
133
134 rnc->ssp.arbitration_wait_time = 0;
135
a1a113b0 136 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
6f231dda 137 rnc->ssp.connection_occupancy_timeout =
e2023b87 138 scic->user_parameters.sds1.stp_max_occupancy_timeout;
6f231dda 139 rnc->ssp.connection_inactivity_timeout =
e2023b87 140 scic->user_parameters.sds1.stp_inactivity_timeout;
6f231dda
DW
141 } else {
142 rnc->ssp.connection_occupancy_timeout =
e2023b87 143 scic->user_parameters.sds1.ssp_max_occupancy_timeout;
6f231dda 144 rnc->ssp.connection_inactivity_timeout =
e2023b87 145 scic->user_parameters.sds1.ssp_inactivity_timeout;
6f231dda
DW
146 }
147
148 rnc->ssp.initial_arbitration_wait_time = 0;
149
150 /* Open Address Frame Parameters */
9614395e 151 rnc->ssp.oaf_connection_rate = sci_dev->connection_rate;
6f231dda
DW
152 rnc->ssp.oaf_features = 0;
153 rnc->ssp.oaf_source_zone_group = 0;
154 rnc->ssp.oaf_more_compatibility_features = 0;
155}
156
157/**
158 *
e2023b87
DJ
159 * @sci_rnc:
160 * @callback:
6f231dda
DW
161 * @callback_parameter:
162 *
163 * This method will setup the remote node context object so it will transition
164 * to its ready state. If the remote node context is already setup to
165 * transition to its final state then this function does nothing. none
166 */
167static void scic_sds_remote_node_context_setup_to_resume(
e2023b87
DJ
168 struct scic_sds_remote_node_context *sci_rnc,
169 scics_sds_remote_node_context_callback callback,
6f231dda
DW
170 void *callback_parameter)
171{
e2023b87
DJ
172 if (sci_rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL) {
173 sci_rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY;
174 sci_rnc->user_callback = callback;
175 sci_rnc->user_cookie = callback_parameter;
6f231dda
DW
176 }
177}
178
179/**
180 *
e2023b87
DJ
181 * @sci_rnc:
182 * @callback:
6f231dda
DW
183 * @callback_parameter:
184 *
185 * This method will setup the remote node context object so it will transistion
186 * to its final state. none
187 */
188static void scic_sds_remote_node_context_setup_to_destory(
e2023b87
DJ
189 struct scic_sds_remote_node_context *sci_rnc,
190 scics_sds_remote_node_context_callback callback,
6f231dda
DW
191 void *callback_parameter)
192{
e2023b87
DJ
193 sci_rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL;
194 sci_rnc->user_callback = callback;
195 sci_rnc->user_cookie = callback_parameter;
6f231dda
DW
196}
197
198/**
199 *
e2023b87
DJ
200 * @sci_rnc:
201 * @callback:
6f231dda
DW
202 *
203 * This method will continue to resume a remote node context. This is used in
204 * the states where a resume is requested while a resume is in progress.
205 */
206static enum sci_status scic_sds_remote_node_context_continue_to_resume_handler(
e2023b87
DJ
207 struct scic_sds_remote_node_context *sci_rnc,
208 scics_sds_remote_node_context_callback callback,
6f231dda
DW
209 void *callback_parameter)
210{
e2023b87
DJ
211 if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY) {
212 sci_rnc->user_callback = callback;
213 sci_rnc->user_cookie = callback_parameter;
6f231dda
DW
214
215 return SCI_SUCCESS;
216 }
217
218 return SCI_FAILURE_INVALID_STATE;
219}
220
221/* --------------------------------------------------------------------------- */
222
223static enum sci_status scic_sds_remote_node_context_default_destruct_handler(
e2023b87
DJ
224 struct scic_sds_remote_node_context *sci_rnc,
225 scics_sds_remote_node_context_callback callback,
6f231dda
DW
226 void *callback_parameter)
227{
9614395e 228 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
229 "%s: SCIC Remote Node Context 0x%p requested to stop while "
230 "in unexpected state %d\n",
231 __func__,
e2023b87
DJ
232 sci_rnc,
233 sci_base_state_machine_get_state(&sci_rnc->state_machine));
6f231dda
DW
234
235 /*
236 * We have decided that the destruct request on the remote node context can not fail
237 * since it is either in the initial/destroyed state or is can be destroyed. */
238 return SCI_SUCCESS;
239}
240
241static enum sci_status scic_sds_remote_node_context_default_suspend_handler(
e2023b87 242 struct scic_sds_remote_node_context *sci_rnc,
6f231dda 243 u32 suspend_type,
e2023b87 244 scics_sds_remote_node_context_callback callback,
6f231dda
DW
245 void *callback_parameter)
246{
9614395e 247 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
248 "%s: SCIC Remote Node Context 0x%p requested to suspend "
249 "while in wrong state %d\n",
250 __func__,
e2023b87
DJ
251 sci_rnc,
252 sci_base_state_machine_get_state(&sci_rnc->state_machine));
6f231dda
DW
253
254 return SCI_FAILURE_INVALID_STATE;
255}
256
257static enum sci_status scic_sds_remote_node_context_default_resume_handler(
e2023b87
DJ
258 struct scic_sds_remote_node_context *sci_rnc,
259 scics_sds_remote_node_context_callback callback,
6f231dda
DW
260 void *callback_parameter)
261{
9614395e 262 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
263 "%s: SCIC Remote Node Context 0x%p requested to resume "
264 "while in wrong state %d\n",
265 __func__,
e2023b87
DJ
266 sci_rnc,
267 sci_base_state_machine_get_state(&sci_rnc->state_machine));
6f231dda
DW
268
269 return SCI_FAILURE_INVALID_STATE;
270}
271
272static enum sci_status scic_sds_remote_node_context_default_start_io_handler(
e2023b87
DJ
273 struct scic_sds_remote_node_context *sci_rnc,
274 struct scic_sds_request *sci_req)
6f231dda 275{
9614395e 276 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
277 "%s: SCIC Remote Node Context 0x%p requested to start io "
278 "0x%p while in wrong state %d\n",
279 __func__,
e2023b87
DJ
280 sci_rnc,
281 sci_req,
282 sci_base_state_machine_get_state(&sci_rnc->state_machine));
6f231dda
DW
283
284 return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
285}
286
287static enum sci_status scic_sds_remote_node_context_default_start_task_handler(
e2023b87
DJ
288 struct scic_sds_remote_node_context *sci_rnc,
289 struct scic_sds_request *sci_req)
6f231dda 290{
9614395e 291 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
292 "%s: SCIC Remote Node Context 0x%p requested to start "
293 "task 0x%p while in wrong state %d\n",
294 __func__,
e2023b87
DJ
295 sci_rnc,
296 sci_req,
297 sci_base_state_machine_get_state(&sci_rnc->state_machine));
6f231dda
DW
298
299 return SCI_FAILURE;
300}
301
302static enum sci_status scic_sds_remote_node_context_default_event_handler(
e2023b87 303 struct scic_sds_remote_node_context *sci_rnc,
6f231dda
DW
304 u32 event_code)
305{
9614395e 306 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
307 "%s: SCIC Remote Node Context 0x%p requested to process "
308 "event 0x%x while in wrong state %d\n",
309 __func__,
e2023b87 310 sci_rnc,
6f231dda 311 event_code,
e2023b87 312 sci_base_state_machine_get_state(&sci_rnc->state_machine));
6f231dda
DW
313
314 return SCI_FAILURE_INVALID_STATE;
315}
316
317/**
318 *
e2023b87
DJ
319 * @sci_rnc: The rnc for which the task request is targeted.
320 * @sci_req: The request which is going to be started.
6f231dda
DW
321 *
322 * This method determines if the task request can be started by the SCU
323 * hardware. When the RNC is in the ready state any task can be started.
324 * enum sci_status SCI_SUCCESS
325 */
326static enum sci_status scic_sds_remote_node_context_success_start_task_handler(
e2023b87
DJ
327 struct scic_sds_remote_node_context *sci_rnc,
328 struct scic_sds_request *sci_req)
6f231dda
DW
329{
330 return SCI_SUCCESS;
331}
332
333/**
334 *
e2023b87
DJ
335 * @sci_rnc:
336 * @callback:
6f231dda
DW
337 * @callback_parameter:
338 *
339 * This method handles destruct calls from the various state handlers. The
340 * remote node context can be requested to destroy from any state. If there was
341 * a user callback it is always replaced with the request to destroy user
342 * callback. enum sci_status
343 */
344static enum sci_status scic_sds_remote_node_context_general_destruct_handler(
e2023b87
DJ
345 struct scic_sds_remote_node_context *sci_rnc,
346 scics_sds_remote_node_context_callback callback,
6f231dda
DW
347 void *callback_parameter)
348{
349 scic_sds_remote_node_context_setup_to_destory(
e2023b87 350 sci_rnc, callback, callback_parameter
6f231dda
DW
351 );
352
353 sci_base_state_machine_change_state(
e2023b87 354 &sci_rnc->state_machine,
6f231dda
DW
355 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
356 );
357
358 return SCI_SUCCESS;
359}
360
361/* --------------------------------------------------------------------------- */
362
363static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler(
e2023b87
DJ
364 struct scic_sds_remote_node_context *sci_rnc,
365 scics_sds_remote_node_context_callback callback,
6f231dda
DW
366 void *callback_parameter)
367{
e2023b87 368 if (sci_rnc->remote_node_index != SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
6f231dda 369 scic_sds_remote_node_context_setup_to_resume(
e2023b87 370 sci_rnc, callback, callback_parameter
6f231dda
DW
371 );
372
e2023b87 373 scic_sds_remote_node_context_construct_buffer(sci_rnc);
6f231dda
DW
374
375 sci_base_state_machine_change_state(
e2023b87 376 &sci_rnc->state_machine,
6f231dda
DW
377 SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE
378 );
379
380 return SCI_SUCCESS;
381 }
382
383 return SCI_FAILURE_INVALID_STATE;
384}
385
386/* --------------------------------------------------------------------------- */
387
388static enum sci_status scic_sds_remote_node_context_posting_state_event_handler(
e2023b87 389 struct scic_sds_remote_node_context *sci_rnc,
6f231dda
DW
390 u32 event_code)
391{
392 enum sci_status status;
393
394 switch (scu_get_event_code(event_code)) {
395 case SCU_EVENT_POST_RNC_COMPLETE:
396 status = SCI_SUCCESS;
397
398 sci_base_state_machine_change_state(
e2023b87 399 &sci_rnc->state_machine,
6f231dda
DW
400 SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE
401 );
402 break;
403
404 default:
405 status = SCI_FAILURE;
9614395e 406 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
407 "%s: SCIC Remote Node Context 0x%p requested to "
408 "process unexpected event 0x%x while in posting "
409 "state\n",
410 __func__,
e2023b87 411 sci_rnc,
6f231dda
DW
412 event_code);
413 break;
414 }
415
416 return status;
417}
418
419/* --------------------------------------------------------------------------- */
420
421static enum sci_status scic_sds_remote_node_context_invalidating_state_destruct_handler(
e2023b87
DJ
422 struct scic_sds_remote_node_context *sci_rnc,
423 scics_sds_remote_node_context_callback callback,
6f231dda
DW
424 void *callback_parameter)
425{
426 scic_sds_remote_node_context_setup_to_destory(
e2023b87 427 sci_rnc, callback, callback_parameter
6f231dda
DW
428 );
429
430 return SCI_SUCCESS;
431}
432
433static enum sci_status scic_sds_remote_node_context_invalidating_state_event_handler(
e2023b87 434 struct scic_sds_remote_node_context *sci_rnc,
6f231dda
DW
435 u32 event_code)
436{
437 enum sci_status status;
438
439 if (scu_get_event_code(event_code) == SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE) {
440 status = SCI_SUCCESS;
441
e2023b87 442 if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL) {
6f231dda 443 sci_base_state_machine_change_state(
e2023b87 444 &sci_rnc->state_machine,
6f231dda
DW
445 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
446 );
447 } else {
448 sci_base_state_machine_change_state(
e2023b87 449 &sci_rnc->state_machine,
6f231dda
DW
450 SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE
451 );
452 }
453 } else {
454 switch (scu_get_event_type(event_code)) {
455 case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
456 case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
457 /*
458 * We really dont care if the hardware is going to suspend
459 * the device since it's being invalidated anyway */
9614395e 460 dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
461 "%s: SCIC Remote Node Context 0x%p was "
462 "suspeneded by hardware while being "
463 "invalidated.\n",
464 __func__,
e2023b87 465 sci_rnc);
6f231dda
DW
466 status = SCI_SUCCESS;
467 break;
468
469 default:
9614395e 470 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
471 "%s: SCIC Remote Node Context 0x%p "
472 "requested to process event 0x%x while "
473 "in state %d.\n",
474 __func__,
e2023b87 475 sci_rnc,
6f231dda
DW
476 event_code,
477 sci_base_state_machine_get_state(
e2023b87 478 &sci_rnc->state_machine));
6f231dda
DW
479 status = SCI_FAILURE;
480 break;
481 }
482 }
483
484 return status;
485}
486
487/* --------------------------------------------------------------------------- */
488
489
490static enum sci_status scic_sds_remote_node_context_resuming_state_event_handler(
e2023b87 491 struct scic_sds_remote_node_context *sci_rnc,
6f231dda
DW
492 u32 event_code)
493{
494 enum sci_status status;
495
496 if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) {
497 status = SCI_SUCCESS;
498
499 sci_base_state_machine_change_state(
e2023b87 500 &sci_rnc->state_machine,
6f231dda
DW
501 SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE
502 );
503 } else {
504 switch (scu_get_event_type(event_code)) {
505 case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
506 case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
507 /*
508 * We really dont care if the hardware is going to suspend
509 * the device since it's being resumed anyway */
9614395e 510 dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
511 "%s: SCIC Remote Node Context 0x%p was "
512 "suspeneded by hardware while being resumed.\n",
513 __func__,
e2023b87 514 sci_rnc);
6f231dda
DW
515 status = SCI_SUCCESS;
516 break;
517
518 default:
9614395e 519 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
520 "%s: SCIC Remote Node Context 0x%p requested "
521 "to process event 0x%x while in state %d.\n",
522 __func__,
e2023b87 523 sci_rnc,
6f231dda
DW
524 event_code,
525 sci_base_state_machine_get_state(
e2023b87 526 &sci_rnc->state_machine));
6f231dda
DW
527 status = SCI_FAILURE;
528 break;
529 }
530 }
531
532 return status;
533}
534
535/* --------------------------------------------------------------------------- */
536
537/**
538 *
e2023b87
DJ
539 * @sci_rnc: The remote node context object being suspended.
540 * @callback: The callback when the suspension is complete.
6f231dda
DW
541 * @callback_parameter: The parameter that is to be passed into the callback.
542 *
543 * This method will handle the suspend requests from the ready state.
544 * SCI_SUCCESS
545 */
546static enum sci_status scic_sds_remote_node_context_ready_state_suspend_handler(
e2023b87 547 struct scic_sds_remote_node_context *sci_rnc,
6f231dda 548 u32 suspend_type,
e2023b87 549 scics_sds_remote_node_context_callback callback,
6f231dda
DW
550 void *callback_parameter)
551{
e2023b87
DJ
552 sci_rnc->user_callback = callback;
553 sci_rnc->user_cookie = callback_parameter;
554 sci_rnc->suspension_code = suspend_type;
6f231dda
DW
555
556 if (suspend_type == SCI_SOFTWARE_SUSPENSION) {
9614395e
DW
557 scic_sds_remote_device_post_request(rnc_to_dev(sci_rnc),
558 SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX);
6f231dda
DW
559 }
560
561 sci_base_state_machine_change_state(
e2023b87 562 &sci_rnc->state_machine,
6f231dda
DW
563 SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE
564 );
565
566 return SCI_SUCCESS;
567}
568
569/**
570 *
e2023b87
DJ
571 * @sci_rnc: The rnc for which the io request is targeted.
572 * @sci_req: The request which is going to be started.
6f231dda
DW
573 *
574 * This method determines if the io request can be started by the SCU hardware.
575 * When the RNC is in the ready state any io request can be started. enum sci_status
576 * SCI_SUCCESS
577 */
578static enum sci_status scic_sds_remote_node_context_ready_state_start_io_handler(
e2023b87
DJ
579 struct scic_sds_remote_node_context *sci_rnc,
580 struct scic_sds_request *sci_req)
6f231dda
DW
581{
582 return SCI_SUCCESS;
583}
584
585
586static enum sci_status scic_sds_remote_node_context_ready_state_event_handler(
e2023b87 587 struct scic_sds_remote_node_context *sci_rnc,
6f231dda
DW
588 u32 event_code)
589{
590 enum sci_status status;
591
592 switch (scu_get_event_type(event_code)) {
593 case SCU_EVENT_TL_RNC_SUSPEND_TX:
594 sci_base_state_machine_change_state(
e2023b87 595 &sci_rnc->state_machine,
6f231dda
DW
596 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE
597 );
598
e2023b87 599 sci_rnc->suspension_code = scu_get_event_specifier(event_code);
6f231dda
DW
600 status = SCI_SUCCESS;
601 break;
602
603 case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
604 sci_base_state_machine_change_state(
e2023b87 605 &sci_rnc->state_machine,
6f231dda
DW
606 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE
607 );
608
e2023b87 609 sci_rnc->suspension_code = scu_get_event_specifier(event_code);
6f231dda
DW
610 status = SCI_SUCCESS;
611 break;
612
613 default:
9614395e 614 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
615 "%s: SCIC Remote Node Context 0x%p requested to "
616 "process event 0x%x while in state %d.\n",
617 __func__,
e2023b87 618 sci_rnc,
6f231dda
DW
619 event_code,
620 sci_base_state_machine_get_state(
e2023b87 621 &sci_rnc->state_machine));
6f231dda
DW
622
623 status = SCI_FAILURE;
624 break;
625 }
626
627 return status;
628}
629
630/* --------------------------------------------------------------------------- */
631
632static enum sci_status scic_sds_remote_node_context_tx_suspended_state_resume_handler(
e2023b87
DJ
633 struct scic_sds_remote_node_context *sci_rnc,
634 scics_sds_remote_node_context_callback callback,
6f231dda
DW
635 void *callback_parameter)
636{
a1a113b0
DW
637 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
638 struct domain_device *dev = sci_dev_to_domain(sci_dev);
639 enum sci_status status = SCI_SUCCESS;
6f231dda 640
a1a113b0
DW
641 scic_sds_remote_node_context_setup_to_resume(sci_rnc, callback,
642 callback_parameter);
6f231dda
DW
643
644 /* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */
a1a113b0
DW
645 if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev))
646 sci_base_state_machine_change_state(&sci_rnc->state_machine,
647 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
648 else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
649 if (sci_dev->is_direct_attached) {
6f231dda 650 /* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */
6f231dda 651 sci_base_state_machine_change_state(
e2023b87 652 &sci_rnc->state_machine,
a1a113b0 653 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
6f231dda
DW
654 } else {
655 sci_base_state_machine_change_state(
e2023b87 656 &sci_rnc->state_machine,
a1a113b0 657 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
6f231dda 658 }
a1a113b0 659 } else
6f231dda 660 status = SCI_FAILURE;
6f231dda
DW
661
662 return status;
663}
664
665/**
666 *
e2023b87
DJ
667 * @sci_rnc: The remote node context which is to receive the task request.
668 * @sci_req: The task request to be transmitted to to the remote target
6f231dda
DW
669 * device.
670 *
671 * This method will report a success or failure attempt to start a new task
672 * request to the hardware. Since all task requests are sent on the high
673 * priority queue they can be sent when the RCN is in a TX suspend state.
674 * enum sci_status SCI_SUCCESS
675 */
676static enum sci_status scic_sds_remote_node_context_suspended_start_task_handler(
e2023b87
DJ
677 struct scic_sds_remote_node_context *sci_rnc,
678 struct scic_sds_request *sci_req)
6f231dda 679{
e2023b87 680 scic_sds_remote_node_context_resume(sci_rnc, NULL, NULL);
6f231dda
DW
681
682 return SCI_SUCCESS;
683}
684
685/* --------------------------------------------------------------------------- */
686
687static enum sci_status scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler(
e2023b87
DJ
688 struct scic_sds_remote_node_context *sci_rnc,
689 scics_sds_remote_node_context_callback callback,
6f231dda
DW
690 void *callback_parameter)
691{
692 scic_sds_remote_node_context_setup_to_resume(
e2023b87 693 sci_rnc, callback, callback_parameter
6f231dda
DW
694 );
695
696 sci_base_state_machine_change_state(
e2023b87 697 &sci_rnc->state_machine,
6f231dda
DW
698 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE
699 );
700
701 return SCI_FAILURE_INVALID_STATE;
702}
703
704/* --------------------------------------------------------------------------- */
705
706/**
707 *
708 *
709 *
710 */
711static enum sci_status scic_sds_remote_node_context_await_suspension_state_resume_handler(
e2023b87
DJ
712 struct scic_sds_remote_node_context *sci_rnc,
713 scics_sds_remote_node_context_callback callback,
6f231dda
DW
714 void *callback_parameter)
715{
716 scic_sds_remote_node_context_setup_to_resume(
e2023b87 717 sci_rnc, callback, callback_parameter
6f231dda
DW
718 );
719
720 return SCI_SUCCESS;
721}
722
723/**
724 *
e2023b87
DJ
725 * @sci_rnc: The remote node context which is to receive the task request.
726 * @sci_req: The task request to be transmitted to to the remote target
6f231dda
DW
727 * device.
728 *
729 * This method will report a success or failure attempt to start a new task
730 * request to the hardware. Since all task requests are sent on the high
731 * priority queue they can be sent when the RCN is in a TX suspend state.
732 * enum sci_status SCI_SUCCESS
733 */
734static enum sci_status scic_sds_remote_node_context_await_suspension_state_start_task_handler(
e2023b87
DJ
735 struct scic_sds_remote_node_context *sci_rnc,
736 struct scic_sds_request *sci_req)
6f231dda
DW
737{
738 return SCI_SUCCESS;
739}
740
741static enum sci_status scic_sds_remote_node_context_await_suspension_state_event_handler(
e2023b87 742 struct scic_sds_remote_node_context *sci_rnc,
6f231dda
DW
743 u32 event_code)
744{
745 enum sci_status status;
746
747 switch (scu_get_event_type(event_code)) {
748 case SCU_EVENT_TL_RNC_SUSPEND_TX:
749 sci_base_state_machine_change_state(
e2023b87 750 &sci_rnc->state_machine,
6f231dda
DW
751 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE
752 );
753
e2023b87 754 sci_rnc->suspension_code = scu_get_event_specifier(event_code);
6f231dda
DW
755 status = SCI_SUCCESS;
756 break;
757
758 case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
759 sci_base_state_machine_change_state(
e2023b87 760 &sci_rnc->state_machine,
6f231dda
DW
761 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE
762 );
763
e2023b87 764 sci_rnc->suspension_code = scu_get_event_specifier(event_code);
6f231dda
DW
765 status = SCI_SUCCESS;
766 break;
767
768 default:
9614395e 769 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
6f231dda
DW
770 "%s: SCIC Remote Node Context 0x%p requested to "
771 "process event 0x%x while in state %d.\n",
772 __func__,
e2023b87 773 sci_rnc,
6f231dda
DW
774 event_code,
775 sci_base_state_machine_get_state(
e2023b87 776 &sci_rnc->state_machine));
6f231dda
DW
777
778 status = SCI_FAILURE;
779 break;
780 }
781
782 return status;
783}
784
785/* --------------------------------------------------------------------------- */
786
35173d57 787static struct scic_sds_remote_node_context_handlers
a98a7426
JD
788scic_sds_remote_node_context_state_handler_table[] = {
789 [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = {
790 .destruct_handler = scic_sds_remote_node_context_default_destruct_handler,
791 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
792 .resume_handler = scic_sds_remote_node_context_initial_state_resume_handler,
793 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
794 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
795 .event_handler = scic_sds_remote_node_context_default_event_handler
6f231dda 796 },
a98a7426
JD
797 [SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = {
798 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
799 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
800 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
801 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
802 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
803 .event_handler = scic_sds_remote_node_context_posting_state_event_handler
6f231dda 804 },
a98a7426
JD
805 [SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = {
806 .destruct_handler = scic_sds_remote_node_context_invalidating_state_destruct_handler,
807 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
808 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
809 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
810 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
811 .event_handler = scic_sds_remote_node_context_invalidating_state_event_handler
6f231dda 812 },
a98a7426
JD
813 [SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = {
814 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
815 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
816 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
817 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
818 .start_task_handler = scic_sds_remote_node_context_success_start_task_handler,
819 .event_handler = scic_sds_remote_node_context_resuming_state_event_handler
6f231dda 820 },
a98a7426
JD
821 [SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = {
822 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
823 .suspend_handler = scic_sds_remote_node_context_ready_state_suspend_handler,
824 .resume_handler = scic_sds_remote_node_context_default_resume_handler,
825 .start_io_handler = scic_sds_remote_node_context_ready_state_start_io_handler,
826 .start_task_handler = scic_sds_remote_node_context_success_start_task_handler,
827 .event_handler = scic_sds_remote_node_context_ready_state_event_handler
6f231dda 828 },
a98a7426
JD
829 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = {
830 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
831 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
832 .resume_handler = scic_sds_remote_node_context_tx_suspended_state_resume_handler,
833 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
834 .start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler,
835 .event_handler = scic_sds_remote_node_context_default_event_handler
6f231dda 836 },
a98a7426
JD
837 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = {
838 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
839 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
840 .resume_handler = scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler,
841 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
842 .start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler,
843 .event_handler = scic_sds_remote_node_context_default_event_handler
6f231dda 844 },
a98a7426
JD
845 [SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = {
846 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
847 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
848 .resume_handler = scic_sds_remote_node_context_await_suspension_state_resume_handler,
849 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
850 .start_task_handler = scic_sds_remote_node_context_await_suspension_state_start_task_handler,
851 .event_handler = scic_sds_remote_node_context_await_suspension_state_event_handler
6f231dda
DW
852 }
853};
854
855/*
856 * *****************************************************************************
857 * * REMOTE NODE CONTEXT PRIVATE METHODS
858 * ***************************************************************************** */
859
860/**
861 *
862 *
863 * This method just calls the user callback function and then resets the
864 * callback.
865 */
866static void scic_sds_remote_node_context_notify_user(
867 struct scic_sds_remote_node_context *rnc)
868{
869 if (rnc->user_callback != NULL) {
870 (*rnc->user_callback)(rnc->user_cookie);
871
872 rnc->user_callback = NULL;
873 rnc->user_cookie = NULL;
874 }
875}
876
877/**
878 *
879 *
880 * This method will continue the remote node context state machine by
881 * requesting to resume the remote node context state machine from its current
882 * state.
883 */
884static void scic_sds_remote_node_context_continue_state_transitions(
885 struct scic_sds_remote_node_context *rnc)
886{
887 if (rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY) {
888 rnc->state_handlers->resume_handler(
889 rnc, rnc->user_callback, rnc->user_cookie
890 );
891 }
892}
893
894/**
895 *
e2023b87 896 * @sci_rnc: The remote node context object that is to be validated.
6f231dda
DW
897 *
898 * This method will mark the rnc buffer as being valid and post the request to
899 * the hardware. none
900 */
901static void scic_sds_remote_node_context_validate_context_buffer(
e2023b87 902 struct scic_sds_remote_node_context *sci_rnc)
6f231dda 903{
9614395e 904 struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
a1a113b0 905 struct domain_device *dev = sci_dev_to_domain(sci_dev);
6f231dda
DW
906 union scu_remote_node_context *rnc_buffer;
907
908 rnc_buffer = scic_sds_controller_get_remote_node_context_buffer(
9614395e 909 scic_sds_remote_device_get_controller(sci_dev),
e2023b87 910 sci_rnc->remote_node_index
6f231dda
DW
911 );
912
913 rnc_buffer->ssp.is_valid = true;
914
9614395e 915 if (!sci_dev->is_direct_attached &&
a1a113b0 916 (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))) {
9614395e
DW
917 scic_sds_remote_device_post_request(sci_dev,
918 SCU_CONTEXT_COMMAND_POST_RNC_96);
6f231dda 919 } else {
9614395e 920 scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_32);
6f231dda 921
9614395e
DW
922 if (sci_dev->is_direct_attached) {
923 scic_sds_port_setup_transports(sci_dev->owning_port,
924 sci_rnc->remote_node_index);
6f231dda
DW
925 }
926 }
927}
928
929/**
930 *
e2023b87 931 * @sci_rnc: The remote node context object that is to be invalidated.
6f231dda
DW
932 *
933 * This method will update the RNC buffer and post the invalidate request. none
934 */
935static void scic_sds_remote_node_context_invalidate_context_buffer(
e2023b87 936 struct scic_sds_remote_node_context *sci_rnc)
6f231dda
DW
937{
938 union scu_remote_node_context *rnc_buffer;
939
940 rnc_buffer = scic_sds_controller_get_remote_node_context_buffer(
9614395e
DW
941 scic_sds_remote_device_get_controller(rnc_to_dev(sci_rnc)),
942 sci_rnc->remote_node_index);
6f231dda
DW
943
944 rnc_buffer->ssp.is_valid = false;
945
9614395e
DW
946 scic_sds_remote_device_post_request(rnc_to_dev(sci_rnc),
947 SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE);
6f231dda
DW
948}
949
950/*
951 * *****************************************************************************
952 * * REMOTE NODE CONTEXT STATE ENTER AND EXIT METHODS
953 * ***************************************************************************** */
954
955/**
956 *
957 *
958 *
959 */
9a0fff7b 960static void scic_sds_remote_node_context_initial_state_enter(void *object)
6f231dda 961{
af23e857 962 struct scic_sds_remote_node_context *rnc = object;
6f231dda
DW
963
964 SET_STATE_HANDLER(
965 rnc,
966 scic_sds_remote_node_context_state_handler_table,
967 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
968 );
969
970 /*
971 * Check to see if we have gotten back to the initial state because someone
972 * requested to destroy the remote node context object. */
973 if (
974 rnc->state_machine.previous_state_id
975 == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
976 ) {
977 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
978
979 scic_sds_remote_node_context_notify_user(rnc);
980 }
981}
982
983/**
984 *
985 *
986 *
987 */
9a0fff7b 988static void scic_sds_remote_node_context_posting_state_enter(void *object)
6f231dda 989{
af23e857 990 struct scic_sds_remote_node_context *sci_rnc = object;
6f231dda
DW
991
992 SET_STATE_HANDLER(
e2023b87 993 sci_rnc,
6f231dda
DW
994 scic_sds_remote_node_context_state_handler_table,
995 SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE
996 );
997
e2023b87 998 scic_sds_remote_node_context_validate_context_buffer(sci_rnc);
6f231dda
DW
999}
1000
1001/**
1002 *
1003 *
1004 *
1005 */
9a0fff7b 1006static void scic_sds_remote_node_context_invalidating_state_enter(void *object)
6f231dda 1007{
af23e857 1008 struct scic_sds_remote_node_context *rnc = object;
6f231dda
DW
1009
1010 SET_STATE_HANDLER(
1011 rnc,
1012 scic_sds_remote_node_context_state_handler_table,
1013 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
1014 );
1015
1016 scic_sds_remote_node_context_invalidate_context_buffer(rnc);
1017}
1018
1019/**
1020 *
1021 *
1022 *
1023 */
9a0fff7b 1024static void scic_sds_remote_node_context_resuming_state_enter(void *object)
6f231dda 1025{
af23e857 1026 struct scic_sds_remote_node_context *rnc = object;
9614395e 1027 struct scic_sds_remote_device *sci_dev;
a1a113b0 1028 struct domain_device *dev;
6f231dda 1029
9614395e 1030 sci_dev = rnc_to_dev(rnc);
a1a113b0 1031 dev = sci_dev_to_domain(sci_dev);
6f231dda
DW
1032
1033 SET_STATE_HANDLER(
1034 rnc,
1035 scic_sds_remote_node_context_state_handler_table,
1036 SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE
1037 );
1038
24621466
HD
1039 /*
1040 * For direct attached SATA devices we need to clear the TLCR
1041 * NCQ to TCi tag mapping on the phy and in cases where we
1042 * resume because of a target reset we also need to update
1043 * the STPTLDARNI register with the RNi of the device
1044 */
a1a113b0
DW
1045 if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) &&
1046 sci_dev->is_direct_attached)
9614395e
DW
1047 scic_sds_port_setup_transports(sci_dev->owning_port,
1048 rnc->remote_node_index);
24621466 1049
9614395e 1050 scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME);
6f231dda
DW
1051}
1052
1053/**
1054 *
1055 *
1056 *
1057 */
9a0fff7b 1058static void scic_sds_remote_node_context_ready_state_enter(void *object)
6f231dda 1059{
af23e857 1060 struct scic_sds_remote_node_context *rnc = object;
6f231dda
DW
1061
1062 SET_STATE_HANDLER(
1063 rnc,
1064 scic_sds_remote_node_context_state_handler_table,
1065 SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE
1066 );
1067
1068 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
1069
1070 if (rnc->user_callback != NULL) {
1071 scic_sds_remote_node_context_notify_user(rnc);
1072 }
1073}
1074
1075/**
1076 *
1077 *
1078 *
1079 */
9a0fff7b 1080static void scic_sds_remote_node_context_tx_suspended_state_enter(void *object)
6f231dda 1081{
af23e857 1082 struct scic_sds_remote_node_context *rnc = object;
6f231dda
DW
1083
1084 SET_STATE_HANDLER(
1085 rnc,
1086 scic_sds_remote_node_context_state_handler_table,
1087 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE
1088 );
1089
1090 scic_sds_remote_node_context_continue_state_transitions(rnc);
1091}
1092
1093/**
1094 *
1095 *
1096 *
1097 */
1098static void scic_sds_remote_node_context_tx_rx_suspended_state_enter(
9a0fff7b 1099 void *object)
6f231dda 1100{
af23e857 1101 struct scic_sds_remote_node_context *rnc = object;
6f231dda
DW
1102
1103 SET_STATE_HANDLER(
1104 rnc,
1105 scic_sds_remote_node_context_state_handler_table,
1106 SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE
1107 );
1108
1109 scic_sds_remote_node_context_continue_state_transitions(rnc);
1110}
1111
1112/**
1113 *
1114 *
1115 *
1116 */
1117static void scic_sds_remote_node_context_await_suspension_state_enter(
9a0fff7b 1118 void *object)
6f231dda 1119{
af23e857 1120 struct scic_sds_remote_node_context *rnc = object;
6f231dda
DW
1121
1122 SET_STATE_HANDLER(
1123 rnc,
1124 scic_sds_remote_node_context_state_handler_table,
1125 SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE
1126 );
1127}
1128
1129/* --------------------------------------------------------------------------- */
1130
35173d57 1131static const struct sci_base_state scic_sds_remote_node_context_state_table[] = {
6f231dda
DW
1132 [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = {
1133 .enter_state = scic_sds_remote_node_context_initial_state_enter,
1134 },
1135 [SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = {
1136 .enter_state = scic_sds_remote_node_context_posting_state_enter,
1137 },
1138 [SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = {
1139 .enter_state = scic_sds_remote_node_context_invalidating_state_enter,
1140 },
1141 [SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = {
1142 .enter_state = scic_sds_remote_node_context_resuming_state_enter,
1143 },
1144 [SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = {
1145 .enter_state = scic_sds_remote_node_context_ready_state_enter,
1146 },
1147 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = {
1148 .enter_state = scic_sds_remote_node_context_tx_suspended_state_enter,
1149 },
1150 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = {
1151 .enter_state = scic_sds_remote_node_context_tx_rx_suspended_state_enter,
1152 },
1153 [SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = {
1154 .enter_state = scic_sds_remote_node_context_await_suspension_state_enter,
1155 },
1156};
1157
9614395e
DW
1158void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc,
1159 u16 remote_node_index)
35173d57
DW
1160{
1161 memset(rnc, 0, sizeof(struct scic_sds_remote_node_context));
1162
1163 rnc->remote_node_index = remote_node_index;
35173d57
DW
1164 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
1165
1166 sci_base_state_machine_construct(
1167 &rnc->state_machine,
af23e857 1168 rnc,
35173d57
DW
1169 scic_sds_remote_node_context_state_table,
1170 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
1171 );
1172
1173 sci_base_state_machine_start(&rnc->state_machine);
1174}
This page took 0.0888640000000001 seconds and 5 git commands to generate.