1f11c7f63SJim Harris /*-
2*718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3*718cf2ccSPedro F. Giffuni *
4f11c7f63SJim Harris * This file is provided under a dual BSD/GPLv2 license. When using or
5f11c7f63SJim Harris * redistributing this file, you may do so under either license.
6f11c7f63SJim Harris *
7f11c7f63SJim Harris * GPL LICENSE SUMMARY
8f11c7f63SJim Harris *
9f11c7f63SJim Harris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10f11c7f63SJim Harris *
11f11c7f63SJim Harris * This program is free software; you can redistribute it and/or modify
12f11c7f63SJim Harris * it under the terms of version 2 of the GNU General Public License as
13f11c7f63SJim Harris * published by the Free Software Foundation.
14f11c7f63SJim Harris *
15f11c7f63SJim Harris * This program is distributed in the hope that it will be useful, but
16f11c7f63SJim Harris * WITHOUT ANY WARRANTY; without even the implied warranty of
17f11c7f63SJim Harris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18f11c7f63SJim Harris * General Public License for more details.
19f11c7f63SJim Harris *
20f11c7f63SJim Harris * You should have received a copy of the GNU General Public License
21f11c7f63SJim Harris * along with this program; if not, write to the Free Software
22f11c7f63SJim Harris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23f11c7f63SJim Harris * The full GNU General Public License is included in this distribution
24f11c7f63SJim Harris * in the file called LICENSE.GPL.
25f11c7f63SJim Harris *
26f11c7f63SJim Harris * BSD LICENSE
27f11c7f63SJim Harris *
28f11c7f63SJim Harris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29f11c7f63SJim Harris * All rights reserved.
30f11c7f63SJim Harris *
31f11c7f63SJim Harris * Redistribution and use in source and binary forms, with or without
32f11c7f63SJim Harris * modification, are permitted provided that the following conditions
33f11c7f63SJim Harris * are met:
34f11c7f63SJim Harris *
35f11c7f63SJim Harris * * Redistributions of source code must retain the above copyright
36f11c7f63SJim Harris * notice, this list of conditions and the following disclaimer.
37f11c7f63SJim Harris * * Redistributions in binary form must reproduce the above copyright
38f11c7f63SJim Harris * notice, this list of conditions and the following disclaimer in
39f11c7f63SJim Harris * the documentation and/or other materials provided with the
40f11c7f63SJim Harris * distribution.
41f11c7f63SJim Harris *
42f11c7f63SJim Harris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43f11c7f63SJim Harris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44f11c7f63SJim Harris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45f11c7f63SJim Harris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46f11c7f63SJim Harris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47f11c7f63SJim Harris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48f11c7f63SJim Harris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49f11c7f63SJim Harris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50f11c7f63SJim Harris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51f11c7f63SJim Harris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52f11c7f63SJim Harris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53f11c7f63SJim Harris */
54f11c7f63SJim Harris
55f11c7f63SJim Harris #include <sys/cdefs.h>
56f11c7f63SJim Harris /**
57f11c7f63SJim Harris * @file
58f11c7f63SJim Harris *
59f11c7f63SJim Harris * @brief This file contains the implementation of the SCIF_SAS_IO_REQUEST
60f11c7f63SJim Harris * object.
61f11c7f63SJim Harris */
62f11c7f63SJim Harris
63f11c7f63SJim Harris
64f11c7f63SJim Harris #include <dev/isci/scil/scic_io_request.h>
65f11c7f63SJim Harris #include <dev/isci/scil/scic_remote_device.h>
66f11c7f63SJim Harris #include <dev/isci/scil/scic_user_callback.h>
67f11c7f63SJim Harris #include <dev/isci/scil/scic_controller.h>
68f11c7f63SJim Harris #include <dev/isci/scil/scif_user_callback.h>
69f11c7f63SJim Harris
70f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_controller.h>
71f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_domain.h>
72f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_remote_device.h>
73f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_io_request.h>
74f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_task_request.h>
75f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_stp_io_request.h>
76f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_logger.h>
77f11c7f63SJim Harris #include <dev/isci/scil/scif_sas_smp_io_request.h>
78f11c7f63SJim Harris #include <dev/isci/scil/sci_fast_list.h>
79f11c7f63SJim Harris #include <dev/isci/scil/sati.h>
80f11c7f63SJim Harris #include <dev/isci/scil/intel_sat.h>
81f11c7f63SJim Harris #include <dev/isci/scil/sati_translator_sequence.h>
82f11c7f63SJim Harris
83f11c7f63SJim Harris /**
84f11c7f63SJim Harris * @brief This method represents common functionality for the
85f11c7f63SJim Harris * scif_io_request_construct() and scif_sas_io_request_continue()
86f11c7f63SJim Harris * methods.
87f11c7f63SJim Harris *
88f11c7f63SJim Harris * @return This method returns an indication as to whether the
89f11c7f63SJim Harris * construction succeeded.
90f11c7f63SJim Harris */
91f11c7f63SJim Harris static
scif_sas_io_request_construct(SCIF_SAS_REMOTE_DEVICE_T * fw_device,SCIF_SAS_IO_REQUEST_T * fw_io,U16 io_tag,void * user_io_request_object,SCI_IO_REQUEST_HANDLE_T * scif_io_request,BOOL is_initial_construction)92f11c7f63SJim Harris SCI_STATUS scif_sas_io_request_construct(
93f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T * fw_device,
94f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io,
95f11c7f63SJim Harris U16 io_tag,
96f11c7f63SJim Harris void * user_io_request_object,
97f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T * scif_io_request,
98f11c7f63SJim Harris BOOL is_initial_construction
99f11c7f63SJim Harris )
100f11c7f63SJim Harris {
101f11c7f63SJim Harris SCI_STATUS status;
102f11c7f63SJim Harris SMP_DISCOVER_RESPONSE_PROTOCOLS_T dev_protocols;
103f11c7f63SJim Harris
104f11c7f63SJim Harris scic_remote_device_get_protocols(fw_device->core_object, &dev_protocols);
105f11c7f63SJim Harris
106f11c7f63SJim Harris //Currently, all the io requests sent to smp target are internal.
107f11c7f63SJim Harris //so we fail all the external io toward to it.
108f11c7f63SJim Harris //Todo: is there a better way to handle external io to smp target?
109f11c7f63SJim Harris if (dev_protocols.u.bits.attached_smp_target)
110f11c7f63SJim Harris return SCI_FAILURE_INVALID_REMOTE_DEVICE;
111f11c7f63SJim Harris
112f11c7f63SJim Harris SCIF_LOG_TRACE((
113f11c7f63SJim Harris sci_base_object_get_logger(fw_device),
114f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST,
115f11c7f63SJim Harris "scif_sas_io_request_construct(0x%x,0x%x,0x%x,0x%x,0x%x,0x%x) enter\n",
116f11c7f63SJim Harris fw_device, fw_io, io_tag, user_io_request_object, scif_io_request,
117f11c7f63SJim Harris is_initial_construction
118f11c7f63SJim Harris ));
119f11c7f63SJim Harris
120f11c7f63SJim Harris // Initialize the users handle to the framework IO request.
121f11c7f63SJim Harris *scif_io_request = fw_io;
122f11c7f63SJim Harris
123f11c7f63SJim Harris // Construct the parent object first in order to ensure logging can
124f11c7f63SJim Harris // function.
125f11c7f63SJim Harris scif_sas_request_construct(
126f11c7f63SJim Harris &fw_io->parent,
127f11c7f63SJim Harris fw_device,
128f11c7f63SJim Harris sci_base_object_get_logger(fw_device),
129f11c7f63SJim Harris scif_sas_io_request_state_table
130f11c7f63SJim Harris );
131f11c7f63SJim Harris
132f11c7f63SJim Harris status = scic_io_request_construct(
133f11c7f63SJim Harris fw_device->domain->controller->core_object,
134f11c7f63SJim Harris fw_device->core_object,
135f11c7f63SJim Harris io_tag,
136f11c7f63SJim Harris fw_io,
137f11c7f63SJim Harris ((U8 *)fw_io) + sizeof(SCIF_SAS_IO_REQUEST_T),
138f11c7f63SJim Harris &fw_io->parent.core_object
139f11c7f63SJim Harris );
140f11c7f63SJim Harris
141f11c7f63SJim Harris if (status == SCI_SUCCESS)
142f11c7f63SJim Harris {
143f11c7f63SJim Harris // These associations must be set early for the core io request
144f11c7f63SJim Harris // object construction to complete correctly as there will be
145f11c7f63SJim Harris // callbacks into the user driver framework during core construction
146f11c7f63SJim Harris sci_object_set_association(fw_io, user_io_request_object);
147f11c7f63SJim Harris sci_object_set_association(fw_io->parent.core_object, fw_io);
148f11c7f63SJim Harris
149f11c7f63SJim Harris // Perform protocol specific core IO request construction.
150f11c7f63SJim Harris if (dev_protocols.u.bits.attached_ssp_target)
151f11c7f63SJim Harris status = scic_io_request_construct_basic_ssp(fw_io->parent.core_object);
152f11c7f63SJim Harris else if (dev_protocols.u.bits.attached_stp_target)
153f11c7f63SJim Harris {
154f11c7f63SJim Harris if (is_initial_construction == TRUE)
155f11c7f63SJim Harris sati_sequence_construct(&fw_io->parent.stp.sequence);
156f11c7f63SJim Harris
157f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
158f11c7f63SJim Harris if (!scic_remote_device_is_atapi(fw_device->core_object))
159f11c7f63SJim Harris {
160f11c7f63SJim Harris #endif
161f11c7f63SJim Harris status = scif_sas_stp_io_request_construct(fw_io);
162f11c7f63SJim Harris
163f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
164f11c7f63SJim Harris }
165f11c7f63SJim Harris else
166f11c7f63SJim Harris status = scif_sas_stp_packet_io_request_construct(fw_io);
167f11c7f63SJim Harris #endif
168f11c7f63SJim Harris }
169f11c7f63SJim Harris
170f11c7f63SJim Harris sci_base_state_machine_logger_initialize(
171f11c7f63SJim Harris &fw_io->parent.parent.state_machine_logger,
172f11c7f63SJim Harris &fw_io->parent.parent.state_machine,
173f11c7f63SJim Harris &fw_io->parent.parent.parent,
174f11c7f63SJim Harris scif_cb_logger_log_states,
175f11c7f63SJim Harris "SCIF_IO_REQUEST_T", "base_state_machine",
176f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST
177f11c7f63SJim Harris );
178f11c7f63SJim Harris }
179f11c7f63SJim Harris
180f11c7f63SJim Harris return status;
181f11c7f63SJim Harris }
182f11c7f63SJim Harris
183f11c7f63SJim Harris //******************************************************************************
184f11c7f63SJim Harris //* P U B L I C M E T H O D S
185f11c7f63SJim Harris //******************************************************************************
186f11c7f63SJim Harris
scif_io_request_get_object_size(void)187f11c7f63SJim Harris U32 scif_io_request_get_object_size(
188f11c7f63SJim Harris void
189f11c7f63SJim Harris )
190f11c7f63SJim Harris {
191f11c7f63SJim Harris return (sizeof(SCIF_SAS_IO_REQUEST_T) + scic_io_request_get_object_size());
192f11c7f63SJim Harris }
193f11c7f63SJim Harris
194f11c7f63SJim Harris // ----------------------------------------------------------------------------
scif_io_request_get_number_of_bytes_transferred(SCI_IO_REQUEST_HANDLE_T scif_io_request)195f11c7f63SJim Harris U32 scif_io_request_get_number_of_bytes_transferred(
196f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T scif_io_request
197f11c7f63SJim Harris )
198f11c7f63SJim Harris {
199f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_request = (SCIF_SAS_IO_REQUEST_T*) scif_io_request;
200f11c7f63SJim Harris
201f11c7f63SJim Harris if(scic_io_request_get_protocol(scif_io_request_get_scic_handle(scif_io_request))
202f11c7f63SJim Harris == SCIC_STP_PROTOCOL)
203f11c7f63SJim Harris {
204f11c7f63SJim Harris U16 sati_data_bytes_set =
205f11c7f63SJim Harris sati_get_number_data_bytes_set(&(fw_request->parent.stp.sequence));
206f11c7f63SJim Harris
207f11c7f63SJim Harris if (sati_data_bytes_set != 0)
208f11c7f63SJim Harris return sati_data_bytes_set;
209f11c7f63SJim Harris else
210f11c7f63SJim Harris {
211f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
212f11c7f63SJim Harris U8 sat_protocol = fw_request->parent.stp.sequence.protocol;
213f11c7f63SJim Harris if ( sat_protocol & SAT_PROTOCOL_PACKET)
214f11c7f63SJim Harris return
215f11c7f63SJim Harris scif_sas_stp_packet_io_request_get_number_of_bytes_transferred(fw_request);
216f11c7f63SJim Harris else
217f11c7f63SJim Harris #endif
218f11c7f63SJim Harris return scic_io_request_get_number_of_bytes_transferred(
219f11c7f63SJim Harris scif_io_request_get_scic_handle(scif_io_request));
220f11c7f63SJim Harris }
221f11c7f63SJim Harris }
222f11c7f63SJim Harris else
223f11c7f63SJim Harris {
224f11c7f63SJim Harris return scic_io_request_get_number_of_bytes_transferred(
225f11c7f63SJim Harris scif_io_request_get_scic_handle(scif_io_request));
226f11c7f63SJim Harris }
227f11c7f63SJim Harris }
228f11c7f63SJim Harris
229f11c7f63SJim Harris // ---------------------------------------------------------------------------
230f11c7f63SJim Harris
scif_io_request_construct(SCI_CONTROLLER_HANDLE_T scif_controller,SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device,U16 io_tag,void * user_io_request_object,void * io_request_memory,SCI_IO_REQUEST_HANDLE_T * scif_io_request)231f11c7f63SJim Harris SCI_STATUS scif_io_request_construct(
232f11c7f63SJim Harris SCI_CONTROLLER_HANDLE_T scif_controller,
233f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device,
234f11c7f63SJim Harris U16 io_tag,
235f11c7f63SJim Harris void * user_io_request_object,
236f11c7f63SJim Harris void * io_request_memory,
237f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T * scif_io_request
238f11c7f63SJim Harris )
239f11c7f63SJim Harris {
240f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
241f11c7f63SJim Harris io_request_memory;
242f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
243f11c7f63SJim Harris scif_remote_device;
244f11c7f63SJim Harris
245f11c7f63SJim Harris return scif_sas_io_request_construct(
246f11c7f63SJim Harris fw_device,
247f11c7f63SJim Harris fw_io,
248f11c7f63SJim Harris io_tag,
249f11c7f63SJim Harris user_io_request_object,
250f11c7f63SJim Harris scif_io_request,
251f11c7f63SJim Harris TRUE
252f11c7f63SJim Harris );
253f11c7f63SJim Harris }
254f11c7f63SJim Harris
255f11c7f63SJim Harris // ---------------------------------------------------------------------------
256f11c7f63SJim Harris
scif_request_construct(SCI_CONTROLLER_HANDLE_T scif_controller,SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device,U16 io_tag,void * user_io_request_object,void * io_request_memory,SCI_IO_REQUEST_HANDLE_T * scif_io_request)257f11c7f63SJim Harris SCI_STATUS scif_request_construct(
258f11c7f63SJim Harris SCI_CONTROLLER_HANDLE_T scif_controller,
259f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device,
260f11c7f63SJim Harris U16 io_tag,
261f11c7f63SJim Harris void * user_io_request_object,
262f11c7f63SJim Harris void * io_request_memory,
263f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T * scif_io_request
264f11c7f63SJim Harris )
265f11c7f63SJim Harris {
266f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
267f11c7f63SJim Harris io_request_memory;
268f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
269f11c7f63SJim Harris scif_remote_device;
270f11c7f63SJim Harris SCI_STATUS status;
271f11c7f63SJim Harris
272f11c7f63SJim Harris SCIF_LOG_TRACE((
273f11c7f63SJim Harris sci_base_object_get_logger(fw_device),
274f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST,
275f11c7f63SJim Harris "scif_io_request_construct(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) enter\n",
276f11c7f63SJim Harris scif_controller, scif_remote_device, io_tag, user_io_request_object,
277f11c7f63SJim Harris io_request_memory, scif_io_request
278f11c7f63SJim Harris ));
279f11c7f63SJim Harris
280f11c7f63SJim Harris // Step 1: Create the scif io request.
281f11c7f63SJim Harris // Initialize the users handle to the framework IO request.
282f11c7f63SJim Harris *scif_io_request = fw_io;
283f11c7f63SJim Harris
284f11c7f63SJim Harris // Construct the parent object first in order to ensure logging can
285f11c7f63SJim Harris // function.
286f11c7f63SJim Harris scif_sas_request_construct(
287f11c7f63SJim Harris &fw_io->parent,
288f11c7f63SJim Harris fw_device,
289f11c7f63SJim Harris sci_base_object_get_logger(fw_device),
290f11c7f63SJim Harris scif_sas_io_request_state_table
291f11c7f63SJim Harris );
292f11c7f63SJim Harris
293f11c7f63SJim Harris status = scic_io_request_construct(
294f11c7f63SJim Harris (void *) ((SCIF_SAS_CONTROLLER_T *)scif_controller)->core_object,
295f11c7f63SJim Harris (void *) fw_device->core_object,
296f11c7f63SJim Harris io_tag,
297f11c7f63SJim Harris fw_io,
298f11c7f63SJim Harris (U8 *)io_request_memory + sizeof(SCIF_SAS_IO_REQUEST_T),
299f11c7f63SJim Harris &fw_io->parent.core_object
300f11c7f63SJim Harris );
301f11c7f63SJim Harris
302f11c7f63SJim Harris if (status == SCI_SUCCESS)
303f11c7f63SJim Harris {
304f11c7f63SJim Harris // These associations must be set early for the core io request
305f11c7f63SJim Harris // object construction to complete correctly as there will be
306f11c7f63SJim Harris // callbacks into the user driver framework during core construction
307f11c7f63SJim Harris sci_object_set_association(fw_io, user_io_request_object);
308f11c7f63SJim Harris sci_object_set_association(fw_io->parent.core_object, fw_io);
309f11c7f63SJim Harris
310f11c7f63SJim Harris sci_base_state_machine_logger_initialize(
311f11c7f63SJim Harris &fw_io->parent.parent.state_machine_logger,
312f11c7f63SJim Harris &fw_io->parent.parent.state_machine,
313f11c7f63SJim Harris &fw_io->parent.parent.parent,
314f11c7f63SJim Harris scif_cb_logger_log_states,
315f11c7f63SJim Harris "SCIF_IO_REQUEST_T", "base_state_machine",
316f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST
317f11c7f63SJim Harris );
318f11c7f63SJim Harris }
319f11c7f63SJim Harris
320f11c7f63SJim Harris return status;
321f11c7f63SJim Harris }
322f11c7f63SJim Harris
323f11c7f63SJim Harris // ----------------------------------------------------------------------------
324f11c7f63SJim Harris
scif_io_request_construct_with_core(SCI_CONTROLLER_HANDLE_T scif_controller,SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device,void * scic_io_request,void * user_io_request_object,void * io_request_memory,SCI_IO_REQUEST_HANDLE_T * scif_io_request)325f11c7f63SJim Harris SCI_STATUS scif_io_request_construct_with_core (
326f11c7f63SJim Harris SCI_CONTROLLER_HANDLE_T scif_controller,
327f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T scif_remote_device,
328f11c7f63SJim Harris void * scic_io_request,
329f11c7f63SJim Harris void * user_io_request_object,
330f11c7f63SJim Harris void * io_request_memory,
331f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T * scif_io_request
332f11c7f63SJim Harris )
333f11c7f63SJim Harris {
334f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
335f11c7f63SJim Harris io_request_memory;
336f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
337f11c7f63SJim Harris scif_remote_device;
338f11c7f63SJim Harris SCI_STATUS status = SCI_SUCCESS;
339f11c7f63SJim Harris
340f11c7f63SJim Harris SCIF_LOG_TRACE((
341f11c7f63SJim Harris sci_base_object_get_logger(fw_device),
342f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST,
343f11c7f63SJim Harris "scif_io_request_construct_pass_through(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
344f11c7f63SJim Harris scif_remote_device, user_io_request_object,
345f11c7f63SJim Harris io_request_memory, scif_io_request
346f11c7f63SJim Harris ));
347f11c7f63SJim Harris
348f11c7f63SJim Harris // Initialize the users handle to the framework IO request.
349f11c7f63SJim Harris *scif_io_request = fw_io;
350f11c7f63SJim Harris
351f11c7f63SJim Harris // Construct the parent object first in order to ensure logging can
352f11c7f63SJim Harris // function.
353f11c7f63SJim Harris scif_sas_request_construct(
354f11c7f63SJim Harris &fw_io->parent,
355f11c7f63SJim Harris fw_device,
356f11c7f63SJim Harris sci_base_object_get_logger(fw_device),
357f11c7f63SJim Harris scif_sas_io_request_state_table
358f11c7f63SJim Harris );
359f11c7f63SJim Harris
360f11c7f63SJim Harris fw_io->parent.core_object = scic_io_request;
361f11c7f63SJim Harris
362f11c7f63SJim Harris //set association
363f11c7f63SJim Harris sci_object_set_association(fw_io, user_io_request_object);
364f11c7f63SJim Harris sci_object_set_association(fw_io->parent.core_object, fw_io);
365f11c7f63SJim Harris
366f11c7f63SJim Harris
367f11c7f63SJim Harris sci_base_state_machine_logger_initialize(
368f11c7f63SJim Harris &fw_io->parent.parent.state_machine_logger,
369f11c7f63SJim Harris &fw_io->parent.parent.state_machine,
370f11c7f63SJim Harris &fw_io->parent.parent.parent,
371f11c7f63SJim Harris scif_cb_logger_log_states,
372f11c7f63SJim Harris "SCIF_IO_REQUEST_T", "base_state_machine",
373f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST
374f11c7f63SJim Harris );
375f11c7f63SJim Harris
376f11c7f63SJim Harris return status;
377f11c7f63SJim Harris }
378f11c7f63SJim Harris
379f11c7f63SJim Harris // ---------------------------------------------------------------------------
380f11c7f63SJim Harris
scif_io_request_get_response_iu_address(SCI_IO_REQUEST_HANDLE_T scif_io_request)381f11c7f63SJim Harris void * scif_io_request_get_response_iu_address(
382f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T scif_io_request
383f11c7f63SJim Harris )
384f11c7f63SJim Harris {
385f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)scif_io_request;
386f11c7f63SJim Harris
387f11c7f63SJim Harris return (scic_io_request_get_response_iu_address(fw_io->parent.core_object ));
388f11c7f63SJim Harris }
389f11c7f63SJim Harris
390f11c7f63SJim Harris // ---------------------------------------------------------------------------
391f11c7f63SJim Harris
scif_io_request_get_scic_handle(SCI_IO_REQUEST_HANDLE_T scif_io_request)392f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T scif_io_request_get_scic_handle(
393f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T scif_io_request
394f11c7f63SJim Harris )
395f11c7f63SJim Harris {
396f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*) scif_io_request;
397f11c7f63SJim Harris return fw_io->parent.core_object;
398f11c7f63SJim Harris }
399f11c7f63SJim Harris
400f11c7f63SJim Harris // ---------------------------------------------------------------------------
401f11c7f63SJim Harris
scic_cb_io_request_complete(SCI_CONTROLLER_HANDLE_T controller,SCI_REMOTE_DEVICE_HANDLE_T remote_device,SCI_IO_REQUEST_HANDLE_T io_request,SCI_IO_STATUS completion_status)402f11c7f63SJim Harris void scic_cb_io_request_complete(
403f11c7f63SJim Harris SCI_CONTROLLER_HANDLE_T controller,
404f11c7f63SJim Harris SCI_REMOTE_DEVICE_HANDLE_T remote_device,
405f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T io_request,
406f11c7f63SJim Harris SCI_IO_STATUS completion_status
407f11c7f63SJim Harris )
408f11c7f63SJim Harris {
409f11c7f63SJim Harris SCI_STATUS status;
410f11c7f63SJim Harris SCIF_SAS_CONTROLLER_T * fw_controller = (SCIF_SAS_CONTROLLER_T*)
411f11c7f63SJim Harris sci_object_get_association(controller);
412f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T * fw_device = (SCIF_SAS_REMOTE_DEVICE_T*)
413f11c7f63SJim Harris sci_object_get_association(remote_device);
414f11c7f63SJim Harris SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T*)
415f11c7f63SJim Harris sci_object_get_association(io_request);
416f11c7f63SJim Harris
417f11c7f63SJim Harris SCIF_LOG_TRACE((
418f11c7f63SJim Harris sci_base_object_get_logger(controller),
419f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST,
420f11c7f63SJim Harris "scic_cb_io_request_complete(0x%x, 0x%x, 0x%x, 0x%x) enter\n",
421f11c7f63SJim Harris controller, remote_device, io_request, completion_status
422f11c7f63SJim Harris ));
423f11c7f63SJim Harris
424f11c7f63SJim Harris // Invoke the common completion handler routine.
425f11c7f63SJim Harris // A non-successful return indicates we are not in a correct state to
426f11c7f63SJim Harris // receive a completion notification for this request.
427f11c7f63SJim Harris status = fw_request->state_handlers->complete_handler(&fw_request->parent);
428f11c7f63SJim Harris
429f11c7f63SJim Harris // If the status indicates the completion handler was successful, then
430f11c7f63SJim Harris // allow protocol specific completion processing to occur.
431f11c7f63SJim Harris if (status == SCI_SUCCESS)
432f11c7f63SJim Harris {
433f11c7f63SJim Harris if (fw_request->protocol_complete_handler != NULL)
434f11c7f63SJim Harris {
435f11c7f63SJim Harris status = fw_request->protocol_complete_handler(
436f11c7f63SJim Harris fw_controller, fw_device, fw_request, (SCI_STATUS *)&completion_status
437f11c7f63SJim Harris );
438f11c7f63SJim Harris }
439f11c7f63SJim Harris
440f11c7f63SJim Harris // If this isn't an internal framework IO request, then simply pass the
441f11c7f63SJim Harris // notification up to the SCIF user.
442f11c7f63SJim Harris if ( status == SCI_SUCCESS )
443f11c7f63SJim Harris {
444f11c7f63SJim Harris if (fw_request->is_high_priority == FALSE)
445f11c7f63SJim Harris {
446f11c7f63SJim Harris if (fw_request->is_waiting_for_abort_task_set == FALSE)
447f11c7f63SJim Harris {
448f11c7f63SJim Harris scif_cb_io_request_complete(
449f11c7f63SJim Harris fw_controller, fw_device, fw_request, completion_status);
450f11c7f63SJim Harris }
451f11c7f63SJim Harris else
452f11c7f63SJim Harris {
453f11c7f63SJim Harris // do nothing - will complete the I/O when the abort task
454f11c7f63SJim Harris // set completes
455f11c7f63SJim Harris }
456f11c7f63SJim Harris }
457f11c7f63SJim Harris else
458f11c7f63SJim Harris scif_sas_controller_complete_high_priority_io(
459f11c7f63SJim Harris fw_controller, fw_device, fw_request);
460f11c7f63SJim Harris }
461f11c7f63SJim Harris else if ( status == SCI_WARNING_SEQUENCE_INCOMPLETE )
462f11c7f63SJim Harris {
463f11c7f63SJim Harris scif_sas_io_request_continue(fw_controller, fw_device, fw_request);
464f11c7f63SJim Harris }
465f11c7f63SJim Harris }
466f11c7f63SJim Harris }
467f11c7f63SJim Harris
468f11c7f63SJim Harris // ---------------------------------------------------------------------------
469f11c7f63SJim Harris
scic_cb_io_request_get_transfer_length(void * scic_user_io_request)470f11c7f63SJim Harris U32 scic_cb_io_request_get_transfer_length(
471f11c7f63SJim Harris void * scic_user_io_request
472f11c7f63SJim Harris )
473f11c7f63SJim Harris {
474f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
475f11c7f63SJim Harris scic_user_io_request;
476f11c7f63SJim Harris
477f11c7f63SJim Harris return (scif_cb_io_request_get_transfer_length(
478f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object
479f11c7f63SJim Harris ));
480f11c7f63SJim Harris }
481f11c7f63SJim Harris
482f11c7f63SJim Harris // ---------------------------------------------------------------------------
483f11c7f63SJim Harris
scic_cb_io_request_get_data_direction(void * scic_user_io_request)484f11c7f63SJim Harris SCI_IO_REQUEST_DATA_DIRECTION scic_cb_io_request_get_data_direction(
485f11c7f63SJim Harris void * scic_user_io_request
486f11c7f63SJim Harris )
487f11c7f63SJim Harris {
488f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
489f11c7f63SJim Harris scic_user_io_request;
490f11c7f63SJim Harris
491f11c7f63SJim Harris return (scif_cb_io_request_get_data_direction(
492f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object
493f11c7f63SJim Harris ));
494f11c7f63SJim Harris }
495f11c7f63SJim Harris
496f11c7f63SJim Harris // ---------------------------------------------------------------------------
497f11c7f63SJim Harris #ifndef SCI_SGL_OPTIMIZATION_ENABLED
scic_cb_io_request_get_next_sge(void * scic_user_io_request,void * current_sge_address,void ** next_sge)498f11c7f63SJim Harris void scic_cb_io_request_get_next_sge(
499f11c7f63SJim Harris void * scic_user_io_request,
500f11c7f63SJim Harris void * current_sge_address,
501f11c7f63SJim Harris void **next_sge
502f11c7f63SJim Harris )
503f11c7f63SJim Harris {
504f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
505f11c7f63SJim Harris scic_user_io_request;
506f11c7f63SJim Harris
507f11c7f63SJim Harris scif_cb_io_request_get_next_sge(
508f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object,
509f11c7f63SJim Harris current_sge_address,
510f11c7f63SJim Harris next_sge
511f11c7f63SJim Harris );
512f11c7f63SJim Harris }
513f11c7f63SJim Harris #endif
514f11c7f63SJim Harris
515f11c7f63SJim Harris // ---------------------------------------------------------------------------
516f11c7f63SJim Harris
scic_cb_sge_get_address_field(void * scic_user_io_request,void * sge_address)517f11c7f63SJim Harris SCI_PHYSICAL_ADDRESS scic_cb_sge_get_address_field(
518f11c7f63SJim Harris void * scic_user_io_request,
519f11c7f63SJim Harris void * sge_address
520f11c7f63SJim Harris )
521f11c7f63SJim Harris {
522f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
523f11c7f63SJim Harris scic_user_io_request;
524f11c7f63SJim Harris return scif_cb_sge_get_address_field(
525f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object, sge_address
526f11c7f63SJim Harris );
527f11c7f63SJim Harris }
528f11c7f63SJim Harris
529f11c7f63SJim Harris // ---------------------------------------------------------------------------
530f11c7f63SJim Harris
scic_cb_sge_get_length_field(void * scic_user_io_request,void * sge_address)531f11c7f63SJim Harris U32 scic_cb_sge_get_length_field(
532f11c7f63SJim Harris void * scic_user_io_request,
533f11c7f63SJim Harris void * sge_address
534f11c7f63SJim Harris )
535f11c7f63SJim Harris {
536f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
537f11c7f63SJim Harris scic_user_io_request;
538f11c7f63SJim Harris
539f11c7f63SJim Harris return scif_cb_sge_get_length_field(
540f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object,
541f11c7f63SJim Harris sge_address
542f11c7f63SJim Harris );
543f11c7f63SJim Harris }
544f11c7f63SJim Harris
545f11c7f63SJim Harris // ---------------------------------------------------------------------------
546f11c7f63SJim Harris
scic_cb_ssp_io_request_get_cdb_address(void * scic_user_io_request)547f11c7f63SJim Harris void * scic_cb_ssp_io_request_get_cdb_address(
548f11c7f63SJim Harris void * scic_user_io_request
549f11c7f63SJim Harris )
550f11c7f63SJim Harris {
551f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
552f11c7f63SJim Harris scic_user_io_request;
553f11c7f63SJim Harris
554f11c7f63SJim Harris return scif_cb_io_request_get_cdb_address(
555f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object
556f11c7f63SJim Harris );
557f11c7f63SJim Harris }
558f11c7f63SJim Harris
559f11c7f63SJim Harris // ---------------------------------------------------------------------------
560f11c7f63SJim Harris
scic_cb_ssp_io_request_get_cdb_length(void * scic_user_io_request)561f11c7f63SJim Harris U32 scic_cb_ssp_io_request_get_cdb_length(
562f11c7f63SJim Harris void * scic_user_io_request
563f11c7f63SJim Harris )
564f11c7f63SJim Harris {
565f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
566f11c7f63SJim Harris scic_user_io_request;
567f11c7f63SJim Harris
568f11c7f63SJim Harris return scif_cb_io_request_get_cdb_length(
569f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object
570f11c7f63SJim Harris );
571f11c7f63SJim Harris }
572f11c7f63SJim Harris
573f11c7f63SJim Harris // ---------------------------------------------------------------------------
574f11c7f63SJim Harris
575f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
scic_cb_stp_packet_io_request_get_cdb_address(void * scic_user_io_request)576f11c7f63SJim Harris void * scic_cb_stp_packet_io_request_get_cdb_address(
577f11c7f63SJim Harris void * scic_user_io_request
578f11c7f63SJim Harris )
579f11c7f63SJim Harris {
580f11c7f63SJim Harris SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T*)scic_user_io_request;
581f11c7f63SJim Harris
582f11c7f63SJim Harris SATI_TRANSLATOR_SEQUENCE_T * sati_sequence = &fw_request->stp.sequence;
583f11c7f63SJim Harris
584f11c7f63SJim Harris if (sati_sequence->state != SATI_SEQUENCE_STATE_INCOMPLETE)
585f11c7f63SJim Harris return scif_cb_io_request_get_cdb_address(
586f11c7f63SJim Harris fw_request->parent.parent.associated_object
587f11c7f63SJim Harris );
588f11c7f63SJim Harris else
589f11c7f63SJim Harris return
590f11c7f63SJim Harris &(sati_sequence->command_specific_data.sati_atapi_data.request_sense_cdb);
591f11c7f63SJim Harris }
592f11c7f63SJim Harris #endif
593f11c7f63SJim Harris
594f11c7f63SJim Harris // ---------------------------------------------------------------------------
595f11c7f63SJim Harris
596f11c7f63SJim Harris #if !defined(DISABLE_ATAPI)
scic_cb_stp_packet_io_request_get_cdb_length(void * scic_user_io_request)597f11c7f63SJim Harris U32 scic_cb_stp_packet_io_request_get_cdb_length(
598f11c7f63SJim Harris void * scic_user_io_request
599f11c7f63SJim Harris )
600f11c7f63SJim Harris {
601f11c7f63SJim Harris SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T*)
602f11c7f63SJim Harris scic_user_io_request;
603f11c7f63SJim Harris
604f11c7f63SJim Harris SATI_TRANSLATOR_SEQUENCE_T * sati_sequence = &fw_request->stp.sequence;
605f11c7f63SJim Harris
606f11c7f63SJim Harris if (sati_sequence->state != SATI_SEQUENCE_STATE_INCOMPLETE)
607f11c7f63SJim Harris return scif_cb_io_request_get_cdb_length(
608f11c7f63SJim Harris fw_request->parent.parent.associated_object
609f11c7f63SJim Harris );
610f11c7f63SJim Harris else
611f11c7f63SJim Harris return SATI_ATAPI_REQUEST_SENSE_CDB_LENGTH;
612f11c7f63SJim Harris }
613f11c7f63SJim Harris #endif
614f11c7f63SJim Harris
615f11c7f63SJim Harris // ---------------------------------------------------------------------------
616f11c7f63SJim Harris
scic_cb_ssp_io_request_get_lun(void * scic_user_io_request)617f11c7f63SJim Harris U32 scic_cb_ssp_io_request_get_lun(
618f11c7f63SJim Harris void * scic_user_io_request
619f11c7f63SJim Harris )
620f11c7f63SJim Harris {
621f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
622f11c7f63SJim Harris scic_user_io_request;
623f11c7f63SJim Harris
624f11c7f63SJim Harris return scif_cb_io_request_get_lun(
625f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object
626f11c7f63SJim Harris );
627f11c7f63SJim Harris }
628f11c7f63SJim Harris
629f11c7f63SJim Harris // ---------------------------------------------------------------------------
630f11c7f63SJim Harris
scic_cb_ssp_io_request_get_task_attribute(void * scic_user_io_request)631f11c7f63SJim Harris U32 scic_cb_ssp_io_request_get_task_attribute(
632f11c7f63SJim Harris void * scic_user_io_request
633f11c7f63SJim Harris )
634f11c7f63SJim Harris {
635f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
636f11c7f63SJim Harris scic_user_io_request;
637f11c7f63SJim Harris
638f11c7f63SJim Harris return scif_cb_io_request_get_task_attribute(
639f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object
640f11c7f63SJim Harris );
641f11c7f63SJim Harris }
642f11c7f63SJim Harris
643f11c7f63SJim Harris // ---------------------------------------------------------------------------
644f11c7f63SJim Harris
scic_cb_ssp_io_request_get_command_priority(void * scic_user_io_request)645f11c7f63SJim Harris U32 scic_cb_ssp_io_request_get_command_priority(
646f11c7f63SJim Harris void * scic_user_io_request
647f11c7f63SJim Harris )
648f11c7f63SJim Harris {
649f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io = (SCIF_SAS_IO_REQUEST_T*)
650f11c7f63SJim Harris scic_user_io_request;
651f11c7f63SJim Harris
652f11c7f63SJim Harris return scif_cb_io_request_get_command_priority(
653f11c7f63SJim Harris fw_io->parent.parent.parent.associated_object
654f11c7f63SJim Harris );
655f11c7f63SJim Harris }
656f11c7f63SJim Harris
657f11c7f63SJim Harris // ---------------------------------------------------------------------------
658f11c7f63SJim Harris
scic_cb_request_is_initial_construction(void * scic_user_io_request)659f11c7f63SJim Harris BOOL scic_cb_request_is_initial_construction(
660f11c7f63SJim Harris void * scic_user_io_request
661f11c7f63SJim Harris )
662f11c7f63SJim Harris {
663f11c7f63SJim Harris SCIF_SAS_REQUEST_T * fw_request = (SCIF_SAS_REQUEST_T*)
664f11c7f63SJim Harris scic_user_io_request;
665f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T* fw_device = fw_request->device;
666f11c7f63SJim Harris
667f11c7f63SJim Harris SMP_DISCOVER_RESPONSE_PROTOCOLS_T dev_protocols;
668f11c7f63SJim Harris scic_remote_device_get_protocols(fw_device->core_object, &dev_protocols);
669f11c7f63SJim Harris
670f11c7f63SJim Harris if (dev_protocols.u.bits.attached_stp_target
671f11c7f63SJim Harris && fw_request->stp.sequence.state == SATI_SEQUENCE_STATE_INCOMPLETE)
672f11c7f63SJim Harris return FALSE;
673f11c7f63SJim Harris
674f11c7f63SJim Harris return TRUE;
675f11c7f63SJim Harris }
676f11c7f63SJim Harris
677f11c7f63SJim Harris
678f11c7f63SJim Harris //******************************************************************************
679f11c7f63SJim Harris //* P R O T E C T E D M E T H O D S
680f11c7f63SJim Harris //******************************************************************************
681f11c7f63SJim Harris /**
682f11c7f63SJim Harris * @brief This method constructs an scif sas smp request.
683f11c7f63SJim Harris *
684f11c7f63SJim Harris * @param[in] fw_controller The framework controller
685f11c7f63SJim Harris * @param[in] fw_device The smp device that the smp request targets to.
686f11c7f63SJim Harris * @param[in] fw_io_memory The memory space for the smp request.
687f11c7f63SJim Harris * @param[in] core_io_memory The memory space for the core request.
688f11c7f63SJim Harris * @param[in] io_tag The io tag for the internl io to be constructed.
689f11c7f63SJim Harris * @param[in] smp_command A pointer to the smp request data structure according
690f11c7f63SJim Harris * to SAS protocol.
691f11c7f63SJim Harris *
692f11c7f63SJim Harris * @return Indicate if the internal io was successfully constructed.
693f11c7f63SJim Harris * @retval SCI_SUCCESS This value is returned if the internal io was
694f11c7f63SJim Harris * successfully constructed.
695f11c7f63SJim Harris * @retval SCI_FAILURE This value is returned if the internal io was failed to
696f11c7f63SJim Harris * be constructed.
697f11c7f63SJim Harris */
scif_sas_io_request_construct_smp(SCIF_SAS_CONTROLLER_T * fw_controller,SCIF_SAS_REMOTE_DEVICE_T * fw_device,void * fw_io_memory,void * core_io_memory,U16 io_tag,SMP_REQUEST_T * smp_command,void * user_request_object)698f11c7f63SJim Harris SCI_STATUS scif_sas_io_request_construct_smp(
699f11c7f63SJim Harris SCIF_SAS_CONTROLLER_T * fw_controller,
700f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T * fw_device,
701f11c7f63SJim Harris void * fw_io_memory,
702f11c7f63SJim Harris void * core_io_memory,
703f11c7f63SJim Harris U16 io_tag,
704f11c7f63SJim Harris SMP_REQUEST_T * smp_command,
705f11c7f63SJim Harris void * user_request_object
706f11c7f63SJim Harris )
707f11c7f63SJim Harris {
708f11c7f63SJim Harris SCIF_SAS_IO_REQUEST_T * fw_io =
709f11c7f63SJim Harris (SCIF_SAS_IO_REQUEST_T*)fw_io_memory;
710f11c7f63SJim Harris
711f11c7f63SJim Harris SCI_STATUS status = SCI_SUCCESS;
712f11c7f63SJim Harris
713f11c7f63SJim Harris SCIF_LOG_TRACE((
714f11c7f63SJim Harris sci_base_object_get_logger(fw_device),
715f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST,
716f11c7f63SJim Harris "scif_sas_io_request_construct_smp(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) enter\n",
717f11c7f63SJim Harris fw_controller,
718f11c7f63SJim Harris fw_device,
719f11c7f63SJim Harris fw_io_memory,
720f11c7f63SJim Harris core_io_memory,
721f11c7f63SJim Harris io_tag,
722f11c7f63SJim Harris smp_command,
723f11c7f63SJim Harris user_request_object
724f11c7f63SJim Harris ));
725f11c7f63SJim Harris
726f11c7f63SJim Harris // Construct the parent object first in order to ensure logging can
727f11c7f63SJim Harris // function.
728f11c7f63SJim Harris scif_sas_request_construct(
729f11c7f63SJim Harris &fw_io->parent,
730f11c7f63SJim Harris fw_device,
731f11c7f63SJim Harris sci_base_object_get_logger(fw_controller),
732f11c7f63SJim Harris scif_sas_io_request_state_table
733f11c7f63SJim Harris );
734f11c7f63SJim Harris
735f11c7f63SJim Harris status = scic_io_request_construct(
736f11c7f63SJim Harris fw_device->domain->controller->core_object,
737f11c7f63SJim Harris fw_device->core_object,
738f11c7f63SJim Harris io_tag,
739f11c7f63SJim Harris (void*)fw_io,
740f11c7f63SJim Harris (U8 *)core_io_memory,
741f11c7f63SJim Harris &fw_io->parent.core_object
742f11c7f63SJim Harris );
743f11c7f63SJim Harris
744f11c7f63SJim Harris if (status == SCI_SUCCESS)
745f11c7f63SJim Harris {
746f11c7f63SJim Harris //set object association.
747f11c7f63SJim Harris sci_object_set_association(fw_io, user_request_object);
748f11c7f63SJim Harris sci_object_set_association(fw_io->parent.core_object, fw_io);
749f11c7f63SJim Harris
750f11c7f63SJim Harris scif_sas_smp_request_construct(&fw_io->parent, smp_command);
751f11c7f63SJim Harris
752f11c7f63SJim Harris fw_io->parent.is_high_priority = TRUE;
753f11c7f63SJim Harris
754f11c7f63SJim Harris sci_base_state_machine_logger_initialize(
755f11c7f63SJim Harris &fw_io->parent.parent.state_machine_logger,
756f11c7f63SJim Harris &fw_io->parent.parent.state_machine,
757f11c7f63SJim Harris &fw_io->parent.parent.parent,
758f11c7f63SJim Harris scif_cb_logger_log_states,
759f11c7f63SJim Harris "SCIF_IO_REQUEST_T", "base_state_machine",
760f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST
761f11c7f63SJim Harris );
762f11c7f63SJim Harris }
763f11c7f63SJim Harris
764f11c7f63SJim Harris return status;
765f11c7f63SJim Harris }
766f11c7f63SJim Harris
767f11c7f63SJim Harris
768f11c7f63SJim Harris /**
769f11c7f63SJim Harris * @brief This method continues a scif sas request.
770f11c7f63SJim Harris *
771f11c7f63SJim Harris * @param[in] fw_controller The framework controller
772f11c7f63SJim Harris * @param[in] fw_device The device that the IO request targets to.
773f11c7f63SJim Harris * @param[in] fw_request The IO request to be continued.
774f11c7f63SJim Harris *
775f11c7f63SJim Harris * @return Indicate if the internal io was successfully constructed.
776f11c7f63SJim Harris * @retval SCI_SUCCESS This value is returned if the internal io was
777f11c7f63SJim Harris * successfully continued.
778f11c7f63SJim Harris * @retval SCI_FAILURE This value is returned if the io was failed to
779f11c7f63SJim Harris * be continued.
780f11c7f63SJim Harris */
scif_sas_io_request_continue(SCIF_SAS_CONTROLLER_T * fw_controller,SCIF_SAS_REMOTE_DEVICE_T * fw_device,SCIF_SAS_REQUEST_T * fw_request)781f11c7f63SJim Harris SCI_STATUS scif_sas_io_request_continue(
782f11c7f63SJim Harris SCIF_SAS_CONTROLLER_T * fw_controller,
783f11c7f63SJim Harris SCIF_SAS_REMOTE_DEVICE_T * fw_device,
784f11c7f63SJim Harris SCIF_SAS_REQUEST_T * fw_request
785f11c7f63SJim Harris )
786f11c7f63SJim Harris {
787f11c7f63SJim Harris SCI_IO_REQUEST_HANDLE_T dummy_handle;
788f11c7f63SJim Harris
789f11c7f63SJim Harris SCIF_LOG_TRACE((
790f11c7f63SJim Harris sci_base_object_get_logger(fw_request),
791f11c7f63SJim Harris SCIF_LOG_OBJECT_IO_REQUEST,
792f11c7f63SJim Harris "scif_sas_io_request_continue(0x%x, 0x%x, 0x%x) enter\n",
793f11c7f63SJim Harris fw_controller,
794f11c7f63SJim Harris fw_device,
795f11c7f63SJim Harris fw_request
796f11c7f63SJim Harris ));
797f11c7f63SJim Harris
798f11c7f63SJim Harris //complete this io request in framework and core.
799f11c7f63SJim Harris scif_controller_complete_io(fw_controller, fw_device, fw_request);
800f11c7f63SJim Harris
801f11c7f63SJim Harris //construct next command in the sequence using the same memory. We pass
802f11c7f63SJim Harris //a dummy pointer to let the framework user keep the pointer to this IO
803f11c7f63SJim Harris //request untouched.
804f11c7f63SJim Harris scif_sas_io_request_construct(
805f11c7f63SJim Harris fw_device,
806f11c7f63SJim Harris (SCIF_SAS_IO_REQUEST_T*)fw_request,
807f11c7f63SJim Harris SCI_CONTROLLER_INVALID_IO_TAG,
808f11c7f63SJim Harris (void *)sci_object_get_association(fw_request),
809f11c7f63SJim Harris &dummy_handle,
810f11c7f63SJim Harris FALSE
811f11c7f63SJim Harris );
812f11c7f63SJim Harris
813f11c7f63SJim Harris //start the new constructed IO.
8140f2a8452SJim Harris return (SCI_STATUS)scif_controller_start_io(
815f11c7f63SJim Harris (SCI_CONTROLLER_HANDLE_T) fw_controller,
816f11c7f63SJim Harris (SCI_REMOTE_DEVICE_HANDLE_T) fw_device,
817f11c7f63SJim Harris (SCI_IO_REQUEST_HANDLE_T) fw_request,
818f11c7f63SJim Harris SCI_CONTROLLER_INVALID_IO_TAG
819f11c7f63SJim Harris );
820f11c7f63SJim Harris }
821