xref: /openbmc/linux/drivers/scsi/isci/request.h (revision e301370ac553a9a0ac0d1d25e769b86cf60395b3)
16f231ddaSDan Williams /*
26f231ddaSDan Williams  * This file is provided under a dual BSD/GPLv2 license.  When using or
36f231ddaSDan Williams  * redistributing this file, you may do so under either license.
46f231ddaSDan Williams  *
56f231ddaSDan Williams  * GPL LICENSE SUMMARY
66f231ddaSDan Williams  *
76f231ddaSDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
86f231ddaSDan Williams  *
96f231ddaSDan Williams  * This program is free software; you can redistribute it and/or modify
106f231ddaSDan Williams  * it under the terms of version 2 of the GNU General Public License as
116f231ddaSDan Williams  * published by the Free Software Foundation.
126f231ddaSDan Williams  *
136f231ddaSDan Williams  * This program is distributed in the hope that it will be useful, but
146f231ddaSDan Williams  * WITHOUT ANY WARRANTY; without even the implied warranty of
156f231ddaSDan Williams  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
166f231ddaSDan Williams  * General Public License for more details.
176f231ddaSDan Williams  *
186f231ddaSDan Williams  * You should have received a copy of the GNU General Public License
196f231ddaSDan Williams  * along with this program; if not, write to the Free Software
206f231ddaSDan Williams  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
216f231ddaSDan Williams  * The full GNU General Public License is included in this distribution
226f231ddaSDan Williams  * in the file called LICENSE.GPL.
236f231ddaSDan Williams  *
246f231ddaSDan Williams  * BSD LICENSE
256f231ddaSDan Williams  *
266f231ddaSDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
276f231ddaSDan Williams  * All rights reserved.
286f231ddaSDan Williams  *
296f231ddaSDan Williams  * Redistribution and use in source and binary forms, with or without
306f231ddaSDan Williams  * modification, are permitted provided that the following conditions
316f231ddaSDan Williams  * are met:
326f231ddaSDan Williams  *
336f231ddaSDan Williams  *   * Redistributions of source code must retain the above copyright
346f231ddaSDan Williams  *     notice, this list of conditions and the following disclaimer.
356f231ddaSDan Williams  *   * Redistributions in binary form must reproduce the above copyright
366f231ddaSDan Williams  *     notice, this list of conditions and the following disclaimer in
376f231ddaSDan Williams  *     the documentation and/or other materials provided with the
386f231ddaSDan Williams  *     distribution.
396f231ddaSDan Williams  *   * Neither the name of Intel Corporation nor the names of its
406f231ddaSDan Williams  *     contributors may be used to endorse or promote products derived
416f231ddaSDan Williams  *     from this software without specific prior written permission.
426f231ddaSDan Williams  *
436f231ddaSDan Williams  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
446f231ddaSDan Williams  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
456f231ddaSDan Williams  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
466f231ddaSDan Williams  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
476f231ddaSDan Williams  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
486f231ddaSDan Williams  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
496f231ddaSDan Williams  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
506f231ddaSDan Williams  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
516f231ddaSDan Williams  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
526f231ddaSDan Williams  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
536f231ddaSDan Williams  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
546f231ddaSDan Williams  */
556f231ddaSDan Williams 
560d84366fSDan Williams #ifndef _ISCI_REQUEST_H_
576f231ddaSDan Williams #define _ISCI_REQUEST_H_
586f231ddaSDan Williams 
596f231ddaSDan Williams #include "isci.h"
60ce2b3261SDan Williams #include "host.h"
61f1f52e75SDan Williams #include "scu_task_context.h"
626f231ddaSDan Williams 
636f231ddaSDan Williams /**
646f231ddaSDan Williams  * struct isci_request_status - This enum defines the possible states of an I/O
656f231ddaSDan Williams  *    request.
666f231ddaSDan Williams  *
676f231ddaSDan Williams  *
686f231ddaSDan Williams  */
696f231ddaSDan Williams enum isci_request_status {
706f231ddaSDan Williams 	unallocated = 0x00,
716f231ddaSDan Williams 	allocated   = 0x01,
726f231ddaSDan Williams 	started     = 0x02,
736f231ddaSDan Williams 	completed   = 0x03,
746f231ddaSDan Williams 	aborting    = 0x04,
756f231ddaSDan Williams 	aborted     = 0x05,
764dc043c4SJeff Skirvin 	terminating = 0x06,
774dc043c4SJeff Skirvin 	dead        = 0x07
786f231ddaSDan Williams };
796f231ddaSDan Williams 
806f231ddaSDan Williams enum task_type {
816f231ddaSDan Williams 	io_task  = 0,
826f231ddaSDan Williams 	tmf_task = 1
836f231ddaSDan Williams };
846f231ddaSDan Williams 
85f1f52e75SDan Williams enum sci_request_protocol {
86f1f52e75SDan Williams 	SCIC_NO_PROTOCOL,
87f1f52e75SDan Williams 	SCIC_SMP_PROTOCOL,
88f1f52e75SDan Williams 	SCIC_SSP_PROTOCOL,
89f1f52e75SDan Williams 	SCIC_STP_PROTOCOL
90c72086e3SDan Williams }; /* XXX remove me, use sas_task.{dev|task_proto} instead */;
91f1f52e75SDan Williams 
925dec6f4eSDan Williams struct scic_sds_stp_request {
935dec6f4eSDan Williams 	union {
945dec6f4eSDan Williams 		u32 ncq;
955dec6f4eSDan Williams 
965dec6f4eSDan Williams 		u32 udma;
975dec6f4eSDan Williams 
985dec6f4eSDan Williams 		struct scic_sds_stp_pio_request {
99*e301370aSEdmund Nadolski 			/*
100*e301370aSEdmund Nadolski 			 * Total transfer for the entire PIO request recorded
101*e301370aSEdmund Nadolski 			 * at request constuction time.
1025dec6f4eSDan Williams 			 *
103*e301370aSEdmund Nadolski 			 * @todo Should we just decrement this value for each
104*e301370aSEdmund Nadolski 			 * byte of data transitted or received to elemenate
105*e301370aSEdmund Nadolski 			 * the current_transfer_bytes field?
1065dec6f4eSDan Williams 			 */
1075dec6f4eSDan Williams 			u32 total_transfer_bytes;
1085dec6f4eSDan Williams 
109*e301370aSEdmund Nadolski 			/*
110*e301370aSEdmund Nadolski 			 * Total number of bytes received/transmitted in data
111*e301370aSEdmund Nadolski 			 * frames since the start of the IO request.  At the
112*e301370aSEdmund Nadolski 			 * end of the IO request this should equal the
1135dec6f4eSDan Williams 			 * total_transfer_bytes.
1145dec6f4eSDan Williams 			 */
1155dec6f4eSDan Williams 			u32 current_transfer_bytes;
1165dec6f4eSDan Williams 
117*e301370aSEdmund Nadolski 			/*
118*e301370aSEdmund Nadolski 			 * The number of bytes requested in the in the PIO
119*e301370aSEdmund Nadolski 			 * setup.
1205dec6f4eSDan Williams 			 */
1215dec6f4eSDan Williams 			u32 pio_transfer_bytes;
1225dec6f4eSDan Williams 
123*e301370aSEdmund Nadolski 			/*
124*e301370aSEdmund Nadolski 			 * PIO Setup ending status value to tell us if we need
125*e301370aSEdmund Nadolski 			 * to wait for another FIS or if the transfer is
126*e301370aSEdmund Nadolski 			 * complete. On the receipt of a D2H FIS this will be
1275dec6f4eSDan Williams 			 * the status field of that FIS.
1285dec6f4eSDan Williams 			 */
1295dec6f4eSDan Williams 			u8 ending_status;
1305dec6f4eSDan Williams 
131*e301370aSEdmund Nadolski 			/*
132*e301370aSEdmund Nadolski 			 * On receipt of a D2H FIS this will be the ending
133*e301370aSEdmund Nadolski 			 * error field if the ending_status has the
134*e301370aSEdmund Nadolski 			 * SATA_STATUS_ERR bit set.
1355dec6f4eSDan Williams 			 */
1365dec6f4eSDan Williams 			u8 ending_error;
1375dec6f4eSDan Williams 
1385dec6f4eSDan Williams 			struct scic_sds_request_pio_sgl {
1395dec6f4eSDan Williams 				struct scu_sgl_element_pair *sgl_pair;
1405dec6f4eSDan Williams 				u8 sgl_set;
1415dec6f4eSDan Williams 				u32 sgl_offset;
1425dec6f4eSDan Williams 			} request_current;
1435dec6f4eSDan Williams 		} pio;
1445dec6f4eSDan Williams 
1455dec6f4eSDan Williams 		struct {
146*e301370aSEdmund Nadolski 			/*
147*e301370aSEdmund Nadolski 			 * The number of bytes requested in the PIO setup
148*e301370aSEdmund Nadolski 			 * before CDB data frame.
1495dec6f4eSDan Williams 			 */
1505dec6f4eSDan Williams 			u32 device_preferred_cdb_length;
1515dec6f4eSDan Williams 		} packet;
1525dec6f4eSDan Williams 	} type;
1535dec6f4eSDan Williams };
1545dec6f4eSDan Williams 
155f1f52e75SDan Williams struct scic_sds_request {
156*e301370aSEdmund Nadolski 	/*
157*e301370aSEdmund Nadolski 	 * This field contains the information for the base request state
158*e301370aSEdmund Nadolski 	 * machine.
159f1f52e75SDan Williams 	 */
160*e301370aSEdmund Nadolski 	struct sci_base_state_machine sm;
161f1f52e75SDan Williams 
162*e301370aSEdmund Nadolski 	/*
163f1f52e75SDan Williams 	 * This field simply points to the controller to which this IO request
164f1f52e75SDan Williams 	 * is associated.
165f1f52e75SDan Williams 	 */
166f1f52e75SDan Williams 	struct scic_sds_controller *owning_controller;
167f1f52e75SDan Williams 
168*e301370aSEdmund Nadolski 	/*
169*e301370aSEdmund Nadolski 	 * This field simply points to the remote device to which this IO
170*e301370aSEdmund Nadolski 	 * request is associated.
171f1f52e75SDan Williams 	 */
172f1f52e75SDan Williams 	struct scic_sds_remote_device *target_device;
173f1f52e75SDan Williams 
174*e301370aSEdmund Nadolski 	/*
175f1f52e75SDan Williams 	 * This field is utilized to determine if the SCI user is managing
176f1f52e75SDan Williams 	 * the IO tag for this request or if the core is managing it.
177f1f52e75SDan Williams 	 */
178f1f52e75SDan Williams 	bool was_tag_assigned_by_user;
179f1f52e75SDan Williams 
180*e301370aSEdmund Nadolski 	/*
181f1f52e75SDan Williams 	 * This field indicates the IO tag for this request.  The IO tag is
182f1f52e75SDan Williams 	 * comprised of the task_index and a sequence count. The sequence count
183f1f52e75SDan Williams 	 * is utilized to help identify tasks from one life to another.
184f1f52e75SDan Williams 	 */
185f1f52e75SDan Williams 	u16 io_tag;
186f1f52e75SDan Williams 
187*e301370aSEdmund Nadolski 	/*
188f1f52e75SDan Williams 	 * This field specifies the protocol being utilized for this
189f1f52e75SDan Williams 	 * IO request.
190f1f52e75SDan Williams 	 */
191f1f52e75SDan Williams 	enum sci_request_protocol protocol;
192f1f52e75SDan Williams 
193*e301370aSEdmund Nadolski 	/*
194f1f52e75SDan Williams 	 * This field indicates the completion status taken from the SCUs
195*e301370aSEdmund Nadolski 	 * completion code.  It indicates the completion result for the SCU
196*e301370aSEdmund Nadolski 	 * hardware.
197f1f52e75SDan Williams 	 */
198f1f52e75SDan Williams 	u32 scu_status;
199f1f52e75SDan Williams 
200*e301370aSEdmund Nadolski 	/*
201*e301370aSEdmund Nadolski 	 * This field indicates the completion status returned to the SCI user.
202*e301370aSEdmund Nadolski 	 * It indicates the users view of the io request completion.
203f1f52e75SDan Williams 	 */
204f1f52e75SDan Williams 	u32 sci_status;
205f1f52e75SDan Williams 
206*e301370aSEdmund Nadolski 	/*
207*e301370aSEdmund Nadolski 	 * This field contains the value to be utilized when posting
208*e301370aSEdmund Nadolski 	 * (e.g. Post_TC, * Post_TC_Abort) this request to the silicon.
209f1f52e75SDan Williams 	 */
210f1f52e75SDan Williams 	u32 post_context;
211f1f52e75SDan Williams 
212f1f52e75SDan Williams 	struct scu_task_context *task_context_buffer;
213f1f52e75SDan Williams 	struct scu_task_context tc ____cacheline_aligned;
214f1f52e75SDan Williams 
215f1f52e75SDan Williams 	/* could be larger with sg chaining */
216f1f52e75SDan Williams 	#define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2)
217f1f52e75SDan Williams 	struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
218f1f52e75SDan Williams 
219*e301370aSEdmund Nadolski 	/*
220f1f52e75SDan Williams 	 * This field indicates if this request is a task management request or
221f1f52e75SDan Williams 	 * normal IO request.
222f1f52e75SDan Williams 	 */
223f1f52e75SDan Williams 	bool is_task_management_request;
224f1f52e75SDan Williams 
225*e301370aSEdmund Nadolski 	/*
226*e301370aSEdmund Nadolski 	 * This field is a pointer to the stored rx frame data.  It is used in
227*e301370aSEdmund Nadolski 	 * STP internal requests and SMP response frames.  If this field is
228*e301370aSEdmund Nadolski 	 * non-NULL the saved frame must be released on IO request completion.
229f1f52e75SDan Williams 	 *
230f1f52e75SDan Williams 	 * @todo In the future do we want to keep a list of RX frame buffers?
231f1f52e75SDan Williams 	 */
232f1f52e75SDan Williams 	u32 saved_rx_frame_index;
233f1f52e75SDan Williams 
234*e301370aSEdmund Nadolski 	/*
235*e301370aSEdmund Nadolski 	 * This field in the recorded device sequence for the io request.
236*e301370aSEdmund Nadolski 	 * This is recorded during the build operation and is compared in the
237*e301370aSEdmund Nadolski 	 * start operation.  If the sequence is different then there was a
238*e301370aSEdmund Nadolski 	 * change of devices from the build to start operations.
239f1f52e75SDan Williams 	 */
240f1f52e75SDan Williams 	u8 device_sequence;
241f1f52e75SDan Williams 
242f1f52e75SDan Williams 	union {
243f1f52e75SDan Williams 		struct {
244f1f52e75SDan Williams 			union {
245f1f52e75SDan Williams 				struct ssp_cmd_iu cmd;
246f1f52e75SDan Williams 				struct ssp_task_iu tmf;
247f1f52e75SDan Williams 			};
248f1f52e75SDan Williams 			union {
249f1f52e75SDan Williams 				struct ssp_response_iu rsp;
250f1f52e75SDan Williams 				u8 rsp_buf[SSP_RESP_IU_MAX_SIZE];
251f1f52e75SDan Williams 			};
252f1f52e75SDan Williams 		} ssp;
253f1f52e75SDan Williams 
254f1f52e75SDan Williams 		struct {
255f1f52e75SDan Williams 			struct smp_req cmd;
256f1f52e75SDan Williams 			struct smp_resp rsp;
257f1f52e75SDan Williams 		} smp;
258f1f52e75SDan Williams 
259f1f52e75SDan Williams 		struct {
260f1f52e75SDan Williams 			struct scic_sds_stp_request req;
261f1f52e75SDan Williams 			struct host_to_dev_fis cmd;
262f1f52e75SDan Williams 			struct dev_to_host_fis rsp;
263f1f52e75SDan Williams 		} stp;
264f1f52e75SDan Williams 	};
265f1f52e75SDan Williams 
266f1f52e75SDan Williams };
267f1f52e75SDan Williams 
268f1f52e75SDan Williams static inline struct scic_sds_request *to_sci_req(struct scic_sds_stp_request *stp_req)
269f1f52e75SDan Williams {
270f1f52e75SDan Williams 	struct scic_sds_request *sci_req;
271f1f52e75SDan Williams 
272f1f52e75SDan Williams 	sci_req = container_of(stp_req, typeof(*sci_req), stp.req);
273f1f52e75SDan Williams 	return sci_req;
274f1f52e75SDan Williams }
275f1f52e75SDan Williams 
2766f231ddaSDan Williams struct isci_request {
2776f231ddaSDan Williams 	enum isci_request_status status;
2786f231ddaSDan Williams 	enum task_type ttype;
2796f231ddaSDan Williams 	unsigned short io_tag;
2806f231ddaSDan Williams 	bool complete_in_target;
28167ea838dSDan Williams 	bool terminated;
2826f231ddaSDan Williams 
2836f231ddaSDan Williams 	union ttype_ptr_union {
2846f231ddaSDan Williams 		struct sas_task *io_task_ptr;   /* When ttype==io_task  */
2856f231ddaSDan Williams 		struct isci_tmf *tmf_task_ptr;  /* When ttype==tmf_task */
2866f231ddaSDan Williams 	} ttype_ptr;
2876f231ddaSDan Williams 	struct isci_host *isci_host;
2886f231ddaSDan Williams 	struct isci_remote_device *isci_device;
2896f231ddaSDan Williams 	/* For use in the requests_to_{complete|abort} lists: */
2906f231ddaSDan Williams 	struct list_head completed_node;
2916f231ddaSDan Williams 	/* For use in the reqs_in_process list: */
2926f231ddaSDan Williams 	struct list_head dev_node;
2936f231ddaSDan Williams 	spinlock_t state_lock;
2946f231ddaSDan Williams 	dma_addr_t request_daddr;
2956f231ddaSDan Williams 	dma_addr_t zero_scatter_daddr;
2966f231ddaSDan Williams 
2976f231ddaSDan Williams 	unsigned int num_sg_entries;			/* returned by pci_alloc_sg */
2986f231ddaSDan Williams 
2996f231ddaSDan Williams 	/** Note: "io_request_completion" is completed in two different ways
3006f231ddaSDan Williams 	 * depending on whether this is a TMF or regular request.
3016f231ddaSDan Williams 	 * - TMF requests are completed in the thread that started them;
3026f231ddaSDan Williams 	 * - regular requests are completed in the request completion callback
3036f231ddaSDan Williams 	 *   function.
3046f231ddaSDan Williams 	 * This difference in operation allows the aborter of a TMF request
3056f231ddaSDan Williams 	 * to be sure that once the TMF request completes, the I/O that the
3066f231ddaSDan Williams 	 * TMF was aborting is guaranteed to have completed.
3076f231ddaSDan Williams 	 */
3086f231ddaSDan Williams 	struct completion *io_request_completion;
30967ea838dSDan Williams 	struct scic_sds_request sci;
3106f231ddaSDan Williams };
3116f231ddaSDan Williams 
31267ea838dSDan Williams static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_req)
31367ea838dSDan Williams {
31467ea838dSDan Williams 	struct isci_request *ireq = container_of(sci_req, typeof(*ireq), sci);
31567ea838dSDan Williams 
31667ea838dSDan Williams 	return ireq;
31767ea838dSDan Williams }
31867ea838dSDan Williams 
3196f231ddaSDan Williams /**
320f1f52e75SDan Williams  * enum sci_base_request_states - This enumeration depicts all the states for
321f1f52e75SDan Williams  *    the common request state machine.
322f1f52e75SDan Williams  *
323f1f52e75SDan Williams  *
324f1f52e75SDan Williams  */
325f1f52e75SDan Williams enum sci_base_request_states {
326*e301370aSEdmund Nadolski 	/*
327f1f52e75SDan Williams 	 * Simply the initial state for the base request state machine.
328f1f52e75SDan Williams 	 */
329*e301370aSEdmund Nadolski 	SCI_REQ_INIT,
330f1f52e75SDan Williams 
331*e301370aSEdmund Nadolski 	/*
332*e301370aSEdmund Nadolski 	 * This state indicates that the request has been constructed.
333*e301370aSEdmund Nadolski 	 * This state is entered from the INITIAL state.
334f1f52e75SDan Williams 	 */
335*e301370aSEdmund Nadolski 	SCI_REQ_CONSTRUCTED,
336f1f52e75SDan Williams 
337*e301370aSEdmund Nadolski 	/*
338*e301370aSEdmund Nadolski 	 * This state indicates that the request has been started. This state
339*e301370aSEdmund Nadolski 	 * is entered from the CONSTRUCTED state.
340f1f52e75SDan Williams 	 */
341*e301370aSEdmund Nadolski 	SCI_REQ_STARTED,
342f1f52e75SDan Williams 
343*e301370aSEdmund Nadolski 	SCI_REQ_STP_UDMA_WAIT_TC_COMP,
344*e301370aSEdmund Nadolski 	SCI_REQ_STP_UDMA_WAIT_D2H,
3455dec6f4eSDan Williams 
346*e301370aSEdmund Nadolski 	SCI_REQ_STP_NON_DATA_WAIT_H2D,
347*e301370aSEdmund Nadolski 	SCI_REQ_STP_NON_DATA_WAIT_D2H,
3485dec6f4eSDan Williams 
349*e301370aSEdmund Nadolski 	SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED,
350*e301370aSEdmund Nadolski 	SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG,
351*e301370aSEdmund Nadolski 	SCI_REQ_STP_SOFT_RESET_WAIT_D2H,
3525dec6f4eSDan Williams 
353*e301370aSEdmund Nadolski 	/*
354*e301370aSEdmund Nadolski 	 * While in this state the IO request object is waiting for the TC
355*e301370aSEdmund Nadolski 	 * completion notification for the H2D Register FIS
3565dec6f4eSDan Williams 	 */
357*e301370aSEdmund Nadolski 	SCI_REQ_STP_PIO_WAIT_H2D,
3585dec6f4eSDan Williams 
359*e301370aSEdmund Nadolski 	/*
360*e301370aSEdmund Nadolski 	 * While in this state the IO request object is waiting for either a
361*e301370aSEdmund Nadolski 	 * PIO Setup FIS or a D2H register FIS.  The type of frame received is
362*e301370aSEdmund Nadolski 	 * based on the result of the prior frame and line conditions.
3635dec6f4eSDan Williams 	 */
364*e301370aSEdmund Nadolski 	SCI_REQ_STP_PIO_WAIT_FRAME,
3655dec6f4eSDan Williams 
366*e301370aSEdmund Nadolski 	/*
367*e301370aSEdmund Nadolski 	 * While in this state the IO request object is waiting for a DATA
368*e301370aSEdmund Nadolski 	 * frame from the device.
3695dec6f4eSDan Williams 	 */
370*e301370aSEdmund Nadolski 	SCI_REQ_STP_PIO_DATA_IN,
3715dec6f4eSDan Williams 
372*e301370aSEdmund Nadolski 	/*
373*e301370aSEdmund Nadolski 	 * While in this state the IO request object is waiting to transmit
374*e301370aSEdmund Nadolski 	 * the next data frame to the device.
3755dec6f4eSDan Williams 	 */
376*e301370aSEdmund Nadolski 	SCI_REQ_STP_PIO_DATA_OUT,
3775dec6f4eSDan Williams 
378*e301370aSEdmund Nadolski 	/*
379f139303dSDan Williams 	 * The AWAIT_TC_COMPLETION sub-state indicates that the started raw
380f139303dSDan Williams 	 * task management request is waiting for the transmission of the
381f139303dSDan Williams 	 * initial frame (i.e. command, task, etc.).
382f139303dSDan Williams 	 */
383*e301370aSEdmund Nadolski 	SCI_REQ_TASK_WAIT_TC_COMP,
384f139303dSDan Williams 
385*e301370aSEdmund Nadolski 	/*
386f139303dSDan Williams 	 * This sub-state indicates that the started task management request
387f139303dSDan Williams 	 * is waiting for the reception of an unsolicited frame
388f139303dSDan Williams 	 * (i.e. response IU).
389f139303dSDan Williams 	 */
390*e301370aSEdmund Nadolski 	SCI_REQ_TASK_WAIT_TC_RESP,
391f139303dSDan Williams 
392*e301370aSEdmund Nadolski 	/*
393c72086e3SDan Williams 	 * This sub-state indicates that the started task management request
394c72086e3SDan Williams 	 * is waiting for the reception of an unsolicited frame
395c72086e3SDan Williams 	 * (i.e. response IU).
396c72086e3SDan Williams 	 */
397*e301370aSEdmund Nadolski 	SCI_REQ_SMP_WAIT_RESP,
398c72086e3SDan Williams 
399*e301370aSEdmund Nadolski 	/*
400*e301370aSEdmund Nadolski 	 * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP
401*e301370aSEdmund Nadolski 	 * request is waiting for the transmission of the initial frame
402*e301370aSEdmund Nadolski 	 * (i.e. command, task, etc.).
403c72086e3SDan Williams 	 */
404*e301370aSEdmund Nadolski 	SCI_REQ_SMP_WAIT_TC_COMP,
405c72086e3SDan Williams 
406*e301370aSEdmund Nadolski 	/*
407f1f52e75SDan Williams 	 * This state indicates that the request has completed.
408*e301370aSEdmund Nadolski 	 * This state is entered from the STARTED state. This state is entered
409*e301370aSEdmund Nadolski 	 * from the ABORTING state.
410f1f52e75SDan Williams 	 */
411*e301370aSEdmund Nadolski 	SCI_REQ_COMPLETED,
412f1f52e75SDan Williams 
413*e301370aSEdmund Nadolski 	/*
414f1f52e75SDan Williams 	 * This state indicates that the request is in the process of being
415f1f52e75SDan Williams 	 * terminated/aborted.
416f1f52e75SDan Williams 	 * This state is entered from the CONSTRUCTED state.
417f1f52e75SDan Williams 	 * This state is entered from the STARTED state.
418f1f52e75SDan Williams 	 */
419*e301370aSEdmund Nadolski 	SCI_REQ_ABORTING,
420f1f52e75SDan Williams 
421*e301370aSEdmund Nadolski 	/*
422f1f52e75SDan Williams 	 * Simply the final state for the base request state machine.
423f1f52e75SDan Williams 	 */
424*e301370aSEdmund Nadolski 	SCI_REQ_FINAL,
425f1f52e75SDan Williams };
426f1f52e75SDan Williams 
427f1f52e75SDan Williams /**
428f1f52e75SDan Williams  * scic_sds_request_get_controller() -
429f1f52e75SDan Williams  *
430f1f52e75SDan Williams  * This macro will return the controller for this io request object
431f1f52e75SDan Williams  */
432f1f52e75SDan Williams #define scic_sds_request_get_controller(sci_req) \
433f1f52e75SDan Williams 	((sci_req)->owning_controller)
434f1f52e75SDan Williams 
435f1f52e75SDan Williams /**
436f1f52e75SDan Williams  * scic_sds_request_get_device() -
437f1f52e75SDan Williams  *
438f1f52e75SDan Williams  * This macro will return the device for this io request object
439f1f52e75SDan Williams  */
440f1f52e75SDan Williams #define scic_sds_request_get_device(sci_req) \
441f1f52e75SDan Williams 	((sci_req)->target_device)
442f1f52e75SDan Williams 
443f1f52e75SDan Williams /**
444f1f52e75SDan Williams  * scic_sds_request_get_port() -
445f1f52e75SDan Williams  *
446f1f52e75SDan Williams  * This macro will return the port for this io request object
447f1f52e75SDan Williams  */
448f1f52e75SDan Williams #define scic_sds_request_get_port(sci_req)	\
449f1f52e75SDan Williams 	scic_sds_remote_device_get_port(scic_sds_request_get_device(sci_req))
450f1f52e75SDan Williams 
451f1f52e75SDan Williams /**
452f1f52e75SDan Williams  * scic_sds_request_get_post_context() -
453f1f52e75SDan Williams  *
454f1f52e75SDan Williams  * This macro returns the constructed post context result for the io request.
455f1f52e75SDan Williams  */
456f1f52e75SDan Williams #define scic_sds_request_get_post_context(sci_req)	\
457f1f52e75SDan Williams 	((sci_req)->post_context)
458f1f52e75SDan Williams 
459f1f52e75SDan Williams /**
460f1f52e75SDan Williams  * scic_sds_request_get_task_context() -
461f1f52e75SDan Williams  *
462f1f52e75SDan Williams  * This is a helper macro to return the os handle for this request object.
463f1f52e75SDan Williams  */
464f1f52e75SDan Williams #define scic_sds_request_get_task_context(request) \
465f1f52e75SDan Williams 	((request)->task_context_buffer)
466f1f52e75SDan Williams 
467f1f52e75SDan Williams /**
468f1f52e75SDan Williams  * scic_sds_request_set_status() -
469f1f52e75SDan Williams  *
470f1f52e75SDan Williams  * This macro will set the scu hardware status and sci request completion
471f1f52e75SDan Williams  * status for an io request.
472f1f52e75SDan Williams  */
473f1f52e75SDan Williams #define scic_sds_request_set_status(request, scu_status_code, sci_status_code) \
474f1f52e75SDan Williams 	{ \
475f1f52e75SDan Williams 		(request)->scu_status = (scu_status_code); \
476f1f52e75SDan Williams 		(request)->sci_status = (sci_status_code); \
477f1f52e75SDan Williams 	}
478f1f52e75SDan Williams 
479f1f52e75SDan Williams /**
480f1f52e75SDan Williams  * SCU_SGL_ZERO() -
481f1f52e75SDan Williams  *
482f1f52e75SDan Williams  * This macro zeros the hardware SGL element data
483f1f52e75SDan Williams  */
484f1f52e75SDan Williams #define SCU_SGL_ZERO(scu_sge) \
485f1f52e75SDan Williams 	{ \
486f1f52e75SDan Williams 		(scu_sge).length = 0; \
487f1f52e75SDan Williams 		(scu_sge).address_lower = 0; \
488f1f52e75SDan Williams 		(scu_sge).address_upper = 0; \
489f1f52e75SDan Williams 		(scu_sge).address_modifier = 0;	\
490f1f52e75SDan Williams 	}
491f1f52e75SDan Williams 
492f1f52e75SDan Williams /**
493f1f52e75SDan Williams  * SCU_SGL_COPY() -
494f1f52e75SDan Williams  *
495f1f52e75SDan Williams  * This macro copys the SGL Element data from the host os to the hardware SGL
496f1f52e75SDan Williams  * elment data
497f1f52e75SDan Williams  */
498f1f52e75SDan Williams #define SCU_SGL_COPY(scu_sge, os_sge) \
499f1f52e75SDan Williams 	{ \
500f1f52e75SDan Williams 		(scu_sge).length = sg_dma_len(sg); \
501f1f52e75SDan Williams 		(scu_sge).address_upper = \
502f1f52e75SDan Williams 			upper_32_bits(sg_dma_address(sg)); \
503f1f52e75SDan Williams 		(scu_sge).address_lower = \
504f1f52e75SDan Williams 			lower_32_bits(sg_dma_address(sg)); \
505f1f52e75SDan Williams 		(scu_sge).address_modifier = 0;	\
506f1f52e75SDan Williams 	}
507f1f52e75SDan Williams 
508f1f52e75SDan Williams enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req);
509f1f52e75SDan Williams enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req);
510*e301370aSEdmund Nadolski enum sci_status
511*e301370aSEdmund Nadolski scic_sds_io_request_event_handler(struct scic_sds_request *sci_req,
512f1f52e75SDan Williams 				  u32 event_code);
513*e301370aSEdmund Nadolski enum sci_status
514*e301370aSEdmund Nadolski scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req,
515f1f52e75SDan Williams 				  u32 frame_index);
516*e301370aSEdmund Nadolski enum sci_status
517*e301370aSEdmund Nadolski scic_sds_task_request_terminate(struct scic_sds_request *sci_req);
518*e301370aSEdmund Nadolski extern enum sci_status
519*e301370aSEdmund Nadolski scic_sds_request_complete(struct scic_sds_request *sci_req);
520*e301370aSEdmund Nadolski extern enum sci_status
521*e301370aSEdmund Nadolski scic_sds_io_request_tc_completion(struct scic_sds_request *sci_req, u32 code);
522f1f52e75SDan Williams 
523f1f52e75SDan Williams /* XXX open code in caller */
524f1f52e75SDan Williams static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req,
525f1f52e75SDan Williams 					       dma_addr_t phys_addr)
526f1f52e75SDan Williams {
527f1f52e75SDan Williams 	struct isci_request *ireq = sci_req_to_ireq(sci_req);
528f1f52e75SDan Williams 	dma_addr_t offset;
529f1f52e75SDan Williams 
530f1f52e75SDan Williams 	BUG_ON(phys_addr < ireq->request_daddr);
531f1f52e75SDan Williams 
532f1f52e75SDan Williams 	offset = phys_addr - ireq->request_daddr;
533f1f52e75SDan Williams 
534f1f52e75SDan Williams 	BUG_ON(offset >= sizeof(*ireq));
535f1f52e75SDan Williams 
536f1f52e75SDan Williams 	return (char *)ireq + offset;
537f1f52e75SDan Williams }
538f1f52e75SDan Williams 
539f1f52e75SDan Williams /* XXX open code in caller */
540*e301370aSEdmund Nadolski static inline dma_addr_t
541*e301370aSEdmund Nadolski scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, void *virt_addr)
542f1f52e75SDan Williams {
543f1f52e75SDan Williams 	struct isci_request *ireq = sci_req_to_ireq(sci_req);
544f1f52e75SDan Williams 
545f1f52e75SDan Williams 	char *requested_addr = (char *)virt_addr;
546f1f52e75SDan Williams 	char *base_addr = (char *)ireq;
547f1f52e75SDan Williams 
548f1f52e75SDan Williams 	BUG_ON(requested_addr < base_addr);
549f1f52e75SDan Williams 	BUG_ON((requested_addr - base_addr) >= sizeof(*ireq));
550f1f52e75SDan Williams 
551f1f52e75SDan Williams 	return ireq->request_daddr + (requested_addr - base_addr);
552f1f52e75SDan Williams }
553f1f52e75SDan Williams 
554f1f52e75SDan Williams /**
5556f231ddaSDan Williams  * This function gets the status of the request object.
5566f231ddaSDan Williams  * @request: This parameter points to the isci_request object
5576f231ddaSDan Williams  *
5586f231ddaSDan Williams  * status of the object as a isci_request_status enum.
5596f231ddaSDan Williams  */
560*e301370aSEdmund Nadolski static inline enum isci_request_status
561*e301370aSEdmund Nadolski isci_request_get_state(struct isci_request *isci_request)
5626f231ddaSDan Williams {
5636f231ddaSDan Williams 	BUG_ON(isci_request == NULL);
5646f231ddaSDan Williams 
5656f231ddaSDan Williams 	/*probably a bad sign...	*/
5666f231ddaSDan Williams 	if (isci_request->status == unallocated)
5676f231ddaSDan Williams 		dev_warn(&isci_request->isci_host->pdev->dev,
5686f231ddaSDan Williams 			 "%s: isci_request->status == unallocated\n",
5696f231ddaSDan Williams 			 __func__);
5706f231ddaSDan Williams 
5716f231ddaSDan Williams 	return isci_request->status;
5726f231ddaSDan Williams }
5736f231ddaSDan Williams 
5746f231ddaSDan Williams 
5756f231ddaSDan Williams /**
5766f231ddaSDan Williams  * isci_request_change_state() - This function sets the status of the request
5776f231ddaSDan Williams  *    object.
5786f231ddaSDan Williams  * @request: This parameter points to the isci_request object
5796f231ddaSDan Williams  * @status: This Parameter is the new status of the object
5806f231ddaSDan Williams  *
5816f231ddaSDan Williams  */
582*e301370aSEdmund Nadolski static inline enum isci_request_status
583*e301370aSEdmund Nadolski isci_request_change_state(struct isci_request *isci_request,
5846f231ddaSDan Williams 			  enum isci_request_status status)
5856f231ddaSDan Williams {
5866f231ddaSDan Williams 	enum isci_request_status old_state;
5876f231ddaSDan Williams 	unsigned long flags;
5886f231ddaSDan Williams 
5896f231ddaSDan Williams 	dev_dbg(&isci_request->isci_host->pdev->dev,
5906f231ddaSDan Williams 		"%s: isci_request = %p, state = 0x%x\n",
5916f231ddaSDan Williams 		__func__,
5926f231ddaSDan Williams 		isci_request,
5936f231ddaSDan Williams 		status);
5946f231ddaSDan Williams 
5956f231ddaSDan Williams 	BUG_ON(isci_request == NULL);
5966f231ddaSDan Williams 
5976f231ddaSDan Williams 	spin_lock_irqsave(&isci_request->state_lock, flags);
5986f231ddaSDan Williams 	old_state = isci_request->status;
5996f231ddaSDan Williams 	isci_request->status = status;
6006f231ddaSDan Williams 	spin_unlock_irqrestore(&isci_request->state_lock, flags);
6016f231ddaSDan Williams 
6026f231ddaSDan Williams 	return old_state;
6036f231ddaSDan Williams }
6046f231ddaSDan Williams 
6056f231ddaSDan Williams /**
6066f231ddaSDan Williams  * isci_request_change_started_to_newstate() - This function sets the status of
6076f231ddaSDan Williams  *    the request object.
6086f231ddaSDan Williams  * @request: This parameter points to the isci_request object
6096f231ddaSDan Williams  * @status: This Parameter is the new status of the object
6106f231ddaSDan Williams  *
6116f231ddaSDan Williams  * state previous to any change.
6126f231ddaSDan Williams  */
613*e301370aSEdmund Nadolski static inline enum isci_request_status
614*e301370aSEdmund Nadolski isci_request_change_started_to_newstate(struct isci_request *isci_request,
6156f231ddaSDan Williams 					struct completion *completion_ptr,
6166f231ddaSDan Williams 					enum isci_request_status newstate)
6176f231ddaSDan Williams {
6186f231ddaSDan Williams 	enum isci_request_status old_state;
6196f231ddaSDan Williams 	unsigned long flags;
6206f231ddaSDan Williams 
6216f231ddaSDan Williams 	spin_lock_irqsave(&isci_request->state_lock, flags);
6226f231ddaSDan Williams 
6236f231ddaSDan Williams 	old_state = isci_request->status;
6246f231ddaSDan Williams 
625f219f010SJeff Skirvin 	if (old_state == started || old_state == aborting) {
6266f231ddaSDan Williams 		BUG_ON(isci_request->io_request_completion != NULL);
6276f231ddaSDan Williams 
6286f231ddaSDan Williams 		isci_request->io_request_completion = completion_ptr;
6296f231ddaSDan Williams 		isci_request->status = newstate;
6306f231ddaSDan Williams 	}
631*e301370aSEdmund Nadolski 
6326f231ddaSDan Williams 	spin_unlock_irqrestore(&isci_request->state_lock, flags);
6336f231ddaSDan Williams 
6346f231ddaSDan Williams 	dev_dbg(&isci_request->isci_host->pdev->dev,
6356f231ddaSDan Williams 		"%s: isci_request = %p, old_state = 0x%x\n",
6366f231ddaSDan Williams 		__func__,
6376f231ddaSDan Williams 		isci_request,
6386f231ddaSDan Williams 		old_state);
6396f231ddaSDan Williams 
6406f231ddaSDan Williams 	return old_state;
6416f231ddaSDan Williams }
6426f231ddaSDan Williams 
6436f231ddaSDan Williams /**
6446f231ddaSDan Williams  * isci_request_change_started_to_aborted() - This function sets the status of
6456f231ddaSDan Williams  *    the request object.
6466f231ddaSDan Williams  * @request: This parameter points to the isci_request object
6476f231ddaSDan Williams  * @completion_ptr: This parameter is saved as the kernel completion structure
6486f231ddaSDan Williams  *    signalled when the old request completes.
6496f231ddaSDan Williams  *
6506f231ddaSDan Williams  * state previous to any change.
6516f231ddaSDan Williams  */
652*e301370aSEdmund Nadolski static inline enum isci_request_status
653*e301370aSEdmund Nadolski isci_request_change_started_to_aborted(struct isci_request *isci_request,
6546f231ddaSDan Williams 				       struct completion *completion_ptr)
6556f231ddaSDan Williams {
656*e301370aSEdmund Nadolski 	return isci_request_change_started_to_newstate(isci_request,
657*e301370aSEdmund Nadolski 						       completion_ptr,
658*e301370aSEdmund Nadolski 						       aborted);
6596f231ddaSDan Williams }
6606f231ddaSDan Williams /**
6616f231ddaSDan Williams  * isci_request_free() - This function frees the request object.
6626f231ddaSDan Williams  * @isci_host: This parameter specifies the ISCI host object
6636f231ddaSDan Williams  * @isci_request: This parameter points to the isci_request object
6646f231ddaSDan Williams  *
6656f231ddaSDan Williams  */
666*e301370aSEdmund Nadolski static inline void isci_request_free(struct isci_host *isci_host,
6676f231ddaSDan Williams 				     struct isci_request *isci_request)
6686f231ddaSDan Williams {
6696cb4d6b3SBartosz Barcinski 	if (!isci_request)
6706cb4d6b3SBartosz Barcinski 		return;
6716f231ddaSDan Williams 
6726f231ddaSDan Williams 	/* release the dma memory if we fail. */
673*e301370aSEdmund Nadolski 	dma_pool_free(isci_host->dma_pool,
674*e301370aSEdmund Nadolski 		      isci_request,
6756f231ddaSDan Williams 		      isci_request->request_daddr);
6766f231ddaSDan Williams }
6776f231ddaSDan Williams 
678*e301370aSEdmund Nadolski #define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr)
6796f231ddaSDan Williams 
680*e301370aSEdmund Nadolski #define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr)
6816f231ddaSDan Williams 
682*e301370aSEdmund Nadolski int isci_request_alloc_tmf(struct isci_host *isci_host,
6836f231ddaSDan Williams 			   struct isci_tmf *isci_tmf,
6846f231ddaSDan Williams 			   struct isci_request **isci_request,
6856f231ddaSDan Williams 			   struct isci_remote_device *isci_device,
6866f231ddaSDan Williams 			   gfp_t gfp_flags);
6876f231ddaSDan Williams 
6886f231ddaSDan Williams 
689*e301370aSEdmund Nadolski int isci_request_execute(struct isci_host *isci_host,
6906f231ddaSDan Williams 			 struct sas_task *task,
6916f231ddaSDan Williams 			 struct isci_request **request,
6926f231ddaSDan Williams 			 gfp_t gfp_flags);
6936f231ddaSDan Williams 
6946f231ddaSDan Williams /**
6956f231ddaSDan Williams  * isci_request_unmap_sgl() - This function unmaps the DMA address of a given
6966f231ddaSDan Williams  *    sgl
6976f231ddaSDan Williams  * @request: This parameter points to the isci_request object
6986f231ddaSDan Williams  * @*pdev: This Parameter is the pci_device struct for the controller
6996f231ddaSDan Williams  *
7006f231ddaSDan Williams  */
701*e301370aSEdmund Nadolski static inline void
702*e301370aSEdmund Nadolski isci_request_unmap_sgl(struct isci_request *request, struct pci_dev *pdev)
7036f231ddaSDan Williams {
7046f231ddaSDan Williams 	struct sas_task *task = isci_request_access_task(request);
7056f231ddaSDan Williams 
7066f231ddaSDan Williams 	dev_dbg(&request->isci_host->pdev->dev,
7076f231ddaSDan Williams 		"%s: request = %p, task = %p,\n"
7086f231ddaSDan Williams 		"task->data_dir = %d, is_sata = %d\n ",
7096f231ddaSDan Williams 		__func__,
7106f231ddaSDan Williams 		request,
7116f231ddaSDan Williams 		task,
7126f231ddaSDan Williams 		task->data_dir,
7136f231ddaSDan Williams 		sas_protocol_ata(task->task_proto));
7146f231ddaSDan Williams 
7156f231ddaSDan Williams 	if ((task->data_dir != PCI_DMA_NONE) &&
7166f231ddaSDan Williams 	    !sas_protocol_ata(task->task_proto)) {
7176f231ddaSDan Williams 		if (task->num_scatter == 0)
7186f231ddaSDan Williams 			/* 0 indicates a single dma address */
7196f231ddaSDan Williams 			dma_unmap_single(
7206f231ddaSDan Williams 				&pdev->dev,
7216f231ddaSDan Williams 				request->zero_scatter_daddr,
7226f231ddaSDan Williams 				task->total_xfer_len,
7236f231ddaSDan Williams 				task->data_dir
7246f231ddaSDan Williams 				);
7256f231ddaSDan Williams 
7266f231ddaSDan Williams 		else  /* unmap the sgl dma addresses */
7276f231ddaSDan Williams 			dma_unmap_sg(
7286f231ddaSDan Williams 				&pdev->dev,
7296f231ddaSDan Williams 				task->scatter,
7306f231ddaSDan Williams 				request->num_sg_entries,
7316f231ddaSDan Williams 				task->data_dir
7326f231ddaSDan Williams 				);
7336f231ddaSDan Williams 	}
7346f231ddaSDan Williams }
7356f231ddaSDan Williams 
7366f231ddaSDan Williams /**
7376f231ddaSDan Williams  * isci_request_io_request_get_next_sge() - This function is called by the sci
7386f231ddaSDan Williams  *    core to retrieve the next sge for a given request.
7396f231ddaSDan Williams  * @request: This parameter is the isci_request object.
7406f231ddaSDan Williams  * @current_sge_address: This parameter is the last sge retrieved by the sci
7416f231ddaSDan Williams  *    core for this request.
7426f231ddaSDan Williams  *
7436f231ddaSDan Williams  * pointer to the next sge for specified request.
7446f231ddaSDan Williams  */
745*e301370aSEdmund Nadolski static inline void *
746*e301370aSEdmund Nadolski isci_request_io_request_get_next_sge(struct isci_request *request,
7476f231ddaSDan Williams 				     void *current_sge_address)
7486f231ddaSDan Williams {
7496f231ddaSDan Williams 	struct sas_task *task = isci_request_access_task(request);
7506f231ddaSDan Williams 	void *ret = NULL;
7516f231ddaSDan Williams 
7526f231ddaSDan Williams 	dev_dbg(&request->isci_host->pdev->dev,
7536f231ddaSDan Williams 		"%s: request = %p, "
7546f231ddaSDan Williams 		"current_sge_address = %p, "
7556f231ddaSDan Williams 		"num_scatter = %d\n",
7566f231ddaSDan Williams 		__func__,
7576f231ddaSDan Williams 		request,
7586f231ddaSDan Williams 		current_sge_address,
7596f231ddaSDan Williams 		task->num_scatter);
7606f231ddaSDan Williams 
7616f231ddaSDan Williams 	if (!current_sge_address)	/* First time through.. */
7626f231ddaSDan Williams 		ret = task->scatter;    /* always task->scatter */
7636f231ddaSDan Williams 	else if (task->num_scatter == 0) /* Next element, if num_scatter == 0 */
7646f231ddaSDan Williams 		ret = NULL;              /* there is only one element. */
7656f231ddaSDan Williams 	else
7666f231ddaSDan Williams 		ret = sg_next(current_sge_address);     /* sg_next returns NULL
7676f231ddaSDan Williams 							 * for the last element
7686f231ddaSDan Williams 							 */
7696f231ddaSDan Williams 
7706f231ddaSDan Williams 	dev_dbg(&request->isci_host->pdev->dev,
7716f231ddaSDan Williams 		"%s: next sge address = %p\n",
7726f231ddaSDan Williams 		__func__,
7736f231ddaSDan Williams 		ret);
7746f231ddaSDan Williams 
7756f231ddaSDan Williams 	return ret;
7766f231ddaSDan Williams }
7776f231ddaSDan Williams 
778*e301370aSEdmund Nadolski void
779*e301370aSEdmund Nadolski isci_terminate_pending_requests(struct isci_host *isci_host,
7806f231ddaSDan Williams 				struct isci_remote_device *isci_device,
7816f231ddaSDan Williams 				enum isci_request_status new_request_state);
782*e301370aSEdmund Nadolski enum sci_status
783*e301370aSEdmund Nadolski scic_task_request_construct(struct scic_sds_controller *scic,
784f1f52e75SDan Williams 			    struct scic_sds_remote_device *sci_dev,
785f1f52e75SDan Williams 			    u16 io_tag,
786f1f52e75SDan Williams 			    struct scic_sds_request *sci_req);
787*e301370aSEdmund Nadolski enum sci_status
788*e301370aSEdmund Nadolski scic_task_request_construct_ssp(struct scic_sds_request *sci_req);
789*e301370aSEdmund Nadolski enum sci_status
790*e301370aSEdmund Nadolski scic_task_request_construct_sata(struct scic_sds_request *sci_req);
791*e301370aSEdmund Nadolski void
792*e301370aSEdmund Nadolski scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag);
793f1f52e75SDan Williams void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req);
7946f231ddaSDan Williams #endif /* !defined(_ISCI_REQUEST_H_) */
795